diff --git a/src/Mod/Inspection/App/InspectionFeature.cpp b/src/Mod/Inspection/App/InspectionFeature.cpp index af329f6ea6..36efecf560 100644 --- a/src/Mod/Inspection/App/InspectionFeature.cpp +++ b/src/Mod/Inspection/App/InspectionFeature.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -112,8 +113,20 @@ InspectActualShape::InspectActualShape(const Part::TopoShape& shape) : _rShape(s Base::BoundBox3d bbox = _rShape.getBoundBox(); Standard_Real deflection = (bbox.LengthX() + bbox.LengthY() + bbox.LengthZ())/300.0 * deviation; - std::vector f; - _rShape.getFaces(points, f, (float)deflection); + // get points from faces or sub-sampled edges + TopTools_IndexedMapOfShape mapOfShapes; + TopExp::MapShapes(_rShape.getShape(), TopAbs_FACE, mapOfShapes); + if (!mapOfShapes.IsEmpty()) { + std::vector f; + _rShape.getFaces(points, f, (float)deflection); + } + else { + TopExp::MapShapes(_rShape.getShape(), TopAbs_EDGE, mapOfShapes); + if (!mapOfShapes.IsEmpty()) { + std::vector n; + _rShape.getPoints(points, n, (float)deflection); + } + } } unsigned long InspectActualShape::countPoints() const @@ -483,7 +496,7 @@ float InspectNominalShape::getDistance(const Base::Vector3f& point) const } else if (fMinDist > 0) { - // check if the distance was compued from a face + // check if the distance was computed from a face for (Standard_Integer index = 1; index <= distss->NbSolution(); index++) { if (distss->SupportTypeShape1(index) == BRepExtrema_IsInFace) { TopoDS_Shape face = distss->SupportOnShape1(index); @@ -700,6 +713,8 @@ public: } double getRMS() { + if (this->m_numv == 0) + return 0.0; return sqrt(this->m_sumsq / (double)this->m_numv); } int m_numv; diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index a52625bbe2..8c44b25d3d 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -218,6 +218,14 @@ void ViewProviderInspection::updateData(const App::Property* prop) Base::BoundBox3d bbox = data->getBoundBox(); accuracy = (float)((bbox.LengthX() + bbox.LengthY() + bbox.LengthZ())/300.0 * deviation); data->getFaces(points, faces, accuracy); + if (points.empty()) { + std::vector normals_d; + data->getPoints(points, normals_d, accuracy); + normals.reserve(normals_d.size()); + std::transform(normals_d.cbegin(), normals_d.cend(), std::back_inserter(normals), [](const Base::Vector3d& p){ + return Base::toVector(p); + }); + } } } else if (object->getTypeId().isDerivedFrom(pointId)) {