diff --git a/EGkDistPointArc.h b/EGkDistPointArc.h new file mode 100644 index 0000000..88a52bb --- /dev/null +++ b/EGkDistPointArc.h @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------------- +// EgalTech 2013-2013 +//---------------------------------------------------------------------------- +// File : EGkDistPointArc.h Data : 28.12.13 Versione : 1.4l5 +// Contenuto : Dichiarazione della classe distanza punto da circonferenza/arco. +// +// +// +// Modifiche : 28.12.13 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkPoint3d.h" +#include "/EgtDev/Include/EGkCurveArc.h" + +//----------------------- Macro per import/export ---------------------------- +#undef EGK_EXPORT +#if defined( I_AM_EGK) // da definirsi solo nella DLL + #define EGK_EXPORT __declspec( dllexport) +#else + #define EGK_EXPORT __declspec( dllimport) +#endif + + +//----------------------------------------------------------------------------- +class DistPointArc +{ + public : + EGK_EXPORT DistPointArc( const Point3d& ptP, const ICurveArc& arArc) ; + + public : + EGK_EXPORT bool GetSqDist( double& dSqDist) ; + EGK_EXPORT bool GetDist( double& dDist) ; + EGK_EXPORT bool GetPointMinDist( Point3d& ptMinDist, bool* pbDet = nullptr) ; + EGK_EXPORT bool GetParamAtPointMinDist( double& dParam, bool* pbDet = nullptr) ; + + private : + DistPointArc( void) ; + void DistPointCircle( const Point3d& ptP, const ICurveArc& arArc) ; + void DistPointFlatArc( const Point3d& ptP, const ICurveArc& arArc) ; + + private : + bool m_bDet ; + double m_dDist ; + double m_dParam ; + Point3d m_ptMinDist ; +} ; + diff --git a/EGkDistPointLine.h b/EGkDistPointLine.h index 9ac84e6..c9ca5c7 100644 --- a/EGkDistPointLine.h +++ b/EGkDistPointLine.h @@ -14,6 +14,7 @@ #pragma once #include "/EgtDev/Include/EGkPoint3d.h" +#include "/EgtDev/Include/EGkCurveLine.h" //----------------------- Macro per import/export ---------------------------- #undef EGK_EXPORT @@ -28,27 +29,29 @@ class DistPointLine { public : - EGK_EXPORT DistPointLine( void) ; + EGK_EXPORT DistPointLine( const Point3d& ptP, + const ICurveLine& crvLine, bool bIsSegment = true) ; + EGK_EXPORT DistPointLine( const Point3d& ptP, + const Point3d& ptIni, const Point3d& ptFin, bool bIsSegment = true) ; + EGK_EXPORT DistPointLine( const Point3d& ptP, + const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) + { Calculate( ptP, ptIni, vtDir, dLen, bIsSegment) ; } public : - EGK_EXPORT bool Set( const Point3d& ptP, const Point3d& ptIni, const Point3d& ptFin, bool bIsSegment) ; - EGK_EXPORT bool SetPoint( const Point3d& ptP) ; - EGK_EXPORT bool SetLine( const Point3d& ptIni, const Point3d& ptFin, bool bIsSegment) ; - EGK_EXPORT double GetSqDist( void) ; - EGK_EXPORT double GetDist( void) ; - EGK_EXPORT const Point3d& GetPointMinDist( void) ; + EGK_EXPORT bool GetSqDist( double& dSqDist) ; + EGK_EXPORT bool GetDist( double& dDist) ; + EGK_EXPORT bool GetPointMinDist( Point3d& ptMinDist) ; + EGK_EXPORT bool GetParamAtPointMinDist( double& dParam) ; private : - bool Calculate( void) ; + DistPointLine( void) ; + void Calculate( const Point3d& ptP, + const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment) ; private : - Point3d m_ptP ; - Point3d m_ptIni ; - Vector3d m_vtDir ; - double m_dLen ; - bool m_bIsSegment ; - double m_dSqDist ; - double m_dDist ; - Point3d m_ptMinDist ; + double m_dSqDist ; + double m_dDist ; + double m_dParam ; + Point3d m_ptMinDist ; } ; diff --git a/EGkFrame3d.h b/EGkFrame3d.h index bf6fdcb..1490658 100644 --- a/EGkFrame3d.h +++ b/EGkFrame3d.h @@ -43,8 +43,8 @@ class EGK_EXPORT Frame3d // Mirror non possibile (cambia il senso destrorso in sinistrorso) bool ToGlob( const Frame3d& frRef) ; bool ToLoc( const Frame3d& frRef) ; - const Frame3d operator*=( const Frame3d& frRef) { this->ToGlob( frRef) ; return *this ;} - const Frame3d operator/=( const Frame3d& frRef) { this->ToLoc( frRef) ; return *this ;} + const Frame3d& operator*=( const Frame3d& frRef) { this->ToGlob( frRef) ; return *this ;} + const Frame3d& operator/=( const Frame3d& frRef) { this->ToLoc( frRef) ; return *this ;} int GetType( void) const { return m_nType ;} int GetZType( void) const { return m_nZType ;} const Point3d& Orig( void) const { return m_ptOrig ;} diff --git a/EGkGdbIterator.h b/EGkGdbIterator.h index 03db02a..37d5749 100644 --- a/EGkGdbIterator.h +++ b/EGkGdbIterator.h @@ -41,6 +41,7 @@ class __declspec( novtable) IGdbIterator virtual bool GetGroupGlobFrame( Frame3d& frGlob) = 0 ; virtual int GetId( void) = 0 ; virtual int GetParentId( void) = 0 ; + virtual bool GetGlobFrame( Frame3d& frGlob) = 0 ; } ; //----------------------------------------------------------------------------- diff --git a/EGkGeomDB.h b/EGkGeomDB.h index 4db9ff1..f1fc9cf 100644 --- a/EGkGeomDB.h +++ b/EGkGeomDB.h @@ -43,6 +43,7 @@ class __declspec( novtable) IGeomDB virtual Frame3d* GetGroupFrame( int nId) = 0 ; virtual bool GetGroupGlobFrame( int nId, Frame3d& frGlob) = 0 ; virtual int GetParentId( int nId) = 0 ; + virtual bool GetGlobFrame( int nId, Frame3d& frGlob) = 0 ; virtual int Copy( int nIdSou, int nIdDest, int nParentIdDest) = 0 ; virtual bool Erase( int nId) = 0 ; virtual bool Translate( int nId, const Vector3d& vtMove) = 0 ; diff --git a/EGkPoint3d.h b/EGkPoint3d.h index 3650743..2696d90 100644 --- a/EGkPoint3d.h +++ b/EGkPoint3d.h @@ -30,9 +30,9 @@ class Frame3d ; class EGK_EXPORT Point3d { public : - Point3d( double dX, double dY, double dZ) { x = dX ; y = dY ; z = dZ ;} - Point3d( double dX, double dY) { x = dX ; y = dY ; z = 0 ;} - Point3d( void) { x = 0 ; y = 0 ; z = 0 ;} + Point3d( double dX, double dY, double dZ) : x( dX), y( dY), z( dZ) {} + Point3d( double dX, double dY) : x( dX), y( dY), z( 0) {} + Point3d( void) : x( 0), y( 0), z( 0) {} void Set( double dX, double dY, double dZ) { x = dX ; y = dY ; z = dZ ;} const Point3d& operator =( const Point3d& ptSrc) { if ( &ptSrc != this) { @@ -40,6 +40,15 @@ class EGK_EXPORT Point3d return *this ; } public : + const Point3d& operator +=( const Vector3d& vtV) + { this->x += vtV.x ; this->y += vtV.y ; this->z += vtV.z ; return *this ; } + // questa somma è valida solo se equivalente ad una combinazione baricentrica + const Point3d& operator +=( const Point3d& ptP) + { this->x += ptP.x ; this->y += ptP.y ; this->z += ptP.z ; return *this ; } + const Point3d& operator *=( double dMul) + { this->x *= dMul ; this->y *= dMul ; this->z *= dMul ; return *this ; } + const Point3d& operator /=( double dDiv) + { double dMul = 1 / dDiv ; this->x *= dMul ; this->y *= dMul ; this->z *= dMul ; return *this ; } void Translate( const Vector3d& vtMove) ; bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad) ; bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ; @@ -47,6 +56,8 @@ class EGK_EXPORT Point3d bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ; bool ToGlob( const Frame3d& frRef) ; bool ToLoc( const Frame3d& frRef) ; + bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) + { return ( ToGlob( frOri) && ToLoc( frDest)) ; } public : double x ; @@ -165,6 +176,25 @@ Dist( const Point3d& ptP1, const Point3d& ptP2) return sqrt( dX * dX + dY * dY + dZ * dZ) ; } +//---------------------------------------------------------------------------- +// Direzione e distanza tra due punti +//---------------------------------------------------------------------------- +inline bool +DirDist( const Point3d& ptP1, const Point3d& ptP2, Vector3d& vtDir, double& dDist) +{ + dDist = Dist( ptP1, ptP2) ; + + // se distanza significativa + if ( dDist > EPS_SMALL) { + vtDir = ( ptP2 - ptP1) / dDist ; + return true ; + } + + // punti praticamente coincidenti + vtDir.Set( 0, 0, 0) ; + return false ; +} + //---------------------------------------------------------------------------- // Verifica che due punti sono quasi coincidenti (Small error -> Near) //---------------------------------------------------------------------------- diff --git a/EGkPolyLine.h b/EGkPolyLine.h index 1978ac9..74b601e 100644 --- a/EGkPolyLine.h +++ b/EGkPolyLine.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2013-2013 //---------------------------------------------------------------------------- -// File : DistPointLine.cpp Data : 22.12.13 Versione : 1.4l3 +// File : EGkPolyLine.cpp Data : 22.12.13 Versione : 1.4l3 // Contenuto : Dichiarazione della classe PolyLine. // // diff --git a/EGkVector3d.h b/EGkVector3d.h index b226150..1bafa2f 100644 --- a/EGkVector3d.h +++ b/EGkVector3d.h @@ -30,9 +30,9 @@ class Frame3d ; class EGK_EXPORT Vector3d { public : - Vector3d( double dX, double dY, double dZ) { x = dX ; y = dY ; z = dZ ;} - Vector3d( double dX, double dY) { x = dX ; y = dY ; z = 0 ;} - Vector3d( void) { x = 0 ; y = 0 ; z = 0 ;} + Vector3d( double dX, double dY, double dZ) : x( dX), y( dY), z( dZ) {} + Vector3d( double dX, double dY) : x( dX), y( dY), z( 0) {} + Vector3d( void) : x( 0), y( 0), z( 0) {} void Set( double dX, double dY, double dZ) { x = dX ; y = dY ; z = dZ ;} const Vector3d& operator =( const Vector3d& vtSrc) { if ( &vtSrc != this) { @@ -54,16 +54,26 @@ class EGK_EXPORT Vector3d { return ( fabs( x) < EPS_ZERO && fabs( y) < EPS_ZERO && z > EPS_ZERO) ; } bool IsZminus( void) const { return ( fabs( x) < EPS_ZERO && fabs( y) < EPS_ZERO && z < - EPS_ZERO) ; } + const Vector3d& operator +=( const Vector3d& vtV) + { this->x += vtV.x ; this->y += vtV.y ; this->z += vtV.z ; return *this ; } + const Vector3d& operator -=( const Vector3d& vtV) + { this->x -= vtV.x ; this->y -= vtV.y ; this->z -= vtV.z ; return *this ; } + const Vector3d& operator *=( double dMul) + { this->x *= dMul ; this->y *= dMul ; this->z *= dMul ; return *this ; } + const Vector3d& operator /=( double dDiv) + { double dMul = 1 / dDiv ; this->x *= dMul ; this->y *= dMul ; this->z *= dMul ; return *this ; } void ToSpherical( double* pdLen, double* pdAngVertDeg, double* pdAngOrizzDeg) const ; - bool Normalize( void) ; - bool Rotate( const Vector3d& vtAx, double dAngRad) ; - bool Rotate( const Vector3d& vtAx, double dCosAng, double dSinAng) ; - bool Scale( double dCoeffX, double dCoeffY, double dCoeffZ) ; - bool Mirror( const Vector3d& vtNorm) ; - bool ToGlob( const Frame3d& frRef) ; - bool ToLoc( const Frame3d& frRef) ; - bool GetAngle( const Vector3d& vtEnd, double& dAngDeg) ; - bool GetRotation( const Vector3d& vtEnd, const Vector3d& vtAx, double& dAngDeg, bool& bDet) ; + bool Normalize( void) ; + bool Rotate( const Vector3d& vtAx, double dAngRad) ; + bool Rotate( const Vector3d& vtAx, double dCosAng, double dSinAng) ; + bool Scale( double dCoeffX, double dCoeffY, double dCoeffZ) ; + bool Mirror( const Vector3d& vtNorm) ; + bool ToGlob( const Frame3d& frRef) ; + bool ToLoc( const Frame3d& frRef) ; + bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) + { return ( ToGlob( frOri) && ToLoc( frDest)) ; } + bool GetAngle( const Vector3d& vtEnd, double& dAngDeg) const ; + bool GetRotation( const Vector3d& vtEnd, const Vector3d& vtAx, double& dAngDeg, bool& bDet) const ; public : double x ; @@ -170,9 +180,7 @@ Media( const Vector3d& vtV1, const Vector3d& vtV2, double dCoeff) inline bool AreSameVectorNear( const Vector3d& vtV1, const Vector3d& vtV2) { - return ( fabs( vtV1.x - vtV2.x) < EPS_SMALL && - fabs( vtV1.y - vtV2.y) < EPS_SMALL && - fabs( vtV1.z - vtV2.z) < EPS_SMALL) ; + return ( ( vtV1 - vtV2).IsSmall()) ; } //---------------------------------------------------------------------------- @@ -181,9 +189,7 @@ AreSameVectorNear( const Vector3d& vtV1, const Vector3d& vtV2) inline bool AreSameVectorExact( const Vector3d& vtV1, const Vector3d& vtV2) { - return ( fabs( vtV1.x - vtV2.x) < EPS_ZERO && - fabs( vtV1.y - vtV2.y) < EPS_ZERO && - fabs( vtV1.z - vtV2.z) < EPS_ZERO) ; + return ( ( vtV1 - vtV2).IsZero()) ; } //---------------------------------------------------------------------------- diff --git a/EgkCurve.h b/EgkCurve.h index bc9d010..d481675 100644 --- a/EgkCurve.h +++ b/EgkCurve.h @@ -30,11 +30,11 @@ class __declspec( novtable) ICurve : public IGeoObj virtual bool GetEndPoint( Point3d& ptEnd) const = 0 ; virtual bool GetDomain( double& dStart, double& dEnd) const = 0 ; virtual bool GetLength( double& dLen) const = 0 ; - virtual bool GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const = 0 ; - virtual bool GetPoint( double dU, Side nS, Point3d& ptPos) const = 0 ; + virtual bool GetPointD1D2( double dU, Side nS, Point3d& ptPos, + Vector3d* pvtDer1 = nullptr, Vector3d* pvtDer2 = nullptr) const = 0 ; virtual bool GetPointTang( double dU, Side nS, Point3d& ptPos, Vector3d& vtTang) const = 0 ; virtual bool GetPointDiffGeom( double dU, Side nS, CrvPointDiffGeom& oDiffG) const = 0 ; - virtual bool Reverse( void) = 0 ; + virtual bool Invert( void) = 0 ; virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const = 0 ; virtual bool TrimStartAtParam( double dUTrim) = 0 ; virtual bool TrimEndAtParam( double dUTrim) = 0 ; diff --git a/EgkCurveArc.h b/EgkCurveArc.h index 2a39279..b4eac50 100644 --- a/EgkCurveArc.h +++ b/EgkCurveArc.h @@ -23,6 +23,8 @@ class __declspec( novtable) ICurveArc : public ICurve const Vector3d& vtS, double dAngCenDeg, double dDeltaN) = 0 ; virtual bool Set( const Point3d& ptCen, double dRad, double dAngIniDeg, double dAngCenDeg, double dDeltaZ) = 0 ; virtual bool Set( const Point3d& ptCen, double dRad) = 0 ; + virtual bool IsFlat( void) const = 0 ; + virtual bool IsACircle( void) const = 0 ; virtual bool IsInPlaneXY( void) const = 0 ; virtual const Point3d& GetCenter( void) const = 0 ; virtual const Vector3d& GetNormVersor( void) const = 0 ;