#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>
IMPLEMENT_STANDARD_HANDLE (BRepMesh_FaceAttribute, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FaceAttribute, Standard_Transient)
myVMax (0.),
myDeltaX (1.),
myDeltaY (1.),
+ myMinStep (-1.),
+ myAdaptiveMin (Standard_False),
myStatus (BRepMesh_NoError)
{
init();
myVMax (0.),
myDeltaX (1.),
myDeltaY (1.),
+ myMinStep (-1.),
+ myAdaptiveMin (Standard_False),
myStatus (BRepMesh_NoError),
myBoundaryVertices(theBoundaryVertices),
myBoundaryPoints (theBoundaryPoints),
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);
}
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);
}
//=======================================================================
//! Returns V tolerance of face calculated regarding its parameters.
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.
inline Standard_Real GetDefFace() const
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;
myRelative (theRelative),
myShapetrigu (theShapetrigu),
myInshape (theInshape),
+ myAdaptiveMin(Standard_False),
myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
myMinSize(theMinSize),
myRelative (theRelative),
myShapetrigu (theShapetrigu),
myInshape (theInshape),
+ myAdaptiveMin(Standard_False),
myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
myMinSize(theMinSize),
myAttributes.Bind(theFace, myAttribute);
}
+ myAttribute->AdaptiveParametricTolerance() = myAdaptiveMin;
BRepMesh::HIMapOfInteger& aVertexEdgeMap = myAttribute->ChangeVertexEdgeMap();
BRepMesh::HDMapOfShapePairOfPolygon& aInternalEdges = myAttribute->ChangeInternalEdges();
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>
//! to improve performance (should be supported by plugin). <br>
inline void SetParallel(const Standard_Boolean theInParallel)
Standard_Boolean myRelative;
Standard_Boolean myShapetrigu;
Standard_Boolean myInshape;
+ Standard_Boolean myAdaptiveMin;
TopTools_DataMapOfShapeReal myMapdefle;
// Data shared for whole shape
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
: myRelative (Standard_False),
myInParallel(Standard_False),
+ myAdaptiveMin(Standard_False),
myMinSize (Precision::Confusion()),
myInternalVerticesMode(Standard_True),
myIsControlSurfaceDeflection(Standard_True)
const Standard_Boolean isInParallel)
: myRelative (isRelative),
myInParallel(isInParallel),
+ myAdaptiveMin(Standard_False),
myMinSize (Precision::Confusion()),
myInternalVerticesMode(Standard_True),
myIsControlSurfaceDeflection(Standard_True)
myRelative, Standard_True, myInParallel, myMinSize,
myInternalVerticesMode, myIsControlSurfaceDeflection);
+ myMesh->AdaptiveParametricTolerance() = myAdaptiveMin;
+
myMesh->InitSharedFaces(myShape);
}
{
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.
inline Standard_Boolean IsModified() const
{
BRepMesh::DMapOfEdgeListOfTriangulationBool myEdges;
Handle(BRepMesh_FastDiscret) myMesh;
Standard_Boolean myModified;
+ Standard_Boolean myAdaptiveMin;
TopTools_DataMapOfShapeReal myEdgeDeflection;
Standard_Real myMaxShapeSize;
Standard_Integer myStatus;
(enabled by default)\n\
-surf_def_off disables control of deflection of mesh from real\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;
}
Standard_Boolean isInParallel = Standard_False;
Standard_Boolean isIntVertices = Standard_True;
Standard_Boolean isControlSurDef = Standard_True;
+ Standard_Boolean isAdaptiveMin = Standard_False;
if (nbarg > 3)
{
isIntVertices = Standard_False;
else if (aOpt == "-surf_def_off")
isControlSurDef = Standard_False;
+ else if (aOpt == "-adaptive")
+ isAdaptiveMin = Standard_True;
else if (i < nbarg)
{
Standard_Real aVal = Draw::Atof(argv[i++]);
aMesher.SetMinSize (aMinSize);
aMesher.SetInternalVerticesMode(isIntVertices);
aMesher.SetControlSurfaceDeflection(isControlSurDef);
+ aMesher.AdaptiveParametricTolerance() = isAdaptiveMin;
aMesher.Perform();
di << "Meshing statuses: ";