diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 696ddbc..d8046fc 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -38,6 +38,9 @@ using namespace std ; +//---------------------------------------------------------------------------- +static const double EPS_CONNECT = 0.01 * EPS_SMALL ; + //---------------------------------------------------------------------------- GEOOBJ_REGISTER( CRV_COMPO, NGE_C_CMP, CurveComposite) ; @@ -215,7 +218,7 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT // verifico sia in continuitā con il finale attuale Point3d ptEnd ; GetEndPoint( ptEnd) ; - if ( ! AreSamePointEpsilon( ptCrvStart, ptEnd, 0.01 * EPS_SMALL)) { + if ( ! AreSamePointEpsilon( ptCrvStart, ptEnd, EPS_CONNECT)) { // se in tolleranza, modifico l'inizio dell'entitā if ( SqDist( ptCrvStart, ptEnd) < ( dLinTol * dLinTol)) { // lunghezza della curva originale @@ -237,7 +240,7 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT // verifico sia in continuitā con l'iniziale attuale Point3d ptStart ; GetStartPoint( ptStart) ; - if ( ! AreSamePointEpsilon( ptCrvEnd, ptStart, 0.01 * EPS_SMALL)) { + if ( ! AreSamePointEpsilon( ptCrvEnd, ptStart, EPS_CONNECT)) { // se in tolleranza, modifico la fine dell'entitā if ( SqDist( ptCrvEnd, ptStart) < ( dLinTol * dLinTol)) { // lunghezza della curva originale @@ -267,7 +270,8 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT // imposto ricalcolo Voronoi ResetVoronoiObject() ; - return Validate() ; + + return TestClosure() ; } //---------------------------------------------------------------------------- @@ -857,20 +861,31 @@ CurveComposite::Validate( void) } // verifico chiusura - if ( IsClosed()) { - Point3d ptStart ; m_CrvSmplS.front()->GetStartPoint( ptStart) ; - Point3d ptEnd ; m_CrvSmplS.back()->GetEndPoint( ptEnd) ; - // se distanza superiore al limite ridotto forzo i punti a coincidere - if ( ! AreSamePointEpsilon( ptStart, ptEnd, 0.01 * EPS_SMALL)) { - Point3d ptM = Media( ptStart, ptEnd) ; - m_CrvSmplS.front()->ModifyStart( ptM) ; - m_CrvSmplS.back()->ModifyEnd( ptM) ; - } - } + TestClosure() ; return ( m_nStatus == OK) ; } +//---------------------------------------------------------------------------- +bool +CurveComposite::TestClosure( void) +{ + // se non č chiusa, esco subito + if ( ! IsClosed()) + return true ; + // verifico ed eventualmente aggiusto coincidenza punti estremi + Point3d ptStart ; m_CrvSmplS.front()->GetStartPoint( ptStart) ; + Point3d ptEnd ; m_CrvSmplS.back()->GetEndPoint( ptEnd) ; + // se distanza superiore al limite ridotto forzo i punti a coincidere + if ( ! AreSamePointEpsilon( ptStart, ptEnd, EPS_CONNECT)) { + Point3d ptM = Media( ptStart, ptEnd) ; + if ( ! m_CrvSmplS.front()->ModifyStart( ptM) || + ! m_CrvSmplS.back()->ModifyEnd( ptM)) + return false ; + } + return true ; +} + //---------------------------------------------------------------------------- bool CurveComposite::IsFlat( Plane3d& plPlane, bool bUseExtrusion, double dToler) const diff --git a/CurveComposite.h b/CurveComposite.h index a5b7f95..ee458fc 100644 --- a/CurveComposite.h +++ b/CurveComposite.h @@ -199,6 +199,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW private : bool CopyFrom( const CurveComposite& ccSrc) ; bool Validate( void) ; + bool TestClosure( void) ; bool AddCurveByRelocate( CurveComposite& ccSrc, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ; bool AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ; bool GetIndSCurveAndLocPar( double dU, Side nS, int& nSCrv, double& dLocU) const ; diff --git a/GdbIterator.cpp b/GdbIterator.cpp index f5f7d26..21dfb1a 100644 --- a/GdbIterator.cpp +++ b/GdbIterator.cpp @@ -1468,7 +1468,8 @@ GdbIterator::SetInfo( const string& sKey, int nInfo) bool GdbIterator::SetInfo( const string& sKey, double dInfo) { - return SetInfo( sKey, ToString( dInfo)) ; + int nErr ; + return ( SetInfo( sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ; } //---------------------------------------------------------------------------- diff --git a/GdbObj.cpp b/GdbObj.cpp index 0bdda80..bf8f258 100644 --- a/GdbObj.cpp +++ b/GdbObj.cpp @@ -862,7 +862,8 @@ GdbObj::SetInfo( const string& sKey, int nInfo) bool GdbObj::SetInfo( const string& sKey, double dInfo) { - return SetInfo( sKey, ToString( dInfo)) ; + int nErr ; + return ( SetInfo( sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ; } //---------------------------------------------------------------------------- diff --git a/GeomDB.cpp b/GeomDB.cpp index 80a13bc..e8a6374 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -2785,7 +2785,8 @@ GeomDB::SetInfo( int nId, const string& sKey, int nInfo) bool GeomDB::SetInfo( int nId, const string& sKey, double dInfo) { - return SetInfo( nId, sKey, ToString( dInfo)) ; + int nErr ; + return ( SetInfo( nId, sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ; } //----------------------------------------------------------------------------