Add new flag IsAutoTriangulated to Prs3d_Drawer. It is True by default.
If this flag is True automatic re-triangulation with deflection-check logic will be applied.
Else this feature will be disable and triangulation is expected to be computed by application itself.
Change the syntax of vdefalts command.
Add new parameter -autoTriang for check of AutoTriangulated functionality.
Adjust camera position in test case bugs/xde/bug23969
if (theMode == AIS_Shaded)
{
- // compute mesh for entire shape beforehand to ensure consistency and optimizations (parallelization)
- Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
- Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
- Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
- if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
- || (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
+ if (myDrawer->IsAutoTriangulation())
{
- BRepTools::Clean (myshape);
+ // compute mesh for entire shape beforehand to ensure consistency and optimizations (parallelization)
+ Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
+ Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
+ Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
+ if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
+ || (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
+ {
+ BRepTools::Clean (myshape);
+ }
+ StdPrs_ShadedShape::Tessellate (myshape, myDrawer);
}
- StdPrs_ShadedShape::Tessellate (myshape, myDrawer);
}
TopoDS_Compound anOpened, aClosed;
// process HLRAngle and HLRDeviationCoefficient()
Standard_Real aPrevAngle = myDrawer->HLRAngle();
Standard_Real aNewAngle = aDefaultDrawer->HLRAngle();
- if (Abs (aNewAngle - aPrevAngle) > Precision::Angular())
+ if (myDrawer->IsAutoTriangulation() &&
+ Abs (aNewAngle - aPrevAngle) > Precision::Angular())
{
BRepTools::Clean (theShape);
}
}
case 1:
{
- Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
- Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
- Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
- if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
- || (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
+ if (myDrawer->IsAutoTriangulation())
{
- BRepTools::Clean (myshape);
+ Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
+ Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
+ Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
+ if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
+ || (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
+ {
+ BRepTools::Clean (myshape);
+ }
}
//shading only on face...
Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
-// coefficients for calculation
-
- Standard_Real prevangle, newangle ,prevcoeff,newcoeff ;
- Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle(newangle,prevangle);
- Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient(newcoeff,prevcoeff);
- if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
- ((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient)) {
-#ifdef OCCT_DEBUG
- cout << "AIS_Shape : compute"<<endl;
- cout << "newangle : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl;
- cout << "newcoeff : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
-#endif
+ if (myDrawer->IsAutoTriangulation())
+ {
+ // coefficients for calculation
+ Standard_Real aPrevAngle, aNewAngle, aPrevCoeff, aNewCoeff;
+ Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle (aNewAngle, aPrevAngle);
+ Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient (aNewCoeff, aPrevCoeff);
+ if (((Abs (aNewAngle - aPrevAngle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
+ ((Abs (aNewCoeff - aPrevCoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient))
+ {
BRepTools::Clean(SH);
}
+ }
{
try {
// POP protection against crash in low layers
Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
- Standard_Boolean autoTriangulation = Standard_True;
try {
OCC_CATCH_SIGNALS
StdSelect_BRepSelectionTool::Load(aSelection,
TypOfSel,
aDeflection,
myDrawer->HLRAngle(),
- autoTriangulation);
+ myDrawer->IsAutoTriangulation());
} catch ( Standard_Failure ) {
// cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<<endl;
if ( aMode == 0 ) {
case AIS_Shaded:
case 3: // texture mapping on triangulation
{
- Standard_Real prevangle;
- Standard_Real newangle;
- Standard_Real prevcoeff;
- Standard_Real newcoeff;
-
- Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle(newangle,prevangle);
- Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(newcoeff,prevcoeff);
- if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnDeviationAngle) ||
- ((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnDeviationCoefficient)) {
- BRepTools::Clean (myshape);
+ if (myDrawer->IsAutoTriangulation())
+ {
+ Standard_Real aPrevAngle;
+ Standard_Real aNewAngle;
+ Standard_Real aPrevCoeff;
+ Standard_Real aNewCoeff;
+
+ Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (aNewAngle, aPrevAngle);
+ Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient (aNewCoeff,aPrevCoeff);
+ if (((Abs (aNewAngle - aPrevAngle) > Precision::Angular()) && isOwnDeviationAngle) ||
+ ((Abs (aNewCoeff - aPrevCoeff) > Precision::Confusion()) && isOwnDeviationCoefficient))
+ {
+ BRepTools::Clean (myshape);
+ }
}
if (myshape.ShapeType() > TopAbs_FACE)
myHasOwnHLRDeviationAngle (Standard_False),
myIsoOnPlane (Standard_False),
myHasOwnIsoOnPlane (Standard_False),
+ myIsAutoTriangulated (Standard_True),
+ myHasOwnIsAutoTriangulated (Standard_False),
myHasOwnUIsoAspect (Standard_False),
myHasOwnVIsoAspect (Standard_False),
myHasOwnHLRDeviationAngle = Standard_True;
}
+// =======================================================================
+// function : SetAutoTriangulation
+// purpose :
+// =======================================================================
+
+void Prs3d_Drawer::SetAutoTriangulation (const Standard_Boolean theIsEnabled)
+{
+ myHasOwnIsAutoTriangulated = Standard_True;
+ myIsAutoTriangulated = theIsEnabled;
+}
+
// =======================================================================
// function : FreeBoundaryAspect
// purpose :
myHasOwnDeviationAngle = Standard_False;
myHasOwnHLRDeviationAngle = Standard_False;
myHasOwnIsoOnPlane = Standard_False;
+ myHasOwnIsAutoTriangulated = Standard_False;
myHasOwnWireDraw = Standard_False;
myHasOwnShadingAspectGlobal = Standard_False;
myHasOwnLineArrowDraw = Standard_False;
: 0.0;
}
+ //! Sets IsAutoTriangulated on or off by setting the parameter theIsEnabled to true or false.
+ //! If this flag is True automatic re-triangulation with deflection-check logic will be applied.
+ //! Else this feature will be disable and triangulation is expected to be computed by application itself
+ //! and no shading presentation at all if unavailable.
+ Standard_EXPORT void SetAutoTriangulation (const Standard_Boolean theIsEnabled);
+
+ //! Returns True if automatic triangulation is enabled.
+ Standard_Boolean IsAutoTriangulation() const
+ {
+ return HasOwnIsAutoTriangulation() || myLink.IsNull()
+ ? myIsAutoTriangulated
+ : myLink->IsAutoTriangulation();
+ }
+
+ //! Returns true if the drawer has IsoOnPlane setting active.
+ Standard_Boolean HasOwnIsAutoTriangulation() const { return myHasOwnIsAutoTriangulated; }
+
//! Defines the attributes which are used when drawing an
//! U isoparametric curve of a face. Defines the number
//! of U isoparametric curves to be drawn for a single face.
Standard_Real myPreviousHLRDeviationAngle;
Standard_Boolean myIsoOnPlane;
Standard_Boolean myHasOwnIsoOnPlane;
+ Standard_Boolean myIsAutoTriangulated;
+ Standard_Boolean myHasOwnIsAutoTriangulated;
Handle(Prs3d_IsoAspect) myUIsoAspect;
Standard_Boolean myHasOwnUIsoAspect;
TColgp_SequenceOfPnt HiddenPnts;
TColgp_SequenceOfPnt SeenPnts;
- const Standard_Boolean rel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE;
- Standard_Real def = rel? aDrawer->HLRDeviationCoefficient() : aDrawer->MaximalChordialDeviation();
- BRepMesh_IncrementalMesh mesh(aShape, def, rel, aDrawer->HLRAngle());
+ if (aDrawer->IsAutoTriangulation())
+ {
+ const Standard_Boolean aRel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE;
+ Standard_Real aDef = aRel ? aDrawer->HLRDeviationCoefficient() : aDrawer->MaximalChordialDeviation();
+ BRepMesh_IncrementalMesh mesh(aShape, aDef, aRel, aDrawer->HLRAngle());
+ }
Handle(HLRBRep_PolyAlgo) hider = new HLRBRep_PolyAlgo(aShape);
#include <Precision.hxx>
#include <Prs3d.hxx>
#include <Prs3d_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <StdPrs_ToolShadedShape.hxx>
+#include <StdPrs_WFDeflectionShape.hxx>
#include <StdPrs_WFShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
}
}
+ //! Computes special wireframe presentation for faces without triangulation.
+ void wireframeNoTriangFacesFromShape (const Handle(Prs3d_Presentation)& thePrs,
+ const TopoDS_Shape& theShape,
+ const Handle(Prs3d_Drawer)& theDrawer)
+ {
+ TopoDS_Compound aCompoundWF;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound (aCompoundWF);
+ TopLoc_Location aLoc;
+ Standard_Boolean hasElement = Standard_False;
+
+ for (TopExp_Explorer aShapeIter(theShape, TopAbs_FACE); aShapeIter.More(); aShapeIter.Next())
+ {
+ const TopoDS_Face& aFace = TopoDS::Face (aShapeIter.Current());
+ const Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation (aFace, aLoc);
+ if (aTriang.IsNull())
+ {
+ hasElement = Standard_True;
+ aBuilder.Add (aCompoundWF, aFace);
+ }
+ }
+
+ if (hasElement)
+ {
+ Standard_Integer aPrevUIsoNb = theDrawer->UIsoAspect()->Number();
+ Standard_Integer aPrevVIsoNb = theDrawer->VIsoAspect()->Number();
+ theDrawer->UIsoAspect()->SetNumber (5);
+ theDrawer->VIsoAspect()->SetNumber (5);
+
+ StdPrs_WFDeflectionShape::Add (thePrs, aCompoundWF, theDrawer);
+
+ theDrawer->UIsoAspect()->SetNumber (aPrevUIsoNb);
+ theDrawer->VIsoAspect()->SetNumber (aPrevVIsoNb);
+ }
+ }
+
//! 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,
// add wireframe presentation for isolated edges and vertices
wireframeFromShape (thePrs, theShape, theDrawer);
- // Triangulation completeness is important for "open-closed" analysis - perform tessellation beforehand
- Tessellate (theShape, theDrawer);
+ // Use automatic re-triangulation with deflection-check logic only if this feature is enable
+ if (theDrawer->IsAutoTriangulation())
+ {
+ // Triangulation completeness is important for "open-closed" analysis - perform tessellation beforehand
+ Tessellate (theShape, theDrawer);
+ }
+
+ // add special wireframe presentation for faces without triangulation
+ wireframeNoTriangFacesFromShape (thePrs, theShape, theDrawer);
// The shape types listed below need advanced analysis as potentially containing
// both closed and open parts. Solids are also included, because they might
<< "AbsoluteDeflection: " << aDefParams->MaximalChordialDeviation() << "\n";
}
theDi << "AngularDeflection: " << (180.0 * aDefParams->HLRAngle() / M_PI) << "\n";
+ theDi << "AutoTriangulation: " << (aDefParams->IsAutoTriangulation() ? "on" : "off") << "\n";
return 0;
}
for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
{
TCollection_AsciiString anArg (theArgVec[anArgIter]);
- TCollection_AsciiString aKey, aValue;
- if (!ViewerTest::SplitParameter (anArg, aKey, aValue)
- || aValue.IsEmpty())
- {
- std::cerr << "Error, wrong syntax at: '" << anArg.ToCString() << "'!\n";
- return 1;
- }
-
- aKey.UpperCase();
- if (aKey == "ABSDEFL"
- || aKey == "ABSOLUTEDEFLECTION"
- || aKey == "DEFL"
- || aKey == "DEFLECTION")
+ anArg.UpperCase();
+ if (anArg == "-ABSDEFL"
+ || anArg == "-ABSOLUTEDEFLECTION"
+ || anArg == "-DEFL"
+ || anArg == "-DEFLECTION")
{
+ if (++anArgIter >= theArgsNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
aDefParams->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE);
- aDefParams->SetMaximalChordialDeviation (aValue.RealValue());
+ aDefParams->SetMaximalChordialDeviation (Draw::Atof (theArgVec[anArgIter]));
}
- else if (aKey == "RELDEFL"
- || aKey == "RELATIVEDEFLECTION"
- || aKey == "DEVCOEFF"
- || aKey == "DEVIATIONCOEFF"
- || aKey == "DEVIATIONCOEFFICIENT")
+ else if (anArg == "-RELDEFL"
+ || anArg == "-RELATIVEDEFLECTION"
+ || anArg == "-DEVCOEFF"
+ || anArg == "-DEVIATIONCOEFF"
+ || anArg == "-DEVIATIONCOEFFICIENT")
{
+ if (++anArgIter >= theArgsNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
aDefParams->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
- aDefParams->SetDeviationCoefficient (aValue.RealValue());
+ aDefParams->SetDeviationCoefficient (Draw::Atof (theArgVec[anArgIter]));
}
- else if (aKey == "ANGDEFL"
- || aKey == "ANGULARDEFL"
- || aKey == "ANGULARDEFLECTION")
+ else if (anArg == "-ANGDEFL"
+ || anArg == "-ANGULARDEFL"
+ || anArg == "-ANGULARDEFLECTION")
{
+ if (++anArgIter >= theArgsNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
// currently HLRDeviationAngle is used instead of DeviationAngle in most places
- aDefParams->SetHLRAngle (M_PI * aValue.RealValue() / 180.0);
+ aDefParams->SetHLRAngle (M_PI * Draw::Atof (theArgVec[anArgIter]) / 180.0);
+ }
+ if (anArg == "-AUTOTR"
+ || anArg == "-AUTOTRIANG"
+ || anArg == "-AUTOTRIANGULATION")
+ {
+ if (++anArgIter >= theArgsNb)
+ {
+ std::cout << "Error: wrong syntax at " << anArg << "\n";
+ return 1;
+ }
+ TCollection_AsciiString aValue (theArgVec[anArgIter]);
+ aValue.LowerCase();
+ if (aValue == "on"
+ || aValue == "1")
+ {
+ aDefParams->SetAutoTriangulation (Standard_True);
+ }
+ else if (aValue == "off"
+ || aValue == "0")
+ {
+ aDefParams->SetAutoTriangulation (Standard_False);
+ }
}
else
{
" this command sets texture details mode for the specified view.\n"
, __FILE__, VSetTextureMode, group);
theCommands.Add("vdefaults",
- "vdefaults [absDefl=value] [devCoeff=value] [angDefl=value]",
- __FILE__, VDefaults, group);
+ "vdefaults [-absDefl value]"
+ "\n\t\t: [-devCoeff value]"
+ "\n\t\t: [-angDefl value]"
+ "\n\t\t: [-autoTriang {off/on | 0/1}]"
+ , __FILE__, VDefaults, group);
theCommands.Add("vlight",
"tool to manage light sources, without arguments shows list of lights."
"\n Main commands: "
# set rough meshing parameters
vinit
-vdefaults absDefl=10 devCoeff=0.1
+vdefaults -absDefl 10 -devCoeff 0.1
puts "Displaying two equal cones, one with Phong shader"
pcone p_gouraud 10 100 100
--- /dev/null
+puts "============"
+puts "CR23200"
+puts "Check that the shape is automatic re-triangulated with deflection-check logic"
+puts "in case of enabled auto triangulation feature (its own triangulation can be lost)."
+puts "And it keeps its already computed triangulation"
+puts "in case of disabled auto triangulation feature."
+puts "============"
+puts ""
+
+set aDefaultShape $imagedir/${casename}_shape.png
+set aShapeAutoTr $imagedir/${casename}_shape_auto_triangulation.png
+set aShapeNotAutoTr $imagedir/${casename}_shape_not_auto_triangulation.png
+
+vinit View1
+vclear
+vaxo
+vsetdispmode 1
+vdefaults -autoTriang on
+psphere s 0.5
+vdisplay s
+vfit
+vdump $aDefaultShape
+
+vclear
+tclean s
+incmesh s 0.1 -a 45
+set tri_info [trinfo s]
+regexp { +([-0-9.+eE]+) +triangles} $tri_info full triIncmesh1
+
+vdisplay s
+set tri_info [trinfo s]
+regexp { +([-0-9.+eE]+) +triangles} $tri_info full triAutoTrShape
+vfit
+vdump $aShapeAutoTr
+
+vclear
+vdefaults -autoTriang off
+tclean s
+incmesh s 0.1 -a 45
+set tri_info [trinfo s]
+regexp { +([-0-9.+eE]+) +triangles} $tri_info full triIncmesh2
+
+vdisplay s
+set tri_info [trinfo s]
+regexp { +([-0-9.+eE]+) +triangles} $tri_info full triNotAutoTrShape
+vfit
+vdump $aShapeNotAutoTr
+
+if {${triIncmesh1} == ${triAutoTrShape}} {
+ puts "ERROR : Test failed. Incorrect triangulation in case of enabled auto triangulation feature."
+}
+if {${triIncmesh2} != ${triNotAutoTrShape}} {
+ puts "ERROR : Test failed. Incorrect triangulation in case of disabled auto triangulation feature."
+}
--- /dev/null
+puts "============"
+puts "CR23200"
+puts "Check that the shape doesn't have a shading presentation"
+puts "due to its triangulation isn't computed in case of disabled auto triangulation feature."
+puts "But in this case the shape should have special wireframe presentation."
+puts "============"
+puts ""
+
+vinit View1
+vclear
+vaxo
+vsetdispmode 1
+vdefaults -autoTriang off
+pcone c 0 5 10
+vdisplay c
+vfit
+
+set aColor [vreadpixel 200 77 rgb name]
+vdump $imagedir/${casename}_shape_pres.png
+
+if {"$aColor" != "GRAY75"} {
+ puts "Error: shading presentation of shape is incorrect"
+}
vdisplay s
vfit
-vdefaults angDefl=1
+vdefaults -angDefl 1
vsetdispmode s 1
vdump ${imagedir}/${casename}_1.png
vdisplay s
vfit
-vdefaults angDefl=1
+vdefaults -angDefl 1
vsetdispmode s 1
vdump ${imagedir}/${casename}_1.png
vdisplay s
vfit
-vdefaults angDefl=1
+vdefaults -angDefl 1
vsetdispmode s 1
vdump ${imagedir}/${casename}_1.png
vinit
vsetdispmode 1
vdisplay res_1
+
vfit
+vdump $::imagedir/${::casename}_fit.png
+
+vviewparams -eye 106.849 -177.049 169.775 -at -70.2 -5.456e-015 -7.274 -up -0.408 0.408 0.816 -scale 3.048
set ver_color [vreadpixel 157 104]
if {$ver_color == "0 0 0 0"} {
if {$ver_color == "0 0 0 0"} {
puts "ERROR: OCC23969 is reproduced"
}
+vdump $::imagedir/${::casename}_center.png
set 3dviewer 1
# draw box
vinit View1
vclear
-vdefaults absDefl=0.5
+vdefaults -absDefl 0.5
vsetdispmode 1
vaxo
vdisplay f
# draw box
vinit View1
vclear
-vdefaults absDefl=0.5
+vdefaults -absDefl 0.5
vsetdispmode 1
vaxo
vdisplay f
# draw box
vinit View1
vclear
-vdefaults absDefl=0.5
+vdefaults -absDefl 0.5
vsetdispmode 1
vaxo
vdisplay f