1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0023200: Visualization - prevent multiple triangulating of a shape that already has been triangulated

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
This commit is contained in:
osa
2015-03-05 14:48:42 +03:00
committed by bugmaster
parent 5149c3f34b
commit 4c5133866b
19 changed files with 280 additions and 76 deletions

View File

@@ -64,9 +64,12 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
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);

View File

@@ -33,6 +33,7 @@
#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>
@@ -40,6 +41,7 @@
#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>
@@ -105,6 +107,42 @@ namespace
}
}
//! 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,
@@ -504,8 +542,15 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
// 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