Measure: Fix quickmeasure problem with Part::Line objects

This commit is contained in:
PaddleStroke
2024-11-06 09:20:37 +01:00
committed by Yorik van Havre
parent 9898461d3c
commit df3bf98ef7

View File

@@ -122,68 +122,63 @@ MeasureType Measurement::findType()
int other = 0;
for (; obj != objects.end(); ++obj, ++subEl) {
// Check if solid object
if (strcmp((*subEl).c_str(), "") == 0) {
vols++;
TopoDS_Shape refSubShape;
try {
refSubShape = Part::Feature::getShape(*obj, (*subEl).c_str(), true);
if (refSubShape.IsNull()) {
return MeasureType::Invalid;
}
}
else {
catch (Standard_Failure& e) {
std::stringstream errorMsg;
TopoDS_Shape refSubShape;
try {
refSubShape = Part::Feature::getShape(*obj, (*subEl).c_str(), true);
if (refSubShape.IsNull()) {
return MeasureType::Invalid;
errorMsg << "Measurement - getType - " << e.GetMessageString() << std::endl;
throw Base::CADKernelError(e.GetMessageString());
}
switch (refSubShape.ShapeType()) {
case TopAbs_VERTEX: {
verts++;
} break;
case TopAbs_EDGE: {
edges++;
TopoDS_Edge edge = TopoDS::Edge(refSubShape);
BRepAdaptor_Curve sf(edge);
if (sf.GetType() == GeomAbs_Line) {
lines++;
}
}
catch (Standard_Failure& e) {
std::stringstream errorMsg;
else if (sf.GetType() == GeomAbs_Circle) {
circles++;
}
} break;
case TopAbs_FACE: {
faces++;
TopoDS_Face face = TopoDS::Face(refSubShape);
BRepAdaptor_Surface sf(face);
errorMsg << "Measurement - getType - " << e.GetMessageString() << std::endl;
throw Base::CADKernelError(e.GetMessageString());
}
switch (refSubShape.ShapeType()) {
case TopAbs_VERTEX: {
verts++;
} break;
case TopAbs_EDGE: {
edges++;
TopoDS_Edge edge = TopoDS::Edge(refSubShape);
BRepAdaptor_Curve sf(edge);
if (sf.GetType() == GeomAbs_Line) {
lines++;
}
else if (sf.GetType() == GeomAbs_Circle) {
circles++;
}
} break;
case TopAbs_FACE: {
faces++;
TopoDS_Face face = TopoDS::Face(refSubShape);
BRepAdaptor_Surface sf(face);
if (sf.GetType() == GeomAbs_Plane) {
planes++;
}
else if (sf.GetType() == GeomAbs_Cylinder) {
cylinders++;
}
else if (sf.GetType() == GeomAbs_Sphere) {
spheres++;
}
else if (sf.GetType() == GeomAbs_Cone) {
cones++;
}
else if (sf.GetType() == GeomAbs_Torus) {
torus++;
}
} break;
default:
other++;
break;
}
if (sf.GetType() == GeomAbs_Plane) {
planes++;
}
else if (sf.GetType() == GeomAbs_Cylinder) {
cylinders++;
}
else if (sf.GetType() == GeomAbs_Sphere) {
spheres++;
}
else if (sf.GetType() == GeomAbs_Cone) {
cones++;
}
else if (sf.GetType() == GeomAbs_Torus) {
torus++;
}
} break;
case TopAbs_SOLID: {
vols++;
} break;
default:
other++;
break;
}
}
@@ -287,7 +282,7 @@ TopoDS_Shape Measurement::getShape(App::DocumentObject* rootObj, const char* sub
{
std::vector<std::string> names = Base::Tools::splitSubName(subName);
if (names.empty() || names.back() == "") {
if (names.empty()) {
TopoDS_Shape shape = Part::Feature::getShape(rootObj);
if (shape.IsNull()) {
throw Part::NullShapeException("null shape in measurement");