1) Reduce the number of calls to malloc by grouping requests to larger blocks. To achieve this goal, the following ways are used:
- Containers of types sequence, list and map are initialized with an instance of NCollection_IncAllocator, at this taking care of the time of life of allocated objects, so that not to occupy huge amount of memory.
- Allocation of several arrays having the same and short life time is changed so that to allocate a buffer array of necessary size and to place arrays in this buffer.
2) In BRepMesh_FastDiscretFace, optimize the function filterParameters so that to avoid excess memory allocations.
3) In NCollection_CellFilter, change declaration of the method Reset to accept array by reference rather than by value.
4) Add Allocator() method in map, sequence and vector collection classes by analogy with list collection.
5) Correct the size of block for IncAllocator for x64 platform. In order free-ed block to be returned to the system its size should be at least 1024K on x64 and 512K on x86. This allows to retain free virtual space almost to the state before algorithm run.
6) Decrease amount of memory zeroed by calloc. For that, reduce theIncrement parameter of the embedded vectors of the classes NCollection_UBTreeFiller and BRepMesh_VertexInspector to default value 256.
7) Avoid computing bounding box when not necessary (if no relative deflection is used)
8) Cycles by wires of face using TopExp_Explorer are converted to use TopoDS_Iterator instead.
9) BRepMesh_FastDiscret::Add optimized to avoid storing sequences of faces and edges
10) The tests "mesh standard_* W7" are corrected to accept the new behavior. Earlier the following error took place:
Not connected mesh inside face 9
{12 13}
Now this error was replaced with another one:
free nodes (in pairs: face / node):
{9 12}
Actually it is not a regression, rather improvement, if we look at the snapshot.
11) Change other test cases to their actual state.
Standard_Integer nu,nv,nc;
nu=mySurface->NbUIntervals(S);
nv=mySurface->NbVIntervals(S);
+ nc=myCurve->NbIntervals(S);
+
+ // Allocate the memory for arrays TabU, TabV, TabC only once using the buffer TabBuf.
+ TColStd_Array1OfReal TabBuf(1, nu + nv + nc + 3);
+ TColStd_Array1OfReal TabU(TabBuf(1), 1, nu+1);
+ TColStd_Array1OfReal TabV(TabBuf(nu + 2), 1, nv+1);
+ TColStd_Array1OfReal TabC(TabBuf(nu + nv + 3), 1, nc+1);
- TColStd_Array1OfReal TabU(1,nu+1);
- TColStd_Array1OfReal TabV(1,nv+1);
Standard_Integer NbSample = 20;
Standard_Real U,V,Tdeb,Tfin;
Tdeb=myCurve->FirstParameter();
Tfin=myCurve->LastParameter();
- nc=myCurve->NbIntervals(S);
- TColStd_Array1OfReal TabC(1,nc+1);
myCurve->Intervals(TabC,S);
Standard_Real Tol= Precision::PConfusion()/10;
TopTools_ListOfShape& LF)
{
LF.Clear();
- TopTools_ListOfShape LTri,LPlan,LCyl,LCon,LSphere,LTor,LOther;
+ // Use the allocator of the result LF for intermediate results
+ TopTools_ListOfShape LTri(LF.Allocator()), LPlan(LF.Allocator()),
+ LCyl(LF.Allocator()), LCon(LF.Allocator()), LSphere(LF.Allocator()),
+ LTor(LF.Allocator()), LOther(LF.Allocator());
TopExp_Explorer exp(Sh,TopAbs_FACE);
TopLoc_Location l;
- Handle(Geom_Surface) S;
for (; exp.More(); exp.Next()) {
const TopoDS_Face& F = TopoDS::Face(exp.Current());
- S = BRep_Tool::Surface(F, l);
+ const Handle(Geom_Surface)& S = BRep_Tool::Surface(F, l);
if (!S.IsNull()) {
- if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
- S = Handle(Geom_RectangularTrimmedSurface)::DownCast (S)->BasisSurface();
- }
GeomAdaptor_Surface AS(S);
switch (AS.GetType()) {
case GeomAbs_Plane:
namespace BRepMesh
{
- //! Default size for memory block allocated by IncAllocator.
+ //! Default size for memory block allocated by IncAllocator.
+ /**
+ * The idea here is that blocks of the given size are returned to the system
+ * rather than retained in the malloc heap, at least on WIN32 and WIN64 platforms.
+ */
+#ifdef _WIN64
+ const size_t MEMORY_BLOCK_SIZE_HUGE = 1024 * 1024;
+#else
const size_t MEMORY_BLOCK_SIZE_HUGE = 512 * 1024;
+#endif
//! Structure keeping parameters of segment.
struct Segment
const Handle(NCollection_IncAllocator)& theAllocator,
const Standard_Integer theReservedNodeSize)
: myAllocator (theAllocator),
- myNodes (new BRepMesh_VertexTool(theReservedNodeSize, myAllocator)),
+ myNodes (new BRepMesh_VertexTool(myAllocator)),
+ myNodeLinks (theReservedNodeSize * 3, myAllocator),
myLinks (theReservedNodeSize * 3, myAllocator),
myDelLinks (myAllocator),
myElements (theReservedNodeSize * 2, myAllocator),
Handle(NCollection_IncAllocator) aAllocator =
new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE);
- BRepMesh::MapOfIntegerInteger aLoopEdges(10, aAllocator);
-
Standard_Real aTolU, aTolV;
myMeshData->Data()->GetTolerance(aTolU, aTolV);
const Standard_Real aSqTol = aTolU * aTolU + aTolV * aTolV;
Standard_Integer anUpper = theVertexIndexes.Upper();
for( ; anIndex <= anUpper; ++anIndex )
{
- aLoopEdges.Clear();
aAllocator->Reset(Standard_False);
+ BRepMesh::MapOfIntegerInteger aLoopEdges(10, aAllocator);
Standard_Integer aVertexIdx = theVertexIndexes( anIndex );
const BRepMesh_Vertex& aVertex = GetVertex( aVertexIdx );
for(;;)
{
+ aAllocator->Reset(Standard_False);
BRepMesh::MapOfIntegerInteger aLoopEdges(10, aAllocator);
BRepMesh::MapOfInteger aDelTriangles(10, aAllocator);
myMeshData->RemoveLink( aLoopEdgesIt.Key() );
}
- aAllocator->Reset(Standard_False);
if ( aDeletedTrianglesNb == 0 )
break;
}
BRepMesh::HMapOfInteger BRepMesh_Delaun::getEdgesByType(
const BRepMesh_DegreeOfFreedom theEdgeType ) const
{
- BRepMesh::HMapOfInteger aResult = new BRepMesh::MapOfInteger;
+ Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
+ BRepMesh::HMapOfInteger aResult = new BRepMesh::MapOfInteger(1, anAlloc);
BRepMesh::MapOfInteger::Iterator anEdgeIt( myMeshData->LinksOfDomain() );
for ( ; anEdgeIt.More(); anEdgeIt.Next() )
#include <TopoDS_Iterator.hxx>
#include <BRep_Tool.hxx>
-
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FaceAttribute,Standard_Transient)
//=======================================================================
// between vertices
myMinStep = RealLast();
- for (TopExp_Explorer anExp(myFace, TopAbs_WIRE); anExp.More(); anExp.Next())
+ for (TopoDS_Iterator aFaceIt(myFace); aFaceIt.More(); aFaceIt.Next())
{
- TopoDS_Wire aWire = TopoDS::Wire(anExp.Current());
-
- for (TopoDS_Iterator aWireExp(aWire); aWireExp.More(); aWireExp.Next())
+ for (TopoDS_Iterator aWireIt(aFaceIt.Value()); aWireIt.More(); aWireIt.Next())
{
- TopoDS_Edge anEdge = TopoDS::Edge(aWireExp.Value());
- if (BRep_Tool::IsClosed(anEdge))
+ const TopoDS_Edge& anEdge = TopoDS::Edge(aWireIt.Value());
+ if (anEdge.IsNull() || BRep_Tool::IsClosed(anEdge))
continue;
// Get end points on 2d curve
#include <Extrema_LocateExtPC.hxx>
#include <TColStd_Array1OfInteger.hxx>
+#include <TColStd_Array1OfCharacter.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColGeom2d_SequenceOfCurve.hxx>
BRepMesh_FastDiscret::BRepMesh_FastDiscret( const Bnd_Box& theBox,
const BRepMesh_FastDiscret::Parameters& theParams)
:
+ myMapdefle(1000, new NCollection_IncAllocator()),
myBoundaryVertices(new BRepMesh::DMapOfVertexInteger),
myBoundaryPoints(new BRepMesh::DMapOfIntegerPnt),
myParameters(theParams),
resetDataStructure();
- Standard_Real defedge;
+ Standard_Real defedge = myParameters.Deflection;
Standard_Integer nbEdge = 0;
Standard_Real savangle = myParameters.Angle;
Standard_Real cdef;
if (!myParameters.Relative)
defface = Max(myParameters.Deflection, maxdef);
- NCollection_Sequence<EdgePCurve> aPCurves;
- NCollection_Sequence<TopoDS_Edge> aFaceEdges;
-
const TopoDS_Face& aFace = myAttribute->Face();
- const Handle(BRepAdaptor_HSurface)& gFace = myAttribute->Surface();
- TopExp_Explorer aWireIt(aFace, TopAbs_WIRE);
- for (; aWireIt.More(); aWireIt.Next())
+ for (TopoDS_Iterator aWireIt(aFace); aWireIt.More(); aWireIt.Next())
{
- TopExp_Explorer aEdgeIt(aWireIt.Current(), TopAbs_EDGE);
- for (; aEdgeIt.More(); aEdgeIt.Next(), ++nbEdge)
+ for (TopoDS_Iterator aEdgeIt(aWireIt.Value()); aEdgeIt.More(); aEdgeIt.Next(), ++nbEdge)
{
- const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
+ const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Value());
+ if (aEdge.IsNull())
+ continue;
if (!myMapdefle.IsBound(aEdge))
{
if (myParameters.Relative)
continue;
EdgePCurve aPCurve = { aCurve2d, aFirstParam, aLastParam };
- aPCurves.Append(aPCurve);
- aFaceEdges.Append(aEdge);
add(aEdge, aPCurve, defedge);
myParameters.Angle = savangle;
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLoc);
+ const Handle(BRepAdaptor_HSurface)& gFace = myAttribute->Surface();
if ( aTriangulation.IsNull() )
{
++nbmaill;
resetDataStructure();
- for (Standard_Integer j = 1; j <= aFaceEdges.Length(); ++j)
- {
- const TopoDS_Edge& anEdge = aFaceEdges(j);
- if (myEdges.IsBound(anEdge))
- myEdges.UnBind(anEdge);
- defedge = Max(myMapdefle(anEdge) / 3.0, eps);
- myMapdefle.Bind(anEdge, defedge);
-
- add(anEdge, aPCurves(j), defedge);
+ for (TopoDS_Iterator aWireIt(aFace); aWireIt.More(); aWireIt.Next())
+ {
+ for (TopoDS_Iterator aEdgeIt(aWireIt.Value()); aEdgeIt.More(); aEdgeIt.Next(), ++nbEdge)
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge(aEdgeIt.Value());
+ if (anEdge.IsNull())
+ continue;
+ if (myEdges.IsBound(anEdge))
+ myEdges.UnBind(anEdge);
+
+ defedge = Max(myMapdefle(anEdge) / 3.0, eps);
+ myMapdefle.Bind(anEdge, defedge);
+
+ Standard_Real aFirstParam, aLastParam;
+ Handle(Geom2d_Curve) aCurve2d =
+ BRep_Tool::CurveOnSurface(anEdge, aFace, aFirstParam, aLastParam);
+ if (aCurve2d.IsNull())
+ continue;
+
+ EdgePCurve aPCurve = { aCurve2d, aFirstParam, aLastParam };
+ add(anEdge, aPCurve, defedge);
+ }
}
aDFaceChecker.ReCompute(aClassifier);
Handle(Poly_PolygonOnTriangulation) P1, P2;
if (BRepMesh_ShapeTool::IsDegenerated(theEdge, aFace))
{
- const Standard_Integer aNodesNb = 2;
- TColStd_Array1OfInteger aNewNodes (1, aNodesNb);
- TColStd_Array1OfInteger aNewNodInStruct(1, aNodesNb);
- TColStd_Array1OfReal aNewParams (1, aNodesNb);
-
- aNewNodInStruct(1) = ipf;
- aNewNodes (1) = isvf;
- aNewParams (1) = aEAttr.FirstParam;
-
- aNewNodInStruct(aNodesNb) = ipl;
- aNewNodes (aNodesNb) = isvl;
- aNewParams (aNodesNb) = aEAttr.LastParam;
+ // two nodes
+ Standard_Integer aNewNodesArr[] = {isvf, isvl};
+ Standard_Integer aNewNodInStructArr[] = {ipf, ipl};
+ Standard_Real aNewParamsArr[] = {aEAttr.FirstParam, aEAttr.LastParam};
+ TColStd_Array1OfInteger aNewNodes (aNewNodesArr[0], 1, 2);
+ TColStd_Array1OfInteger aNewNodInStruct(aNewNodInStructArr[0], 1, 2);
+ TColStd_Array1OfReal aNewParams (aNewParamsArr[0], 1, 2);
P1 = new Poly_PolygonOnTriangulation(aNewNodes, aNewParams);
P2 = new Poly_PolygonOnTriangulation(aNewNodInStruct, aNewParams);
else
{
const Standard_Integer aNodesNb = aEdgeTool->NbPoints();
- TColStd_Array1OfInteger aNewNodesVec (1, aNodesNb);
- TColStd_Array1OfInteger aNewNodesInStructVec(1, aNodesNb);
- TColStd_Array1OfReal aNewParamsVec (1, aNodesNb);
+ // Allocate the memory for arrays aNewNodesVec, aNewNodesInStructVec, aNewParamsVec
+ // only once using the buffer aBuf.
+ TColStd_Array1OfCharacter aBuf(1, aNodesNb * (2*sizeof(Standard_Integer) + sizeof(Standard_Real)));
+ TColStd_Array1OfInteger aNewNodesVec(*reinterpret_cast<const Standard_Integer*>
+ (&aBuf(1)), 1, aNodesNb);
+ TColStd_Array1OfInteger aNewNodesInStructVec(*reinterpret_cast<const Standard_Integer*>
+ (&aBuf(1 + aNodesNb*sizeof(Standard_Integer))), 1, aNodesNb);
+ TColStd_Array1OfReal aNewParamsVec(*reinterpret_cast<const Standard_Real*>
+ (&aBuf(1 + aNodesNb*2*sizeof(Standard_Integer))), 1, aNodesNb);
Standard_Integer aNodesCount = 1;
aNewNodesInStructVec(aNodesCount) = ipf;
myStructure->Data()->SetTolerance( aTolU / deltaX, aTolV / deltaY);
myAttribute->ChangeStructure() = myStructure;
- myAttribute->ChangeSurfacePoints() = new BRepMesh::DMapOfIntegerPnt;
- myAttribute->ChangeSurfaceVertices()= new BRepMesh::DMapOfVertexInteger;
+ myAttribute->ChangeSurfacePoints() = new BRepMesh::DMapOfIntegerPnt(1, aAllocator);
+ myAttribute->ChangeSurfaceVertices()= new BRepMesh::DMapOfVertexInteger(1, aAllocator);
// Check the necessity to fill the map of parameters
const Handle(BRepAdaptor_HSurface)& gFace = myAttribute->Surface();
thetype == GeomAbs_BSplineSurface);
const Standard_Boolean useUVParam = (thetype == GeomAbs_Torus || IsCompexSurface (thetype));
- myUParam.Clear();
- myVParam.Clear();
+ myUParam.Clear(aAllocator);
+ myVParam.Clear(aAllocator);
// essai de determination de la longueur vraie:
// akm (bug OCC16) : We must calculate these measures in non-singular
Standard_Real aDef = -1;
if ( !isaline && myStructure->ElementsOfDomain().Extent() > 0 )
{
- BRepMesh::ListOfVertex aNewVertices;
+ Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
+ BRepMesh::ListOfVertex aNewVertices(anAlloc);
if (!rajout)
{
aDef = control(aNewVertices, trigu, Standard_True);
BRepMesh::SequenceOfReal& theResult)
{
// Sort sequence of parameters
- BRepMesh::SequenceOfReal aParamTmp;
- Standard_Integer aParamLength = 1;
const Standard_Integer anInitLen = theParams.Extent();
TColStd_Array1OfReal aParamArray(1, anInitLen);
std::sort (aParamArray.begin(), aParamArray.end());
// mandatory pre-filtering using the first (minimal) filter value
- Standard_Real aP1, aP2;
- aP1 = aParamArray(1);
- aParamTmp.Append(aP1);
+ Standard_Integer aParamLength = 1;
for (j = 2; j <= anInitLen; j++)
{
- aP2 = aParamArray(j);
- if ((aP2-aP1) > theMinDist)
+ if ((aParamArray(j)-aParamArray(aParamLength)) > theMinDist)
{
- aParamTmp.Append(aP2);
- aP1 = aP2;
- aParamLength++;
+ if (++aParamLength < j)
+ aParamArray(aParamLength) = aParamArray(j);
}
}
-
- //add last point if required
- if(aParamArray(anInitLen)-theParams(aParamLength) > theMinDist)
- {
- aParamTmp.Append(aParamArray(anInitLen));
- aParamLength++;
- }
//perform filtering on series
Standard_Real aLastAdded, aLastCandidate;
Standard_Boolean isCandidateDefined = Standard_False;
- aLastAdded = aParamTmp.First();
+ aLastAdded = aParamArray(1);
aLastCandidate = aLastAdded;
- theResult.Append(aParamTmp.First());
+ theResult.Append(aLastAdded);
- for(j=2;j<aParamTmp.Length();j++)
+ for(j=2; j < aParamLength; j++)
{
- Standard_Real aVal = aParamTmp.Value(j);
+ Standard_Real aVal = aParamArray(j);
if(aVal-aLastAdded > theFilterDist)
{
//adds the parameter
aLastCandidate = aVal;
isCandidateDefined = Standard_True;
}
- theResult.Append(aParamTmp.Last());
+ theResult.Append(aParamArray(aParamLength));
}
void BRepMesh_FastDiscretFace::insertInternalVertices(
const Standard_Real aDefFace = myAttribute->GetDefFace();
const Handle(BRepAdaptor_HSurface)& gFace = myAttribute->Surface();
- BRepMesh::SequenceOfReal aParams[2];
+ Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
+ BRepMesh::SequenceOfReal aParams[2] = { BRepMesh::SequenceOfReal(anAlloc),
+ BRepMesh::SequenceOfReal(anAlloc) };
for (Standard_Integer i = 0; i < 2; ++i)
{
Standard_Boolean isU = (i == 0);
Handle (Geom_Surface) aSurface = gFace->ChangeSurface ().Surface ().Surface ();
const BRepMesh::HClassifier& aClassifier = myAttribute->ChangeClassifier();
- BRepMesh::MapOfReal aParamsToRemove[2];
- BRepMesh::MapOfReal aParamsForbiddenToRemove[2];
+ BRepMesh::MapOfReal aParamsToRemove[2] = { BRepMesh::MapOfReal(1, anAlloc),
+ BRepMesh::MapOfReal(1, anAlloc) };
+ BRepMesh::MapOfReal aParamsForbiddenToRemove[2] = { BRepMesh::MapOfReal(1, anAlloc),
+ BRepMesh::MapOfReal(1, anAlloc) };
// precision for compare square distances
const Standard_Real aPrecision = Precision::Confusion();
const Standard_Real theFaceDeflection,
const BRepMesh_CircleTool& theCircleTool,
BRepMesh::ListOfVertex& theVertices,
- Standard_Real& theMaxTriangleDeflection)
+ Standard_Real& theMaxTriangleDeflection,
+ const Handle(NCollection_IncAllocator)& theTempAlloc)
{
if (theTriangleDeflection > theMaxTriangleDeflection)
theMaxTriangleDeflection = theTriangleDeflection;
const_cast<BRepMesh_CircleTool&>(theCircleTool).Select(
myAttribute->Scale(theUV, Standard_True));
- Handle(NCollection_IncAllocator) aAllocator =
- new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE);
- BRepMesh::MapOfInteger aUsedNodes(10, aAllocator);
+ BRepMesh::MapOfInteger aUsedNodes(10, theTempAlloc);
BRepMesh::ListOfInteger::Iterator aCircleIt(aCirclesList);
for (; aCircleIt.More(); aCircleIt.Next())
{
if (IsCompexSurface (aSurfType) && aSurfType != GeomAbs_SurfaceOfExtrusion)
aBSpline = gFace->ChangeSurface ().Surface().Surface();
- NCollection_DataMap<Standard_Integer, gp_Dir> aNorMap;
- BRepMesh::MapOfIntegerInteger aStatMap;
- NCollection_Map<BRepMesh_OrientedEdge> aCouples(3 * aTrianglesNb);
+ Handle(NCollection_IncAllocator) anAlloc =
+ new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE);
+ NCollection_DataMap<Standard_Integer, gp_Dir> aNorMap(1, anAlloc);
+ BRepMesh::MapOfIntegerInteger aStatMap(1, anAlloc);
+ NCollection_Map<BRepMesh_OrientedEdge> aCouples(3 * aTrianglesNb, anAlloc);
const BRepMesh_CircleTool& aCircles = theTrigu.Circles();
// Perform refinement passes
Standard_Real aMaxSqDef = -1.;
Standard_Integer aPass = 1, aInsertedNb = 1;
Standard_Boolean isAllDegenerated = Standard_False;
+ Handle(NCollection_IncAllocator) aTempAlloc =
+ new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE);
for (; aPass <= aPassesNb && aInsertedNb && !isAllDegenerated; ++aPass)
{
+ aTempAlloc->Reset(Standard_False);
theNewVertices.Clear();
// Reset stop condition
aSqDef *= aSqDef;
isSkipped = !checkDeflectionAndInsert(pDef, aCenter2d, theIsFirst,
- aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef);
+ aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef, aTempAlloc);
if (isSkipped)
break;
aSqDef = aLin.SquareDistance(pDef);
isSkipped = !checkDeflectionAndInsert(pDef, mi2d, theIsFirst,
- aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef);
+ aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef, aTempAlloc);
}
}
BRepMesh_ShapeTool::AddInFace(aFace, aNewTriangulation);
// Delete unused data
+ myUParam.Clear(0L);
+ myVParam.Clear(0L);
myAttribute->ChangeStructure().Nullify();
myAttribute->ChangeSurfacePoints().Nullify();
myAttribute->ChangeSurfaceVertices().Nullify();
const Standard_Real theFaceDeflection,
const BRepMesh_CircleTool& theCircleTool,
BRepMesh::ListOfVertex& theVertices,
- Standard_Real& theMaxTriangleDeflection);
+ Standard_Real& theMaxTriangleDeflection,
+ const Handle(NCollection_IncAllocator)& theTempAlloc);
private:
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
+#include <TColStd_MapOfTransient.hxx>
#include <TopTools_HArray1OfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
//=======================================================================
void BRepMesh_IncrementalMesh::clear()
{
- myEdges.Clear();
- myEdgeDeflection.Clear();
+ // the allocator will be alive while the structures are alive
+ Handle(NCollection_IncAllocator) anAlloc =
+ new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE);
+ myEdges.Clear(anAlloc);
+ myEdgeDeflection.Clear(anAlloc);
myFaces.Clear();
myMesh.Nullify();
}
collectFaces();
Bnd_Box aBox;
- BRepBndLib::Add(myShape, aBox, Standard_False);
-
- if (aBox.IsVoid())
+ if ( myParameters.Relative )
{
- // Nothing to mesh.
- return;
- }
+ BRepBndLib::Add(myShape, aBox, Standard_False);
- BRepMesh_ShapeTool::BoxMaxDimension(aBox, myMaxShapeSize);
+ if (aBox.IsVoid())
+ {
+ // Nothing to mesh.
+ return;
+ }
+
+ BRepMesh_ShapeTool::BoxMaxDimension(aBox, myMaxShapeSize);
+ }
myMesh = new BRepMesh_FastDiscret (aBox, myParameters);
//=======================================================================
void BRepMesh_IncrementalMesh::collectFaces()
{
- TopTools_ListOfShape aFaceList;
+ Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
+ TopTools_ListOfShape aFaceList(anAlloc);
BRepLib::ReverseSortFaces(myShape, aFaceList);
- TopTools_MapOfShape aFaceMap;
+ TColStd_MapOfTransient aTFaceMap(1, anAlloc);
// make array of faces suitable for processing (excluding faces without surface)
TopLoc_Location aDummyLoc;
- const TopLoc_Location aEmptyLoc;
TopTools_ListIteratorOfListOfShape aFaceIter(aFaceList);
for (; aFaceIter.More(); aFaceIter.Next())
{
- TopoDS_Shape aFaceNoLoc = aFaceIter.Value();
- aFaceNoLoc.Location(aEmptyLoc);
- if (!aFaceMap.Add (aFaceNoLoc))
+ const TopoDS_Face& aFace = TopoDS::Face(aFaceIter.Value());
+ const Handle(TopoDS_TShape)& aTFace = aFace.TShape();
+ if (!aTFaceMap.Add (aTFace))
continue; // already processed
- TopoDS_Face aFace = TopoDS::Face(aFaceIter.Value());
const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(aFace, aDummyLoc);
if (aSurf.IsNull())
continue;
Standard_Real BRepMesh_IncrementalMesh::edgeDeflection(
const TopoDS_Edge& theEdge)
{
- if (myEdgeDeflection.IsBound(theEdge))
- return myEdgeDeflection(theEdge);
+ const Standard_Real* pDef = myEdgeDeflection.Seek(theEdge);
+ if (pDef)
+ return *pDef;
Standard_Real aEdgeDeflection;
if ( myParameters.Relative )
void BRepMesh_IncrementalMesh::update(const TopoDS_Edge& theEdge)
{
if (!myEdges.IsBound(theEdge))
- myEdges.Bind(theEdge, BRepMesh::DMapOfTriangulationBool());
+ myEdges.Bind(theEdge, BRepMesh::DMapOfTriangulationBool(3, myEdges.Allocator()));
Standard_Real aEdgeDeflection = edgeDeflection(theEdge);
// Check that triangulation relies to face of the given shape.
typedef Standard_Integer Target;
//! Constructor.
- //! @param theReservedSize size to be reserved for vector of vertices.
//! @param theAllocator memory allocator to be used by internal collections.
Standard_EXPORT BRepMesh_VertexInspector (
- const Standard_Integer theReservedSize,
const Handle(NCollection_IncAllocator)& theAllocator)
: myResIndices(theAllocator),
- myVertices (new BRepMesh::VectorOfVertex(theReservedSize)),
+ myVertices (new BRepMesh::VectorOfVertex),
myDelNodes (theAllocator)
{
SetTolerance( Precision::Confusion() );
//purpose :
//=======================================================================
BRepMesh_VertexTool::BRepMesh_VertexTool(
- const Standard_Integer theReservedSize,
const Handle(NCollection_IncAllocator)& theAllocator)
: myAllocator (theAllocator),
myCellFilter(0., myAllocator),
- mySelector (Max(theReservedSize, 64),myAllocator)
+ mySelector (myAllocator)
{
const Standard_Real aTol = Precision::Confusion();
SetCellSize ( aTol + 0.05 * aTol );
DEFINE_STANDARD_ALLOC
//! Constructor.
- //! @param theReservedSize size to be reserved for vector of vertices.
//! @param theAllocator memory allocator to be used by internal collections.
Standard_EXPORT BRepMesh_VertexTool(
- const Standard_Integer theReservedSize,
const Handle(NCollection_IncAllocator)& theAllocator);
//! Sets new size of cell for cellfilter equal in both directions.
#include <BRepTools_WireExplorer.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopoDS.hxx>
-#include <TopExp_Explorer.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Iterator.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <BRepMesh_PairOfPolygon.hxx>
#include <TColStd_SequenceOfInteger.hxx>
TopoDS_Face aFace = theFace;
aFace.Orientation(TopAbs_FORWARD);
- TopExp_Explorer aFaceExplorer(aFace, TopAbs_WIRE);
- for (; aFaceExplorer.More(); aFaceExplorer.Next())
+ for (TopoDS_Iterator aFaceIt(aFace); aFaceIt.More(); aFaceIt.Next())
{
- const TopoDS_Wire& aWire = TopoDS::Wire(aFaceExplorer.Current());
+ if (aFaceIt.Value().IsNull() || aFaceIt.Value().ShapeType() != TopAbs_WIRE) // may be inner vertex
+ continue;
+ const TopoDS_Wire& aWire = TopoDS::Wire(aFaceIt.Value());
myWiresEdges.Append(ListOfEdges());
ListOfEdges& aEdges = myWiresEdges.ChangeLast();
Standard_Integer Index1 = 0;
Standard_Integer Index2 = 0;
Standard_Real newFirst, newLast;
- TColStd_Array1OfReal TK(1,Nb);
- TColStd_Array1OfInteger TM(1,Nb);
- myBSplineCurve->Knots(TK);
- myBSplineCurve->Multiplicities(TM);
+ const TColStd_Array1OfReal& TK = myBSplineCurve->Knots();
+ const TColStd_Array1OfInteger& TM = myBSplineCurve->Multiplicities();
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,U1,myBSplineCurve->IsPeriodic(),
1,Nb,Index1,newFirst);
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,U2,myBSplineCurve->IsPeriodic(),
Standard_Integer Index1 = 0;
Standard_Integer Index2 = 0;
Standard_Real newFirst, newLast;
- TColStd_Array1OfReal TK(1,Nb);
- TColStd_Array1OfInteger TM(1,Nb);
- myBSplineCurve->Knots(TK);
- myBSplineCurve->Multiplicities(TM);
+ const TColStd_Array1OfReal& TK = myBSplineCurve->Knots();
+ const TColStd_Array1OfInteger& TM = myBSplineCurve->Multiplicities();
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myFirst,
myBSplineCurve->IsPeriodic(),
1,Nb,Index1,newFirst);
Standard_Integer Index1 = 0;
Standard_Integer Index2 = 0;
Standard_Real newFirst, newLast;
- TColStd_Array1OfReal TK(1,Nb);
- TColStd_Array1OfInteger TM(1,Nb);
- myBSplineCurve->Knots(TK);
- myBSplineCurve->Multiplicities(TM);
+ const TColStd_Array1OfReal& TK = myBSplineCurve->Knots();
+ const TColStd_Array1OfInteger& TM = myBSplineCurve->Multiplicities();
BSplCLib::LocateParameter(myBSplineCurve->Degree(),TK,TM,myFirst,
myBSplineCurve->IsPeriodic(),
1,Nb,Index1,newFirst);
//! Statistics
Standard_EXPORT void Statistics(Standard_OStream& S) const;
+ //! Returns attached allocator
+ const Handle(NCollection_BaseAllocator)& Allocator() const
+ { return myAllocator; }
+
protected:
// -------- PROTECTED METHODS -----------
Standard_Boolean IsEmpty () const {return (mySize == 0);}
Standard_Integer Length () const {return mySize;}
+ //! Returns attached allocator
+ const Handle(NCollection_BaseAllocator)& Allocator() const
+ { return myAllocator; }
+
protected:
// Methods PROTECTED
//
}
}
+ //! Returns attached allocator
+ const Handle(NCollection_BaseAllocator)& Allocator() const
+ {
+ return myAllocator;
+ }
+
protected: //! @name Protected fields
Handle(NCollection_BaseAllocator) myAllocator;
}
//! Clear the data structures and set new cell sizes and allocator
- void Reset (NCollection_Array1<Standard_Real> theCellSize,
+ void Reset (NCollection_Array1<Standard_Real>& theCellSize,
const Handle(NCollection_IncAllocator)& theAlloc=0)
{
myCellSize = theCellSize;
NCollection_UBTreeFiller (UBTree& theTree,
const Handle(NCollection_BaseAllocator)& theAlloc=0L,
const Standard_Boolean isFullRandom = Standard_True)
- : myTree(theTree), mySeqPtr(1000, theAlloc),
+ : myTree(theTree), mySeqPtr(256, theAlloc),
myRandGen (5489u /* == std::mt19937::default_seed, not defined in older environments, e.g, on Debian 6.0 with GCC 4.4.5 */),
myIsFullRandom (isFullRandom) {}
vsetdispmode result 1
vfit
-checktrinfo result -tri 444 -nod 435
+checktrinfo result -tri 430 -nod 428
checkview -display result -2d -path ${imagedir}/${test_image}.png
vsetdispmode result 1
vfit
-checktrinfo result -tri 5497 -nod 3987
+checktrinfo result -tri 5457 -nod 3967
checkview -display result -2d -path ${imagedir}/${test_image}.png
vdisplay result
vfit
-checktrinfo result -tri 8142 -nod 7015
+checktrinfo result -tri 9198 -nod 7543
checkmaxtol result -ref 0.92213088179312575
checknbshapes result -shell 1
vfit
vsetdispmode result 1
-checktrinfo result -tri 17548 -nod 9208
+checktrinfo result -tri 8970 -nod 4919
checkprops result -s 24861.2
checkshape result
checkview -display result -2d -path ${imagedir}/${test_image}.png
triangles result
vfit
-checktrinfo result -tri 7988 -nod 8350
+checktrinfo result -tri 7980 -nod 8346
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
set TheFileName shading_wrongshape_027.brep
set bug_freenodes "OCC22687"
-#set nbfreenodes(All) 2
+set nbfreenodes(All) 1
set max_rel_tol_diff 1
if { [string compare $command "shading"] != 0 } {
#set bug_area "OCC22687"
- set rel_tol 2.13
+ set rel_tol 1.2
} else {
set nbfreenodes(All) 2
set rel_tol 0.48