From: oan Date: Fri, 1 Apr 2016 11:30:15 +0000 (+0300) Subject: 0027226: Meshing algorithm fails if edge curves has small defects (bends, loops...) X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=495cb861dce528f5606527f9b7892015a9828bc9;p=occt-copy.git 0027226: Meshing algorithm fails if edge curves has small defects (bends, loops...) Take into account tolerance of edge vertices in order to reduce density of discretization points. --- diff --git a/src/BRepMesh/BRepMesh_EdgeTessellator.cxx b/src/BRepMesh/BRepMesh_EdgeTessellator.cxx index d1895602c1..472513cf35 100644 --- a/src/BRepMesh/BRepMesh_EdgeTessellator.cxx +++ b/src/BRepMesh/BRepMesh_EdgeTessellator.cxx @@ -30,7 +30,7 @@ #include #include #include - +#include IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_EdgeTessellator,BRepMesh_IEdgeTool) @@ -47,6 +47,8 @@ BRepMesh_EdgeTessellator::BRepMesh_EdgeTessellator( const Standard_Real theMinSize) : mySurface(theFaceAttribute->Surface()) { + TopExp::Vertices (theEdge, myFirstVertex, myLastVertex); + Standard_Real aPreciseAngDef = 0.5 * theAngDeflection; Standard_Real aPreciseLinDef = 0.5 * theLinDeflection; if (theEdge.Orientation() == TopAbs_INTERNAL) @@ -164,6 +166,20 @@ BRepMesh_EdgeTessellator::BRepMesh_EdgeTessellator( myFaceRangeV[1] = mySurface->LastVParameter() + aDv; } +//======================================================================= +//function : isInToleranceOfVertex +//purpose : +//======================================================================= +Standard_Boolean BRepMesh_EdgeTessellator::isInToleranceOfVertex ( + const gp_Pnt& thePoint, + const TopoDS_Vertex& theVertex) +{ + const gp_Pnt aPoint = BRep_Tool::Pnt (theVertex); + const Standard_Real aTolerance = BRep_Tool::Tolerance (theVertex); + + return (thePoint.SquareDistance (aPoint) < aTolerance * aTolerance); +} + //======================================================================= //function : Value //purpose : @@ -176,6 +192,12 @@ Standard_Boolean BRepMesh_EdgeTessellator::Value( { myTool->Value(theIndex, mySurface, theParameter, thePoint, theUV); + if (isInToleranceOfVertex (thePoint, myFirstVertex) || + isInToleranceOfVertex (thePoint, myLastVertex)) + { + return Standard_False; + } + // If point coordinates are out of surface range, // it is necessary to re-project point. if (mySurface->GetType() != GeomAbs_BSplineSurface && diff --git a/src/BRepMesh/BRepMesh_EdgeTessellator.hxx b/src/BRepMesh/BRepMesh_EdgeTessellator.hxx index 80b184d3dd..0b63193ef0 100644 --- a/src/BRepMesh/BRepMesh_EdgeTessellator.hxx +++ b/src/BRepMesh/BRepMesh_EdgeTessellator.hxx @@ -24,6 +24,7 @@ #include #include #include +#include class Geom_Surface; class Geom2d_Curve; @@ -76,6 +77,11 @@ private: const Standard_Real theLast, const Standard_Integer theNbIter); + //! Checks whether the given point lies within tolerance of the vertex. + Standard_Boolean isInToleranceOfVertex ( + const gp_Pnt& thePoint, + const TopoDS_Vertex& theVertex); + private: NCollection_Handle myTool; Handle(BRepAdaptor_HSurface) mySurface; @@ -85,6 +91,8 @@ private: Standard_Real myEdgeSqTol; Standard_Real myFaceRangeU[2]; Standard_Real myFaceRangeV[2]; + TopoDS_Vertex myFirstVertex; + TopoDS_Vertex myLastVertex; }; DEFINE_STANDARD_HANDLE(BRepMesh_EdgeTessellator, BRepMesh_IEdgeTool)