41a38fef3b
- aggiunta entità testo (con font Nfe e di sistema) - in tutte le rotate ora l'angolo è in gradi - aggiunta trasformazione Shear (scorrimento) - aggiunta trsformazione LocToLoc - Set/GetInfo specializzate per i diversi tipi di informazioni - Copy e Relocate con possibilità di indicare l'entità di riferimento rispetto a cui inserire - aggiunte trasformazioni a PolyLine.
149 lines
7.8 KiB
C++
149 lines
7.8 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2013-2013
|
|
//----------------------------------------------------------------------------
|
|
// File : CurveBezier.h Data : 22.11.13 Versione : 1.3a1
|
|
// Contenuto : Dichiarazione della classe Curve di Bezier.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 30.12.12 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "ObjGraphicsMgr.h"
|
|
#include "CurveAux.h"
|
|
#include "PolynomialPoint3d.h"
|
|
#include "DllMain.h"
|
|
#include "GeoObjRW.h"
|
|
#include "/EgtDev/Include/EGkCurveBezier.h"
|
|
#include "/EgtDev/Include/EgtNumCollection.h"
|
|
|
|
//----------------------------------------------------------------------------
|
|
class CurveBezier : public ICurveBezier, public IGeoObjRW
|
|
{
|
|
public : // IGeoObj
|
|
virtual ~CurveBezier( void) ;
|
|
virtual CurveBezier* Clone( void) const ;
|
|
virtual GeoObjType GetType( void) const ;
|
|
virtual bool IsValid( void) const
|
|
{ return ( m_nStatus == OK) ; }
|
|
virtual const std::string& GetTitle( void) const ;
|
|
virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ;
|
|
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
|
|
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
|
|
virtual bool Translate( const Vector3d& vtMove) ;
|
|
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
|
{ double dAngRad = dAngDeg * DEGTORAD ;
|
|
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
|
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
|
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
|
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
|
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
|
virtual bool ToGlob( const Frame3d& frRef) ;
|
|
virtual bool ToLoc( const Frame3d& frRef) ;
|
|
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
|
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
|
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
|
virtual IObjGraphics* GetObjGraphics( void)
|
|
{ return m_OGrMgr.GetObjGraphics() ; }
|
|
virtual const IObjGraphics* GetObjGraphics( void) const
|
|
{ return m_OGrMgr.GetObjGraphics() ; }
|
|
|
|
public : // ICurve
|
|
virtual bool IsSimple( void) const { return true ; }
|
|
virtual bool IsClosed( void) const
|
|
{ return ::IsClosed( *this) ; }
|
|
virtual bool GetStartPoint( Point3d& ptStart) const ;
|
|
virtual bool GetEndPoint( Point3d& ptEnd) const ;
|
|
virtual bool GetMidPoint( Point3d& ptMid) const ;
|
|
virtual bool GetCenterPoint( Point3d& ptCen) const
|
|
{ return GetMidPoint( ptCen) ; }
|
|
virtual bool GetStartDir( Vector3d& vtDir) const
|
|
{ return ::GetTang( *this, 0, FROM_PLUS, vtDir) ; }
|
|
virtual bool GetEndDir( Vector3d& vtDir) const
|
|
{ return ::GetTang( *this, 1, FROM_MINUS, vtDir) ; }
|
|
virtual bool GetMidDir( Vector3d& vtDir) const
|
|
{ return ::GetTang( *this, 0.5, FROM_MINUS, vtDir) ; }
|
|
virtual bool GetDomain( double& dStart, double& dEnd) const
|
|
{ dStart = 0 ; dEnd = 1 ; return ( m_nStatus == OK) ; }
|
|
virtual bool GetLength( double& dLen) const ;
|
|
virtual bool GetLengthAtParam( double dU, double& dLen) const ;
|
|
virtual bool GetParamAtLength( double dLen, double& dU) const ;
|
|
virtual bool GetPointD1D2( double dU, Side nS, Point3d& ptPos,
|
|
Vector3d* pvtDer1 = nullptr, Vector3d* pvtDer2 = nullptr) const ;
|
|
virtual bool GetPointTang( double dU, Side nS, Point3d& ptPos, Vector3d& vtTang) const
|
|
{ return ::GetPointTang( *this, dU, nS, ptPos, vtTang) ; }
|
|
virtual bool GetPointDiffGeom( double dU, Side nS, CrvPointDiffGeom& oDiffG) const
|
|
{ oDiffG.nFlag = CrvPointDiffGeom::STD ;
|
|
return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
|
|
virtual bool Invert( void) ;
|
|
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
|
|
virtual bool TrimStartAtParam( double dUTrim) ;
|
|
virtual bool TrimEndAtParam( double dUTrim) ;
|
|
virtual bool TrimStartAtLen( double dLenTrim) ;
|
|
virtual bool TrimEndAtLen( double dLenTrim) ;
|
|
|
|
public : // ICurveBezier
|
|
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
|
virtual bool Init( int nDeg, bool bIsRational) ;
|
|
virtual bool SetControlPoint( int nInd, const Point3d& ptCtrl) ;
|
|
virtual bool SetControlPoint( int nInd, const Point3d& ptCtrl, double dW) ;
|
|
virtual bool FromArc( const ICurveArc& crArc) ;
|
|
virtual int GetDegree( void) const
|
|
{ return m_nDeg ; }
|
|
virtual bool IsRational( void) const
|
|
{ return m_bRat ; }
|
|
virtual const Point3d& GetControlPoint( int nInd, bool* pbOk = NULL) const ;
|
|
virtual double GetControlWeight( int nInd, bool* pbOk = NULL) const ;
|
|
virtual bool GetControlPolygonLength( double& dLen) const ;
|
|
virtual int GetSingularParam( double& dPar) const ;
|
|
|
|
public : // IGeoObjRW
|
|
virtual int GetNgeId( void) const ;
|
|
virtual bool Save( NgeWriter& ngeOut) const ;
|
|
virtual bool Load( NgeReader& ngeIn) ;
|
|
|
|
public :
|
|
CurveBezier( void) ;
|
|
const CurveBezier& operator =( const CurveBezier& cbSrc)
|
|
{ if ( ! Copy( cbSrc))
|
|
LOG_ERROR( GetEGkLogger(), "CurveBezier : copy error")
|
|
return *this ; }
|
|
|
|
private :
|
|
bool Copy( const CurveBezier& cbSrc) ;
|
|
bool Validate( void) ;
|
|
bool GetPointD1D2( double dU, Point3d& ptPos,
|
|
Vector3d* pvtDer1 = nullptr, Vector3d* pvtDer2 = nullptr) const ;
|
|
void IncreaseBernsteinOneDegree( double dU, int nDeg, double dBern[]) const ;
|
|
bool CalcSingularParam( void) const ;
|
|
double GetSegmentLength( int nLev, double dU0, double dU1, double dU2,
|
|
const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2) const ;
|
|
bool GetSegmentParam( double dLen, double& dCurrLen, double& dSegLen,
|
|
double& dUIni, double& dUFin) const ;
|
|
bool FlatOrSplit( int nLev, const CurveBezier& crvBez, double dParStart, double dParEnd,
|
|
double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
|
|
bool ToPowerBase( PolynomialPoint3d& pol3P) const ;
|
|
bool ToPowerBase( PolynomialPoint3d& pol3Num, Polynomial& polDen) const ;
|
|
|
|
private :
|
|
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
|
static const int MAXDEG = 11 ;
|
|
static const int ST_PTC = 4 ;
|
|
|
|
private :
|
|
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
|
Status m_nStatus ; // stato
|
|
int m_nDeg ; // grado
|
|
bool m_bRat ; // flag di razionale/polinomiale
|
|
mutable double m_dParSing ; // eventuale parametro della singolarità (-1=no, -2=da calcolare)
|
|
int m_nDimArr ; // dimensione dell'array dinamico di punti
|
|
Point3d* m_aPtCtrl ; // array dei punti di controllo
|
|
double* m_aWeCtrl ; // array dei pesi di controllo
|
|
Point3d m_aStPtCtrl[ST_PTC] ; // array predefinito di 4 punti di controllo
|
|
double m_aStWeCtrl[ST_PTC] ; // array predefinito di 4 pesi di controllo
|
|
} ;
|