TechDraw: Add option to use polygonal HLR algorithm

Now on property panel there is option 'Coarse View' which allows to set
selected drawing view's Hidden Line Removal to utilize polygonal algorithm.
This should be faster on same cases (complex models).

When this option is set for a view there is known limitation with dimensions not
working on this experimental mode. At least currently this is best utilized on
view with no dimensions.

Also the vertices' 'black dots' are not drawn on this mode view to avoid
cluttering.  Face hilite is avoided, to gain speed. All curves are represented
by short linesegments in this mode.

Previously TechDraw always used OCC's exact HLR algorithm to generate views,
which produces good quality and continous shape lines but is sometimes
slower to generate than with polygonal approach.

Additionally now there is bool 'CoarseView' Parameter Editor setting, if anyone
wants to set this as their default.
This commit is contained in:
TeroK
2018-01-13 12:45:48 +02:00
committed by wmayer
parent e697f2ef50
commit 434bf4d3f3
6 changed files with 113 additions and 13 deletions

View File

@@ -43,6 +43,14 @@
#include <HLRBRep_Algo.hxx>
#include <HLRBRep_HLRToShape.hxx>
#include <HLRAlgo_Projector.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <HLRBRep_PolyAlgo.hxx>
#include <HLRBRep_PolyHLRToShape.hxx>
#include <Poly_Triangulation.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
@@ -83,7 +91,9 @@ GeometryObject::GeometryObject(const string& parent, TechDraw::DrawView* parentO
m_parent(parentObj),
m_isoCount(0),
m_isPersp(false),
m_focus(100.0)
m_focus(100.0),
m_usePolygonHLR(false)
{
}
@@ -209,9 +219,77 @@ void GeometryObject::projectShape(const TopoDS_Shape& input,
catch (...) {
Standard_Failure::Raise("GeometryObject::projectShape - error occurred while extracting edges");
}
}
//!set up a hidden line remover and project a shape with it
void GeometryObject::projectShapeWithPolygonAlgo(const TopoDS_Shape& input,
const gp_Ax2 viewAxis)
{
// Clear previous Geometry
clear();
auto start = chrono::high_resolution_clock::now();
Handle(HLRBRep_PolyAlgo) brep_hlrPoly = NULL;
try {
TopExp_Explorer faces(input, TopAbs_FACE);
for (int i = 1; faces.More(); faces.Next(), i++) {
const TopoDS_Face& f = TopoDS::Face(faces.Current());
if (!f.IsNull()) {
BRepMesh_IncrementalMesh(f, 0.10); //Poly Algo requires a mesh!
}
}
brep_hlrPoly = new HLRBRep_PolyAlgo();
brep_hlrPoly->Load(input);
if (m_isPersp) {
double fLength = std::max(Precision::Confusion(), m_focus);
HLRAlgo_Projector projector(viewAxis, fLength);
brep_hlrPoly->Projector(projector);
}
else { // non perspective
HLRAlgo_Projector projector(viewAxis);
brep_hlrPoly->Projector(projector);
}
brep_hlrPoly->Update();
}
catch (...) {
Standard_Failure::Raise("GeometryObject::projectShapeWithPolygonAlgo - error occurred while projecting shape");
}
auto end = chrono::high_resolution_clock::now();
auto diff = end - start;
double diffOut = chrono::duration <double, milli>(diff).count();
Base::Console().Log("TIMING - %s GO spent: %.3f millisecs in HLRBRep_PolyAlgo & co\n", m_parentName.c_str(), diffOut);
try {
HLRBRep_PolyHLRToShape polyhlrToShape;
polyhlrToShape.Update(brep_hlrPoly);
visHard = polyhlrToShape.VCompound();
visSmooth = polyhlrToShape.Rg1LineVCompound();
visSeam = polyhlrToShape.RgNLineVCompound();
visOutline = polyhlrToShape.OutLineVCompound();
hidHard = polyhlrToShape.HCompound();
hidSmooth = polyhlrToShape.Rg1LineHCompound();
hidSeam = polyhlrToShape.RgNLineHCompound();
hidOutline = polyhlrToShape.OutLineHCompound();
//need these 3d curves to prevent "zero edges" later
BRepLib::BuildCurves3d(visHard);
BRepLib::BuildCurves3d(visSmooth);
BRepLib::BuildCurves3d(visSeam);
BRepLib::BuildCurves3d(visOutline);
BRepLib::BuildCurves3d(hidHard);
BRepLib::BuildCurves3d(hidSmooth);
BRepLib::BuildCurves3d(hidSeam);
BRepLib::BuildCurves3d(hidOutline);
}
catch (...) {
Standard_Failure::Raise("GeometryObject::projectShapeWithPolygonAlgo - error occurred while extracting edges");
}
}
//!add edges meeting filter criteria for category, visibility
void GeometryObject::extractGeometry(edgeClass category, bool visible)
{