Skip to content

Commit

Permalink
[TD]fix ComplexSection null cut shape
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Nov 27, 2022
1 parent c23ee7a commit 13acca7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
45 changes: 20 additions & 25 deletions src/Mod/TechDraw/App/DrawComplexSection.cpp
Expand Up @@ -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";

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/Mod/TechDraw/App/DrawComplexSection.h
Expand Up @@ -53,7 +53,6 @@ class TechDrawExport DrawComplexSection: public DrawViewSection
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;
Expand All @@ -80,6 +79,7 @@ class TechDrawExport DrawComplexSection: public DrawViewSection
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);
Expand All @@ -94,7 +94,6 @@ class TechDrawExport DrawComplexSection: public DrawViewSection
gp_Dir getFaceNormal(TopoDS_Face &face);

TopoDS_Shape m_toolFaceShape;
TopoDS_Wire m_profileWire;

static const char *ProjectionStrategyEnums[];
};
Expand Down

0 comments on commit 13acca7

Please sign in to comment.