From 13acca75047cee891df4d40290a0cf91a148776e Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sat, 26 Nov 2022 22:08:55 -0500 Subject: [PATCH] [TD]fix ComplexSection null cut shape --- src/Mod/TechDraw/App/DrawComplexSection.cpp | 45 +++++++++------------ src/Mod/TechDraw/App/DrawComplexSection.h | 3 +- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawComplexSection.cpp b/src/Mod/TechDraw/App/DrawComplexSection.cpp index 4c2765b4a5..e2241889d0 100644 --- a/src/Mod/TechDraw/App/DrawComplexSection.cpp +++ b/src/Mod/TechDraw/App/DrawComplexSection.cpp @@ -133,7 +133,7 @@ const char *DrawComplexSection::ProjectionStrategyEnums[] = {"Offset", "Aligned" nullptr}; DrawComplexSection::DrawComplexSection() - : m_toolFaceShape(TopoDS_Shape()), m_profileWire(TopoDS_Wire()) + : m_toolFaceShape(TopoDS_Shape()) { static const char *fgroup = "Cutting Tool"; @@ -171,35 +171,17 @@ TopoDS_Shape DrawComplexSection::getShapeToCut() return DrawViewSection::getShapeToCut(); } -void DrawComplexSection::makeSectionCut(TopoDS_Shape &baseShape) -{ - // Base::Console().Message("DCS::makeSectionCut() - %s\n", getNameInDocument(), baseShape.IsNull()); - if (ProjectionStrategy.getValue() == 0) { - //Offset. Use regular section behaviour - DrawViewSection::makeSectionCut(baseShape); - return; - } - //Aligned strategy - if (debugSection()) { - //only useful for debugging with Aligned strategy - DrawViewSection::makeSectionCut(baseShape); - } - return; -} - TopoDS_Shape DrawComplexSection::makeCuttingTool(double dMax) { // Base::Console().Message("DCS::makeCuttingTool()\n"); - App::DocumentObject *toolObj = CuttingToolWireObject.getValue(); - if (!isProfileObject(toolObj)) { - return TopoDS_Shape(); + TopoDS_Wire profileWire = makeProfileWire(); + if (profileWire.IsNull()) { + throw Base::RuntimeError("Can not make wire from cutting tool (1)"); } - TopoDS_Wire profileWire = makeProfileWire(toolObj); - BRepBuilderAPI_Copy BuilderCopy(profileWire); - m_profileWire = TopoDS::Wire(BuilderCopy.Shape()); + if (debugSection()) { //the nose to tail version of the profile - BRepTools::Write(m_profileWire, "DCSProfileWire.brep");//debug + BRepTools::Write(profileWire, "DCSProfileWire.brep");//debug } gp_Ax2 sectionCS = getSectionCS(); @@ -326,7 +308,11 @@ TopoDS_Shape DrawComplexSection::makeAlignedPieces(const TopoDS_Shape &rawShape, gp_Vec gProjectionUnit = gp_Vec(getSectionCS().Direction()); //get a vector that describes the profile's orientation - gp_Vec gProfileVec = makeProfileVector(m_profileWire); + TopoDS_Wire profileWire = makeProfileWire(); + if (profileWire.IsNull()) { + throw Base::RuntimeError("Can not make wire from cutting tool (2)"); + } + gp_Vec gProfileVec = makeProfileVector(profileWire); //now we want to know what the profileVector looks like on the page (only X,Y coords) gProfileVec = projectVector(gProfileVec).Normalized(); @@ -611,10 +597,19 @@ TopoDS_Shape DrawComplexSection::getShapeToIntersect() //Aligned return m_preparedShape; } +TopoDS_Wire DrawComplexSection::makeProfileWire() const +{ + App::DocumentObject *toolObj = CuttingToolWireObject.getValue(); + return makeProfileWire(toolObj); +} TopoDS_Wire DrawComplexSection::makeProfileWire(App::DocumentObject *toolObj) { // Base::Console().Message("DCS::makeProfileWire()\n"); + if (!isProfileObject(toolObj)) { + return TopoDS_Wire(); + } + TopoDS_Shape toolShape = Part::Feature::getShape(toolObj); if (toolShape.IsNull()) { return TopoDS_Wire(); diff --git a/src/Mod/TechDraw/App/DrawComplexSection.h b/src/Mod/TechDraw/App/DrawComplexSection.h index 769ef31e0e..146f288329 100644 --- a/src/Mod/TechDraw/App/DrawComplexSection.h +++ b/src/Mod/TechDraw/App/DrawComplexSection.h @@ -53,7 +53,6 @@ public: TopoDS_Compound findSectionPlaneIntersections(const TopoDS_Shape &cutShape) override; TopoDS_Shape prepareShape(const TopoDS_Shape &cutShape, double shapeSize) override; TopoDS_Shape getShapeToPrepare() const override; - void makeSectionCut(TopoDS_Shape &baseShape) override; TopoDS_Shape getShapeToIntersect() override; gp_Pln getSectionPlane() const override; TopoDS_Compound alignSectionFaces(TopoDS_Shape faceIntersections) override; @@ -80,6 +79,7 @@ public: bool showSegment(gp_Dir segmentNormal) const; gp_Vec projectVector(const gp_Vec& vec) const; + TopoDS_Wire makeProfileWire() const; static TopoDS_Wire makeProfileWire(App::DocumentObject *toolObj); static TopoDS_Wire makeNoseToTailWire(TopoDS_Wire inWire); static gp_Vec makeProfileVector(TopoDS_Wire profileWire); @@ -94,7 +94,6 @@ private: gp_Dir getFaceNormal(TopoDS_Face &face); TopoDS_Shape m_toolFaceShape; - TopoDS_Wire m_profileWire; static const char *ProjectionStrategyEnums[]; };