EgtGeomKernel :
- modifica a Trimming - sistemazioni estetiche varie.
This commit is contained in:
+177
-194
@@ -167,7 +167,7 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
PNTMATRIX vvPoints ;
|
||||
Vector3d vtTanCurr = V_INVALID, vtTanNext = V_INVALID ;
|
||||
bool bNewCurve = true ;
|
||||
int nPoints = int( vPoints.size()) ;
|
||||
int nPoints = ssize( vPoints) ;
|
||||
for ( int nP = 0 ; nP < nPoints - 2 ; ++ nP) {
|
||||
// Recupero il punto corrente e i due punti successivi
|
||||
Point3d& ptCurr = vPoints[nP] ;
|
||||
@@ -209,8 +209,8 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
// Se PolyLine originale chiusa
|
||||
if ( PL.IsClosed()) {
|
||||
// Se ho più tratti, potrei riuniore il primo con l'ultimo
|
||||
if ( int( vvPoints.size()) > 1) {
|
||||
Point3d& ptCurr = vPoints[int( vPoints.size()) - 2] ;
|
||||
if ( ssize( vvPoints) > 1) {
|
||||
Point3d& ptCurr = vPoints[ssize( vPoints) - 2] ;
|
||||
Point3d& ptNext = vPoints[0] ;
|
||||
Point3d& ptNextNext = vPoints[1] ;
|
||||
vtTanCurr = ptNext - ptCurr ; vtTanCurr.Normalize() ;
|
||||
@@ -219,19 +219,19 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
// Se dentro alla tolleranza
|
||||
if ( dCos > dCosTol) {
|
||||
// Recupero la tangenza del tratto finale dell'ultimo tratto
|
||||
Point3d& ptLast = vvPoints.back()[int( vvPoints.back().size()) - 1] ;
|
||||
Point3d& ptLastLast = vvPoints.back()[int( vvPoints.back().size()) - 2] ;
|
||||
Point3d& ptLast = vvPoints.back()[ssize( vvPoints.back()) - 1] ;
|
||||
Point3d& ptLastLast = vvPoints.back()[ssize( vvPoints.back()) - 2] ;
|
||||
Vector3d vtTanLast = ptLast - ptLastLast ; vtTanLast.Normalize() ;
|
||||
dCos = vtTanLast * vtTanCurr ;
|
||||
// Se nella tolleranza allora posso allacciare il primo e l'ultimo tratto
|
||||
if ( dCos > dCosTol) {
|
||||
for ( int i = bNewCurve ? 1 : 0 ; i < int( vvPoints[0].size()) ; ++ i)
|
||||
for ( int i = bNewCurve ? 1 : 0 ; i < ssize( vvPoints[0]) ; ++ i)
|
||||
vvPoints.back().emplace_back( vvPoints[0][i]) ;
|
||||
vvPoints.erase( vvPoints.begin()) ;
|
||||
}
|
||||
// Altrimenti sposto il punto d'inizio in ptCurr del primo tratto
|
||||
else {
|
||||
PNTVECTOR vPointsFirst ; vPointsFirst.reserve( vvPoints.front().size() + 1) ;
|
||||
PNTVECTOR vPointsFirst ; vPointsFirst.reserve( ssize( vvPoints.front()) + 1) ;
|
||||
vPointsFirst.emplace_back( ptCurr) ;
|
||||
for ( const Point3d& pt : vvPoints.front())
|
||||
vPointsFirst.emplace_back( pt) ;
|
||||
@@ -252,8 +252,8 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
// Se devo creare una curva nuova, aggiungo il tratto finale
|
||||
if ( bNewCurve) {
|
||||
vvPoints.emplace_back( PNTVECTOR{}) ;
|
||||
vvPoints.back().emplace_back( vPoints[int( vPoints.size()) - 2]) ;
|
||||
vvPoints.back().emplace_back( vPoints[int( vPoints.size()) - 1]) ;
|
||||
vvPoints.back().emplace_back( vPoints[ssize( vPoints) - 2]) ;
|
||||
vvPoints.back().emplace_back( vPoints[ssize( vPoints) - 1]) ;
|
||||
}
|
||||
}
|
||||
#if DEBUG_ANG_APPROX
|
||||
@@ -271,10 +271,10 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
#endif
|
||||
|
||||
// Converto i punti ricavati in PolyLine risultati
|
||||
for ( int i = 0 ; i < int( vvPoints.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vvPoints) ; ++ i) {
|
||||
vPL.emplace_back( PolyLine()) ;
|
||||
double dPar = -1. ;
|
||||
for ( int j = 0 ; j < int( vvPoints[i].size()) ; ++ j) {
|
||||
for ( int j = 0 ; j < ssize( vvPoints[i]) ; ++ j) {
|
||||
vPL.back().AddUPoint( ++ dPar, vvPoints[i][j]) ;
|
||||
}
|
||||
}
|
||||
@@ -580,7 +580,7 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
// Le Patch più corte della tolleranza vengono considerate invalide
|
||||
SimpleBorderVector vSimpleBorder ; vSimpleBorder.reserve( matPLPatches.size()) ;
|
||||
vector<set<double>> matPatchPar ; matPatchPar.reserve( matPLPatches.size()) ;
|
||||
for ( int i = 0 ; i < int( matPLPatches.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( matPLPatches) ; ++ i) {
|
||||
vSimpleBorder.emplace_back( SimpleBorder()) ;
|
||||
matPatchPar.emplace_back( set<double>()) ;
|
||||
for ( int j = 0 ; j < ssize( matPLPatches[i]) ; ++ j) {
|
||||
@@ -599,8 +599,8 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
}
|
||||
#if DEBUG_CHAIN_CURVES
|
||||
VC.clear() ; VT.clear() ;
|
||||
for ( int i = 0 ; i < int( vSimpleBorder.size()) ; ++ i) {
|
||||
for ( int j = 0 ; j < int( vSimpleBorder[i].size()) ; ++ j) {
|
||||
for ( int i = 0 ; i < ssize( vSimpleBorder) ; ++ i) {
|
||||
for ( int j = 0 ; j < ssize( vSimpleBorder[i]) ; ++ j) {
|
||||
VT.emplace_back( matCompoPatches[i][j].Clone()) ;
|
||||
VC.emplace_back( RED) ;
|
||||
IGeoPoint3d* ptS = CreateGeoPoint3d() ;
|
||||
@@ -720,11 +720,11 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
// Si eliminano ora tutte le Patch che si sovrappongono, in modo da ottenere solo un
|
||||
// le Patch che rappresentano il bordo esterno
|
||||
const double MAXPOINT = 10 ;
|
||||
for ( int nCurrCrv = 0 ; nCurrCrv < int( vSimpleBorder.size()) - 1 ; ++ nCurrCrv) {
|
||||
for ( int nCurrCrv = 0 ; nCurrCrv < ssize( vSimpleBorder) - 1 ; ++ nCurrCrv) {
|
||||
// Recupero la curva corrente
|
||||
SimpleBorder& CurrCurve = vSimpleBorder[nCurrCrv] ;
|
||||
// Scorro i suoi Edges
|
||||
for ( int nCurrEdge = 0 ; nCurrEdge < int( CurrCurve.size()) ; ++ nCurrEdge) {
|
||||
for ( int nCurrEdge = 0 ; nCurrEdge < ssize( CurrCurve) ; ++ nCurrEdge) {
|
||||
// Se Edge cancellato, passo al successivo
|
||||
if ( CurrCurve[nCurrEdge].bErase)
|
||||
continue ;
|
||||
@@ -732,11 +732,11 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
Point3d& ptCurrStart = CurrCurve[nCurrEdge].ptStart ;
|
||||
Point3d& ptCurrEnd = CurrCurve[nCurrEdge].ptEnd ;
|
||||
// Scorro le curve successive
|
||||
for ( int nNextCrv = nCurrCrv + 1 ; nNextCrv < int( vSimpleBorder.size()) ; ++ nNextCrv) {
|
||||
for ( int nNextCrv = nCurrCrv + 1 ; nNextCrv < ssize( vSimpleBorder) ; ++ nNextCrv) {
|
||||
// Recupero la curva successiva
|
||||
SimpleBorder& NextCurve = vSimpleBorder[nNextCrv] ;
|
||||
// Scorro i suoi Edges
|
||||
for ( int nNextEdge = 0 ; nNextEdge < int( NextCurve.size()) ; ++ nNextEdge) {
|
||||
for ( int nNextEdge = 0 ; nNextEdge < ssize( NextCurve) ; ++ nNextEdge) {
|
||||
// Se Edge cancellato, passo al successivo
|
||||
#if 0
|
||||
// Se pezze si superficie piccolissime, si rischia di eliminare tutti i
|
||||
@@ -790,11 +790,11 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
}
|
||||
|
||||
// Recupero solo i sottotratti di curva validi ( quindi che non fanno overlap tra loro)
|
||||
for ( int nCrv = 0 ; nCrv < int( vSimpleBorder.size()) ; ++ nCrv) {
|
||||
for ( int nCrv = 0 ; nCrv < ssize( vSimpleBorder) ; ++ nCrv) {
|
||||
// Recupero la curva
|
||||
SimpleBorder& CrvEdge = vSimpleBorder[nCrv] ;
|
||||
// Scorro i suoi edges
|
||||
for ( int nEdge = 0 ; nEdge < int( CrvEdge.size()) ; ++ nEdge) {
|
||||
for ( int nEdge = 0 ; nEdge < ssize( CrvEdge) ; ++ nEdge) {
|
||||
// Se edge non attivo, passo al successivo
|
||||
if ( CrvEdge[nEdge].bErase)
|
||||
continue ;
|
||||
@@ -815,15 +815,15 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
}
|
||||
}
|
||||
// Conservo solo le curve valide
|
||||
for ( int nCrv = 0 ; nCrv < int( vCompoResult.size()) ; ++ nCrv) {
|
||||
if ( IsNull( vCompoResult[nCrv]) || ! vCompoResult[nCrv]->IsValid()) {
|
||||
for ( int nCrv = 0 ; nCrv < ssize( vCompoResult) ; ++ nCrv) {
|
||||
if ( IsNull( vCompoResult[nCrv]) || ! vCompoResult[nCrv]->IsValid()) {
|
||||
vCompoResult.erase( vCompoResult.begin() + nCrv) ;
|
||||
-- nCrv ;
|
||||
}
|
||||
}
|
||||
#if DEBUG_CHAIN_CURVES // Debug per le Patch risultanti
|
||||
VT.clear() ; VC.clear() ;
|
||||
for ( int i = 0 ; i < int( vCompoResult.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoResult) ; ++ i) {
|
||||
VT.emplace_back( vCompoResult[i]->Clone()) ;
|
||||
VC.emplace_back( ORANGE) ;
|
||||
}
|
||||
@@ -854,7 +854,7 @@ ChainCompoPatches( ICRVCOMPOPOVECTOR& vCompoPatches, double dChainTol,
|
||||
// La concatenazione parte dalla curva più lunga
|
||||
double dMaxLen = - INFINITO ;
|
||||
int nInd = 0 ;
|
||||
for ( int i = 0 ; i < int( vCompoPatches.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoPatches) ; ++ i) {
|
||||
double dLen = 0. ;
|
||||
vCompoPatches[i]->GetLength( dLen) ;
|
||||
if ( dLen > dMaxLen) {
|
||||
@@ -868,7 +868,7 @@ ChainCompoPatches( ICRVCOMPOPOVECTOR& vCompoPatches, double dChainTol,
|
||||
// Scorro le curve
|
||||
vCompoChained.reserve( vCompoPatches.size()) ;
|
||||
BOOLVECTOR vbCrvChained( vCompoPatches.size(), false) ;
|
||||
for ( int nCurrCrv = 0 ; nCurrCrv < int( vCompoPatches.size()) ; ++ nCurrCrv) {
|
||||
for ( int nCurrCrv = 0 ; nCurrCrv < ssize( vCompoPatches) ; ++ nCurrCrv) {
|
||||
// Se curva già concatenata, passo alla successiva ( no biforcazioni ammesse -> errore )
|
||||
if ( vbCrvChained[nCurrCrv])
|
||||
continue ;
|
||||
@@ -881,7 +881,7 @@ ChainCompoPatches( ICRVCOMPOPOVECTOR& vCompoPatches, double dChainTol,
|
||||
for ( int nU = 0 ; nU < vCompoChained.back()->GetCurveCount() ; ++ nU)
|
||||
vCompoChained.back()->SetCurveTempProp( nU, vCompoPatches[nCurrCrv]->GetTempProp( 0), 0) ;
|
||||
// Cerco tra le altre curve disponibili una candidata alla concatenazione
|
||||
for ( int nNextCrv = 0 ; nNextCrv < int( vCompoPatches.size()) ; ++ nNextCrv) {
|
||||
for ( int nNextCrv = 0 ; nNextCrv < ssize( vCompoPatches) ; ++ nNextCrv) {
|
||||
if ( nNextCrv == nCurrCrv || vbCrvChained[nNextCrv])
|
||||
continue ;
|
||||
// Recupero i suoi estremi [ sono tratti lineari, la ricerca è immediata ]
|
||||
@@ -932,7 +932,7 @@ ChainCompoPatches( ICRVCOMPOPOVECTOR& vCompoPatches, double dChainTol,
|
||||
}
|
||||
}
|
||||
// Verifico la validità delle curve ottenute
|
||||
for ( int i = 0 ; i < int( vCompoChained.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoChained) ; ++ i) {
|
||||
if ( IsNull( vCompoChained[i]) || ! vCompoChained[i]->IsValid())
|
||||
return false ;
|
||||
// Se curva al di sotto della tolleranza, la scarto
|
||||
@@ -1032,7 +1032,7 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
}
|
||||
}
|
||||
// Se non ho ottenuto esattamente due tratti, non analizzo più la curva corrente
|
||||
if ( int( vBiPntSplit.size()) != 2) {
|
||||
if ( ssize( vBiPntSplit) != 2) {
|
||||
LOG_INFO( GetEGkLogger(), "Warning in Trimming : Detected more Curves by Thick values") ;
|
||||
break ; // lascio la curva invariata
|
||||
}
|
||||
@@ -1069,10 +1069,10 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
if ( vBreakingPts.empty())
|
||||
return true ;
|
||||
// Se ho punti di rottura in comune, errore
|
||||
for ( int i = 0 ; i < int( vBreakingPts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vBreakingPts) ; ++ i) {
|
||||
if ( AreSamePointEpsilon( vBreakingPts[i].first, vBreakingPts[i].second, dLinTol))
|
||||
return false ;
|
||||
for ( int j = i + 1 ; j < int( vBreakingPts.size()) ; ++ j) {
|
||||
for ( int j = i + 1 ; j < ssize( vBreakingPts) ; ++ j) {
|
||||
if ( AreSamePointEpsilon( vBreakingPts[i].first, vBreakingPts[j].first, dLinTol) ||
|
||||
AreSamePointEpsilon( vBreakingPts[i].first, vBreakingPts[j].second, dLinTol) ||
|
||||
AreSamePointEpsilon( vBreakingPts[i].second, vBreakingPts[j].first, dLinTol) ||
|
||||
@@ -1110,7 +1110,7 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
return false ;
|
||||
for ( const BIPOINT& BiPnts : vBreakingPts) {
|
||||
// Scorro i tratti ( inizialmente la curva stessa)
|
||||
for ( int i = 0 ; i < int( vCompoParts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoParts) ; ++ i) {
|
||||
// Controllo che la coppia di punti giacia su quella curva
|
||||
if ( ! vCompoParts[i]->IsPointOn( BiPnts.first, dLinTol) ||
|
||||
! vCompoParts[i]->IsPointOn( BiPnts.second, dLinTol))
|
||||
@@ -1152,7 +1152,7 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
}
|
||||
}
|
||||
// Memorizzo tutte le curve valide ottenute dai punti di rottura
|
||||
for ( int i = 0 ; i < int( vCompoParts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoParts) ; ++ i) {
|
||||
if ( ! IsNull( vCompoParts[i]) && vCompoParts[i]->IsValid())
|
||||
vCrvResult.emplace_back( Release( vCompoParts[i])) ;
|
||||
}
|
||||
@@ -1186,13 +1186,13 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
if ( ! GetPointSetByAngTol( myPL, ANG_SPLIT, vPL))
|
||||
return false ;
|
||||
// Se meno di 4 PolyLine non faccio nulla
|
||||
if ( int( vPL.size()) < 4) {
|
||||
if ( ssize( vPL) < 4) {
|
||||
LOG_INFO( GetEGkLogger(), "Warning in Trimming : Not Detected 2 Curves") ;
|
||||
return true ;
|
||||
}
|
||||
// Scorro le PolyLine e ricavo le due più corte
|
||||
INTDBLVECTOR vIndPLLen ; vIndPLLen.reserve( vPL.size()) ;
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vPL) ; ++ i) {
|
||||
double dLen ; vPL[i].GetLength( dLen) ;
|
||||
vIndPLLen.emplace_back( make_pair( i, dLen)) ;
|
||||
}
|
||||
@@ -1301,7 +1301,7 @@ InsertLoopsOfSurf( const ISurf* pSurf, POLYLINEVECTOR& vPL)
|
||||
return false ;
|
||||
// Li inserisco nel vettore ( come insieme di tratti lineari)
|
||||
// NB. Tengo le tolleranze molto basse per ottenere dei loop rappresentativi della geometria
|
||||
for ( int nL = 0 ; nL < int( vLoops.size()) ; ++ nL) {
|
||||
for ( int nL = 0 ; nL < ssize( vLoops) ; ++ nL) {
|
||||
if ( ! IsNull( vLoops[nL]) && vLoops[nL]->IsValid()) {
|
||||
vPL.emplace_back( PolyLine()) ;
|
||||
if ( ! vLoops[nL]->ApproxWithLines( EPS_SMALL, EPS_ANG_SMALL, ICurve::APL_STD, vPL.back()))
|
||||
@@ -1427,7 +1427,7 @@ GetSurfBorders( const CISURFPVECTOR& vSurf, const SELVECTOR& vSurfFace, double d
|
||||
// - Loop di una Superficie TriMesh
|
||||
// - Insieme di facce di una supericie TriMesh
|
||||
// Scorro il vettore delle superfici
|
||||
for ( int nS = 0 ; nS < int( vSurf.size()) ; ++ nS) {
|
||||
for ( int nS = 0 ; nS < ssize( vSurf) ; ++ nS) {
|
||||
// Recupero la superficie
|
||||
const ISurf* pSurf = vSurf[nS] ;
|
||||
if ( pSurf == nullptr)
|
||||
@@ -1440,9 +1440,9 @@ GetSurfBorders( const CISURFPVECTOR& vSurf, const SELVECTOR& vSurfFace, double d
|
||||
vFaces.push_back( SurfFace.nSub) ;
|
||||
}
|
||||
// Recupero la dimensione del vettore delle PolyLine risultati attuale
|
||||
int nSize = int( vPLBorders.size()) ;
|
||||
int nSize = ssize( vPLBorders) ;
|
||||
// Se non ho nessuna faccia e nessun triangolo da scartare, estraggo i bordi complessivi della superficie
|
||||
if ( int( vFaces.size()) == 1 && vFaces[0] == SEL_SUB_ALL) {
|
||||
if ( ssize( vFaces) == 1 && vFaces[0] == SEL_SUB_ALL) {
|
||||
if ( ! InsertLoopsOfSurf( pSurf, vPLBorders))
|
||||
return false ;
|
||||
}
|
||||
@@ -1463,7 +1463,7 @@ GetSurfBorders( const CISURFPVECTOR& vSurf, const SELVECTOR& vSurfFace, double d
|
||||
return false ;
|
||||
}
|
||||
// Associo alle nuove PolyLine ricavate l'indice della superficie corrispondente
|
||||
for ( int i = nSize ; i < int( vPLBorders.size()) ; ++ i)
|
||||
for ( int i = nSize ; i < ssize( vPLBorders) ; ++ i)
|
||||
vPLBorders[i].SetTempProp( nS, 0) ;
|
||||
}
|
||||
|
||||
@@ -1509,52 +1509,36 @@ GetBorderByExtrusion( const SurfTriMesh* pStm, double dThick, double dLinTol, do
|
||||
// Scorro i Loop
|
||||
for ( PolyLine& PLLoop : vPLLoop) {
|
||||
PolyLine PLLoopExtr ;
|
||||
// Scorro i Segmenti
|
||||
Point3d ptI, ptE ;
|
||||
double dUI, dUE ;
|
||||
bool bFound = PLLoop.GetFirstULine( &dUI, &ptI, &dUE, &ptE) ;
|
||||
// Scorro i Punti
|
||||
Point3d ptP ;
|
||||
double dU ;
|
||||
bool bFound = PLLoop.GetFirstUPoint( &dU, &ptP) ;
|
||||
double dPar = -1 ;
|
||||
bool bFirst = true ;
|
||||
while ( bFound) {
|
||||
// Recupero il TriangoloEx del tratto lineare corrente
|
||||
// Recupero il TriangoloEx associato al punto
|
||||
Triangle3dEx Tria ;
|
||||
if ( ! pStm->GetTriangle( int( dUI), Tria))
|
||||
if ( ! pStm->GetTriangle( lround( dU), Tria))
|
||||
return false ;
|
||||
// Tale Triangolo contiene le normali mediate, cerco quelle riferite ai vertici
|
||||
if ( bFirst) {
|
||||
int nTriaP = 0 ;
|
||||
for ( ; nTriaP < 3 ; ++ nTriaP) {
|
||||
if ( AreSamePointApprox( Tria.GetP( nTriaP), ptI))
|
||||
break ;
|
||||
}
|
||||
PLLoopExtr.AddUPoint( ++ dPar, ptI - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
#if DEBUG_BORDERS_BY_NORMALS
|
||||
IGeoVector3d* _vtN = CreateGeoVector3d() ; _vtN->Set( Tria.GetVertexNorm( nTriaP), ptI) ;
|
||||
VT.emplace_back( _vtN) ;
|
||||
Color _myCol = Color( abs( Tria.GetVertexNorm( nTriaP).x), abs( Tria.GetVertexNorm( nTriaP).y), abs( Tria.GetVertexNorm( nTriaP).z)) ;
|
||||
VC.emplace_back( _myCol) ;
|
||||
CurveLine _Line ; _Line.Set( ptI, ptI - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
VT.emplace_back( _Line.Clone()) ;
|
||||
VC.emplace_back( _myCol) ;
|
||||
#endif
|
||||
bFirst = false ;
|
||||
}
|
||||
// Cerco il vertice associato al punto
|
||||
int nTriaP = 0 ;
|
||||
for ( ; nTriaP < 3 ; ++ nTriaP) {
|
||||
if ( AreSamePointApprox( Tria.GetP( nTriaP), ptE))
|
||||
if ( AreSamePointApprox( Tria.GetP( nTriaP), ptP))
|
||||
break ;
|
||||
}
|
||||
PLLoopExtr.AddUPoint( ++ dPar, ptE - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
if ( nTriaP == 3)
|
||||
return false ;
|
||||
PLLoopExtr.AddUPoint( ++ dPar, ptP - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
#if DEBUG_BORDERS_BY_NORMALS
|
||||
IGeoVector3d* _vtN = CreateGeoVector3d() ; _vtN->Set( Tria.GetVertexNorm( nTriaP), ptE) ;
|
||||
IGeoVector3d* _vtN = CreateGeoVector3d() ; _vtN->Set( Tria.GetVertexNorm( nTriaP), ptP) ;
|
||||
VT.emplace_back( _vtN) ;
|
||||
Color _myCol = Color( abs( Tria.GetVertexNorm( nTriaP).x), abs( Tria.GetVertexNorm( nTriaP).y), abs( Tria.GetVertexNorm( nTriaP).z)) ;
|
||||
VC.emplace_back( _myCol) ;
|
||||
CurveLine _Line ; _Line.Set( ptE, ptE - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
CurveLine _Line ; _Line.Set( ptP, ptP - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
VT.emplace_back( _Line.Clone()) ;
|
||||
VC.emplace_back( _myCol) ;
|
||||
#endif
|
||||
bFound = PLLoop.GetNextULine( &dUI, &ptI, &dUE, &ptE) ;
|
||||
bFound = PLLoop.GetNextUPoint( &dU, &ptP) ;
|
||||
}
|
||||
#if DEBUG_BORDERS_BY_NORMALS
|
||||
ICurveComposite* pC = CreateCurveComposite() ;
|
||||
@@ -1562,8 +1546,9 @@ GetBorderByExtrusion( const SurfTriMesh* pStm, double dThick, double dLinTol, do
|
||||
VT.emplace_back( pC->Clone()) ;
|
||||
VC.emplace_back( AQUA) ;
|
||||
#endif
|
||||
// Loop valido con almeno 4 punti
|
||||
if ( PLLoopExtr.GetPointNbr() >= 4) {
|
||||
// Il primo e l'ultimo punto devono coincidere
|
||||
// Primo e ultimo punto devono coincidere
|
||||
PNTULIST& lPntU = PLLoopExtr.GetUPointList() ;
|
||||
Point3d ptClose = Media( lPntU.front().first, lPntU.back().first) ;
|
||||
lPntU.front().first = ptClose ;
|
||||
@@ -2071,10 +2056,10 @@ ClassifyTriangles( const SurfTriMesh& Stm, const INTVECTOR& vTBox, int nFirstTri
|
||||
// Collezione di triangoli già visitati
|
||||
unordered_set<int> setTria ; setTria.reserve( vTBox.size()) ;
|
||||
// Collezioni di triangoli da analizzare
|
||||
INTVECTOR vTria ; vTria.reserve( int( vTBox.size()) + 1) ;
|
||||
INTVECTOR vTria ; vTria.reserve( ssize( vTBox) + 1) ;
|
||||
vTria.push_back( nFirstTria) ;
|
||||
// Collezioni di adiacenze da non riguardare
|
||||
unordered_map<int, INTVECTOR> mapAdjToAvoid ; mapAdjToAvoid.reserve( int( vTBox.size() + 1)) ;
|
||||
unordered_map<int, INTVECTOR> mapAdjToAvoid ; mapAdjToAvoid.reserve( ssize( vTBox) + 1) ;
|
||||
|
||||
// Finchè ho triangoli da visitare
|
||||
while ( ! vTria.empty()) {
|
||||
@@ -2221,14 +2206,14 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
|
||||
// Per ogni Edge ricavato, conservo solo le parti interne al Box corrente
|
||||
INTVECTOR vEdgeToSave ; vEdgeToSave.reserve( vBiPnts.size()) ;
|
||||
for ( int nEdge = 0 ; nEdge < int( vBiPnts.size()) ; ++ nEdge) {
|
||||
for ( int nEdge = 0 ; nEdge < ssize( vBiPnts) ; ++ nEdge) {
|
||||
Point3d& ptL1 = vBiPnts[nEdge].first ;
|
||||
Point3d& ptL2 = vBiPnts[nEdge].second ;
|
||||
Vector3d vtDir = ptL2 - ptL1 ;
|
||||
vtDir.Normalize() ;
|
||||
INTDBLVECTOR vInters ;
|
||||
if ( IntersLineBox( ptL1, ptL2, BBoxCurr, vInters, true)) {
|
||||
if ( int( vInters.size()) == 2) {
|
||||
if ( ssize( vInters) == 2) {
|
||||
vEdgeToSave.push_back( nEdge) ;
|
||||
// Se edge sul bordo, lo spezzo
|
||||
if ( vInters[1].first == ILBT_OUT)
|
||||
@@ -2240,14 +2225,14 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
}
|
||||
unordered_set<int> setBiPntsToSave( vEdgeToSave.begin(), vEdgeToSave.end()) ;
|
||||
int nCurr = 0 ;
|
||||
for ( int i = 0 ; i < int( vBiPnts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vBiPnts) ; ++ i) {
|
||||
if ( setBiPntsToSave.count( i))
|
||||
vBiPnts[nCurr ++] = vBiPnts[i] ;
|
||||
}
|
||||
vBiPnts.resize( nCurr) ;
|
||||
|
||||
#if DEBUG_FACE_SEARCH
|
||||
for ( int i = 0 ; i < int( vBiPnts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vBiPnts) ; ++ i) {
|
||||
ICurveLine* pLine = CreateCurveLine() ;
|
||||
pLine->Set( vBiPnts[i].first, vBiPnts[i].second) ;
|
||||
VT.emplace_back( pLine) ;
|
||||
@@ -2259,7 +2244,7 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
// Concateno i Segmenti interni al Box corrente
|
||||
BOOLVECTOR vIndInChain ; vIndInChain.resize( vBiPnts.size(), false) ;
|
||||
vCompoChain.reserve( vBiPnts.size()) ;
|
||||
for ( int i = 0 ; i < int( vBiPnts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vBiPnts) ; ++ i) {
|
||||
// Se già in Chain, passo al successivo
|
||||
if ( vIndInChain[i])
|
||||
continue ;
|
||||
@@ -2273,7 +2258,7 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
vCompoChain.back().AddLine( ptCurrEnd) ;
|
||||
// Punti di controllo per Biforcazioni
|
||||
PNTVECTOR vPtForks ; vPtForks.reserve( vBiPnts.size()) ;
|
||||
for ( int j = 0 ; j < int( vBiPnts.size()) ; ++ j) {
|
||||
for ( int j = 0 ; j < ssize( vBiPnts) ; ++ j) {
|
||||
// Controllo un altro Edge non in Chain, recuperando i suoi estremi
|
||||
if ( i == j || vIndInChain[j])
|
||||
continue ;
|
||||
@@ -2344,7 +2329,7 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
}
|
||||
|
||||
#if DEBUG_FACE_SEARCH
|
||||
for ( int i = 0 ; i < int( vCompoChain.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoChain) ; ++ i) {
|
||||
VT.emplace_back( vCompoChain[i].Clone()) ;
|
||||
VC.emplace_back( FUCHSIA) ;
|
||||
}
|
||||
@@ -2426,7 +2411,7 @@ CheckCurvesInBox( const SurfTriMesh& Stm, const COMPOVECTOR& vCompoChain, const
|
||||
return false ;
|
||||
|
||||
#if DEBUG_FACE_SEARCH
|
||||
for ( int _i = 0 ; _i < int( vCompoChain.size()) ; ++ _i) {
|
||||
for ( int _i = 0 ; _i < ssize( vCompoChain) ; ++ _i) {
|
||||
VT.emplace_back( vCompoChain[_i].Clone()) ;
|
||||
VC.emplace_back( PURPLE) ;
|
||||
}
|
||||
@@ -2436,7 +2421,7 @@ CheckCurvesInBox( const SurfTriMesh& Stm, const COMPOVECTOR& vCompoChain, const
|
||||
CurveComposite CompoATmp, CompoBTmp ;
|
||||
|
||||
// Se ho una sola curva, allora i bordi si sono uniti
|
||||
if ( int( vCompoChain.size()) == 1) {
|
||||
if ( ssize( vCompoChain) == 1) {
|
||||
// Approssimo la curva in Patches
|
||||
PolyLine PL ;
|
||||
if ( ! vCompoChain[0].ApproxWithLines( EPS_SMALL, EPS_ANG_SMALL, ICurve::APL_SPECIAL, PL))
|
||||
@@ -2448,14 +2433,14 @@ CheckCurvesInBox( const SurfTriMesh& Stm, const COMPOVECTOR& vCompoChain, const
|
||||
CompoBTmp.FromPolyLine( matPL[0].back()) ;
|
||||
}
|
||||
// Se due curve di bordo
|
||||
else if ( int( vCompoChain.size()) == 2) {
|
||||
else if ( ssize( vCompoChain) == 2) {
|
||||
CompoATmp = vCompoChain[0] ;
|
||||
CompoBTmp = vCompoChain[1] ;
|
||||
}
|
||||
// Se più di due, cerco le due curve più vicine
|
||||
else if ( int( vCompoChain.size()) > 2) {
|
||||
else if ( ssize( vCompoChain) > 2) {
|
||||
INTDBLVECTOR vIndSqDist ; vIndSqDist.reserve( vCompoChain.size()) ;
|
||||
for ( int nCrv = 0 ; nCrv < int( vCompoChain.size()) ; ++ nCrv) {
|
||||
for ( int nCrv = 0 ; nCrv < ssize( vCompoChain) ; ++ nCrv) {
|
||||
vIndSqDist.emplace_back( make_pair( nCrv, 0.)) ;
|
||||
if ( ! DistPointCurve( ptSel, vCompoChain[nCrv]).GetSqDist( vIndSqDist.back().second))
|
||||
return false ;
|
||||
@@ -2896,7 +2881,7 @@ CheckBordersInBox( CurveComposite& CompoA, CurveComposite& CompoB,
|
||||
return false ;
|
||||
double dMinSqDist = INFINITO ;
|
||||
int nTria = 0 ;
|
||||
for ( int nT = 0 ; nT < int( vTBox.size()) ; ++ nT) {
|
||||
for ( int nT = 0 ; nT < ssize( vTBox) ; ++ nT) {
|
||||
Triangle3d Tria ;
|
||||
if ( ! Stm.GetTriangle( vTBox[nT], Tria))
|
||||
return false ;
|
||||
@@ -2924,10 +2909,10 @@ CheckBordersInBox( CurveComposite& CompoA, CurveComposite& CompoB,
|
||||
#endif
|
||||
|
||||
// Se ottengo una sola curva, allora la striscia si è chiusa
|
||||
if ( int( vCompoChain.size()) <= 1)
|
||||
if ( ssize( vCompoChain) <= 1)
|
||||
return true ;
|
||||
// Se ottengo ancora due curve, allora la striscia non rispetta lo spessore minimo
|
||||
bBreak = ( int( vCompoChain.size()) >= 2) ;
|
||||
bBreak = ( ssize( vCompoChain) >= 2) ;
|
||||
if ( bBreak) {
|
||||
// Se devo fermare la ricerca e ho ancora CompoA e CompoB valide
|
||||
if ( bValidA && bValidB) {
|
||||
@@ -3302,7 +3287,7 @@ IsBorderACircle( const PolyLine& PL, double dLinTol, double dAngTol, Frame3d& fr
|
||||
// Per ogni coppia di punti calcolo la Distanza Massima e Minima dal centro del cerchio locale ( ORIG)
|
||||
double dSqMaxDist = 0. ;
|
||||
double dSqMinDist = INFINITO ;
|
||||
for ( int i = 0 ; i < int( floor( 0.5 * int( vPts.size()))) ; i = i + 2) {
|
||||
for ( int i = 0 ; i < ssize( vPts) / 2 ; i = i + 2) {
|
||||
double dSqLineDist = INFINITO ;
|
||||
DistPointLine( ORIG, vPts[i], vPts[i + 1]).GetSqDist( dSqLineDist) ;
|
||||
if ( dSqLineDist < dSqMinDist) {
|
||||
@@ -3562,7 +3547,7 @@ GetTrimmingFinalBorders( ICRVCOMPOPOVECTOR& vCompoBezierEdges, double dLinTol, d
|
||||
return false ;
|
||||
}
|
||||
// Se ho 1 curva, allora cerco di spezzarla
|
||||
else if ( int( vCompoBezierEdges.size()) == 1) {
|
||||
else if ( ssize( vCompoBezierEdges) == 1) {
|
||||
// Se sono presenti dei punti di rottura
|
||||
bool bOk = true ;
|
||||
if ( ! vBreakingPts.empty())
|
||||
@@ -3577,7 +3562,7 @@ GetTrimmingFinalBorders( ICRVCOMPOPOVECTOR& vCompoBezierEdges, double dLinTol, d
|
||||
LOG_INFO( GetEGkLogger(), "Warning in Trimming : Breaking curves failed") ;
|
||||
}
|
||||
// Se ho 2 curve, perfetto !
|
||||
else if ( int( vCompoBezierEdges.size()) == 2)
|
||||
else if ( ssize( vCompoBezierEdges) == 2)
|
||||
return true ;
|
||||
// Se più curve, errore
|
||||
else {
|
||||
@@ -3618,7 +3603,7 @@ GetTrimmingFinalBorders( CISURFPVECTOR& vpSurf, const SELVECTOR& vSurfFaces, dou
|
||||
|
||||
// Recupero la superficie TriMesh complessiva
|
||||
PtrOwner<const SurfTriMesh> pStm( nullptr) ;
|
||||
if ( int( vpSurf.size()) == 1) {
|
||||
if ( ssize( vpSurf) == 1) {
|
||||
const ISurf* pSurf = vpSurf[0] ;
|
||||
if ( pSurf == nullptr)
|
||||
return false ;
|
||||
@@ -3678,9 +3663,9 @@ GetTrimmingFinalBorders( CISURFPVECTOR& vpSurf, const SELVECTOR& vSurfFaces, dou
|
||||
}
|
||||
|
||||
// Restituisco le curve orientate correttamente per la creazione della superficie di Bezier
|
||||
erase_if( vCompoBezierEdges, []( ICurveComposite* pBezierEdge) {
|
||||
return ( pBezierEdge == nullptr || ! pBezierEdge->IsValid() || pBezierEdge->GetCurveCount() == 0) ;
|
||||
}) ;
|
||||
erase_if( vCompoBezierEdges,
|
||||
[]( ICurveComposite* pBezierEdge) {
|
||||
return ( pBezierEdge == nullptr || ! pBezierEdge->IsValid() || pBezierEdge->GetCurveCount() == 0) ;}) ;
|
||||
for ( int i = 0 ; i < ssize( vCompoBezierEdges) - 1 ; i += 2) {
|
||||
ManageRuledBorders( vCompoBezierEdges[i], vCompoBezierEdges[i+1]) ;
|
||||
// Essendo l'Offset fatto in negativo, entrambe le curve vanno invertite
|
||||
@@ -3707,7 +3692,7 @@ GetTrimmingBezierEdges( ICRVCOMPOPOVECTOR& vCompoRawEdges, double dLinTol, doubl
|
||||
|
||||
#if DEBUG_EDGES
|
||||
VC.clear() ; VT.clear() ;
|
||||
for ( int _i = 0 ; _i < int( vCompoRawEdges.size()) ; ++ _i) {
|
||||
for ( int _i = 0 ; _i < ssize( vCompoRawEdges) ; ++ _i) {
|
||||
VT.emplace_back( vCompoRawEdges[_i]->Clone()) ;
|
||||
VC.emplace_back( RED) ;
|
||||
}
|
||||
@@ -3715,7 +3700,7 @@ GetTrimmingBezierEdges( ICRVCOMPOPOVECTOR& vCompoRawEdges, double dLinTol, doubl
|
||||
|
||||
// Approssimo i bordi grezzi
|
||||
vBezierEdges.reserve( vCompoRawEdges.size()) ;
|
||||
for ( int i = 0 ; i < int( vCompoRawEdges.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoRawEdges) ; ++ i) {
|
||||
PtrOwner<ICurveComposite> pCompoTmp( CloneCurveComposite( vCompoRawEdges[i])) ;
|
||||
if ( IsNull( pCompoTmp) ||
|
||||
! ApproxBorder( *GetBasicCurveComposite( pCompoTmp), dMyLinTol, dMyAngTol) ||
|
||||
@@ -3726,15 +3711,15 @@ GetTrimmingBezierEdges( ICRVCOMPOPOVECTOR& vCompoRawEdges, double dLinTol, doubl
|
||||
}
|
||||
|
||||
// Restituisco le curve orientate correttamente per la creazione della superficie di Bezier
|
||||
erase_if( vBezierEdges, []( ICurveComposite* pBezierEdge) {
|
||||
return ( pBezierEdge == nullptr || ! pBezierEdge->IsValid() || pBezierEdge->GetCurveCount() == 0) ;
|
||||
}) ;
|
||||
erase_if( vBezierEdges,
|
||||
[]( ICurveComposite* pBezierEdge) {
|
||||
return ( pBezierEdge == nullptr || ! pBezierEdge->IsValid() || pBezierEdge->GetCurveCount() == 0) ;}) ;
|
||||
for ( int i = 0 ; i < ssize( vBezierEdges) - 1 ; i += 2)
|
||||
ManageRuledBorders( vBezierEdges[i], vBezierEdges[i+1]) ;
|
||||
|
||||
#if DEBUG_EDGES
|
||||
VC.clear() ; VT.clear() ;
|
||||
for ( int _i = 0 ; _i < int( vBezierEdges.size()) ; ++ _i) {
|
||||
for ( int _i = 0 ; _i < ssize( vBezierEdges) ; ++ _i) {
|
||||
VT.emplace_back( vBezierEdges[_i]->Clone()) ;
|
||||
VC.emplace_back( ORANGE) ;
|
||||
}
|
||||
@@ -3776,7 +3761,7 @@ GetTrimmingSurfBzSyncPoints( const ICurve* pCrvEdge1, const ICurve* pCrvEdge2,
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
pSBzRuled->GetAllPatchesIsocurves( false, vCrv) ;
|
||||
vSyncPoints.reserve( vCrv.size()) ;
|
||||
for ( int i = 0 ; i < int( vCrv.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCrv) ; ++ i) {
|
||||
if ( ! IsNull( vCrv[i]) && vCrv[i]->IsValid()) {
|
||||
#if DEBUG_SYNC_POINTS
|
||||
VT.emplace_back( vCrv[i]->Clone()) ;
|
||||
@@ -4035,14 +4020,14 @@ GetTrimmingAdjSurfs( const CISURFPVECTOR& vSurf, const CISURFPVECTOR& vOtherSurf
|
||||
// Recupero le Patch delle superfici
|
||||
SURFPATCHESVECTOR vSurfPatches ; vSurfPatches.reserve( vSurf.size() + vOtherSurf.size()) ;
|
||||
// --- Superfici Selezionate
|
||||
for ( int nS = 0 ; nS < int( vSurf.size()) ; ++ nS) {
|
||||
for ( int nS = 0 ; nS < ssize( vSurf) ; ++ nS) {
|
||||
vSurfPatches.emplace_back( SurfPatches()) ;
|
||||
vSurfPatches.back().pSurf = vSurf[nS] ;
|
||||
if ( ! CalcSurfPatch( vSurf[nS], dLinTol, dAngTol, vSurfPatches.back()))
|
||||
return false ;
|
||||
}
|
||||
// --- Altre Superfici
|
||||
for ( int nS = 0 ; nS < int( vOtherSurf.size()) ; ++ nS) {
|
||||
for ( int nS = 0 ; nS < ssize( vOtherSurf) ; ++ nS) {
|
||||
vSurfPatches.emplace_back( SurfPatches()) ;
|
||||
vSurfPatches.back().pSurf = vOtherSurf[nS] ;
|
||||
if ( ! CalcSurfPatch( vOtherSurf[nS], dLinTol, dAngTol, vSurfPatches.back()))
|
||||
@@ -4225,7 +4210,7 @@ GetTrimmingAdjSurfs( const CISURFPVECTOR& vSurf, const CISURFPVECTOR& vOtherSurf
|
||||
// della tolleranza angolare
|
||||
INTVECTOR vSurfToCheck ;
|
||||
INTSET setSurf ;
|
||||
for ( int i = 0 ; i < int( vSurf.size()) ; ++ i)
|
||||
for ( int i = 0 ; i < ssize( vSurf) ; ++ i)
|
||||
vSurfToCheck.push_back( i) ;
|
||||
|
||||
// Finchè ho una superficie da analizzare
|
||||
@@ -4341,7 +4326,7 @@ GetTrimmingAdjSurfs( const CISURFPVECTOR& vSurf, const CISURFPVECTOR& vOtherSurf
|
||||
#endif
|
||||
vSurfToCheck.emplace_back( nOtherSurf) ;
|
||||
OtherPatch.bErase = true ;
|
||||
if ( nOtherSurf >= int( vSurf.size()) &&
|
||||
if ( nOtherSurf >= ssize( vSurf) &&
|
||||
find( vIndOtherSurf.begin(), vIndOtherSurf.end(), nOtherSurf - ssize( vSurf)) == vIndOtherSurf.end())
|
||||
vIndOtherSurf.push_back( nOtherSurf - ssize( vSurf)) ;
|
||||
}
|
||||
@@ -4466,107 +4451,105 @@ GetTrimmingHoleBorders( const CISURFPVECTOR& vpSurf, const Point3d& ptRef, doubl
|
||||
|
||||
// Vedo se ci sono curve da accoppiare tra di loro
|
||||
vHoleBorders.reserve( vHoles.size()) ;
|
||||
if ( ssize( vHoles) > 1) {
|
||||
for ( int i = 0 ; i < ssize( vHoles) - 1 ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vHoles) - 1 ; ++ i) {
|
||||
// Recupero la curva corrente, se non presente allora passo alla successiva
|
||||
if ( IsNull( vHoles[i].pCompoHole))
|
||||
continue ;
|
||||
int nIndJ = -1 ;
|
||||
// Scorro le curve successive
|
||||
for ( int j = i + 1 ; nIndJ == -1 && j < ssize( vHoles) ; ++ j) {
|
||||
// Recupero la curva corrente, se non presente allora passo alla successiva
|
||||
if ( IsNull( vHoles[i].pCompoHole))
|
||||
continue ;
|
||||
int nIndJ = -1 ;
|
||||
// Scorro le curve successive
|
||||
for ( int j = i + 1 ; nIndJ == -1 && j < ssize( vHoles) ; ++ j) {
|
||||
// Recupero la curva corrente, se non presente allora passo alla successiva
|
||||
if ( IsNull( vHoles[i].pCompoHole))
|
||||
continue ;
|
||||
// Se il tipo è differente non possono essere in coppia
|
||||
if ( vHoles[i].nType != vHoles[j].nType)
|
||||
continue ;
|
||||
// Essendo della stessa topologia, verifico i parametri
|
||||
bool bCouple = false ;
|
||||
Vector3d vtCenCen ;
|
||||
if ( vHoles[i].nType == HoleType::CIRCLE) {
|
||||
bCouple = ( abs( vHoles[i].dRad - vHoles[j].dRad) < dMyEdgeLinTol &&
|
||||
AreSameOrOppositeVectorEpsilon( vHoles[i].frCompo.VersZ(), vHoles[j].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
// Se il tipo è differente non possono essere in coppia
|
||||
if ( vHoles[i].nType != vHoles[j].nType)
|
||||
continue ;
|
||||
// Essendo della stessa topologia, verifico i parametri
|
||||
bool bCouple = false ;
|
||||
Vector3d vtCenCen ;
|
||||
if ( vHoles[i].nType == HoleType::CIRCLE) {
|
||||
bCouple = ( abs( vHoles[i].dRad - vHoles[j].dRad) < dMyEdgeLinTol &&
|
||||
AreSameOrOppositeVectorEpsilon( vHoles[i].frCompo.VersZ(), vHoles[j].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
if ( bCouple) {
|
||||
vtCenCen = ( vHoles[i].frCompo.Orig() - vHoles[j].frCompo.Orig()) ;
|
||||
bCouple = ( vtCenCen.SqLen() > dMyEdgeLinTol * dMyEdgeLinTol) ;
|
||||
if ( bCouple) {
|
||||
vtCenCen = ( vHoles[i].frCompo.Orig() - vHoles[j].frCompo.Orig()) ;
|
||||
bCouple = ( vtCenCen.SqLen() > dMyEdgeLinTol * dMyEdgeLinTol) ;
|
||||
if ( bCouple) {
|
||||
bCouple = ( vtCenCen.Normalize() &&
|
||||
AreSameOrOppositeVectorEpsilon( vtCenCen, vHoles[i].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
}
|
||||
bCouple = ( vtCenCen.Normalize() &&
|
||||
AreSameOrOppositeVectorEpsilon( vtCenCen, vHoles[i].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
}
|
||||
}
|
||||
else if ( vHoles[i].nType == HoleType::BUTTONHOLE) {
|
||||
bCouple = ( abs( vHoles[i].dRad - vHoles[j].dRad) < dMyEdgeLinTol &&
|
||||
abs( vHoles[i].dLen - vHoles[j].dLen) < dMyEdgeLinTol &&
|
||||
AreSameOrOppositeVectorEpsilon( vHoles[i].frCompo.VersZ(), vHoles[j].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
if ( bCouple) {
|
||||
vtCenCen = ( vHoles[i].frCompo.Orig() - vHoles[j].frCompo.Orig()) ;
|
||||
bCouple = ( vtCenCen.SqLen() > dMyEdgeLinTol * dMyEdgeLinTol) ;
|
||||
if ( bCouple) {
|
||||
bCouple = ( vtCenCen.Normalize() &&
|
||||
AreSameOrOppositeVectorEpsilon( vtCenCen, vHoles[i].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( bCouple)
|
||||
nIndJ = j ;
|
||||
}
|
||||
else if ( vHoles[i].nType == HoleType::BUTTONHOLE) {
|
||||
bCouple = ( abs( vHoles[i].dRad - vHoles[j].dRad) < dMyEdgeLinTol &&
|
||||
abs( vHoles[i].dLen - vHoles[j].dLen) < dMyEdgeLinTol &&
|
||||
AreSameOrOppositeVectorEpsilon( vHoles[i].frCompo.VersZ(), vHoles[j].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
if ( bCouple) {
|
||||
vtCenCen = ( vHoles[i].frCompo.Orig() - vHoles[j].frCompo.Orig()) ;
|
||||
bCouple = ( vtCenCen.SqLen() > dMyEdgeLinTol * dMyEdgeLinTol) ;
|
||||
if ( bCouple) {
|
||||
bCouple = ( vtCenCen.Normalize() &&
|
||||
AreSameOrOppositeVectorEpsilon( vtCenCen, vHoles[i].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( bCouple)
|
||||
nIndJ = j ;
|
||||
}
|
||||
|
||||
// Determino l'indice della curva da conservare
|
||||
int nInd = i ;
|
||||
// Se curva non in coppia, allora ho finito, altrimenti devo sceglierne una
|
||||
if ( nIndJ != -1) {
|
||||
int nIndToErase = nIndJ ;
|
||||
// Recupero i due Box
|
||||
BBox3d BBoxI ; vHoles[i].pCompoHole->GetLocalBBox( BBoxI) ;
|
||||
BBox3d BBoxJ ; vHoles[nIndJ].pCompoHole->GetLocalBBox( BBoxJ) ;
|
||||
// Recupero le Coordinate massime di ZGlob
|
||||
double dZI = BBoxI.GetMax().z ;
|
||||
double dZJ = BBoxJ.GetMax().z ;
|
||||
// Se le 2 curve hanno ZGlob massime differente tra loro
|
||||
if ( abs( dZI - dZJ) > 5. * EPS_SMALL) {
|
||||
// Tengo la Curva con ZGlob massima
|
||||
if ( dZJ > dZI)
|
||||
// Determino l'indice della curva da conservare
|
||||
int nInd = i ;
|
||||
// Se curva non in coppia, allora ho finito, altrimenti devo sceglierne una
|
||||
if ( nIndJ != -1) {
|
||||
int nIndToErase = nIndJ ;
|
||||
// Recupero i due Box
|
||||
BBox3d BBoxI ; vHoles[i].pCompoHole->GetLocalBBox( BBoxI) ;
|
||||
BBox3d BBoxJ ; vHoles[nIndJ].pCompoHole->GetLocalBBox( BBoxJ) ;
|
||||
// Recupero le Coordinate massime di ZGlob
|
||||
double dZI = BBoxI.GetMax().z ;
|
||||
double dZJ = BBoxJ.GetMax().z ;
|
||||
// Se le 2 curve hanno ZGlob massime differente tra loro
|
||||
if ( abs( dZI - dZJ) > 5. * EPS_SMALL) {
|
||||
// Tengo la Curva con ZGlob massima
|
||||
if ( dZJ > dZI)
|
||||
swap( nInd, nIndToErase) ;
|
||||
}
|
||||
// Se invece le ZGlob sono circa uguali
|
||||
else {
|
||||
// Tengo la Curva più distante dal punto di Riferimento ( se Valido)
|
||||
if ( ptRef.IsValid()) {
|
||||
double dSqDistI = INFINITO, dSqDistJ = INFINITO ;
|
||||
DistPointCurve( ptRef, *vHoles[i].pCompoHole).GetSqDist( dSqDistI) ;
|
||||
DistPointCurve( ptRef, *vHoles[nIndJ].pCompoHole).GetSqDist( dSqDistJ) ;
|
||||
if ( dSqDistJ > dSqDistI)
|
||||
swap( nInd, nIndToErase) ;
|
||||
}
|
||||
// Se invece le ZGlob sono circa uguali
|
||||
else {
|
||||
// Tengo la Curva più distante dal punto di Riferimento ( se Valido)
|
||||
if ( ptRef.IsValid()) {
|
||||
double dSqDistI = INFINITO, dSqDistJ = INFINITO ;
|
||||
DistPointCurve( ptRef, *vHoles[i].pCompoHole).GetSqDist( dSqDistI) ;
|
||||
DistPointCurve( ptRef, *vHoles[nIndJ].pCompoHole).GetSqDist( dSqDistJ) ;
|
||||
if ( dSqDistJ > dSqDistI)
|
||||
swap( nInd, nIndToErase) ;
|
||||
}
|
||||
}
|
||||
// Elimino la curva non significativa delle 2
|
||||
vHoles[nIndToErase].pCompoHole.Reset() ;
|
||||
}
|
||||
|
||||
// Imposto Estrusione alla curva nInd-esima
|
||||
Vector3d vtExtr = vHoles[nInd].frCompo.VersZ() ;
|
||||
// Se Estrusione perpendicolare a Z_AX
|
||||
if ( OrthoCompo( Z_AX, vtExtr).Len() > 1 - 5. * EPS_SMALL) {
|
||||
// Se punto di Riferimento valido
|
||||
if ( ptRef.IsValid()) {
|
||||
Vector3d vtCenCen = vHoles[nInd].frCompo.Orig() - ptRef ;
|
||||
vtCenCen.Normalize() ;
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( ( vtExtr * vtCenCen > 0.) ? vtExtr : - vtExtr) ;
|
||||
}
|
||||
else
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( vtExtr) ;
|
||||
}
|
||||
// Se estrusione non perpendicolare a Z_AX
|
||||
else
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( ( vtExtr * Z_AX > 0.) ? vtExtr : - vtExtr) ;
|
||||
|
||||
// Imposso Spessore alla curva nInd-esima
|
||||
vHoles[nInd].pCompoHole->SetThickness( - dMyEdgeThick) ;
|
||||
|
||||
// Memorizzo la curva nInd-esima
|
||||
vHoleBorders.emplace_back( Release( vHoles[nInd].pCompoHole)) ;
|
||||
// Elimino la curva non significativa delle 2
|
||||
vHoles[nIndToErase].pCompoHole.Reset() ;
|
||||
}
|
||||
|
||||
// Imposto Estrusione alla curva nInd-esima
|
||||
Vector3d vtExtr = vHoles[nInd].frCompo.VersZ() ;
|
||||
// Se Estrusione perpendicolare a Z_AX
|
||||
if ( OrthoCompo( Z_AX, vtExtr).Len() > 1 - 5. * EPS_SMALL) {
|
||||
// Se punto di Riferimento valido
|
||||
if ( ptRef.IsValid()) {
|
||||
Vector3d vtCenCen = vHoles[nInd].frCompo.Orig() - ptRef ;
|
||||
vtCenCen.Normalize() ;
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( ( vtExtr * vtCenCen > 0.) ? vtExtr : - vtExtr) ;
|
||||
}
|
||||
else
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( vtExtr) ;
|
||||
}
|
||||
// Se estrusione non perpendicolare a Z_AX
|
||||
else
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( ( vtExtr * Z_AX > 0.) ? vtExtr : - vtExtr) ;
|
||||
|
||||
// Imposso Spessore alla curva nInd-esima
|
||||
vHoles[nInd].pCompoHole->SetThickness( - dMyEdgeThick) ;
|
||||
|
||||
// Memorizzo la curva nInd-esima
|
||||
vHoleBorders.emplace_back( Release( vHoles[nInd].pCompoHole)) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
Reference in New Issue
Block a user