diff --git a/ChainCurves.cpp b/ChainCurves.cpp index 280cc27..426ef0d 100644 --- a/ChainCurves.cpp +++ b/ChainCurves.cpp @@ -169,7 +169,7 @@ ChainCurves::GetChainFromPoint( const Point3d& ptStart, const Vector3d& vtStart, ptCurr = bEquiv ? m_vCrvData[nId].ptEnd : m_vCrvData[nId].ptStart ; vtCurr = bEquiv ? m_vCrvData[nId].vtEnd : - m_vCrvData[nId].vtStart ; // verifico se sono arrivato al punto di chiusura - if ( AreSamePointEpsilon( ptCurr, ptStop, m_dToler)) { + if ( AreSamePointEpsilon( ptCurr, ptStop, 0.5 * EPS_SMALL)) { bStopped = true ; break ; } diff --git a/SurfAux.cpp b/SurfAux.cpp index e2aa4c4..d234d60 100644 --- a/SurfAux.cpp +++ b/SurfAux.cpp @@ -29,6 +29,7 @@ #define SAVEMKUNIF_CRVS 0 #if SAVEMKUNIF_CRVS + std::vector vGeo ; #include "/EgtDev/Include/EGkGeoObjSave.h" #endif @@ -618,7 +619,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons #if SAVEMKUNIF_CRVS //debug - vector vGeo ; + vGeo.clear() ; for( int i = 0 ; i < ssize( vLoop); ++i){ vGeo.push_back(vLoop[i]->Clone()) ; } @@ -654,7 +655,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons for ( int l = 0 ; l < ssize( vLoop); ++l) { #if SAVEMKUNIF_CRVS //debug - vector vGeo ; + vGeo.clear() ; vGeo.push_back(pTrimMask->Clone()) ; vGeo.push_back(vLoop[l]->Clone()) ; SaveGeoObj( vGeo, "D:\\Temp\\bezier\\import3dm\\trim_error\\failed_trim_crv_inters.nge") ; @@ -741,7 +742,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons #if SAVEMKUNIF_CRVS //debug - vector vGeo ; + vGeo.clear() ; for( int i = 0 ; i < ssize( vCrvStrip); ++i){ vGeo.push_back(vCrvStrip[i]->Clone()) ; } @@ -784,7 +785,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons #if SAVEMKUNIF_CRVS //debug - vector vGeo ; + vGeo.clear() ; for( int i = 0 ; i < ssize( vCrvStrip); ++i){ vGeo.push_back(vCrvStrip[i]->Clone()) ; } @@ -797,7 +798,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons if ( ! vUniformedCurves.empty() || ! vCrvStrip.empty()) { #if SAVEMKUNIF_CRVS //debug - vector vGeo ; + vGeo.clear() ; for( int i = 0 ; i < ssize( vUniformedCurves); ++i){ vGeo.push_back(vUniformedCurves[i]->Clone()) ; } @@ -830,6 +831,15 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons ICRVCOMPOPOVECTOR vNewCrv ; int nCrvPrec = ssize( vUniformedCurves) ; while ( chainCrv.GetChainFromNear( ORIG, false, vIds)) { + // se ho una solo curva piccola allora la salto + if ( ssize(vIds) == 1) { + double dLen = 0 ; + int nId = vIds[0] - 1 ; + if ( ( nId < nCrvPrec && vUniformedCurves[nId]->GetLength( dLen) && dLen < dChainTol) || + ( vCrvStrip[nId - ssize(vUniformedCurves)]->GetLength(dLen) && dLen < dChainTol)) + continue ; + } + vNewCrv.emplace_back( CreateBasicCurveComposite()) ; for ( int nId : vIds) { nId -= 1 ; @@ -839,6 +849,16 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons vNewCrv.back()->AddCurve( Release( vCrvStrip[nId - ssize( vUniformedCurves)]), true, dChainTol) ; } } + #if SAVEMKUNIF_CRVS + //debug + vGeo.clear() ; + for( int i = 0 ; i < ssize( vNewCrv); ++i){ + vGeo.push_back(vNewCrv[i]->Clone()) ; + } + SaveGeoObj( vGeo, "D:\\Temp\\bezier\\import3dm\\trim_error\\trim_crv_unif_AFTERchain.nge") ; + //debug + #endif + // aggiorno le curve vUniformedCurves.clear() ; vUniformedCurves.swap( vNewCrv) ; @@ -871,7 +891,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons // controllo che tutte le curve siano chiuse, sennĂ² vuol dire che ho perso qualche pezzo durante le intersezioni for ( int i = 0 ; i < ssize( vUniformedCurves); ++i) { - if ( ! vUniformedCurves[i]->IsClosed()) + if ( ! vUniformedCurves[i]->IsClosed() && ! vUniformedCurves[i]->Close()) return false ; } diff --git a/SurfFlatRegionBooleans.cpp b/SurfFlatRegionBooleans.cpp index cbd5ef9..266538a 100644 --- a/SurfFlatRegionBooleans.cpp +++ b/SurfFlatRegionBooleans.cpp @@ -20,6 +20,12 @@ #include "/EgtDev/Include/EGkIntervals.h" #include "/EgtDev/Include/EgtPointerOwner.h" +#define SAVELOOPS 0 +#if SAVELOOPS +std::vector vGeo ; +#include "/EgtDev/Include/EGkGeoObjSave.h" +#endif + using namespace std ; //---------------------------------------------------------------------------- @@ -172,6 +178,13 @@ SurfFlatRegion::Subtract( const ISurfFlatRegion& Other) pSfr.Set( new( nothrow) SurfFlatRegion) ; else pSfr.Set( MyNewSurfFromLoops( vpLoop)) ; + +#if SAVELOOPS + for (int i = 0 ; i < ssize( vpLoop) ; ++i) + vGeo.push_back( vpLoop[i]) ; + SaveGeoObj( vGeo, "D:\\Temp\\inters\\CrvCrvInters\\NewLoops.nge") ; +#endif + if ( IsNull( pSfr)) { MyTestAndDelete( vpCurve) ; MyTestAndDelete( vpLoop) ;