]> OCCT Git - occt.git/commitdiff
0031461: Mesh - Add possibility to force the meshing of the shape
authoroan <oan@opencascade.com>
Mon, 16 Jan 2023 11:58:19 +0000 (14:58 +0300)
committeroan <oan@opencascade.com>
Mon, 16 Jan 2023 11:58:19 +0000 (14:58 +0300)
BRepMesh: Add new mesh parameter *AllowQualityDecrease* which affects the criteria used for checking of the consistency of the existing mesh to new meshing parameters.
So if set to true it will force the meshing of the shape if current deflection strongly vary from the new one, no matter in which side.

BRepTools::Clean: Keep triangulation on non-geometric shapes (faces with no surface or edges with no curves).

src/BRep/BRep_Tool.cxx
src/BRep/BRep_Tool.hxx
src/BRepTools/BRepTools.cxx
src/BRepTools/BRepTools.hxx

index d4bade16eb9393c7de9bb8e09204defe79aec95b..defb2cdcde72c0225a643fc9fc3f96fde61f6ee1 100644 (file)
@@ -206,6 +206,17 @@ Handle(Geom_Curve)  BRep_Tool::Curve(const TopoDS_Edge& E,
   return C;
 }
 
+//=======================================================================
+//function : IsGeometric
+//purpose  : Returns True if <F> has a surface.
+//=======================================================================
+Standard_Boolean BRep_Tool::IsGeometric (const TopoDS_Face& F)
+{
+  const BRep_TFace* TF = static_cast<const BRep_TFace*>(F.TShape().get());
+  const Handle(Geom_Surface)& S = TF->Surface();
+  return !S.IsNull();
+}
+
 //=======================================================================
 //function : IsGeometric
 //purpose  : Returns True if <E> is a 3d curve or a curve on
index fa6efbe69da873e759625fb6782c00a9a2b7a4cb..12c061cde98977e6385777e99601ad2085777e01 100644 (file)
@@ -74,6 +74,9 @@ public:
   //! Returns the  NaturalRestriction  flag of the  face.
   Standard_EXPORT static Standard_Boolean NaturalRestriction (const TopoDS_Face& F);
   
+  //! Returns True if <F> has a surface, false otherwise.
+  Standard_EXPORT static Standard_Boolean IsGeometric (const TopoDS_Face& F);
+
   //! Returns True if <E> is a 3d curve or a curve on
   //! surface.
   Standard_EXPORT static Standard_Boolean IsGeometric (const TopoDS_Edge& E);
index ae2cb9dce432330961e964590439cc55a6f8e788..eb178570defb5a0757b0c55caaf0837ecfccb9ae 100644 (file)
@@ -62,6 +62,7 @@
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Wire.hxx>
 #include <TopTools_SequenceOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
 #include <GeomLib_CheckCurveOnSurface.hxx>
 #include <errno.h>
 //=======================================================================
@@ -843,19 +844,36 @@ Standard_Boolean BRepTools::Read(TopoDS_Shape& Sh,
 //purpose  : 
 //=======================================================================
 
-void BRepTools::Clean(const TopoDS_Shape& theShape)
+void BRepTools::Clean (const TopoDS_Shape& theShape)
 {
+  if (theShape.IsNull())
+    return;
+
   BRep_Builder aBuilder;
   Handle(Poly_Triangulation) aNullTriangulation;
   Handle(Poly_PolygonOnTriangulation) aNullPoly;
 
-  if (theShape.IsNull())
-    return;
+  TopTools_MapOfShape aShapeMap;
+  const TopLoc_Location anEmptyLoc;
 
   TopExp_Explorer aFaceIt(theShape, TopAbs_FACE);
   for (; aFaceIt.More(); aFaceIt.Next())
   {
-    const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
+    TopoDS_Shape aFaceNoLoc = aFaceIt.Current();
+    aFaceNoLoc.Location (anEmptyLoc);
+    if (!aShapeMap.Add (aFaceNoLoc))
+    {
+      // the face has already been processed
+      continue;
+    }
+
+    const TopoDS_Face& aFace = TopoDS::Face (aFaceIt.Current());
+    if (!BRep_Tool::IsGeometric (aFace))
+    {
+      // Do not remove triangulation as there is no surface to recompute it.
+      continue;
+    }
+
 
     TopLoc_Location aLoc;
     const Handle(Poly_Triangulation)& aTriangulation =
@@ -865,6 +883,10 @@ void BRepTools::Clean(const TopoDS_Shape& theShape)
       continue;
 
     // Nullify edges
+    // Theoretically, the edges on the face (with surface) may have no geometry
+    // (no curve 3d or 2d or both). Such faces should be considered as invalid and
+    // are not supported by current implementation. So, both triangulation of the face
+    // and polygon on triangulation of the edges are removed unconditionally.
     TopExp_Explorer aEdgeIt(aFace, TopAbs_EDGE);
     for (; aEdgeIt.More(); aEdgeIt.Next())
     {
@@ -874,8 +896,34 @@ void BRepTools::Clean(const TopoDS_Shape& theShape)
 
     aBuilder.UpdateFace(aFace, aNullTriangulation);
   }
-}
 
+  // Iterate over all edges seeking for 3d polygons
+  Handle (Poly_Polygon3D) aNullPoly3d;
+  TopExp_Explorer aEdgeIt (theShape, TopAbs_EDGE);
+  for (; aEdgeIt.More (); aEdgeIt.Next ())
+  {
+    TopoDS_Edge anEdgeNoLoc = TopoDS::Edge (aEdgeIt.Current());
+    anEdgeNoLoc.Location (anEmptyLoc);
+
+    if (!aShapeMap.Add (anEdgeNoLoc))
+    {
+      // the edge has already been processed
+      continue;
+    }
+    if (!BRep_Tool::IsGeometric (TopoDS::Edge (anEdgeNoLoc)))
+    {
+      // Do not remove polygon 3d as there is no curve to recompute it.
+      continue;
+    }
+
+    TopLoc_Location aLoc;
+    Handle (Poly_Polygon3D) aPoly3d = BRep_Tool::Polygon3D (anEdgeNoLoc, aLoc);
+    if (aPoly3d.IsNull())
+      continue;
+
+    aBuilder.UpdateEdge (anEdgeNoLoc, aNullPoly3d);
+  }
+}
 //=======================================================================
 //function : RemoveUnusedPCurves
 //purpose  : 
index cc49cc1044bcec0d40f62c75ba0ce72c0bcd5c54..74ca6749e263eb9deec371b8b8eae02ecde55840 100644 (file)
@@ -152,9 +152,11 @@ public:
   //! same point at there common extremity.
   Standard_EXPORT static void UpdateFaceUVPoints (const TopoDS_Face& F);
   
-  //! Removes all the triangulations of the faces of <S>
-  //! and removes all polygons on triangulations of the
-  //! edges.
+  //! Removes all cashed polygonal representation of the shape,
+  //! i.e. the triangulations of the faces of <S> and polygons on
+  //! triangulations and polygons 3d of the edges.
+  //! In case polygonal representation is the only available representation
+  //! for the shape (shape does not have geometry) it is not removed.
   Standard_EXPORT static void Clean (const TopoDS_Shape& S);
   
   //! Removes all the pcurves of the edges of <S> that