EgtGeomKernel :

- unificazione del codice per la CalcRegionPolyLines e modifiche collegate.
This commit is contained in:
Daniele Bariletti
2024-08-29 09:20:00 +02:00
parent f649954ee1
commit de3f187ddf
8 changed files with 105 additions and 150 deletions
+30 -23
View File
@@ -575,19 +575,11 @@ SurfFlatRegionByContours::GetUnusedCurveTempProps( INTVECTOR& vId)
//-------------------------------------------------------------------------------
bool
CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
POLYLINEVECTOR& vPL, Vector3d& vtN)
CalcRegionPolyLines( const POLYLINEVECTOR& vPL, POLYLINEVECTOR& vPLOrd, Vector3d& vtN, INTMATRIX& vnPLIndMat)
{
// se non ho curve, non faccio nulla
if ( int( vpCurve.size()) == 0)
return true ;
// calcolo le polilinee che approssimano le curve
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]))
return false ;
}
// 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 ;
// ricavo versore normale
Plane3d plPlane ; double dArea ;
@@ -599,6 +591,7 @@ CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
std::vector<INDAREA> m_vArea ;
// calcolo piano medio e area delle curve
m_vArea.reserve( vPL.size()) ;
VCT3DVECTOR vvtN ;
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
// calcolo piano medio e area
Plane3d plPlane ;
@@ -608,6 +601,8 @@ CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
// verifico che le normali siano molto vicine
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtN))
return false ;
// salvo la normale
vvtN.push_back( plPlane.GetVersN()) ;
// assegno il segno all'area secondo il verso della normale
if ( ( plPlane.GetVersN() * vtN) > 0)
m_vArea.emplace_back( i, dArea) ;
@@ -629,16 +624,17 @@ CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
vCrvCompo[i]->ToLoc( frRef) ;
}
// creo una 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 ;
// restituisco la normale del loop più grande
bool bInvertAll = vvtN[m_vArea[0].first] * vtN < 0 ;
vtN = vvtN[m_vArea[0].first] ;
// vettore di indici per ordinare le PolyLine
//// vettore di indici per ordinare le PolyLine
INTVECTOR vPL_IndOrder ; vPL_IndOrder.resize( int( vPL.size())) ;
for ( int i = 0 ; i < int( m_vArea.size()) ; ++ i)
vPL_IndOrder[i] = m_vArea[i].first ;
// aggiungo le diverse curve
vPLOrd = vPL ;
bool bFirstCrv ;
Plane3d plExtLoop ;
double dAreaExtLoop = 0. ;
@@ -656,7 +652,7 @@ CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
dAreaExtLoop = m_vArea[i].second ;
// inverto se necessario
if ( m_vArea[i].second < EPS_SMALL) {
vPL[j].Invert() ;
vPLOrd[j].Invert() ;
vCrvCompo[j]->Invert() ;
dAreaExtLoop *= -1 ;
}
@@ -691,7 +687,7 @@ CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
m_vArea[i].first = -1 ;
// inverto se necessario
if ( m_vArea[i].second * dAreaExtLoop > 0.) {
vPL[j].Invert() ;
vPLOrd[j].Invert() ;
vCrvCompo[j]->Invert() ;
}
}
@@ -699,11 +695,22 @@ CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
}
} while ( ! bFirstCrv) ;
// ordino le PolyLine per area
POLYLINEVECTOR vPL_tmp ;
for ( int i = 0 ; i < int( vPL_IndOrder.size()) ; ++ i)
vPL_tmp.push_back( vPL[ vPL_IndOrder[i]]) ;
swap( vPL, vPL_tmp) ;
if ( bInvertAll) {
for ( int i = 0 ; i < int( vPLOrd.size()) ; ++i)
vPLOrd[i].Invert() ;
}
//// 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 ;
}