#include <gp_Pnt.hxx>
#include <NCollection_List.hxx>
#include <Precision.hxx>
+#include <Prs3d.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Presentation.hxx>
const TopoDS_Shape& theShape,
const Handle (Prs3d_Drawer)& theDrawer)
{
- if (theShape.ShapeType() != TopAbs_COMPOUND)
+ Standard_Boolean aDrawAllVerticesFlag = (theDrawer->VertexDrawMode() == Prs3d_VDM_All);
+
+ if (!aDrawAllVerticesFlag && theShape.ShapeType() != TopAbs_COMPOUND)
{
return;
}
return;
}
+ // We have to create a compound and collect all subshapes not drawn by the shading algo.
+ // This includes:
+ // - isolated edges
+ // - isolated vertices, if aDrawAllVerticesFlag == Standard_False
+ // - all shape's vertices, if aDrawAllVerticesFlag == Standard_True
TopoDS_Compound aCompoundWF;
BRep_Builder aBuilder;
aBuilder.MakeCompound (aCompoundWF);
hasElement = Standard_True;
aBuilder.Add (aCompoundWF, aShapeIter.Current());
}
- // isolated vertices
- for (aShapeIter.Init (theShape, TopAbs_VERTEX, TopAbs_EDGE); aShapeIter.More(); aShapeIter.Next())
+ // isolated or all vertices
+ aShapeIter.Init (theShape, TopAbs_VERTEX, aDrawAllVerticesFlag ? TopAbs_SHAPE : TopAbs_EDGE);
+ for (; aShapeIter.More(); aShapeIter.Next())
{
hasElement = Standard_True;
aBuilder.Add (aCompoundWF, aShapeIter.Current());
}
}
- //! Computes absolute deflection, required by drawer
- static Standard_Real getDeflection (const TopoDS_Shape& theShape,
- const Handle(Prs3d_Drawer)& theDrawer)
- {
- #define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
- #define MAX3(X, Y, Z) (MAX2 (MAX2 (X, Y), Z))
-
- Standard_Real aDeflection = theDrawer->MaximalChordialDeviation();
- if (theDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
- {
- Bnd_Box aBndBox;
- BRepBndLib::Add (theShape, aBndBox, Standard_False);
- if (!aBndBox.IsVoid())
- {
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
- aDeflection = MAX3 (aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * theDrawer->DeviationCoefficient() * 4.0;
- }
- }
- return aDeflection;
- }
-
//! Gets triangulation of every face of shape and fills output array of triangles
static Handle(Graphic3d_ArrayOfTriangles) fillTriangles (const TopoDS_Shape& theShape,
const Standard_Boolean theHasTexels,
const Handle (Prs3d_Drawer)& theDrawer)
{
// Check if it is possible to avoid unnecessary recomputation of shape triangulation
- Standard_Real aDeflection = getDeflection (theShape, theDrawer);
+ Standard_Real aDeflection = Prs3d::GetDeflection (theShape, theDrawer);
if (BRepTools::Triangulation (theShape, aDeflection))
{
return;