diff --git a/CurveArc.cpp b/CurveArc.cpp index 55ea883..101a954 100644 --- a/CurveArc.cpp +++ b/CurveArc.cpp @@ -640,7 +640,8 @@ CurveArc::Save( NgeWriter& ngeOut) const if ( ! ngeOut.WriteVector( m_VtS, ";")) return false ; // angolo al centro - if ( ! ngeOut.WriteDouble( m_dAngCenDeg, ";")) + int nDec = ( m_dRad < 0.1 * BIG_ARC_RAD ? 6 : 9) ; + if ( ! ngeOut.WriteDouble( m_dAngCenDeg, ";", false, nDec)) return false ; // deltaN if ( ! ngeOut.WriteDouble( m_dDeltaN, ";", true)) @@ -673,6 +674,7 @@ CurveArc::Load( NgeReader& ngeIn) // recupero il versore iniziale if ( ! ngeIn.ReadVector( m_VtS, ";")) return false ; + m_VtS.Normalize() ; // per garantire la precisione con raggi grandi // recupero l'angolo al centro if ( ! ngeIn.ReadDouble( m_dAngCenDeg, ";")) return false ; @@ -766,7 +768,8 @@ CurveArc::Validate( void) // eseguo il controllo m_nStatus = ( ( m_VtN.IsNormalized() && m_VtS.IsNormalized() && AreOrthoApprox( m_VtN, m_VtS) && - m_dRad > EPS_SMALL && fabs( m_dAngCenDeg) > EPS_ANG_ZERO) ? OK : ERR) ; + m_dRad > EPS_SMALL && m_dRad < MAX_ARC_RAD && + fabs( m_dAngCenDeg) > EPS_ANG_ZERO) ? OK : ERR) ; } return ( m_nStatus == OK) ; diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index a677cd9..3b1dfb6 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/GeoConst.h b/GeoConst.h index 6444832..30c8a3f 100644 --- a/GeoConst.h +++ b/GeoConst.h @@ -37,6 +37,12 @@ const double LIN_TOL_FINE = 0.01 ; // lunghezza minima feature lineare const double LIN_FEA_LEN_STD = 20 ; +//----------------- Costanti per archi --------------------------------------- +// raggio oltre il quale un angolo al centro EPS_ANG_ZERO produce spostamento maggiore di EPS_SMALL +const double BIG_ARC_RAD = 500000 ; +// raggio massimo ammesso per un arco +const double MAX_ARC_RAD = 50000000 ; + //----------------- Costanti per archi come curve di Bezier ------------------ // massimo angolo al centro di un arco espresso tramite curva di Bezier const double BEZARC_ANG_CEN_MAX = 90 ; diff --git a/Vector3d.cpp b/Vector3d.cpp index c50a26b..9dac16c 100644 --- a/Vector3d.cpp +++ b/Vector3d.cpp @@ -151,7 +151,7 @@ Vector3d::Normalize( double dEps) { // se già normalizzato, ok double dSqLen = x * x + y * y + z * z ; - if ( fabs( 1.0 - dSqLen) < ( 2 * EPS_ZERO)) + if ( fabs( 1.0 - dSqLen) < ( 2 * 1000 * DBL_EPSILON)) return true ; // se troppo piccolo, errore