From b1564f7de0d1418d58b52a1daa3854d4e49cb91a Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 5 Sep 2024 08:52:57 +0200 Subject: [PATCH 1/5] EgtGeomKernel : - aggiunto un commento. --- SfrCreate.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SfrCreate.cpp b/SfrCreate.cpp index ab14894..5756dc1 100644 --- a/SfrCreate.cpp +++ b/SfrCreate.cpp @@ -580,6 +580,7 @@ CalcRegionPolyLines( const POLYLINEVECTOR& vPL, POLYLINEVECTOR& vPLOrd, Vector3d // matrice di interi : ogni riga corrisponde ad un chunk, dove in posizione 0 c'è il loop esterno e nelle // successive i loop interni //INTMATRIX vnPLIndMat ; + // vettore di bool : riferito al vettore originale delle polyline, riporta true se la polyline è stata invertita // ricavo versore normale Plane3d plPlane ; double dArea ; From 76dceb4fc9839b19ea1c78bb5e217a6d9e03f2ca Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 5 Sep 2024 08:52:57 +0200 Subject: [PATCH 2/5] EgtGeomKernel : - aggiunto un commento. --- SfrCreate.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SfrCreate.cpp b/SfrCreate.cpp index ab14894..5756dc1 100644 --- a/SfrCreate.cpp +++ b/SfrCreate.cpp @@ -580,6 +580,7 @@ CalcRegionPolyLines( const POLYLINEVECTOR& vPL, POLYLINEVECTOR& vPLOrd, Vector3d // matrice di interi : ogni riga corrisponde ad un chunk, dove in posizione 0 c'è il loop esterno e nelle // successive i loop interni //INTMATRIX vnPLIndMat ; + // vettore di bool : riferito al vettore originale delle polyline, riporta true se la polyline è stata invertita // ricavo versore normale Plane3d plPlane ; double dArea ; From ec6cb79a8df1b913cdc56c919e3801a22c7c544a Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 5 Sep 2024 11:37:24 +0200 Subject: [PATCH 3/5] EgtGeomKernel : - correzione alla SurfTmByRegionExtrusion - correzione alla SurfBzByScrewing. --- StmFromCurves.cpp | 2 +- SurfBezier.cpp | 9 ++++++--- Triangulate.cpp | 11 ++--------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/StmFromCurves.cpp b/StmFromCurves.cpp index e90cbab..dca6e90 100644 --- a/StmFromCurves.cpp +++ b/StmFromCurves.cpp @@ -167,7 +167,7 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d& // se componente estrusione negativa, inverto tutti i percorsi if ( dOrthoExtr < 0) { for ( int i = 0 ; i < int( vPL.size()) ; ++ i) - vPL[i].Invert() ; + vPLOrd[i].Invert() ; } // creo la prima superficie di estremità PtrOwner pSTM( CreateBasicSurfTriMesh()) ; diff --git a/SurfBezier.cpp b/SurfBezier.cpp index 5987782..27c565a 100644 --- a/SurfBezier.cpp +++ b/SurfBezier.cpp @@ -3782,7 +3782,7 @@ SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const V // se sto facendo una rivoluzione e la curva è piana faccio un controllo // se la curva attraversa l'asse allora mi fermo - if ( dMove < EPS_SMALL ) { + if ( abs( dMove) < EPS_SMALL ) { Plane3d plPlane ; if ( pCurve->IsFlat(plPlane, false, EPS_SMALL) ) { PtrOwner pAx( CreateCurveLine()) ; @@ -3827,7 +3827,7 @@ SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const V const ICurveBezier* pSubCrvBezU = GetCurveBezier( pCrvU->GetCurve( j)) ; for ( int i = 0 ; i < nDegU + 1 && ! bFound ; ++i) { Point3d ptCtrlU = pSubCrvBezU->GetControlPoint( i) ; - DistPointLine dpl( ptCtrlU, ptAx, vtAx, 0, false) ; + DistPointLine dpl( ptCtrlU, ptAx, vtAx, 1, false) ; if ( ! dpl.IsSmall()) { PtrOwner pSpiral( CreateCurveArc()) ; pSpiral->SetCPAN( ptAx, ptCtrlU, dAngRotDeg, dMove, vtAx) ; @@ -3914,7 +3914,7 @@ SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const V ICurve* pSpiralBezier( ArcToBezierCurve( pSpiral)) ; // converto in curva bezier di grado 3 perché l'arco è una spirale pCrvV->AddCurve( pSpiralBezier) ; } - else if ( dMove > EPS_SMALL){ + else if ( abs( dMove) > EPS_SMALL){ // creo un segmento in forma bezier con il giusto numero di span PtrOwner pCL( CreateBasicCurveLine()) ; pCL->Set( ptCtrlU, ptCtrlU + vtAx * dMove) ; @@ -3939,6 +3939,9 @@ SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const V for ( int j = 0 ; j < nSpanV ; ++j) pCrvV->AddCurve( pCrvBezier->Clone()) ; } + + if( ! pCrvV->IsValid()) + return false ; // aggiungo i punti di controllo // scorro le sottocurve della spirale diff --git a/Triangulate.cpp b/Triangulate.cpp index ce3f8a2..ae8e10d 100644 --- a/Triangulate.cpp +++ b/Triangulate.cpp @@ -249,15 +249,8 @@ Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVEC return false ; } else { - //for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) { - // for ( int j = 0 ; j < int( vnPLIndMat[i].size()) ; ++j ) { - // vPL.push_back( vPLORIG[vnPLIndMat[i][j]]) ; - // if( vbInvert[vnPLIndMat[i][j]]) - // vPL.back().Invert() ; - // } - //} - - // ho gi� calcolato e riordinato tutto, devo solo fare una copia delle polyline + // ho già calcolato e riordinato tutto, devo solo fare una copia delle polyline + // non serve fare le eventuali inversioni delle polyline, perché se è già stata calcolata la matrice dei chunck allora sono GIà state invertire vPL = vPLORIG ; vnPLIndMat = vnPLIndMatPre ; } From aa2b6ccde54b276fb9cafd48ad46bc4aed3d4c84 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 5 Sep 2024 12:09:28 +0200 Subject: [PATCH 4/5] EgtGeomKernel : - modifica degli argomenti della funzione CalcRegionPolyLines. --- SbzFromCurves.cpp | 11 +++++++++-- SfrCreate.cpp | 19 +------------------ StmFromCurves.cpp | 23 ++++++++++++++++------- Triangulate.cpp | 11 +++++++++-- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/SbzFromCurves.cpp b/SbzFromCurves.cpp index aa2d01f..09bcf8d 100644 --- a/SbzFromCurves.cpp +++ b/SbzFromCurves.cpp @@ -63,7 +63,6 @@ GetSurfBezierByRegion( const CICURVEPVECTOR& vpCurve, double dLinTol) if ( &vpCurve == nullptr || vpCurve.empty()) return nullptr ; // calcolo le polilinee che approssimano le curve della regione - POLYLINEVECTOR vPLOrd ; POLYLINEVECTOR vPL ; vPL.resize( vpCurve.size()) ; for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) { @@ -73,8 +72,16 @@ GetSurfBezierByRegion( const CICURVEPVECTOR& vpCurve, double dLinTol) Vector3d vtN ; INTMATRIX vnPLIndMat ; BOOLVECTOR vbInvert ; - if ( ! CalcRegionPolyLines( vPL, vPLOrd, vtN, vnPLIndMat,vbInvert)) + if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat,vbInvert)) return nullptr ; + POLYLINEVECTOR vPLOrd ; + for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) { + for ( int j = 0 ; j < int( vnPLIndMat[i].size()) ; ++j){ + vPLOrd.push_back(vPL[vnPLIndMat[i][j]]) ; + if( vbInvert[vnPLIndMat[i][j]]) + vPLOrd.back().Invert() ; + } + } // creo e setto la superficie di bezier PtrOwner pSbz( CreateBasicSurfBezier()) ; if ( IsNull( pSbz) || ! pSbz->CreateByRegion( vPLOrd)) diff --git a/SfrCreate.cpp b/SfrCreate.cpp index 5756dc1..86477c1 100644 --- a/SfrCreate.cpp +++ b/SfrCreate.cpp @@ -635,7 +635,6 @@ CalcRegionPolyLines( const POLYLINEVECTOR& vPL, POLYLINEVECTOR& vPLOrd, Vector3d vPL_IndOrder[i] = m_vArea[i].first ; // aggiungo le diverse curve - vPLOrd = vPL ; bool bFirstCrv ; Plane3d plExtLoop ; double dAreaExtLoop = 0. ; @@ -655,7 +654,6 @@ CalcRegionPolyLines( const POLYLINEVECTOR& vPL, POLYLINEVECTOR& vPLOrd, Vector3d dAreaExtLoop = m_vArea[i].second ; // inverto se necessario if ( m_vArea[i].second < EPS_SMALL) { - vPLOrd[j].Invert() ; vCrvCompo[j]->Invert() ; dAreaExtLoop *= -1 ; vbInvert[j] = true ; @@ -691,7 +689,6 @@ CalcRegionPolyLines( const POLYLINEVECTOR& vPL, POLYLINEVECTOR& vPLOrd, Vector3d m_vArea[i].first = -1 ; // inverto se necessario if ( m_vArea[i].second * dAreaExtLoop > 0.) { - vPLOrd[j].Invert() ; vCrvCompo[j]->Invert() ; vbInvert[j] = true ; } @@ -701,23 +698,9 @@ CalcRegionPolyLines( const POLYLINEVECTOR& vPL, POLYLINEVECTOR& vPLOrd, Vector3d } while ( ! bFirstCrv) ; if ( bInvertAll) { - for ( int i = 0 ; i < int( vPLOrd.size()) ; ++i) { - vPLOrd[i].Invert() ; + for ( int i = 0 ; i < int( vPL.size()) ; ++i) vbInvert[i] = ! vbInvert[i] ; - } } - //// ordino le PolyLine per area - // POLYLINEVECTOR vPL_tmp ; - // for ( int i = 0 ; i < int( vPL_IndOrder.size()) ; ++ i) - // vPL_tmp.push_back( vPLOrd[ vPL_IndOrder[i]]) ; - - //for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) { - // for ( int j = 0 ; j < int( vnPLIndMat[i].size()) ; ++j ) { - // vPL_tmp.push_back( vPLOrd[vnPLIndMat[i][j]]) ; - // } - //} - //swap( vPLOrd, vPL_tmp) ; - return true ; } diff --git a/StmFromCurves.cpp b/StmFromCurves.cpp index dca6e90..9283b9e 100644 --- a/StmFromCurves.cpp +++ b/StmFromCurves.cpp @@ -60,7 +60,6 @@ GetSurfTriMeshByRegion( const CICURVEPVECTOR& vpCurve, double dLinTol) if ( &vpCurve == nullptr || vpCurve.empty()) return nullptr ; // calcolo le polilinee che approssimano le curve della regione - POLYLINEVECTOR vPLOrd ; POLYLINEVECTOR vPL ; vPL.resize( vpCurve.size()) ; for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) { @@ -70,11 +69,17 @@ GetSurfTriMeshByRegion( const CICURVEPVECTOR& vpCurve, double dLinTol) Vector3d vtN ; INTMATRIX vnPLIndMat ; BOOLVECTOR vbInvert ; - if ( ! CalcRegionPolyLines( vPL, vPLOrd, vtN, vnPLIndMat, vbInvert)) + if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat, vbInvert)) return nullptr ; + for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) { + for ( int j = 0 ; j < int( vnPLIndMat[i].size()) ; ++j){ + if( vbInvert[vnPLIndMat[i][j]]) + vPL[vnPLIndMat[i][j]].Invert() ; + } + } // creo e setto la superficie trimesh PtrOwner pSTM( CreateBasicSurfTriMesh()) ; - if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPLOrd, vnPLIndMat)) + if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL, vnPLIndMat)) return nullptr ; // salvo tolleranza lineare usata pSTM->SetLinearTolerance( dLinTol) ; @@ -149,7 +154,6 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d& return GetSurfTriMeshByExtrusion( vpCurve[0], vtExtr, true, dLinTol) ; // calcolo le polilinee che approssimano le curve della regione POLYLINEVECTOR vPL ; - POLYLINEVECTOR vPLOrd ; vPL.resize( vpCurve.size()) ; for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) { if ( ! vpCurve[i]->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, vPL[i])) @@ -158,8 +162,12 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d& Vector3d vtN ; INTMATRIX vnPLIndMat ; BOOLVECTOR vbInvert ; - if ( ! CalcRegionPolyLines( vPL, vPLOrd, vtN, vnPLIndMat, vbInvert)) + if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat, vbInvert)) return nullptr ; + for ( int i = 0 ; i < int( vPL.size()) ; ++i) { + if( vbInvert[i]) + vPL[i].Invert() ; + } // verifico la direzione di estrusione double dOrthoExtr = vtN * vtExtr ; if ( ( abs( dOrthoExtr) < EPS_SMALL)) @@ -167,11 +175,12 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d& // se componente estrusione negativa, inverto tutti i percorsi if ( dOrthoExtr < 0) { for ( int i = 0 ; i < int( vPL.size()) ; ++ i) - vPLOrd[i].Invert() ; + vPL[i].Invert() ; } // creo la prima superficie di estremità PtrOwner pSTM( CreateBasicSurfTriMesh()) ; - if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPLOrd, vnPLIndMat)) + // alla funzione CreateByRegion passo anche la matrice che contiene la struttura dei chunk. Le polyline hanno già il verso giusto + if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL, vnPLIndMat)) return nullptr ; // creo la seconda superficie e la unisco alla prima { // copio la prima superficie diff --git a/Triangulate.cpp b/Triangulate.cpp index ae8e10d..53c3a5c 100644 --- a/Triangulate.cpp +++ b/Triangulate.cpp @@ -245,13 +245,20 @@ Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVEC INTMATRIX vnPLIndMat ; BOOLVECTOR vbInvert ; if( vnPLIndMatPre.size() == 0){ - if ( ! CalcRegionPolyLines( vPLORIG, vPL, vtN, vnPLIndMat, vbInvert)) + if ( ! CalcRegionPolyLines( vPLORIG, vtN, vnPLIndMat, vbInvert)) return false ; + vPL = vPLORIG ; + for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) { + for ( int j = 0 ; j < int( vnPLIndMat[i].size()) ; ++j){ + if( vbInvert[vnPLIndMat[i][j]]) + vPL.back().Invert() ; + } + } } else { // ho già calcolato e riordinato tutto, devo solo fare una copia delle polyline // non serve fare le eventuali inversioni delle polyline, perché se è già stata calcolata la matrice dei chunck allora sono GIà state invertire - vPL = vPLORIG ; + vPL = &vPLORIG ; vnPLIndMat = vnPLIndMatPre ; } From 8e2226747626454a6021b0144d4a05bdc4cb5d34 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 5 Sep 2024 12:13:28 +0200 Subject: [PATCH 5/5] EgtGeomKernel : - piccole correzioni. --- SfrCreate.cpp | 2 +- StmFromCurves.cpp | 2 +- Triangulate.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SfrCreate.cpp b/SfrCreate.cpp index 86477c1..4d576d8 100644 --- a/SfrCreate.cpp +++ b/SfrCreate.cpp @@ -575,7 +575,7 @@ SurfFlatRegionByContours::GetUnusedCurveTempProps( INTVECTOR& vId) //------------------------------------------------------------------------------- bool -CalcRegionPolyLines( const POLYLINEVECTOR& vPL, POLYLINEVECTOR& vPLOrd, Vector3d& vtN, INTMATRIX& vnPLIndMat, BOOLVECTOR& vbInvert) +CalcRegionPolyLines( const POLYLINEVECTOR& vPL, Vector3d& vtN, INTMATRIX& vnPLIndMat, BOOLVECTOR& vbInvert) { // matrice di interi : ogni riga corrisponde ad un chunk, dove in posizione 0 c'è il loop esterno e nelle // successive i loop interni diff --git a/StmFromCurves.cpp b/StmFromCurves.cpp index 9283b9e..a35ed06 100644 --- a/StmFromCurves.cpp +++ b/StmFromCurves.cpp @@ -197,7 +197,7 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d& for ( int i = 0 ; i < int( vPL.size()) ; ++ i) { // estrusione SurfTriMesh STM2 ; - if ( ! STM2.CreateByExtrusion( vPLOrd[i], vtExtr)) + if ( ! STM2.CreateByExtrusion( vPL[i], vtExtr)) return nullptr ; // la unisco alla superficie principale if ( ! pSTM->DoSewing( STM2)) diff --git a/Triangulate.cpp b/Triangulate.cpp index 53c3a5c..adde136 100644 --- a/Triangulate.cpp +++ b/Triangulate.cpp @@ -258,7 +258,7 @@ Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVEC else { // ho già calcolato e riordinato tutto, devo solo fare una copia delle polyline // non serve fare le eventuali inversioni delle polyline, perché se è già stata calcolata la matrice dei chunck allora sono GIà state invertire - vPL = &vPLORIG ; + vPL = vPLORIG ; vnPLIndMat = vnPLIndMatPre ; }