1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

0031461: Mesh - Add possibility to force the meshing of the shape

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).
This commit is contained in:
oan
2023-01-16 14:58:19 +03:00
parent 805ecb0df3
commit f3dae035ef
4 changed files with 72 additions and 8 deletions

View 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

View 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);

View 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 :

View 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