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 0e11e83c68
commit 90cd417fe4
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);