From 7ee0e38cecf68feb42741eb4e4ae272de0f2dc33 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 28 Nov 2022 15:18:28 +0100 Subject: [PATCH] EgtGeomKernel 2.4k6 : - migliorata IsClosedAndFlat di PolyLine (se non riesce a calcolare il piano chiama IsFlat e quindi usa PCA) - corretta RemoveCurveSmallZs per caso in cui non riesce a rimuovere il segmento incriminato. --- EgtGeomKernel.rc | Bin 11726 -> 11726 bytes PolyLine.cpp | 6 ++++-- RemoveCurveDefects.cpp | 23 ++++++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index f415dc0dabe2a3c97cb46e69e3fc6aa9714f0137..f84e23109c153dab63aadbc40eb151659329f4f6 100644 GIT binary patch delta 110 zcmX>XeJ*;#A2vp_&G-4vGfh^I(V2WtQH{}TvZAo=<^U--#?6zseVD=0wm=Fh>;V)O Q4#E(g#Dd413gs{^0Q1-)Z~y=R delta 110 zcmX>XeJ*;#A2vqQ&G-4vGfh^I(V2WtQH{}bvZAo=<^U--#?6zseVD=0wm=Fh>;V)O Q4#E(g#Dd413gs{^0P+qZXaE2J diff --git a/PolyLine.cpp b/PolyLine.cpp index 6a200a8..9357389 100644 --- a/PolyLine.cpp +++ b/PolyLine.cpp @@ -599,8 +599,10 @@ PolyLine::IsClosedAndFlat( Plane3d& plPlane, double& dArea, double dToler) const PolygonPlane PolyPlane ; for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP)) PolyPlane.AddPoint( ptP) ; - if ( ! PolyPlane.GetPlane( plPlane) || ! PolyPlane.GetArea( dArea)) - return false ; + if ( ! PolyPlane.GetPlane( plPlane) || ! PolyPlane.GetArea( dArea)) { + dArea = 0 ; + return IsFlat( plPlane, dToler) ; + } // Test each vertex to see if it is farther from plane than allowed max distance for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP)) { double dDist = ( ( ptP - ORIG) * plPlane.GetVersN()) - plPlane.GetDist() ; diff --git a/RemoveCurveDefects.cpp b/RemoveCurveDefects.cpp index c4c7d04..c0f95fa 100644 --- a/RemoveCurveDefects.cpp +++ b/RemoveCurveDefects.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2017-2022 //---------------------------------------------------------------------------- -// File : RemoveCurveDefects.cpp Data : 13.11.22 Versione : 2.4k2 +// File : RemoveCurveDefects.cpp Data : 28.11.22 Versione : 2.4k6 // Contenuto : Implementazione rimozione spikes di curva. // // @@ -114,12 +114,21 @@ RemoveCurveSmallZs( ICurveComposite* pCurve, double dLinTol) ( DistPointCurve( ptMid, *pPrevCrv).GetDist( dDistM2) && dDistM2 < dLinTol) && ( DistPointCurve( ptEnd, *pPrevCrv).GetDist( dDistE) && dDistE < dLinTol))) { // rimuovo il segmento - pCurve->RemoveJoint( i) ; - -- nCrvCount ; - -- nEnd ; - -- i ; - // porto il nuovo estremo sul punto medio - pCurve->ModifyJoint( i + 1, ptMid) ; + 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) ; + } } } }