diff --git a/SurfTriMeshBooleans.cpp b/SurfTriMeshBooleans.cpp index e48299b..16435a4 100644 --- a/SurfTriMeshBooleans.cpp +++ b/SurfTriMeshBooleans.cpp @@ -47,88 +47,6 @@ static int IntersRectangleTriangle( const Point3d& ptP, const Vector3d& vtL1, const Vector3d& vtL2, const Triangle3d& trTria, Point3d& ptStSeg, Point3d& ptEnSeg) { -#define bUseTria false - -#if bUseTria - // Definisco i due triangoli formanti il rettangolo - Triangle3d trTriaA ; - trTriaA.Set( ptP, ptP + vtL1, ptP + vtL2) ; - if ( ! trTriaA.Validate()) - return -1 ; - Triangle3d trTriaB ; - trTriaB.Set( ptP + vtL1, ptP + vtL1 + vtL2, ptP + vtL2) ; - if ( ! trTriaB.Validate()) - return -1 ; - // Interseco il triangolo con il primo dei due triangoli del rettangolo - int nIntA = 0 ; - Point3d ptIntA1, ptIntA2 ; - TRIA3DVECTOR vTriaA ; - int nIntTypeA = IntersTriaTria( trTria, trTriaA, ptIntA1, ptIntA2, vTriaA) ; - if ( nIntTypeA == ITTT_VERT_VERT || nIntTypeA == ITTT_VERT_EDGE || nIntTypeA == ITTT_VERT_INT || nIntTypeA == ITTT_EDGE_VERT || nIntTypeA == ITTT_EDGE_EDGE_PNT || nIntTypeA == ITTT_INT_VERT) - nIntA = 1 ; - else if ( /*nIntTypeA == ITTT_EDGE_EDGE_SEG || nIntTypeA == ITTT_EDGE_INT ||*/ nIntTypeA == ITTT_INT_EDGE || nIntTypeA == ITTT_INT_INT_SEG) { - nIntA = 2 ; - } - // Interseco il triangolo con il secondo dei due triangoli del rettangolo - int nIntB = 0 ; - Point3d ptIntB1, ptIntB2 ; - TRIA3DVECTOR vTriaB ; - int nIntTypeB = IntersTriaTria( trTria, trTriaB, ptIntB1, ptIntB2, vTriaB) ; - if ( nIntTypeB == ITTT_VERT_VERT || nIntTypeB == ITTT_VERT_EDGE || nIntTypeB == ITTT_VERT_INT || nIntTypeB == ITTT_EDGE_VERT || nIntTypeB == ITTT_EDGE_EDGE_PNT || nIntTypeB == ITTT_INT_VERT) - nIntB = 1 ; - else if ( /*nIntTypeB == ITTT_EDGE_EDGE_SEG || nIntTypeB == ITTT_EDGE_INT ||*/ nIntTypeB == ITTT_INT_EDGE || nIntTypeB == ITTT_INT_INT_SEG) { - nIntB = 2 ; - } - // Unisco le due intersezioni - int nIntTot = nIntA + nIntB ; - if ( nIntTot == 4) { - if ( AreSamePointApprox( ptIntA2, ptIntB1)) { - ptStSeg = ptIntA1 ; - ptEnSeg = ptIntB2 ; - } - else { - ptStSeg = ptIntB1 ; - ptEnSeg = ptIntA2 ; - } - return 2 ; - } - else if ( nIntTot == 3) { - if ( nIntA == 2) { - ptStSeg = ptIntA1 ; - ptEnSeg = ptIntA2 ; - } - else { - ptStSeg = ptIntB1 ; - ptEnSeg = ptIntB2 ; - } - return 2 ; - } - else if ( nIntTot == 2) { - if ( nIntA == 2) { - ptStSeg = ptIntA1 ; - ptEnSeg = ptIntA2 ; - } - else if ( nIntA == 1) { - ptStSeg = ptIntA1 ; - ptEnSeg = ptIntB1 ; - } - else { - ptStSeg = ptIntB1 ; - ptEnSeg = ptIntB2 ; - } - return 2 ; - } - else if ( nIntTot == 1) { - if ( nIntA == 1) - ptStSeg = ptIntA1 ; - else - ptStSeg = ptIntB1 ; - return 1 ; - } - else - return 0 ; -#else - // Definisco il piano; se non definibile, segnalo un errore. Plane3d plRectanglePlane ; if ( ! plRectanglePlane.Set( ptP, vtL1 ^ vtL2)) @@ -193,8 +111,6 @@ IntersRectangleTriangle( const Point3d& ptP, const Vector3d& vtL1, const Vector3 } else return 1 ; - -#endif } //---------------------------------------------------------------------------- @@ -431,7 +347,7 @@ SurfTriMesh::GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq) b3SurfBox.GetMinMax( ptMin, ptMax) ; Vector3d vtMax = ( ptMax.z + 10) * vtExtr ; Vector3d vtMin = ( ptMin.z - 10) * vtExtr ; - + // Ciclo sui triangoli bool bModif = false ; int nNumTria = GetTriangleSize() ; @@ -585,16 +501,7 @@ SurfTriMesh::GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq) CHAINVECTOR cvOpenChain ; for ( int nL = 0 ; nL < int( vChain.size()) ; ++ nL) { int nCurLoopLast = max( int(vChain[nL].size()) - 1, 0) ; - if (nCurLoopLast <= 1) { - static int nTimeCount = 0; - ++nTimeCount; - if (nTimeCount == 211) - int Stop = 0; - string sOut = "nTimeCount = " + ToString( nTimeCount) ; - LOG_ERROR( GetEGkLogger(), sOut.c_str()) - - } - if ( AreSamePointApprox( vChain[nL][0].ptSt, vChain[nL][nCurLoopLast].ptEn) && nCurLoopLast > 1) + if ( AreSamePointApprox( vChain[nL][0].ptSt, vChain[nL][nCurLoopLast].ptEn) && nCurLoopLast > 0) cvClosedChain.emplace_back( vChain[nL]) ; else { cvOpenChain.emplace_back( vChain[nL]) ; @@ -753,10 +660,12 @@ SurfTriMesh::GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq) } // da eliminare - else if ( nVertInside == 0) + else if ( nVertInside == 0) { RemoveTriangle( nT) ; + bModif = true ; + } } - + // Se avvenuta modifica, aggiorno tutto if ( bModif) { // aggiorno tutto