From fcd7fab8a86aae3badf30ed263f7bad29cad0847 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 9 Apr 2014 13:02:22 +0000 Subject: [PATCH] Include : - modifiche a Vector3d e Point3d - migliorie a FromString - aggiunta struttura Plane3d - migliorie varie. --- EGkPlane3d.h | 24 ++++++++++++++++++++++++ EGkPoint3d.h | 11 ++++++++--- EGkPolyLine.h | 18 ++++++++++++++++-- EGkStringUtils3d.h | 6 ++++-- EGkTriangle3d.h | 6 ++++++ EGkVector3d.h | 11 ++++++++--- EGnStringUtils.h | 41 +++++++++++++++++++++++++---------------- EgkSurf.h | 3 ++- EgkSurfTriMesh.h | 5 +++++ 9 files changed, 98 insertions(+), 27 deletions(-) create mode 100644 EGkPlane3d.h diff --git a/EGkPlane3d.h b/EGkPlane3d.h new file mode 100644 index 0000000..ab42352 --- /dev/null +++ b/EGkPlane3d.h @@ -0,0 +1,24 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : EGkPlane3d.h Data : 08.04.14 Versione : 1.5d2 +// Contenuto : Dichiarazione classe piano Plane3d. +// +// +// +// Modifiche : 08.04.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkPoint3d.h" + +//----------------------------------------------------------------------------- +class Plane3d +{ + public : + Vector3d vtN ; + double dDist ; +} ; diff --git a/EGkPoint3d.h b/EGkPoint3d.h index 651fa78..5b77965 100644 --- a/EGkPoint3d.h +++ b/EGkPoint3d.h @@ -66,9 +66,14 @@ class EGK_EXPORT Point3d { return ( ToGlob( frOri) && ToLoc( frDest)) ; } public : - double x ; - double y ; - double z ; + union { + struct { + double x ; + double y ; + double z ; + } ; + double v[3] ; + } ; } ; //---------------------------------------------------------------------------- diff --git a/EGkPolyLine.h b/EGkPolyLine.h index 4bfe7df..9b17125 100644 --- a/EGkPolyLine.h +++ b/EGkPolyLine.h @@ -16,6 +16,8 @@ #include "/EgtDev/Include/EGkPoint3d.h" #include "/EgtDev/Include/EGkGeoCollection.h" +class Plane3d ; + //----------------------- Macro per import/export ---------------------------- #undef EGK_EXPORT #if defined( I_AM_EGK) // da definirsi solo nella DLL @@ -30,10 +32,13 @@ class PolyLine public : EGK_EXPORT PolyLine( void) ; EGK_EXPORT ~PolyLine( void) ; + EGK_EXPORT bool Clear( void) ; EGK_EXPORT bool AddUPoint( double dPar, const Point3d& ptP) ; EGK_EXPORT bool EraseFirstUPoint( void) ; + EGK_EXPORT bool EraseLastUPoint( void) ; EGK_EXPORT bool AddOffsetToU( double dOffset) ; EGK_EXPORT bool Splice( PolyLine& PL) ; + EGK_EXPORT bool IsClosed( void) const ; EGK_EXPORT int GetPointNbr( void) const { return m_nCount ; } EGK_EXPORT bool GetFirstUPoint( double* pdPar, Point3d* pptP) const ; @@ -47,10 +52,15 @@ class PolyLine EGK_EXPORT bool GetNextPoint( Point3d& ptP) const { return GetNextUPoint( nullptr, &ptP) ; } EGK_EXPORT bool GetLastUPoint( double* pdPar, Point3d* pptP) const ; - EGK_EXPORT bool GetLastU( double& dPar) + EGK_EXPORT bool GetPrevUPoint( double* pdPar, Point3d* pptP) const ; + EGK_EXPORT bool GetLastU( double& dPar) const { return GetLastUPoint( &dPar, nullptr) ; } - EGK_EXPORT bool GetLastPoint( Point3d& ptP) + EGK_EXPORT bool GetPrevU( double& dPar) const + { return GetPrevUPoint( &dPar, nullptr) ; } + EGK_EXPORT bool GetLastPoint( Point3d& ptP) const { return GetLastUPoint( nullptr, &ptP) ; } + EGK_EXPORT bool GetPrevPoint( Point3d& ptP) const + { return GetPrevUPoint( nullptr, &ptP) ; } EGK_EXPORT int GetLineNbr( void) const { return ( m_nCount > 1 ? ( m_nCount - 1) : 0) ; } EGK_EXPORT bool GetFirstULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const ; @@ -59,6 +69,10 @@ class PolyLine { return GetFirstULine( nullptr, &ptIni, nullptr, &ptFin) ; } EGK_EXPORT bool GetNextLine( Point3d& ptIni, Point3d& ptFin) const { return GetNextULine( nullptr, &ptIni, nullptr, &ptFin) ; } + EGK_EXPORT bool IsPlanar( Plane3d& plPlane, double dToler = EPS_SMALL) const ; + + private : + bool NewellPlane( Plane3d& plPlane) const ; private : int m_nCount ; diff --git a/EGkStringUtils3d.h b/EGkStringUtils3d.h index 0421a40..3fbc281 100644 --- a/EGkStringUtils3d.h +++ b/EGkStringUtils3d.h @@ -26,8 +26,10 @@ #endif //---------------------------------------------------------------------------- -EGK_EXPORT bool FromString( const std::string& sVal, Vector3d& vtVal) ; -EGK_EXPORT bool FromString( const std::string& sVal, Point3d& ptVal) ; +inline bool FromString( const std::string& sVal, Vector3d& vtVal) + { return FromString( sVal, vtVal.v) ; } +inline bool FromString( const std::string& sVal, Point3d& ptVal) + { return FromString( sVal, ptVal.v) ; } EGK_EXPORT bool FromString( const std::string& sVal, Point3d& ptVal, double& dW) ; EGK_EXPORT bool FromString( const std::string& sVal, Frame3d& frFrame) ; EGK_EXPORT bool FromString( const std::string& sVal, Color& cCol) ; diff --git a/EGkTriangle3d.h b/EGkTriangle3d.h index d570091..e1c980e 100644 --- a/EGkTriangle3d.h +++ b/EGkTriangle3d.h @@ -51,3 +51,9 @@ class Triangle3d Vector3d vtN ; } ; +//----------------------------------------------------------------------------- +class TriNormals3d +{ + public : + Vector3d vtN[3] ; +} ; diff --git a/EGkVector3d.h b/EGkVector3d.h index d7fd357..07435ff 100644 --- a/EGkVector3d.h +++ b/EGkVector3d.h @@ -85,9 +85,14 @@ class EGK_EXPORT Vector3d bool GetRotation( const Vector3d& vtEnd, const Vector3d& vtAx, double& dAngDeg, bool& bDet) const ; public : - double x ; - double y ; - double z ; + union { + struct { + double x ; + double y ; + double z ; + } ; + double v[3] ; + } ; } ; //---------------------------------------------------------------------------- diff --git a/EGnStringUtils.h b/EGnStringUtils.h index b015cc8..a8fb6a8 100644 --- a/EGnStringUtils.h +++ b/EGnStringUtils.h @@ -63,10 +63,9 @@ ToLower( std::string& sString) //---------------------------------------------------------------------------- inline bool FromString( const std::string& sVal, int& nVal) - { const char* pStart ; + { const char* pStart = sVal.c_str() ; char* pStop ; errno = 0 ; - pStart = sVal.c_str() ; nVal = strtol( pStart, &pStop, 10) ; return ( pStop != pStart && *pStop == '\0' && errno == 0) ; } inline bool @@ -78,26 +77,36 @@ FromString( const std::string& sVal, bool& bVal) return true ; } inline bool FromString( const std::string& sVal, double& dVal) - { const char* pStart ; + { const char* pStart = sVal.c_str() ; char* pStop ; errno = 0 ; - pStart = sVal.c_str() ; dVal = strtod( pStart, &pStop) ; return ( pStop != pStart && *pStop == '\0' && errno == 0) ; } template bool FromString( const std::string& sVal, int (&nVal)[size]) - { // divido la stringa in parametri - STRVECTOR vsParams ; - Tokenize( sVal, ",", vsParams) ; - // devono essere size parametri - if ( vsParams.size() != size) - return false ; - // recupero il punto - for ( int i = 0 ; i < size ; ++ i) { - if ( ! FromString( vsParams[i], nVal[i])) - return false ; - } - return true ; + { const char* pStart = sVal.c_str() ; + char* pStop ; + errno = 0 ; + for ( int i = 0 ; i < size ; ++ i) { + nVal[i] = strtol( pStart, &pStop, 10) ; + if ( ( i < size - 1 && *pStop != ',') || errno != 0) + return false ; + pStart = pStop + 1 ; + } + return ( *pStop == '\0' && errno == 0) ; + } +template +bool FromString( const std::string& sVal, double (&dVal)[size]) + { const char* pStart = sVal.c_str() ; + char* pStop ; + errno = 0 ; + for ( int i = 0 ; i < size ; ++ i) { + dVal[i] = strtod( pStart, &pStop) ; + if ( ( i < size - 1 && *pStop != ',') || errno != 0) + return false ; + pStart = pStop + 1 ; + } + return ( *pStop == '\0' && errno == 0) ; } EGN_EXPORT const std::string ToString( int nVal, int nPrec = 1) ; inline const std::string diff --git a/EgkSurf.h b/EgkSurf.h index 680dca8..f10182b 100644 --- a/EgkSurf.h +++ b/EgkSurf.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- -// File : EgkSurf.h Data : 26.03.14 Versione : 1.5c9 +// File : EgkSurf.h Data : 07.04.14 Versione : 1.5d2 // Contenuto : Dichiarazione della interfaccia ISurf. // // @@ -21,6 +21,7 @@ class __declspec( novtable) ISurf : public IGeoObj public : virtual bool IsSimple( void) const = 0 ; virtual bool IsClosed( void) const = 0 ; + virtual bool Invert( void) = 0 ; } ; //---------------------------------------------------------------------------- diff --git a/EgkSurfTriMesh.h b/EgkSurfTriMesh.h index 7757664..be5e92f 100644 --- a/EgkSurfTriMesh.h +++ b/EgkSurfTriMesh.h @@ -16,6 +16,8 @@ #include "/EgtDev/Include/EGkSurf.h" #include "/EgtDev/Include/EGkTriangle3d.h" +class PolyLine ; + //---------------------------------------------------------------------------- class __declspec( novtable) ISurfTriMesh : public ISurf { @@ -25,12 +27,15 @@ class __declspec( novtable) ISurfTriMesh : public ISurf virtual int AddVertex( const Point3d& ptVert) = 0 ; virtual int AddTriangle( const int nIdVert[3]) = 0 ; virtual bool AdjustTopology( void) = 0 ; + virtual bool CreateByTriangulation( const PolyLine& PL) = 0 ; + virtual bool CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr) = 0 ; virtual int GetVertexNum( void) const = 0 ; virtual int GetTriangleNum( void) const = 0 ; virtual int GetFirstVertex( Point3d& ptP) const = 0 ; virtual int GetNextVertex( int nId, Point3d& ptP) const = 0 ; virtual int GetFirstTriangle( Triangle3d& Tria) const = 0 ; virtual int GetNextTriangle( int nId, Triangle3d& Tria) const = 0 ; + virtual bool GetTriangleSmoothNormals( int nId, TriNormals3d& TNrms) const = 0 ; } ; //-----------------------------------------------------------------------------