diff --git a/Tree.cpp b/Tree.cpp index 227a65f..69ab52a 100644 --- a/Tree.cpp +++ b/Tree.cpp @@ -2956,8 +2956,9 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX vEdgeVertex3d[2].push_back( m_mVert[nId][0]) ; vEdgeVertex3d[3].push_back( m_mVert[nId][1]) ; // la PolyLine รจ riempita a partire dal lato bottom - Point3d ptStart ; + Point3d ptStart, pt3d ; plCell.GetFirstPoint( ptStart) ; + plCell3d.GetFirstPoint( pt3d) ; INTVECTOR vEdge = { 2, 3, 0, 1} ; for ( int p = 0 ; p < 4 ; ++ p) { int j = vEdge[p] ; @@ -2965,8 +2966,9 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX if ( j == 3) next = 0 ; Point3d ptToAdd ; - while ( plCell.GetNextPoint( ptToAdd) && ! AreSamePointExact( ptToAdd, vEdgeVertex[next][0])) { + while ( plCell.GetNextPoint( ptToAdd) && plCell3d.GetNextPoint( pt3d) && ! AreSamePointExact( ptToAdd, vEdgeVertex[next][0])) { vEdgeVertex[j].push_back( ptToAdd) ; + vEdgeVertex3d[j].push_back( pt3d) ; } } @@ -3581,7 +3583,7 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe // se su un edge devo fare dei controlli // edge 0 if ( ptToAdd.x >= ptBL.x && ptToAdd.x <= ptTR.x && ptToAdd.y == ptTR.y && abs( vDir.x) > 1 - EPS_SMALL) { - for ( int t = 0 ; t < (int)vEdgeVertex[0].size() ; ++ t) { + for ( int t = 1 ; t < (int)vEdgeVertex[0].size() ; ++ t) { Point3d ptIntermed = vEdgeVertex[0][t] ; if ( ptIntermed.x > ptToAdd.x && ptIntermed.x < ptLast.x) { plTrimmedPoly.AddUPoint( c, ptIntermed) ; @@ -3590,13 +3592,17 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe } } plTrimmedPoly.AddUPoint( c, ptToAdd) ; - Point3d pt3d ; m_pSrfBz->GetPointD1D2( ptToAdd.x / SBZ_TREG_COEFF, ptToAdd.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; + Point3d pt3d ; + if( ! AreSamePointApprox(ptToAdd, vEdgeVertex[1][0])) + m_pSrfBz->GetPointD1D2( ptToAdd.x / SBZ_TREG_COEFF, ptToAdd.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; + else + pt3d = vEdgeVertex3d[1][0] ; plTrimmedPoly3d.AddUPoint( c, pt3d) ; ++ c ; } // edge 1 else if ( ptToAdd.y >= ptBL.y && ptToAdd.y <= ptTR.y && ptToAdd.x == ptBL.x && abs( vDir.y) > 1 - EPS_SMALL) { - for ( int t = 0 ; t < (int)vEdgeVertex[1].size() ; ++ t) { + for ( int t = 1 ; t < (int)vEdgeVertex[1].size() ; ++ t) { Point3d ptIntermed = vEdgeVertex[1][t] ; if ( ptIntermed.y > ptToAdd.y && ptIntermed.y < ptLast.y) { plTrimmedPoly.AddUPoint( c, ptIntermed) ; @@ -3605,13 +3611,17 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe } } plTrimmedPoly.AddUPoint( c, ptToAdd) ; - Point3d pt3d ; m_pSrfBz->GetPointD1D2( ptToAdd.x / SBZ_TREG_COEFF, ptToAdd.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; + Point3d pt3d ; + if( ! AreSamePointApprox(ptToAdd, vEdgeVertex[2][0])) + m_pSrfBz->GetPointD1D2( ptToAdd.x / SBZ_TREG_COEFF, ptToAdd.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; + else + pt3d = vEdgeVertex3d[2][0] ; plTrimmedPoly3d.AddUPoint( c, pt3d) ; ++ c ; } // edge 2 else if ( ptToAdd.x >= ptBL.x && ptToAdd.x <= ptTR.x && ptToAdd.y == ptBL.y && abs( vDir.x) > 1 - EPS_SMALL) { - for ( int t = 0 ; t < (int)vEdgeVertex[2].size() ; ++ t) { + for ( int t = 1 ; t < (int)vEdgeVertex[2].size() ; ++ t) { Point3d ptIntermed = vEdgeVertex[2][t] ; if ( ptIntermed.x < ptToAdd.x && ptIntermed.x > ptLast.x) { plTrimmedPoly.AddUPoint( c, ptIntermed) ; @@ -3620,13 +3630,17 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe } } plTrimmedPoly.AddUPoint( c, ptToAdd) ; - Point3d pt3d ; m_pSrfBz->GetPointD1D2( ptToAdd.x / SBZ_TREG_COEFF, ptToAdd.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; + Point3d pt3d ; + if( ! AreSamePointApprox(ptToAdd, vEdgeVertex[3][0])) + m_pSrfBz->GetPointD1D2( ptToAdd.x / SBZ_TREG_COEFF, ptToAdd.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; + else + pt3d = vEdgeVertex3d[3][0] ; plTrimmedPoly3d.AddUPoint( c, pt3d) ; ++ c ; } // edge 3 else if ( ptToAdd.y >= ptBL.y && ptToAdd.y <= ptTR.y && ptToAdd.x == ptTR.x && abs( vDir.y) > 1 - EPS_SMALL) { - for ( int t = 0 ; t < (int)vEdgeVertex[3].size() ; ++ t) { + for ( int t = 1 ; t < (int)vEdgeVertex[3].size() ; ++ t) { Point3d ptIntermed = vEdgeVertex[3][t] ; if ( ptIntermed.y < ptToAdd.y && ptIntermed.y > ptLast.y) { plTrimmedPoly.AddUPoint( c, ptIntermed) ; @@ -3635,7 +3649,11 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe } } plTrimmedPoly.AddUPoint( c, ptToAdd) ; - Point3d pt3d ; m_pSrfBz->GetPointD1D2( ptToAdd.x / SBZ_TREG_COEFF, ptToAdd.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; + Point3d pt3d ; + if( ! AreSamePointApprox(ptToAdd, vEdgeVertex[0][0])) + m_pSrfBz->GetPointD1D2( ptToAdd.x / SBZ_TREG_COEFF, ptToAdd.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; + else + pt3d = vEdgeVertex3d[0][0] ; plTrimmedPoly3d.AddUPoint( c, pt3d) ; ++ c ; }