diff --git a/EGkPolyArc.h b/EGkPolyArc.h new file mode 100644 index 0000000..377f555 --- /dev/null +++ b/EGkPolyArc.h @@ -0,0 +1,72 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : EGkPolyArc.h Data : 14.08.14 Versione : 1.5h3 +// Contenuto : Dichiarazione della classe PolyArc. +// +// +// +// Modifiche : 14.08.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#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 + #define EGK_EXPORT __declspec( dllexport) +#else + #define EGK_EXPORT __declspec( dllimport) +#endif + +//----------------------------------------------------------------------------- +class PolyArc +{ + public : + EGK_EXPORT PolyArc( void) ; + EGK_EXPORT ~PolyArc( void) ; + EGK_EXPORT bool Clear( void) ; + EGK_EXPORT bool AddUPoint( double dPar, const Point3d& ptP, double dBulge) ; + EGK_EXPORT bool EraseFirstUPoint( void) ; + EGK_EXPORT bool EraseLastUPoint( void) ; + EGK_EXPORT bool AddOffsetToU( double dOffset) ; + EGK_EXPORT bool ToGlob( const Frame3d& frRef) ; + EGK_EXPORT bool ToLoc( const Frame3d& frRef) ; + EGK_EXPORT bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ; + EGK_EXPORT bool Splice( PolyArc& PA) ; + EGK_EXPORT int GetPointNbr( void) const + { return m_nCount ; } + EGK_EXPORT bool GetFirstUPoint( double* pdPar, Point3d* pptP, double* pdBulge) const ; + EGK_EXPORT bool GetNextUPoint( double* pdPar, Point3d* pptP, double* pdBulge, bool bNotLast = false) const ; + EGK_EXPORT bool GetFirstU( double& dPar) const + { return GetFirstUPoint( &dPar, nullptr, nullptr) ; } + EGK_EXPORT bool GetNextU( double& dPar, bool bNotLast = false) const + { return GetNextUPoint( &dPar, nullptr, nullptr, bNotLast) ; } + EGK_EXPORT bool GetFirstPoint( Point3d& ptP, double& dBulge) const + { return GetFirstUPoint( nullptr, &ptP, &dBulge) ; } + EGK_EXPORT bool GetNextPoint( Point3d& ptP, double& dBulge, bool bNotLast = false) const + { return GetNextUPoint( nullptr, &ptP, &dBulge, bNotLast) ; } + + private : + struct UPointB + { + double dU ; + Point3d ptP ; + double dB ; + UPointB( double dU_, const Point3d& ptP_, double dB_) + : dU( dU_), ptP( ptP_), dB( dB_) {} + } ; + typedef std::list UPNTBLIST ; // lista di UPointB + + private : + int m_nCount ; + UPNTBLIST m_lUPointBs ; + mutable UPNTBLIST::const_iterator m_iter ; +} ; diff --git a/EGkPolyLine.h b/EGkPolyLine.h index 65bdb31..efe1b47 100644 --- a/EGkPolyLine.h +++ b/EGkPolyLine.h @@ -86,16 +86,14 @@ class PolyLine { return GetLastULine( nullptr, &ptIni, nullptr, &ptFin) ; } EGK_EXPORT bool GetPrevLine( Point3d& ptIni, Point3d& ptFin) const { return GetPrevULine( nullptr, &ptIni, nullptr, &ptFin) ; } - EGK_EXPORT bool IsFlat( Plane3d& plPlane, double& dArea, double dToler = EPS_SMALL) const ; + EGK_EXPORT bool IsFlat( int& nRank, Point3d& ptCen, Vector3d& vtDir, double dToler = EPS_SMALL) const ; + EGK_EXPORT bool IsClosedAndFlat( Plane3d& plPlane, double& dArea, double dToler = EPS_SMALL) const ; EGK_EXPORT bool GetApproxLength( double& dLen) const ; EGK_EXPORT bool GetLength( double& dLen) const ; EGK_EXPORT bool GetAreaXY( double& dArea) const ; EGK_EXPORT bool GetMaxDistanceFromLine( double& dMaxDist, const Point3d& ptAx, const Vector3d& vtAx, double dLen, bool bIsSegment = true) const ; - private : - bool NewellPlane( Plane3d& plPlane, double& dArea) const ; - private : int m_nCount ; UPNTLIST m_lUPoints ; diff --git a/EGkVector3d.h b/EGkVector3d.h index b20797a..ae4f46f 100644 --- a/EGkVector3d.h +++ b/EGkVector3d.h @@ -38,16 +38,12 @@ class EGK_EXPORT Vector3d //! Costruttore del vettore nullo X = Y = Z = 0 Vector3d( void) : x( 0), y( 0), z( 0) {} //! Assegnazione delle componenti X, Y e Z al vettore - void Set( double dX, double dY, double dZ) { x = dX ; y = dY ; z = dZ ;} + void Set( double dX, double dY, double dZ) { x = dX ; y = dY ; z = dZ ; } //! Copia const Vector3d& operator =( const Vector3d& vtSrc) { if ( &vtSrc != this) { x = vtSrc.x , y = vtSrc.y , z = vtSrc.z ; } return *this ; } - //! Definizione a partire da coordinate sferiche - void FromSpherical( double dLen, double dAngVertDeg, double dAngOrizzDeg) ; - //! Definizione a partire da coordinate polari - void FromPolar( double dLen, double dAngDeg) ; public : //! Quadrato della lunghezza del vettore @@ -101,7 +97,10 @@ class EGK_EXPORT Vector3d { double dMul = 1 / dDiv ; this->x *= dMul ; this->y *= dMul ; this->z *= dMul ; return *this ; } //! Ritorna la rappresentazione in coordinate sferiche void ToSpherical( double* pdLen, double* pdAngVertDeg, double* pdAngOrizzDeg) const ; - //! Normalizzazione di un vettore (trasformazione in versore) + //! Inversione del vettore + void Invert( void) + { x = - x ; y = - y ; z = - z ; } + //! Normalizzazione del vettore (trasformazione in versore) bool Normalize( double dEps = EPS_SMALL) ; //! Rotazione attorno ad un asse, dato l'angolo in gradi bool Rotate( const Vector3d& vtAx, double dAngDeg) ; @@ -150,6 +149,21 @@ const Vector3d Y_AX( 0, 1, 0) ; //! Versore asse Z const Vector3d Z_AX( 0, 0, 1) ; +//---------------------------------------------------------------------------- +//! Definizione a partire da coordinate sferiche +//---------------------------------------------------------------------------- +EGK_EXPORT Vector3d FromSpherical( double dLen, double dAngVertDeg, double dAngOrizzDeg) ; + +//---------------------------------------------------------------------------- +//! Definizione a partire da coordinate polari ( nel piano XY, Z = 0) +//---------------------------------------------------------------------------- +EGK_EXPORT Vector3d FromPolar( double dLen, double dAngDeg) ; + +//---------------------------------------------------------------------------- +//! Definizione come pił verticale dei vettori ortogonali a quello ricevuto +//---------------------------------------------------------------------------- +EGK_EXPORT Vector3d FromUprightOrtho( const Vector3d& vtV) ; + //---------------------------------------------------------------------------- //! Opposto di un vettore //---------------------------------------------------------------------------- diff --git a/EgkCurve.h b/EgkCurve.h index 62488af..2f64ca6 100644 --- a/EgkCurve.h +++ b/EgkCurve.h @@ -15,6 +15,8 @@ #include "/EgtDev/Include/EGkGeoObj.h" #include "/EgtDev/Include/EGkPolyLine.h" +#include "/EgtDev/Include/EGkPolyArc.h" +#include "/EgtDev/Include/EGkPlane3d.h" //---------------------------------------------------------------------------- class __declspec( novtable) ICurve : public IGeoObj @@ -36,6 +38,7 @@ class __declspec( novtable) ICurve : public IGeoObj public : virtual bool IsSimple( void) const = 0 ; virtual bool IsClosed( void) const = 0 ; + virtual bool IsFlat( Plane3d& plPlane, double dToler = EPS_SMALL) const = 0 ; virtual bool GetStartPoint( Point3d& ptStart) const = 0 ; virtual bool GetEndPoint( Point3d& ptEnd) const = 0 ; virtual bool GetMidPoint( Point3d& ptMid) const = 0 ; @@ -56,6 +59,7 @@ class __declspec( novtable) ICurve : public IGeoObj virtual bool GetPointDiffGeom( double dU, Side nS, CrvPointDiffGeom& oDiffG) const = 0 ; virtual bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const = 0 ; virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const = 0 ; + virtual bool ApproxWithArcs( double dLinTol, double dAngTolDeg, PolyArc& PA) const = 0 ; virtual ICurve* CopyParamRange( double dUStart, double dUEnd) const = 0 ; virtual bool Invert( void) = 0 ; virtual bool Offset( double dDist, int nSide, int nType = OFF_FILLET) = 0 ; diff --git a/EgkCurveArc.h b/EgkCurveArc.h index 57ff74e..dbfe37a 100644 --- a/EgkCurveArc.h +++ b/EgkCurveArc.h @@ -30,7 +30,7 @@ class __declspec( novtable) ICurveArc : public ICurve virtual bool Set2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStartDeg) = 0 ; virtual bool Set2PRS( const Point3d& ptStart, const Point3d& ptEnd, double dRad, bool bCCW = true) = 0 ; virtual bool SetC2P( const Point3d& ptCen, const Point3d& ptStart, const Point3d& ptNearEnd) = 0 ; - virtual bool IsFlat( void) const = 0 ; + virtual bool IsFlat( double dToler = EPS_SMALL) const = 0 ; virtual bool IsACircle( void) const = 0 ; virtual bool IsInPlaneXY( void) const = 0 ; virtual const Point3d& GetCenter( void) const = 0 ;