Improved bounding box calculation for datum feature display size
This commit is contained in:
committed by
Stefan Tröger
parent
02dfb8551d
commit
a6431ee5cf
@@ -25,12 +25,16 @@
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include <App/Plane.h>
|
||||
#include <Base/Placement.h>
|
||||
|
||||
#include "Feature.h"
|
||||
#include "Body.h"
|
||||
#include "BodyPy.h"
|
||||
#include "FeatureSketchBased.h"
|
||||
#include "DatumPoint.h"
|
||||
#include "DatumLine.h"
|
||||
#include "DatumPlane.h"
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
@@ -316,6 +320,38 @@ App::DocumentObjectExecReturn *Body::execute(void)
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
Base::BoundBox3d Body::getBoundBox()
|
||||
{
|
||||
Base::BoundBox3d result;
|
||||
|
||||
Part::Feature* tipSolid = static_cast<Part::Feature*>(getPrevSolidFeature());
|
||||
if (tipSolid != NULL) {
|
||||
result = tipSolid->Shape.getShape().getBoundBox();
|
||||
} else {
|
||||
result = App::Plane::getBoundBox();
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> model = Model.getValues();
|
||||
// TODO: In DatumLine and DatumPlane, recalculate the Base point to be as near as possible to the origin (0,0,0)
|
||||
for (std::vector<App::DocumentObject*>::const_iterator m = model.begin(); m != model.end(); m++) {
|
||||
if ((*m)->getTypeId().isDerivedFrom(PartDesign::Point::getClassTypeId())) {
|
||||
PartDesign::Point* point = static_cast<PartDesign::Point*>(*m);
|
||||
result.Add(point->_Point.getValue());
|
||||
} else if ((*m)->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) {
|
||||
PartDesign::Line* line = static_cast<PartDesign::Line*>(*m);
|
||||
result.Add(line->_Base.getValue());
|
||||
} else if ((*m)->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
|
||||
PartDesign::Plane* plane = static_cast<PartDesign::Plane*>(*m);
|
||||
result.Add(plane->_Base.getValue());
|
||||
} else if ((*m)->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
// Note: We only take into account the base planes here
|
||||
result.Add(Base::Vector3d(0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject *Body::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())){
|
||||
|
||||
Reference in New Issue
Block a user