Measure: Fix retrival of shape in measure geomtery handlers
This commit is contained in:
@@ -89,21 +89,18 @@ static float getRadius(TopoDS_Shape& edge){
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
TopoDS_Shape getLocatedShape(const App::SubObjectT& subject)
|
||||
TopoDS_Shape getLocatedShape(const App::SubObjectT& subject, Base::Matrix4D* mat = nullptr)
|
||||
{
|
||||
App::DocumentObject* obj = subject.getSubObjectList().back();
|
||||
if (!obj) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Part::TopoShape shape = Part::Feature::getTopoShape(obj, subject.getElementName());
|
||||
Part::TopoShape shape = Part::Feature::getTopoShape(obj, subject.getElementName(), false, mat, nullptr, true);
|
||||
if (shape.isNull()) {
|
||||
Base::Console().Log("Part::MeasureClient::getLocatedShape: Did not retrieve shape for %s, %s\n", obj->getNameInDocument(), subject.getElementName());
|
||||
return {};
|
||||
}
|
||||
auto geoFeat = dynamic_cast<App::GeoFeature*>(obj);
|
||||
if (geoFeat) {
|
||||
shape.setPlacement(geoFeat->globalPlacement());
|
||||
}
|
||||
|
||||
// Don't get the subShape from datum elements
|
||||
if (obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) {
|
||||
@@ -181,31 +178,22 @@ bool getShapeFromStrings(TopoDS_Shape &shapeOut, const App::SubObjectT& subject,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Part::VectorAdapter buildAdapter(const App::SubObjectT& subject)
|
||||
{
|
||||
if (!subject.getObject()) {
|
||||
return Part::VectorAdapter();
|
||||
}
|
||||
Base::Matrix4D mat;
|
||||
TopoDS_Shape shape = Part::Feature::getShape(subject.getObject(), subject.getElementName(), true);
|
||||
TopoDS_Shape shape = getLocatedShape(subject, &mat);
|
||||
|
||||
if (shape.IsNull()) {
|
||||
// failure here on loading document with existing measurement.
|
||||
Base::Console().Message("Part::buildAdapter did not retrieve shape for %s, %s\n",
|
||||
subject.getObjectName(), subject.getElementName());
|
||||
return Part::VectorAdapter();
|
||||
}
|
||||
|
||||
TopAbs_ShapeEnum shapeType = shape.ShapeType();
|
||||
|
||||
|
||||
if (shapeType == TopAbs_EDGE)
|
||||
{
|
||||
TopoDS_Shape edgeShape;
|
||||
if (!getShapeFromStrings(edgeShape, subject, &mat)) {
|
||||
return {};
|
||||
}
|
||||
TopoDS_Edge edge = TopoDS::Edge(edgeShape);
|
||||
TopoDS_Edge edge = TopoDS::Edge(shape);
|
||||
// make edge orientation so that end of edge closest to pick is head of vector.
|
||||
TopoDS_Vertex firstVertex = TopExp::FirstVertex(edge, Standard_True);
|
||||
TopoDS_Vertex lastVertex = TopExp::LastVertex(edge, Standard_True);
|
||||
@@ -232,12 +220,7 @@ Part::VectorAdapter buildAdapter(const App::SubObjectT& subject)
|
||||
}
|
||||
if (shapeType == TopAbs_FACE)
|
||||
{
|
||||
TopoDS_Shape faceShape;
|
||||
if (!getShapeFromStrings(faceShape, subject, &mat)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
TopoDS_Face face = TopoDS::Face(faceShape);
|
||||
TopoDS_Face face = TopoDS::Face(shape);
|
||||
Base::Vector3d vTemp(0.0, 0.0, 0.0); //v(current.x, current.y, current.z);
|
||||
vTemp = mat*vTemp;
|
||||
gp_Vec pickPoint(vTemp.x, vTemp.y, vTemp.z);
|
||||
|
||||
Reference in New Issue
Block a user