#include <Poly_Connect.hxx>
+#include <NCollection_IncAllocator.hxx>
#include <Poly_Triangle.hxx>
#include <Poly_Triangulation.hxx>
struct polyedge
{
polyedge* next; // the next edge in the list
- Standard_Integer nd; // the second node of the edge
Standard_Integer nt[2]; // the two adjacent triangles
Standard_Integer nn[2]; // the two adjacent nodes
+ Standard_Integer nd; // the second node of the edge
DEFINE_STANDARD_ALLOC
};
// create an array to store the edges starting from the vertices
NCollection_Array1<polyedge*> anEdges (1, aNbNodes);
anEdges.Init (NULL);
+ // use incremental allocator for small allocations
+ Handle(NCollection_IncAllocator) anIncAlloc = new NCollection_IncAllocator();
// loop on the triangles
NCollection_Vec3<Standard_Integer> aTriNodes;
if (ced == NULL)
{
// create the edge if not found
- ced = new polyedge();
+ ced = (polyedge* )anIncAlloc->Allocate (sizeof(polyedge));
ced->next = anEdges[anEdgeNodes[0]];
anEdges[anEdgeNodes[0]] = ced;
ced->nd = anEdgeNodes[1];
anAdjIndex += 3;
}
- // destroy the edges array
- for (Standard_Integer aNodeIter = anEdges.Lower(); aNodeIter <= anEdges.Upper(); ++aNodeIter)
+ // destroy the edges array - can be skipped when using NCollection_IncAllocator
+ /*for (Standard_Integer aNodeIter = anEdges.Lower(); aNodeIter <= anEdges.Upper(); ++aNodeIter)
{
for (polyedge* anEdgeIter = anEdges[aNodeIter]; anEdgeIter != NULL;)
{
polyedge* aTmp = anEdgeIter->next;
- delete anEdgeIter;
+ anIncAlloc->Free (anEdgeIter);
anEdgeIter = aTmp;
}
- }
+ }*/
}
//=======================================================================
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
+#include <NCollection_IncAllocator.hxx>
#include <NCollection_List.hxx>
+#include <NCollection_Shared.hxx>
#include <Precision.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_IsoAspect.hxx>
Standard_Integer aNbPolylines = 0;
TopLoc_Location aTrsf;
- TColgp_SequenceOfPnt aSeqPntsExtra;
+
+ Handle(NCollection_Shared<TColgp_SequenceOfPnt>) aSeqPntsExtra;
for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
{
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
if (aFace.NbChildren() == 0)
{
// handle specifically faces without boundary definition (triangulation-only)
- StdPrs_WFShape::AddEdgesOnTriangulation (aSeqPntsExtra, aFace, Standard_False);
+ if (aSeqPntsExtra.IsNull())
+ {
+ Handle(NCollection_IncAllocator) anIncAlloc = new NCollection_IncAllocator();
+ aSeqPntsExtra = new NCollection_Shared<TColgp_SequenceOfPnt> (anIncAlloc);
+ }
+ StdPrs_WFShape::AddEdgesOnTriangulation (*aSeqPntsExtra, aFace, Standard_False);
}
}
++aNbPolylines;
}
}
+ const Standard_Integer aNbExtra = !aSeqPntsExtra.IsNull() ? aSeqPntsExtra->Size() : 0;
if (aNodeNumber == 0)
{
- if (aSeqPntsExtra.Size() < 2)
+ if (aNbExtra < 2)
{
return Handle(Graphic3d_ArrayOfSegments)();
}
- Standard_Integer aNbVertices = aSeqPntsExtra.Size();
- Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments (aNbVertices);
- for (Standard_Integer aPntIter = 1; aPntIter <= aNbVertices; aPntIter += 2)
+ Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments (aNbExtra);
+ for (TColgp_SequenceOfPnt::Iterator aPntIter (*aSeqPntsExtra); aPntIter.More(); aPntIter.Next())
{
- aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter));
- aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter + 1));
+ aSegments->AddVertex (aPntIter.Value());
}
return aSegments;
}
// create indexed segments array to pack polylines from different edges into single array
const Standard_Integer aSegmentEdgeNb = (aNodeNumber - aNbPolylines) * 2;
- Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments (aNodeNumber + aSeqPntsExtra.Size(), aSegmentEdgeNb + aSeqPntsExtra.Size());
+ Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments (aNodeNumber + aNbExtra, aSegmentEdgeNb + aNbExtra);
for (TopTools_IndexedDataMapOfShapeListOfShape::Iterator anEdgeIter (anEdgesMap); anEdgeIter.More(); anEdgeIter.Next())
{
if (anEdgeIter.Value().Extent() == 0)
}
}
+ if (!aSeqPntsExtra.IsNull())
{
Standard_Integer aSegmentEdge = aSegments->VertexNumber();
- const Standard_Integer aNbVertices = aSeqPntsExtra.Size();
- for (Standard_Integer aPntIter = 1; aPntIter <= aNbVertices; aPntIter += 2)
+ for (TColgp_SequenceOfPnt::Iterator aPntIter (*aSeqPntsExtra); aPntIter.More(); aPntIter.Next())
{
- aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter));
- aSegments->AddEdge (++aSegmentEdge);
- aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter + 1));
+ aSegments->AddVertex (aPntIter.Value());
aSegments->AddEdge (++aSegmentEdge);
}
}