Improved bounding box calculation for datum feature display size

This commit is contained in:
jrheinlaender
2013-05-06 11:39:53 +04:30
committed by Stefan Tröger
parent 02dfb8551d
commit a6431ee5cf
7 changed files with 52 additions and 11 deletions

View File

@@ -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())){