From a281832627b45a40bda1a8dd26c316872ab90ba4 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 15 Oct 2018 15:37:52 -0400 Subject: [PATCH] Change tool from cylinder to prism - cutting with cylinder produced too many short bsplines from HLR. Straight cut from prism reduces these and speeds up HLR significantly. --- src/Mod/TechDraw/App/DrawViewDetail.cpp | 30 +++++++++++++++---------- src/Mod/TechDraw/App/DrawViewPart.cpp | 9 +++++++- src/Mod/TechDraw/App/GeometryObject.cpp | 7 ++++++ src/Mod/TechDraw/Gui/QGIMatting.cpp | 2 +- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index ff787204c0..09b8066b2d 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -75,6 +75,7 @@ #include #include +#include #include "Geometry.h" #include "GeometryObject.h" @@ -196,11 +197,10 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void) -shapeRotate); myShape = TechDrawGeometry::moveShape(myShape, //centre on origin -shapeCenter); -// shapeCenter = Base::Vector3d(0.0,0.0,0.0); gpCenter = TechDrawGeometry::findCentroid(myShape, dirDetail); shapeCenter = Base::Vector3d(gpCenter.X(),gpCenter.Y(),gpCenter.Z()); - + Bnd_Box bbxSource; bbxSource.SetGap(0.0); BRepBndLib::Add(myShape, bbxSource); @@ -220,14 +220,18 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void) extentNear = extentNear - offsetCenter3D; } - gp_Dir cylDir(dirDetail.x,dirDetail.y,dirDetail.z); - gp_Pnt cylPoint(extentNear.x,extentNear.y,extentNear.z); - gp_Ax2 cylAxis(cylPoint,cylDir); - - BRepPrimAPI_MakeCylinder mkCyl(cylAxis, radius, (extentFar-extentNear).Length()); - TopoDS_Shell sh = mkCyl.Cylinder().Shell(); - BRepBuilderAPI_MakeSolid mkSol(sh); - TopoDS_Solid tool = mkSol.Solid(); + gp_Pnt gpnt(extentNear.x,extentNear.y,extentNear.z); + gp_Dir gdir(dirDetail.x,dirDetail.y,dirDetail.z); + gp_Pln gpln(gpnt,gdir); + double hideToolRadius = radius * 1.0; + BRepBuilderAPI_MakeFace mkFace(gpln, -hideToolRadius,hideToolRadius,-hideToolRadius,hideToolRadius); + TopoDS_Face aProjFace = mkFace.Face(); + if(aProjFace.IsNull()) { + return new App::DocumentObjectExecReturn("DrawViewDetail - Projected face is NULL"); + } + Base::Vector3d extrudeVec = dirDetail* (extentFar-extentNear).Length(); + gp_Vec extrudeDir(extrudeVec.x,extrudeVec.y,extrudeVec.z); + TopoDS_Shape tool = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape(); BRepAlgoAPI_Common mkCommon(myShape,tool); if (!mkCommon.IsDone()) { @@ -243,7 +247,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void) TopExp_Explorer xp; xp.Init(mkCommon.Shape(),TopAbs_SOLID); if (!(xp.More() == Standard_True)) { - Base::Console().Message("DVD::execute - mkCommon.Shape is not a solid!\n"); + Base::Console().Warning("DVD::execute - mkCommon.Shape is not a solid!\n"); } TopoDS_Shape detail = mkCommon.Shape(); Bnd_Box testBox; @@ -274,6 +278,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void) viewAxis, Rotation.getValue()); //degrees cw? } + geometryObject = buildGeometryObject(mirroredShape,viewAxis); geometryObject->pruneVertexGeom(Base::Vector3d(0.0,0.0,0.0),Radius.getValue() * scale); //remove vertices beyond clipradius @@ -291,7 +296,8 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void) #endif //#if MOD_TECHDRAW_HANDLE_FACES } catch (Standard_Failure& e1) { - Base::Console().Log("LOG - DVD::execute - base shape failed for %s - %s **\n",getNameInDocument(),e1.GetMessageString()); + Base::Console().Message("LOG - DVD::execute - failed to create detail %s - %s **\n",getNameInDocument(),e1.GetMessageString()); + return new App::DocumentObjectExecReturn(e1.GetMessageString()); } diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index def322a193..e5d7e29f60 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -335,7 +335,9 @@ TechDrawGeometry::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape go->projectShape(shape, viewAxis); } - + + auto start = chrono::high_resolution_clock::now(); + go->extractGeometry(TechDrawGeometry::ecHARD, //always show the hard&outline visible lines true); go->extractGeometry(TechDrawGeometry::ecOUTLINE, @@ -370,6 +372,11 @@ TechDrawGeometry::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape go->extractGeometry(TechDrawGeometry::ecUVISO, false); } + auto end = chrono::high_resolution_clock::now(); + auto diff = end - start; + double diffOut = chrono::duration (diff).count(); + Base::Console().Log("TIMING - %s DVP spent: %.3f millisecs in GO::extractGeometry\n",getNameInDocument(),diffOut); + bbox = go->calcBoundingBox(); return go; } diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp index b6df74fdfd..8118d4b32f 100644 --- a/src/Mod/TechDraw/App/GeometryObject.cpp +++ b/src/Mod/TechDraw/App/GeometryObject.cpp @@ -192,6 +192,8 @@ void GeometryObject::projectShape(const TopoDS_Shape& input, double diffOut = chrono::duration (diff).count(); Base::Console().Log("TIMING - %s GO spent: %.3f millisecs in HLRBRep_Algo & co\n",m_parentName.c_str(),diffOut); + start = chrono::high_resolution_clock::now(); + try { HLRBRep_HLRToShape hlrToShape(brep_hlr); @@ -221,6 +223,11 @@ void GeometryObject::projectShape(const TopoDS_Shape& input, catch (...) { Standard_Failure::Raise("GeometryObject::projectShape - error occurred while extracting edges"); } + end = chrono::high_resolution_clock::now(); + diff = end - start; + diffOut = chrono::duration (diff).count(); + Base::Console().Log("TIMING - %s GO spent: %.3f millisecs in hlrToShape and BuildCurves\n",m_parentName.c_str(),diffOut); + } //!set up a hidden line remover and project a shape with it diff --git a/src/Mod/TechDraw/Gui/QGIMatting.cpp b/src/Mod/TechDraw/Gui/QGIMatting.cpp index 0bb70316c8..eedb639794 100644 --- a/src/Mod/TechDraw/Gui/QGIMatting.cpp +++ b/src/Mod/TechDraw/Gui/QGIMatting.cpp @@ -79,7 +79,7 @@ QGIMatting::QGIMatting() : void QGIMatting::draw() { prepareGeometryChange(); - double radiusFudge = 1.1; //keep slightly larger than fudge in App/DVDetail to prevent bleed through + double radiusFudge = 1.25; //keep slightly larger than fudge in App/DVDetail to prevent bleed through double outerRadius = m_radius * radiusFudge; m_width = outerRadius; m_height = outerRadius;