EgtGeomKernel :

- ripristinata AssociatePolyLinesMinDistPoints ( la modifica è stata spostata nell'executor solo per associazione nel caso di spiralize della curva).
This commit is contained in:
SaraP
2025-09-08 17:32:46 +02:00
parent 5230261be8
commit 8ddc1c70e1
-74
View File
@@ -1609,8 +1609,6 @@ SplitPolyLineAtPoint( const PolyLine& plPoly, const Point3d& ptP, double dToler,
bool
AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIVECTOR& vPnt1, PNTIVECTOR& vPnt2, bool& bCommonInternalPoints)
{
const double CORNER_COS = 0.96 ;
// controllo che le polyline abbiano almeno un punto
int nPnt1 = PL1.GetPointNbr() ;
int nPnt2 = PL2.GetPointNbr() ;
@@ -1637,36 +1635,6 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
}
int nTotP2 = int( vPnt2.size()) ;
// individuo gli spigoli
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() ;
// calcoli per prima curva
int nLastJ = 0 ;
vPnt1[0].second = 0 ;
@@ -1698,28 +1666,6 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
nLastJ = nMinJ ;
}
// correzione per associare spigoli : 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 ;
}
}
// calcoli per seconda curva
int nLastI = 0 ;
vPnt2[0].second = 0 ;
@@ -1749,26 +1695,6 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
vPnt2[j].second = nMinI ;
nLastI = nMinI ;
}
// correzione per associare spigoli
for ( int i = 0 ; i < nTotP2 ; i ++) {
if ( vSharpCorner2[i] && ! vSharpCorner1[vPnt2[i].second]) {
int nPrevI = ( i == 0 ? 0 : i - 1) ;
int nNextI = ( i == nTotP2 - 1 ? i : i + 1) ;
int nPrevJ = vPnt2[nPrevI].second ;
int nNextJ = vPnt2[nNextI].second ;
int nStart = ( vSharpCorner1[nPrevJ] ? nPrevJ + 1 : nPrevJ) ;
int nEnd = ( vSharpCorner1[nNextJ] ? nNextJ - 1 : nNextJ) ;
double dMinDist = INFINITO ;
int nCorner = vPnt2[i].second ;
for ( int j = nStart ; j <= nEnd ; j ++) {
if ( vSharpCorner1[j] && Dist( vPnt2[i].first, vPnt1[j].first) < dMinDist)
nCorner = j ;
}
vPnt2[i].second = nCorner ;
}
}
return true ;
}