diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj
index 961ea5e..59f799a 100644
--- a/EgtGeomKernel.vcxproj
+++ b/EgtGeomKernel.vcxproj
@@ -114,6 +114,7 @@
true
ProgramDatabase
false
+ \EgtDev\Extern\GeometricToolsEngine
Windows
@@ -195,6 +196,7 @@ copy $(TargetPath) \EgtProg\DllD64
true
false
ProgramDatabase
+ \EgtDev\Extern\GeometricToolsEngine
Windows
@@ -397,6 +399,8 @@ copy $(TargetPath) \EgtProg\Dll64
+
+
@@ -560,6 +564,7 @@ copy $(TargetPath) \EgtProg\Dll64
+
@@ -607,6 +612,10 @@ copy $(TargetPath) \EgtProg\Dll64
+
+
+
+
diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters
index c1175ce..22ea494 100644
--- a/EgtGeomKernel.vcxproj.filters
+++ b/EgtGeomKernel.vcxproj.filters
@@ -46,6 +46,12 @@
{865b76ee-b10d-41fc-861c-b48ce52fa277}
+
+ {9596e38a-8880-4ab5-bd65-e1db39c92ac5}
+
+
+ {636e60fa-4b24-4a7b-b2e9-74e1c1e8fb31}
+
@@ -453,6 +459,12 @@
File di origine\GeoCollision
+
+ File di origine\tpp
+
+
+ File di origine\tpp
+
@@ -1076,6 +1088,21 @@
File di intestazione
+
+ File di intestazione\tpp
+
+
+ File di intestazione\tpp
+
+
+ File di intestazione\tpp
+
+
+ File di intestazione\tpp
+
+
+ File di intestazione\tpp
+
diff --git a/PolyLine.cpp b/PolyLine.cpp
index 88c31ca..8848f6a 100644
--- a/PolyLine.cpp
+++ b/PolyLine.cpp
@@ -22,6 +22,8 @@
#include "/EgtDev/Include/EGkPolyLine.h"
#include "/EgtDev/Include/EGkPlane3d.h"
#include "/EgtDev/Include/EGnStringUtils.h"
+#include "/EgtDev/Include/EgtNumUtils.h"
+#include "/EgtDev/Include/EGkPolygon3d.h"
using namespace std ;
@@ -1296,3 +1298,326 @@ PolyLine::Trim( const Plane3d& plPlane, bool bInVsOut)
return true ;
}
+
+
+//----------------------------------------------------------------------------
+/*static*/ bool
+ChangePolyLineStart( const Point3d& ptNewStart, PolyLine& Loop, double dTol)
+{
+ // Rinomino la lista di punti della PolyLine.
+ PNTULIST& LoopList = Loop.GetUPointList() ;
+ // Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
+ double dMinSqDist = DBL_MAX ;
+ auto itMinDist = LoopList.end() ;
+ auto itSt = LoopList.begin() ;
+ auto itEn = itSt ;
+ ++ itEn ;
+ for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) {
+ // Estremi del segmento corrente del loop
+ Point3d ptSegSt = itSt->first ;
+ Point3d ptSegEn = itEn->first ;
+ // Distanza del punto dal segmento del loop
+ DistPointLine dDistCalc( ptNewStart, ptSegSt, ptSegEn) ;
+ double dSqDist ;
+ dDistCalc.GetSqDist( dSqDist) ;
+ if ( dSqDist < dMinSqDist) {
+ dMinSqDist = dSqDist ;
+ itMinDist = itSt ;
+ }
+ }
+ // Se il punto non sta sul loop, errore
+ if ( dMinSqDist > dTol * dTol)
+ return false ;
+ // Se il punto non sta su un vertice del segmento, lo aggiungo. Altrimenti non devo fare nulla.
+ auto itNewPointSt = LoopList.begin() ;
+ auto itNext = itMinDist ;
+ ++ itNext ;
+ bool bOnStart = AreSamePointApprox( ptNewStart, itMinDist->first) ;
+ bool bOnEnd = AreSamePointApprox( ptNewStart, itNext->first) ;
+ itNewPointSt = LoopList.emplace( itNext, ptNewStart, 0) ;
+ // Sposto i punti precedenti in coda.
+ bool bStartRemoved = false ;
+ auto it = LoopList.begin() ;
+ while ( it != itNewPointSt) {
+ if ( bStartRemoved) {
+ LoopList.emplace_back( it->first, it->second) ;
+ }
+ bStartRemoved = true ;
+ it = LoopList.erase( it) ;
+ }
+ // Se il punto inserito non coincide con l'inizio del segmento chiudo il loop.
+ if ( ! bOnStart) {
+ LoopList.emplace_back( ptNewStart, 0) ;
+ // Se coincide con la fine tolgo il punto di fine che diviene inutile.
+ if ( bOnEnd) {
+ //LoopList.erase( itNext) ;
+ auto itNewStart = LoopList.begin() ;
+ ++ itNewStart ;
+ LoopList.erase( itNewStart) ;
+ }
+ }
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+// nSegNum 0-based
+/*static*/ bool
+PointPositionOnPolyLine( const Point3d& ptPoint, /*const*/ PolyLine& Loop, int& nSegNum, double& dParOnSeg, double dTol)
+{
+ // Rinomino la lista di punti della PolyLine.
+ /*const*/ PNTULIST& LoopList = Loop.GetUPointList() ;
+ // Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
+ nSegNum = - 1 ;
+ double dMinSqDist = DBL_MAX ;
+ int nS = 0 ;
+ auto itMinDistSt = LoopList.end() ;
+ auto itMinDistEn = itMinDistSt ;
+ auto itSt = LoopList.begin() ;
+ auto itEn = itSt ;
+ ++ itEn ;
+ for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn, ++ nS) {
+ // Estremi del segmento corrente del loop
+ Point3d ptSegSt = itSt->first ;
+ Point3d ptSegEn = itEn->first ;
+ // Distanza del punto dal segmento del loop
+ DistPointLine dDistCalc( ptPoint, ptSegSt, ptSegEn) ;
+ double dSqDist ;
+ dDistCalc.GetSqDist( dSqDist) ;
+ if ( dSqDist < dMinSqDist) {
+ nSegNum = nS ;
+ dMinSqDist = dSqDist ;
+ itMinDistSt = itSt ;
+ itMinDistEn = itEn ;
+ }
+ }
+ // Se il punto non sta sul loop, lo segnalo.
+ if ( dMinSqDist > dTol * dTol)
+ return false ;
+ // Calcolo il parametro lungo il segmento.
+ Vector3d vtSeg = itMinDistEn->first - itMinDistSt->first ;
+ double dSegLen = vtSeg.Len() ;
+ if ( dSegLen < EPS_SMALL)
+ return false ;
+ vtSeg /= dSegLen ;
+ dParOnSeg = Clamp( ( ptPoint - itMinDistSt->first) * vtSeg, 0., dSegLen) ;
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+/*static*/ bool
+IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly)
+{
+ // Se la PolyLine non è chiusa, il punto non può essere interno.
+ if ( ! plPoly.IsClosed())
+ return false ;
+ // Lista dei punti
+ PolyLine& MyPlPoly = const_cast< PolyLine&>( plPoly) ;
+ const PNTULIST& List = MyPlPoly.GetUPointList() ;
+ // Ciclo sui segmenti della PolyLine per cercarne il tratto più vicino al punto.
+ double dMinSqDist = DBL_MAX ;
+ Point3d ptMinDist ;
+ auto itMinDistSt = List.end() ;
+ auto itSt = List.begin() ;
+ auto itEn = itSt ;
+ ++ itEn ;
+ for ( ; itSt != List.end() && itEn != List.end() ; ++ itSt, ++ itEn) {
+ // Estremi del segmento corrente del loop
+ Point3d ptSegSt = itSt->first ;
+ Point3d ptSegEn = itEn->first ;
+ // Distanza del punto dal segmento del loop
+ DistPointLine dDistCalc( ptP, ptSegSt, ptSegEn) ;
+ double dSqDist ;
+ dDistCalc.GetSqDist( dSqDist) ;
+ if ( dSqDist < dMinSqDist) {
+ dMinSqDist = dSqDist ;
+ dDistCalc.GetMinDistPoint( ptMinDist) ;
+ itMinDistSt = itSt ;
+ }
+ }
+ // Termine del segmento di minima distanza.
+ auto itMinDistEn = itMinDistSt ;
+ ++ itMinDistEn ;
+ // Punto di minima distanza nell'estremo iniziale del segento
+ if ( AreSamePointApprox( ptMinDist, itMinDistSt->first)) {
+ auto itPrevSt = List.begin() ;
+ if ( itMinDistSt == List.begin()) {
+ auto itAuxNext = itPrevSt ;
+ ++ ( ++ itAuxNext) ;
+ for ( ; itAuxNext != List.end() ; ++ itPrevSt, ++ itAuxNext)
+ ;
+ }
+ else {
+ auto itAuxNext = itPrevSt ;
+ ++ itAuxNext ;
+ for (; itAuxNext != itMinDistSt; ++itPrevSt, ++itAuxNext)
+ ;
+ }
+ Vector3d vtPrevTan = itMinDistSt->first - itPrevSt->first ;
+ vtPrevTan.Normalize() ;
+ Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ;
+ vtTan.Normalize() ;
+ Polygon3d AuxPolygon ;
+ AuxPolygon.FromPolyLine( plPoly) ;
+ Vector3d vtPolyNorm = AuxPolygon.GetVersN() ;
+ Vector3d vtPrevOut = vtPrevTan ^ vtPolyNorm ;
+ Vector3d vtOut = vtTan ^ vtPolyNorm ;
+ // Caso concavo
+ if ( vtTan * vtPrevOut > 0) {
+ Vector3d vtTest = ptP - ptMinDist ;
+ if ( vtTest * vtPrevOut < 0 || vtTest * vtOut < 0)
+ return true ;
+ }
+ // Caso convesso
+ else {
+ Vector3d vtTest = ptP - ptMinDist ;
+ if ( vtTest * vtPrevOut < 0 && vtTest * vtOut < 0)
+ return true ;
+ }
+ }
+ // Punto di minima distanza nell'estremo finale del segento
+ else if ( AreSamePointApprox( ptMinDist, itMinDistEn->first)) {
+ auto itNextEn = itMinDistEn ;
+ ++ itNextEn ;
+ if ( itNextEn == List.end()) {
+ itNextEn = List.begin() ;
+ ++ itNextEn ;
+ }
+ Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ;
+ vtTan.Normalize() ;
+ Vector3d vtNextTan = itNextEn->first - itMinDistEn->first ;
+ vtNextTan.Normalize() ;
+ Polygon3d AuxPolygon ;
+ AuxPolygon.FromPolyLine( plPoly) ;
+ Vector3d vtPolyNorm = AuxPolygon.GetVersN() ;
+ Vector3d vtOut = vtTan ^ vtPolyNorm ;
+ Vector3d vtNextOut = vtNextTan ^ vtPolyNorm ;
+ // Caso concavo
+ if ( vtNextTan * vtOut > 0) {
+ Vector3d vtTest = ptP - ptMinDist ;
+ if ( vtTest * vtOut < 0 || vtTest * vtNextOut < 0)
+ return true ;
+ }
+ // Caso convesso
+ else {
+ Vector3d vtTest = ptP - ptMinDist ;
+ if ( vtTest * vtOut < 0 && vtTest * vtNextOut < 0)
+ return true ;
+ }
+ }
+ // Punto di minima distanza interno al segmeno
+ else {
+ Vector3d vtP = ptP - itMinDistSt->first ;
+ Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ;
+ vtTan.Normalize() ;
+ Polygon3d AuxPolygon ;
+ AuxPolygon.FromPolyLine( plPoly) ;
+ Vector3d vtPolyNorm = AuxPolygon.GetVersN() ;
+ Vector3d vtOut = vtTan ^ vtPolyNorm ;
+ vtP -= ( vtP * vtTan) * vtTan ;
+ if ( vtP * vtOut < - EPS_SMALL)
+ return true ;
+ }
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dPointPolyLineDist)
+{
+ if ( plPoly.GetPointNbr() == 0)
+ return false ;
+ dPointPolyLineDist = DBL_MAX ;
+ Point3d ptSt, ptEn ;
+ bool bContinue = plPoly.GetFirstPoint( ptSt) && plPoly.GetNextPoint( ptEn) ;
+ while ( bContinue) {
+ double dPoinLineDist ;
+ DistPointLine PointLineDistCalc( ptP, ptSt, ptEn) ;
+ PointLineDistCalc.GetDist( dPoinLineDist) ;
+ if ( dPoinLineDist < dPointPolyLineDist)
+ dPointPolyLineDist = dPoinLineDist ;
+ ptSt = ptEn ;
+ bContinue = plPoly.GetNextPoint( ptEn) ;
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+/*static*/ bool
+SplitPolyLineAtPoint( const Point3d& ptPoint, /*const*/ PolyLine& Loop, PolyLine& Loop1, PolyLine& Loop2, double dTol)
+{
+ // Rinomino la lista di punti della PolyLine.
+ /*const*/ PNTULIST& LoopList = Loop.GetUPointList() ;
+ // Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
+ double dMinSqDist = DBL_MAX ;
+ auto itMinDistSt = LoopList.end() ;
+ auto itSt = LoopList.begin() ;
+ auto itEn = itSt ;
+ ++ itEn ;
+ for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) {
+ // Estremi del segmento corrente del loop
+ Point3d ptSegSt = itSt->first ;
+ Point3d ptSegEn = itEn->first ;
+ // Distanza del punto dal segmento del loop
+ DistPointLine dDistCalc( ptPoint, ptSegSt, ptSegEn) ;
+ double dSqDist ;
+ dDistCalc.GetSqDist( dSqDist) ;
+ if ( dSqDist < dMinSqDist) {
+ dMinSqDist = dSqDist ;
+ itMinDistSt = itSt ;
+ }
+ }
+ // Se il punto non sta sul loop, lo segnalo.
+ if ( dMinSqDist > dTol * dTol)
+ return false ;
+ // Se il punto di stop sta su un vertice non devo aggiungerlo e il
+ // punto di stop sarà uno degli estremi del segmento su cui giace.
+ auto itStop = itMinDistSt ;
+ auto itNext = itMinDistSt ;
+ ++ itNext ;
+ if ( AreSamePointApprox( ptPoint, itStop->first))
+ ;
+ else if ( AreSamePointApprox( ptPoint, itNext->first))
+ itStop = itNext ;
+ else {
+ itStop = LoopList.emplace( itNext, ptPoint, 0.) ;
+ }
+ // Creo i due loop
+ PNTULIST& LoopList1 = Loop1.GetUPointList() ;
+ PNTULIST& LoopList2 = Loop2.GetUPointList() ;
+ for ( auto it = LoopList.begin() ; it != itStop ; ++ it) {
+ LoopList1.emplace_back( it->first, it->second) ;
+ }
+ LoopList1.emplace_back( itStop->first, itStop->second) ;
+ for ( auto it = itStop ; it != LoopList.end() ; ++ it) {
+ LoopList2.emplace_back( it->first, it->second) ;
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+/*static*/ bool
+AddPolyLineToPolyLine( PolyLine& Poly, PolyLine& PolyToAdd, double dTol)
+{
+ // Se la PolyLine a cui devo aggiungere l'altra è chiusa, non posso aggiungere nulla.
+ if ( Poly.IsClosed())
+ return false ;
+ // Se la PolyLina che devo aggiungere è vuota, ho finito.
+ PNTULIST& PolyToAddList = PolyToAdd.GetUPointList() ;
+ if ( int( PolyToAddList.size()) == 0)
+ return true ;
+ // Se Poly non è vuota e la sua fine non coincide con l'inizio di PolyToAdd, non è possibile aggiungere nulla.
+ Point3d ptLast ;
+ Poly.GetLastPoint( ptLast) ;
+ auto it = PolyToAddList.begin() ;
+ if ( Poly.GetPointNbr() != 0 && ! AreSamePointEpsilon( it->first, ptLast, dTol))
+ return false ;
+ /*if ( Poly.GetPointNbr() == 0)
+ Poly.AddUPoint( 0., it->first) ;
+ ++ it ;*/
+ // Aggiungo i punti.
+ for ( ; it != PolyToAddList.end() ; ++ it) {
+ Poly.AddUPoint( 0., it->first) ;
+ }
+ return true ;
+}
diff --git a/SurfTriMeshBooleans.cpp b/SurfTriMeshBooleans.cpp
index 0377b79..121dbe9 100644
--- a/SurfTriMeshBooleans.cpp
+++ b/SurfTriMeshBooleans.cpp
@@ -2804,66 +2804,6 @@ SurfTriMesh::IntersFacetFacet( const SurfFlatRegion& RegionA, const PolyLine& Ex
// return bOk ;
//}
-//----------------------------------------------------------------------------
-static bool
-ChangePolyLineStart( const Point3d& ptNewStart, PolyLine& Loop)
-{
- // Rinomino la lista di punti della PolyLine.
- PNTULIST& LoopList = Loop.GetUPointList() ;
- // Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
- double dMinSqDist = DBL_MAX ;
- auto itMinDist = LoopList.end() ;
- auto itSt = LoopList.begin() ;
- auto itEn = itSt ;
- ++ itEn ;
- for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) {
- // Estremi del segmento corrente del loop
- Point3d ptSegSt = itSt->first ;
- Point3d ptSegEn = itEn->first ;
- // Distanza del punto dal segmento del loop
- DistPointLine dDistCalc( ptNewStart, ptSegSt, ptSegEn) ;
- double dSqDist ;
- dDistCalc.GetSqDist( dSqDist) ;
- if ( dSqDist < dMinSqDist) {
- dMinSqDist = dSqDist ;
- itMinDist = itSt ;
- }
- }
- // Se il punto non sta sul loop, errore
- if ( dMinSqDist > 100 * SQ_EPS_SMALL)
- return false ;
- // Se il punto non sta su un vertice del segmento, lo aggiungo. Altrimenti non devo fare nulla.
- auto itNewPointSt = LoopList.begin() ;
- auto itNext = itMinDist ;
- ++ itNext ;
- bool bOnStart = AreSamePointApprox( ptNewStart, itMinDist->first) ;
- bool bOnEnd = AreSamePointApprox( ptNewStart, itNext->first) ;
- itNewPointSt = LoopList.emplace( itNext, ptNewStart, 0) ;
- // Sposto i punti precedenti in coda.
- bool bStartRemoved = false ;
- auto it = LoopList.begin() ;
- while ( it != itNewPointSt) {
- if ( bStartRemoved) {
- LoopList.emplace_back( it->first, it->second) ;
- }
- bStartRemoved = true ;
- it = LoopList.erase( it) ;
- }
- // Se il punto inserito non coincide con l'inizio del segmento chiudo il loop.
- if ( ! bOnStart) {
- LoopList.emplace_back( ptNewStart, 0) ;
- // Se coincide con la fine tolgo il punto di fine che diviene inutile.
- if ( bOnEnd) {
- //LoopList.erase( itNext) ;
- auto itNewStart = LoopList.begin() ;
- ++ itNewStart ;
- LoopList.erase( itNewStart) ;
- }
- }
-
- return true ;
-}
-
//----------------------------------------------------------------------------
// nSegNum 0-based
static bool
@@ -3024,27 +2964,6 @@ IsPointInsidePolyLine( const Point3d& ptP, /*const*/ PolyLine& plPoly)
return false ;
}
-//----------------------------------------------------------------------------
-bool
-DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dPointPolyLineDist)
-{
- if ( plPoly.GetPointNbr() == 0)
- return false ;
- dPointPolyLineDist = DBL_MAX ;
- Point3d ptSt, ptEn ;
- bool bContinue = plPoly.GetFirstPoint( ptSt) && plPoly.GetNextPoint( ptEn) ;
- while ( bContinue) {
- double dPoinLineDist ;
- DistPointLine PointLineDistCalc( ptP, ptSt, ptEn) ;
- PointLineDistCalc.GetDist( dPoinLineDist) ;
- if ( dPoinLineDist < dPointPolyLineDist)
- dPointPolyLineDist = dPoinLineDist ;
- ptSt = ptEn ;
- bContinue = plPoly.GetNextPoint( ptEn) ;
- }
- return true ;
-}
-
//----------------------------------------------------------------------------
// Una faccia di una trimesh ha una sola componente connessa.
// Si assume che i loop siano corretti e rispettino tale proprietà.
@@ -3088,98 +3007,6 @@ DistPointFacet( const Point3d& ptP, /*const*/ POLYLINEVECTOR& vPolyVec, double&
return true ;
}
-//----------------------------------------------------------------------------
-static bool
-SplitPolyLineAtPoint( const Point3d& ptPoint, /*const*/ PolyLine& Loop, PolyLine& Loop1, PolyLine& Loop2)
-{
- // Rinomino la lista di punti della PolyLine.
- /*const*/ PNTULIST& LoopList = Loop.GetUPointList() ;
- // Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
- double dMinSqDist = DBL_MAX ;
- auto itMinDistSt = LoopList.end() ;
- auto itSt = LoopList.begin() ;
- auto itEn = itSt ;
- ++ itEn ;
- for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) {
- // Estremi del segmento corrente del loop
- Point3d ptSegSt = itSt->first ;
- Point3d ptSegEn = itEn->first ;
- // Distanza del punto dal segmento del loop
- DistPointLine dDistCalc( ptPoint, ptSegSt, ptSegEn) ;
- double dSqDist ;
- dDistCalc.GetSqDist( dSqDist) ;
- if ( dSqDist < dMinSqDist) {
- dMinSqDist = dSqDist ;
- itMinDistSt = itSt ;
- }
- }
- // Se il punto non sta sul loop, lo segnalo.
- if ( dMinSqDist > 100 * SQ_EPS_SMALL)
- return false ;
- // Se il punto di stop sta su un vertice non devo aggiungerlo e il
- // punto di stop sarà uno degli estremi del segmento su cui giace.
- auto itStop = itMinDistSt ;
- auto itNext = itMinDistSt ;
- ++ itNext ;
- if ( AreSamePointApprox( ptPoint, itStop->first))
- ;
- else if ( AreSamePointApprox( ptPoint, itNext->first))
- itStop = itNext ;
- else {
- itStop = LoopList.emplace( itNext, ptPoint, 0.) ;
- }
- // Creo i due loop
- PNTULIST& LoopList1 = Loop1.GetUPointList() ;
- PNTULIST& LoopList2 = Loop2.GetUPointList() ;
- for ( auto it = LoopList.begin() ; it != itStop ; ++ it) {
- LoopList1.emplace_back( it->first, it->second) ;
- }
- LoopList1.emplace_back( itStop->first, itStop->second) ;
- for ( auto it = itStop ; it != LoopList.end() ; ++ it) {
- LoopList2.emplace_back( it->first, it->second) ;
- }
- return true ;
-}
-
-//----------------------------------------------------------------------------
-static bool
-AddPolyLineToPolyLine( PolyLine& Poly, PolyLine& PolyToAdd)
-{
- // Se la PolyLine a cui devo aggiungere l'altra è chiusa, non posso aggiungere nulla.
- if ( Poly.IsClosed())
- return false ;
- // Se la PolyLina che devo aggiungere è vuota, ho finito.
- PNTULIST& PolyToAddList = PolyToAdd.GetUPointList() ;
- if ( int( PolyToAddList.size()) == 0)
- return true ;
- // Se Poly non è vuota e la sua fine non coincide con l'inizio di PolyToAdd, non è possibile aggiungere nulla.
- Point3d ptLast ;
- Poly.GetLastPoint( ptLast) ;
- auto it = PolyToAddList.begin() ;
- if ( Poly.GetPointNbr() != 0 && ! AreSamePointEpsilon( it->first, ptLast, 10 * EPS_SMALL))
- return false ;
- /*if ( Poly.GetPointNbr() == 0)
- Poly.AddUPoint( 0., it->first) ;
- ++ it ;*/
- // Aggiungo i punti.
- for ( ; it != PolyToAddList.end() ; ++ it) {
- Poly.AddUPoint( 0., it->first) ;
- }
- return true ;
-}
-
-//----------------------------------------------------------------------------
-struct PositionOnPolyLine {
- int nIndexInVec ;
- int nSegNum ;
- double dParOnSeg ;
- PositionOnPolyLine( int nIndex, int nSeg, double dPar) {
- nIndexInVec = nIndex ;
- nSegNum = nSeg ;
- dParOnSeg = dPar ;
- }
-} ;
-
//----------------------------------------------------------------------------
bool
SurfTriMesh::SplitFacet( const INTERSCHAINMAP& IntersLineMap, PieceMap& NewFacet)
diff --git a/Triangulate.cpp b/Triangulate.cpp
index 2a8dba3..f03b97a 100644
--- a/Triangulate.cpp
+++ b/Triangulate.cpp
@@ -16,12 +16,18 @@
#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 "Mathematics/TriangulateCDT.h"
#include
+#include "tpp_interface.hpp"
+
using namespace std ;
using namespace tpp ;
using namespace gte ;
@@ -38,18 +44,22 @@ 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
+ // 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 ;
- // determino il piano ottimale di proiezione e il relativo senso di rotazione
+
+ 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))
return false ;
- // riempio il vettore con i vertici del poligono da triangolare
+ // riempio il vettore con i vertici del poligono da triangolare
vPt.clear() ;
vPt.reserve( PL.GetPointNbr() - 1) ;
// salto il primo punto (coincide con l'ultimo)
@@ -59,24 +69,24 @@ Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr)
// inserisco i punti
while ( PL.GetNextPoint( ptP))
vPt.push_back( ptP) ;
- // se non CCW inverto il vettore dei punti
+ // se non CCW inverto il vettore dei punti
if ( ! bCCW)
reverse( vPt.begin(), vPt.end()) ;
- // creo il vettore degli indici del Poligono
+ // creo il vettore degli indici del Poligono
INTVECTOR vPol ;
int n = int( vPt.size()) ;
vPol.reserve( n) ;
for ( int i = 0 ; i < n ; ++ i)
vPol.push_back( i) ;
- // eseguo la triangolazione
+ // eseguo la triangolazione
if ( ! MakeByEC2( vPt, vPol, vTr) &&
- ! MakeByEC3( vPt, vPol, vTr)) {
+ ! MakeByEC3( vPt, vPol, vTr)) {
LOG_ERROR( GetEGkLogger(), "Error in MakeByEC23(1)")
- return false ;
+ return false ;
}
- // se era CW, devo invertire il senso dei triangoli
+ // se era CW, devo invertire il senso dei triangoli
if ( ! bCCW)
reverse( vTr.begin(), vTr.end()) ;
@@ -89,7 +99,7 @@ Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr)
// 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() ;
diff --git a/Triangulate.h b/Triangulate.h
index 99714ef..cce6d13 100644
--- a/Triangulate.h
+++ b/Triangulate.h
@@ -28,8 +28,8 @@ enum TrgType { TRG_STANDARD, // ear clipping
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,