aProjector : Projector from Prs3d;
aPresentation : Presentation from Prs3d;
ashape : Shape from TopoDS) is static private;
-
- GetDeflection(myclass; aShape : Shape from TopoDS;
- aDrawer : Drawer from Prs3d)
- returns Real from Standard;
DisplayBox(myclass; aPrs : Presentation from Prs3d;
aBox : Box from Bnd;
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_SequenceOfGroup.hxx>
+#include <Prs3d.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
static Standard_Boolean myFirstCompute;
-Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
- const Handle(Prs3d_Drawer)& aDrawer)
-{
- // WARNING: this same piece of code appears several times in Prs3d classes
- Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
- if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
- Bnd_Box B;
- BRepBndLib::Add(aShape, B, Standard_False);
- if ( ! B.IsVoid() )
- {
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
- aDeflection = Max( aXmax-aXmin, Max(aYmax-aYmin, aZmax-aZmin)) *
- aDrawer->DeviationCoefficient() * 4;
- }
- }
- return aDeflection;
-}
-
void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
const Bnd_Box& B,
const Handle(Prs3d_Drawer)& aDrawer)
// POP protection against crash in low layers
- Standard_Real aDeflection = GetDeflection(shape, myDrawer);
+ Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
Standard_Boolean autoTriangulation = Standard_True;
try {
OCC_CATCH_SIGNALS
package Prs3d
- ---Purpose: The Prs3d package provides the following services
- -- - a presentation object (the context for all
- -- modifications to the display, its presentation will be
- -- displayed in every view of an active viewer)
- -- - an attribute manager governing how objects such
- -- as color, width, and type of line are displayed;
- -- these are generic objects, whereas those in
- -- StdPrs are specific geometries and topologies.
- -- - generic algorithms providing default settings for
- -- objects such as points, curves, surfaces and shapes
- -- - a root object which provides the abstract
- -- framework for the DsgPrs definitions at work in
- -- display of dimensions, relations and trihedra.
+ ---Purpose: The Prs3d package provides the following services
+ -- - a presentation object (the context for all
+ -- modifications to the display, its presentation will be
+ -- displayed in every view of an active viewer)
+ -- - an attribute manager governing how objects such
+ -- as color, width, and type of line are displayed;
+ -- these are generic objects, whereas those in
+ -- StdPrs are specific geometries and topologies.
+ -- - generic algorithms providing default settings for
+ -- objects such as points, curves, surfaces and shapes
+ -- - a root object which provides the abstract
+ -- framework for the DsgPrs definitions at work in
+ -- display of dimensions, relations and trihedra.
uses
Graphic3d,
class Presentation;
- ---Category: Aspect classes.
+ ---Category: Aspect classes.
deferred class BasicAspect;
class PointAspect;
class LineAspect;
- class ShadingAspect;
- class TextAspect;
+ class ShadingAspect;
+ class TextAspect;
class IsoAspect;
class ArrowAspect;
- class PlaneAspect;
+ class PlaneAspect;
class DimensionAspect;
- class DatumAspect;
+ class DatumAspect;
imported DimensionUnits;
class Drawer;
---Category: Basis construction elements.
- class Text;
+ class Text;
---Category: Class signatures.
- class ShapeTool;
+ class ShapeTool;
class Arrow;
- ---Purpose: draws an arrow at a given location, with respect
- -- to a given direction.
+ ---Purpose: draws an arrow at a given location, with respect
+ -- to a given direction.
imported NListOfSequenceOfPnt;
imported NListIteratorListOfSequenceOfPnt;
imported WFShape;
MatchSegment(X,Y,Z: Length from Quantity;
- aDistance: Length from Quantity;
- p1,p2: Pnt from gp;
+ aDistance: Length from Quantity;
+ p1,p2: Pnt from gp;
dist: out Length from Quantity)
- returns Boolean from Standard;
+ returns Boolean from Standard;
+
+ GetDeflection (theShape : Shape from TopoDS;
+ theDrawer : Drawer from Prs3d)
+ returns Real from Standard;
+ ---Purpose: Computes the absolute deflection value depending on
+ -- the type of deflection in theDrawer:
+ -- <ul>
+ -- <li><b>Aspect_TOD_RELATIVE</b>: the absolute deflection is computed using the relative
+ -- deviation coefficient from theDrawer and the shape's bounding box;</li>
+ -- <li><b>Aspect_TOD_ABSOLUTE</b>: the maximal chordial deviation from theDrawer is returned.</li>
+ -- </ul>
+ -- This function should always be used to compute the deflection value for building
+ -- discrete representations of the shape (triangualtion, wireframe) to avoid incosistencies
+ -- between different representations of the shape and undesirable visual artifacts.
end Prs3d;
// commercial license or contractual agreement.
#include <Prs3d.ixx>
+#include <Bnd_Box.hxx>
+#include <BRepBndLib.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <TopoDS_Shape.hxx>
+//=======================================================================
+//function : MatchSegment
+//purpose :
+//=======================================================================
Standard_Boolean Prs3d::MatchSegment
(const Quantity_Length X,
- const Quantity_Length Y,
- const Quantity_Length Z,
- const Quantity_Length aDistance,
- const gp_Pnt& P1,
- const gp_Pnt& P2,
- Quantity_Length& dist) {
-
- Standard_Real X1,Y1,Z1,X2,Y2,Z2;
+ const Quantity_Length Y,
+ const Quantity_Length Z,
+ const Quantity_Length aDistance,
+ const gp_Pnt& P1,
+ const gp_Pnt& P2,
+ Quantity_Length& dist)
+{
+ Standard_Real X1,Y1,Z1,X2,Y2,Z2;
P1.Coord(X1,Y1,Z1); P2.Coord(X2,Y2,Z2);
Standard_Real DX = X2-X1;
Standard_Real DY = Y2-Y1;
Standard_Real Lambda = ((X-X1)*DX + (Y-Y1)*DY + (Z-Z1)*DZ)/Dist;
if ( Lambda < 0. || Lambda > 1. ) return Standard_False;
dist = Abs(X-X1-Lambda*DX) +
- Abs(Y-Y1-Lambda*DY) +
- Abs(Z-Z1-Lambda*DZ);
+ Abs(Y-Y1-Lambda*DY) +
+ Abs(Z-Z1-Lambda*DZ);
return (dist < aDistance);
+}
+
+//=======================================================================
+//function : GetDeflection
+//purpose :
+//=======================================================================
+Standard_Real Prs3d::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;
}
-
#include <Poly_Array1OfTriangle.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
+#include <Prs3d.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_PointAspect.hxx>
}
}
- Standard_Real aDeflection = theDrawer->MaximalChordialDeviation();
- if (theDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
- {
- // The arrow calculation is based on the global min max
- Bnd_Box aBndBox;
- BRepBndLib::Add (theShape, aBndBox);
- if (!aBndBox.IsVoid())
- {
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
- aDeflection = Max (aXmax-aXmin, Max (aYmax-aYmin, aZmax-aZmin))
- * theDrawer->DeviationCoefficient();
- }
- }
+ Standard_Real aDeflection = Prs3d::GetDeflection(theShape, theDrawer);
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
#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>
}
}
- //! 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;
vdisplay result
vfit
-set x1 101
+###set x1 101
+set x1 102
set y1 199
set Color [QAGetPixelColor ${x1} ${y1}]
--- /dev/null
+puts "============"
+puts "CR25071"
+puts "============"
+puts ""
+#######################################################################
+# Check that the selected wireframe representation uses exactly the same
+# discretization of face boundaries as the face outlines shown in shading mode
+#######################################################################
+
+vinit View1
+
+# Computing wireframe without triangulation, then checking face boundaries and selection
+pcone c 0 5 10
+vdisplay c; vfit
+vsetdispmode c 1
+vshowfaceboundary c 1 64 64 0
+vselect 200 200
+
+vdump $imagedir/${casename}_wf_no_triang.png
+
+vremove c
+vclose View1
+vinit View1
+
+# Computing wireframe after triangulation, then checking face boundaries and selection
+vsetdispmode 1
+vdisplay c; vfit
+vshowfaceboundary c 1 64 64 0
+vselect 200 200
+
+vdump $imagedir/${casename}_wf_with_triang.png