Fix solid feature detection for "Transform Body" mode

Because the Origins property is empty in "Transform Body" mode, the
features are detected as not solid.
This messes with the feature order on insertions and moves.

This is fixed by calling the isMultitransformChild() method of the
Transformed features instead of checking the Origins property in the
Body code.
This commit is contained in:
André Althaus
2024-03-28 11:43:32 +01:00
parent f021ea6c7f
commit f4aa5879cc
3 changed files with 15 additions and 30 deletions

View File

@@ -183,35 +183,22 @@ bool Body::isAfterInsertPoint(App::DocumentObject* feature) {
}
}
bool Body::isMemberOfMultiTransform(const App::DocumentObject* obj)
{
if (!obj)
return false;
// ORIGINAL COMMENT:
// This can be recognized because the Originals property is empty (it is contained
// in the MultiTransform instead)
// COMMENT ON THE COMMENT:
// This is wrong because at the creation (addObject) and before assigning the originals, that
// is when this code is executed, the originals property is indeed empty.
//
// However, for the purpose of setting the base feature, the transform feature has been modified
// to auto set it when the originals are not null. See:
// App::DocumentObjectExecReturn *Transformed::execute(void)
//
return (obj->isDerivedFrom<PartDesign::Transformed>() &&
static_cast<const PartDesign::Transformed*>(obj)->Originals.getValues().empty());
}
bool Body::isSolidFeature(const App::DocumentObject *obj)
{
if (!obj)
if (!obj) {
return false;
}
if (obj->isDerivedFrom<PartDesign::Feature>() &&
!PartDesign::Feature::isDatum(obj)) {
// Transformed Features inside a MultiTransform are not solid features
return !isMemberOfMultiTransform(obj);
if (obj->isDerivedFrom<PartDesign::Feature>()) {
if (PartDesign::Feature::isDatum(obj)) {
// Datum objects are not solid
return false;
}
if (auto transFeature = Base::freecad_dynamic_cast<PartDesign::Transformed>(obj)) {
// Transformed Features inside a MultiTransform are not solid features
return !transFeature->isMultiTransformChild();
}
return true;
}
return false;//DeepSOIC: work-in-progress?
}

View File

@@ -91,9 +91,6 @@ public:
*/
bool isAfterInsertPoint(App::DocumentObject* feature);
/// Return true if the given feature is member of a MultiTransform feature
static bool isMemberOfMultiTransform(const App::DocumentObject *obj);
/**
* Return true if the given feature is a solid feature allowed in a Body. Currently this is only valid
* for features derived from PartDesign::Feature

View File

@@ -70,6 +70,9 @@ public:
/// Return the sketch of the first original
App::DocumentObject* getSketchObject() const;
/// Return true if this feature is a child of a MultiTransform
bool isMultiTransformChild() const;
/// Get the list of transformations describing the members of the pattern
// Note: Only the Scaled feature requires the originals
virtual const std::list<gp_Trsf>
@@ -102,8 +105,6 @@ protected:
const char* TypeName,
App::Property* prop) override;
/// Return true if this feature is a child of a MultiTransform
bool isMultiTransformChild() const;
virtual void positionBySupport();
TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const;
static TopoDS_Shape getRemainingSolids(const TopoDS_Shape&);