From 33e436946151a4a1f0a4688b7a08df18440119da Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 21 Dec 2013 16:19:58 +0000 Subject: [PATCH] Include : Prime modifiche per ApproxWithLines. --- EGkDistPointLine.h | 54 ++++++++++++++++++++++++++++++++++++ EGkVersion.h => EGkDllMain.h | 8 ++++-- EGkGdbIterator.h | 2 +- EGkGeoConst.h | 6 ++++ EGkGeoFrame3d.h | 2 +- EGkGeoObj.h | 2 +- EGkGeoPoint3d.h | 2 +- EGkGeoType.h | 23 +++++++++++++++ EGkGeoVector3d.h | 2 +- EGkGeomDB.h | 5 ++-- EGkPoint3d.h | 23 +++++++-------- EGkVector3d.h | 23 +++++++-------- EGnVersion.h => EGnDllMain.h | 4 +-- EgkCurve.h | 2 +- EgkCurveArc.h | 4 ++- EgkCurveBezier.h | 5 +++- EgkCurveComposite.h | 2 +- EgkCurveLine.h | 4 ++- EgkGdbExecutor.h | 4 +-- EgnCmdExecutor.h | 2 +- EgnCmdParser.h | 2 +- EgtILogger.h | 13 +++++---- 22 files changed, 146 insertions(+), 48 deletions(-) create mode 100644 EGkDistPointLine.h rename EGkVersion.h => EGkDllMain.h (68%) create mode 100644 EGkGeoType.h rename EGnVersion.h => EGnDllMain.h (81%) diff --git a/EGkDistPointLine.h b/EGkDistPointLine.h new file mode 100644 index 0000000..9ac84e6 --- /dev/null +++ b/EGkDistPointLine.h @@ -0,0 +1,54 @@ +//---------------------------------------------------------------------------- +// EgalTech 2013-2013 +//---------------------------------------------------------------------------- +// File : EGkDistPointLine.h Data : 17.12.13 Versione : 1.4l1 +// Contenuto : Dichiarazione dell'oggetto distanza punto da linea/segmento. +// +// +// +// Modifiche : 30.12.12 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkPoint3d.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 DistPointLine +{ + public : + EGK_EXPORT DistPointLine( void) ; + + 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) ; + + private : + bool Calculate( void) ; + + 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 ; +} ; + diff --git a/EGkVersion.h b/EGkDllMain.h similarity index 68% rename from EGkVersion.h rename to EGkDllMain.h index abed18b..b07d63f 100644 --- a/EGkVersion.h +++ b/EGkDllMain.h @@ -1,8 +1,8 @@ //---------------------------------------------------------------------------- // EgalTech 2013-2013 //---------------------------------------------------------------------------- -// File : EgkVersion.h Data : 21.11.13 Versione : 1.3a1 -// Contenuto : Prototipo funzione con info versione della DLL. +// File : EgkDllMain.h Data : 18.12.13 Versione : 1.4l2 +// Contenuto : Prototipi funzioni generali della DLL. // // // @@ -14,6 +14,7 @@ #pragma once +class ILogger ; //----------------------- Macro per import/export ---------------------------- #undef EGK_EXPORT @@ -24,4 +25,7 @@ #endif //----------------------------------------------------------------------------- +// restituisce la versione della Dll (stringa del tipo 1.4a5) EGK_EXPORT const char* GetEGkVersion( void) ; +// permette di impostare il logger per la Dll +EGK_EXPORT void SetEGkLogger( ILogger* pLogger) ; diff --git a/EGkGdbIterator.h b/EGkGdbIterator.h index 1b05303..03db02a 100644 --- a/EGkGdbIterator.h +++ b/EGkGdbIterator.h @@ -24,7 +24,7 @@ #endif //----------------------------------------------------------------------------- -class _declspec( novtable) IGdbIterator +class __declspec( novtable) IGdbIterator { public : virtual ~IGdbIterator( void) {} diff --git a/EGkGeoConst.h b/EGkGeoConst.h index d2e339f..a21567f 100644 --- a/EGkGeoConst.h +++ b/EGkGeoConst.h @@ -38,3 +38,9 @@ const double SIN_EPS_ANG_SMALL = EPS_ANG_SMALL * DEGTORAD ; const double SIN_EPS_ANG_ZERO = EPS_ANG_ZERO * DEGTORAD ; const double COS_ORTO_ANG_SMALL = SIN_EPS_ANG_SMALL ; const double COS_ORTO_ANG_ZERO = SIN_EPS_ANG_ZERO ; + +// tolleranza lineare minima in approssimazioni lineari +const double LIN_TOL_MIN = 0.01 ; + +// deviazione angolare minima (in gradi) in approssimazioni lineari +const double ANG_TOL_MIN_DEG = 0.1 ; diff --git a/EGkGeoFrame3d.h b/EGkGeoFrame3d.h index fe1e24e..08ee883 100644 --- a/EGkGeoFrame3d.h +++ b/EGkGeoFrame3d.h @@ -16,7 +16,7 @@ #include "/EgtDev/Include/EGkGeoObj.h" //----------------------------------------------------------------------------- -class _declspec( novtable) IGeoFrame3d : public IGeoObj +class __declspec( novtable) IGeoFrame3d : public IGeoObj { public : virtual bool Set( const Point3d& ptOrig, const Vector3d& vtDirX, diff --git a/EGkGeoObj.h b/EGkGeoObj.h index 14ad9a4..738994f 100644 --- a/EGkGeoObj.h +++ b/EGkGeoObj.h @@ -28,7 +28,7 @@ #endif //----------------------------------------------------------------------------- -class _declspec( novtable) IGeoObj +class __declspec( novtable) IGeoObj { public : virtual ~IGeoObj( void) {} diff --git a/EGkGeoPoint3d.h b/EGkGeoPoint3d.h index 137bbc3..e2dac81 100644 --- a/EGkGeoPoint3d.h +++ b/EGkGeoPoint3d.h @@ -16,7 +16,7 @@ #include "/EgtDev/Include/EGkGeoObj.h" //----------------------------------------------------------------------------- -class _declspec( novtable) IGeoPoint3d : public IGeoObj +class __declspec( novtable) IGeoPoint3d : public IGeoObj { public : virtual bool Set( const Point3d& ptP) = 0 ; diff --git a/EGkGeoType.h b/EGkGeoType.h new file mode 100644 index 0000000..23d59b5 --- /dev/null +++ b/EGkGeoType.h @@ -0,0 +1,23 @@ +//---------------------------------------------------------------------------- +// EgalTech 2013-2013 +//---------------------------------------------------------------------------- +// File : EgkGeoType.h Data : 17.12.13 Versione : 1.4l1 +// Contenuto : Tipi generali per calcoli geometrici. +// +// +// +// Modifiche : 17.12.13 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkPoint3d.h" +#include + +//---------------------------------------------------------------------------- +typedef std::vector PNTVECTOR ; // vettore di punti +typedef std::vector VECVECTOR ; // vettore di vettori geometrici +typedef std::pair UPOINT ; // coppia parametro, punto +typedef std::vector UPNTVECTOR ; // vettore di coppie parametro, punto diff --git a/EGkGeoVector3d.h b/EGkGeoVector3d.h index f5ad8fd..05f8232 100644 --- a/EGkGeoVector3d.h +++ b/EGkGeoVector3d.h @@ -16,7 +16,7 @@ #include "/EgtDev/Include/EGkGeoObj.h" //----------------------------------------------------------------------------- -class _declspec( novtable) IGeoVector3d : public IGeoObj +class __declspec( novtable) IGeoVector3d : public IGeoObj { public : virtual bool Set( const Vector3d& vtV) = 0 ; diff --git a/EGkGeomDB.h b/EGkGeomDB.h index 67a7f3a..4db9ff1 100644 --- a/EGkGeomDB.h +++ b/EGkGeomDB.h @@ -27,12 +27,11 @@ #endif //----------------------------------------------------------------------------- -class _declspec( novtable) IGeomDB +class __declspec( novtable) IGeomDB { public : virtual ~IGeomDB( void) {} - virtual bool Init( ILogger* pLogger) = 0 ; - virtual bool ReInit( void) = 0 ; + virtual bool Init( void) = 0 ; virtual bool Clear( void) = 0 ; virtual bool Load( const std::string& sFileIn) = 0 ; virtual bool Save( const std::string& sFileOut) const = 0 ; diff --git a/EGkPoint3d.h b/EGkPoint3d.h index 72677bf..3650743 100644 --- a/EGkPoint3d.h +++ b/EGkPoint3d.h @@ -30,14 +30,15 @@ class Frame3d ; class EGK_EXPORT Point3d { public : - inline Point3d( double dX, double dY, double dZ) { x = dX ; y = dY ; z = dZ ;} - inline Point3d( double dX, double dY) { x = dX ; y = dY ; z = 0 ;} - inline Point3d( void) { x = 0 ; y = 0 ; z = 0 ;} - inline void Set( double dX, double dY, double dZ) { x = dX ; y = dY ; z = dZ ;} - inline const Point3d& operator =( const Point3d& ptSrc) - { if ( &ptSrc != this) { - x = ptSrc.x , y = ptSrc.y , z = ptSrc.z ; } - return *this ; } + 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) { + x = ptSrc.x , y = ptSrc.y , z = ptSrc.z ; } + return *this ; } + public : void Translate( const Vector3d& vtMove) ; bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad) ; @@ -135,7 +136,7 @@ Media( const Point3d& ptP1, const Point3d& ptP2, double dCoeff) // Quadrato della distanza tra due punti //---------------------------------------------------------------------------- inline double -DistSq( const Point3d& ptP1, const Point3d& ptP2) +SqDist( const Point3d& ptP1, const Point3d& ptP2) { double dX = ptP1.x - ptP2.x ; double dY = ptP1.y - ptP2.y ; @@ -170,7 +171,7 @@ Dist( const Point3d& ptP1, const Point3d& ptP2) inline bool AreSamePointNear( const Point3d& ptP1, const Point3d& ptP2) { - return ( DistSq( ptP1, ptP2) < ( EPS_SMALL * EPS_SMALL)) ; + return ( SqDist( ptP1, ptP2) < ( EPS_SMALL * EPS_SMALL)) ; } //---------------------------------------------------------------------------- @@ -179,5 +180,5 @@ AreSamePointNear( const Point3d& ptP1, const Point3d& ptP2) inline bool AreSamePointExact( const Point3d& ptP1, const Point3d& ptP2) { - return ( DistSq( ptP1, ptP2) < ( EPS_ZERO * EPS_ZERO)) ; + return ( SqDist( ptP1, ptP2) < ( EPS_ZERO * EPS_ZERO)) ; } diff --git a/EGkVector3d.h b/EGkVector3d.h index 82c6c39..bed877b 100644 --- a/EGkVector3d.h +++ b/EGkVector3d.h @@ -42,18 +42,18 @@ class EGK_EXPORT Vector3d void FromPolar( double dLen, double dAngDeg) ; public : - double LenSq( void) const ; + double SqLen( void) const ; double Len( void) const ; - inline bool IsSmall( void) const - { return ( ( x * x + y * y + z * z) < ( EPS_SMALL * EPS_SMALL)) ; } - inline bool IsZero( void) const - { return ( ( x * x + y * y + z * z) < ( EPS_ZERO * EPS_ZERO)) ; } - inline bool IsNormalized( void) const - { return ( fabs( 1.0 - (x * x + y * y + z * z)) < ( 2 * EPS_ZERO)) ; } - inline bool IsZplus( void) const - { return ( fabs( x) < EPS_ZERO && fabs( y) < EPS_ZERO && z > EPS_ZERO) ; } - inline bool IsZminus( void) const - { return ( fabs( x) < EPS_ZERO && fabs( y) < EPS_ZERO && z < - EPS_ZERO) ; } + bool IsSmall( void) const + { return ( ( x * x + y * y + z * z) < ( EPS_SMALL * EPS_SMALL)) ; } + bool IsZero( void) const + { return ( ( x * x + y * y + z * z) < ( EPS_ZERO * EPS_ZERO)) ; } + bool IsNormalized( void) const + { return ( fabs( 1.0 - (x * x + y * y + z * z)) < ( 2 * EPS_ZERO)) ; } + bool IsZplus( void) const + { 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) ; } void ToSpherical( double* pdLen, double* pdAngVertDeg, double* pdAngOrizzDeg) const ; bool Normalize( void) ; bool Rotate( const Vector3d& vtAx, double dAngRad) ; @@ -62,6 +62,7 @@ class EGK_EXPORT Vector3d 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) ; public : diff --git a/EGnVersion.h b/EGnDllMain.h similarity index 81% rename from EGnVersion.h rename to EGnDllMain.h index c430772..46d3fd7 100644 --- a/EGnVersion.h +++ b/EGnDllMain.h @@ -1,8 +1,8 @@ //---------------------------------------------------------------------------- // EgalTech 2013-2013 //---------------------------------------------------------------------------- -// File : EgnVersion.h Data : 21.11.13 Versione : 1.3a1 -// Contenuto : Prototipo funzione con info versione della DLL. +// File : EgnDllMain.h Data : 21.11.13 Versione : 1.4l2 +// Contenuto : Prototipi funzioni generali della DLL. // // // diff --git a/EgkCurve.h b/EgkCurve.h index a432e89..712d99e 100644 --- a/EgkCurve.h +++ b/EgkCurve.h @@ -16,7 +16,7 @@ #include "/EgtDev/Include/EGkGeoObj.h" //---------------------------------------------------------------------------- -class _declspec( novtable) ICurve : public IGeoObj +class __declspec( novtable) ICurve : public IGeoObj { public : virtual bool IsSimple( void) const = 0 ; diff --git a/EgkCurveArc.h b/EgkCurveArc.h index 147c5c6..f01c32e 100644 --- a/EgkCurveArc.h +++ b/EgkCurveArc.h @@ -14,9 +14,10 @@ #pragma once #include "/EgtDev/Include/EGkCurve.h" +#include "/EgtDev/Include/EGkGeoType.h" //---------------------------------------------------------------------------- -class _declspec( novtable) ICurveArc : public ICurve +class __declspec( novtable) ICurveArc : public ICurve { public : virtual bool Set( const Point3d& ptCen, const Vector3d& vtN, double dRad, @@ -30,6 +31,7 @@ class _declspec( novtable) ICurveArc : public ICurve virtual double GetRadius( void) const = 0 ; virtual double GetAngCenter( void) const = 0 ; virtual double GetDeltaN( void) const = 0 ; + virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, UPNTVECTOR& vUPoints) const = 0 ; } ; //----------------------------------------------------------------------------- diff --git a/EgkCurveBezier.h b/EgkCurveBezier.h index e720e56..7091bf5 100644 --- a/EgkCurveBezier.h +++ b/EgkCurveBezier.h @@ -14,11 +14,12 @@ #pragma once #include "/EgtDev/Include/EGkCurve.h" +#include "/EgtDev/Include/EGkGeoType.h" class ICurveArc ; //---------------------------------------------------------------------------- -class _declspec( novtable) ICurveBezier : public ICurve +class __declspec( novtable) ICurveBezier : public ICurve { public : virtual bool Init( int nDeg, bool bIsRational) = 0 ; @@ -29,6 +30,8 @@ class _declspec( novtable) ICurveBezier : public ICurve virtual bool IsRational( void) const = 0 ; virtual const Point3d& GetControlPoint( int nInd, bool* pbOk = NULL) const = 0 ; virtual double GetControlWeight( int nInd, bool* pbOk = NULL) const = 0 ; + virtual bool GetControlPolygonLength( double& dLen) const = 0 ; + virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, UPNTVECTOR& vUPoints) const = 0 ; } ; //----------------------------------------------------------------------------- diff --git a/EgkCurveComposite.h b/EgkCurveComposite.h index 5e7cfec..e4f9814 100644 --- a/EgkCurveComposite.h +++ b/EgkCurveComposite.h @@ -16,7 +16,7 @@ #include "/EgtDev/Include/EGkCurve.h" //---------------------------------------------------------------------------- -class _declspec( novtable) ICurveComposite : public ICurve +class __declspec( novtable) ICurveComposite : public ICurve { public : virtual bool Clear( void) = 0 ; diff --git a/EgkCurveLine.h b/EgkCurveLine.h index 63010d2..bc5dec6 100644 --- a/EgkCurveLine.h +++ b/EgkCurveLine.h @@ -14,14 +14,16 @@ #pragma once #include "/EgtDev/Include/EGkCurve.h" +#include "/EgtDev/Include/EGkGeoType.h" //---------------------------------------------------------------------------- -class _declspec( novtable) ICurveLine : public ICurve +class __declspec( novtable) ICurveLine : public ICurve { public : virtual bool Set( const Point3d& ptStart, const Point3d& ptEnd) = 0 ; virtual const Point3d& GetStart( void) const = 0 ; virtual const Point3d& GetEnd( void) const = 0 ; + virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, UPNTVECTOR& vUPoints) const = 0 ; } ; //----------------------------------------------------------------------------- diff --git a/EgkGdbExecutor.h b/EgkGdbExecutor.h index 1377ff9..50d40fb 100644 --- a/EgkGdbExecutor.h +++ b/EgkGdbExecutor.h @@ -26,11 +26,11 @@ #endif //---------------------------------------------------------------------------- -class _declspec( novtable) IGdbExecutor : public ICmdExecutor +class __declspec( novtable) IGdbExecutor : public ICmdExecutor { public : virtual ~IGdbExecutor( void) {} - virtual bool Init( IGeomDB* pGdb, ILogger* pLogger) = 0 ; + virtual bool Init( IGeomDB* pGdb) = 0 ; } ; //---------------------------------------------------------------------------- diff --git a/EgnCmdExecutor.h b/EgnCmdExecutor.h index b0d29fc..db03fc5 100644 --- a/EgnCmdExecutor.h +++ b/EgnCmdExecutor.h @@ -16,7 +16,7 @@ #include "/EgtDev/Include/EgnStringBase.h" //---------------------------------------------------------------------------- -class _declspec( novtable) ICmdExecutor +class __declspec( novtable) ICmdExecutor { public : virtual bool Execute( const std::string& sCmd1, const std::string& sCmd2, const STRVECTOR& vsParams) = 0 ; diff --git a/EgnCmdParser.h b/EgnCmdParser.h index 27aaf8c..09aec9e 100644 --- a/EgnCmdParser.h +++ b/EgnCmdParser.h @@ -26,7 +26,7 @@ #endif //---------------------------------------------------------------------------- -class _declspec( novtable) ICmdParser +class __declspec( novtable) ICmdParser { public : virtual ~ICmdParser( void) {} diff --git a/EgtILogger.h b/EgtILogger.h index 0575cea..9bbe650 100644 --- a/EgtILogger.h +++ b/EgtILogger.h @@ -17,12 +17,14 @@ #define LOG_DATETIME( pLog, szText) if ( (pLog) != nullptr) \ (pLog)->Log( LL_INFO, LI_DATETIME, nullptr, 0, nullptr, szText) ; #define LOG_INFO( pLog, szText) if ( (pLog) != nullptr) \ - (pLog)->Log( LL_INFO, 0, nullptr, 0, nullptr, szText) ; + (pLog)->Log( LL_INFO, LI_NONE, nullptr, 0, nullptr, szText) ; #define LOG_WARN( pLog, szText) if ( (pLog) != nullptr) \ - ((pLog)->Log( LL_WARN, 0, nullptr, 0, nullptr, szText) ; + ((pLog)->Log( LL_WARN, LI_NONE, nullptr, 0, nullptr, szText) ; #define LOG_ERROR( pLog, szText) if ( (pLog) != nullptr) \ - (pLog)->Log( LL_ERROR, 0, nullptr, 0, nullptr, szText) ; -#define LOG_DEBUG( pLog, szText) if ( (pLog) != nullptr) \ + (pLog)->Log( LL_ERROR, LI_NONE, nullptr, 0, nullptr, szText) ; +#define LOG_DBG_INFO( pLog, szText) if ( (pLog) != nullptr) \ + (pLog)->Log( LL_DEBUG, LI_NONE, nullptr, 0, nullptr, szText) ; +#define LOG_DBG_ERR( pLog, szText) if ( (pLog) != nullptr) \ (pLog)->Log( LL_DEBUG, __FILE__, __LINE__, __FUNCTION__, szText) ; #define LOG( pLog, nLev, nItem, szText) if ( (pLog) != nullptr) \ (pLog)->Log( nLev, nItem, __FILE__, __LINE__, __FUNCTION__, szText) ; @@ -39,6 +41,7 @@ enum LogLevel //---------------------------------------------------------------------------- enum LogItem { + LI_NONE = 0x0, LI_FILENAME = 0x1, LI_LINENUMBER = 0x2, LI_FUNCTION = 0x4, @@ -49,7 +52,7 @@ enum LogItem } ; //---------------------------------------------------------------------------- -class _declspec( novtable) ILogger +class __declspec( novtable) ILogger { public : virtual void Log( LogLevel nLevel, const char* szFile, int nLine, const char* szFunc, const char* szText) = 0 ;