EgtGeomKernel :
- piccola correzione in RemoveCurveSmallParts.
This commit is contained in:
+30
-29
@@ -158,7 +158,6 @@ RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol)
|
||||
Point3d ptStart ; pFirstCrv->GetStartPoint( ptStart) ;
|
||||
delete( pCurve->RemoveFirstOrLastCurve( false)) ;
|
||||
pCurve->ModifyStart( ptStart) ;
|
||||
-- nCrvCount ;
|
||||
}
|
||||
// curva finale
|
||||
const ICurve* pLastCrv = pCurve->GetLastCurve() ;
|
||||
@@ -167,38 +166,40 @@ RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol)
|
||||
Point3d ptEnd ; pLastCrv->GetStartPoint( ptEnd) ;
|
||||
delete( pCurve->RemoveFirstOrLastCurve( true)) ;
|
||||
pCurve->ModifyEnd( ptEnd) ;
|
||||
-- nCrvCount ;
|
||||
}
|
||||
}
|
||||
// ciclo sulle curve elementari della composita
|
||||
int nStart = pCurve->IsClosed() ? 0 : 1 ;
|
||||
int nEnd = pCurve->IsClosed() ? nCrvCount : nCrvCount - 1 ;
|
||||
for ( int i = nStart ; i < nEnd ; ++ i) {
|
||||
// recupero la curva corrente
|
||||
const ICurve* pCurrCrv = pCurve->GetCurve( i) ;
|
||||
// se la curva corrente è troppo corta
|
||||
double dLen ; pCurrCrv->GetLength( dLen) ;
|
||||
if ( dLen < dLinTol) {
|
||||
// recupero il punto medio della curva
|
||||
Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ;
|
||||
// rimuovo il segmento
|
||||
if ( pCurve->RemoveJoint( i)) {
|
||||
-- nCrvCount ;
|
||||
-- nEnd ;
|
||||
-- i ;
|
||||
// porto il nuovo estremo sul punto medio
|
||||
pCurve->ModifyJoint( i + 1, ptMid) ;
|
||||
}
|
||||
// altrimenti devo rimuovere anche il successivo
|
||||
else if ( pCurve->RemoveJoint( i + 1) && pCurve->RemoveJoint( i)) {
|
||||
nCrvCount -= 2 ;
|
||||
nEnd -= 2 ;
|
||||
-- i ;
|
||||
// porto il nuovo estremo sul punto medio
|
||||
pCurve->ModifyJoint( i + 1, ptMid) ;
|
||||
// ciclo sulle curve elementari della composita finchè trovo tratti da eliminare
|
||||
bool bRemoved = false ;
|
||||
do {
|
||||
int nStart = pCurve->IsClosed() ? 0 : 1 ;
|
||||
int nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ;
|
||||
bRemoved = false ;
|
||||
for ( int i = nStart ; i < nEnd ; ++ i) {
|
||||
// recupero la curva corrente
|
||||
const ICurve* pCurrCrv = pCurve->GetCurve( i) ;
|
||||
// se la curva corrente è troppo corta
|
||||
double dLen ; pCurrCrv->GetLength( dLen) ;
|
||||
if ( dLen < dLinTol) {
|
||||
// recupero il punto medio della curva
|
||||
Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ;
|
||||
// rimuovo il segmento
|
||||
if ( pCurve->RemoveJoint( i)) {
|
||||
bRemoved = true ;
|
||||
// porto il nuovo estremo sul punto medio
|
||||
pCurve->ModifyJoint( i, ptMid) ;
|
||||
break ;
|
||||
}
|
||||
// altrimenti devo rimuovere anche il successivo
|
||||
else if ( pCurve->RemoveJoint( i + 1) && pCurve->RemoveJoint( i)) {
|
||||
bRemoved = true ;
|
||||
// porto il nuovo estremo sul punto medio
|
||||
pCurve->ModifyJoint( i, ptMid) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while ( bRemoved) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user