diff --git a/SurfBezier.cpp b/SurfBezier.cpp index 003195c..d9c6b61 100644 --- a/SurfBezier.cpp +++ b/SurfBezier.cpp @@ -1607,9 +1607,7 @@ SurfBezier::GetApproxSurf( double dTol, double dSideMin) const bool bMismatch2D3D = vPnt.size() != vPnt3d.size() ; bool bTriangulatedIn3D = false ; PNTVECTOR vPnt2d ; - if ( bTriangulationFailedIn2D || (bMismatch2D3D && vPnt.size() != nTotPnt)) { - PNTVECTOR vPntBackup ; - vPntBackup = vPnt ; + if ( bTriangulationFailedIn2D) { if ( ! Tri.Make( vPL3d, vPnt, vTria)) return nullptr ; bool bTriangulationSucceded = ( vPnt.size() - 2 ) == ( vTria.size() ) / 3 ; @@ -1619,10 +1617,17 @@ SurfBezier::GetApproxSurf( double dTol, double dSideMin) const else LOG_INFO( GetEGkLogger(), "Info : Last problem in MakeByEC23(1) is the same as the previous one") } - if( ! bTriangulationSucceded) - vPnt = vPntBackup ; - else if( bTriangulationSucceded) { + if( bTriangulationSucceded) { bTriangulatedIn3D = true ; + // calcolo la normale della polyline per flippare eventualmente i triangoli se hanno la normale sbagliata + PolyLine& pl3d = vPL3d[0] ; + Plane3d plPlane ; double dArea = 0 ; + pl3d.IsClosedAndFlat( plPlane, dArea) ; + Vector3d vtN = plPlane.GetVersN() ; + Triangle3d tria ; + tria.Set( vPnt[vTria[0]], vPnt[vTria[1]], vPnt[vTria[2]]) ; + if( tria.GetN() * vtN < 0) + reverse( vTria.begin(), vTria.end()) ; for( int i = 0 ; i < int( vPL.size()) ; ++i) { PolyLine& pl = vPL[i] ; Point3d pt ; pl.GetFirstPoint( pt) ; @@ -1634,67 +1639,25 @@ SurfBezier::GetApproxSurf( double dTol, double dSideMin) const } } - // controllo se devo riordinare il vettore dei punti - // se le polyline sono state invertite o ne è stato cambiato il punto di start - int nCurrPoint = 0 ; - for( int i = 0 ; i < int( vPL.size()) ; ++i) { - if( ! bTriangulatedIn3D) { - Point3d pt ; vPL[i].GetFirstPoint( pt) ; - vPL[i].GetNextPoint( pt) ; - int nPoints = vPL[i].GetPointNbr() - 2 ; - if ( AreSamePointApprox( vPnt[nCurrPoint], pt)) - continue ; - else if ( AreSamePointApprox( vPnt[nCurrPoint + nPoints], pt)) - reverse( vPnt3d.begin() + nCurrPoint, vPnt3d.begin() + nCurrPoint + nPoints) ; - else { - // se la polyline non è stata semplicemente invertita allora vuol dire che ne è stato cambiato lo start point - // in questo caso il punto di chiusura non è stato eliminato - nPoints += 2 ; - vPL[i].GetPrevPoint( pt) ; - int nPoints = vPL[i].GetPointNbr() - 1 ; - for ( int j = 0 ; j < nPoints ; ++j ) { - if ( AreSamePointApprox( vPnt[nCurrPoint + j], pt)) { - rotate( vPnt3d.begin() + nCurrPoint, vPnt3d.begin() + nCurrPoint + nPoints - j - 1, vPnt3d.begin() + nCurrPoint + nPoints) ; - vPnt3d.insert( vPnt3d.begin() + nCurrPoint + nPoints, vPnt3d[nCurrPoint]) ; - break ; - } - } - } - nCurrPoint += nPoints ; + // riordino il vettore dei punti su cui non ho fatto la triangolazione + if( int(vPL.size()) > 1 || bTriangulatedIn3D) { + //if( vPnt.size() != vPnt3d.size()) + // return nullptr ; + PNTVECTOR vPntOrd ; + if( bTriangulatedIn3D) { + ReorderPntVector( vPL3d, true, vPnt, vPL, vPntOrd) ; + vPnt3d = vPnt ; + vPnt = vPntOrd ; } else { - Point3d pt ; vPL3d[i].GetFirstPoint( pt) ; - vPL3d[i].GetNextPoint( pt) ; - int nPoints = vPL3d[i].GetPointNbr() - 2 ; - if ( AreSamePointApprox( vPnt[nCurrPoint], pt)) - continue ; - else if ( AreSamePointApprox( vPnt[nCurrPoint + nPoints], pt)) - reverse( vPnt2d.begin() + nCurrPoint, vPnt2d.begin() + nCurrPoint + nPoints) ; - else { - // se la polyline non è stata semplicemente invertita allora vuol dire che ne è stato cambiato lo start point - // in questo caso il punto di chiusura non è stato eliminato - nPoints += 2 ; - vPL3d[i].GetPrevPoint( pt) ; - int nPoints = vPL3d[i].GetPointNbr() - 1 ; - for ( int j = 0 ; j < nPoints ; ++j ) { - if ( AreSamePointApprox( vPnt[nCurrPoint + j], pt)) { - rotate( vPnt2d.begin() + nCurrPoint, vPnt2d.begin() + nCurrPoint + nPoints - j - 1, vPnt2d.begin() + nCurrPoint + nPoints) ; - vPnt2d.insert( vPnt2d.begin() + nCurrPoint + nPoints, vPnt2d[nCurrPoint]) ; - break ; - } - } - } - nCurrPoint += nPoints ; + ReorderPntVector( vPL, false, vPnt, vPL3d, vPntOrd) ; + vPnt3d = vPntOrd ; } } - if ( bTriangulatedIn3D) { - vPnt3d = vPnt ; - vPnt = vPnt2d ; - } //controllo che i due vettori vPnt e vPnt3d abbiano la stessa lunghezza, sennò vuol dire che nel vettore vPnt3d ho avuto dei Rejected e devo ricalcolarli // i punti in eccesso verranno poi scartati dalla trimesh - if( vPnt.size() != vPnt3d.size() && ! bTriangulatedIn3D) { + if( vPnt.size() != vPnt3d.size()) { vPnt3d.clear() ; for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) { Point3d pt3d ; @@ -1722,6 +1685,90 @@ SurfBezier::GetApproxSurf( double dTol, double dSideMin) const return GetBasicSurfTriMesh( stmSoup.GetSurf()) ; } +//---------------------------------------------------------------------------- +bool +SurfBezier::ReorderPntVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D, const PNTVECTOR& vPnt, const POLYLINEVECTOR& vPLToOrd, PNTVECTOR& vPntOrd) const +{ + int nCurrPoint = 0 ; + BOOLVECTOR vbPolyChecked( vPL.size()) ; + fill( vbPolyChecked.begin(), vbPolyChecked.end(), false) ; + for ( int p = 0 ; p < int(vPnt.size()) ; ++p) { + Point3d pt = vPnt[p] ; + int nInd = 0 ; + int nPoly = 0 ; + int nPoints = 0 ; + bool bInverted = false ; + for ( int poly = 0 ; poly < int( vPL.size()) ; ++poly ) { + if( vbPolyChecked[poly]) + continue ; + PolyLine pl = vPL[poly] ; + nInd = 0 ; + Point3d ptPoly ; pl.GetFirstPoint( ptPoly) ; + bool bFound = false ; + if( AreSamePointStepApprox( pt, ptPoly)){ + nPoints = pl.GetPointNbr() ; + nPoly = poly ; + bFound = true ; + pl.GetNextPoint( ptPoly) ; + if( ! AreSamePointStepApprox( vPnt[p+1], ptPoly)) + bInverted = true ; + break ; + } + while ( pl.GetNextPoint( ptPoly) && ! bFound) { + ++ nInd ; + if( AreSamePointStepApprox( pt, ptPoly)) { + nPoints = pl.GetPointNbr() ; + nPoly = poly ; + bFound = true ; + pl.GetNextPoint( ptPoly) ; + if( ! AreSamePointStepApprox( vPnt[p+1], ptPoly)) + bInverted = true ; + break ; + } + } + if( bFound) + break ; + } + if( nInd == 0) { + Point3d ptPoly ; + vPLToOrd[nPoly].GetFirstPoint( ptPoly) ; + vPntOrd.push_back( ptPoly) ; + while ( vPLToOrd[nPoly].GetNextPoint( ptPoly)) + vPntOrd.push_back( ptPoly) ; + } + else if ( nInd == nPoints - 1 ) { + Point3d ptPoly ; + vPLToOrd[nPoly].GetLastPoint( ptPoly) ; + vPntOrd.push_back( ptPoly) ; + while ( vPLToOrd[nPoly].GetPrevPoint( ptPoly)) + vPntOrd.push_back( ptPoly) ; + } + else { + PNTVECTOR vPntToRotate ; + Point3d ptPoly ; + if( ! bInverted) { + vPLToOrd[nPoly].GetFirstPoint( ptPoly) ; + vPntToRotate.push_back( ptPoly) ; + while ( vPLToOrd[nPoly].GetNextPoint( ptPoly)) + vPntToRotate.push_back( ptPoly) ; + } + else { + vPLToOrd[nPoly].GetLastPoint( ptPoly) ; + vPntToRotate.push_back( ptPoly) ; + while ( vPLToOrd[nPoly].GetPrevPoint( ptPoly)) + vPntToRotate.push_back( ptPoly) ; + } + vPntToRotate.pop_back() ; + rotate( vPntToRotate.begin(), vPntToRotate.begin() + nInd, vPntToRotate.end()) ; + vPntToRotate.push_back( vPntToRotate[0]) ; + vPntOrd.insert( vPntOrd.end(), vPntToRotate.begin(), vPntToRotate.end()) ; + } + vbPolyChecked[nPoly] = true ; + p += nPoints - 1; + } + return true ; +} + //---------------------------------------------------------------------------- bool SurfBezier::GetLeaves( vector>& vLeaves) const diff --git a/SurfBezier.h b/SurfBezier.h index 9285813..32fc6e2 100644 --- a/SurfBezier.h +++ b/SurfBezier.h @@ -203,6 +203,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW // funzione che calcola se gli edge sono collassati in poli bool CalcPoles( void) const ; bool FindMatchByParam( const PolyLine& pl0, const PolyLine& pl1, INTVECTOR& vMatch, int& nLong) const ; + bool ReorderPntVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D, const PNTVECTOR& vPnt, const POLYLINEVECTOR& vPLToOrd, PNTVECTOR& vPntOrd) const ; private : ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto diff --git a/Tree.cpp b/Tree.cpp index 3fe6235..0273ea6 100644 --- a/Tree.cpp +++ b/Tree.cpp @@ -206,8 +206,8 @@ Tree::SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches, const Point3d& ptMi // creo la cella Root Point3d ptTop( nSpanU * SBZ_TREG_COEFF, nSpanV * SBZ_TREG_COEFF) ; bool bLimited = false ; - if ( ! AreSamePointExact( ptMax,ORIG)) { - if ( ! AreSamePointExact( ptMax,ptTop)) + if ( ! AreSamePointXYExact( ptMax,ORIG)) { + if ( ! AreSamePointXYExact( ptMax,ptTop)) ptTop = ptMax ; bLimited = true ; } @@ -455,7 +455,7 @@ AddOrMergeBBox( const BBox3d& bBox3dA, vector& vBBox, bool bAdd = true, BBox3d bBox3dB = vBBox[b] ; BBox3d b3Int ; // se sono celle diverse e ho un'intersezione faccio il merge - if ( ! ( AreSamePointExact( ptMin, bBox3dB.GetMin()) && AreSamePointExact( ptMax, bBox3dB.GetMax())) && + if ( ! ( AreSamePointXYExact( ptMin, bBox3dB.GetMin()) && AreSamePointXYExact( ptMax, bBox3dB.GetMax())) && bBox3dA.FindIntersectionXY( bBox3dB, b3Int)) { vBBox[b].Add( bBox3dA) ; if ( ! bAdd ) { @@ -500,7 +500,7 @@ Tree::GetIndependentTrees( BIPNTVECTOR& vTrees) Point3d ptTR( m_nSpanU * SBZ_TREG_COEFF, m_nSpanV * SBZ_TREG_COEFF) ; for ( int i = 0 ; i < int( vBBox.size()) ; ++ i) { BBox3d& bBox3d = vBBox[i] ; - if ( AreSamePointEpsilon( bBox3d.GetMin(), ORIG, 10) && AreSamePointEpsilon( bBox3d.GetMax(), ptTR, 10)) { + if ( AreSamePointXYEpsilon( bBox3d.GetMin(), ORIG, 10) && AreSamePointXYEpsilon( bBox3d.GetMax(), ptTR, 10)) { bIsRoot = true ; break ; } @@ -2318,7 +2318,7 @@ Tree::TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) UpdateSplitLoop( plLoopSplit, nPtLoopSplit, vptInters.back()) ; } // controllo di aggiungere un punto abbastanza distante dal precedente - if( ! AreSamePointEpsilon( vptInters.back(), ptCurr, 10 * EPS_SMALL)) { + if( ! AreSamePointXYEpsilon( vptInters.back(), ptCurr, 10 * EPS_SMALL)) { // aggiungo la fine del segmento nel vettore delle intersezioni vptInters.push_back( ptCurr) ; // aggiorno la polyline splittata @@ -2586,7 +2586,7 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, else if ( nEdge == 7) ptInters = ptTR ; // aggiungo il nuovo punto al vettore delle intersezioni - if ( (int)vptInters.size() == 0 || ! AreSamePointEpsilon( ptInters , vptInters.back(), 10 * EPS_SMALL)) + if ( (int)vptInters.size() == 0 || ! AreSamePointXYEpsilon( ptInters , vptInters.back(), 10 * EPS_SMALL)) vptInters.push_back( ptInters) ; else { // se l'ultimo punto del vettore delle intersezioni è quasi uguale al punto che devo aggiungere allora lo sostituisco con quest'ultimo @@ -2624,9 +2624,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, Point3d ptBr( m_mTree[nId].GetTopRight().x, m_mTree[nId].GetBottomLeft().y) ; if ( ptInters.x > m_mTree[nId].GetBottomLeft().x + EPS_SMALL && ptInters.x < m_mTree[nId].GetTopRight().x - EPS_SMALL) m_mTree[nId].m_vInters.back().nIn = 2 ; - else if ( AreSamePointApprox( ptInters, m_mTree[nId].GetBottomLeft())) + else if ( AreSamePointXYApprox( ptInters, m_mTree[nId].GetBottomLeft())) m_mTree[nId].m_vInters.back().nIn = 5 ; - else if ( AreSamePointApprox( ptInters, ptBr)) + else if ( AreSamePointXYApprox( ptInters, ptBr)) m_mTree[nId].m_vInters.back().nIn = 6 ; else m_mTree[nId].m_vInters.back().nIn = 2 ; @@ -2644,9 +2644,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, Point3d ptBr( m_mTree[nId].GetTopRight().x, m_mTree[nId].GetBottomLeft().y) ; if ( ptInters.y > m_mTree[nId].GetBottomLeft().y + EPS_SMALL && ptInters.y < m_mTree[nId].GetTopRight().y - EPS_SMALL) m_mTree[nId].m_vInters.back().nIn = 3 ; - else if ( AreSamePointApprox( ptInters, ptBr)) + else if ( AreSamePointXYApprox( ptInters, ptBr)) m_mTree[nId].m_vInters.back().nIn = 6 ; - else if ( AreSamePointApprox( ptInters, m_mTree[nId].GetTopRight())) + else if ( AreSamePointXYApprox( ptInters, m_mTree[nId].GetTopRight())) m_mTree[nId].m_vInters.back().nIn = 7 ; else m_mTree[nId].m_vInters.back().nIn = 3 ; @@ -2663,9 +2663,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, Point3d ptTl( m_mTree[nId].GetBottomLeft().x, m_mTree[nId].GetTopRight().y) ; if ( ptInters.x > m_mTree[nId].GetBottomLeft().x + EPS_SMALL && ptInters.x < m_mTree[nId].GetTopRight().x - EPS_SMALL) m_mTree[nId].m_vInters.back().nIn = 0 ; - else if ( AreSamePointApprox( ptInters, ptTl)) + else if ( AreSamePointXYApprox( ptInters, ptTl)) m_mTree[nId].m_vInters.back().nIn = 4 ; - else if ( AreSamePointApprox( ptInters, m_mTree[nId].GetTopRight())) + else if ( AreSamePointXYApprox( ptInters, m_mTree[nId].GetTopRight())) m_mTree[nId].m_vInters.back().nIn = 7 ; else m_mTree[nId].m_vInters.back().nIn = 0 ; @@ -2682,9 +2682,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, Point3d ptTl( m_mTree[nId].GetBottomLeft().x, m_mTree[nId].GetTopRight().y) ; if ( ptInters.y > m_mTree[nId].GetBottomLeft().y + EPS_SMALL && ptInters.y < m_mTree[nId].GetTopRight().y - EPS_SMALL) m_mTree[nId].m_vInters.back().nIn = 1 ; - else if ( AreSamePointApprox( ptInters, m_mTree[nId].GetBottomLeft())) + else if ( AreSamePointXYApprox( ptInters, m_mTree[nId].GetBottomLeft())) m_mTree[nId].m_vInters.back().nIn = 5 ; - else if ( AreSamePointApprox( ptInters, ptTl)) + else if ( AreSamePointXYApprox( ptInters, ptTl)) m_mTree[nId].m_vInters.back().nIn = 4 ; else m_mTree[nId].m_vInters.back().nIn = 1 ; @@ -2702,9 +2702,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, m_mTree[nId].m_vInters.emplace_back() ; // controllo se entro in un vertice o a metà lato Point3d ptBr( m_mTree[nId].GetTopRight().x, m_mTree[nId].GetBottomLeft().y) ; - if ( AreSamePointExact( ptInters, ptBr)) + if ( AreSamePointXYExact( ptInters, ptBr)) m_mTree[nId].m_vInters.back().nIn = 6 ; - else if ( AreSamePointExact( ptInters, m_mTree[nId].GetBottomLeft())) + else if ( AreSamePointXYExact( ptInters, m_mTree[nId].GetBottomLeft())) m_mTree[nId].m_vInters.back().nIn = 5 ; else m_mTree[nId].m_vInters.back().nIn = 2 ; @@ -2715,9 +2715,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, m_mTree[nId].m_vInters.emplace_back() ; // controllo se entro in un vertice o a metà lato Point3d ptBr( m_mTree[nId].GetTopRight().x, m_mTree[nId].GetBottomLeft().y) ; - if ( AreSamePointExact( ptInters, ptBr)) + if ( AreSamePointXYExact( ptInters, ptBr)) m_mTree[nId].m_vInters.back().nIn = 6 ; - else if ( AreSamePointExact( ptInters, m_mTree[nId].GetTopRight())) + else if ( AreSamePointXYExact( ptInters, m_mTree[nId].GetTopRight())) m_mTree[nId].m_vInters.back().nIn = 7 ; else m_mTree[nId].m_vInters.back().nIn = 3 ; @@ -2753,9 +2753,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, m_mTree[nId].m_vInters.emplace_back() ; // controllo se entro in un vertice o a metà lato Point3d ptBr( m_mTree[nId].GetTopRight().x, m_mTree[nId].GetBottomLeft().y) ; - if ( AreSamePointExact( ptInters, ptBr)) + if ( AreSamePointXYExact( ptInters, ptBr)) m_mTree[nId].m_vInters.back().nIn = 6 ; - else if ( AreSamePointExact( ptInters, m_mTree[nId].GetTopRight())) + else if ( AreSamePointXYExact( ptInters, m_mTree[nId].GetTopRight())) m_mTree[nId].m_vInters.back().nIn = 7 ; else m_mTree[nId].m_vInters.back().nIn = 3 ; @@ -2766,9 +2766,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, m_mTree[nId].m_vInters.emplace_back() ; // controllo se entro in un vertice o a metà lato Point3d ptTl( m_mTree[nId].GetBottomLeft().x, m_mTree[nId].GetTopRight().y) ; - if ( AreSamePointExact( ptInters, ptTl)) + if ( AreSamePointXYExact( ptInters, ptTl)) m_mTree[nId].m_vInters.back().nIn = 4 ; - else if ( AreSamePointExact( ptInters, m_mTree[nId].GetTopRight())) + else if ( AreSamePointXYExact( ptInters, m_mTree[nId].GetTopRight())) m_mTree[nId].m_vInters.back().nIn = 7 ; else m_mTree[nId].m_vInters.back().nIn = 0 ; @@ -2804,9 +2804,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, m_mTree[nId].m_vInters.emplace_back() ; // controllo se entro in un vertice o a metà lato Point3d ptTl( m_mTree[nId].GetBottomLeft().x, m_mTree[nId].GetTopRight().y) ; - if ( AreSamePointExact( ptInters, ptTl)) + if ( AreSamePointXYExact( ptInters, ptTl)) m_mTree[nId].m_vInters.back().nIn = 4 ; - else if ( AreSamePointExact( ptInters, m_mTree[nId].GetTopRight())) + else if ( AreSamePointXYExact( ptInters, m_mTree[nId].GetTopRight())) m_mTree[nId].m_vInters.back().nIn = 7 ; else m_mTree[nId].m_vInters.back().nIn = 0 ; @@ -2817,9 +2817,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, m_mTree[nId].m_vInters.emplace_back() ; // controllo se entro in un vertice o a metà lato Point3d ptTl( m_mTree[nId].GetBottomLeft().x, m_mTree[nId].GetTopRight().y) ; - if ( AreSamePointExact( ptInters, ptTl)) + if ( AreSamePointXYExact( ptInters, ptTl)) m_mTree[nId].m_vInters.back().nIn = 4 ; - else if ( AreSamePointExact( ptInters, m_mTree[nId].GetBottomLeft())) + else if ( AreSamePointXYExact( ptInters, m_mTree[nId].GetBottomLeft())) m_mTree[nId].m_vInters.back().nIn = 5 ; else m_mTree[nId].m_vInters.back().nIn = 1 ; @@ -2855,9 +2855,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, m_mTree[nId].m_vInters.emplace_back() ; // controllo se entro in un vertice o a metà lato Point3d ptTl( m_mTree[nId].GetBottomLeft().x, m_mTree[nId].GetTopRight().y) ; - if ( AreSamePointExact( ptInters, ptTl)) + if ( AreSamePointXYExact( ptInters, ptTl)) m_mTree[nId].m_vInters.back().nIn = 4 ; - else if ( AreSamePointExact( ptInters, m_mTree[nId].GetBottomLeft())) + else if ( AreSamePointXYExact( ptInters, m_mTree[nId].GetBottomLeft())) m_mTree[nId].m_vInters.back().nIn = 5 ; else m_mTree[nId].m_vInters.back().nIn = 1 ; @@ -2868,9 +2868,9 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, m_mTree[nId].m_vInters.emplace_back() ; // controllo se entro in un vertice o a metà lato Point3d ptBr( m_mTree[nId].GetTopRight().x, m_mTree[nId].GetBottomLeft().y) ; - if ( AreSamePointExact( ptInters, ptBr)) + if ( AreSamePointXYExact( ptInters, ptBr)) m_mTree[nId].m_vInters.back().nIn = 6 ; - else if ( AreSamePointExact( ptInters, m_mTree[nId].GetBottomLeft())) + else if ( AreSamePointXYExact( ptInters, m_mTree[nId].GetBottomLeft())) m_mTree[nId].m_vInters.back().nIn = 5 ; else m_mTree[nId].m_vInters.back().nIn = 2 ; @@ -2956,12 +2956,12 @@ Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX case 3 : ptNextVert = ptBr ; break ; } if ( ! bForTriangulation) { - while ( plCell.GetNextPoint( ptToAdd) && ! AreSamePointExact( ptToAdd, ptNextVert)) + while ( plCell.GetNextPoint( ptToAdd) && ! AreSamePointXYExact( ptToAdd, ptNextVert)) vEdgeVertex[j].push_back( ptToAdd) ; } else { double dPar = 0 ; - while ( plCell.GetNextUPoint( &dPar, &ptToAdd) && ! AreSamePointExact( ptToAdd, ptNextVert)) { + while ( plCell.GetNextUPoint( &dPar, &ptToAdd) && ! AreSamePointXYExact( ptToAdd, ptNextVert)) { vEdgeVertex[j].push_back( ptToAdd) ; if ( dPar > 0) plCell3d.GetNextPoint( pt3d) ; @@ -3528,10 +3528,10 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe // se è il primo punto della PolyLine lo aggiungo if ( plTrimmedPoly.GetPointNbr() == 0) { // se cerco di aggiungere il vertice che devo saltare, non faccio nulla - if( ( nVertToSkip == 0 && AreSamePointApprox( ptToAdd, ptBL)) || - ( nVertToSkip == 1 && AreSamePointApprox( ptToAdd, ptBr)) || - ( nVertToSkip == 2 && AreSamePointApprox( ptToAdd, ptTR)) || - ( nVertToSkip == 3 && AreSamePointApprox( ptToAdd, ptTl))) { + if( ( nVertToSkip == 0 && AreSamePointXYApprox( ptToAdd, ptBL)) || + ( nVertToSkip == 1 && AreSamePointXYApprox( ptToAdd, ptBr)) || + ( nVertToSkip == 2 && AreSamePointXYApprox( ptToAdd, ptTR)) || + ( nVertToSkip == 3 && AreSamePointXYApprox( ptToAdd, ptTl))) { // aggiorno l'ultimo punto aggiunto ptLast.Set( ptToAdd.x, ptToAdd.y, 0) ; return true ; @@ -3553,7 +3553,7 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe // verifico di essere allineato con un lato, sennò aggiungo e basta Vector3d vDir ; - if ( ! AreSamePointApprox( ptToAdd, ptLast)) + if ( ! AreSamePointXYApprox( ptToAdd, ptLast)) vDir = ptToAdd - ptLast ; else return false ; @@ -3563,19 +3563,19 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe plTrimmedPoly3d.EraseLastUPoint() ; Point3d ptVert ; int nVert = -1 ; - if ( AreSamePointApprox( ptToAdd, ptBr)){ + if ( AreSamePointXYApprox( ptToAdd, ptBr)){ ptVert = ptBr ; nVert = 1 ; } - else if ( AreSamePointApprox( ptToAdd, ptTR)) { + else if ( AreSamePointXYApprox( ptToAdd, ptTR)) { ptVert = ptTR ; nVert = 2 ; } - else if ( AreSamePointApprox( ptToAdd, ptTl)) { + else if ( AreSamePointXYApprox( ptToAdd, ptTl)) { ptVert = ptTl ; nVert = 3 ; } - else if ( AreSamePointApprox( ptToAdd, ptBL)) { + else if ( AreSamePointXYApprox( ptToAdd, ptBL)) { ptVert = ptBL ; nVert = 0 ; } @@ -3610,7 +3610,7 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe ++ c ; } } - bool bVert = AreSamePointApprox( ptToAdd, ptTl) ; + bool bVert = AreSamePointXYApprox( ptToAdd, ptTl) ; if ( ! ( nVertToSkip == 3 && bVert)) { plTrimmedPoly.AddUPoint( c, ptToAdd) ; if( bForTriangulation){ @@ -3635,7 +3635,7 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe ++ c ; } } - bool bVert = AreSamePointApprox( ptToAdd, ptBL) ; + bool bVert = AreSamePointXYApprox( ptToAdd, ptBL) ; if ( ! ( nVertToSkip == 0 && bVert)) { plTrimmedPoly.AddUPoint( c, ptToAdd) ; if( bForTriangulation) { @@ -3660,7 +3660,7 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe ++ c ; } } - bool bVert = AreSamePointApprox( ptToAdd, ptBr) ; + bool bVert = AreSamePointXYApprox( ptToAdd, ptBr) ; if ( ! ( nVertToSkip == 1 && bVert)) { plTrimmedPoly.AddUPoint( c, ptToAdd) ; if( bForTriangulation){ @@ -3685,7 +3685,7 @@ Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVe ++ c ; } } - bool bVert = AreSamePointApprox( ptToAdd, ptTR) ; + bool bVert = AreSamePointXYApprox( ptToAdd, ptTR) ; if ( ! ( nVertToSkip == 2 && bVert)) { plTrimmedPoly.AddUPoint( c, ptToAdd) ; if( bForTriangulation) { @@ -4123,13 +4123,13 @@ Tree::OnWhichEdge( int nId, const Point3d& ptToAssign, int& nEdge) const Point3d ptTl ( ptBL.x, ptTR.y) ; Point3d ptBr ( ptTR.x, ptBL.y) ; - if ( AreSamePointApprox( ptToAssign, ptTR)) + if ( AreSamePointXYApprox( ptToAssign, ptTR)) nEdge = 7 ; - else if ( AreSamePointApprox( ptToAssign, ptTl)) + else if ( AreSamePointXYApprox( ptToAssign, ptTl)) nEdge = 4 ; - else if ( AreSamePointApprox( ptToAssign, ptBL)) + else if ( AreSamePointXYApprox( ptToAssign, ptBL)) nEdge = 5 ; - else if ( AreSamePointApprox( ptToAssign, ptBr)) + else if ( AreSamePointXYApprox( ptToAssign, ptBr)) nEdge = 6 ; else if ( ptToAssign.x > ptBL.x && ptToAssign.x < ptTR.x && abs( ptToAssign.y - ptTR.y) < EPS_SMALL) nEdge = 0 ; @@ -4189,13 +4189,13 @@ Tree::GetEdges3D( POLYLINEMATRIX& mPLEdges) Point3d pt3d ; // a seconda del lato controllo di stare scorrendo il poligono prendendo solo i punti su quel lato if ( i == 0) { - while ( ! AreSamePointApprox(pt, m_mTree.at(vEdges[0][c]).GetTopRight()) && mPL[i][c].GetNextPoint( pt)) { + while ( ! AreSamePointXYApprox(pt, m_mTree.at(vEdges[0][c]).GetTopRight()) && mPL[i][c].GetNextPoint( pt)) { continue ; } mPLEdges.back().back().AddUPoint( nPtCount, m_mVert.at(vEdges[0][c])[2]) ; ++ nPtCount ; // scorro fino alla fine di quel lato - while ( mPL[i][c].GetNextPoint( pt) && ! AreSamePointApprox(pt, m_mTree.at(vEdges[0][c]).GetTopLeft())) { + while ( mPL[i][c].GetNextPoint( pt) && ! AreSamePointXYApprox(pt, m_mTree.at(vEdges[0][c]).GetTopLeft())) { m_pSrfBz->GetPointD1D2( pt.x / SBZ_TREG_COEFF, pt.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; mPLEdges.back().back().AddUPoint( nPtCount, pt3d) ; ++ nPtCount ; @@ -4204,13 +4204,13 @@ Tree::GetEdges3D( POLYLINEMATRIX& mPLEdges) ++ nPtCount ; } else if ( i == 1 ) { - while ( ! AreSamePointApprox(pt, m_mTree.at(vEdges[1][c]).GetTopLeft()) && mPL[i][c].GetNextPoint( pt)) { + while ( ! AreSamePointXYApprox(pt, m_mTree.at(vEdges[1][c]).GetTopLeft()) && mPL[i][c].GetNextPoint( pt)) { continue ; } mPLEdges.back().back().AddUPoint( nPtCount, m_mVert.at(vEdges[1][c])[3]) ; ++ nPtCount ; // scorro fino alla fine di quel lato - while ( mPL[i][c].GetNextPoint( pt) && ! AreSamePointApprox(pt, m_mTree.at(vEdges[1][c]).GetBottomLeft())) { + while ( mPL[i][c].GetNextPoint( pt) && ! AreSamePointXYApprox(pt, m_mTree.at(vEdges[1][c]).GetBottomLeft())) { m_pSrfBz->GetPointD1D2( pt.x / SBZ_TREG_COEFF, pt.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; mPLEdges.back().back().AddUPoint( nPtCount, pt3d) ; ++ nPtCount ; @@ -4219,13 +4219,13 @@ Tree::GetEdges3D( POLYLINEMATRIX& mPLEdges) ++ nPtCount ; } else if ( i == 2) { - while ( ! AreSamePointApprox(pt, m_mTree.at(vEdges[2][c]).GetBottomLeft()) && mPL[i][c].GetNextPoint( pt)) { + while ( ! AreSamePointXYApprox(pt, m_mTree.at(vEdges[2][c]).GetBottomLeft()) && mPL[i][c].GetNextPoint( pt)) { continue ; } mPLEdges.back().back().AddUPoint( nPtCount, m_mVert.at(vEdges[2][c])[0]) ; ++ nPtCount ; // scorro fino alla fine di quel lato - while ( mPL[i][c].GetNextPoint( pt) && ! AreSamePointApprox(pt, m_mTree.at(vEdges[2][c]).GetBottomRight())) { + while ( mPL[i][c].GetNextPoint( pt) && ! AreSamePointXYApprox(pt, m_mTree.at(vEdges[2][c]).GetBottomRight())) { m_pSrfBz->GetPointD1D2( pt.x / SBZ_TREG_COEFF, pt.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; mPLEdges.back().back().AddUPoint( nPtCount, pt3d) ; ++ nPtCount ; @@ -4234,13 +4234,13 @@ Tree::GetEdges3D( POLYLINEMATRIX& mPLEdges) ++ nPtCount ; } else if ( i == 3) { - while ( ! AreSamePointApprox(pt, m_mTree.at(vEdges[3][c]).GetBottomRight()) && mPL[i][c].GetNextPoint( pt)) { + while ( ! AreSamePointXYApprox(pt, m_mTree.at(vEdges[3][c]).GetBottomRight()) && mPL[i][c].GetNextPoint( pt)) { continue ; } mPLEdges.back().back().AddUPoint( nPtCount, m_mVert.at(vEdges[3][c])[1]) ; ++ nPtCount ; // scorro fino alla fine di quel lato - while ( mPL[i][c].GetNextPoint( pt) && ! AreSamePointApprox(pt, m_mTree.at(vEdges[3][c]).GetTopRight())) { + while ( mPL[i][c].GetNextPoint( pt) && ! AreSamePointXYApprox(pt, m_mTree.at(vEdges[3][c]).GetTopRight())) { m_pSrfBz->GetPointD1D2( pt.x / SBZ_TREG_COEFF, pt.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d) ; mPLEdges.back().back().AddUPoint( nPtCount, pt3d) ; ++ nPtCount ;