]> OCCT Git - occt.git/commitdiff
0021593: Small improvement
authoroan <oan@opencascade.com>
Wed, 3 Dec 2014 08:51:58 +0000 (11:51 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 11 Dec 2014 12:26:53 +0000 (15:26 +0300)
New parameter for BRepMesh; Test case

src/BRepMesh/BRepMesh_FastDiscret.cxx
src/BRepMesh/BRepMesh_FastDiscret.hxx
src/BRepMesh/BRepMesh_FastDiscretFace.cxx
src/BRepMesh/BRepMesh_FastDiscretFace.hxx
src/BRepMesh/BRepMesh_IncrementalMesh.cxx
src/BRepMesh/BRepMesh_IncrementalMesh.hxx
src/MeshTest/MeshTest.cxx
tests/bugs/mesh/bug21593 [new file with mode: 0644]

index 273b1526977e917f83bad12bb0258366f9ee71e3..72e4ac8a6c197beca76a1b0b9f731f8eb94a6439 100644 (file)
@@ -86,14 +86,15 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FastDiscret, Standard_Transient)
 //purpose  : 
 //=======================================================================
 BRepMesh_FastDiscret::BRepMesh_FastDiscret(
-  const Standard_Real                              theDefle,
-  const Standard_Real                              theAngl,
-  const Bnd_Box&                                   theBox,
-  const Standard_Boolean                           theWithShare,
-  const Standard_Boolean                           theInshape,
-  const Standard_Boolean                           theRelative,
-  const Standard_Boolean                           theShapetrigu,
-  const Standard_Boolean                           isInParallel)
+  const Standard_Real    theDefle,
+  const Standard_Real    theAngl,
+  const Bnd_Box&         theBox,
+  const Standard_Boolean theWithShare,
+  const Standard_Boolean theInshape,
+  const Standard_Boolean theRelative,
+  const Standard_Boolean theShapetrigu,
+  const Standard_Boolean isInParallel,
+  const Standard_Boolean isInternalVerticesMode)
 : myAngle (theAngl),
   myDeflection (theDefle),
   myWithShare (theWithShare),
@@ -102,7 +103,8 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(
   myShapetrigu (theShapetrigu), 
   myInshape (theInshape),
   myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
-  myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt)
+  myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
+  myInternalVerticesMode(isInternalVerticesMode)
 {
   if ( myRelative )
     BRepMesh_ShapeTool::BoxMaxDimension(theBox, myDtotale);
@@ -112,15 +114,17 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(
 //function : BRepMesh_FastDiscret
 //purpose  : 
 //=======================================================================
-BRepMesh_FastDiscret::BRepMesh_FastDiscret(const TopoDS_Shape&    theShape,
-                                           const Standard_Real    theDefle,
-                                           const Standard_Real    theAngl,
-                                           const Bnd_Box&         theBox,
-                                           const Standard_Boolean theWithShare,
-                                           const Standard_Boolean theInshape,
-                                           const Standard_Boolean theRelative,
-                                           const Standard_Boolean theShapetrigu,
-                                           const Standard_Boolean isInParallel)
+BRepMesh_FastDiscret::BRepMesh_FastDiscret(
+  const TopoDS_Shape&    theShape,
+  const Standard_Real    theDefle,
+  const Standard_Real    theAngl,
+  const Bnd_Box&         theBox,
+  const Standard_Boolean theWithShare,
+  const Standard_Boolean theInshape,
+  const Standard_Boolean theRelative,
+  const Standard_Boolean theShapetrigu,
+  const Standard_Boolean isInParallel,
+  const Standard_Boolean isInternalVerticesMode)
 : myAngle (theAngl),
   myDeflection (theDefle),
   myWithShare (theWithShare),
@@ -129,7 +133,8 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(const TopoDS_Shape&    theShape,
   myShapetrigu (theShapetrigu),
   myInshape (theInshape),
   myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
-  myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt)
+  myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
+  myInternalVerticesMode(isInternalVerticesMode)
 {
   if ( myRelative )
     BRepMesh_ShapeTool::BoxMaxDimension(theBox, myDtotale);
@@ -193,7 +198,7 @@ void BRepMesh_FastDiscret::Process(const TopoDS_Face& theFace) const
     {
       OCC_CATCH_SIGNALS
 
-      BRepMesh_FastDiscretFace aTool(GetAngle());
+      BRepMesh_FastDiscretFace aTool(GetAngle(), myInternalVerticesMode);
       aTool.Perform(anAttribute);
     }
     catch (Standard_Failure)
index b1fe24d407bcc605f14a81f4af51613190e5a1c5..e0c6db9c14ba2b07366ec5960efc7b3b92b87783 100644 (file)
@@ -58,14 +58,16 @@ class BRepMesh_FastDiscret : public Standard_Transient
 {
 public:
   
-  Standard_EXPORT BRepMesh_FastDiscret(const Standard_Real defle,
-                                       const Standard_Real angle,
-                                       const Bnd_Box& B,
-                                       const Standard_Boolean withShare = Standard_True,
-                                       const Standard_Boolean inshape = Standard_False,
-                                       const Standard_Boolean relative = Standard_False,
-                                       const Standard_Boolean shapetrigu = Standard_False,
-                                       const Standard_Boolean isInParallel = Standard_False);
+  Standard_EXPORT BRepMesh_FastDiscret(
+    const Standard_Real defle,
+    const Standard_Real angle,
+    const Bnd_Box& B,
+    const Standard_Boolean withShare = Standard_True,
+    const Standard_Boolean inshape = Standard_False,
+    const Standard_Boolean relative = Standard_False,
+    const Standard_Boolean shapetrigu = Standard_False,
+    const Standard_Boolean isInParallel = Standard_False,
+    const Standard_Boolean isInternalVerticesMode = Standard_True);
 
   //! if the boolean <relative> is True, the <br>
   //! deflection used for the polygonalisation of <br>
@@ -79,15 +81,17 @@ public:
   //! <br>
   //! if <inshape> is True, the calculated <br>
   //! triangulation will be stored in the shape. <br>
-  Standard_EXPORT BRepMesh_FastDiscret(const TopoDS_Shape& shape,
-                                       const Standard_Real defle,
-                                       const Standard_Real angle,
-                                       const Bnd_Box& B,
-                                       const Standard_Boolean withShare = Standard_True,
-                                       const Standard_Boolean inshape = Standard_False,
-                                       const Standard_Boolean relative = Standard_False,
-                                       const Standard_Boolean shapetrigu = Standard_False,
-                                       const Standard_Boolean isInParallel = Standard_False);
+  Standard_EXPORT BRepMesh_FastDiscret(
+    const TopoDS_Shape& shape,
+    const Standard_Real defle,
+    const Standard_Real angle,
+    const Bnd_Box& B,
+    const Standard_Boolean withShare = Standard_True,
+    const Standard_Boolean inshape = Standard_False,
+    const Standard_Boolean relative = Standard_False,
+    const Standard_Boolean shapetrigu = Standard_False,
+    const Standard_Boolean isInParallel = Standard_False,
+    const Standard_Boolean isInternalVerticesMode = Standard_True);
 
   //! Build triangulation on the whole shape.
   Standard_EXPORT void Perform(const TopoDS_Shape& shape);
@@ -362,6 +366,7 @@ private:
   // Fast access to attributes of current face
   Handle(BRepMesh_FaceAttribute)                   myAttribute;
   TopTools_IndexedDataMapOfShapeListOfShape        mySharedFaces;
+  Standard_Boolean                                 myInternalVerticesMode;
 };
 
 DEFINE_STANDARD_HANDLE(BRepMesh_FastDiscret, Standard_Transient)
index 5ec84b646bd2c2359a24cad210db991b040ebad8..ad1471c3dfad1ec42b9d5be9b9b4894000cf9147 100644 (file)
@@ -141,10 +141,11 @@ namespace
 //function : BRepMesh_FastDiscretFace
 //purpose  :
 //=======================================================================
-BRepMesh_FastDiscretFace::BRepMesh_FastDiscretFace
-                          (const Standard_Real     theAngle)
+BRepMesh_FastDiscretFace::BRepMesh_FastDiscretFace(
+  const Standard_Real    theAngle,
+  const Standard_Boolean isInternalVerticesMode)
 : myAngle(theAngle),
-  myInternalVerticesMode(Standard_True)
+  myInternalVerticesMode(isInternalVerticesMode)
 {
   myAllocator = new NCollection_IncAllocator(
     BRepMesh::MEMORY_BLOCK_SIZE_HUGE);
@@ -1247,6 +1248,9 @@ void BRepMesh_FastDiscretFace::add(const TopoDS_Vertex& theVertex)
     OCC_CATCH_SIGNALS
 
     gp_Pnt2d aPnt2d = BRep_Tool::Parameters(theVertex, myAttribute->Face());
+    // check UV values for internal vertices
+    if (myAttribute->ChangeClassifier()->Perform(aPnt2d) != TopAbs_IN)
+      return;
 
     NCollection_Handle<FixedVExplorer> aFixedVExplorer = new FixedVExplorer(theVertex);
     Standard_Integer aIndex = myAttribute->GetVertexIndex(aFixedVExplorer);
index 6f469b83b1098dceee26c63ec4f9e7a051158bfb..41098452cf6cb7487bff6a29ea9182b031835ba9 100644 (file)
@@ -50,8 +50,13 @@ class BRepMesh_FastDiscretFace : public Standard_Transient
 {
 public:
   
+  //! Constructor.
+  //! @param theAngle deviation angle to be used for surface tessellation.
+  //! @param isInternalVerticesMode flag enabling/disabling internal 
+  //! vertices mode.
   Standard_EXPORT BRepMesh_FastDiscretFace(
-    const Standard_Real theAngle);
+    const Standard_Real    theAngle,
+    const Standard_Boolean isInternalVerticesMode);
 
   Standard_EXPORT void Perform(const Handle(BRepMesh_FaceAttribute)& theAttribute);
 
index 358a44b56addff8ef1f966bf96df4aa197c5f3db..31cbdfc1e72c70acd895f035e3695c8b41580c8b 100644 (file)
@@ -73,7 +73,8 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
 //=======================================================================
 BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
 : myRelative (Standard_False),
-  myInParallel (Standard_False)
+  myInParallel (Standard_False),
+  myInternalVerticesMode(Standard_True)
 {
 }
 
@@ -88,7 +89,8 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(
   const Standard_Real    theAngDeflection,
   const Standard_Boolean isInParallel)
   : myRelative  (isRelative),
-    myInParallel(isInParallel)
+    myInParallel(isInParallel),
+    myInternalVerticesMode(Standard_True)
 {
   myDeflection  = theLinDeflection;
   myAngle       = theAngDeflection;
@@ -143,7 +145,8 @@ void BRepMesh_IncrementalMesh::init()
   BRepMesh_ShapeTool::BoxMaxDimension(aBox, myMaxShapeSize);
 
   myMesh = new BRepMesh_FastDiscret(myDeflection, myAngle, aBox,
-    Standard_True, Standard_True, myRelative, Standard_True, myInParallel);
+    Standard_True, Standard_True, myRelative, Standard_True,
+    myInParallel, myInternalVerticesMode);
 
   myMesh->InitSharedFaces(myShape);
 }
index 879b9b8cf2bb7cb8d305b67e303764dfb0663237..a789fe387a8a7fbd80d28cee5f4d6943688edf9e 100644 (file)
@@ -103,6 +103,18 @@ public: //! @name accessing to parameters.
     return myInParallel;
   }
 
+  //! Enables/disables internal vertices mode.
+  inline void SetInternalVerticesMode(const Standard_Boolean isEnabled)
+  {
+    myInternalVerticesMode = isEnabled;
+  }
+  
+  //! Returns flag indicating is internal vertices mode enabled/disabled.
+  inline Standard_Boolean IsInternalVerticesMode() const
+  {
+    return myInternalVerticesMode;
+  }
+
 public: //! @name plugin API
 
   //! Plugin interface for the Mesh Factories.
@@ -193,6 +205,7 @@ protected:
   Standard_Real                               myMaxShapeSize;
   Standard_Integer                            myStatus;
   NCollection_Vector<TopoDS_Face>             myFaces;
+  Standard_Boolean                            myInternalVerticesMode;
 };
 
 DEFINE_STANDARD_HANDLE(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot)
index 519e01e29e3193a621e1221c677474609d0b55dd..30bdb557426434de1318f2d3023ea5b5e3ac0c6d 100644 (file)
@@ -130,6 +130,8 @@ options:\n\
         -a val          angular deflection in deg (default ~28.64 deg = 0.5 rad)\n\
         -relative       notifies that relative deflection is used\n\
                         (switched off by default)\n\
+        -int_vert_off   disables insertion of internal vertices into mesh\n\
+                        (enabled by default)\n\
         -parallel       enables parallel execution (switched off by default)\n";
     return 0;
   }
@@ -141,10 +143,11 @@ options:\n\
     return 0;
   }
 
-  Standard_Real aLinDeflection  = Max(Draw::Atof(argv[2]), Precision::Confusion());
-  Standard_Real aAngDeflection  = 0.5;
-  Standard_Boolean isRelative   = Standard_False;
-  Standard_Boolean isInParallel = Standard_False;
+  Standard_Real aLinDeflection   = Max(Draw::Atof(argv[2]), Precision::Confusion());
+  Standard_Real aAngDeflection   = 0.5;
+  Standard_Boolean isRelative    = Standard_False;
+  Standard_Boolean isInParallel  = Standard_False;
+  Standard_Boolean isIntVertices = Standard_True;
 
   if (nbarg > 3)
   {
@@ -160,6 +163,8 @@ options:\n\
         isRelative = Standard_True;
       else if (aOpt == "-parallel")
         isInParallel = Standard_True;
+      else if (aOpt == "-int_vert_off")
+        isIntVertices = Standard_False;
       else if (i < nbarg)
       {
         Standard_Real aVal = Draw::Atof(argv[i++]);
@@ -174,8 +179,14 @@ options:\n\
   di << "Incremental Mesh, multi-threading "
      << (isInParallel ? "ON" : "OFF") << "\n";
 
-  BRepMesh_IncrementalMesh aMesher(aShape, aLinDeflection, isRelative, 
-    aAngDeflection, isInParallel);
+  BRepMesh_IncrementalMesh aMesher;
+  aMesher.SetShape               (aShape);
+  aMesher.SetDeflection          (aLinDeflection);
+  aMesher.SetRelative            (isRelative);
+  aMesher.SetAngle               (aAngDeflection);
+  aMesher.SetParallel            (isInParallel);
+  aMesher.SetInternalVerticesMode(isIntVertices);
+  aMesher.Perform();
 
   di << "Meshing statuses: ";
   Standard_Integer statusFlags = aMesher.GetStatusFlags();
diff --git a/tests/bugs/mesh/bug21593 b/tests/bugs/mesh/bug21593
new file mode 100644 (file)
index 0000000..5387bdf
--- /dev/null
@@ -0,0 +1,41 @@
+# test for #21593: compare number of triangles/nodes
+# produced by BRepMesh for face with internal vertices
+# depening on value of InternalVerticesMode flag.
+
+restore [locate_data_file bug21593_internal_vertices.brep] a
+
+# enable internal vertices mode
+tclean a
+incmesh a 0.1
+set trinfo_a [trinfo a]
+regexp {([0-9]+) triangles} $trinfo_a str nbtriangles_a
+regexp {([0-9]+) nodes} $trinfo_a str nbnodes_a
+
+# check triangles
+if { $nbtriangles_a != 10 } {
+    puts "Error: incorrect number of triangles in case of internal vertices mode is ON ($nbtriangles_a)"
+}
+
+# check nodes
+if { $nbnodes_a != 8 } {
+    puts "Error: incorrect number of nodes in case of internal vertices mode is ON ($nbnodes_a)"
+}
+
+
+# disable internal vertices mode
+tclean a
+incmesh a 0.1 -int_vert_off
+set trinfo_a [trinfo a]
+regexp {([0-9]+) triangles} $trinfo_a str nbtriangles_a
+regexp {([0-9]+) nodes} $trinfo_a str nbnodes_a
+
+# check triangles
+if { $nbtriangles_a != 2 } {
+    puts "Error: incorrect number of triangles in case of internal vertices mode is OFF ($nbtriangles_a)"
+}
+
+# check nodes
+if { $nbnodes_a != 4 } {
+    puts "Error: incorrect number of nodes in case of internal vertices mode is OFF ($nbnodes_a)"
+}
+