Moved some methods from PartDesign::Body to Part::BodyBase so the SketchObjects will be removed cleanly from the Body when deleted
This commit is contained in:
committed by
Stefan Tröger
parent
5b3d5e6bd8
commit
02dfb8551d
@@ -25,6 +25,8 @@
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Base/Placement.h>
|
||||
|
||||
#include "BodyBase.h"
|
||||
@@ -55,4 +57,25 @@ App::DocumentObjectExecReturn *BodyBase::execute(void)
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
}
|
||||
const bool BodyBase::hasFeature(const App::DocumentObject* f) const
|
||||
{
|
||||
const std::vector<App::DocumentObject*> features = Model.getValues();
|
||||
return std::find(features.begin(), features.end(), f) != features.end();
|
||||
}
|
||||
|
||||
BodyBase* BodyBase::findBodyOf(const App::DocumentObject* f)
|
||||
{
|
||||
App::Document* doc = App::GetApplication().getActiveDocument();
|
||||
if (doc != NULL) {
|
||||
std::vector<App::DocumentObject*> bodies = doc->getObjectsOfType(BodyBase::getClassTypeId());
|
||||
for (std::vector<App::DocumentObject*>::const_iterator b = bodies.begin(); b != bodies.end(); b++) {
|
||||
BodyBase* body = static_cast<BodyBase*>(*b);
|
||||
if (body->hasFeature(f))
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user