Allow datum lines and planes for Transformed features' references

This commit is contained in:
jrheinlaender
2013-05-15 20:37:14 +04:30
committed by Stefan Tröger
parent 54895922a4
commit 4524103dbc
16 changed files with 1709 additions and 203 deletions

View File

@@ -34,6 +34,9 @@
#include "FeatureLinearPattern.h"
#include "DatumPlane.h"
#include "DatumLine.h"
#include <App/Plane.h>
#include <Base/Axis.h>
#include <Base/Exception.h>
#include <Mod/Part/App/TopoShape.h>
@@ -79,10 +82,9 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
App::DocumentObject* refObject = Direction.getValue();
if (refObject == NULL)
throw Base::Exception("No direction reference specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Direction reference must be edge or face of a feature");
std::vector<std::string> subStrings = Direction.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
if (subStrings.empty())
throw Base::Exception("No direction reference specified");
gp_Dir dir;
@@ -102,7 +104,23 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
}
axis *= refSketch->Placement.getValue();
dir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
} else {
} else if (refObject->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
PartDesign::Plane* plane = static_cast<PartDesign::Plane*>(refObject);
Base::Vector3d d = plane->getNormal();
dir = gp_Dir(d.x, d.y, d.z);
} else if (refObject->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) {
PartDesign::Line* line = static_cast<PartDesign::Line*>(refObject);
Base::Vector3d d = line->getDirection();
dir = gp_Dir(d.x, d.y, d.z);
} else if (refObject->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
App::Plane* plane = static_cast<App::Plane*>(refObject);
Base::Rotation rot = plane->Placement.getValue().getRotation();
Base::Vector3d d(0,0,1);
rot.multVec(d, d);
dir = gp_Dir(d.x, d.y, d.z);
} else if (refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (subStrings[0].empty())
throw Base::Exception("No direction reference specified");
Part::Feature* refFeature = static_cast<Part::Feature*>(refObject);
Part::TopoShape refShape = refFeature->Shape.getShape();
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
@@ -128,6 +146,8 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
} else {
throw Base::Exception("Direction reference must be edge or face");
}
} else {
throw Base::Exception("Direction reference must be edge/face of a feature or a datum line/plane");
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
dir.Transform(invObjLoc.Transformation());