mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
0026664: Triangulating a very small polygon fails
Parameter for adaptive computation of minimal 2D meshing precision added
This commit is contained in:
@@ -18,6 +18,12 @@
|
|||||||
#include <BRepMesh_ShapeTool.hxx>
|
#include <BRepMesh_ShapeTool.hxx>
|
||||||
#include <BRepMesh_Classifier.hxx>
|
#include <BRepMesh_Classifier.hxx>
|
||||||
#include <BRepTools.hxx>
|
#include <BRepTools.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopoDS_Wire.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_HANDLE (BRepMesh_FaceAttribute, Standard_Transient)
|
IMPLEMENT_STANDARD_HANDLE (BRepMesh_FaceAttribute, Standard_Transient)
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FaceAttribute, Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FaceAttribute, Standard_Transient)
|
||||||
@@ -34,6 +40,8 @@ BRepMesh_FaceAttribute::BRepMesh_FaceAttribute()
|
|||||||
myVMax (0.),
|
myVMax (0.),
|
||||||
myDeltaX (1.),
|
myDeltaX (1.),
|
||||||
myDeltaY (1.),
|
myDeltaY (1.),
|
||||||
|
myMinStep (-1.),
|
||||||
|
myAdaptiveMin (Standard_False),
|
||||||
myStatus (BRepMesh_NoError)
|
myStatus (BRepMesh_NoError)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
@@ -54,6 +62,8 @@ BRepMesh_FaceAttribute::BRepMesh_FaceAttribute(
|
|||||||
myVMax (0.),
|
myVMax (0.),
|
||||||
myDeltaX (1.),
|
myDeltaX (1.),
|
||||||
myDeltaY (1.),
|
myDeltaY (1.),
|
||||||
|
myMinStep (-1.),
|
||||||
|
myAdaptiveMin (Standard_False),
|
||||||
myStatus (BRepMesh_NoError),
|
myStatus (BRepMesh_NoError),
|
||||||
myBoundaryVertices(theBoundaryVertices),
|
myBoundaryVertices(theBoundaryVertices),
|
||||||
myBoundaryPoints (theBoundaryPoints),
|
myBoundaryPoints (theBoundaryPoints),
|
||||||
@@ -88,6 +98,30 @@ void BRepMesh_FaceAttribute::init()
|
|||||||
myFace.Orientation(TopAbs_FORWARD);
|
myFace.Orientation(TopAbs_FORWARD);
|
||||||
BRepTools::UVBounds(myFace, myUMin, myUMax, myVMin, myVMax);
|
BRepTools::UVBounds(myFace, myUMin, myUMax, myVMin, myVMax);
|
||||||
|
|
||||||
|
if(myAdaptiveMin) {
|
||||||
|
// compute minimal UV distance
|
||||||
|
// between vertices
|
||||||
|
|
||||||
|
myMinStep = RealLast();
|
||||||
|
for(TopExp_Explorer anExp(myFace, TopAbs_WIRE);anExp.More();anExp.Next()) {
|
||||||
|
TopoDS_Wire aWire = TopoDS::Wire(anExp.Current());
|
||||||
|
|
||||||
|
for (TopoDS_Iterator aWireExp(aWire);aWireExp.More();aWireExp.Next()) {
|
||||||
|
TopoDS_Edge anEdge = TopoDS::Edge(aWireExp.Value());
|
||||||
|
if(BRep_Tool::IsClosed(anEdge))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get end points on 2d curve
|
||||||
|
gp_Pnt2d aFirst2d, aLast2d;
|
||||||
|
BRep_Tool::UVPoints(anEdge, myFace, aFirst2d,aLast2d);
|
||||||
|
Standard_Real aDist =aFirst2d.Distance(aLast2d);
|
||||||
|
if(aDist < myMinStep)
|
||||||
|
myMinStep = aDist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BRepAdaptor_Surface aSurfAdaptor(myFace, Standard_False);
|
BRepAdaptor_Surface aSurfAdaptor(myFace, Standard_False);
|
||||||
mySurface = new BRepAdaptor_HSurface(aSurfAdaptor);
|
mySurface = new BRepAdaptor_HSurface(aSurfAdaptor);
|
||||||
}
|
}
|
||||||
@@ -113,7 +147,11 @@ Standard_Real BRepMesh_FaceAttribute::computeParametricTolerance(
|
|||||||
const Standard_Real theLastParam) const
|
const Standard_Real theLastParam) const
|
||||||
{
|
{
|
||||||
const Standard_Real aDeflectionUV = 1.e-05;
|
const Standard_Real aDeflectionUV = 1.e-05;
|
||||||
return Max(Precision::PConfusion(), (theLastParam - theFirstParam) * aDeflectionUV);
|
Standard_Real aPreci = (theLastParam - theFirstParam) * aDeflectionUV;
|
||||||
|
if(myAdaptiveMin && myMinStep < aPreci)
|
||||||
|
aPreci = myMinStep;
|
||||||
|
|
||||||
|
return Max(Precision::PConfusion(), aPreci);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -84,6 +84,15 @@ public: //! @name main geometrical properties.
|
|||||||
|
|
||||||
//! Returns V tolerance of face calculated regarding its parameters.
|
//! Returns V tolerance of face calculated regarding its parameters.
|
||||||
Standard_EXPORT Standard_Real ToleranceV() const;
|
Standard_EXPORT Standard_Real ToleranceV() const;
|
||||||
|
|
||||||
|
//! Returns modifiable adaptive parametric tolerance flag.
|
||||||
|
//! If this flag is set to true the minimal parametric tolerance
|
||||||
|
//! is computed taking minimal parametric distance between vertices
|
||||||
|
//! into account
|
||||||
|
inline Standard_Boolean& AdaptiveParametricTolerance()
|
||||||
|
{
|
||||||
|
return myAdaptiveMin;
|
||||||
|
}
|
||||||
|
|
||||||
//! Gives face deflection parameter.
|
//! Gives face deflection parameter.
|
||||||
inline Standard_Real GetDefFace() const
|
inline Standard_Real GetDefFace() const
|
||||||
@@ -361,7 +370,9 @@ private:
|
|||||||
Standard_Real myVMax; //!< Describes maximal value in V domain
|
Standard_Real myVMax; //!< Describes maximal value in V domain
|
||||||
Standard_Real myDeltaX;
|
Standard_Real myDeltaX;
|
||||||
Standard_Real myDeltaY;
|
Standard_Real myDeltaY;
|
||||||
|
Standard_Real myMinStep;
|
||||||
Standard_Integer myStatus;
|
Standard_Integer myStatus;
|
||||||
|
Standard_Boolean myAdaptiveMin;
|
||||||
|
|
||||||
BRepMesh::HDMapOfVertexInteger myBoundaryVertices;
|
BRepMesh::HDMapOfVertexInteger myBoundaryVertices;
|
||||||
BRepMesh::HDMapOfIntegerPnt myBoundaryPoints;
|
BRepMesh::HDMapOfIntegerPnt myBoundaryPoints;
|
||||||
|
@@ -101,6 +101,7 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(
|
|||||||
myRelative (theRelative),
|
myRelative (theRelative),
|
||||||
myShapetrigu (theShapetrigu),
|
myShapetrigu (theShapetrigu),
|
||||||
myInshape (theInshape),
|
myInshape (theInshape),
|
||||||
|
myAdaptiveMin(Standard_False),
|
||||||
myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
|
myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
|
||||||
myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
|
myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
|
||||||
myMinSize(theMinSize),
|
myMinSize(theMinSize),
|
||||||
@@ -135,6 +136,7 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(
|
|||||||
myRelative (theRelative),
|
myRelative (theRelative),
|
||||||
myShapetrigu (theShapetrigu),
|
myShapetrigu (theShapetrigu),
|
||||||
myInshape (theInshape),
|
myInshape (theInshape),
|
||||||
|
myAdaptiveMin(Standard_False),
|
||||||
myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
|
myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
|
||||||
myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
|
myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
|
||||||
myMinSize(theMinSize),
|
myMinSize(theMinSize),
|
||||||
@@ -249,6 +251,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
|||||||
|
|
||||||
myAttributes.Bind(theFace, myAttribute);
|
myAttributes.Bind(theFace, myAttribute);
|
||||||
}
|
}
|
||||||
|
myAttribute->AdaptiveParametricTolerance() = myAdaptiveMin;
|
||||||
|
|
||||||
BRepMesh::HIMapOfInteger& aVertexEdgeMap = myAttribute->ChangeVertexEdgeMap();
|
BRepMesh::HIMapOfInteger& aVertexEdgeMap = myAttribute->ChangeVertexEdgeMap();
|
||||||
BRepMesh::HDMapOfShapePairOfPolygon& aInternalEdges = myAttribute->ChangeInternalEdges();
|
BRepMesh::HDMapOfShapePairOfPolygon& aInternalEdges = myAttribute->ChangeInternalEdges();
|
||||||
|
@@ -115,6 +115,15 @@ public:
|
|||||||
Process(face);
|
Process(face);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Returns modifiable adaptive parametric tolerance flag.
|
||||||
|
//! If this flag is set to true the minimal parametric tolerance
|
||||||
|
//! is computed taking minimal parametric distance between vertices
|
||||||
|
//! into account
|
||||||
|
inline Standard_Boolean& AdaptiveParametricTolerance()
|
||||||
|
{
|
||||||
|
return myAdaptiveMin;
|
||||||
|
}
|
||||||
|
|
||||||
//! Request algorithm to launch in multiple threads <br>
|
//! Request algorithm to launch in multiple threads <br>
|
||||||
//! to improve performance (should be supported by plugin). <br>
|
//! to improve performance (should be supported by plugin). <br>
|
||||||
inline void SetParallel(const Standard_Boolean theInParallel)
|
inline void SetParallel(const Standard_Boolean theInParallel)
|
||||||
@@ -362,6 +371,7 @@ private:
|
|||||||
Standard_Boolean myRelative;
|
Standard_Boolean myRelative;
|
||||||
Standard_Boolean myShapetrigu;
|
Standard_Boolean myShapetrigu;
|
||||||
Standard_Boolean myInshape;
|
Standard_Boolean myInshape;
|
||||||
|
Standard_Boolean myAdaptiveMin;
|
||||||
TopTools_DataMapOfShapeReal myMapdefle;
|
TopTools_DataMapOfShapeReal myMapdefle;
|
||||||
|
|
||||||
// Data shared for whole shape
|
// Data shared for whole shape
|
||||||
|
@@ -70,6 +70,7 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
|
|||||||
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
|
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
|
||||||
: myRelative (Standard_False),
|
: myRelative (Standard_False),
|
||||||
myInParallel(Standard_False),
|
myInParallel(Standard_False),
|
||||||
|
myAdaptiveMin(Standard_False),
|
||||||
myMinSize (Precision::Confusion()),
|
myMinSize (Precision::Confusion()),
|
||||||
myInternalVerticesMode(Standard_True),
|
myInternalVerticesMode(Standard_True),
|
||||||
myIsControlSurfaceDeflection(Standard_True)
|
myIsControlSurfaceDeflection(Standard_True)
|
||||||
@@ -88,6 +89,7 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(
|
|||||||
const Standard_Boolean isInParallel)
|
const Standard_Boolean isInParallel)
|
||||||
: myRelative (isRelative),
|
: myRelative (isRelative),
|
||||||
myInParallel(isInParallel),
|
myInParallel(isInParallel),
|
||||||
|
myAdaptiveMin(Standard_False),
|
||||||
myMinSize (Precision::Confusion()),
|
myMinSize (Precision::Confusion()),
|
||||||
myInternalVerticesMode(Standard_True),
|
myInternalVerticesMode(Standard_True),
|
||||||
myIsControlSurfaceDeflection(Standard_True)
|
myIsControlSurfaceDeflection(Standard_True)
|
||||||
@@ -149,6 +151,8 @@ void BRepMesh_IncrementalMesh::init()
|
|||||||
myRelative, Standard_True, myInParallel, myMinSize,
|
myRelative, Standard_True, myInParallel, myMinSize,
|
||||||
myInternalVerticesMode, myIsControlSurfaceDeflection);
|
myInternalVerticesMode, myIsControlSurfaceDeflection);
|
||||||
|
|
||||||
|
myMesh->AdaptiveParametricTolerance() = myAdaptiveMin;
|
||||||
|
|
||||||
myMesh->InitSharedFaces(myShape);
|
myMesh->InitSharedFaces(myShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,7 +78,16 @@ public: //! @name accessing to parameters.
|
|||||||
{
|
{
|
||||||
return myRelative;
|
return myRelative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Returns modifiable adaptive parametric tolerance flag.
|
||||||
|
//! If this flag is set to true the minimal parametric tolerance
|
||||||
|
//! is computed taking minimal parametric distance between vertices
|
||||||
|
//! into account
|
||||||
|
inline Standard_Boolean& AdaptiveParametricTolerance()
|
||||||
|
{
|
||||||
|
return myAdaptiveMin;
|
||||||
|
}
|
||||||
|
|
||||||
//! Returns modified flag.
|
//! Returns modified flag.
|
||||||
inline Standard_Boolean IsModified() const
|
inline Standard_Boolean IsModified() const
|
||||||
{
|
{
|
||||||
@@ -227,6 +236,7 @@ protected:
|
|||||||
BRepMesh::DMapOfEdgeListOfTriangulationBool myEdges;
|
BRepMesh::DMapOfEdgeListOfTriangulationBool myEdges;
|
||||||
Handle(BRepMesh_FastDiscret) myMesh;
|
Handle(BRepMesh_FastDiscret) myMesh;
|
||||||
Standard_Boolean myModified;
|
Standard_Boolean myModified;
|
||||||
|
Standard_Boolean myAdaptiveMin;
|
||||||
TopTools_DataMapOfShapeReal myEdgeDeflection;
|
TopTools_DataMapOfShapeReal myEdgeDeflection;
|
||||||
Standard_Real myMaxShapeSize;
|
Standard_Real myMaxShapeSize;
|
||||||
Standard_Integer myStatus;
|
Standard_Integer myStatus;
|
||||||
|
@@ -139,7 +139,8 @@ options:\n\
|
|||||||
(enabled by default)\n\
|
(enabled by default)\n\
|
||||||
-surf_def_off disables control of deflection of mesh from real\n\
|
-surf_def_off disables control of deflection of mesh from real\n\
|
||||||
surface (enabled by default)\n\
|
surface (enabled by default)\n\
|
||||||
-parallel enables parallel execution (switched off by default)\n";
|
-parallel enables parallel execution (switched off by default)\n\
|
||||||
|
-adaptive enables adaptive computation of minimal value in parametric space\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +158,7 @@ options:\n\
|
|||||||
Standard_Boolean isInParallel = Standard_False;
|
Standard_Boolean isInParallel = Standard_False;
|
||||||
Standard_Boolean isIntVertices = Standard_True;
|
Standard_Boolean isIntVertices = Standard_True;
|
||||||
Standard_Boolean isControlSurDef = Standard_True;
|
Standard_Boolean isControlSurDef = Standard_True;
|
||||||
|
Standard_Boolean isAdaptiveMin = Standard_False;
|
||||||
|
|
||||||
if (nbarg > 3)
|
if (nbarg > 3)
|
||||||
{
|
{
|
||||||
@@ -176,6 +178,8 @@ options:\n\
|
|||||||
isIntVertices = Standard_False;
|
isIntVertices = Standard_False;
|
||||||
else if (aOpt == "-surf_def_off")
|
else if (aOpt == "-surf_def_off")
|
||||||
isControlSurDef = Standard_False;
|
isControlSurDef = Standard_False;
|
||||||
|
else if (aOpt == "-adaptive")
|
||||||
|
isAdaptiveMin = Standard_True;
|
||||||
else if (i < nbarg)
|
else if (i < nbarg)
|
||||||
{
|
{
|
||||||
Standard_Real aVal = Draw::Atof(argv[i++]);
|
Standard_Real aVal = Draw::Atof(argv[i++]);
|
||||||
@@ -201,6 +205,7 @@ options:\n\
|
|||||||
aMesher.SetMinSize (aMinSize);
|
aMesher.SetMinSize (aMinSize);
|
||||||
aMesher.SetInternalVerticesMode(isIntVertices);
|
aMesher.SetInternalVerticesMode(isIntVertices);
|
||||||
aMesher.SetControlSurfaceDeflection(isControlSurDef);
|
aMesher.SetControlSurfaceDeflection(isControlSurDef);
|
||||||
|
aMesher.AdaptiveParametricTolerance() = isAdaptiveMin;
|
||||||
aMesher.Perform();
|
aMesher.Perform();
|
||||||
|
|
||||||
di << "Meshing statuses: ";
|
di << "Meshing statuses: ";
|
||||||
|
Reference in New Issue
Block a user