EgtGeomKernel :

- correzione bug di triangolazione bezier.
This commit is contained in:
Daniele Bariletti
2024-07-15 10:04:48 +02:00
parent 7a67ce9333
commit 649f97e933
2 changed files with 17 additions and 12 deletions
+15 -11
View File
@@ -3049,10 +3049,13 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX
case 2 : ptNextVert = ptBL ; break ;
case 3 : ptNextVert = ptBr ; break ;
}
while ( plCell.GetNextPoint( ptToAdd) && ! AreSamePointExact( ptToAdd, ptNextVert)) {
vEdgeVertex[j].push_back( ptToAdd) ;
if ( bForTriangulation) {
plCell3d.GetNextPoint( pt3d) ;
if ( ! bForTriangulation) {
while ( plCell.GetNextPoint( ptToAdd) && ! AreSamePointExact( ptToAdd, ptNextVert))
vEdgeVertex[j].push_back( ptToAdd) ;
}
else {
while ( plCell.GetNextPoint( ptToAdd) && plCell3d.GetNextPoint( pt3d) && ! AreSamePointExact( ptToAdd, ptNextVert)) {
vEdgeVertex[j].push_back( ptToAdd) ;
vEdgeVertex3d[j].push_back( pt3d) ;
}
}
@@ -3090,7 +3093,7 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX
nFirstLoopInPoly = j ;
}
for ( Point3d ptInt : inA.vpt) {
AddVertex( nId, vEdgeVertex, vEdgeVertex3d, plTrimmedPoly, c, ptInt, plTrimmedPoly3d) ;
AddVertex( nId, vEdgeVertex, vEdgeVertex3d, plTrimmedPoly, c, ptInt, plTrimmedPoly3d, bForTriangulation) ;
}
vAddedLoops.push_back( j) ;
nEdge = inA.nOut ;
@@ -3182,7 +3185,7 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX
ptVert = ptBr ;
else if ( nEdge == 3)
ptVert = ptTR ;
AddVertex( nId, vEdgeVertex, vEdgeVertex3d, plTrimmedPoly, c, ptVert, plTrimmedPoly3d) ;
AddVertex( nId, vEdgeVertex, vEdgeVertex3d, plTrimmedPoly, c, ptVert, plTrimmedPoly3d, bForTriangulation) ;
if ( nEdge > 3 && nEdge != 7)
nEdge = nEdge - 4 ;
else if ( nEdge < 3)
@@ -3202,6 +3205,7 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX
for ( int p = 1 ; p < (int) vEdgeVertex[nEdge].size() ; ++ p) {
if ( CheckIfBefore( nEdge, vEdgeVertex[nEdge][p], m_mTree[nId].m_vInters[vToCheckNow[nNext]].vpt[0])) {
plTrimmedPoly.AddUPoint( c, vEdgeVertex[nEdge][p]) ;
plTrimmedPoly3d.AddUPoint( c, vEdgeVertex3d[nEdge][p]) ;
++ c ;
}
}
@@ -3215,6 +3219,7 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX
for ( int p = 1 ; p < (int) vEdgeVertex[nEdge].size() ; ++ p) {
if ( CheckIfBefore( nEdge, vEdgeVertex[nEdge][p], ptStart)) {
plTrimmedPoly.AddUPoint( c, vEdgeVertex[nEdge][p]) ;
plTrimmedPoly3d.AddUPoint( c, vEdgeVertex3d[nEdge][p]) ;
++ c ;
}
}
@@ -3236,7 +3241,7 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX
ptVert = ptBr ;
else if ( nEdge == 3)
ptVert = ptTR ;
AddVertex( nId, vEdgeVertex, vEdgeVertex3d, plTrimmedPoly, c, ptVert, plTrimmedPoly3d) ;
AddVertex( nId, vEdgeVertex, vEdgeVertex3d, plTrimmedPoly, c, ptVert, plTrimmedPoly3d, bForTriangulation) ;
if ( nEdge > 3 && nEdge != 7)
nEdge = nEdge - 4 ;
else if ( nEdge < 3)
@@ -3249,6 +3254,7 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX
for ( int p = 1 ; p < (int) vEdgeVertex[nEdge].size() ; ++ p) {
if ( CheckIfBefore( nEdge, vEdgeVertex[nEdge][p], ptStart)) {
plTrimmedPoly.AddUPoint( c, vEdgeVertex[nEdge][p]) ;
plTrimmedPoly3d.AddUPoint( c, vEdgeVertex3d[nEdge][p]) ;
++ c ;
}
}
@@ -3579,11 +3585,9 @@ Tree::AreSameEdge( int nEdge1, int nEdge2) const
//----------------------------------------------------------------------------
bool
Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVertex3d, PolyLine& plTrimmedPoly, int& c, const Point3d& ptToAdd, PolyLine& plTrimmedPoly3d) const
Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVertex3d, PolyLine& plTrimmedPoly, int& c,
const Point3d& ptToAdd, PolyLine& plTrimmedPoly3d, bool bForTriangulation) const
{
//capisco se sono in modalità ForTriangulation
bool bForTriangulation = plTrimmedPoly3d.GetPointNbr() ;
// se è il primo punto della PolyLine lo aggiungo
if ( plTrimmedPoly.GetPointNbr() == 0) {
plTrimmedPoly.AddUPoint( c, ptToAdd) ;