63fb9a638b
- a SimpleOffset di Curve aggiunto parametro opzionale dMaxAngExt (angolo esterno oltre il quale estendi diventa smussa) con default 90deg.
201 lines
11 KiB
C++
201 lines
11 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2013-2013
|
|
//----------------------------------------------------------------------------
|
|
// File : CurveLine.h Data : 16.04.13 Versione : 1.1d1
|
|
// Contenuto : Dichiarazione della classe Segmento di Linea.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 16.04.13 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "ObjGraphicsMgr.h"
|
|
#include "CurveAux.h"
|
|
#include "DllMain.h"
|
|
#include "GeoObjRW.h"
|
|
#include "/EgtDev/Include/EGkCurveLine.h"
|
|
|
|
class Voronoi ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
class CurveLine : public ICurveLine, public IGeoObjRW
|
|
{
|
|
public : // IGeoObj
|
|
~CurveLine( void) override ;
|
|
CurveLine* 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, int nPropInd = 0) override
|
|
{ if ( nPropInd >= 0 && nPropInd < 2)
|
|
m_nTempProp[nPropInd] = nProp ; }
|
|
int GetTempProp( int nPropInd = 0) const override
|
|
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
|
void SetTempParam( double dParam, int nParamInd = 0) override
|
|
{ if ( nParamInd >= 0 && nParamInd < 2)
|
|
m_dTempParam[nParamInd] = dParam ; }
|
|
double GetTempParam( int nParamInd = 0) const override
|
|
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
|
|
|
public : // ICurve
|
|
bool IsSimple( void) const override
|
|
{ return true ; }
|
|
bool IsClosed( void) const override
|
|
{ return ::IsClosed( *this) ; }
|
|
bool IsFlat( Plane3d& plPlane, bool bUseExtrusion = true, 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
|
|
{ return GetMidPoint( ptCen) ; }
|
|
bool GetStartDir( Vector3d& vtDir) const override ;
|
|
bool GetEndDir( Vector3d& vtDir) const override
|
|
{ return GetStartDir( vtDir) ; }
|
|
bool GetMidDir( Vector3d& vtDir) const override
|
|
{ return GetStartDir( vtDir) ; }
|
|
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
|
|
{ dStart = 0 ; dEnd = 1 ; return ( m_nStatus == OK) ; }
|
|
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 = 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 false ; }
|
|
bool GetArea( Plane3d& plPlane, double& dArea) const override
|
|
{ return false ; }
|
|
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
|
|
{ return ApproxWithArcs( dLinTol, dAngTolDeg, PA) ; }
|
|
ICurve* CopyParamRange( double dUStart, double dUEnd) const override ;
|
|
bool Invert( void) override ;
|
|
bool SimpleOffset( double dDist, int nType = OFF_FILLET, double dMaxAngExt = ANG_RIGHT) 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 : // ICurveLine
|
|
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
|
bool Set( const Point3d& ptStart, const Point3d& ptEnd) override ;
|
|
bool SetPVL( const Point3d& ptStart, const Vector3d& vtDir, double dLen) override ;
|
|
bool SetPDL( const Point3d& ptStart, double dDirAngDeg, double dLen) override ;
|
|
const Point3d& GetStart( void) const override
|
|
{ return m_PtStart ; }
|
|
const Point3d& GetEnd( void) const override
|
|
{ return m_PtEnd ; }
|
|
bool CalcPointParamPosiz( const Point3d& ptP, bool bOnXY, double& dU, int& nPos) const override ;
|
|
|
|
public : // IGeoObjRW
|
|
int GetNgeId( void) const override ;
|
|
bool Save( NgeWriter& ngeOut) const override ;
|
|
bool PreSave( GdbGeo& Wrapper) const override { return true ; }
|
|
bool PostSave( GdbGeo& Wrapper) const override { return true ; }
|
|
bool Load( NgeReader& ngeIn) override ;
|
|
bool PostLoad( GdbGeo& Wrapper) override { return true ; }
|
|
|
|
public :
|
|
CurveLine( void) ;
|
|
CurveLine( const CurveLine& clSrc) : m_pVoronoiObj( nullptr)
|
|
{ if ( ! CopyFrom( clSrc))
|
|
LOG_ERROR( GetEGkLogger(), "CurveLine : copy constructor error") }
|
|
CurveLine& operator =( const CurveLine& clSrc)
|
|
{ if ( ! CopyFrom( clSrc))
|
|
LOG_ERROR( GetEGkLogger(), "CurveLine : copy error")
|
|
return *this ; }
|
|
Voronoi* GetVoronoiObject( void) const ;
|
|
void ResetVoronoiObject( void) const ;
|
|
|
|
private :
|
|
bool CopyFrom( const CurveLine& clSrc) ;
|
|
bool Validate( void) ;
|
|
bool CalcVoronoiObject( void) const ;
|
|
|
|
private :
|
|
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
|
|
|
private :
|
|
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
|
Status m_nStatus ; // stato
|
|
Point3d m_PtStart ; // punto iniziale
|
|
Point3d m_PtEnd ; // punto finale
|
|
Vector3d m_VtExtr ; // vettore estrusione
|
|
double m_dThick ; // spessore
|
|
int m_nTempProp[2] ; // vettore proprietà temporanee
|
|
double m_dTempParam[2] ; // vettore parametri temporanei
|
|
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
|
} ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
inline CurveLine* CreateBasicCurveLine( void)
|
|
{ return ( static_cast<CurveLine*>( CreateGeoObj( CRV_LINE))) ; }
|
|
inline CurveLine* CloneBasicCurveLine( const IGeoObj* pGObj)
|
|
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_LINE)
|
|
return nullptr ;
|
|
return ( static_cast<CurveLine*>( pGObj->Clone())) ; }
|
|
inline const CurveLine* GetBasicCurveLine( const IGeoObj* pGObj)
|
|
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_LINE)
|
|
return nullptr ;
|
|
return ( static_cast<const CurveLine*>( pGObj)) ; }
|
|
inline CurveLine* GetBasicCurveLine( IGeoObj* pGObj)
|
|
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_LINE)
|
|
return nullptr ;
|
|
return ( static_cast<CurveLine*>( pGObj)) ; }
|