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.
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <double, milli> (diff).count();
|
||||
Base::Console().Log("TIMING - %s DVP spent: %.3f millisecs in GO::extractGeometry\n",getNameInDocument(),diffOut);
|
||||
|
||||
bbox = go->calcBoundingBox();
|
||||
return go;
|
||||
}
|
||||
|
||||
@@ -192,6 +192,8 @@ void GeometryObject::projectShape(const TopoDS_Shape& input,
|
||||
double diffOut = chrono::duration <double, milli> (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 <double, milli> (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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user