2c6ebdadca
- correzioni, migliorie e d estensioni alle superfici di Bezier - in Release cambiate opzioni di ottimizzazione da /Ox a /O2.
206 lines
12 KiB
C++
206 lines
12 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
|
|
~CurveBezier( void) override ;
|
|
CurveBezier* 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) const override
|
|
{ return m_nTempProp ; }
|
|
|
|
public : // ICurve
|
|
bool IsSimple( void) const override { return true ; }
|
|
bool IsClosed( void) const override
|
|
{ return ::IsClosed( *this) ; }
|
|
bool IsFlat( Plane3d& plPlane, double dToler) 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
|
|
{ return ::GetTang( *this, 0, FROM_PLUS, vtDir) ; }
|
|
bool GetEndDir( Vector3d& vtDir) const override
|
|
{ return ::GetTang( *this, 1, FROM_MINUS, vtDir) ; }
|
|
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
|
|
{ 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 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
|
|
{ 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) override
|
|
{ return false ; } // l'offset di crvBezier non è crvBezier tranne in casi molto particolari
|
|
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 : // ICurveBezier
|
|
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
|
bool Init( int nDeg, bool bIsRational) override ;
|
|
bool SetControlPoint( int nInd, const Point3d& ptCtrl) override ;
|
|
bool SetControlPoint( int nInd, const Point3d& ptCtrl, double dW) override ;
|
|
bool FromArc( const ICurveArc& crArc) override ;
|
|
int GetDegree( void) const override
|
|
{ return m_nDeg ; }
|
|
bool IsRational( void) const override
|
|
{ return m_bRat ; }
|
|
bool IsAPoint( void) const override ;
|
|
const Point3d& GetControlPoint( int nInd, bool* pbOk = NULL) const override ;
|
|
double GetControlWeight( int nInd, bool* pbOk = NULL) const override ;
|
|
bool GetControlPolygonLength( double& dLen) const override ;
|
|
int GetSingularParam( double& dPar) const override ;
|
|
|
|
public : // IGeoObjRW
|
|
int GetNgeId( void) const override ;
|
|
bool Save( NgeWriter& ngeOut) const override ;
|
|
bool Load( NgeReader& ngeIn) override ;
|
|
|
|
public :
|
|
CurveBezier( void) ;
|
|
CurveBezier( const CurveBezier& cbSrc)
|
|
{ if ( ! CopyFrom( cbSrc))
|
|
LOG_ERROR( GetEGkLogger(), "CurveBezier : copy constructor error")}
|
|
CurveBezier& operator =( const CurveBezier& cbSrc)
|
|
{ if ( ! CopyFrom( cbSrc))
|
|
LOG_ERROR( GetEGkLogger(), "CurveBezier : copy error")
|
|
return *this ; }
|
|
bool ApproxWithLines( int nStep, PolyLine& PL) const ;
|
|
bool GetApproxLength( double& dLen) const ;
|
|
|
|
private :
|
|
bool CopyFrom( const CurveBezier& cbSrc) ;
|
|
bool Validate( void) ;
|
|
bool GetPointD1D2( double dU, Point3d& ptPos,
|
|
Vector3d* pvtDer1 = nullptr, Vector3d* pvtDer2 = nullptr) 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 ApproxWithArcsXY(double dLinTol, double dAngTolDeg, PolyArc& PA) const;
|
|
bool BiArcOrSplit(int nLev, PolyLine& PL, double dLinTol, double dAngTolDeg, PolyArc& PA) 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 ;
|
|
|
|
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)
|
|
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
|
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
|
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
|
double m_dThick ; // spessore
|
|
int m_nTempProp ; // proprietà temporanea
|
|
} ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
inline CurveBezier* CreateBasicCurveBezier( void)
|
|
{ return (static_cast<CurveBezier*>( CreateGeoObj( CRV_BEZIER))) ; }
|
|
inline CurveBezier* CloneBasicCurveBezier( const IGeoObj* pGObj)
|
|
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_BEZIER)
|
|
return nullptr ;
|
|
return (static_cast<CurveBezier*>(pGObj->Clone())) ; }
|
|
inline const CurveBezier* GetBasicCurveBezier( const IGeoObj* pGObj)
|
|
{ return (dynamic_cast<const CurveBezier*>(pGObj)) ; }
|
|
inline CurveBezier* GetBasicCurveBezier( IGeoObj* pGObj)
|
|
{ return (dynamic_cast<CurveBezier*>(pGObj)) ; }
|