1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0028213: Visualization, StdPrs_ShadedShape - compute face edges for triangulation-only Faces

This commit is contained in:
kgv 2016-12-12 12:54:25 +03:00 committed by apn
parent 3a4a396251
commit 0a8630615d
4 changed files with 98 additions and 47 deletions

View File

@ -304,6 +304,17 @@ namespace
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;
@ -335,12 +346,24 @@ namespace
}
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)
@ -388,6 +411,19 @@ namespace
}
}
}
{
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;
}

View File

@ -73,15 +73,13 @@ void StdPrs_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
// 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;
@ -263,19 +261,47 @@ void StdPrs_WFShape::addEdges (const TopTools_ListOfShape& theEdges,
// 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;
TopLoc_Location aLocation;
TopTools_ListIteratorOfListOfShape aFaceIter;
for (aFaceIter.Initialize (theFaces); aFaceIter.More(); aFaceIter.Next())
TColgp_SequenceOfPnt aSeqPnts;
AddEdgesOnTriangulation (aSeqPnts, theShape, theToExcludeGeometric);
if (aSeqPnts.Size() < 2)
{
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Value());
return Handle(Graphic3d_ArrayOfSegments)();
}
Handle(Poly_Triangulation) T = BRep_Tool::Triangulation (aFace, aLocation);
Standard_Integer aNbVertices = aSeqPnts.Size();
Handle(Graphic3d_ArrayOfSegments) aSurfArray = new Graphic3d_ArrayOfSegments (aNbVertices);
for (Standard_Integer anI = 1; anI <= aNbVertices; anI += 2)
{
aSurfArray->AddVertex (aSeqPnts.Value (anI));
aSurfArray->AddVertex (aSeqPnts.Value (anI + 1));
}
return aSurfArray;
}
// =========================================================================
// 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;
@ -345,26 +371,10 @@ void StdPrs_WFShape::addEdgesOnTriangulation (const Handle(Prs3d_Presentation)&
{
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);
}
// =========================================================================

View File

@ -37,6 +37,20 @@ public:
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.
@ -48,15 +62,6 @@ private:
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.

View File

@ -18,7 +18,7 @@ vaxo
vdisplay -noupdate -dispMode 0 s
vaspects s -subshapes s_1 -setcolor RED
vdisplay -noupdate -dispMode 1 s
vshowfaceboundary s 1
vshowfaceboundary s 1 255 0 0 2
vfit
vselect 250 250