From 6b6b30437fec5d65a84612add1df898e509ca2cb Mon Sep 17 00:00:00 2001 From: LorenzoM Date: Wed, 21 Jul 2021 09:31:46 +0200 Subject: [PATCH] Modifiche varie --- EgtGeomKernel.vcxproj | 7 +++++ EgtGeomKernel.vcxproj.filters | 21 +++++++++++++ PolyLine.cpp | 2 ++ SurfTriMeshBooleans.cpp | 28 +++++++++-------- Tool.h | 2 +- Triangulate.cpp | 57 ++++++++++++++++++++++++++++++++--- Triangulate.h | 14 +++++++-- VolZmap.h | 2 +- VolZmapVolume.cpp | 2 +- 9 files changed, 112 insertions(+), 23 deletions(-) diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj index d8284cb..c3ea478 100644 --- a/EgtGeomKernel.vcxproj +++ b/EgtGeomKernel.vcxproj @@ -397,6 +397,8 @@ copy $(TargetPath) \EgtProg\Dll64 + + @@ -560,6 +562,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -607,6 +610,10 @@ copy $(TargetPath) \EgtProg\Dll64 + + + + diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters index c1175ce..1510977 100644 --- a/EgtGeomKernel.vcxproj.filters +++ b/EgtGeomKernel.vcxproj.filters @@ -453,6 +453,12 @@ File di origine\GeoCollision + + File di origine + + + File di origine + @@ -1076,6 +1082,21 @@ File di intestazione + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + diff --git a/PolyLine.cpp b/PolyLine.cpp index c941d65..8b83385 100644 --- a/PolyLine.cpp +++ b/PolyLine.cpp @@ -19,9 +19,11 @@ #include "PolygonPlane.h" #include "PointsPCA.h" #include "GeoConst.h" +#include "/EgtDev/Include/EGkPolygon3d.h" #include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkPlane3d.h" #include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGtNumUtils.h" using namespace std ; diff --git a/SurfTriMeshBooleans.cpp b/SurfTriMeshBooleans.cpp index c4ec162..6db28fb 100644 --- a/SurfTriMeshBooleans.cpp +++ b/SurfTriMeshBooleans.cpp @@ -33,6 +33,7 @@ #include "/EgtDev/Include/EGkGeoCollection.h" #include "/EgtDev/Include/EGkPolygon3d.h" #include "/EgtDev/Include/EgtPerfCounter.h" +#include "/EgtDev/Include/EgtNumUtils.h" #include "/EgtDev/Include/EgnStringUtils.h" #include @@ -3418,17 +3419,17 @@ AddPolyLineToPolyLine( PolyLine& Poly, PolyLine& PolyToAdd) return true ; } -//---------------------------------------------------------------------------- -struct PositionOnPolyLine { - int nIndexInVec ; - int nSegNum ; - double dParOnSeg ; - PositionOnPolyLine( int nIndex, int nSeg, double dPar) { - nIndexInVec = nIndex ; - nSegNum = nSeg ; - dParOnSeg = dPar ; - } -} ; +////---------------------------------------------------------------------------- +//struct PositionOnPolyLine { +// int nIndexInVec ; +// int nSegNum ; +// double dParOnSeg ; +// PositionOnPolyLine( int nIndex, int nSeg, double dPar) { +// nIndexInVec = nIndex ; +// nSegNum = nSeg ; +// dParOnSeg = dPar ; +// } +//} ; //---------------------------------------------------------------------------- bool @@ -3931,8 +3932,9 @@ SurfTriMesh::SplitFacet( const INTERSCHAINMAP& IntersLineMap, PieceMap& NewFacet if ( vNewPieces[nPieceN].vPieceLoop[0].IsPointInsidePolyLine( ptInnP) || ( itInnNext != LoopList.end() && vNewPieces[nPieceN].vPieceLoop[0].IsPointInsidePolyLine( 0.5 * ( ptInnP + ptInnNextP)))) { double dPieceArea ; - vNewPieces[nPieceN].vPieceLoop[0].IsClosedAndFlat( Plane3d(), dPieceArea) ; - if ( vNewPieces[nPieceN].vPieceLoop[0].IsClosedAndFlat( Plane3d(), dPieceArea) && dPieceArea < dIncluderPieceArea) { + Plane3d plMyFictitiousPlane ; + vNewPieces[nPieceN].vPieceLoop[0].IsClosedAndFlat( plMyFictitiousPlane, dPieceArea) ; + if ( vNewPieces[nPieceN].vPieceLoop[0].IsClosedAndFlat( plMyFictitiousPlane, dPieceArea) && dPieceArea < dIncluderPieceArea) { nIncluderPiece = nPieceN ; Polygon3d AuxPolygon ; AuxPolygon.FromPolyLine( CurInnerLoop) ; diff --git a/Tool.h b/Tool.h index 1fda871..d96a5c5 100644 --- a/Tool.h +++ b/Tool.h @@ -16,7 +16,7 @@ #include "CurveComposite.h" //---------------------------------------------------------------------------- -class Tool +class Tool { public : Tool( bool bApproxWithLines = false) ; diff --git a/Triangulate.cpp b/Triangulate.cpp index 905844a..92835e2 100644 --- a/Triangulate.cpp +++ b/Triangulate.cpp @@ -12,17 +12,34 @@ //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- +//#include "stdafx.h" +//#include "DllMain.h" +//#include "Triangulate.h" +//#include "ProjPlane.h" +//#include "/EgtDev/Include/EGkPolyLine.h" +//#include "/EgtDev/Include/EGkPlane3d.h" +//#include "/EgtDev/Include/EGkStringUtils3d.h" +//#include #include "stdafx.h" #include "DllMain.h" #include "Triangulate.h" #include "ProjPlane.h" +#include "CurveComposite.h" +#include "CurveLine.h" +#include "/EgtDev/Include/EGkIntersCurves.h" +#include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkPlane3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h" +#include "tpp_interface.hpp" + #include using namespace std ; +using namespace tpp ; + + //---------------------------------------------------------------------------- enum EarStatus{ EAS_NULL = -1, EAS_NO = 0, EAS_OK = 1} ; @@ -35,13 +52,17 @@ static bool ChangeStartPntVector( int nNewStart, PNTVECTOR& vPi) ; // INTVECTOR (int Vector) : 3*T indices of above points for T triangles //---------------------------------------------------------------------------- bool -Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) +Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType) { // verifico che la polilinea sia chiusa e piana e calcolo il piano medio del poligono double dArea ; Plane3d plPlane ; if ( ! PL.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)) return false ; + + if ( trgType != TRG_STANDARD) + return Make( POLYLINEVECTOR{ PL}, vPt, vTr, trgType) ; + // determino il piano ottimale di proiezione e il relativo senso di rotazione bool bCCW ; if ( ! CalcProjPlane( plPlane.GetVersN(), m_nPlane, bCCW)) @@ -82,12 +103,13 @@ Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) //---------------------------------------------------------------------------- // In : POLYLINEVECTOR : vector of polylines, the first outer, the others inner +// trgType : triangulation type // Out : PNTVECTOR (Point3d Vector) : points of the polyline // INTVECTOR (int Vector) : 3*T indices of above points for T triangles //---------------------------------------------------------------------------- bool -Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) -{ +Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType) +{ // pulisco i vettori di ritorno vPt.clear() ; vTr.clear() ; @@ -95,7 +117,7 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) if ( &vPL == nullptr || vPL.empty()) return false ; // se una sola polilinea mi riconduco al caso precedente - if ( vPL.size() == 1) + if ( vPL.size() == 1 && trgType == TRG_STANDARD) return Make( vPL[0], vPt, vTr) ; // verifico che la polilinea esterna sia chiusa e piana e calcolo il piano medio del poligono double dArea ; @@ -115,6 +137,31 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ! AreOppositeVectorApprox( plExtPlane.GetVersN(), plPlane.GetVersN())) return false ; } + + // triangolazione Delaunay + if ( trgType == TRG_DEL_CONFORMING) { + if ( ! MakeByDelaunay( vPL, vPt, vTr, true, true)) { + LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( conforming)") ; + return false ; + } + return true ; + } + else if ( trgType == TRG_DEL_QUALITY) { + if ( ! MakeByDelaunay( vPL, vPt, vTr, false, true)) { + LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( quality)") ; + return false ; + } + return true ; + } + else if ( trgType == TRG_DEL_NOQUALITY) { + if ( ! MakeByDelaunay( vPL, vPt, vTr, false, false)) { + LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( no quality)") ; + return false ; + } + return true ; + } + + // ear clipping // se non CCW inverto tutte le polilinee if ( ! bCCW) { for ( int i = 0 ; i < int( vPL.size()) ; ++i) @@ -172,7 +219,7 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) INTVECTOR vPol ; int n = int( vPt.size()) ; vPol.reserve( n) ; - // non devo gestire separatamente CCW perch� ho gi� invertito i punti + // non devo gestire separatamente CCW perch� ho gi� invertito i punti for ( int i = 0 ; i < n ; ++ i) vPol.push_back( i) ; diff --git a/Triangulate.h b/Triangulate.h index c95549a..a20fa86 100644 --- a/Triangulate.h +++ b/Triangulate.h @@ -16,12 +16,19 @@ #include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkPointGrid3d.h" +// +enum TrgType { TRG_STANDARD, // ear clipping + TRG_DEL_CONFORMING, // conforming constrained Delaunay ( with quality constraint) + TRG_DEL_QUALITY, // constrained Delaunay with quality constraints ( no angle smaller than 20 degrees) + TRG_DEL_NOQUALITY // constrained Delaunay without quality constraints + } ; + //---------------------------------------------------------------------------- class Triangulate { public : - bool Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) ; - bool Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ; + bool Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType = TRG_STANDARD) ; + bool Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType = TRG_STANDARD) ; private : bool PrepareGrid( const PNTVECTOR& vPt, const INTVECTOR& vPol, @@ -29,6 +36,7 @@ class Triangulate bool MakeByEC( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ; bool MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ; bool MakeByEC3( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ; + bool MakeByDelaunay( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, bool bConforming, bool bQuality) ; bool TestTriangle( const PNTVECTOR& vPt, const INTVECTOR& vPol, const INTVECTOR& vPrev, INTVECTOR& vNext, int i) ; double CalcTriangleAspectRatio( const Point3d& ptPa, const Point3d& ptPb, const Point3d& ptPc) ; @@ -50,3 +58,5 @@ class Triangulate PointGrid3d m_VertGrid ; INTVECTOR m_vVert ; } ; + + diff --git a/VolZmap.h b/VolZmap.h index e1ecc99..29b2d21 100644 --- a/VolZmap.h +++ b/VolZmap.h @@ -311,7 +311,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool SurfCyl_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dRad, bool bOuterCutter, bool bTapB, bool bTapT) ; bool SurfCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, double dHei, double dRad, bool bTapB, bool bTapT) ; + const Vector3d& vtToolDir, double dHei, double dRad, bool bOuterCutter, bool bTapB, bool bTapT) ; bool SurfConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR) ; bool SurfConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, diff --git a/VolZmapVolume.cpp b/VolZmapVolume.cpp index 84383ba..90044a2 100644 --- a/VolZmapVolume.cpp +++ b/VolZmapVolume.cpp @@ -5206,7 +5206,7 @@ VolZmap::SurfCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, for ( int i = nStartI ; i <= nEndI ; ++ i) { for ( int j = nStartJ ; j <= nEndJ ; ++ j) { - Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0) ; + Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0.) ; vector> vParAndNormIntersVec ; Point3d ptInt1, ptInt2 ;