[TD]fix ComplexSection null cut shape

This commit is contained in:
wandererfan
2022-11-26 22:08:55 -05:00
committed by WandererFan
parent c23ee7ad88
commit 13acca7504
2 changed files with 21 additions and 27 deletions

View File

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

View File

@@ -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[];
};