Add function to check if a Transformed feature is a sub-feature of MultiTransform

This will check the in-list instead of relying on an empty Originals property.
This commit is contained in:
André Althaus
2024-03-25 01:33:43 +01:00
parent d12635246f
commit 4d9b89e265
2 changed files with 24 additions and 4 deletions

View File

@@ -43,6 +43,7 @@
#include "FeatureTransformed.h"
#include "Body.h"
#include "FeatureAddSub.h"
#include "FeatureMultiTransform.h"
#include "FeatureMirrored.h"
#include "FeatureLinearPattern.h"
#include "FeaturePolarPattern.h"
@@ -138,6 +139,22 @@ void Transformed::Restore(Base::XMLReader &reader)
PartDesign::Feature::Restore(reader);
}
bool Transformed::isMultiTransformChild() const
{
for (auto const* obj : getInList()) {
auto mt = Base::freecad_dynamic_cast<PartDesign::MultiTransform>(obj);
if (!mt) {
continue;
}
auto const transfmt = mt->Transformations.getValues();
if (std::find(transfmt.begin(), transfmt.end(), this) != transfmt.end()) {
return true;
}
}
return false;
}
void Transformed::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop)
{
// The property 'Angle' of PolarPattern has changed from PropertyFloat
@@ -165,9 +182,9 @@ short Transformed::mustExecute() const
App::DocumentObjectExecReturn *Transformed::execute()
{
std::vector<App::DocumentObject*> originals = Originals.getValues();
if (originals.empty()) // typically InsideMultiTransform
if (isMultiTransformChild()) {
return App::DocumentObject::StdReturn;
}
if(!this->BaseFeature.getValue()) {
auto body = getFeatureBody();
@@ -178,6 +195,7 @@ App::DocumentObjectExecReturn *Transformed::execute()
this->positionBySupport();
std::vector<App::DocumentObject*> originals = Originals.getValues();
// Remove suppressed features from the list so the transformations behave as if they are not there
{
auto eraseIter = std::remove_if(originals.begin(), originals.end(), [](App::DocumentObject const* obj) {

View File

@@ -45,8 +45,7 @@ public:
Transformed();
/** The shapes to be transformed
* if Originals is empty the instance is just a container for storing transformation data
*/
*/
App::PropertyLinkList Originals;
App::PropertyBool Refine;
@@ -90,6 +89,9 @@ public:
protected:
void Restore(Base::XMLReader &reader) override;
void handleChangedPropertyType(Base::XMLReader &reader, 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;
void divideTools(const std::vector<TopoDS_Shape> &toolsIn, std::vector<TopoDS_Shape> &individualsOut,