d253312139
- gestione traslazione, rotazione e cambi di frame per Voronoi - aggiunta funzione per resettare Voronoi degli oggetti.
185 lines
9.7 KiB
C++
185 lines
9.7 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : SurfFlatRegion.h Data : 05.08.15 Versione : 1.6h2
|
|
// Contenuto : Dichiarazione della classe Surface FlatRegion.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 05.08.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "ObjGraphicsMgr.h"
|
|
#include "DllMain.h"
|
|
#include "GeoObjRW.h"
|
|
#include "SurfTriMesh.h"
|
|
#include "/EgtDev/Include/EGkCurve.h"
|
|
#include "/EgtDev/Include/EGkCurveComposite.h"
|
|
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
|
#include <deque>
|
|
|
|
class Voronoi ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
|
{
|
|
public : // IGeoObj
|
|
~SurfFlatRegion( void) override ;
|
|
SurfFlatRegion* 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 : // ISurf
|
|
bool IsSimple( void) const override
|
|
{ return true ; }
|
|
bool IsClosed( void) const override
|
|
{ return false ; }
|
|
bool GetArea( double& dArea) const override ;
|
|
bool GetVolume( double& dVolume) const override
|
|
{ dVolume = 0 ;
|
|
return ( m_nStatus == OK) ; }
|
|
bool GetCentroid( Point3d& ptCen) const override ;
|
|
bool Invert( void) override ;
|
|
|
|
public : // ISurfFlatRegion
|
|
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
|
bool Clear( void) override ;
|
|
bool AddExtLoop( const ICurve& cCrv) override ;
|
|
bool AddExtLoop( ICurve* pCrv) override ;
|
|
bool AddIntLoop( const ICurve& cCrv) override ;
|
|
bool AddIntLoop( ICurve* pCrv) override ;
|
|
bool Add( const ISurfFlatRegion& Other) override ;
|
|
bool Subtract( const ISurfFlatRegion& Other) override ;
|
|
bool Intersect( const ISurfFlatRegion& Other) override ;
|
|
bool Offset( double dDist, int nType) override ;
|
|
SurfFlatRegion* CreateOffsetSurf( double dDist, int nType) const override ;
|
|
bool GetGrossArea( double& dArea) const override ;
|
|
const Point3d& GetPlanePoint( void) const override
|
|
{ return m_frF.Orig() ; }
|
|
const Vector3d& GetNormVersor( void) const override
|
|
{ return m_frF.VersZ() ; }
|
|
int GetChunkCount( void) const override ;
|
|
int GetLoopCount( int nChunk) const override ;
|
|
ICurve* GetLoop( int nChunk, int nLoop) const override ; // nChunk 0-based, nLoop 0-based (1°esterno, successivi interni)
|
|
bool ApproxLoopWithLines( int nChunk, int nLoop, double dLinTol, double dAngTolDeg, int nType, PolyLine& PL) const override ;
|
|
const SurfTriMesh* GetAuxSurf( void) const override ;
|
|
SurfFlatRegion* CloneChunk( int nChunk) const override ;
|
|
bool GetChunkCentroid( int nChunk, Point3d& ptCen) const override ;
|
|
bool GetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const override ;
|
|
int GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion& Other, int nOthChunk) const override ; // compare only outsides
|
|
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = 3) const override ;
|
|
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const override ;
|
|
void ResetVoronoiObject( void) 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 :
|
|
SurfFlatRegion( void) ;
|
|
SurfFlatRegion( const SurfFlatRegion& stSrc) : m_pSTM( nullptr), m_pVoronoiObj( nullptr)
|
|
{ if ( ! CopyFrom( stSrc))
|
|
LOG_ERROR( GetEGkLogger(), "SurfFlatRegion : copy constructor error") }
|
|
SurfFlatRegion& operator =( const SurfFlatRegion& stSrc)
|
|
{ if ( ! CopyFrom( stSrc))
|
|
LOG_ERROR( GetEGkLogger(), "SurfFlatRegion : copy error")
|
|
return *this ; }
|
|
SurfTriMesh* CalcAuxSurf( double dLinTol, double dAngTolDeg) const ;
|
|
|
|
friend class MyCAvSimpleSurfFrMove ;
|
|
|
|
private :
|
|
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
|
|
|
private :
|
|
typedef std::deque<ICurve*> PCRV_DEQUE ;
|
|
|
|
private :
|
|
bool CopyFrom( const SurfFlatRegion& clSrc) ;
|
|
bool AddSimpleExtLoop( ICurve* pCrv) ;
|
|
bool MyAddExtLoop( ICurve* pCrv) ;
|
|
bool AddSimpleIntLoop( ICurve* pCrv) ;
|
|
bool MyAddIntLoop( ICurve* pCrv, int nChunk) ;
|
|
int GetIndFromChunkLoop( int nChunk, int nLoop) const ;
|
|
bool GetChunkLoopFromInd( int nInd, int& nChunk, int& nLoop) const ;
|
|
ICurve* GetMyLoop( int nInd) const ; // indice nel vettore di tutti i loop
|
|
ICurve* GetMyLoop( int nChunk, int nLoop) const ; // nChunk 0-based, nLoop 0-based (1°esterno, successivi interni)
|
|
void ResetAuxSurf( void) const ;
|
|
bool ConvertArcsToBezierCurves( void) ;
|
|
bool MyGetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const ;
|
|
static bool MySelectCurves( const PCRV_DEQUE& vpLoop, const SurfFlatRegion& Other,
|
|
int nType1, bool bInvert1, int nType2, bool bInvert2, PCRV_DEQUE& vpCurve) ;
|
|
static bool MyChainCurves( PCRV_DEQUE& vpCurve, PCRV_DEQUE& vpLoop) ;
|
|
static SurfFlatRegion* MyNewSurfFromLoops( PCRV_DEQUE& vpLoop) ;
|
|
static bool MyTestAndDelete( PCRV_DEQUE& vpCrv) ;
|
|
bool CalcVoronoiObject( void) const ;
|
|
|
|
private :
|
|
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
|
mutable SurfTriMesh* m_pSTM ; // superficie trimesh ausiliaria
|
|
Status m_nStatus ; // stato
|
|
Frame3d m_frF ; // riferimento intrinseco
|
|
PCRV_DEQUE m_vpLoop ; // deque delle curve che formano i loop
|
|
INTVECTOR m_vExtInd ; // indice dei loop esterni nel precedente vettore
|
|
int m_nTempProp[2] ; // vettore proprietà temporanee
|
|
double m_dTempParam[2] ; // vettore parametri temporanei
|
|
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
|
|
|
} ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
inline SurfFlatRegion* CreateBasicSurfFlatRegion( void)
|
|
{ return ( static_cast<SurfFlatRegion*>( CreateGeoObj( SRF_FLATRGN))) ; }
|
|
inline SurfFlatRegion* CloneBasicSurfFlatRegion( const IGeoObj* pGObj)
|
|
{ if ( pGObj == nullptr || pGObj->GetType() != SRF_FLATRGN)
|
|
return nullptr ;
|
|
return ( static_cast<SurfFlatRegion*>( pGObj->Clone())) ; }
|
|
inline const SurfFlatRegion* GetBasicSurfFlatRegion( const IGeoObj* pGObj)
|
|
{ if ( pGObj == nullptr || pGObj->GetType() != SRF_FLATRGN)
|
|
return nullptr ;
|
|
return ( static_cast<const SurfFlatRegion*>( pGObj)) ; }
|
|
inline SurfFlatRegion* GetBasicSurfFlatRegion( IGeoObj* pGObj)
|
|
{ if ( pGObj == nullptr || pGObj->GetType() != SRF_FLATRGN)
|
|
return nullptr ;
|
|
return ( static_cast<SurfFlatRegion*>( pGObj)) ; }
|