// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <Prs3d.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <gp_Pnt.hxx>
-#include <Prs3d.hxx>
+#include <Graphic3d_Group.hxx>
#include <Prs3d_Drawer.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Root.hxx>
#include <TopoDS_Shape.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
//=======================================================================
//function : MatchSegment
}
return aDeflection;
}
+
+//==================================================================
+// function: PrimitivesFromPolylines
+// purpose:
+//==================================================================
+Handle(Graphic3d_ArrayOfPrimitives) Prs3d::PrimitivesFromPolylines (const Prs3d_NListOfSequenceOfPnt& thePoints)
+{
+ if (thePoints.IsEmpty())
+ {
+ return Handle(Graphic3d_ArrayOfPrimitives)();
+ }
+
+ Standard_Integer aNbVertices = 0;
+ for (Prs3d_NListOfSequenceOfPnt::Iterator anIt (thePoints); anIt.More(); anIt.Next())
+ {
+ aNbVertices += anIt.Value()->Length();
+ }
+ const Standard_Integer aSegmentEdgeNb = (aNbVertices - thePoints.Size()) * 2;
+ Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments (aNbVertices, aSegmentEdgeNb);
+ for (Prs3d_NListOfSequenceOfPnt::Iterator anIt (thePoints); anIt.More(); anIt.Next())
+ {
+ const Handle(TColgp_HSequenceOfPnt)& aPoints = anIt.Value();
+
+ Standard_Integer aSegmentEdge = aSegments->VertexNumber() + 1;
+ aSegments->AddVertex (aPoints->First());
+ for (Standard_Integer aPntIter = aPoints->Lower() + 1; aPntIter <= aPoints->Upper(); ++aPntIter)
+ {
+ aSegments->AddVertex (aPoints->Value (aPntIter));
+ aSegments->AddEdge ( aSegmentEdge);
+ aSegments->AddEdge (++aSegmentEdge);
+ }
+ }
+
+ return aSegments;
+}
+
+//==================================================================
+// function: AddPrimitivesGroup
+// purpose:
+//==================================================================
+void Prs3d::AddPrimitivesGroup (const Handle(Prs3d_Presentation)& thePrs,
+ const Handle(Prs3d_LineAspect)& theAspect,
+ Prs3d_NListOfSequenceOfPnt& thePolylines)
+{
+ Handle(Graphic3d_ArrayOfPrimitives) aPrims = Prs3d::PrimitivesFromPolylines (thePolylines);
+ thePolylines.Clear();
+ if (!aPrims.IsNull())
+ {
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
+ aGroup->SetPrimitivesAspect (theAspect->Aspect());
+ aGroup->AddPrimitiveArray (aPrims);
+ }
+}