Skip to content

Commit

Permalink
PD: fix ProfileBased::getSupportFace() to also handle the case where …
Browse files Browse the repository at this point in the history
…a support face is selected
  • Loading branch information
wwmayer committed Jul 16, 2022
1 parent fcd5394 commit 6564086
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/Mod/PartDesign/App/FeatureSketchBased.cpp
Expand Up @@ -296,14 +296,24 @@ std::vector<TopoDS_Wire> ProfileBased::getProfileWires() const {
// Note: We cannot return a reference, because it will become Null.
// Not clear where, because we check for IsNull() here, but as soon as it is passed out of
// this method, it becomes null!
const TopoDS_Face ProfileBased::getSupportFace() const {
const Part::Part2DObject* sketch = getVerifiedSketch();
if (sketch->MapMode.getValue() == Attacher::mmFlatFace && sketch->Support.getValue()) {
const TopoDS_Face ProfileBased::getSupportFace() const
{
const Part::Part2DObject* sketch = getVerifiedSketch(true);
if (sketch) {
return getSupportFace(sketch);
}

return getSupportFace(Profile);
}

TopoDS_Face ProfileBased::getSupportFace(const Part::Part2DObject* sketch) const
{
if (sketch && sketch->MapMode.getValue() == Attacher::mmFlatFace && sketch->Support.getValue()) {
const auto& Support = sketch->Support;
App::DocumentObject* ref = Support.getValue();

Part::Feature* part = static_cast<Part::Feature*>(ref);
if (part && part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
Part::Feature* part = dynamic_cast<Part::Feature*>(ref);
if (part) {
const std::vector<std::string>& sub = Support.getSubValues();
assert(sub.size() == 1);

Expand Down Expand Up @@ -335,6 +345,18 @@ const TopoDS_Face ProfileBased::getSupportFace() const {
return TopoDS::Face(Feature::makeShapeFromPlane(sketch));
}

TopoDS_Face ProfileBased::getSupportFace(const App::PropertyLinkSub& link) const
{
App::DocumentObject* result = link.getValue();
if (!result) {
throw Base::RuntimeError("No support linked");
}

TopoDS_Face face;
getFaceFromLinkSub(face, link);
return face;
}

int ProfileBased::getSketchAxisCount(void) const
{
Part::Part2DObject* sketch = static_cast<Part::Part2DObject*>(Profile.getValue());
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/PartDesign/App/FeatureSketchBased.h
Expand Up @@ -124,6 +124,9 @@ class PartDesignExport ProfileBased : public PartDesign::FeatureAddSub
protected:
void remapSupportShape(const TopoDS_Shape&);

TopoDS_Face getSupportFace(const Part::Part2DObject*) const;
TopoDS_Face getSupportFace(const App::PropertyLinkSub& link) const;

/// Extract a face from a given LinkSub
static void getFaceFromLinkSub(TopoDS_Face& upToFace,
const App::PropertyLinkSub& refFace);
Expand Down

3 comments on commit 6564086

@donovaly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks!
Can I backport this to 0.20.1?
Is this a known bug?

@wwmayer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a known bug?

It's a known limitation not directly a bug. When deciding to add this commit to v0.20 then you must also add its parent commit.

@donovaly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a known limitation not directly a bug.

OK. However this seems as something worth to be backported and at least my personal preference is to backport things that are maybe only annoyances. I would cunt this one into this.

It's a known limitation not directly a bug. When deciding to add this commit to v0.20 then you must also add its parent commit.

Thanks. I backported now both and will watch of the CI runs fine on this.

Please sign in to comment.