X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_Slot.cxx;h=33c16aa277fe2ce57655b8d710e2d195ca04d32e;hb=f79e964b7592c63818f892516f3b4936d7704397;hp=f706f5bceeddf28bea7b575d2cdd3bab0c773f9a;hpb=55d3f10182c716ecec2b6f71d5b3ac25391ca5d9;p=modules%2Fsmesh.git diff --git a/src/SMESHUtils/SMESH_Slot.cxx b/src/SMESHUtils/SMESH_Slot.cxx index f706f5bce..33c16aa27 100644 --- a/src/SMESHUtils/SMESH_Slot.cxx +++ b/src/SMESHUtils/SMESH_Slot.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2019 OPEN CASCADE +// Copyright (C) 2018-2020 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -127,6 +127,15 @@ namespace return 0; if ( myFreeEnds.empty() ) { + // remove degenerated cuts + // for ( size_t iC1 = 0; iC1 < myCuts.size(); ++iC1 ) + // if ( myCuts[ iC1 ][ 0 ].myNode == myCuts[ iC1 ][ 1 ].myNode ) + // { + // if ( iC1 < myCuts.size() - 1 ) + // myCuts[ iC1 ] = myCuts.back(); + // myCuts.pop_back(); + // } + int nbShared = 0; std::vector< bool > isSharedPnt( myCuts.size() * 2, false ); for ( size_t iC1 = 0; iC1 < myCuts.size() - 1; ++iC1 ) @@ -144,7 +153,12 @@ namespace if ( myCuts[ iC1 ][ iP1 ].SquareDistance( myCuts[ iC2 ][ iP2 ]) < tol * tol ) { nbShared += 2; - isSharedPnt[ i1 ] = isSharedPnt[ i2 ] = true; + if ( myCuts[ iC1 ][ 0 ].SquareDistance( myCuts[ iC1 ][ 1 ]) < tol * tol ) + isSharedPnt[ iC1 * 2 ] = isSharedPnt[ iC1 * 2 + 1 ] = true; + else if ( myCuts[ iC2 ][ 0 ].SquareDistance( myCuts[ iC2 ][ 1 ]) < tol * tol ) + isSharedPnt[ iC2 * 2 ] = isSharedPnt[ iC2 * 2 + 1 ] = true; + else + isSharedPnt[ i1 ] = isSharedPnt[ i2 ] = true; } } } @@ -469,7 +483,7 @@ namespace const Segment* findTooCloseSegment( const IntPoint& p, const double minDist, - const double tol, + const double /*tol*/, const Segment* curSegment, const SMDS_MeshNode* curNode, const TSegmentsOfNode& segmentsOfNode ) @@ -509,7 +523,7 @@ namespace //================================================================================ /*! * \brief Create a slot of given width around given 1D elements lying on a triangle mesh. - * The slot is consrtucted by cutting faces by cylindrical surfaces made around each segment. + * The slot is constructed by cutting faces by cylindrical surfaces made around each segment. * \return Edges located at the slot boundary */ //================================================================================ @@ -556,6 +570,7 @@ SMESH_MeshAlgos::MakeSlot( SMDS_ElemIteratorPtr theSegmentIt, // --------------------------------- const double tol = Precision::Confusion(); + const double angularTol = 1e-5; std::vector< gp_XYZ > faceNormals; SMESH_MeshAlgos::Intersector meshIntersector( theMesh, tol, faceNormals ); std::unique_ptr< SMESH_ElementSearcher> faceSearcher; @@ -716,7 +731,7 @@ SMESH_MeshAlgos::MakeSlot( SMDS_ElemIteratorPtr theSegmentIt, if ( intPoints.size() == 2 ) toCut = true; else if ( isCylinderOnFace ) - toCut = cylAxis.Direction().IsParallel( edegDir, tol ); + toCut = cylAxis.Direction().IsParallel( edegDir, angularTol ); else { SMESH_NodeXYZ nBetween; @@ -791,10 +806,10 @@ SMESH_MeshAlgos::MakeSlot( SMDS_ElemIteratorPtr theSegmentIt, isOut( intPnt[1].myNode, planeNormal, intPnt[1].myIsOutPln, 1 ); const Segment * closeSeg[2] = { 0, 0 }; if ( intPnt[0].myIsOutPln[0] ) - closeSeg[0] = findTooCloseSegment( intPnt[0], 0.5 * theWidth - tol, tol, + closeSeg[0] = findTooCloseSegment( intPnt[0], 0.5 * theWidth - 1e-3*tol, tol, segment, n1, segmentsOfNode ); if ( intPnt[1].myIsOutPln[0] ) - closeSeg[1] = findTooCloseSegment( intPnt[1], 0.5 * theWidth - tol, tol, + closeSeg[1] = findTooCloseSegment( intPnt[1], 0.5 * theWidth - 1e-3*tol, tol, segment, n1, segmentsOfNode ); int nbCut = bool( closeSeg[0] ) + bool( closeSeg[1] ); if ( nbCut == 0 ) @@ -821,20 +836,22 @@ SMESH_MeshAlgos::MakeSlot( SMDS_ElemIteratorPtr theSegmentIt, // 2) double minCutDist = theWidth; gp_XYZ projection, closestProj; - int iCut; - for ( size_t iC = 0; iC < closeSeg[iP]->myCuts.size(); ++iC ) + int iCut = -1; + for ( size_t iC2 = 0; iC2 < closeSeg[iP]->myCuts.size(); ++iC2 ) { - double cutDist = closeSeg[iP]->myCuts[iC].SquareDistance( intPnt[iP].myNode, + double cutDist = closeSeg[iP]->myCuts[iC2].SquareDistance( intPnt[iP].myNode, projection ); if ( cutDist < minCutDist ) { closestProj = projection; minCutDist = cutDist; - iCut = iC; + iCut = iC2; + if ( minCutDist < tol * tol ) + break; } - if ( minCutDist < tol * tol ) - break; } + if ( iCut < 0 ) + continue; // ??? double d1 = SMESH_MeshAlgos::GetDistance( neighborSeg->myEdge, closeSeg[iP]->myCuts[iCut][0].myNode ); double d2 = SMESH_MeshAlgos::GetDistance( neighborSeg->myEdge,