From 9dfe558a837b8359586d18003ad256cbfd072b55 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 29 Jan 2024 09:15:50 +0100 Subject: [PATCH] =?UTF-8?q?EgtGeomKernel=202.6a2=20:=20-=20cambiate=20inte?= =?UTF-8?q?rfacce=20legate=20a=20Voronoi=20reso=20non=20pi=C3=B9=20visibil?= =?UTF-8?q?e=20all'esterno=20della=20libreria.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CurveArc.cpp | 1 + CurveArc.h | 5 +- CurveAux.cpp | 21 +++++++-- CurveAux.h | 3 ++ CurveBezier.cpp | 1 + CurveBezier.h | 6 +-- CurveComposite.cpp | 1 + CurveComposite.h | 5 +- CurveLine.cpp | 1 + CurveLine.h | 5 +- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes EgtGeomKernel.vcxproj | 9 ++-- EgtGeomKernel.vcxproj.filters | 3 ++ OffsetCurve.cpp | 16 +++---- SfrCreate.cpp | 9 ++-- StmFromCurves.cpp | 9 ++-- SurfFlatRegion.cpp | 16 +------ SurfFlatRegion.h | 5 +- SurfFlatRegionOffset.cpp | 9 ++-- Voronoi.cpp | 2 +- Voronoi.h | 85 ++++++++++++++++++++++++++++++++++ 21 files changed, 151 insertions(+), 61 deletions(-) create mode 100644 Voronoi.h diff --git a/CurveArc.cpp b/CurveArc.cpp index 1b0b5b9..34ec910 100644 --- a/CurveArc.cpp +++ b/CurveArc.cpp @@ -22,6 +22,7 @@ #include "GeoObjFactory.h" #include "NgeWriter.h" #include "NgeReader.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkAngle.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkUiUnits.h" diff --git a/CurveArc.h b/CurveArc.h index d11bb8c..3879e20 100644 --- a/CurveArc.h +++ b/CurveArc.h @@ -18,7 +18,8 @@ #include "DllMain.h" #include "GeoObjRW.h" #include "/EgtDev/Include/EGkCurveArc.h" -#include "/EgtDev/Include/EGkVoronoi.h" + +class Voronoi ; //---------------------------------------------------------------------------- class CurveArc : public ICurveArc, public IGeoObjRW @@ -129,7 +130,6 @@ class CurveArc : public ICurveArc, public IGeoObjRW bool TrimEndAtLen( double dLenTrim) override ; bool ExtendStartByLen( double dLenExt) override ; bool ExtendEndByLen( double dLenExt) override ; - Voronoi* GetVoronoiObject( void) const override ; public : // ICurveArc bool CopyFrom( const IGeoObj* pGObjSrc) override ; @@ -199,6 +199,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW return *this ; } bool MyExtendedOffset( double dDist, bool bAll, int nType = OFF_FILLET) ; bool MyCalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos, double dLinTol) const ; + Voronoi* GetVoronoiObject( void) const ; private : bool CopyFrom( const CurveArc& caSrc) ; diff --git a/CurveAux.cpp b/CurveAux.cpp index f8850b0..ee05bb1 100644 --- a/CurveAux.cpp +++ b/CurveAux.cpp @@ -19,11 +19,11 @@ #include "CurveArc.h" #include "CurveBezier.h" #include "CurveComposite.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkUiUnits.h" #include "/EgtDev/Include/EgtPointerOwner.h" -#include "/EgtDev/Include/EGkVoronoi.h" using namespace std ; @@ -1041,11 +1041,24 @@ AdjustCurveSlope( ICurveComposite* pCrv, double dNini, double dNfin) return true ; } +//---------------------------------------------------------------------------- +Voronoi* +GetCurveVoronoi( const ICurve& crvC) +{ + switch ( crvC.GetType()) { + case CRV_LINE : return GetBasicCurveLine( &crvC)->GetVoronoiObject() ; + case CRV_ARC : return GetBasicCurveArc( &crvC)->GetVoronoiObject() ; + case CRV_BEZIER : return GetBasicCurveBezier( &crvC)->GetVoronoiObject() ; + case CRV_COMPO : return GetBasicCurveComposite( &crvC)->GetVoronoiObject() ; + } + return nullptr ; +} + //---------------------------------------------------------------------------- bool CalcCurveVoronoiDiagram( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nBound) { - Voronoi* pVoronoiObj = crvC.GetVoronoiObject() ; + Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ; if ( pVoronoiObj == nullptr) return false ; @@ -1056,7 +1069,7 @@ CalcCurveVoronoiDiagram( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nBound) bool CalcCurveMedialAxis( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nSide) { - Voronoi* pVoronoiObj = crvC.GetVoronoiObject() ; + Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ; if ( pVoronoiObj == nullptr) return false ; @@ -1067,7 +1080,7 @@ CalcCurveMedialAxis( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nSide) bool CalcCurveFatCurve( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, double dRadius, bool bSquareEnds, bool bSquareMids) { - Voronoi* pVoronoiObj = crvC.GetVoronoiObject() ; + Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ; if ( pVoronoiObj == nullptr) return false ; diff --git a/CurveAux.h b/CurveAux.h index 18bab55..197cd96 100644 --- a/CurveAux.h +++ b/CurveAux.h @@ -15,6 +15,8 @@ #include "/EgtDev/Include/EGkCurveAux.h" +class Voronoi ; + //---------------------------------------------------------------------------- bool IsClosed( const ICurve& crvC) ; bool IsValidParam( const ICurve& crvC, double dPar, ICurve::Side nSide) ; @@ -31,3 +33,4 @@ bool CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea) ; bool CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ; bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ; bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ; +Voronoi* GetCurveVoronoi( const ICurve& crvC) ; diff --git a/CurveBezier.cpp b/CurveBezier.cpp index 5eabe92..78351a3 100644 --- a/CurveBezier.cpp +++ b/CurveBezier.cpp @@ -26,6 +26,7 @@ #include "PolynomialPoint3d.h" #include "Bernstein.h" #include "deCasteljau.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkCurveArc.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkUiUnits.h" diff --git a/CurveBezier.h b/CurveBezier.h index b303d9b..f87d649 100644 --- a/CurveBezier.h +++ b/CurveBezier.h @@ -19,8 +19,8 @@ #include "DllMain.h" #include "GeoObjRW.h" #include "/EgtDev/Include/EGkCurveBezier.h" -#include "/EgtDev/Include/EgtNumCollection.h" -#include "/EgtDev/Include/EGkVoronoi.h" + +class Voronoi ; //---------------------------------------------------------------------------- class CurveBezier : public ICurveBezier, public IGeoObjRW @@ -131,7 +131,6 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW bool TrimEndAtLen( double dLenTrim) override ; bool ExtendStartByLen( double dLenExt) override ; bool ExtendEndByLen( double dLenExt) override ; - Voronoi* GetVoronoiObject( void) const override ; public : // ICurveBezier bool CopyFrom( const IGeoObj* pGObjSrc) override ; @@ -165,6 +164,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW return *this ; } bool ApproxWithLines( int nStep, PolyLine& PL) const ; bool GetApproxLength( double& dLen) const ; + Voronoi* GetVoronoiObject( void) const ; private : bool CopyFrom( const CurveBezier& cbSrc) ; diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 1990f14..823a89c 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -26,6 +26,7 @@ #include "GeoObjFactory.h" #include "NgeWriter.h" #include "NgeReader.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkCurveByApprox.h" #include "/EgtDev/Include/EGkArcSpecial.h" #include "/EgtDev/Include/EGkSfrCreate.h" diff --git a/CurveComposite.h b/CurveComposite.h index 3eb7546..a5b7f95 100644 --- a/CurveComposite.h +++ b/CurveComposite.h @@ -19,9 +19,10 @@ #include "DllMain.h" #include "GeoObjRW.h" #include "/EgtDev/Include/EGkCurveComposite.h" -#include "/EgtDev/Include/EGkVoronoi.h" #include +class Voronoi ; + //---------------------------------------------------------------------------- class CurveComposite : public ICurveComposite, public IGeoObjRW { @@ -126,7 +127,6 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW bool TrimEndAtLen( double dLenTrim) override ; bool ExtendStartByLen( double dLenExt) override ; bool ExtendEndByLen( double dLenExt) override ; - Voronoi* GetVoronoiObject( void) const override ; public : // ICurveComposite bool CopyFrom( const IGeoObj* pGObjSrc) override ; @@ -194,6 +194,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW return *this ; } bool RelocateFrom( CurveComposite& ccSrc) ; bool GetApproxLength( double& dLen) const ; + Voronoi* GetVoronoiObject( void) const ; private : bool CopyFrom( const CurveComposite& ccSrc) ; diff --git a/CurveLine.cpp b/CurveLine.cpp index 8050e48..92e78a2 100644 --- a/CurveLine.cpp +++ b/CurveLine.cpp @@ -18,6 +18,7 @@ #include "GeoObjFactory.h" #include "NgeWriter.h" #include "NgeReader.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EgtNumUtils.h" #include "/EgtDev/Include/EgtPointerOwner.h" diff --git a/CurveLine.h b/CurveLine.h index 73e5860..e7d5de0 100644 --- a/CurveLine.h +++ b/CurveLine.h @@ -18,7 +18,8 @@ #include "DllMain.h" #include "GeoObjRW.h" #include "/EgtDev/Include/EGkCurveLine.h" -#include "/EgtDev/Include/EGkVoronoi.h" + +class Voronoi ; //---------------------------------------------------------------------------- class CurveLine : public ICurveLine, public IGeoObjRW @@ -130,7 +131,6 @@ class CurveLine : public ICurveLine, public IGeoObjRW bool TrimEndAtLen( double dLenTrim) override ; bool ExtendStartByLen( double dLenExt) override ; bool ExtendEndByLen( double dLenExt) override ; - Voronoi* GetVoronoiObject( void) const override ; public : // ICurveLine bool CopyFrom( const IGeoObj* pGObjSrc) override ; @@ -157,6 +157,7 @@ class CurveLine : public ICurveLine, public IGeoObjRW { if ( ! CopyFrom( clSrc)) LOG_ERROR( GetEGkLogger(), "CurveLine : copy error") return *this ; } + Voronoi* GetVoronoiObject( void) const ; private : bool CopyFrom( const CurveLine& clSrc) ; diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index f895a8ec332d7d0ad4593c643cfc06d999a1ef48..790e9c0fc05d731d8cff79e8dc5f54e6f8c8f39f 100644 GIT binary patch delta 94 zcmdlNy)SyhFE&P_&A-_cnHh~HD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-Vf-5U delta 94 zcmdlNy)SyhFE&QQ&A-_cnHdcyD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-U|t&X diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj index 48dc5a0..8c884bb 100644 --- a/EgtGeomKernel.vcxproj +++ b/EgtGeomKernel.vcxproj @@ -109,7 +109,7 @@ Use Level3 Disabled - WIN32;_WINDOWS;I_AM_EGK;NVRONI;_DEBUG;%(PreprocessorDefinitions) + WIN32;_WINDOWS;I_AM_EGK;_DEBUG;%(PreprocessorDefinitions) false CompileAsCpp false @@ -145,7 +145,7 @@ copy $(TargetPath) \EgtProg\DllD32 Use Level3 Disabled - WIN32;_WINDOWS;I_AM_EGK;NVRONI;_DEBUG;%(PreprocessorDefinitions) + WIN32;_WINDOWS;I_AM_EGK;_DEBUG;%(PreprocessorDefinitions) false CompileAsCpp false @@ -183,7 +183,7 @@ copy $(TargetPath) \EgtProg\DllD64 MaxSpeed true true - WIN32;_WINDOWS;I_AM_EGK;NVRONI;NDEBUG;%(PreprocessorDefinitions) + WIN32;_WINDOWS;I_AM_EGK;NDEBUG;%(PreprocessorDefinitions) false CompileAsCpp Speed @@ -232,7 +232,7 @@ copy $(TargetPath) \EgtProg\Dll32 MaxSpeed true true - WIN32;_WINDOWS;I_AM_EGK;NVRONI;NDEBUG;%(PreprocessorDefinitions) + WIN32;_WINDOWS;I_AM_EGK;NDEBUG;%(PreprocessorDefinitions) false CompileAsCpp Speed @@ -449,6 +449,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters index 1f8e8f8..c24cae1 100644 --- a/EgtGeomKernel.vcxproj.filters +++ b/EgtGeomKernel.vcxproj.filters @@ -1166,6 +1166,9 @@ File di intestazione\Include + + File di intestazione + diff --git a/OffsetCurve.cpp b/OffsetCurve.cpp index 17de301..c4e0128 100644 --- a/OffsetCurve.cpp +++ b/OffsetCurve.cpp @@ -21,6 +21,7 @@ #include "CurveComposite.h" #include "RemoveCurveDefects.h" #include "OffsetAux.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkOffsetCurve.h" #include "/EgtDev/Include/EGkIntersCurves.h" #include "/EgtDev/Include/EGkDistPointCurve.h" @@ -66,11 +67,7 @@ OffsetCurve::Reset( void) bool OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) { - // imposto metodo di calcolo - bool bUseVoronoi = false ; - #ifdef _VRONI - bUseVoronoi = true ; - #endif // _VRONI + // metodo di calcolo impostato da USE_VORONOI // pulisco tutto Reset() ; @@ -168,7 +165,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) bool bChangeStart = true ; // -------------------- OFFSET STANDARD --------------------------------- - if ( ! bUseVoronoi) { + if ( ! USE_VORONOI) { // verifico che la curva sia fatta solo da rette e archi che giacciono nel piano XY (VtExtr è ora Z+) if ( ! ccCopy.ArcsBezierCurvesToArcsPerpExtr( m_dLinTol, ANG_TOL_STD_DEG)) @@ -692,7 +689,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) if ( bNeedRef || bNeedScale) voronoiObj = ccCopy.GetVoronoiObject() ; else - voronoiObj = pCrv->GetVoronoiObject() ; + voronoiObj = GetCurveVoronoi( *pCrv) ; if ( voronoiObj == nullptr) return false ; @@ -733,10 +730,13 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) pCrv->ToGlob( frCopy) ; } - // assegno estrusione e spessore come curva originale + // assegno estrusione e spessore come curva originale e unisco parti allineate for ( auto pCrv : m_CrvLst) { pCrv->SetExtrusion( vtExtr) ; pCrv->SetThickness( dThick) ; + // unisco eventuali parti allineate (tranne gli estremi) + if ( pCrv->GetType() == CRV_COMPO) + GetBasicCurveComposite( pCrv)->MergeCurves( 10 * EPS_SMALL, ANG_TOL_STD_DEG, false) ; } // ordino le curve in ordine decrescente di lunghezza diff --git a/SfrCreate.cpp b/SfrCreate.cpp index 107c53c..e84ece2 100644 --- a/SfrCreate.cpp +++ b/SfrCreate.cpp @@ -19,6 +19,7 @@ #include "SurfFlatRegion.h" #include "AdjustLoops.h" #include "GeoConst.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkBiArcs.h" #include "/EgtDev/Include/EGkOffsetCurve.h" @@ -116,11 +117,7 @@ GetSurfFlatRegionDisk( double dRadius) ISurfFlatRegion* GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, bool bSquareMids, double dOffsLinTol) { - // imposto metodo di calcolo - bool bUseVoronoi = false ; - #ifdef _VRONI - bUseVoronoi = true ; - #endif // _VRONI + // metodo di calcolo impostato da USE_VORONOI // mi impossesso della curva PtrOwner pCurve( pCrv) ; @@ -132,7 +129,7 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b vtExtr = Z_AX ; // ----------------- CALCOLO STANDARD -------------------------------- - if ( ! bUseVoronoi) { + if ( ! USE_VORONOI) { PtrOwner pCompo1 ; if ( ! pCompo1.Set( ConvertCurveToBasicComposite( Release( pCurve)))) return nullptr ; diff --git a/StmFromCurves.cpp b/StmFromCurves.cpp index 974683e..c6385f2 100644 --- a/StmFromCurves.cpp +++ b/StmFromCurves.cpp @@ -18,6 +18,7 @@ #include "CurveArc.h" #include "CurveComposite.h" #include "SurfTriMesh.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkOffsetCurve.h" #include "/EgtDev/Include/EGkStmFromCurves.h" #include "/EgtDev/Include/EGkStmFromTriangleSoup.h" @@ -440,11 +441,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide, static ISurfTriMesh* GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol) { - // imposto metodo di calcolo - bool bUseVoronoi = false ; - #ifdef _VRONI - bUseVoronoi = true ; - #endif // _VRONI + // metodo di calcolo impostato da USE_VORONOI // verifico che la linea guida sia piana Plane3d plGuide ; @@ -463,7 +460,7 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub OffsetCurve vOffsCrv[NUM_OFFS] ; double vDist[NUM_OFFS] = { dDimH / 2 - dBevelH, -dDimH / 2 + dBevelH, dDimH / 2, -dDimH / 2} ; bool bOk = true ; - if ( ! bUseVoronoi) { + if ( ! USE_VORONOI) { future vRes[NUM_OFFS] ; for ( int i = 0 ; i < NUM_OFFS ; ++ i) vRes[i] = async( launch::async, &OffsetCurve::Make, &vOffsCrv[i], pGuide, vDist[i], ICurve::OFF_FILLET) ; diff --git a/SurfFlatRegion.cpp b/SurfFlatRegion.cpp index a250754..7c0095d 100644 --- a/SurfFlatRegion.cpp +++ b/SurfFlatRegion.cpp @@ -22,6 +22,7 @@ #include "CurveLine.h" #include "AdjustLoops.h" #include "GeoConst.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkUiUnits.h" #include "/EgtDev/Include/EGkIntervals.h" @@ -1439,21 +1440,6 @@ SurfFlatRegion::CalcVoronoiObject() const return true ; } -//---------------------------------------------------------------------------- -Voronoi* -SurfFlatRegion::GetVoronoiObject() const -{ - if ( m_nStatus != OK) - return nullptr ; - - // se non è stato calcolato, lo calcolo - if ( m_pVoronoiObj == nullptr) - CalcVoronoiObject() ; - - // restituisco Voronoi - return m_pVoronoiObj ; -} - //---------------------------------------------------------------------------- void SurfFlatRegion::ResetVoronoiObject() const diff --git a/SurfFlatRegion.h b/SurfFlatRegion.h index 794e755..dcfb642 100644 --- a/SurfFlatRegion.h +++ b/SurfFlatRegion.h @@ -22,6 +22,8 @@ #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include +class Voronoi ; + //---------------------------------------------------------------------------- class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW { @@ -101,8 +103,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW 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 - Voronoi* GetVoronoiObject( void) const override ; - bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = VORONOI_STD_BOUND) const override ; + bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = 3) const override ; bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const override ; public : // IGeoObjRW diff --git a/SurfFlatRegionOffset.cpp b/SurfFlatRegionOffset.cpp index c1e47cb..cda1912 100644 --- a/SurfFlatRegionOffset.cpp +++ b/SurfFlatRegionOffset.cpp @@ -16,6 +16,7 @@ #include "GeoConst.h" #include "CurveComposite.h" #include "SurfFlatRegion.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkOffsetCurve.h" #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -28,11 +29,7 @@ SurfFlatRegion::CreateOffsetSurf( double dDist, int nType) const { // restituisce la superficie offsettata senza modificare la superficie corrente. In caso di errore restituisce nullptr - // imposto metodo di calcolo - bool bUseVoronoi = false ; - #ifdef _VRONI - bUseVoronoi = true ; - #endif // _VRONI + // metodo di calcolo impostato da USE_VORONOI // recupero il numero dei chunk int nChunk = GetChunkCount() ; @@ -49,7 +46,7 @@ SurfFlatRegion::CreateOffsetSurf( double dDist, int nType) const return nullptr ; // -------------------- OFFSET STANDARD ------------------------------------- - if ( ! bUseVoronoi) { + if ( ! USE_VORONOI) { bool bFirstRegion = true ; // ciclo sui chunk for ( int i = 0 ; i < nChunk ; ++ i) { diff --git a/Voronoi.cpp b/Voronoi.cpp index b0db98e..8e54cba 100644 --- a/Voronoi.cpp +++ b/Voronoi.cpp @@ -18,7 +18,7 @@ #include "SurfFlatRegion.h" #include "OffsetAux.h" #include "RemoveCurveDefects.h" -#include "/EgtDev/Include/EGkVoronoi.h" +#include "Voronoi.h" #include "/EgtDev/Include/EGkDistPointCurve.h" using namespace std ; diff --git a/Voronoi.h b/Voronoi.h new file mode 100644 index 0000000..180520d --- /dev/null +++ b/Voronoi.h @@ -0,0 +1,85 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2023 +//---------------------------------------------------------------------------- +// File : Voronoi.h Data : 23.11.23 Versione : 2.5k5 +// Contenuto : Dichiarazione della classe Voronoi con libreria VRONI +// +// +// +// Modifiche : 23.11.23 SP Creazione modulo. + +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkFrame3d.h" +#include "/EgtDev/Include/EGkCurve.h" +#include "/EgtDev/Include/EGkCurveArc.h" +#include "/EgtDev/Include/EGkCurveBezier.h" +#include "/EgtDev/Include/EGkCurveComposite.h" +#include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Extern/vroni/Include/vroni_object.h" + +//---------------------------------------------------------------------------- +static const bool USE_VORONOI = false ; +static const int VORONOI_STD_BOUND = 3 ; +static const double VRONI_OFFS_TOL = 1e-14 ; + +//-------------------------- Forward Definitions ------------------------------- +class ISurfFlatRegion ; + +//---------------------------------------------------------------------------- +class Voronoi +{ + public : + // costanti per il lato del medial axis + enum WMATSide { WMAT_BOTHSIDES = 0, + WMAT_LEFT = 1, + WMAT_RIGHT = 2} ; + public : + Voronoi( void) + : m_vroni( nullptr), m_nBound( VORONOI_STD_BOUND), m_bVDComputed( false), m_bAllowAdd( true) {} ; + Voronoi( const ICurve* pCrv, bool bAllowAdd) ; + Voronoi( const ISurfFlatRegion* pSfr, bool bAllowAdd) ; + ~Voronoi( void) ; + + public : + bool AddCurve( const ICurve* pCrv) ; + bool AddSurfFlatRegion( const ISurfFlatRegion* pSfr) ; + ICurve* GetCurve( int nId) const ; + int GetCurveCount( void) const + { return m_vpCrvs.size() ; } ; + bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = VORONOI_STD_BOUND) ; + bool CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType) ; + bool CalcFatCurve( ICURVEPOVECTOR& vOffs, double dOffs, bool bSquareEnds, bool bSquareMids) ; + bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) ; + + private : + bool Clear( void) ; + bool IsValid( void) const + { return m_vroni != nullptr ; } ; + bool AddCurveToVroni( const ICurve * pCrv) ; + bool AddLineToVroni( const ICurveLine* pLine, int& nVroniCrv, int nLoopId, int nCrvId = 0, Point3d ptForcedEnd = P_INVALID) ; + bool AddArcToVroni( const ICurveArc* pArc, int& nVroniCrv, int nLoopId, int nCrvId = 0, Point3d ptForcedEnd = P_INVALID) ; + bool AddCompoToVroni( const ICurveComposite* pCompo, int& nCrv, int nLoopId) ; + bool AddBezierToVroni( const ICurveBezier* pBezier, int& nVroniCrv, int nLoopId) ; + + bool CalcVoronoi( int nBound = VORONOI_STD_BOUND) ; + bool CalcVroniOffset( ICRVCOMPOPLIST& vOffs, double dOffs, bool bRightOffs, bool bLeftOffs) ; + bool UpdateVoronoi( double dOffs) ; + bool VerifyCurvesValidityForOffset( void) ; + bool AdjustOpenOffsetCurve( ICurveComposite& pCompo, double dOffs) ; + bool AdjustOffsetStart( ICurveComposite& pCompo) ; + int GetOffsetCurveSide( const ICurveComposite& pOffs, int nCrv) ; + ICurve* GetBisectorCurve( int i) ; + + private : + vroniObject* m_vroni ; // oggetto base della libreria vroni + Frame3d m_Frame ; // frame in cui è espresso l'oggetto vroni + int m_nBound ; // bound associato al diagramma di Voronoi corrente + CICURVEPVECTOR m_vpCrvs ; // curve associate al Voronoi ( espresse rispetto a m_Frame) + BBox3d m_bBox ; // box degli oggetti associati al Voronoi + bool m_bVDComputed ; // indica se il diagramma di Voronoi è stato calcolato + bool m_bAllowAdd ; // indica se possibile aggiungere altre curve/superifici dopo aver creato l'oggetto Voronoi +} ;