mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-08 14:17:06 +03:00
0029570: Visualization, Graphic3d_Aspect - merge Graphic3d_Group aspects
Graphic3d_AspectFillArea3d, Graphic3d_AspectLine3d, Graphic3d_AspectMarker3d and Graphic3d_AspectText3d have been merged into new class Graphic3d_Aspects. The old classes are preserved as dummy sub-classes of Graphic3d_Aspects preserving different per-aspect defaults. Methods IsGroupPrimitivesAspectSet(), GroupPrimitivesAspect(), FillAreaAspect(), LineAspect() and MarkerAspect() have been removed from Graphic3d_Group. Instead, a new method Graphic3d_Group::ReplaceAspects() has been introduced for replacing existing group aspects. AIS_Shape now uses new method AIS_InteractiveObject::replaceAspects() for updating computed groups with new aspects without presentation recomputation in places where SynchronizeAspects() is not applicable. OpenGl_AspectFace, OpenGl_AspectLine, OpenGl_AspectMarker and OpenGl_AspectText have been merged into new class OpenGl_Aspects. ViewerTest::parseColor() - fix uninitialized alpha component. Graphic3d_AspectText3d/Prs3d_TextAspect - removed unused properties Space, ExpansionFactor, Angle. Remove getters Values() deprecated since OCCT 7.1.0.
This commit is contained in:
@@ -592,7 +592,7 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
{
|
||||
if (Handle(Graphic3d_ArrayOfSegments) aBndSegments = fillFaceBoundaries (theShape, theDrawer->FaceBoundaryUpperContinuity()))
|
||||
{
|
||||
Handle(Graphic3d_Group) aPrsGrp = Prs3d_Root::CurrentGroup (thePrs);
|
||||
Handle(Graphic3d_Group) aPrsGrp = thePrs->NewGroup();
|
||||
aPrsGrp->SetGroupPrimitivesAspect (theDrawer->FaceBoundaryAspect()->Aspect());
|
||||
aPrsGrp->AddPrimitiveArray (aBndSegments);
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
@@ -99,36 +100,17 @@ void StdPrs_WFShape::Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
return;
|
||||
}
|
||||
|
||||
Prs3d_ShapeTool aTool (theShape, theDrawer->VertexDrawMode() == Prs3d_VDM_All);
|
||||
|
||||
// Explore shape elements.
|
||||
TopTools_ListOfShape aLFree, aLUnFree, aLWire;
|
||||
for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
|
||||
// draw triangulation-only edges
|
||||
if (Handle(Graphic3d_ArrayOfPrimitives) aTriFreeEdges = AddEdgesOnTriangulation (theShape, Standard_True))
|
||||
{
|
||||
const TopoDS_Edge& anEdge = aTool.GetCurve();
|
||||
switch (aTool.Neighbours())
|
||||
{
|
||||
case 0: aLWire.Append (anEdge); break;
|
||||
case 1: aLFree.Append (anEdge); break;
|
||||
default: aLUnFree.Append (anEdge); break;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real aShapeDeflection = Prs3d::GetDeflection (theShape, theDrawer);
|
||||
|
||||
// Draw shape elements
|
||||
{
|
||||
Handle(Graphic3d_ArrayOfPrimitives) aTriFreeEdges = AddEdgesOnTriangulation (theShape, Standard_True);
|
||||
if (!aTriFreeEdges.IsNull())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
|
||||
aGroup->SetPrimitivesAspect (theDrawer->FreeBoundaryAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aTriFreeEdges);
|
||||
}
|
||||
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
|
||||
aGroup->SetPrimitivesAspect (theDrawer->FreeBoundaryAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aTriFreeEdges);
|
||||
}
|
||||
|
||||
Prs3d_NListOfSequenceOfPnt aCommonPolylines;
|
||||
const Handle(Prs3d_LineAspect)& aWireAspect = theDrawer->WireAspect();
|
||||
const Standard_Real aShapeDeflection = Prs3d::GetDeflection (theShape, theDrawer);
|
||||
|
||||
// Draw isolines
|
||||
{
|
||||
@@ -140,15 +122,15 @@ void StdPrs_WFShape::Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Handle(Prs3d_LineAspect)& anIsoAspectV = theDrawer->VIsoAspect();
|
||||
if (anIsoAspectV->Aspect()->IsEqual (*anIsoAspectU->Aspect()))
|
||||
{
|
||||
aVPolylinesPtr = aUPolylinesPtr;
|
||||
aVPolylinesPtr = aUPolylinesPtr; // put both U and V isolines into single group
|
||||
}
|
||||
if (anIsoAspectU->Aspect()->IsEqual (*aWireAspect->Aspect()))
|
||||
{
|
||||
aUPolylinesPtr = &aCommonPolylines;
|
||||
aUPolylinesPtr = &aCommonPolylines; // put U isolines into single group with common edges
|
||||
}
|
||||
if (anIsoAspectV->Aspect()->IsEqual (*aWireAspect->Aspect()))
|
||||
{
|
||||
aVPolylinesPtr = &aCommonPolylines;
|
||||
aVPolylinesPtr = &aCommonPolylines; // put V isolines into single group with common edges
|
||||
}
|
||||
|
||||
bool isParallelIso = false;
|
||||
@@ -194,54 +176,126 @@ void StdPrs_WFShape::Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
Prs3d::AddPrimitivesGroup (thePresentation, anIsoAspectV, aVPolylines);
|
||||
}
|
||||
|
||||
if (!aLWire.IsEmpty() && theDrawer->WireDraw())
|
||||
{
|
||||
addEdges (aLWire, theDrawer, aShapeDeflection, aCommonPolylines);
|
||||
}
|
||||
Prs3d_NListOfSequenceOfPnt anUnfree, aFree;
|
||||
Prs3d_NListOfSequenceOfPnt* anUnfreePtr = &anUnfree;
|
||||
Prs3d_NListOfSequenceOfPnt* aFreePtr = &aFree;
|
||||
if (!theDrawer->UnFreeBoundaryDraw())
|
||||
{
|
||||
anUnfreePtr = NULL;
|
||||
}
|
||||
else if (theDrawer->UnFreeBoundaryAspect()->Aspect()->IsEqual (*aWireAspect->Aspect()))
|
||||
{
|
||||
anUnfreePtr = &aCommonPolylines; // put unfree edges into single group with common edges
|
||||
}
|
||||
|
||||
if (!aLUnFree.IsEmpty() && theDrawer->UnFreeBoundaryDraw())
|
||||
{
|
||||
const Handle(Prs3d_LineAspect)& aLineAspect = theDrawer->UnFreeBoundaryAspect();
|
||||
if (!aLineAspect->Aspect()->IsEqual (*aWireAspect->Aspect()))
|
||||
if (!theDrawer->FreeBoundaryDraw())
|
||||
{
|
||||
Prs3d_NListOfSequenceOfPnt aPolylines;
|
||||
addEdges (aLUnFree, theDrawer, aShapeDeflection, aPolylines);
|
||||
Prs3d::AddPrimitivesGroup (thePresentation, aLineAspect, aPolylines);
|
||||
aFreePtr = NULL;
|
||||
}
|
||||
else
|
||||
else if (theDrawer->FreeBoundaryAspect()->Aspect()->IsEqual (*aWireAspect->Aspect()))
|
||||
{
|
||||
addEdges (aLUnFree, theDrawer, aShapeDeflection, aCommonPolylines);
|
||||
aFreePtr = &aCommonPolylines; // put free edges into single group with common edges
|
||||
}
|
||||
}
|
||||
|
||||
if (!aLFree.IsEmpty() && theDrawer->FreeBoundaryDraw())
|
||||
{
|
||||
const Handle(Prs3d_LineAspect)& aLineAspect = theDrawer->FreeBoundaryAspect();
|
||||
if (!aLineAspect->Aspect()->IsEqual (*aWireAspect->Aspect()))
|
||||
{
|
||||
Prs3d_NListOfSequenceOfPnt aPolylines;
|
||||
addEdges (aLFree, theDrawer, aShapeDeflection, aPolylines);
|
||||
Prs3d::AddPrimitivesGroup (thePresentation, aLineAspect, aPolylines);
|
||||
}
|
||||
else
|
||||
{
|
||||
addEdges (aLFree, theDrawer, aShapeDeflection, aCommonPolylines);
|
||||
}
|
||||
addEdges (theShape,
|
||||
theDrawer,
|
||||
aShapeDeflection,
|
||||
theDrawer->WireDraw() ? &aCommonPolylines : NULL,
|
||||
aFreePtr,
|
||||
anUnfreePtr);
|
||||
Prs3d::AddPrimitivesGroup (thePresentation, theDrawer->UnFreeBoundaryAspect(), anUnfree);
|
||||
Prs3d::AddPrimitivesGroup (thePresentation, theDrawer->FreeBoundaryAspect(), aFree);
|
||||
}
|
||||
|
||||
Prs3d::AddPrimitivesGroup (thePresentation, theDrawer->WireAspect(), aCommonPolylines);
|
||||
|
||||
if (Handle(Graphic3d_ArrayOfPoints) aVertexArray = AddVertexes (theShape, theDrawer->VertexDrawMode()))
|
||||
{
|
||||
TColgp_SequenceOfPnt aShapeVertices;
|
||||
for (aTool.InitVertex(); aTool.MoreVertex(); aTool.NextVertex())
|
||||
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
|
||||
aGroup->SetPrimitivesAspect (theDrawer->PointAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aVertexArray);
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// function : AddAllEdges
|
||||
// purpose :
|
||||
// =========================================================================
|
||||
Handle(Graphic3d_ArrayOfPrimitives) StdPrs_WFShape::AddAllEdges (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
const Standard_Real aShapeDeflection = Prs3d::GetDeflection (theShape, theDrawer);
|
||||
Prs3d_NListOfSequenceOfPnt aPolylines;
|
||||
addEdges (theShape, theDrawer, aShapeDeflection,
|
||||
&aPolylines, &aPolylines, &aPolylines);
|
||||
return Prs3d::PrimitivesFromPolylines (aPolylines);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// function : addEdges
|
||||
// purpose :
|
||||
// =========================================================================
|
||||
void StdPrs_WFShape::addEdges (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
Standard_Real theShapeDeflection,
|
||||
Prs3d_NListOfSequenceOfPnt* theWire,
|
||||
Prs3d_NListOfSequenceOfPnt* theFree,
|
||||
Prs3d_NListOfSequenceOfPnt* theUnFree)
|
||||
{
|
||||
if (theShape.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TopTools_ListOfShape aLWire, aLFree, aLUnFree;
|
||||
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
|
||||
TopExp::MapShapesAndAncestors (theShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap);
|
||||
for (TopTools_IndexedDataMapOfShapeListOfShape::Iterator anEdgeIter (anEdgeMap); anEdgeIter.More(); anEdgeIter.Next())
|
||||
{
|
||||
const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Key());
|
||||
const Standard_Integer aNbNeighbours = anEdgeIter.Value().Extent();
|
||||
switch (aNbNeighbours)
|
||||
{
|
||||
aShapeVertices.Append (BRep_Tool::Pnt (aTool.GetVertex()));
|
||||
}
|
||||
if (!aShapeVertices.IsEmpty())
|
||||
{
|
||||
addVertices (thePresentation, aShapeVertices, theDrawer->PointAspect());
|
||||
case 0:
|
||||
{
|
||||
if (theWire != NULL)
|
||||
{
|
||||
aLWire.Append (anEdge);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (theFree != NULL)
|
||||
{
|
||||
aLFree.Append (anEdge);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (theUnFree)
|
||||
{
|
||||
aLUnFree.Append (anEdge);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!aLWire.IsEmpty())
|
||||
{
|
||||
addEdges (aLWire, theDrawer, theShapeDeflection, *theWire);
|
||||
}
|
||||
if (!aLFree.IsEmpty())
|
||||
{
|
||||
addEdges (aLFree, theDrawer, theShapeDeflection, *theFree);
|
||||
}
|
||||
if (!aLUnFree.IsEmpty())
|
||||
{
|
||||
addEdges (aLUnFree, theDrawer, theShapeDeflection, *theUnFree);
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
@@ -452,26 +506,56 @@ void StdPrs_WFShape::AddEdgesOnTriangulation (TColgp_SequenceOfPnt& theSegments,
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// function : AddPoints
|
||||
// function : AddVertexes
|
||||
// purpose :
|
||||
// =========================================================================
|
||||
void StdPrs_WFShape::addVertices (const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const TColgp_SequenceOfPnt& theVertices,
|
||||
const Handle (Prs3d_PointAspect)& theAspect)
|
||||
Handle(Graphic3d_ArrayOfPoints) StdPrs_WFShape::AddVertexes (const TopoDS_Shape& theShape,
|
||||
Prs3d_VertexDrawMode theVertexMode)
|
||||
{
|
||||
Standard_Integer aNbVertices = theVertices.Length();
|
||||
if (aNbVertices < 1)
|
||||
TColgp_SequenceOfPnt aShapeVertices;
|
||||
if (theVertexMode == Prs3d_VDM_All)
|
||||
{
|
||||
return;
|
||||
for (TopExp_Explorer aVertIter (theShape, TopAbs_VERTEX); aVertIter.More(); aVertIter.Next())
|
||||
{
|
||||
const TopoDS_Vertex& aVert = TopoDS::Vertex (aVertIter.Current());
|
||||
aShapeVertices.Append (BRep_Tool::Pnt (aVert));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// isolated vertices
|
||||
for (TopExp_Explorer aVertIter (theShape, TopAbs_VERTEX, TopAbs_EDGE); aVertIter.More(); aVertIter.Next())
|
||||
{
|
||||
const TopoDS_Vertex& aVert = TopoDS::Vertex (aVertIter.Current());
|
||||
aShapeVertices.Append (BRep_Tool::Pnt (aVert));
|
||||
}
|
||||
|
||||
// internal vertices
|
||||
for (TopExp_Explorer anEdgeIter (theShape, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next())
|
||||
{
|
||||
for (TopoDS_Iterator aVertIter (anEdgeIter.Current(), Standard_False, Standard_True); aVertIter.More(); aVertIter.Next())
|
||||
{
|
||||
const TopoDS_Shape& aVertSh = aVertIter.Value();
|
||||
if (aVertSh.Orientation() == TopAbs_INTERNAL
|
||||
&& aVertSh.ShapeType() == TopAbs_VERTEX)
|
||||
{
|
||||
const TopoDS_Vertex& aVert = TopoDS::Vertex (aVertSh);
|
||||
aShapeVertices.Append (BRep_Tool::Pnt (aVert));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aShapeVertices.IsEmpty())
|
||||
{
|
||||
return Handle(Graphic3d_ArrayOfPoints)();
|
||||
}
|
||||
|
||||
const Standard_Integer aNbVertices = aShapeVertices.Length();
|
||||
Handle(Graphic3d_ArrayOfPoints) aVertexArray = new Graphic3d_ArrayOfPoints (aNbVertices);
|
||||
for (Standard_Integer anI = 1; anI <= aNbVertices; ++anI)
|
||||
for (Standard_Integer aVertIter = 1; aVertIter <= aNbVertices; ++aVertIter)
|
||||
{
|
||||
aVertexArray->AddVertex (theVertices.Value (anI));
|
||||
aVertexArray->AddVertex (aShapeVertices.Value (aVertIter));
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
|
||||
aGroup->SetPrimitivesAspect (theAspect->Aspect());
|
||||
aGroup->AddPrimitiveArray (aVertexArray);
|
||||
return aVertexArray;
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
|
||||
class Graphic3d_ArrayOfPoints;
|
||||
|
||||
//! Tool for computing wireframe presentation of a TopoDS_Shape.
|
||||
class StdPrs_WFShape : public Prs3d_Root
|
||||
{
|
||||
@@ -53,24 +55,44 @@ public:
|
||||
const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean theToExcludeGeometric = Standard_True);
|
||||
|
||||
//! Compute all edges (wire, free, unfree) and put them into single primitive array.
|
||||
//! @param theShape [in] the shape
|
||||
//! @param theDrawer [in] the drawer settings (deviation angle and maximal parameter value)
|
||||
Standard_EXPORT static Handle(Graphic3d_ArrayOfPrimitives) AddAllEdges (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer);
|
||||
|
||||
//! Compute vertex presentation for a shape.
|
||||
//! @param theShape [in] the shape
|
||||
//! @param theVertexMode [in] vertex filter
|
||||
Standard_EXPORT static Handle(Graphic3d_ArrayOfPoints) AddVertexes (const TopoDS_Shape& theShape,
|
||||
Prs3d_VertexDrawMode theVertexMode);
|
||||
|
||||
private:
|
||||
|
||||
//! Compute edge presentations for a shape.
|
||||
//! @param theEdges [in] the list of edges.
|
||||
//! @param theDrawer [in] the drawer settings.
|
||||
//! @param theShapeDeflection [in] the deflection for the wireframe shape.
|
||||
//! @param theShape [in] the shape
|
||||
//! @param theDrawer [in] the drawer settings (deviation angle and maximal parameter value)
|
||||
//! @param theShapeDeflection [in] the deflection for the wireframe shape
|
||||
//! @param theWire [out] output polylines for lonely wires
|
||||
//! @param theFree [out] output polylines for free edges
|
||||
//! @param theUnFree [out] output polylines for non-free edges
|
||||
Standard_EXPORT static void addEdges (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
Standard_Real theShapeDeflection,
|
||||
Prs3d_NListOfSequenceOfPnt* theWire,
|
||||
Prs3d_NListOfSequenceOfPnt* theFree,
|
||||
Prs3d_NListOfSequenceOfPnt* theUnFree);
|
||||
|
||||
//! Compute edge presentations for a shape.
|
||||
//! @param theEdges [in] the list of edges
|
||||
//! @param theDrawer [in] the drawer settings (deviation angle and maximal parameter value)
|
||||
//! @param theShapeDeflection [in] the deflection for the wireframe shape
|
||||
//! @param thePolylines [out] output polylines
|
||||
static void addEdges (const TopTools_ListOfShape& theEdges,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theShapeDeflection,
|
||||
Prs3d_NListOfSequenceOfPnt& thePolylines);
|
||||
|
||||
//! Compute vertex presentation for a shape.
|
||||
//! @param thePresentation [in] the presentation.
|
||||
//! @param theVertices [in] the list of points.
|
||||
//! @param theAspect [in] the point drawing aspect.
|
||||
static void addVertices (const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const TColgp_SequenceOfPnt& theVertices,
|
||||
const Handle (Prs3d_PointAspect)& theAspect);
|
||||
};
|
||||
|
||||
#endif // _StdPrs_WFShape_H__
|
||||
|
Reference in New Issue
Block a user