EgtExecutor :
- in ExeSpiralizeCurveAlongGuide aggiunta gestione per associare gli spigoli.
This commit is contained in:
+56
-1
@@ -522,12 +522,67 @@ ExeSpiralizeCurveAlongGuide( int nCrvId, int nGuideId, double dLinTol)
|
||||
bFound = PL1.GetNextPoint( ptP1) ;
|
||||
}
|
||||
bOk = bOk && pCompoGuide->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, APP_SPECIAL_LINES, PL2) ;
|
||||
|
||||
|
||||
// associo i punti a minima distanza delle polylines
|
||||
PNTIVECTOR vPnt1, vPnt2 ;
|
||||
bool bTmp ;
|
||||
bOk = bOk && AssociatePolyLinesMinDistPoints( PL1, PL2, vPnt1, vPnt2, bTmp) ;
|
||||
|
||||
// correzione per gestione ottimale degli spigoli :
|
||||
// individuo gli spigoli
|
||||
const double CORNER_COS = 0.96 ;
|
||||
int nTotP1 = vPnt1.size() ;
|
||||
int nTotP2 = vPnt2.size() ;
|
||||
BOOLVECTOR vSharpCorner1( nTotP1, false), vSharpCorner2( nTotP2, false) ;
|
||||
for ( int i = 0 ; i < nTotP1 - 1 ; i ++) {
|
||||
// se estremo di curva aperta non è spigolo
|
||||
if ( i == 0 && ! PL1.IsClosed())
|
||||
continue ;
|
||||
// recupero direzioni precedente e successiva
|
||||
int nPrevI = ( i == 0 ? nTotP1 - 2 : i - 1) ;
|
||||
int nNextI = i + 1 ;
|
||||
Vector3d vtPrev = vPnt1[i].first - vPnt1[nPrevI].first ;
|
||||
vtPrev.Normalize() ;
|
||||
Vector3d vtNext = vPnt1[nNextI].first - vPnt1[i].first ;
|
||||
vtNext.Normalize() ;
|
||||
vSharpCorner1[i] = ( vtPrev * vtNext < CORNER_COS) ;
|
||||
}
|
||||
vSharpCorner1.back() = vSharpCorner1.front() ;
|
||||
|
||||
for ( int i = 0 ; i < nTotP2 - 1 ; i ++) {
|
||||
if ( i == 0 && ! PL2.IsClosed())
|
||||
continue ;
|
||||
int nPrevI = ( i == 0 ? nTotP2 - 2 : i - 1) ;
|
||||
int nNextI = i + 1 ;
|
||||
Vector3d vtPrev = vPnt2[i].first - vPnt2[nPrevI].first ;
|
||||
vtPrev.Normalize() ;
|
||||
Vector3d vtNext = vPnt2[nNextI].first - vPnt2[i].first ;
|
||||
vtNext.Normalize() ;
|
||||
vSharpCorner2[i] = ( vtPrev * vtNext < CORNER_COS) ;
|
||||
}
|
||||
vSharpCorner2.back() = vSharpCorner2.front() ;
|
||||
|
||||
// se spigolo non associato ad altro spigolo, verifico se esiste un possibile spigolo da associare
|
||||
for ( int i = 0 ; i < nTotP1 ; i ++) {
|
||||
if ( vSharpCorner1[i] && ! vSharpCorner2[vPnt1[i].second]) {
|
||||
// individuo i limiti per la ricerca dello spigolo
|
||||
int nPrevI = ( i == 0 ? 0 : i - 1) ;
|
||||
int nNextI = ( i == nTotP1 - 1 ? i : i + 1) ;
|
||||
int nPrevJ = vPnt1[nPrevI].second ;
|
||||
int nNextJ = vPnt1[nNextI].second ;
|
||||
int nStart = ( vSharpCorner2[nPrevJ] ? nPrevJ + 1 : nPrevJ) ;
|
||||
int nEnd = ( vSharpCorner2[nNextJ] ? nNextJ - 1 : nNextJ) ;
|
||||
double dMinDist = INFINITO ;
|
||||
int nCorner = vPnt1[i].second ;
|
||||
// cerco lo spigolo più vicino nel range fissato
|
||||
for ( int j = nStart ; j <= nEnd ; j ++) {
|
||||
if ( vSharpCorner2[j] && Dist( vPnt1[i].first, vPnt2[j].first) < dMinDist)
|
||||
nCorner = j ;
|
||||
}
|
||||
vPnt1[i].second = nCorner ;
|
||||
}
|
||||
}
|
||||
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
bOk = bOk && ! IsNull( pCompo) ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user