diff --git a/CurveArc.cpp b/CurveArc.cpp index 75ce94e..c6595b0 100644 --- a/CurveArc.cpp +++ b/CurveArc.cpp @@ -55,7 +55,8 @@ class ArcApproxer //---------------------------------------------------------------------------- CurveArc::CurveArc( void) - : m_nStatus( TO_VERIFY), m_PtCen(), m_VtN(), m_VtS(), m_dRad( 0), m_dAngCenDeg( 0), m_dDeltaN( 0) + : m_nStatus( TO_VERIFY), m_PtCen(), m_VtN(), m_VtS(), m_dRad(), + m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick() { } @@ -443,6 +444,8 @@ CurveArc::CopyFrom( const CurveArc& caSrc) { if ( &caSrc == this) return true ; + m_VtExtr = caSrc.m_VtExtr ; + m_dThick = caSrc.m_dThick ; return Set( caSrc.m_PtCen, caSrc.m_VtN, caSrc.m_dRad, caSrc.m_VtS, caSrc.m_dAngCenDeg, caSrc.m_dDeltaN) ; } @@ -509,6 +512,11 @@ CurveArc::Save( NgeWriter& ngeOut) const // deltaN if ( ! ngeOut.WriteDouble( m_dDeltaN, ";", true)) return false ; + // da versione 1008 : linea con VtEstrusione e Spessore + if ( ! ngeOut.WriteVector( m_VtExtr, ";")) + return false ; + if ( ! ngeOut.WriteDouble( m_dThick, ";", true)) + return false ; return true ; } @@ -538,6 +546,13 @@ CurveArc::Load( NgeReader& ngeIn) // recupero il delta N if ( ! ngeIn.ReadDouble( m_dDeltaN, ";", true)) return false ; + // da versione 1008 : linea con VtEstrusione e Spessore + if ( ngeIn.GetFileVersion() >= NGE_VER_1008) { + if ( ! ngeIn.ReadVector( m_VtExtr, ";")) + return false ; + if ( ! ngeIn.ReadDouble( m_dThick, ";", true)) + return false ; + } // eseguo validazione return Validate() ; } @@ -613,10 +628,17 @@ CurveArc::IsFlat( Plane3d& plPlane, double dToler) const return false ; // assegno dati possibile piano - plPlane.vtN = m_VtN ; + bool bFlat = IsFlat( dToler) ; + if ( m_VtExtr.IsSmall()) { + plPlane.vtN = m_VtN ; + } + else { + plPlane.vtN = m_VtExtr ; + bFlat = bFlat && AreSameOrOppositeVectorApprox( m_VtExtr, m_VtN) ; + } plPlane.dDist = ( m_PtCen - ORIG) * plPlane.vtN ; - // verifico piattezza - return IsFlat( dToler) ; + // ritorno conferma + return bFlat ; } //---------------------------------------------------------------------------- @@ -1265,6 +1287,8 @@ CurveArc::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou m_PtCen.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; m_VtN.Rotate( vtAx, dCosAng, dSinAng) ; m_VtS.Rotate( vtAx, dCosAng, dSinAng) ; + // ruoto il vettore estrusione + m_VtExtr.Rotate( vtAx, dCosAng, dSinAng) ; return true ; } @@ -1294,6 +1318,13 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC m_dDeltaN *= dCoeffX ; if ( dCoeffX < 0) m_VtS = - m_VtS ; + // scalo vettore estrusione, lo normalizzo e aggiusto spessore + m_VtExtr.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; + double dLen = m_VtExtr.Len() ; + if ( dLen > EPS_ZERO) { + m_VtExtr /= dLen ; + m_dThick *= dLen ; + } m_nStatus = TO_VERIFY ; return Validate() ; @@ -1319,6 +1350,8 @@ CurveArc::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) m_VtN.Mirror( vtNorm) ; m_VtS.Mirror( vtNorm) ; m_dAngCenDeg *= -1 ; + // specchio il vettore estrusione + m_VtExtr.Mirror( vtNorm) ; return true ; } @@ -1337,7 +1370,7 @@ CurveArc::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vt // possibile solo se l'arco è piatto e il piano di scorrimento coincide con quello dell'arco if ( ! ( fabs( m_dDeltaN) < EPS_SMALL) || - ! ( AreSameVectorExact( m_VtN, vtNorm) || AreOppositeVectorExact( m_VtN, vtNorm))) + ! AreSameOrOppositeVectorExact( m_VtN, vtNorm)) return false ; // imposto ricalcolo della grafica @@ -1345,6 +1378,13 @@ CurveArc::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vt // eseguo scorrimento del centro m_PtCen.Shear( ptOn, vtNorm, vtDir, dCoeff) ; + // eseguo scorrimento del vettore estrusione, lo normalizzo e aggiusto spessore + m_VtExtr.Shear( vtNorm, vtDir, dCoeff) ; + double dLen = m_VtExtr.Len() ; + if ( dLen > EPS_ZERO) { + m_VtExtr /= dLen ; + m_dThick *= dLen ; + } return true ; } @@ -1367,7 +1407,8 @@ CurveArc::ToGlob( const Frame3d& frRef) // trasformo il centro e i versori return ( m_PtCen.ToGlob( frRef) && m_VtN.ToGlob( frRef) && - m_VtS.ToGlob( frRef)) ; + m_VtS.ToGlob( frRef) && + m_VtExtr.ToGlob( frRef)) ; } //---------------------------------------------------------------------------- @@ -1388,7 +1429,8 @@ CurveArc::ToLoc( const Frame3d& frRef) // trasformo il centro e i versori return ( m_PtCen.ToLoc( frRef) && m_VtN.ToLoc( frRef) && - m_VtS.ToLoc( frRef)) ; + m_VtS.ToLoc( frRef) && + m_VtExtr.ToLoc( frRef)) ; } //---------------------------------------------------------------------------- @@ -1407,9 +1449,10 @@ CurveArc::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) // imposto ricalcolo della grafica m_OGrMgr.Reset() ; // trasformo il centro e i versori - return ( m_PtCen.ToGlob( frOri) && m_PtCen.ToLoc( frDest) && - m_VtN.ToGlob( frOri) && m_VtN.ToLoc( frDest) && - m_VtS.ToGlob( frOri) && m_VtS.ToLoc( frDest)) ; + return ( m_PtCen.LocToLoc( frOri, frDest) && + m_VtN.LocToLoc( frOri, frDest) && + m_VtS.LocToLoc( frOri, frDest) && + m_VtExtr.LocToLoc( frOri, frDest)) ; } //---------------------------------------------------------------------------- diff --git a/CurveArc.h b/CurveArc.h index ba0a92e..0af952c 100644 --- a/CurveArc.h +++ b/CurveArc.h @@ -66,6 +66,10 @@ class CurveArc : public ICurveArc, public IGeoObjRW { return GetDir( 1, vtDir) ; } virtual bool GetMidDir( Vector3d& vtDir) const { return GetDir( 0.5, vtDir) ; } + virtual bool GetExtrusion( Vector3d& vtExtr) const + { vtExtr = m_VtExtr ; return ( m_nStatus == OK) ; } + virtual bool GetThickness( double& dThick) const + { dThick = m_dThick ; return ( m_nStatus == OK) ; } virtual bool GetDomain( double& dStart, double& dEnd) const { dStart = 0 ; dEnd = 1 ; return ( m_nStatus == OK) ; } virtual bool IsValidParam( double dPar, Side nSide) const @@ -92,6 +96,10 @@ class CurveArc : public ICurveArc, public IGeoObjRW virtual bool Offset( double dDist, int nSide, int nType = OFF_FILLET) ; virtual bool ModifyStart( const Point3d& ptNewStart) ; virtual bool ModifyEnd( const Point3d& ptNewEnd) ; + virtual bool SetExtrusion( const Vector3d& vtExtr) + { m_VtExtr = vtExtr ; m_VtExtr.Normalize() ; m_OGrMgr.Reset() ; return true ; } + virtual bool SetThickness( double dThick) + { m_dThick = dThick ; m_OGrMgr.Reset() ; return true ; } virtual bool TrimStartAtParam( double dUTrim) ; virtual bool TrimEndAtParam( double dUTrim) ; virtual bool TrimStartEndAtParam( double dUStartTrim, double dUEndTrim) ; @@ -165,6 +173,8 @@ class CurveArc : public ICurveArc, public IGeoObjRW double m_dRad ; // raggio double m_dAngCenDeg ; // angolo al centro in gradi (positivo se antiorario visto da VtN) double m_dDeltaN ; // variazione di quota lungo VtN della fine rispetto all'inizio + Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN) + double m_dThick ; // spessore } ; //----------------------------------------------------------------------------- diff --git a/CurveAux.cpp b/CurveAux.cpp index ac990f9..fdab918 100644 --- a/CurveAux.cpp +++ b/CurveAux.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "CurveAux.h" #include "GeoConst.h" +#include "CurveLine.h" #include "CurveArc.h" #include "CurveBezier.h" #include "CurveComposite.h" @@ -197,7 +198,15 @@ CurveDump( const ICurve& crvC, string& sOut, const char* szNewLine) sOut += "VS(" + ToString( vtDirS, 3) + ")" + szNewLine ; Vector3d vtDirE ; crvC.GetEndDir( vtDirE) ; - sOut += "VE(" + ToString( vtDirE, 3) + ")" + szNewLine ; + sOut += "VE(" + ToString( vtDirE, 3) + ")" + szNewLine ; + // eventuali direzione di estrusione e spessore + Vector3d vtExtr ; + crvC.GetExtrusion( vtExtr) ; + if ( ! vtExtr.IsSmall()) { + double dThick ; + crvC.GetThickness( dThick) ; + sOut += "Extr(" + ToString( vtExtr, 3) + ") Th=" + ToString( dThick) + szNewLine ; + } // lunghezza double dLen = 0 ; crvC.GetLength( dLen) ; diff --git a/CurveBezier.cpp b/CurveBezier.cpp index 425a577..049e111 100644 --- a/CurveBezier.cpp +++ b/CurveBezier.cpp @@ -36,8 +36,8 @@ GEOOBJ_REGISTER( CRV_BEZ, NGE_C_BEZ, CurveBezier) ; //---------------------------------------------------------------------------- CurveBezier::CurveBezier( void) - : m_nStatus( TO_VERIFY), m_nDeg( 0), m_bRat( false), m_dParSing( -2), - m_nDimArr( 0), m_aPtCtrl( nullptr), m_aWeCtrl( nullptr) + : m_nStatus( TO_VERIFY), m_nDeg(), m_bRat( false), m_dParSing( -2), + m_nDimArr(), m_aPtCtrl( nullptr), m_aWeCtrl( nullptr), m_VtExtr(), m_dThick() { } @@ -317,6 +317,8 @@ CurveBezier::CopyFrom( const CurveBezier& cbSrc) return true ; if ( ! Init( cbSrc.m_nDeg, cbSrc.m_bRat)) return false ; + m_VtExtr = cbSrc.m_VtExtr ; + m_dThick = cbSrc.m_dThick ; for ( int i = 0 ; i <= m_nDeg ; ++ i) { m_aPtCtrl[i] = cbSrc.m_aPtCtrl[i] ; if ( cbSrc.m_bRat) @@ -390,6 +392,11 @@ CurveBezier::Save( NgeWriter& ngeOut) const return false ; } } + // da versione 1008 : linea con VtEstrusione e Spessore + if ( ! ngeOut.WriteVector( m_VtExtr, ";")) + return false ; + if ( ! ngeOut.WriteDouble( m_dThick, ";", true)) + return false ; return true ; } @@ -441,6 +448,13 @@ CurveBezier::Load( NgeReader& ngeIn) return false ; } } + // da versione 1008 : linea con VtEstrusione e Spessore + if ( ngeIn.GetFileVersion() >= NGE_VER_1008) { + if ( ! ngeIn.ReadVector( m_VtExtr, ";")) + return false ; + if ( ! ngeIn.ReadDouble( m_dThick, ";", true)) + return false ; + } // eseguo validazione return Validate() ; } @@ -515,20 +529,32 @@ CurveBezier::IsFlat( Plane3d& plPlane, double dToler) const switch ( nRank) { case 0 : // punto if ( bFlat) { - plPlane.vtN = Z_AX ; + plPlane.vtN = ( m_VtExtr.IsSmall() ? Z_AX : m_VtExtr) ; plPlane.dDist = ( ptCen - ORIG) * plPlane.vtN ; } else { - plPlane.vtN = V_NULL ; + plPlane.vtN = ( m_VtExtr.IsSmall() ? V_NULL : m_VtExtr) ; plPlane.dDist = 0 ; } break ; case 1 : // linea - plPlane.vtN = FromUprightOrtho( vtDir) ; + if ( m_VtExtr.IsSmall()) { + plPlane.vtN = FromUprightOrtho( vtDir) ; + } + else { + plPlane.vtN = m_VtExtr ; + bFlat = bFlat && ( AreOrthoApprox( m_VtExtr, vtDir)) ; + } plPlane.dDist = ( ptCen - ORIG) * plPlane.vtN ; break ; default : // piana o 3d - plPlane.vtN = vtDir ; + if ( m_VtExtr.IsSmall()) { + plPlane.vtN = vtDir ; + } + else { + plPlane.vtN = m_VtExtr ; + bFlat = bFlat && ( AreSameOrOppositeVectorApprox( m_VtExtr, vtDir)) ; + } plPlane.dDist = ( ptCen - ORIG) * plPlane.vtN ; break ; } @@ -1639,6 +1665,8 @@ CurveBezier::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, // ruoto i punti di controllo for ( int i = 0 ; i <= m_nDeg ; ++ i) m_aPtCtrl[i].Rotate( ptAx, vtAx, dCosAng, dSinAng) ; + // ruoto il vettore estrusione + m_VtExtr.Rotate( vtAx, dCosAng, dSinAng) ; return true ; } @@ -1661,6 +1689,13 @@ CurveBezier::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double // scalo i punti di controllo for ( int i = 0 ; i <= m_nDeg ; ++ i) m_aPtCtrl[i].Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; + // scalo vettore estrusione, lo normalizzo e aggiusto spessore + m_VtExtr.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; + double dLen = m_VtExtr.Len() ; + if ( dLen > EPS_ZERO) { + m_VtExtr /= dLen ; + m_dThick *= dLen ; + } return true ; } @@ -1683,6 +1718,8 @@ CurveBezier::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) // specchio i punti di controllo for ( int i = 0 ; i <= m_nDeg ; ++ i) m_aPtCtrl[i].Mirror( ptOn, vtNorm) ; + // specchio il vettore estrusione + m_VtExtr.Mirror( vtNorm) ; return true ; } @@ -1705,6 +1742,13 @@ CurveBezier::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& // eseguo scorrimento dei punti di controllo for ( int i = 0 ; i <= m_nDeg ; ++ i) m_aPtCtrl[i].Shear( ptOn, vtNorm, vtDir, dCoeff) ; + // eseguo scorrimento del vettore estrusione, lo normalizzo e aggiusto spessore + m_VtExtr.Shear( vtNorm, vtDir, dCoeff) ; + double dLen = m_VtExtr.Len() ; + if ( dLen > EPS_ZERO) { + m_VtExtr /= dLen ; + m_dThick *= dLen ; + } return true ; } @@ -1727,6 +1771,8 @@ CurveBezier::ToGlob( const Frame3d& frRef) // trasformo i punti di controllo for ( int i = 0 ; i <= m_nDeg ; ++ i) m_aPtCtrl[i].ToGlob( frRef) ; + // trasformo il vettore estrusione + m_VtExtr.ToGlob( frRef) ; return true ; } @@ -1749,6 +1795,8 @@ CurveBezier::ToLoc( const Frame3d& frRef) // trasformo i punti di controllo for ( int i = 0 ; i <= m_nDeg ; ++ i) m_aPtCtrl[i].ToLoc( frRef) ; + // trasformo il vettore estrusione + m_VtExtr.ToLoc( frRef) ; return true ; } @@ -1769,10 +1817,10 @@ CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) m_OGrMgr.Reset() ; // trasformo i punti di controllo - for ( int i = 0 ; i <= m_nDeg ; ++ i) { - m_aPtCtrl[i].ToGlob( frOri) ; - m_aPtCtrl[i].ToLoc( frDest) ; - } + for ( int i = 0 ; i <= m_nDeg ; ++ i) + m_aPtCtrl[i].LocToLoc( frOri, frDest) ; + // trasformo il vettore estrusione + m_VtExtr.LocToLoc( frOri, frDest) ; return true ; } diff --git a/CurveBezier.h b/CurveBezier.h index 3005556..a5d0b27 100644 --- a/CurveBezier.h +++ b/CurveBezier.h @@ -68,6 +68,10 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW { return ::GetTang( *this, 1, FROM_MINUS, vtDir) ; } virtual bool GetMidDir( Vector3d& vtDir) const { return ::GetTang( *this, 0.5, FROM_MINUS, vtDir) ; } + virtual bool GetExtrusion( Vector3d& vtExtr) const + { vtExtr = m_VtExtr ; return ( m_nStatus == OK) ; } + virtual bool GetThickness( double& dThick) const + { dThick = m_dThick ; return ( m_nStatus == OK) ; } virtual bool GetDomain( double& dStart, double& dEnd) const { dStart = 0 ; dEnd = 1 ; return ( m_nStatus == OK) ; } virtual bool IsValidParam( double dPar, Side nSide) const @@ -95,6 +99,10 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW { return false ; } virtual bool ModifyStart( const Point3d& ptNewStart) ; virtual bool ModifyEnd( const Point3d& ptNewEnd) ; + virtual bool SetExtrusion( const Vector3d& vtExtr) + { m_VtExtr = vtExtr ; m_VtExtr.Normalize() ; m_OGrMgr.Reset() ; return true ; } + virtual bool SetThickness( double dThick) + { m_dThick = dThick ; m_OGrMgr.Reset() ; return true ; } virtual bool TrimStartAtParam( double dUTrim) ; virtual bool TrimEndAtParam( double dUTrim) ; virtual bool TrimStartEndAtParam( double dUStartTrim, double dUEndTrim) ; @@ -162,6 +170,8 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW double* m_aWeCtrl ; // array dei pesi di controllo Point3d m_aStPtCtrl[ST_PTC] ; // array predefinito di 4 punti di controllo double m_aStWeCtrl[ST_PTC] ; // array predefinito di 4 pesi di controllo + Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN) + double m_dThick ; // spessore } ; //----------------------------------------------------------------------------- diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 839c812..4c35f4c 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -33,7 +33,7 @@ GEOOBJ_REGISTER( CRV_COMPO, NGE_C_CMP, CurveComposite) ; //---------------------------------------------------------------------------- CurveComposite::CurveComposite( void) - : m_nStatus( TO_VERIFY), m_nCounter( 0), m_bClosed( false) + : m_nStatus( TO_VERIFY), m_nCounter(), m_bClosed( false), m_VtExtr(), m_dThick() { } @@ -57,6 +57,8 @@ CurveComposite::Clear( void) m_nStatus = TO_VERIFY ; m_nCounter = 0 ; m_bClosed = false ; + m_VtExtr = V_NULL ; + m_dThick = 0 ; // imposto ricalcolo della grafica m_OGrMgr.Reset() ; @@ -160,6 +162,9 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT if ( ! pCrv->IsSimple()) return false ; + // annullo l'estrusione + pCrv->SetExtrusion( V_NULL) ; + // recupero i punti iniziali e finali della curva Point3d ptStart, ptEnd ; if ( ! pCrv->GetStartPoint( ptStart) || ! pCrv->GetEndPoint( ptEnd)) @@ -281,9 +286,8 @@ CurveComposite::FromPolyLine( const PolyLine& PL) // ciclo di inserimento dei segmenti che uniscono i punti Point3d ptIni, ptFin ; - for ( bool bFound = PL.GetFirstLine( ptIni, ptFin) ; - bFound ; - bFound = PL.GetNextLine( ptIni, ptFin)) { + PL.GetFirstPoint( ptIni) ; + while ( PL.GetNextPoint( ptFin)) { // se i punti della coppia coincidono, passo alla coppia successiva if ( AreSamePointApprox( ptIni, ptFin)) continue ; @@ -297,6 +301,8 @@ CurveComposite::FromPolyLine( const PolyLine& PL) // aggiungo la retta alla curva composita if ( ! AddSimpleCurve( Release( pCrvLine))) return false ; + // aggiorno dati prossimo punto iniziale + ptIni = ptFin ; } // imposto ricalcolo della grafica @@ -317,11 +323,10 @@ CurveComposite::FromPolyArc( const PolyArc& PA) return false ; // Creo le diverse curve semplici e le inserisco in quella composita - double dBulge ; + double dBulge, dNextBulge ; Point3d ptIni, ptFin ; - for ( bool bFound = PA.GetFirstArc( ptIni, ptFin, dBulge) ; - bFound ; - bFound = PA.GetNextArc( ptIni, ptFin, dBulge)) { + PA.GetFirstPoint( ptIni, dBulge) ; + while ( PA.GetNextPoint( ptFin, dNextBulge)) { // se i punti della coppia coincidono, passo alla coppia successiva if ( AreSamePointApprox( ptIni, ptFin)) continue ; @@ -351,6 +356,9 @@ CurveComposite::FromPolyArc( const PolyArc& PA) if ( ! AddSimpleCurve( Release( pCrvArc))) return false ; } + // aggiorno dati prossimo punto iniziale + ptIni = ptFin ; + dBulge = dNextBulge ; } return true ; @@ -494,6 +502,8 @@ CurveComposite::CopyFrom( const CurveComposite& ccSrc) if ( &ccSrc == this) return true ; Clear() ; + m_VtExtr = ccSrc.m_VtExtr ; + m_dThick = ccSrc.m_dThick ; PCRVSMPL_DEQUE::const_iterator Iter ; for ( Iter = ccSrc.m_CrvSmplS.begin() ; Iter != ccSrc.m_CrvSmplS.end() ; ++Iter) { if ( ! AddCurve( **Iter)) @@ -577,6 +587,11 @@ CurveComposite::Save( NgeWriter& ngeOut) const // passo alla successiva pCrvSmpl = GetNextCurve() ; } + // da versione 1008 : linea con VtEstrusione e Spessore + if ( ! ngeOut.WriteVector( m_VtExtr, ";")) + return false ; + if ( ! ngeOut.WriteDouble( m_dThick, ";", true)) + return false ; return true ; } @@ -618,6 +633,13 @@ CurveComposite::Load( NgeReader& ngeIn) if ( ! bOk) return false ; } + // da versione 1008 : linea con VtEstrusione e Spessore + if ( ngeIn.GetFileVersion() >= NGE_VER_1008) { + if ( ! ngeIn.ReadVector( m_VtExtr, ";")) + return false ; + if ( ! ngeIn.ReadDouble( m_dThick, ";", true)) + return false ; + } return true ; } @@ -779,20 +801,32 @@ CurveComposite::IsFlat( Plane3d& plPlane, double dToler) const switch ( nRank) { case 0 : // punto if ( bFlat) { - plPlane.vtN = Z_AX ; + plPlane.vtN = ( m_VtExtr.IsSmall() ? Z_AX : m_VtExtr) ; plPlane.dDist = ( ptCen - ORIG) * plPlane.vtN ; } else { - plPlane.vtN = V_NULL ; + plPlane.vtN = ( m_VtExtr.IsSmall() ? V_NULL : m_VtExtr) ; plPlane.dDist = 0 ; } break ; case 1 : // linea - plPlane.vtN = FromUprightOrtho( vtDir) ; + if ( m_VtExtr.IsSmall()) { + plPlane.vtN = FromUprightOrtho( vtDir) ; + } + else { + plPlane.vtN = m_VtExtr ; + bFlat = bFlat && ( AreOrthoApprox( m_VtExtr, vtDir)) ; + } plPlane.dDist = ( ptCen - ORIG) * plPlane.vtN ; break ; default : // piana o 3d - plPlane.vtN = vtDir ; + if ( m_VtExtr.IsSmall()) { + plPlane.vtN = vtDir ; + } + else { + plPlane.vtN = m_VtExtr ; + bFlat = bFlat && ( AreSameOrOppositeVectorApprox( m_VtExtr, vtDir)) ; + } plPlane.dDist = ( ptCen - ORIG) * plPlane.vtN ; break ; } @@ -1534,6 +1568,8 @@ CurveComposite::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAn // ruoto i punti estremi m_PtStart.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; m_PtEnd.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; + // ruoto il vettore estrusione + m_VtExtr.Rotate( vtAx, dCosAng, dSinAng) ; return true ; } @@ -1566,7 +1602,15 @@ CurveComposite::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, dou // scalo i punti estremi m_PtStart.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; m_PtEnd.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; + // scalo vettore estrusione, lo normalizzo e aggiusto spessore + m_VtExtr.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; + double dLen = m_VtExtr.Len() ; + if ( dLen > EPS_ZERO) { + m_VtExtr /= dLen ; + m_dThick *= dLen ; + } + m_nStatus = TO_VERIFY ; return Validate() ; } @@ -1589,6 +1633,8 @@ CurveComposite::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) // specchio i punti estremi m_PtStart.Mirror( ptOn, vtNorm) ; m_PtEnd.Mirror( ptOn, vtNorm) ; + // specchio il vettore estrusione + m_VtExtr.Mirror( vtNorm) ; return true ; } @@ -1616,6 +1662,13 @@ CurveComposite::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector // eseguo scorrimento dei punti estremi m_PtStart.Shear( ptOn, vtNorm, vtDir, dCoeff) ; m_PtEnd.Shear( ptOn, vtNorm, vtDir, dCoeff) ; + // eseguo scorrimento del vettore estrusione, lo normalizzo e aggiusto spessore + m_VtExtr.Shear( vtNorm, vtDir, dCoeff) ; + double dLen = m_VtExtr.Len() ; + if ( dLen > EPS_ZERO) { + m_VtExtr /= dLen ; + m_dThick *= dLen ; + } return true ; } @@ -1636,9 +1689,10 @@ CurveComposite::ToGlob( const Frame3d& frRef) for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) (*Iter)->ToGlob( frRef) ; - // trasformo i punti estremi + // trasformo i punti estremi e il vettore estrusione m_PtStart.ToGlob( frRef) ; m_PtEnd.ToGlob( frRef) ; + m_VtExtr.ToGlob( frRef) ; return true ; } @@ -1659,9 +1713,10 @@ CurveComposite::ToLoc( const Frame3d& frRef) for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) (*Iter)->ToLoc( frRef) ; - // trasformo i punti estremi + // trasformo i punti estremi e il vettore estrusione m_PtStart.ToLoc( frRef) ; m_PtEnd.ToLoc( frRef) ; + m_VtExtr.ToLoc( frRef) ; return true ; } @@ -1687,9 +1742,10 @@ CurveComposite::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) (*Iter)->LocToLoc( frOri, frDest) ; } - // trasformo i punti estremi + // trasformo i punti estremi e il vettore estrusione m_PtStart.LocToLoc( frOri, frDest) ; m_PtEnd.LocToLoc( frOri, frDest) ; + m_VtExtr.LocToLoc( frOri, frDest) ; return true ; } @@ -1803,6 +1859,9 @@ CurveComposite::RemoveFirstOrLastCurve( bool bLast) m_bClosed = ( AreSamePointApprox( m_PtStart, m_PtEnd)) ; else m_bClosed = false ; + // assegno estrusione e spessore della curva composita + pCrv->SetExtrusion( m_VtExtr) ; + pCrv->SetThickness( m_dThick) ; return pCrv ; } else diff --git a/CurveComposite.h b/CurveComposite.h index 494adaf..201243d 100644 --- a/CurveComposite.h +++ b/CurveComposite.h @@ -68,6 +68,10 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW { return ::GetTang( *this, m_nCounter, FROM_MINUS, vtDir) ; } virtual bool GetMidDir( Vector3d& vtDir) const { return ::GetTang( *this, 0.5 * m_nCounter, FROM_MINUS, vtDir) ; } + virtual bool GetExtrusion( Vector3d& vtExtr) const + { vtExtr = m_VtExtr ; return ( m_nStatus == OK) ; } + virtual bool GetThickness( double& dThick) const + { dThick = m_dThick ; return ( m_nStatus == OK) ; } virtual bool GetDomain( double& dStart, double& dEnd) const ; virtual bool IsValidParam( double dPar, Side nSide) const { return ::IsValidParam( *this, dPar, nSide) ; } @@ -94,6 +98,10 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW { return false ; } virtual bool ModifyStart( const Point3d& ptNewStart) ; virtual bool ModifyEnd( const Point3d& ptNewEnd) ; + virtual bool SetExtrusion( const Vector3d& vtExtr) + { m_VtExtr = vtExtr ; m_VtExtr.Normalize() ; m_OGrMgr.Reset() ; return true ; } + virtual bool SetThickness( double dThick) + { m_dThick = dThick ; m_OGrMgr.Reset() ; return true ; } virtual bool TrimStartAtParam( double dUTrim) ; virtual bool TrimEndAtParam( double dUTrim) ; virtual bool TrimStartEndAtParam( double dUStartTrim, double dUEndTrim) ; @@ -154,6 +162,8 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW Point3d m_PtStart ; // punto iniziale Point3d m_PtEnd ; // punto finale bool m_bClosed ; // flag per indicare che la curva è chiusa + Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN) + double m_dThick ; // spessore mutable PCRVSMPL_DEQUE::const_iterator m_Iter ; // iteratore } ; diff --git a/CurveLine.cpp b/CurveLine.cpp index 515164e..4e85af0 100644 --- a/CurveLine.cpp +++ b/CurveLine.cpp @@ -29,7 +29,7 @@ GEOOBJ_REGISTER( CRV_LINE, NGE_C_LIN, CurveLine) ; //---------------------------------------------------------------------------- CurveLine::CurveLine( void) - : m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd() + : m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd(), m_VtExtr(), m_dThick() { } @@ -121,6 +121,8 @@ CurveLine::CopyFrom( const CurveLine& clSrc) { if ( &clSrc == this) return true ; + m_VtExtr = clSrc.m_VtExtr ; + m_dThick = clSrc.m_dThick ; return Set( clSrc.m_PtStart, clSrc.m_PtEnd) ; } @@ -167,6 +169,11 @@ CurveLine::Save( NgeWriter& ngeOut) const return false ; if ( ! ngeOut.WritePoint( m_PtEnd, ";", true)) return false ; + // da versione 1008 : linea con VtEstrusione e Spessore + if ( ! ngeOut.WriteVector( m_VtExtr, ";")) + return false ; + if ( ! ngeOut.WriteDouble( m_dThick, ";", true)) + return false ; return true ; } @@ -182,6 +189,13 @@ CurveLine::Load( NgeReader& ngeIn) return false ; if ( ! ngeIn.ReadPoint( m_PtEnd, ";", true)) return false ; + // da versione 1008 : linea con VtEstrusione e Spessore + if ( ngeIn.GetFileVersion() >= NGE_VER_1008) { + if ( ! ngeIn.ReadVector( m_VtExtr, ";")) + return false ; + if ( ! ngeIn.ReadDouble( m_dThick, ";", true)) + return false ; + } // eseguo validazione return Validate() ; } @@ -238,10 +252,19 @@ CurveLine::IsFlat( Plane3d& plPlane, double dToler) const return false ; // assegno dati piano - plPlane.vtN = FromUprightOrtho( m_PtEnd - m_PtStart) ; ; - plPlane.dDist = ( m_PtStart - ORIG) * plPlane.vtN ; + bool bFlat ; + if ( m_VtExtr.IsSmall()) { + plPlane.vtN = FromUprightOrtho( m_PtEnd - m_PtStart) ; + bFlat = true ; + } + else { + plPlane.vtN = m_VtExtr ; + bFlat = ( AreOrthoApprox( m_VtExtr, ( m_PtEnd - m_PtStart))) ; + } + plPlane.dDist = ( 0.5 * ( m_PtStart + m_PtEnd) - ORIG) * plPlane.vtN ; + // ritorno conferma - return true ; + return bFlat ; } //---------------------------------------------------------------------------- @@ -662,6 +685,9 @@ CurveLine::TrimEndAtLen( double dLenTrim) bool CurveLine::Translate( const Vector3d& vtMove) { + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; // imposto ricalcolo della grafica m_OGrMgr.Reset() ; @@ -676,6 +702,9 @@ CurveLine::Translate( const Vector3d& vtMove) bool CurveLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) { + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; // verifico validità dell'asse di rotazione if ( vtAx.IsSmall()) return false ; @@ -686,6 +715,8 @@ CurveLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, do // ruoto i punti estremi m_PtStart.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; m_PtEnd.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; + // ruoto il vettore estrusione + m_VtExtr.Rotate( vtAx, dCosAng, dSinAng) ; return true ; } @@ -694,6 +725,9 @@ CurveLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, do bool CurveLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) { + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; // verifico non sia nulla if ( fabs( dCoeffX) < EPS_ZERO && fabs( dCoeffY) < EPS_ZERO && fabs( dCoeffZ) < EPS_ZERO) return false ; @@ -704,6 +738,13 @@ CurveLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double d // scalo i punti estremi m_PtStart.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; m_PtEnd.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; + // scalo vettore estrusione, lo normalizzo e aggiusto spessore + m_VtExtr.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; + double dLen = m_VtExtr.Len() ; + if ( dLen > EPS_ZERO) { + m_VtExtr /= dLen ; + m_dThick *= dLen ; + } m_nStatus = TO_VERIFY ; return Validate() ; @@ -713,6 +754,9 @@ CurveLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double d bool CurveLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) { + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; // verifico validità del piano di specchiatura if ( vtNorm.IsSmall()) return false ; @@ -723,6 +767,8 @@ CurveLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) // specchio i punti estremi m_PtStart.Mirror( ptOn, vtNorm) ; m_PtEnd.Mirror( ptOn, vtNorm) ; + // specchio il vettore estrusione + m_VtExtr.Mirror( vtNorm) ; return true ; } @@ -731,6 +777,9 @@ CurveLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) bool CurveLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) { + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; // verifico validità dei parametri if ( vtNorm.IsSmall() || vtDir.IsSmall()) return false ; @@ -741,6 +790,13 @@ CurveLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& v // eseguo scorrimento dei punti estremi m_PtStart.Shear( ptOn, vtNorm, vtDir, dCoeff) ; m_PtEnd.Shear( ptOn, vtNorm, vtDir, dCoeff) ; + // eseguo scorrimento del vettore estrusione, lo normalizzo e aggiusto spessore + m_VtExtr.Shear( vtNorm, vtDir, dCoeff) ; + double dLen = m_VtExtr.Len() ; + if ( dLen > EPS_ZERO) { + m_VtExtr /= dLen ; + m_dThick *= dLen ; + } return true ; } @@ -749,6 +805,9 @@ CurveLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& v bool CurveLine::ToGlob( const Frame3d& frRef) { + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; // verifico validità del frame if ( frRef.GetType() == Frame3d::ERR) return false ; @@ -756,14 +815,17 @@ CurveLine::ToGlob( const Frame3d& frRef) // imposto ricalcolo della grafica m_OGrMgr.Reset() ; - // trasformo i punti estremi - return ( m_PtStart.ToGlob( frRef) && m_PtEnd.ToGlob( frRef)) ; + // trasformo i punti estremi e il vettore estrusione + return ( m_PtStart.ToGlob( frRef) && m_PtEnd.ToGlob( frRef) && m_VtExtr.ToGlob( frRef)) ; } //---------------------------------------------------------------------------- bool CurveLine::ToLoc( const Frame3d& frRef) { + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; // verifico validità del frame if ( frRef.GetType() == Frame3d::ERR) return false ; @@ -771,14 +833,17 @@ CurveLine::ToLoc( const Frame3d& frRef) // imposto ricalcolo della grafica m_OGrMgr.Reset() ; - // trasformo i punti estremi - return ( m_PtStart.ToLoc( frRef) && m_PtEnd.ToLoc( frRef)) ; + // trasformo i punti estremi e il vettore estrusione + return ( m_PtStart.ToLoc( frRef) && m_PtEnd.ToLoc( frRef) && m_VtExtr.ToLoc( frRef)) ; } //---------------------------------------------------------------------------- bool CurveLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) { + // la curva deve essere validata + if ( m_nStatus != OK) + return false ; // verifico validità dei frame if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR) return false ; @@ -789,9 +854,10 @@ CurveLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) // imposto ricalcolo della grafica m_OGrMgr.Reset() ; - // trasformo i punti estremi - return ( m_PtStart.ToGlob( frOri) && m_PtStart.ToLoc( frDest) && - m_PtEnd.ToGlob( frOri) && m_PtEnd.ToLoc( frDest)) ; + // trasformo i punti estremi e il vettore estrusione + return ( m_PtStart.LocToLoc( frOri, frDest) && + m_PtEnd.LocToLoc( frOri, frDest) && + m_VtExtr.LocToLoc( frOri, frDest)) ; } //---------------------------------------------------------------------------- diff --git a/CurveLine.h b/CurveLine.h index b3f617a..a097d2b 100644 --- a/CurveLine.h +++ b/CurveLine.h @@ -66,6 +66,10 @@ class CurveLine : public ICurveLine, public IGeoObjRW { return GetStartDir( vtDir) ; } virtual bool GetMidDir( Vector3d& vtDir) const { return GetStartDir( vtDir) ; } + virtual bool GetExtrusion( Vector3d& vtExtr) const + { vtExtr = m_VtExtr ; return ( m_nStatus == OK) ; } + virtual bool GetThickness( double& dThick) const + { dThick = m_dThick ; return ( m_nStatus == OK) ; } virtual bool GetDomain( double& dStart, double& dEnd) const { dStart = 0 ; dEnd = 1 ; return ( m_nStatus == OK) ; } virtual bool IsValidParam( double dPar, Side nSide) const @@ -92,6 +96,10 @@ class CurveLine : public ICurveLine, public IGeoObjRW virtual bool Offset( double dDist, int nSide, int nType = OFF_FILLET) ; virtual bool ModifyStart( const Point3d& ptNewStart) ; virtual bool ModifyEnd( const Point3d& ptNewEnd) ; + virtual bool SetExtrusion( const Vector3d& vtExtr) + { m_VtExtr = vtExtr ; m_VtExtr.Normalize() ; m_OGrMgr.Reset() ; return true ; } + virtual bool SetThickness( double dThick) + { m_dThick = dThick ; m_OGrMgr.Reset() ; return true ; } virtual bool TrimStartAtParam( double dUTrim) ; virtual bool TrimEndAtParam( double dUTrim) ; virtual bool TrimStartEndAtParam( double dUStartTrim, double dUEndTrim) ; @@ -129,10 +137,12 @@ class CurveLine : public ICurveLine, public IGeoObjRW enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; private : - ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto - Status m_nStatus ; // stato - Point3d m_PtStart ; // punto iniziale - Point3d m_PtEnd ; // punto finale + ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto + Status m_nStatus ; // stato + Point3d m_PtStart ; // punto iniziale + Point3d m_PtEnd ; // punto finale + Vector3d m_VtExtr ; // vettore estrusione + double m_dThick ; // spessore } ; //----------------------------------------------------------------------------- diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index e125bdc..a7b02c2 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index e713a59..223e1f5 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -24,6 +24,7 @@ #include "/EgtDev/Include/EgkGeoVector3d.h" #include "/EgtDev/Include/EgkGeoFrame3d.h" #include "/EgtDev/Include/EgkCurveLine.h" +#include "/EgtDev/Include/EgkCurveAux.h" #include "/EgtDev/Include/EgkLinePntTgCurve.h" #include "/EgtDev/Include/EgkLineTgTwoArcs.h" #include "/EgtDev/Include/EgkCurveArc.h" @@ -4830,6 +4831,10 @@ GdbExecutor::ExecuteCurveModify( const string& sCmd2, const STRVECTOR& vsParams) return CurveModifyStartPoint( vsParams) ; else if ( sCmd2 == "EP" || sCmd2 == "ENDPOINT") return CurveModifyEndPoint( vsParams) ; + else if ( sCmd2 == "EXTR" || sCmd2 == "EXTRUSION") + return CurveModifyExtrusion( vsParams) ; + else if ( sCmd2 == "TH" || sCmd2 == "THICKNESS") + return CurveModifyThickness( vsParams) ; if ( sCmd2 == "TRSL" || sCmd2 == "TRIMSTARTLEN") return CurveModifyTrim( vsParams, SL) ; else if ( sCmd2 == "TREL" || sCmd2 == "TRIMENDLEN") @@ -4913,6 +4918,50 @@ GdbExecutor::CurveModifyEndPoint( const STRVECTOR& vsParams) return pCrv->ModifyEnd( ptNewEnd) ; } +//---------------------------------------------------------------------------- +bool +GdbExecutor::CurveModifyExtrusion( const STRVECTOR& vsParams) +{ + // 2 parametri : Id, vtExtrusion + if ( vsParams.size() != 2) + return false ; + // recupero la curva sorgente + int nIdCrv = GetIdParam( vsParams[0]) ; + ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ; + if ( pCrv == nullptr) + return false ; + // recupero il suo riferimento + Frame3d frCrv ; + if ( ! m_pGDB->GetGlobFrame( nIdCrv, frCrv)) + return false ; + // recupero il vettore di estrusione + Vector3d vtExtr ; + if ( ! GetVectorParam( vsParams[1], frCrv, vtExtr)) + return false ; + // eseguo la modifica + return pCrv->SetExtrusion( vtExtr) ; +} + +//---------------------------------------------------------------------------- +bool +GdbExecutor::CurveModifyThickness( const STRVECTOR& vsParams) +{ + // 2 parametri : Id, dThick + if ( vsParams.size() != 2) + return false ; + // recupero la curva sorgente + int nIdCrv = GetIdParam( vsParams[0]) ; + ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ; + if ( pCrv == nullptr) + return false ; + // recupero lo spessore + double dThick ; + if ( ! GetLengthParam( vsParams[1], dThick)) + return false ; + // eseguo la modifica + return pCrv->SetThickness( dThick) ; +} + //---------------------------------------------------------------------------- bool GdbExecutor::CurveModifyTrim( const STRVECTOR& vsParams, int nTrimType) diff --git a/GdbExecutor.h b/GdbExecutor.h index d59b04e..eecec23 100644 --- a/GdbExecutor.h +++ b/GdbExecutor.h @@ -148,6 +148,8 @@ class GdbExecutor : public IGdbExecutor bool CurveModifyInvert( const STRVECTOR& vsParams) ; bool CurveModifyStartPoint( const STRVECTOR& vsParams) ; bool CurveModifyEndPoint( const STRVECTOR& vsParams) ; + bool CurveModifyExtrusion( const STRVECTOR& vsParams) ; + bool CurveModifyThickness( const STRVECTOR& vsParams) ; bool CurveModifyTrim( const STRVECTOR& vsParams, int nTrimType) ; bool ExecuteCurveCopy( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool CurveCopyByParamRange( const STRVECTOR& vsParams) ; diff --git a/GdbGeo.cpp b/GdbGeo.cpp index 6835494..a5f6514 100644 --- a/GdbGeo.cpp +++ b/GdbGeo.cpp @@ -278,8 +278,7 @@ GdbGeo::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDi ICurveArc* pArc = GetCurveArc( m_pGeoObj) ; // se l'arco non è piatto o il piano di scorrimento non coincide con quello dell'arco if ( ! pArc->IsFlat() || - ! ( AreSameVectorExact( pArc->GetNormVersor(), vtNorm) || - AreOppositeVectorExact( pArc->GetNormVersor(), vtNorm))) { + ! AreSameOrOppositeVectorExact( pArc->GetNormVersor(), vtNorm)) { // trasformo in curva di Bezier (semplice o composta) ICurve* pCrvNew = ArcToBezierCurve( GetCurve( m_pGeoObj)) ; if ( pCrvNew == nullptr) diff --git a/GeomDB.cpp b/GeomDB.cpp index 1657bcb..a449c75 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -127,15 +127,14 @@ GeomDB::LoadHeader( NgeReader& ngeIn) if ( ! ngeIn.ReadKey( nKey) || nKey != NGE_START) return false ; string sVal ; + + // tipo file e versione if ( ! ngeIn.ReadString( sVal, ",") || sVal != NGE_GEOMDB) return false ; - int nVal ; - if ( ! ngeIn.ReadInt( nVal, ".")) - return false ; - if ( ! ngeIn.ReadInt( nVal, ".")) - return false ; - if ( ! ngeIn.ReadInt( nVal, ";", true)) + int nFileVer ; + if ( ! ngeIn.ReadInt( nFileVer, ";", true)) return false ; + ngeIn.SetFileVersion( nFileVer) ; // materiale di default come colore if ( ! ngeIn.ReadKey( nKey) || nKey != NGE_MAT_DEF) @@ -246,11 +245,7 @@ GeomDB::SaveHeader( NgeWriter& ngeOut) const return false ; if ( ! ngeOut.WriteString( NGE_GEOMDB, ",")) return false ; - if ( ! ngeOut.WriteInt( NGE_MAJOR_VER, ".")) - return false ; - if ( ! ngeOut.WriteInt( NGE_MINOR_VER, ".")) - return false ; - if ( ! ngeOut.WriteInt( NGE_PATCH_VER, ";", true)) + if ( ! ngeOut.WriteInt( NGE_VER_LAST, ";", true)) return false ; // materiale di default come colore diff --git a/LineTgTwoArcs.cpp b/LineTgTwoArcs.cpp index 6ce8724..723c50c 100644 --- a/LineTgTwoArcs.cpp +++ b/LineTgTwoArcs.cpp @@ -32,8 +32,7 @@ GetLineTgTwoArcs( const ICurveArc& crvArc1, const Point3d& ptNear1, const ICurveArc& crvArc2, const Point3d& ptNear2) { // verifico che i due archi abbiano lo stesso piano intrinseco - if ( ! AreSameVectorApprox( crvArc1.GetNormVersor(), crvArc2.GetNormVersor()) && - ! AreOppositeVectorApprox( crvArc1.GetNormVersor(), crvArc2.GetNormVersor())) + if ( ! AreSameOrOppositeVectorApprox( crvArc1.GetNormVersor(), crvArc2.GetNormVersor())) return nullptr ; // calcolo il riferimento intrinseco del primo arco (Z->DirNorm e X->DirStart) diff --git a/NgeConst.h b/NgeConst.h index e65391a..08206b8 100644 --- a/NgeConst.h +++ b/NgeConst.h @@ -8,6 +8,7 @@ // // Modifiche : 12.04.14 DS Creazione modulo. // 28.05.14 DS 1.5.7 -> aggiunto aggetto Testo. +// 23.08.14 DS 1007 -> versione con 1 solo int e cambiato nome GDB in "EgtGeomDB". // //---------------------------------------------------------------------------- @@ -18,13 +19,15 @@ //---------------------------------------------------------------------------- // Costanti per file NGE //---------------------------------------------------------------------------- -// versione -const int NGE_MAJOR_VER = 1 ; -const int NGE_MINOR_VER = 5 ; -const int NGE_PATCH_VER = 7 ; -// nome GDB -const std::string NGE_GEOMDB = "GeomDB" ; -// indici KeyWord +// Nome GDB +const std::string NGE_GEOMDB = "EgtGeomDB" ; +// Versione +const int NGE_VER_1007 = 1007 ; +// 1007 : nuovo versioning con unico valore +const int NGE_VER_1008 = 1008 ; +// 1008 : aggiunge vtExtr e dThick a tutte le curve +const int NGE_VER_LAST = NGE_VER_1008 ; +// Indici KeyWord const int NGE_START = 0 ; const int NGE_END = 1 ; const int NGE_MAT_DEF = 2 ; diff --git a/NgeReader.h b/NgeReader.h index 6a90deb..97a3c63 100644 --- a/NgeReader.h +++ b/NgeReader.h @@ -24,12 +24,13 @@ class NgeReader { public : - NgeReader( void) : m_iPosStart( std::string::npos), m_bUngetKey( false) {} + NgeReader( void) + : m_iPosStart( std::string::npos), m_bUngetKey( false), m_nFileVer() {} ~NgeReader( void) { Close() ; } bool Init( const std::string& sFileIn) ; bool Close( void) ; - int GetCurrPos( void) ; + int GetCurrPos( void) ; bool ReadUchar( unsigned char& ucVal, const char* szSep, bool bEndL = false) ; bool ReadBool( bool& bVal, const char* szSep, bool bEndL = false) ; bool ReadInt( int& nVal, const char* szSep, bool bEndL = false) ; @@ -38,11 +39,15 @@ class NgeReader bool ReadPoint( Point3d& ptP, const char* szSep, bool bEndL = false) ; bool ReadPointW( Point3d& ptP, double& dW, const char* szSep, bool bEndL = false) ; bool ReadFrame( Frame3d& frF, const char* szSep, bool bEndL) ; + bool ReadCol( Color& cCol, const char* szSep, bool bEndL = false) ; bool ReadString( std::string& sVal, const char* szSep, bool bEndL = false) ; bool ReadKey( int& nKey /* bEndL = true*/) ; void UngetKey( void) { m_bUngetKey = true ; } - bool ReadCol( Color& cCol, const char* szSep, bool bEndL = false) ; + bool SetFileVersion( int nFileVer) + { m_nFileVer = nFileVer ; return true ; } + int GetFileVersion( void) + { return m_nFileVer ; } private : enum { NGE_ERROR = 0, NGE_ASCII = 1, NGE_BINARY = 2 } ; @@ -63,4 +68,6 @@ class NgeReader // unget Key bool m_bUngetKey ; int m_nLastKey ; + // file version + int m_nFileVer ; } ; diff --git a/PolyLine.cpp b/PolyLine.cpp index c77b0e2..14af17f 100644 --- a/PolyLine.cpp +++ b/PolyLine.cpp @@ -266,11 +266,15 @@ PolyLine::IsClosed( void) const //---------------------------------------------------------------------------- bool -PolyLine::GetFirstUPoint( double* pdPar, Point3d* pptP) const +PolyLine::GetFirstUPoint( double* pdPar, Point3d* pptP, bool bNotLast) const { m_iter = m_lUPoints.begin() ; if ( m_iter == m_lUPoints.end()) return false ; + if ( bNotLast && m_iter == -- ( m_lUPoints.end())) { + m_iter = m_lUPoints.end() ; + return false ; + } if ( pdPar != nullptr) *pdPar = m_iter->first ; @@ -289,8 +293,10 @@ PolyLine::GetNextUPoint( double* pdPar, Point3d* pptP, bool bNotLast) const ++ m_iter ; if ( m_iter == m_lUPoints.end()) return false ; - if ( bNotLast && m_iter == -- ( m_lUPoints.end())) + if ( bNotLast && m_iter == -- ( m_lUPoints.end())) { + m_iter = m_lUPoints.end() ; return false ; + } if ( pdPar != nullptr) *pdPar = m_iter->first ; @@ -302,15 +308,18 @@ PolyLine::GetNextUPoint( double* pdPar, Point3d* pptP, bool bNotLast) const //---------------------------------------------------------------------------- bool -PolyLine::GetLastUPoint( double* pdPar, Point3d* pptP) const +PolyLine::GetLastUPoint( double* pdPar, Point3d* pptP, bool bNotFirst) const { m_iter = m_lUPoints.end() ; if ( m_iter == m_lUPoints.begin()) return false ; -- m_iter ; - if ( m_iter == m_lUPoints.end()) return false ; + if ( bNotFirst && m_iter == m_lUPoints.begin()) { + m_iter = m_lUPoints.end() ; + return false ; + } if ( pdPar != nullptr) *pdPar = m_iter->first ; @@ -327,7 +336,27 @@ PolyLine::GetPrevUPoint( double* pdPar, Point3d* pptP, bool bNotFirst) const if ( m_iter == m_lUPoints.begin()) return false ; -- m_iter ; - if ( bNotFirst && m_iter == m_lUPoints.begin()) + if ( m_iter == m_lUPoints.end()) + return false ; + if ( bNotFirst && m_iter == m_lUPoints.begin()) { + m_iter = m_lUPoints.end() ; + return false ; + } + + if ( pdPar != nullptr) + *pdPar = m_iter->first ; + if ( pptP != nullptr) + *pptP = m_iter->second ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +PolyLine::GetCurrUPoint( double* pdPar, Point3d* pptP) const +{ + // verifico validità punto corrente + if ( m_iter == m_lUPoints.end()) return false ; if ( pdPar != nullptr) diff --git a/Vector3d.cpp b/Vector3d.cpp index ac43e9a..fae8910 100644 --- a/Vector3d.cpp +++ b/Vector3d.cpp @@ -171,6 +171,10 @@ Vector3d::Normalize( double dEps) bool Vector3d::Rotate( const Vector3d& vtAx, double dAngDeg) { + // se vettore nullo + if ( IsZero()) + return true ; + // calcolo ed eseguo rotazione double dAngRad = dAngDeg * DEGTORAD ; return Rotate( vtAx, cos( dAngRad), sin( dAngRad)) ; } @@ -181,6 +185,10 @@ Vector3d::Rotate( const Vector3d& vtAx, double dAngDeg) bool Vector3d::Rotate( const Vector3d& vtAx, double dCosAng, double dSinAng) { + // se vettore nullo + if ( IsZero()) + return true ; + // ricavo versore asse di rotazione Vector3d vtDirAx = vtAx ; if ( ! vtDirAx.Normalize()) @@ -274,6 +282,10 @@ Vector3d::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC if ( frRef.GetType() == Frame3d::ERR) return false ; + // se vettore nullo + if ( IsZero()) + return true ; + // ricavo le componenti sugli assi di scalatura, le scalo e riassemblo il vettore completo *this = ( (*this) * frRef.VersX() * dCoeffX) * frRef.VersX() + ( (*this) * frRef.VersY() * dCoeffY) * frRef.VersY() + @@ -288,6 +300,10 @@ Vector3d::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC bool Vector3d::Mirror( const Vector3d& vtNorm) { + // se vettore nullo + if ( IsZero()) + return true ; + // ricavo versore normale al piano di simmetria Vector3d vtDirNorm = vtNorm ; if ( ! vtDirNorm.Normalize()) @@ -308,9 +324,11 @@ Vector3d::Mirror( const Vector3d& vtNorm) bool Vector3d::Shear( const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) { + // se vettore nullo + if ( IsZero()) + return true ; // costruisco il vettore *this += dCoeff * ( *this * vtNorm) * vtDir ; - return true ; } @@ -324,6 +342,10 @@ Vector3d::ToGlob( const Frame3d& frRef) if ( frRef.GetType() == Frame3d::ERR) return false ; + // se vettore nullo o riferimento identità per le rotazioni + if ( IsZero() || frRef.GetType() == Frame3d::TOP) + return true ; + // eseguo trasformazione if ( frRef.GetType() != Frame3d::TOP) { Vector3d vtT( x, y, z) ; @@ -345,6 +367,10 @@ Vector3d::ToLoc( const Frame3d& frRef) if ( frRef.GetType() == Frame3d::ERR) return false ; + // se vettore nullo o riferimento identità per le rotazioni + if ( IsZero() || frRef.GetType() == Frame3d::TOP) + return true ; + // eseguo trasformazione if ( frRef.GetType() != Frame3d::TOP) { Vector3d vtT( x, y, z) ; @@ -362,8 +388,8 @@ Vector3d::ToLoc( const Frame3d& frRef) bool Vector3d::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) { - // se i due riferimenti coincidono, non devo fare alcunché - if ( AreSameFrame( frOri, frDest)) + // se vettore nullo o i due riferimenti coincidono, non devo fare alcunché + if ( IsZero() || AreSameFrame( frOri, frDest)) return true ; return ( ToGlob( frOri) && ToLoc( frDest)) ;