Standard_Integer aNbPolylines = 0;
TopLoc_Location aTrsf;
+ TColgp_SequenceOfPnt aSeqPntsExtra;
+ for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
+ {
+ const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
+ TopoDS_Iterator aSubShapeIter (aFace);
+ if (!aSubShapeIter.More())
+ {
+ // handle specifically faces without boundary definition (triangulation-only)
+ StdPrs_WFShape::AddEdgesOnTriangulation (aSeqPntsExtra, aFace, Standard_False);
+ }
+ }
// explore all boundary edges
TopTools_IndexedDataMapOfShapeListOfShape anEdgesMap;
}
if (aNodeNumber == 0)
{
- return Handle(Graphic3d_ArrayOfSegments)();
+ if (aSeqPntsExtra.Size() < 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)
+ {
+ aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter));
+ aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter + 1));
+ }
+ 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, aSegmentEdgeNb);
+ Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments (aNodeNumber + aSeqPntsExtra.Size(), aSegmentEdgeNb + aSeqPntsExtra.Size());
for (TopTools_IndexedDataMapOfShapeListOfShape::Iterator anEdgeIter (anEdgesMap); anEdgeIter.More(); anEdgeIter.Next())
{
if (anEdgeIter.Value().Extent() == 0)
}
}
}
+
+ {
+ Standard_Integer aSegmentEdge = aSegments->VertexNumber();
+ const Standard_Integer aNbVertices = aSeqPntsExtra.Size();
+ for (Standard_Integer aPntIter = 1; aPntIter <= aNbVertices; aPntIter += 2)
+ {
+ aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter));
+ aSegments->AddEdge (++aSegmentEdge);
+ aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter + 1));
+ aSegments->AddEdge (++aSegmentEdge);
+ }
+ }
+
return aSegments;
}
// Draw shape elements
{
- TopTools_ListOfShape aDiscreteFaces;
- for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
+ Handle(Graphic3d_ArrayOfPrimitives) aTriFreeEdges = AddEdgesOnTriangulation (theShape, Standard_True);
+ if (!aTriFreeEdges.IsNull())
{
- if (!aTool.HasSurface())
- {
- aDiscreteFaces.Append (aTool.GetFace());
- }
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
+ aGroup->SetPrimitivesAspect (theDrawer->FreeBoundaryAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aTriFreeEdges);
}
- addEdgesOnTriangulation (thePresentation, aDiscreteFaces, theDrawer->FreeBoundaryAspect());
}
Prs3d_NListOfSequenceOfPnt aCommonPolylines;
// function : AddEdgesOnTriangulation
// purpose :
// =========================================================================
-void StdPrs_WFShape::addEdgesOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
- const TopTools_ListOfShape& theFaces,
- const Handle (Prs3d_LineAspect)& theAspect)
+Handle(Graphic3d_ArrayOfPrimitives) StdPrs_WFShape::AddEdgesOnTriangulation (const TopoDS_Shape& theShape,
+ const Standard_Boolean theToExcludeGeometric)
{
- TColgp_SequenceOfPnt aSurfPoints;
+ TColgp_SequenceOfPnt aSeqPnts;
+ AddEdgesOnTriangulation (aSeqPnts, theShape, theToExcludeGeometric);
+ if (aSeqPnts.Size() < 2)
+ {
+ return Handle(Graphic3d_ArrayOfSegments)();
+ }
- TopLoc_Location aLocation;
- TopTools_ListIteratorOfListOfShape aFaceIter;
- for (aFaceIter.Initialize (theFaces); aFaceIter.More(); aFaceIter.Next())
+ Standard_Integer aNbVertices = aSeqPnts.Size();
+ Handle(Graphic3d_ArrayOfSegments) aSurfArray = new Graphic3d_ArrayOfSegments (aNbVertices);
+ for (Standard_Integer anI = 1; anI <= aNbVertices; anI += 2)
{
- const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Value());
+ aSurfArray->AddVertex (aSeqPnts.Value (anI));
+ aSurfArray->AddVertex (aSeqPnts.Value (anI + 1));
+ }
+ return aSurfArray;
+}
- Handle(Poly_Triangulation) T = BRep_Tool::Triangulation (aFace, aLocation);
+// =========================================================================
+// function : AddEdgesOnTriangulation
+// purpose :
+// =========================================================================
+void StdPrs_WFShape::AddEdgesOnTriangulation (TColgp_SequenceOfPnt& theSegments,
+ const TopoDS_Shape& theShape,
+ const Standard_Boolean theToExcludeGeometric)
+{
+ TopLoc_Location aLocation, aDummyLoc;
+ for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
+ {
+ const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
+ if (theToExcludeGeometric)
+ {
+ const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aDummyLoc);
+ if (!aSurf.IsNull())
+ {
+ continue;
+ }
+ }
+ const Handle(Poly_Triangulation)& T = BRep_Tool::Triangulation (aFace, aLocation);
if (T.IsNull())
{
continue;
{
gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (aLocation);
gp_Pnt aPoint2 = aNodes (aFree (2 * anI )).Transformed (aLocation);
- aSurfPoints.Append (aPoint1);
- aSurfPoints.Append (aPoint2);
+ theSegments.Append (aPoint1);
+ theSegments.Append (aPoint2);
}
}
-
- if (aSurfPoints.Length() < 2)
- {
- return;
- }
-
- Standard_Integer aNbVertices = aSurfPoints.Length();
- Handle(Graphic3d_ArrayOfSegments) aSurfArray = new Graphic3d_ArrayOfSegments (aNbVertices);
- for (Standard_Integer anI = 1; anI <= aNbVertices; anI += 2)
- {
- aSurfArray->AddVertex (aSurfPoints.Value (anI));
- aSurfArray->AddVertex (aSurfPoints.Value (anI + 1));
- }
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
- aGroup->SetPrimitivesAspect (theAspect->Aspect());
- aGroup->AddPrimitiveArray (aSurfArray);
}
// =========================================================================
const TopoDS_Shape& theShape,
const Handle (Prs3d_Drawer)& theDrawer);
+ //! Compute free and boundary edges on a triangulation of each face in the given shape.
+ //! @param theShape [in] the list of triangulated faces
+ //! @param theToExcludeGeometric [in] flag indicating that Faces with defined Surface should be skipped
+ Standard_EXPORT static Handle(Graphic3d_ArrayOfPrimitives) AddEdgesOnTriangulation (const TopoDS_Shape& theShape,
+ const Standard_Boolean theToExcludeGeometric = Standard_True);
+
+ //! Compute free and boundary edges on a triangulation of each face in the given shape.
+ //! @param theSegments [in] the sequence of points defining segments
+ //! @param theShape [in] the list of triangulated faces
+ //! @param theToExcludeGeometric [in] flag indicating that Faces with defined Surface should be skipped
+ Standard_EXPORT static void AddEdgesOnTriangulation (TColgp_SequenceOfPnt& theSegments,
+ const TopoDS_Shape& theShape,
+ const Standard_Boolean theToExcludeGeometric = Standard_True);
+
private:
//! Compute edge presentations for a shape.
const Standard_Real theShapeDeflection,
Prs3d_NListOfSequenceOfPnt& thePolylines);
- //! Compute free and boundary edges on a triangulation of a face.
- //! @param thePresentation [in] the presentation.
- //! @param theFaces [in] the list of triangulated faces.
- //! @param theAspect [in] the edge drawing aspect.
- //! @param theDrawer [in] the drawer settings.
- static void addEdgesOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
- const TopTools_ListOfShape& theFaces,
- const Handle (Prs3d_LineAspect)& theAspect);
-
//! Compute vertex presentation for a shape.
//! @param thePresentation [in] the presentation.
//! @param theVertices [in] the list of points.