diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 423d9f5..cff3ca5 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -255,14 +255,25 @@ CurveComposite::Close( void) // se già chiusa, non faccio alcunché if ( IsClosed()) return true ; - // aggiungo la linea di chiusura - PtrOwner pLine( CreateBasicCurveLine()) ; + // determino la distanza tra gli estremi Point3d ptStart, ptEnd ; if ( ! GetStartPoint( ptStart) || - ! GetEndPoint( ptEnd) || - ! pLine->Set( ptEnd, ptStart) || - ! AddSimpleCurve( Release( pLine))) + ! GetEndPoint( ptEnd)) return false ; + // se molto vicini li modifico + if ( SqDist( ptStart, ptEnd) < 100 * SQ_EPS_SMALL) { + Point3d ptMid = Media( ptStart, ptEnd) ; + if ( ! ModifyStart( ptMid) || + ! ModifyEnd( ptMid)) + return false ; + } + // altrimenti aggiungo la linea di chiusura + else { + PtrOwner pLine( CreateBasicCurveLine()) ; + if ( ! pLine->Set( ptEnd, ptStart) || + ! AddSimpleCurve( Release( pLine))) + return false ; + } // imposto ricalcolo della grafica m_OGrMgr.Reset() ; diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 0580985..08bfb16 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/SfrCreate.cpp b/SfrCreate.cpp index d21c5ac..6c588f9 100644 --- a/SfrCreate.cpp +++ b/SfrCreate.cpp @@ -136,14 +136,21 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b pCompo1->GetEndPoint( ptEnd) ; pCompo1->GetEndDir( vtEnd) ; pCompo1->GetMidPoint( ptMid) ; - if ( Dist( ptStart, ptEnd) <= 2 * dRadius && Dist( ptStart, ptMid) > 2 * dRadius && Dist( ptEnd, ptMid) > 2 * dRadius) { - double dAngEnd ; vtEnd.ToSpherical( nullptr, nullptr, &dAngEnd) ; - double dAngStart ; vtStart.ToSpherical( nullptr, nullptr, &dAngStart) ; - PtrOwner pClose( GetBiArc( ptEnd, dAngEnd, ptStart, dAngStart, 0.5)) ; - if ( ! IsNull( pClose)) - pCompo1->AddCurve( Release( pClose)) ; - else - pCompo1->Close() ; + if ( AreSamePointEpsilon( ptStart, ptEnd, 2 * dRadius) && Dist( ptStart, ptMid) > 2 * dRadius && Dist( ptEnd, ptMid) > 2 * dRadius) { + if ( AreSamePointEpsilon( ptStart, ptEnd, max( 0.1 * dRadius, 10 * EPS_SMALL))) { + Point3d ptNew = Media( ptStart, ptEnd) ; + pCompo1->ModifyStart( ptNew) ; + pCompo1->ModifyEnd( ptNew) ; + } + else { + double dAngEnd ; vtEnd.ToSpherical( nullptr, nullptr, &dAngEnd) ; + double dAngStart ; vtStart.ToSpherical( nullptr, nullptr, &dAngStart) ; + PtrOwner pClose( GetBiArc( ptEnd, dAngEnd, ptStart, dAngStart, 0.5)) ; + if ( ! IsNull( pClose)) + pCompo1->AddCurve( Release( pClose)) ; + else + pCompo1->Close() ; + } } // tipo di offset int nOffsType = ( bSquareMids ? ICurve::OFF_EXTEND : ICurve::OFF_FILLET) ;