mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0026664: Triangulating a very small polygon fails
Parameter for adaptive computation of minimal 2D meshing precision added in BRepMesh_IncrementalMesh API. Corresponding option -adaptive added in DRAW command All meshing parameters are collected in structure, BRepMesh_FastDiscret::Parameters, which is now used to define and manipulate parameters of the algorithm.
This commit is contained in:
@@ -21,9 +21,7 @@
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepMesh_DiscretRoot::BRepMesh_DiscretRoot()
|
||||
: myDeflection (0.001),
|
||||
myAngle (0.1),
|
||||
myIsDone (Standard_False)
|
||||
: myIsDone (Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -28,30 +28,6 @@ public:
|
||||
//! Destructor
|
||||
Standard_EXPORT virtual ~BRepMesh_DiscretRoot();
|
||||
|
||||
//! Setup linear deflection.
|
||||
inline void SetDeflection(const Standard_Real theDeflection)
|
||||
{
|
||||
myDeflection = theDeflection;
|
||||
}
|
||||
|
||||
//! Returns linear deflection.
|
||||
inline Standard_Real Deflection() const
|
||||
{
|
||||
return myDeflection;
|
||||
}
|
||||
|
||||
//! Setup angular deflection.
|
||||
inline void SetAngle(const Standard_Real theAngle)
|
||||
{
|
||||
myAngle = theAngle;
|
||||
}
|
||||
|
||||
//! Returns angular deflection.
|
||||
inline Standard_Real Angle() const
|
||||
{
|
||||
return myAngle;
|
||||
}
|
||||
|
||||
//! Set the shape to triangulate.
|
||||
inline void SetShape(const TopoDS_Shape& theShape)
|
||||
{
|
||||
@@ -94,8 +70,6 @@ protected:
|
||||
|
||||
Standard_EXPORT virtual void init();
|
||||
|
||||
Standard_Real myDeflection;
|
||||
Standard_Real myAngle;
|
||||
TopoDS_Shape myShape;
|
||||
Standard_Boolean myIsDone;
|
||||
};
|
||||
|
@@ -18,6 +18,12 @@
|
||||
#include <BRepMesh_ShapeTool.hxx>
|
||||
#include <BRepMesh_Classifier.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>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
@@ -32,7 +38,9 @@ BRepMesh_FaceAttribute::BRepMesh_FaceAttribute()
|
||||
myVMax (0.),
|
||||
myDeltaX (1.),
|
||||
myDeltaY (1.),
|
||||
myStatus (BRepMesh_NoError)
|
||||
myMinStep (-1.),
|
||||
myStatus (BRepMesh_NoError),
|
||||
myAdaptiveMin (Standard_False)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -44,7 +52,8 @@ BRepMesh_FaceAttribute::BRepMesh_FaceAttribute()
|
||||
BRepMesh_FaceAttribute::BRepMesh_FaceAttribute(
|
||||
const TopoDS_Face& theFace,
|
||||
const BRepMesh::HDMapOfVertexInteger& theBoundaryVertices,
|
||||
const BRepMesh::HDMapOfIntegerPnt& theBoundaryPoints)
|
||||
const BRepMesh::HDMapOfIntegerPnt& theBoundaryPoints,
|
||||
const Standard_Boolean theAdaptiveMin)
|
||||
: myDefFace (0.),
|
||||
myUMin (0.),
|
||||
myUMax (0.),
|
||||
@@ -52,7 +61,9 @@ BRepMesh_FaceAttribute::BRepMesh_FaceAttribute(
|
||||
myVMax (0.),
|
||||
myDeltaX (1.),
|
||||
myDeltaY (1.),
|
||||
myMinStep (-1.),
|
||||
myStatus (BRepMesh_NoError),
|
||||
myAdaptiveMin (theAdaptiveMin),
|
||||
myBoundaryVertices(theBoundaryVertices),
|
||||
myBoundaryPoints (theBoundaryPoints),
|
||||
myFace (theFace)
|
||||
@@ -86,6 +97,32 @@ void BRepMesh_FaceAttribute::init()
|
||||
myFace.Orientation(TopAbs_FORWARD);
|
||||
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);
|
||||
mySurface = new BRepAdaptor_HSurface(aSurfAdaptor);
|
||||
}
|
||||
@@ -111,7 +148,11 @@ Standard_Real BRepMesh_FaceAttribute::computeParametricTolerance(
|
||||
const Standard_Real theLastParam) const
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -29,19 +29,19 @@ class BRepMesh_FaceAttribute : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Standard_EXPORT BRepMesh_FaceAttribute();
|
||||
|
||||
//! Constructor.
|
||||
//! @param theFace face the attribute is created for.
|
||||
//! Used for default initialization. Attribute keeps reference
|
||||
//! to the source face with forward orientation.
|
||||
//! @param theBoundaryVertices shared map of shape vertices.
|
||||
//! @param theBoundaryPoints shared discretization points of shape boundaries.
|
||||
//! @param theAdaptiveMin switches on adaptive computation of minimal parametric
|
||||
//! tolerance (if true).
|
||||
Standard_EXPORT BRepMesh_FaceAttribute(
|
||||
const TopoDS_Face& theFace,
|
||||
const BRepMesh::HDMapOfVertexInteger& theBoundaryVertices,
|
||||
const BRepMesh::HDMapOfIntegerPnt& theBoundaryPoints);
|
||||
const BRepMesh::HDMapOfIntegerPnt& theBoundaryPoints,
|
||||
const Standard_Boolean theAdaptiveMin);
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT virtual ~BRepMesh_FaceAttribute();
|
||||
@@ -54,11 +54,6 @@ public: //! @name main geometrical properties.
|
||||
return mySurface;
|
||||
}
|
||||
|
||||
//! Sets reference face.
|
||||
inline void SetFace(const TopoDS_Face& theFace)
|
||||
{
|
||||
myFace = theFace;
|
||||
}
|
||||
|
||||
//! Returns forward oriented face to be used for calculations.
|
||||
inline const TopoDS_Face& Face() const
|
||||
@@ -326,6 +321,9 @@ public: //! @name Auxiliary methods
|
||||
|
||||
private:
|
||||
|
||||
//! Default constructor.
|
||||
BRepMesh_FaceAttribute();
|
||||
|
||||
//! Assignment operator.
|
||||
void operator =(const BRepMesh_FaceAttribute& /*theOther*/)
|
||||
{
|
||||
@@ -360,7 +358,9 @@ private:
|
||||
Standard_Real myVMax; //!< Describes maximal value in V domain
|
||||
Standard_Real myDeltaX;
|
||||
Standard_Real myDeltaY;
|
||||
Standard_Real myMinStep;
|
||||
Standard_Integer myStatus;
|
||||
Standard_Boolean myAdaptiveMin;
|
||||
|
||||
BRepMesh::HDMapOfVertexInteger myBoundaryVertices;
|
||||
BRepMesh::HDMapOfIntegerPnt myBoundaryPoints;
|
||||
|
@@ -73,76 +73,22 @@
|
||||
|
||||
#define UVDEFLECTION 1.e-05
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepMesh_FastDiscret
|
||||
//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 theMinSize,
|
||||
const Standard_Boolean isInternalVerticesMode,
|
||||
const Standard_Boolean isControlSurfaceDeflection)
|
||||
: myAngle (theAngl),
|
||||
myDeflection (theDefle),
|
||||
myWithShare (theWithShare),
|
||||
myInParallel (isInParallel),
|
||||
myRelative (theRelative),
|
||||
myShapetrigu (theShapetrigu),
|
||||
myInshape (theInshape),
|
||||
BRepMesh_FastDiscret::BRepMesh_FastDiscret( const Bnd_Box& theBox,
|
||||
const BRepMesh_FastDiscret::Parameters& theParams)
|
||||
:
|
||||
myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
|
||||
myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
|
||||
myMinSize(theMinSize),
|
||||
myInternalVerticesMode(isInternalVerticesMode),
|
||||
myIsControlSurfaceDeflection(isControlSurfaceDeflection)
|
||||
{
|
||||
if ( myRelative )
|
||||
myParameters(theParams),
|
||||
myDtotale(0.)
|
||||
{
|
||||
if ( myParameters.Relative )
|
||||
BRepMesh_ShapeTool::BoxMaxDimension(theBox, myDtotale);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//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,
|
||||
const Standard_Real theMinSize,
|
||||
const Standard_Boolean isInternalVerticesMode,
|
||||
const Standard_Boolean isControlSurfaceDeflection)
|
||||
: myAngle (theAngl),
|
||||
myDeflection (theDefle),
|
||||
myWithShare (theWithShare),
|
||||
myInParallel (isInParallel),
|
||||
myRelative (theRelative),
|
||||
myShapetrigu (theShapetrigu),
|
||||
myInshape (theInshape),
|
||||
myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
|
||||
myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
|
||||
myMinSize(theMinSize),
|
||||
myInternalVerticesMode(isInternalVerticesMode),
|
||||
myIsControlSurfaceDeflection(isControlSurfaceDeflection)
|
||||
{
|
||||
if ( myRelative )
|
||||
BRepMesh_ShapeTool::BoxMaxDimension(theBox, myDtotale);
|
||||
|
||||
Perform(theShape);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InitSharedFaces
|
||||
//purpose :
|
||||
@@ -169,7 +115,7 @@ void BRepMesh_FastDiscret::Perform(const TopoDS_Shape& theShape)
|
||||
aFaces.push_back(aFace);
|
||||
}
|
||||
|
||||
OSD_Parallel::ForEach(aFaces.begin(), aFaces.end(), *this, !myInParallel);
|
||||
OSD_Parallel::ForEach(aFaces.begin(), aFaces.end(), *this, !myParameters.InParallel);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,8 +132,8 @@ void BRepMesh_FastDiscret::Process(const TopoDS_Face& theFace) const
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
|
||||
BRepMesh_FastDiscretFace aTool(GetAngle(), myMinSize,
|
||||
myInternalVerticesMode, myIsControlSurfaceDeflection);
|
||||
BRepMesh_FastDiscretFace aTool(myParameters.Angle, myParameters.MinSize,
|
||||
myParameters.InternalVerticesMode, myParameters.ControlSurfaceDeflection);
|
||||
aTool.Perform(anAttribute);
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
@@ -241,32 +187,25 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
if (myAttribute.IsNull())
|
||||
{
|
||||
myAttribute = new BRepMesh_FaceAttribute(theFace,
|
||||
myBoundaryVertices, myBoundaryPoints);
|
||||
myBoundaryVertices, myBoundaryPoints,myParameters.AdaptiveMin);
|
||||
|
||||
myAttributes.Bind(theFace, myAttribute);
|
||||
}
|
||||
|
||||
|
||||
BRepMesh::HIMapOfInteger& aVertexEdgeMap = myAttribute->ChangeVertexEdgeMap();
|
||||
BRepMesh::HDMapOfShapePairOfPolygon& aInternalEdges = myAttribute->ChangeInternalEdges();
|
||||
|
||||
resetDataStructure();
|
||||
|
||||
if (!myWithShare)
|
||||
{
|
||||
myEdges.Clear();
|
||||
myBoundaryVertices->Clear();
|
||||
myBoundaryPoints->Clear();
|
||||
}
|
||||
|
||||
Standard_Real defedge;
|
||||
Standard_Integer nbEdge = 0;
|
||||
Standard_Real savangle = myAngle;
|
||||
Standard_Real savangle = myParameters.Angle;
|
||||
Standard_Real cdef;
|
||||
Standard_Real maxdef = 2.* BRepMesh_ShapeTool::MaxFaceTolerance(theFace);
|
||||
|
||||
Standard_Real defface = 0.;
|
||||
if (!myRelative)
|
||||
defface = Max(myDeflection, maxdef);
|
||||
if (!myParameters.Relative)
|
||||
defface = Max(myParameters.Deflection, maxdef);
|
||||
|
||||
NCollection_Sequence<EdgePCurve> aPCurves;
|
||||
NCollection_Sequence<TopoDS_Edge> aFaceEdges;
|
||||
@@ -282,7 +221,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
|
||||
if (!myMapdefle.IsBound(aEdge))
|
||||
{
|
||||
if (myRelative)
|
||||
if (myParameters.Relative)
|
||||
{
|
||||
if (myEdges.IsBound(aEdge))
|
||||
{
|
||||
@@ -293,9 +232,9 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
else
|
||||
{
|
||||
defedge = BRepMesh_ShapeTool::RelativeEdgeDeflection(
|
||||
aEdge, myDeflection, myDtotale, cdef);
|
||||
aEdge, myParameters.Deflection, myDtotale, cdef);
|
||||
|
||||
myAngle = savangle * cdef;
|
||||
myParameters.Angle = savangle * cdef;
|
||||
}
|
||||
|
||||
defface += defedge;
|
||||
@@ -303,7 +242,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
}
|
||||
else
|
||||
{
|
||||
defedge = myDeflection;
|
||||
defedge = myParameters.Deflection;
|
||||
}
|
||||
|
||||
defedge = Max(maxdef, defedge);
|
||||
@@ -313,7 +252,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
else
|
||||
{
|
||||
defedge = myMapdefle(aEdge);
|
||||
if ( myRelative )
|
||||
if ( myParameters.Relative )
|
||||
{
|
||||
defface += defedge;
|
||||
defface = Max(maxdef, defface);
|
||||
@@ -332,7 +271,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
aFaceEdges.Append(aEdge);
|
||||
|
||||
add(aEdge, aPCurve, defedge);
|
||||
myAngle = savangle;
|
||||
myParameters.Angle = savangle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,22 +282,21 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
return myAttribute->GetStatus();
|
||||
}
|
||||
|
||||
if ( myRelative )
|
||||
if ( myParameters.Relative )
|
||||
{
|
||||
defface = defface / nbEdge;
|
||||
}
|
||||
else
|
||||
{
|
||||
defface = myDeflection;
|
||||
defface = myParameters.Deflection;
|
||||
}
|
||||
|
||||
if ( myWithShare )
|
||||
defface = Max(maxdef, defface);
|
||||
defface = Max(maxdef, defface);
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLoc);
|
||||
|
||||
if (!myShapetrigu || aTriangulation.IsNull())
|
||||
if ( aTriangulation.IsNull() )
|
||||
{
|
||||
Standard_Real xCur, yCur;
|
||||
Standard_Real maxX, minX, maxY, minY;
|
||||
@@ -451,7 +389,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
BRepMesh::HClassifier& aClassifier = myAttribute->ChangeClassifier();
|
||||
BRepMesh_WireChecker aDFaceChecker(aFace, aTol, aInternalEdges,
|
||||
aVertexEdgeMap, myAttribute->ChangeStructure(),
|
||||
myumin, myumax, myvmin, myvmax, myInParallel );
|
||||
myumin, myumax, myvmin, myvmax, myParameters.InParallel );
|
||||
|
||||
aDFaceChecker.ReCompute(aClassifier);
|
||||
BRepMesh_Status aCheckStatus = aDFaceChecker.Status();
|
||||
@@ -556,7 +494,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
|
||||
Dv = Max(1.0e0 - (defface/r),0.0e0) ;
|
||||
Standard_Real oldDv = 2.0 * ACos (Dv);
|
||||
oldDv = Min(oldDv, myAngle);
|
||||
oldDv = Min(oldDv, myParameters.Angle);
|
||||
Dv = 0.9*oldDv; //TWOTHIRD * oldDv;
|
||||
Dv = oldDv;
|
||||
|
||||
@@ -568,7 +506,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
{
|
||||
Du = Max(1.0e0 - (defface/ru),0.0e0);
|
||||
Du = (2.0 * ACos (Du));
|
||||
Du = Min(Du, myAngle);
|
||||
Du = Min(Du, myParameters.Angle);
|
||||
Standard_Real aa = sqrt(Du*Du + oldDv*oldDv);
|
||||
|
||||
if (aa < gp::Resolution())
|
||||
@@ -604,8 +542,8 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
Du = 0.0;
|
||||
|
||||
Du = 2.0 * ACos (Du);
|
||||
if (Du > GetAngle())
|
||||
Du = GetAngle();
|
||||
if (Du > myParameters.Angle)
|
||||
Du = myParameters.Angle;
|
||||
|
||||
deltaX = Du / longv;
|
||||
deltaY = 1.;
|
||||
@@ -861,7 +799,7 @@ void BRepMesh_FastDiscret::update(
|
||||
if (aEdgeTool.IsNull())
|
||||
{
|
||||
aEdgeTool = new BRepMesh_EdgeTessellator(theEdge, myAttribute,
|
||||
mySharedFaces, theDefEdge, myAngle, myMinSize);
|
||||
mySharedFaces, theDefEdge, myParameters.Angle, myParameters.MinSize);
|
||||
}
|
||||
|
||||
Standard_Integer ipf, ivf, isvf, ipl, ivl, isvl;
|
||||
|
@@ -53,45 +53,68 @@ class BRepMesh_FaceAttribute;
|
||||
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,
|
||||
const Standard_Real theMinSize = Precision::Confusion(),
|
||||
const Standard_Boolean isInternalVerticesMode = Standard_True,
|
||||
const Standard_Boolean isControlSurfaceDeflection = Standard_True);
|
||||
|
||||
//! if the boolean <relative> is True, the <br>
|
||||
//! deflection used for the polygonalisation of <br>
|
||||
//! each edge will be <defle> * Size of Edge. <br>
|
||||
//! the deflection used for the faces will be the maximum <br>
|
||||
//! deflection of their edges. <br>
|
||||
//! <br>
|
||||
//! if <shapetrigu> is True, the triangulation, if exists <br>
|
||||
//! with a correct deflection, can be used to re-triangulate <br>
|
||||
//! the shape. <br>
|
||||
//! <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,
|
||||
const Standard_Real theMinSize = Precision::Confusion(),
|
||||
const Standard_Boolean isInternalVerticesMode = Standard_True,
|
||||
const Standard_Boolean isControlSurfaceDeflection = Standard_True);
|
||||
|
||||
//! Structure storing meshing parameters
|
||||
struct Parameters {
|
||||
|
||||
//! Default constructor
|
||||
Parameters()
|
||||
:
|
||||
Angle(0.1),
|
||||
Deflection(0.001),
|
||||
MinSize(Precision::Confusion()),
|
||||
InParallel(Standard_False),
|
||||
Relative(Standard_False),
|
||||
AdaptiveMin(Standard_False),
|
||||
InternalVerticesMode(Standard_True),
|
||||
ControlSurfaceDeflection(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
//! Angular deflection
|
||||
Standard_Real Angle;
|
||||
|
||||
//! Deflection
|
||||
Standard_Real Deflection;
|
||||
|
||||
//! Minimal allowed size of mesh element
|
||||
Standard_Real MinSize;
|
||||
|
||||
//! Switches on/off multy thread computation
|
||||
Standard_Boolean InParallel;
|
||||
|
||||
//! Switches on/off relative computation of edge tolerance<br>
|
||||
//! If trur, deflection used for the polygonalisation of each edge will be
|
||||
//! <defle> * Size of Edge. The deflection used for the faces will be the
|
||||
//! maximum deflection of their edges.
|
||||
Standard_Boolean Relative;
|
||||
|
||||
//! Adaptive parametric tolerance flag. <br>
|
||||
//! If this flag is set to true the minimal parametric tolerance
|
||||
//! is computed taking minimal parametric distance between vertices
|
||||
//! into account
|
||||
Standard_Boolean AdaptiveMin;
|
||||
|
||||
//! Mode to take or ont to take internal face vertices into account
|
||||
//! in triangulation process
|
||||
Standard_Boolean InternalVerticesMode;
|
||||
|
||||
//! Prameter to check the deviation of triangulation and interior of
|
||||
//! the face
|
||||
Standard_Boolean ControlSurfaceDeflection;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//! Constructor.
|
||||
//! Sets the meshing parameters and updates
|
||||
//! relative defletion according to bounding box
|
||||
//! @param B - bounding box encompasing shape
|
||||
//! @param theParams - meshing algo parameters
|
||||
Standard_EXPORT BRepMesh_FastDiscret (const Bnd_Box& B,
|
||||
const Parameters& theParams);
|
||||
|
||||
//! Build triangulation on the whole shape.
|
||||
Standard_EXPORT void Perform(const TopoDS_Shape& shape);
|
||||
@@ -106,51 +129,24 @@ public:
|
||||
//! parallel threads.
|
||||
Standard_EXPORT void Process(const TopoDS_Face& face) const;
|
||||
|
||||
void operator ()(const TopoDS_Face& face) const
|
||||
void operator () (const TopoDS_Face& face) const
|
||||
{
|
||||
Process(face);
|
||||
}
|
||||
|
||||
//! Request algorithm to launch in multiple threads <br>
|
||||
//! to improve performance (should be supported by plugin). <br>
|
||||
inline void SetParallel(const Standard_Boolean theInParallel)
|
||||
//! Returns parameters of meshing
|
||||
inline const Parameters& MeshParameters() const
|
||||
{
|
||||
myInParallel = theInParallel;
|
||||
}
|
||||
|
||||
//! Returns the multi-threading usage flag. <br>
|
||||
inline Standard_Boolean IsParallel() const
|
||||
{
|
||||
return myInParallel;
|
||||
}
|
||||
|
||||
//! returns the deflection value. <br>
|
||||
inline Standard_Real GetDeflection() const
|
||||
{
|
||||
return myDeflection;
|
||||
return myParameters;
|
||||
}
|
||||
|
||||
//! returns the deflection value. <br>
|
||||
inline Standard_Real GetAngle() const
|
||||
//! Returns modificable mesh parameters
|
||||
inline Parameters& ChangeMeshParameters()
|
||||
{
|
||||
return myAngle;
|
||||
return myParameters;
|
||||
}
|
||||
|
||||
|
||||
inline Standard_Boolean WithShare() const
|
||||
{
|
||||
return myWithShare;
|
||||
}
|
||||
|
||||
inline Standard_Boolean InShape() const
|
||||
{
|
||||
return myInshape;
|
||||
}
|
||||
|
||||
inline Standard_Boolean ShapeTrigu() const
|
||||
{
|
||||
return myShapetrigu;
|
||||
}
|
||||
|
||||
Standard_EXPORT void InitSharedFaces(const TopoDS_Shape& theShape);
|
||||
|
||||
inline const TopTools_IndexedDataMapOfShapeListOfShape& SharedFaces() const
|
||||
@@ -348,16 +344,9 @@ private:
|
||||
private:
|
||||
|
||||
TopoDS_Face myFace;
|
||||
Standard_Real myAngle;
|
||||
Standard_Real myDeflection;
|
||||
Standard_Real myDtotale;
|
||||
Standard_Boolean myWithShare;
|
||||
Standard_Boolean myInParallel;
|
||||
|
||||
BRepMesh::DMapOfShapePairOfPolygon myEdges;
|
||||
BRepMesh::DMapOfFaceAttribute myAttributes;
|
||||
Standard_Boolean myRelative;
|
||||
Standard_Boolean myShapetrigu;
|
||||
Standard_Boolean myInshape;
|
||||
TopTools_DataMapOfShapeReal myMapdefle;
|
||||
|
||||
// Data shared for whole shape
|
||||
@@ -368,9 +357,9 @@ private:
|
||||
Handle(BRepMesh_FaceAttribute) myAttribute;
|
||||
TopTools_IndexedDataMapOfShapeListOfShape mySharedFaces;
|
||||
|
||||
Standard_Real myMinSize;
|
||||
Standard_Boolean myInternalVerticesMode;
|
||||
Standard_Boolean myIsControlSurfaceDeflection;
|
||||
Parameters myParameters;
|
||||
|
||||
Standard_Real myDtotale;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(BRepMesh_FastDiscret, Standard_Transient)
|
||||
|
@@ -66,11 +66,9 @@ namespace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
|
||||
: myRelative (Standard_False),
|
||||
myInParallel(Standard_False),
|
||||
myMinSize (Precision::Confusion()),
|
||||
myInternalVerticesMode(Standard_True),
|
||||
myIsControlSurfaceDeflection(Standard_True)
|
||||
: myMaxShapeSize(0.),
|
||||
myModified(Standard_False),
|
||||
myStatus(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -78,20 +76,34 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(
|
||||
const TopoDS_Shape& theShape,
|
||||
const Standard_Real theLinDeflection,
|
||||
const Standard_Boolean isRelative,
|
||||
const Standard_Real theAngDeflection,
|
||||
const Standard_Boolean isInParallel)
|
||||
: myRelative (isRelative),
|
||||
myInParallel(isInParallel),
|
||||
myMinSize (Precision::Confusion()),
|
||||
myInternalVerticesMode(Standard_True),
|
||||
myIsControlSurfaceDeflection(Standard_True)
|
||||
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape& theShape,
|
||||
const Standard_Real theLinDeflection,
|
||||
const Standard_Boolean isRelative,
|
||||
const Standard_Real theAngDeflection,
|
||||
const Standard_Boolean isInParallel,
|
||||
const Standard_Boolean adaptiveMin)
|
||||
: myMaxShapeSize(0.),
|
||||
myModified(Standard_False),
|
||||
myStatus(0)
|
||||
{
|
||||
myParameters.Deflection = theLinDeflection;
|
||||
myParameters.Relative = isRelative;
|
||||
myParameters.Angle = theAngDeflection;
|
||||
myParameters.InParallel = isInParallel;
|
||||
myParameters.AdaptiveMin = adaptiveMin;
|
||||
|
||||
myShape = theShape;
|
||||
Perform();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape,
|
||||
const BRepMesh_FastDiscret::Parameters& theParameters)
|
||||
: myParameters(theParameters)
|
||||
{
|
||||
myDeflection = theLinDeflection;
|
||||
myAngle = theAngDeflection;
|
||||
myShape = theShape;
|
||||
|
||||
Perform();
|
||||
@@ -142,11 +154,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, myMinSize,
|
||||
myInternalVerticesMode, myIsControlSurfaceDeflection);
|
||||
|
||||
myMesh = new BRepMesh_FastDiscret (aBox, myParameters);
|
||||
|
||||
myMesh->InitSharedFaces(myShape);
|
||||
}
|
||||
|
||||
@@ -217,7 +226,7 @@ void BRepMesh_IncrementalMesh::update()
|
||||
update(aFaceIt.Value());
|
||||
|
||||
// Mesh faces
|
||||
OSD_Parallel::ForEach(myFaces.begin(), myFaces.end(), *myMesh, !myInParallel);
|
||||
OSD_Parallel::ForEach(myFaces.begin(), myFaces.end(), *myMesh, !myParameters.InParallel);
|
||||
|
||||
commit();
|
||||
clear();
|
||||
@@ -244,8 +253,8 @@ void BRepMesh_IncrementalMesh::discretizeFreeEdges()
|
||||
|
||||
BRepAdaptor_Curve aCurve(aEdge);
|
||||
GCPnts_TangentialDeflection aDiscret(aCurve, aCurve.FirstParameter(),
|
||||
aCurve.LastParameter(), myAngle, aEdgeDeflection, 2,
|
||||
Precision::PConfusion(), myMinSize);
|
||||
aCurve.LastParameter(), myParameters.Angle, aEdgeDeflection, 2,
|
||||
Precision::PConfusion(), myParameters.MinSize);
|
||||
|
||||
Standard_Integer aNodesNb = aDiscret.NbPoints();
|
||||
TColgp_Array1OfPnt aNodes (1, aNodesNb);
|
||||
@@ -257,7 +266,7 @@ void BRepMesh_IncrementalMesh::discretizeFreeEdges()
|
||||
}
|
||||
|
||||
aPoly3D = new Poly_Polygon3D(aNodes, aUVNodes);
|
||||
aPoly3D->Deflection(myDeflection);
|
||||
aPoly3D->Deflection(myParameters.Deflection);
|
||||
|
||||
BRep_Builder aBuilder;
|
||||
aBuilder.UpdateEdge(aEdge, aPoly3D);
|
||||
@@ -275,14 +284,14 @@ Standard_Real BRepMesh_IncrementalMesh::edgeDeflection(
|
||||
return myEdgeDeflection(theEdge);
|
||||
|
||||
Standard_Real aEdgeDeflection;
|
||||
if (myRelative)
|
||||
if ( myParameters.Relative )
|
||||
{
|
||||
Standard_Real aScale;
|
||||
aEdgeDeflection = BRepMesh_ShapeTool::RelativeEdgeDeflection(theEdge,
|
||||
myDeflection, myMaxShapeSize, aScale);
|
||||
myParameters.Deflection, myMaxShapeSize, aScale);
|
||||
}
|
||||
else
|
||||
aEdgeDeflection = myDeflection;
|
||||
aEdgeDeflection = myParameters.Deflection;
|
||||
|
||||
myEdgeDeflection.Bind(theEdge, aEdgeDeflection);
|
||||
return aEdgeDeflection;
|
||||
@@ -295,8 +304,8 @@ Standard_Real BRepMesh_IncrementalMesh::edgeDeflection(
|
||||
Standard_Real BRepMesh_IncrementalMesh::faceDeflection(
|
||||
const TopoDS_Face& theFace)
|
||||
{
|
||||
if (!myRelative)
|
||||
return myDeflection;
|
||||
if ( !myParameters.Relative )
|
||||
return myParameters.Deflection;
|
||||
|
||||
Standard_Integer aEdgesNb = 0;
|
||||
Standard_Real aFaceDeflection = 0.;
|
||||
@@ -308,7 +317,7 @@ Standard_Real BRepMesh_IncrementalMesh::faceDeflection(
|
||||
aFaceDeflection += edgeDeflection(aEdge);
|
||||
}
|
||||
|
||||
return (aEdgesNb == 0) ? myDeflection : (aFaceDeflection / aEdgesNb);
|
||||
return (aEdgesNb == 0) ? myParameters.Deflection : (aFaceDeflection / aEdgesNb);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -546,10 +555,10 @@ Standard_Integer BRepMesh_IncrementalMesh::Discret(
|
||||
BRepMesh_DiscretRoot* &theAlgo)
|
||||
{
|
||||
BRepMesh_IncrementalMesh* anAlgo = new BRepMesh_IncrementalMesh();
|
||||
anAlgo->SetDeflection(theDeflection);
|
||||
anAlgo->SetAngle (theAngle);
|
||||
anAlgo->ChangeParameters().Deflection = theDeflection;
|
||||
anAlgo->ChangeParameters().Angle = theAngle;
|
||||
anAlgo->ChangeParameters().InParallel = IS_IN_PARALLEL;
|
||||
anAlgo->SetShape (theShape);
|
||||
anAlgo->SetParallel (IS_IN_PARALLEL);
|
||||
theAlgo = anAlgo;
|
||||
return 0; // no error
|
||||
}
|
||||
|
@@ -54,28 +54,33 @@ public: //! @name mesher API
|
||||
Standard_EXPORT BRepMesh_IncrementalMesh(
|
||||
const TopoDS_Shape& theShape,
|
||||
const Standard_Real theLinDeflection,
|
||||
const Standard_Boolean isRelative = Standard_False,
|
||||
const Standard_Boolean isRelative = Standard_False,
|
||||
const Standard_Real theAngDeflection = 0.5,
|
||||
const Standard_Boolean isInParallel = Standard_False);
|
||||
const Standard_Boolean isInParallel = Standard_False,
|
||||
const Standard_Boolean adaptiveMin = Standard_False);
|
||||
|
||||
//! Constructor.
|
||||
//! Automatically calls method Perform.
|
||||
//! @param theShape shape to be meshed.
|
||||
//! @param theParameters - parameters of meshing
|
||||
Standard_EXPORT BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
|
||||
const BRepMesh_FastDiscret::Parameters& theParameters);
|
||||
|
||||
//! Performs meshing ot the shape.
|
||||
Standard_EXPORT virtual void Perform();
|
||||
|
||||
public: //! @name accessing to parameters.
|
||||
|
||||
//! Enables using relative deflection.
|
||||
//! @param isRelative if TRUE deflection used for discretization of
|
||||
//! each edge will be <theLinDeflection> * <size of edge>. Deflection
|
||||
//! used for the faces will be the maximum deflection of their edges.
|
||||
inline void SetRelative(const Standard_Boolean isRelative)
|
||||
//! Returns meshing parameters
|
||||
inline const BRepMesh_FastDiscret::Parameters& Parameters() const
|
||||
{
|
||||
myRelative = isRelative;
|
||||
return myParameters;
|
||||
}
|
||||
|
||||
//! Returns relative deflection flag.
|
||||
inline Standard_Boolean IsRelative() const
|
||||
|
||||
//! Returns modifiable meshing parameters
|
||||
inline BRepMesh_FastDiscret::Parameters& ChangeParameters()
|
||||
{
|
||||
return myRelative;
|
||||
return myParameters;
|
||||
}
|
||||
|
||||
//! Returns modified flag.
|
||||
@@ -90,55 +95,6 @@ public: //! @name accessing to parameters.
|
||||
return myStatus;
|
||||
}
|
||||
|
||||
//! Request algorithm to launch in multiple threads to improve performance.
|
||||
inline void SetParallel(const Standard_Boolean isInParallel)
|
||||
{
|
||||
myInParallel = isInParallel;
|
||||
}
|
||||
|
||||
//! Returns the multi-threading usage flag.
|
||||
inline Standard_Boolean IsParallel() const
|
||||
{
|
||||
return myInParallel;
|
||||
}
|
||||
|
||||
//! Sets min size parameter.
|
||||
inline void SetMinSize(const Standard_Real theMinSize)
|
||||
{
|
||||
myMinSize = Max(theMinSize, Precision::Confusion());
|
||||
}
|
||||
|
||||
//! Returns min size parameter.
|
||||
inline Standard_Real GetMinSize() const
|
||||
{
|
||||
return myMinSize;
|
||||
}
|
||||
|
||||
//! Enables/disables internal vertices mode (enabled by default).
|
||||
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;
|
||||
}
|
||||
|
||||
//! Enables/disables control of deflection of mesh from real surface
|
||||
//! (enabled by default).
|
||||
inline void SetControlSurfaceDeflection(const Standard_Boolean isEnabled)
|
||||
{
|
||||
myIsControlSurfaceDeflection = isEnabled;
|
||||
}
|
||||
|
||||
//! Returns flag indicating is adaptive reconfiguration
|
||||
//! of mesh enabled/disabled.
|
||||
inline Standard_Boolean IsControlSurfaceDeflection() const
|
||||
{
|
||||
return myIsControlSurfaceDeflection;
|
||||
}
|
||||
|
||||
public: //! @name plugin API
|
||||
|
||||
@@ -221,18 +177,16 @@ private:
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Boolean myRelative;
|
||||
Standard_Boolean myInParallel;
|
||||
BRepMesh::DMapOfEdgeListOfTriangulationBool myEdges;
|
||||
Handle(BRepMesh_FastDiscret) myMesh;
|
||||
Standard_Boolean myModified;
|
||||
TopTools_DataMapOfShapeReal myEdgeDeflection;
|
||||
Standard_Real myMaxShapeSize;
|
||||
Standard_Integer myStatus;
|
||||
NCollection_Vector<TopoDS_Face> myFaces;
|
||||
Standard_Real myMinSize;
|
||||
Standard_Boolean myInternalVerticesMode;
|
||||
Standard_Boolean myIsControlSurfaceDeflection;
|
||||
|
||||
BRepMesh_FastDiscret::Parameters myParameters;
|
||||
|
||||
Standard_Real myMaxShapeSize;
|
||||
Standard_Boolean myModified;
|
||||
Standard_Integer myStatus;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot)
|
||||
|
Reference in New Issue
Block a user