mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027490: BRepMesh: Reduce number of memory allocations
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.
This commit is contained in:
@@ -56,8 +56,16 @@ class BRepMesh_VertexTool;
|
||||
|
||||
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
|
||||
|
@@ -35,7 +35,8 @@ BRepMesh_DataStructureOfDelaun::BRepMesh_DataStructureOfDelaun(
|
||||
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),
|
||||
|
@@ -429,8 +429,6 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
|
||||
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;
|
||||
@@ -442,8 +440,8 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
|
||||
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 );
|
||||
@@ -598,6 +596,7 @@ void BRepMesh_Delaun::cleanupMesh()
|
||||
|
||||
for(;;)
|
||||
{
|
||||
aAllocator->Reset(Standard_False);
|
||||
BRepMesh::MapOfIntegerInteger aLoopEdges(10, aAllocator);
|
||||
BRepMesh::MapOfInteger aDelTriangles(10, aAllocator);
|
||||
|
||||
@@ -679,7 +678,6 @@ void BRepMesh_Delaun::cleanupMesh()
|
||||
myMeshData->RemoveLink( aLoopEdgesIt.Key() );
|
||||
}
|
||||
|
||||
aAllocator->Reset(Standard_False);
|
||||
if ( aDeletedTrianglesNb == 0 )
|
||||
break;
|
||||
}
|
||||
@@ -2173,7 +2171,8 @@ Standard_Boolean BRepMesh_Delaun::UseEdge( const Standard_Integer /*theIndex*/ )
|
||||
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() )
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FaceAttribute,Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
@@ -141,14 +140,12 @@ void BRepMesh_FaceAttribute::init()
|
||||
// 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
|
||||
|
@@ -47,6 +47,7 @@
|
||||
#include <Extrema_LocateExtPC.hxx>
|
||||
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_Array1OfCharacter.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColGeom2d_SequenceOfCurve.hxx>
|
||||
@@ -82,6 +83,7 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FastDiscret,Standard_Transient)
|
||||
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),
|
||||
@@ -195,7 +197,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
|
||||
resetDataStructure();
|
||||
|
||||
Standard_Real defedge;
|
||||
Standard_Real defedge = myParameters.Deflection;
|
||||
Standard_Integer nbEdge = 0;
|
||||
Standard_Real savangle = myParameters.Angle;
|
||||
Standard_Real cdef;
|
||||
@@ -205,18 +207,14 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
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)
|
||||
@@ -265,8 +263,6 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
continue;
|
||||
|
||||
EdgePCurve aPCurve = { aCurve2d, aFirstParam, aLastParam };
|
||||
aPCurves.Append(aPCurve);
|
||||
aFaceEdges.Append(aEdge);
|
||||
|
||||
add(aEdge, aPCurve, defedge);
|
||||
myParameters.Angle = savangle;
|
||||
@@ -293,6 +289,7 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLoc);
|
||||
const Handle(BRepAdaptor_HSurface)& gFace = myAttribute->Surface();
|
||||
|
||||
if ( aTriangulation.IsNull() )
|
||||
{
|
||||
@@ -401,16 +398,29 @@ Standard_Integer BRepMesh_FastDiscret::Add(const TopoDS_Face& theFace)
|
||||
++nbmaill;
|
||||
|
||||
resetDataStructure();
|
||||
for (Standard_Integer j = 1; j <= aFaceEdges.Length(); ++j)
|
||||
|
||||
for (TopoDS_Iterator aWireIt(aFace); aWireIt.More(); aWireIt.Next())
|
||||
{
|
||||
const TopoDS_Edge& anEdge = aFaceEdges(j);
|
||||
if (myEdges.IsBound(anEdge))
|
||||
myEdges.UnBind(anEdge);
|
||||
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);
|
||||
defedge = Max(myMapdefle(anEdge) / 3.0, eps);
|
||||
myMapdefle.Bind(anEdge, defedge);
|
||||
|
||||
add(anEdge, aPCurves(j), 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);
|
||||
@@ -806,18 +816,13 @@ void BRepMesh_FastDiscret::update(
|
||||
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);
|
||||
@@ -825,9 +830,15 @@ void BRepMesh_FastDiscret::update(
|
||||
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;
|
||||
|
@@ -207,8 +207,8 @@ void BRepMesh_FastDiscretFace::initDataStructure()
|
||||
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();
|
||||
@@ -217,8 +217,8 @@ void BRepMesh_FastDiscretFace::initDataStructure()
|
||||
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
|
||||
@@ -393,7 +393,8 @@ void BRepMesh_FastDiscretFace::add(const Handle(BRepMesh_FaceAttribute)& theAttr
|
||||
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);
|
||||
@@ -463,8 +464,6 @@ static void filterParameters(const BRepMesh::IMapOfReal& theParams,
|
||||
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);
|
||||
@@ -475,37 +474,26 @@ static void filterParameters(const BRepMesh::IMapOfReal& theParams,
|
||||
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
|
||||
@@ -525,7 +513,7 @@ static void filterParameters(const BRepMesh::IMapOfReal& theParams,
|
||||
aLastCandidate = aVal;
|
||||
isCandidateDefined = Standard_True;
|
||||
}
|
||||
theResult.Append(aParamTmp.Last());
|
||||
theResult.Append(aParamArray(aParamLength));
|
||||
}
|
||||
|
||||
void BRepMesh_FastDiscretFace::insertInternalVertices(
|
||||
@@ -842,7 +830,9 @@ void BRepMesh_FastDiscretFace::insertInternalVerticesOther(
|
||||
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);
|
||||
@@ -868,8 +858,10 @@ void BRepMesh_FastDiscretFace::insertInternalVerticesOther(
|
||||
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();
|
||||
@@ -1043,7 +1035,8 @@ Standard_Boolean BRepMesh_FastDiscretFace::checkDeflectionAndInsert(
|
||||
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;
|
||||
@@ -1058,9 +1051,7 @@ Standard_Boolean BRepMesh_FastDiscretFace::checkDeflectionAndInsert(
|
||||
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())
|
||||
{
|
||||
@@ -1118,9 +1109,11 @@ Standard_Real BRepMesh_FastDiscretFace::control(
|
||||
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
|
||||
@@ -1131,8 +1124,11 @@ Standard_Real BRepMesh_FastDiscretFace::control(
|
||||
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
|
||||
@@ -1208,7 +1204,7 @@ Standard_Real BRepMesh_FastDiscretFace::control(
|
||||
aSqDef *= aSqDef;
|
||||
|
||||
isSkipped = !checkDeflectionAndInsert(pDef, aCenter2d, theIsFirst,
|
||||
aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef);
|
||||
aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef, aTempAlloc);
|
||||
|
||||
if (isSkipped)
|
||||
break;
|
||||
@@ -1242,7 +1238,7 @@ Standard_Real BRepMesh_FastDiscretFace::control(
|
||||
aSqDef = aLin.SquareDistance(pDef);
|
||||
|
||||
isSkipped = !checkDeflectionAndInsert(pDef, mi2d, theIsFirst,
|
||||
aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef);
|
||||
aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef, aTempAlloc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1409,6 +1405,8 @@ void BRepMesh_FastDiscretFace::commitSurfaceTriangulation()
|
||||
BRepMesh_ShapeTool::AddInFace(aFace, aNewTriangulation);
|
||||
|
||||
// Delete unused data
|
||||
myUParam.Clear(0L);
|
||||
myVParam.Clear(0L);
|
||||
myAttribute->ChangeStructure().Nullify();
|
||||
myAttribute->ChangeSurfacePoints().Nullify();
|
||||
myAttribute->ChangeSurfaceVertices().Nullify();
|
||||
|
@@ -174,7 +174,8 @@ private:
|
||||
const Standard_Real theFaceDeflection,
|
||||
const BRepMesh_CircleTool& theCircleTool,
|
||||
BRepMesh::ListOfVertex& theVertices,
|
||||
Standard_Real& theMaxTriangleDeflection);
|
||||
Standard_Real& theMaxTriangleDeflection,
|
||||
const Handle(NCollection_IncAllocator)& theTempAlloc);
|
||||
|
||||
private:
|
||||
|
||||
|
@@ -48,6 +48,7 @@
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_MapOfTransient.hxx>
|
||||
#include <TopTools_HArray1OfShape.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
|
||||
@@ -125,8 +126,11 @@ BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
|
||||
//=======================================================================
|
||||
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();
|
||||
}
|
||||
@@ -146,15 +150,18 @@ void BRepMesh_IncrementalMesh::init()
|
||||
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);
|
||||
|
||||
@@ -167,22 +174,21 @@ void BRepMesh_IncrementalMesh::init()
|
||||
//=======================================================================
|
||||
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;
|
||||
@@ -282,8 +288,9 @@ void BRepMesh_IncrementalMesh::discretizeFreeEdges()
|
||||
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 )
|
||||
@@ -329,7 +336,7 @@ Standard_Real BRepMesh_IncrementalMesh::faceDeflection(
|
||||
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.
|
||||
|
@@ -30,13 +30,11 @@ public:
|
||||
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() );
|
||||
|
@@ -56,11 +56,10 @@ NCollection_CellFilter_Action BRepMesh_VertexInspector::Inspect(
|
||||
//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 );
|
||||
|
@@ -36,10 +36,8 @@ public:
|
||||
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.
|
||||
|
@@ -22,7 +22,8 @@
|
||||
#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>
|
||||
@@ -147,10 +148,11 @@ BRepMesh_WireChecker::BRepMesh_WireChecker(
|
||||
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();
|
||||
|
Reference in New Issue
Block a user