PartDesign: Fix bug of mirror transformation of multiple features

fixes #3317

This code ensures that an individual transformation or a multi-transformation have a proper
base feature and next feature.
This commit is contained in:
Abdullah Tahiri
2018-01-21 19:09:28 +01:00
committed by wmayer
parent 23f88c5d85
commit 01e6cde7aa
3 changed files with 30 additions and 4 deletions

View File

@@ -206,8 +206,17 @@ bool Body::isMemberOfMultiTransform(const App::DocumentObject* f)
if (f == NULL)
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 (f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()) &&
static_cast<const PartDesign::Transformed*>(f)->Originals.getValues().empty());
}
@@ -320,12 +329,18 @@ void Body::insertObject(App::DocumentObject* feature, App::DocumentObject* targe
Group.setValues (model);
// Set the BaseFeature property
setBaseProperty(feature);
}
void Body::setBaseProperty(App::DocumentObject* feature)
{
if (Body::isSolidFeature(feature)) {
// Set BaseFeature property to previous feature (this might be the Tip feature)
App::DocumentObject* prevSolidFeature = getPrevSolidFeature(feature);
// NULL is ok here, it just means we made the current one fiature the base solid
static_cast<PartDesign::Feature*>(feature)->BaseFeature.setValue(prevSolidFeature);
// Reroute the next solid feature's BaseFeature property to this feature
App::DocumentObject* nextSolidFeature = getNextSolidFeature(feature);
if (nextSolidFeature) {
@@ -333,10 +348,8 @@ void Body::insertObject(App::DocumentObject* feature, App::DocumentObject* targe
static_cast<PartDesign::Feature*>(nextSolidFeature)->BaseFeature.setValue(feature);
}
}
}
std::vector<App::DocumentObject*> Body::removeObject(App::DocumentObject* feature)
{
App::DocumentObject* nextSolidFeature = getNextSolidFeature(feature);

View File

@@ -84,6 +84,8 @@ public:
*/
void insertObject(App::DocumentObject* feature, App::DocumentObject* target, bool after=false);
void setBaseProperty(App::DocumentObject* feature);
/// Remove the feature from the body
virtual std::vector<DocumentObject*> removeObject(DocumentObject* obj) override;

View File

@@ -44,6 +44,7 @@
#include "FeatureLinearPattern.h"
#include "FeaturePolarPattern.h"
#include "FeatureSketchBased.h"
#include "Body.h"
#include <Base/Console.h>
#include <Base/Exception.h>
@@ -200,8 +201,18 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
rejected.clear();
std::vector<App::DocumentObject*> originals = Originals.getValues();
if (originals.empty()) // typically InsideMultiTransform
if (originals.empty()) {// typically InsideMultiTransform
return App::DocumentObject::StdReturn;
}
else {
if(!this->BaseFeature.getValue()) {
auto body = getFeatureBody();
if(body) {
body->setBaseProperty(this);
}
}
}
this->positionBySupport();