Inspection: [skip ci] do not use multi-threading when Part objects are used for visual inspection

This commit is contained in:
wmayer
2020-09-08 16:55:35 +02:00
parent 48e0b570fc
commit f388ba1048

View File

@@ -692,7 +692,7 @@ struct DistanceInspection
// Helper internal class for QtConcurrent map operation. Holds sums-of-squares and counts for RMS calculation
class DistanceInspectionRMS {
public:
DistanceInspectionRMS() : m_numv(0), m_sumsq(0.0) {};
DistanceInspectionRMS() : m_numv(0), m_sumsq(0.0) {}
DistanceInspectionRMS& operator += (const DistanceInspectionRMS& rhs)
{
this->m_numv += rhs.m_numv;
@@ -738,6 +738,8 @@ short Feature::mustExecute() const
App::DocumentObjectExecReturn* Feature::execute(void)
{
bool useMultithreading = true;
App::DocumentObject* pcActual = Actual.getValue();
if (!pcActual)
throw Base::ValueError("No actual geometry to inspect specified");
@@ -752,6 +754,7 @@ App::DocumentObjectExecReturn* Feature::execute(void)
actual = new InspectActualPoints(pts->Points.getValue());
}
else if (pcActual->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
useMultithreading = false;
Part::Feature* part = static_cast<Part::Feature*>(pcActual);
actual = new InspectActualShape(part->Shape.getShape());
}
@@ -773,6 +776,7 @@ App::DocumentObjectExecReturn* Feature::execute(void)
nominal = new InspectNominalPoints(pts->Points.getValue(), this->SearchRadius.getValue());
}
else if ((*it)->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
useMultithreading = false;
Part::Feature* part = static_cast<Part::Feature*>(*it);
nominal = new InspectNominalShape(part->Shape.getValue(), this->SearchRadius.getValue());
}
@@ -836,7 +840,6 @@ App::DocumentObjectExecReturn* Feature::execute(void)
Base::Console().Message("RMS value for '%s' with search radius [%.4f,%.4f] is: %.4f\n",
this->Label.getValue(), -this->SearchRadius.getValue(), this->SearchRadius.getValue(), fRMS);
#else
bool useMultithreading = true;
unsigned long count = actual->countPoints();
std::vector<float> vals(count);
std::function<DistanceInspectionRMS(int)> fMap = [&](unsigned int index)
@@ -851,10 +854,12 @@ App::DocumentObjectExecReturn* Feature::execute(void)
fMinDist = fDist;
}
if (fMinDist > this->SearchRadius.getValue())
if (fMinDist > this->SearchRadius.getValue()) {
fMinDist = FLT_MAX;
else if (-fMinDist > this->SearchRadius.getValue())
}
else if (-fMinDist > this->SearchRadius.getValue()) {
fMinDist = -FLT_MAX;
}
else {
res.m_sumsq += fMinDist * fMinDist;
res.m_numv++;