76d94d6194
- modifiche a Zmap - aggiunto clamp a ratio di font - migliorata ricerca nomi con *.
211 lines
12 KiB
C++
211 lines
12 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2013-2013
|
|
//----------------------------------------------------------------------------
|
|
// File : CurveComposite.h Data : 23.11.13 Versione : 1.3a1
|
|
// Contenuto : Dichiarazione della classe Curva composita.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 16.04.13 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "ObjGraphicsMgr.h"
|
|
#include "CurveAux.h"
|
|
#include "DllMain.h"
|
|
#include "GeoObjRW.h"
|
|
#include "/EgtDev/Include/EGkCurveComposite.h"
|
|
#include <deque>
|
|
|
|
//----------------------------------------------------------------------------
|
|
class CurveComposite : public ICurveComposite, public IGeoObjRW
|
|
{
|
|
public : // IGeoObj
|
|
~CurveComposite( void) override ;
|
|
CurveComposite* Clone( void) const override ;
|
|
GeoObjType GetType( void) const override ;
|
|
bool IsValid( void) const override
|
|
{ return ( m_nStatus == OK) ; }
|
|
const std::string& GetTitle( void) const override ;
|
|
bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ;
|
|
bool GetLocalBBox( BBox3d& b3Loc, int nFlag = BBF_STANDARD) const override ;
|
|
bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const override ;
|
|
bool Translate( const Vector3d& vtMove) override ;
|
|
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) override
|
|
{ double dAngRad = dAngDeg * DEGTORAD ;
|
|
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
|
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) override ;
|
|
bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) override ;
|
|
bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) override ;
|
|
bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) override ;
|
|
bool ToGlob( const Frame3d& frRef) override ;
|
|
bool ToLoc( const Frame3d& frRef) override ;
|
|
bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) override ;
|
|
void SetObjGraphics( IObjGraphics* pOGr) override
|
|
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
|
IObjGraphics* GetObjGraphics( void) override
|
|
{ return m_OGrMgr.GetObjGraphics() ; }
|
|
const IObjGraphics* GetObjGraphics( void) const override
|
|
{ return m_OGrMgr.GetObjGraphics() ; }
|
|
void SetTempProp( int nProp) override
|
|
{ m_nTempProp = nProp ; }
|
|
int GetTempProp( void) override
|
|
{ return m_nTempProp ; }
|
|
|
|
public : // ICurve
|
|
bool IsSimple( void) const override
|
|
{ return false ; }
|
|
bool IsClosed( void) const override ;
|
|
bool IsFlat( Plane3d& plPlane, double dToler = EPS_SMALL) const override ;
|
|
bool GetStartPoint( Point3d& ptStart) const override ;
|
|
bool GetEndPoint( Point3d& ptEnd) const override ;
|
|
bool GetMidPoint( Point3d& ptMid) const override ;
|
|
bool GetCenterPoint( Point3d& ptCen) const override
|
|
{ return GetMidPoint( ptCen) ; }
|
|
bool GetCentroid( Point3d& ptCen) const override ;
|
|
bool GetStartDir( Vector3d& vtDir) const override ;
|
|
bool GetEndDir( Vector3d& vtDir) const override ;
|
|
bool GetMidDir( Vector3d& vtDir) const override ;
|
|
bool GetExtrusion( Vector3d& vtExtr) const override
|
|
{ vtExtr = m_VtExtr ; return ( m_nStatus == OK) ; }
|
|
bool GetThickness( double& dThick) const override
|
|
{ dThick = m_dThick ; return ( m_nStatus == OK) ; }
|
|
bool GetDomain( double& dStart, double& dEnd) const override ;
|
|
bool IsValidParam( double dPar, Side nSide) const override
|
|
{ return ::IsValidParam( *this, dPar, nSide) ; }
|
|
bool IsStartParam( double dPar) const override
|
|
{ return ::IsStartParam( *this, dPar) ; }
|
|
bool IsEndParam( double dPar) const override
|
|
{ return ::IsEndParam( *this, dPar) ; }
|
|
bool GetLength( double& dLen) const override ;
|
|
bool GetLengthAtParam( double dU, double& dLen) const override ;
|
|
bool GetParamAtLength( double dLen, double& dU) const override ;
|
|
bool GetPointD1D2( double dU, Side nS, Point3d& ptPos,
|
|
Vector3d* pvtDer1 = nullptr, Vector3d* pvtDer2 = nullptr) const override ;
|
|
bool GetPointTang( double dU, Side nS, Point3d& ptPos, Vector3d& vtTang) const override
|
|
{ return ::GetPointTang( *this, dU, nS, ptPos, vtTang) ; }
|
|
bool GetPointDiffGeom( double dU, Side nS, CrvPointDiffGeom& oDiffG) const override
|
|
{ oDiffG.nFlag = ( IsParamAtJoint( dU) ? CrvPointDiffGeom::TO_VERIFY : CrvPointDiffGeom::STD) ;
|
|
return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
|
|
bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const override ;
|
|
bool GetParamAtPoint( const Point3d& ptP, double& dPar, double dTol = EPS_SMALL) const override ;
|
|
bool GetLengthAtPoint( const Point3d& ptP, double& dLen, double dTol = EPS_SMALL) const override ;
|
|
bool GetNearestExtremityToPoint( const Point3d& ptP, bool& bStart) const override
|
|
{ return ::GetNearestExtremityToPoint( ptP, *this, bStart) ; }
|
|
bool GetAreaXY( double& dArea) const override
|
|
{ return CurveGetAreaXY( *this, dArea) ; }
|
|
bool GetArea( Plane3d& plPlane, double& dArea) const override
|
|
{ return CurveGetArea( *this, plPlane, dArea) ; }
|
|
bool ApproxWithLines( double dLinTol, double dAngTolDeg, int nType, PolyLine& PL) const override ;
|
|
bool ApproxWithArcs( double dLinTol, double dAngTolDeg, PolyArc& PA) const override ;
|
|
bool ApproxWithArcsEx( double dLinTol, double dAngTolDeg, double dLinFea, PolyArc& PA) const override ;
|
|
ICurve* CopyParamRange( double dUStart, double dUEnd) const override ;
|
|
bool Invert( void) override ;
|
|
bool SimpleOffset( double dDist, int nType = OFF_FILLET) override ;
|
|
bool ModifyStart( const Point3d& ptNewStart) override ;
|
|
bool ModifyEnd( const Point3d& ptNewEnd) override ;
|
|
bool SetExtrusion( const Vector3d& vtExtr) override
|
|
{ m_VtExtr = vtExtr ; m_VtExtr.Normalize() ; m_OGrMgr.Reset() ; return true ; }
|
|
bool SetThickness( double dThick) override
|
|
{ m_dThick = dThick ; m_OGrMgr.Reset() ; return true ; }
|
|
bool TrimStartAtParam( double dUTrim) override ;
|
|
bool TrimEndAtParam( double dUTrim) override ;
|
|
bool TrimStartEndAtParam( double dUStartTrim, double dUEndTrim) override ;
|
|
bool TrimStartAtLen( double dLenTrim) override ;
|
|
bool TrimEndAtLen( double dLenTrim) override ;
|
|
bool ExtendStartByLen( double dLenExt) override ;
|
|
bool ExtendEndByLen( double dLenExt) override ;
|
|
|
|
public : // ICurveComposite
|
|
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
|
bool Clear( void) override ;
|
|
bool AddCurve( const ICurve& cCrv, bool bEndOrStart = true, double dLinTol = EPS_SMALL) override ;
|
|
bool AddCurve( ICurve* pCrv, bool bEndOrStart = true, double dLinTol = EPS_SMALL) override ;
|
|
bool Close( void) override ;
|
|
bool FromSplit( const ICurve& cCrv, int nParts) override ;
|
|
bool FromPolyLine( const PolyLine& PL) override ;
|
|
bool FromPolyArc( const PolyArc& PA) override ;
|
|
bool PolygonCenterCorner( int nSides, const Point3d& ptCen, const Point3d& ptCorner, const Vector3d& vtN) override ;
|
|
bool PolygonCenterMidSide( int nSides, const Point3d& ptCen, const Point3d& ptMidSide, const Vector3d& vtN) override ;
|
|
bool PolygonSide( int nSides, const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtN) override ;
|
|
int GetCurveCount( void) const override
|
|
{ return ( ( m_nStatus != OK) ? 0 : int( m_CrvSmplS.size())) ; }
|
|
const ICurve* GetCurve( int nCrv) const override ;
|
|
const ICurve* GetFirstCurve( void) const override ;
|
|
const ICurve* GetNextCurve( void) const override ;
|
|
const ICurve* GetLastCurve( void) const override ;
|
|
const ICurve* GetPrevCurve( void) const override ;
|
|
bool IsParamAtJoint( double dU) const override ;
|
|
ICurve* RemoveFirstOrLastCurve( bool bLast = true) override ;
|
|
bool ChangeStartPoint( double dU) override ;
|
|
bool AddLine( const Point3d& ptNew, bool bEndOrStart = true) override ;
|
|
bool AddArcTg( const Point3d& ptNew, bool bEndOrStart = true) override ;
|
|
bool AddArc2P( const Point3d& ptOther, const Point3d& ptNew, bool bEndOrStart = true) override ;
|
|
bool AddJoint( double dU) override ;
|
|
bool ModifyJoint( int nU, const Point3d& ptNewJoint) override ;
|
|
bool RemoveJoint( int nU) override ;
|
|
bool ArcsToBezierCurves( void) override ;
|
|
bool ArcsBezierCurvesToArcsPerpExtr( double dLinTol, double dAngTolDeg) override ;
|
|
bool MergeCurves( double dLinTol, double dAngTolDeg, bool bStartEnd = true) override ;
|
|
bool RemoveUndercutOnY( double dLinTol, double dAngTolDeg) override ;
|
|
bool IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const override ;
|
|
|
|
public : // IGeoObjRW
|
|
virtual int GetNgeId( void) const ;
|
|
virtual bool Save( NgeWriter& ngeOut) const ;
|
|
virtual bool Load( NgeReader& ngeIn) ;
|
|
|
|
public :
|
|
CurveComposite( void) ;
|
|
CurveComposite( const CurveComposite& ccSrc)
|
|
{ if ( ! CopyFrom( ccSrc))
|
|
LOG_ERROR( GetEGkLogger(), "CurveComposite : copy constructor error") }
|
|
CurveComposite& operator =( const CurveComposite& ccSrc)
|
|
{ if ( ! CopyFrom( ccSrc))
|
|
LOG_ERROR( GetEGkLogger(), "CurveComposite : copy error")
|
|
return *this ; }
|
|
bool RelocateFrom( CurveComposite& ccSrc) ;
|
|
|
|
private :
|
|
bool CopyFrom( const CurveComposite& ccSrc) ;
|
|
bool Validate( void) ;
|
|
bool AddCurveByRelocate( CurveComposite& ccSrc, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ;
|
|
bool AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ;
|
|
bool GetIndSCurveAndLocPar( double dU, Side nS, int& nSCrv, double& dLocU) const ;
|
|
bool SimpleOffsetXY( double dDist, int nType = OFF_FILLET) ;
|
|
bool MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dAngTolDeg) ;
|
|
bool IsOneCircle( Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const ;
|
|
|
|
private :
|
|
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
|
|
|
private :
|
|
typedef std::deque<ICurve*> PCRVSMPL_DEQUE ;
|
|
typedef PCRVSMPL_DEQUE::iterator PCSD_ITER ;
|
|
typedef PCRVSMPL_DEQUE::const_iterator PCSD_CONST_ITER ;
|
|
|
|
private :
|
|
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
|
Status m_nStatus ; // stato
|
|
PCRVSMPL_DEQUE m_CrvSmplS ; // deque di curve semplici
|
|
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
|
double m_dThick ; // spessore
|
|
int m_nTempProp ; // proprietà temporanea
|
|
mutable PCSD_CONST_ITER m_Iter ; // iteratore
|
|
} ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
inline CurveComposite* CreateBasicCurveComposite( void)
|
|
{ return (static_cast<CurveComposite*>( CreateGeoObj( CRV_COMPO))) ; }
|
|
inline CurveComposite* CloneBasicCurveComposite( const IGeoObj* pGObj)
|
|
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_COMPO)
|
|
return nullptr ;
|
|
return (static_cast<CurveComposite*>(pGObj->Clone())) ; }
|
|
inline const CurveComposite* GetBasicCurveComposite( const IGeoObj* pGObj)
|
|
{ return (dynamic_cast<const CurveComposite*>(pGObj)) ; }
|
|
inline CurveComposite* GetBasicCurveComposite( IGeoObj* pGObj)
|
|
{ return (dynamic_cast<CurveComposite*>(pGObj)) ; }
|