]> OCCT Git - occt-copy.git/commitdiff
0027226: Meshing algorithm fails if edge curves has small defects (bends, loops...) CR27226
authoroan <oan@opencascade.com>
Fri, 1 Apr 2016 11:30:15 +0000 (14:30 +0300)
committermkv <mkv@opencascade.com>
Tue, 26 Apr 2016 08:40:29 +0000 (11:40 +0300)
Take into account tolerance of edge vertices in order to reduce density of discretization points.

src/BRepMesh/BRepMesh_EdgeTessellator.cxx
src/BRepMesh/BRepMesh_EdgeTessellator.hxx

index d1895602c1dd1ec67d0953de28c85b53ff9620ce..472513cf355385dd3718dc2a4f7307ec80c5fc9d 100644 (file)
@@ -30,7 +30,7 @@
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TColStd_Array1OfReal.hxx>
-
+#include <TopExp.hxx>
 
 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 &&
index 80b184d3dd5068fccbeb9c7618014aa5a41e6026..0b63193ef03b83982d65ccf69525a50ec3331289 100644 (file)
@@ -24,6 +24,7 @@
 #include <BRepMesh_FaceAttribute.hxx>
 #include <BRepAdaptor_Curve.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopoDS_Vertex.hxx>
 
 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<BRepMesh_GeomTool> 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)