PD: fix ProfileBased::getSupportFace() to also handle the case where a support face is selected

This commit is contained in:
wmayer
2022-07-16 16:08:09 +02:00
parent b0065c5827
commit da70aa2dc6
2 changed files with 30 additions and 5 deletions

View File

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

View File

@@ -124,6 +124,9 @@ public:
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);