Improve GeoFeatureGroup claim children algorithm and remove special Body impelmentation

This commit is contained in:
Stefan Tröger
2017-09-18 20:08:34 +02:00
committed by wmayer
parent 84667e46f0
commit 5e079d331b
3 changed files with 23 additions and 104 deletions

View File

@@ -178,80 +178,6 @@ bool ViewProviderBody::doubleClicked(void)
return true;
}
std::vector<App::DocumentObject*> ViewProviderBody::claimChildren(void)const
{
PartDesign::Body* body= static_cast<PartDesign::Body*> ( getObject () );
const std::vector<App::DocumentObject*> &model = body->Group.getValues ();
std::set<App::DocumentObject*> outSet; //< set of objects not to claim (childrens of childrens)
// search for objects handled (claimed) by the features
for( auto obj: model){
if (!obj) { continue; }
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider ( obj );
if (!vp) { continue; }
auto children = vp->claimChildren();
std::remove_copy ( children.begin (), children.end (), std::inserter (outSet, outSet.begin () ), nullptr);
}
// remove the otherwise handled objects, preserving their order so the order in the TreeWidget is correct
std::vector<App::DocumentObject*> Result;
if (body->Origin.getValue()) { // Clame for the Origin
Result.push_back (body->Origin.getValue());
}
// claim for rest content not claimed by any other features
std::remove_copy_if (model.begin(), model.end(), std::back_inserter (Result),
[outSet] (App::DocumentObject* obj) {
return outSet.find (obj) != outSet.end();
} );
return Result;
}
std::vector<App::DocumentObject*> ViewProviderBody::claimChildren3D(void)const
{
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
const std::vector<App::DocumentObject*> & features = body->Group.getValues();
std::vector<App::DocumentObject*> rv;
if ( body->Origin.getValue() ) { // Add origin
rv.push_back (body->Origin.getValue());
}
if ( body->BaseFeature.getValue() ) { // Add Base Feature
rv.push_back (body->BaseFeature.getValue());
}
// Add all other stuff
std::copy (features.begin(), features.end(), std::back_inserter (rv) );
return rv;
}
// TODO To be deleted (2015-09-08, Fat-Zer)
//void ViewProviderBody::updateTree()