diff --git a/src/Mod/Inspection/App/InspectionFeature.cpp b/src/Mod/Inspection/App/InspectionFeature.cpp index 8ef9e87f89..5c9cccc9b8 100644 --- a/src/Mod/Inspection/App/InspectionFeature.cpp +++ b/src/Mod/Inspection/App/InspectionFeature.cpp @@ -24,6 +24,7 @@ #ifndef _PreComp_ #include +#include #include #include @@ -78,8 +79,9 @@ unsigned long InspectActualMesh::countPoints() const Base::Vector3f InspectActualMesh::getPoint(unsigned long index) const { Base::Vector3f point = _mesh.GetPoint(index); - if (_bApply) + if (_bApply) { _clTrf.multVec(point, point); + } return point; } @@ -96,8 +98,8 @@ unsigned long InspectActualPoints::countPoints() const Base::Vector3f InspectActualPoints::getPoint(unsigned long index) const { - Base::Vector3d p = _rKernel.getPoint(index); - return Base::Vector3f(float(p.x), float(p.y), float(p.z)); + Base::Vector3d pnt = _rKernel.getPoint(index); + return Base::Vector3f(float(pnt.x), float(pnt.y), float(pnt.z)); } // ---------------------------------------------------------------- @@ -146,18 +148,19 @@ namespace Inspection { class MeshInspectGrid : public MeshCore::MeshGrid { public: - MeshInspectGrid (const MeshCore::MeshKernel &mesh, float fGridLen, const Base::Matrix4D& m) - : MeshCore::MeshGrid(mesh), _transform(m) + MeshInspectGrid (const MeshCore::MeshKernel &mesh, float fGridLen, const Base::Matrix4D& mat) + : MeshCore::MeshGrid(mesh), _transform(mat) { - Base::BoundBox3f clBBMesh = _pclMesh->GetBoundBox().Transformed(m); + Base::BoundBox3f clBBMesh = _pclMesh->GetBoundBox().Transformed(mat); Rebuild(std::max((unsigned long)(clBBMesh.LengthX() / fGridLen), 1), std::max((unsigned long)(clBBMesh.LengthY() / fGridLen), 1), std::max((unsigned long)(clBBMesh.LengthZ() / fGridLen), 1)); } - void Validate (const MeshCore::MeshKernel&) override + void Validate (const MeshCore::MeshKernel& kernel) override { // do nothing + boost::ignore_unused(kernel); } void Validate () @@ -198,8 +201,12 @@ namespace Inspection { void AddFacet (const MeshCore::MeshGeomFacet &rclFacet, unsigned long ulFacetIndex) { - unsigned long ulX, ulY, ulZ; - unsigned long ulX1, ulY1, ulZ1, ulX2, ulY2, ulZ2; + unsigned long ulX1; + unsigned long ulY1; + unsigned long ulZ1; + unsigned long ulX2; + unsigned long ulY2; + unsigned long ulZ2; Base::BoundBox3f clBB; clBB.Add(rclFacet._aclPoints[0]); @@ -211,17 +218,18 @@ namespace Inspection { if ((ulX1 < ulX2) || (ulY1 < ulY2) || (ulZ1 < ulZ2)) { - for (ulX = ulX1; ulX <= ulX2; ulX++) { - for (ulY = ulY1; ulY <= ulY2; ulY++) { - for (ulZ = ulZ1; ulZ <= ulZ2; ulZ++) { + for (unsigned long ulX = ulX1; ulX <= ulX2; ulX++) { + for (unsigned long ulY = ulY1; ulY <= ulY2; ulY++) { + for (unsigned long ulZ = ulZ1; ulZ <= ulZ2; ulZ++) { if (rclFacet.IntersectBoundingBox(GetBoundBox(ulX, ulY, ulZ))) _aulGrid[ulX][ulY][ulZ].insert(ulFacetIndex); } } } } - else + else { _aulGrid[ulX1][ulY1][ulZ1].insert(ulFacetIndex); + } } void InitGrid () override @@ -316,8 +324,8 @@ float InspectNominalMesh::getDistance(const Base::Vector3f& point) const float fMinDist=FLT_MAX; bool positive = true; - for (std::vector::iterator it = indices.begin(); it != indices.end(); ++it) { - MeshCore::MeshGeomFacet geomFace = _mesh.GetFacet(*it); + for (unsigned long it : indices) { + MeshCore::MeshGeomFacet geomFace = _mesh.GetFacet(it); if (_bApply) { geomFace.Transform(_clTrf); } @@ -396,8 +404,8 @@ float InspectNominalFastMesh::getDistance(const Base::Vector3f& point) const float fMinDist=FLT_MAX; bool positive = true; - for (std::set::iterator it = indices.begin(); it != indices.end(); ++it) { - MeshCore::MeshGeomFacet geomFace = _mesh.GetFacet(*it); + for (unsigned long it : indices) { + MeshCore::MeshGeomFacet geomFace = _mesh.GetFacet(it); if (_bApply) { geomFace.Transform(_clTrf); } @@ -438,8 +446,8 @@ float InspectNominalPoints::getDistance(const Base::Vector3f& point) const _pGrid->GetElements(x,y,z,indices); double fMinDist=DBL_MAX; - for (std::set::iterator it = indices.begin(); it != indices.end(); ++it) { - Base::Vector3d pt = _rKernel.getPoint(*it); + for (unsigned long it : indices) { + Base::Vector3d pt = _rKernel.getPoint(it); double fDist = Base::Distance(pointd, pt); if (fDist < fMinDist) { fMinDist = fDist; @@ -642,8 +650,8 @@ void PropertyDistanceList::SaveDocFile (Base::Writer &writer) const Base::OutputStream str(writer.Stream()); uint32_t uCt = (uint32_t)getSize(); str << uCt; - for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { - str << *it; + for (float it : _lValueList) { + str << it; } } @@ -653,8 +661,8 @@ void PropertyDistanceList::RestoreDocFile(Base::Reader &reader) uint32_t uCt=0; str >> uCt; std::vector values(uCt); - for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { - str >> *it; + for (float& it : values) { + str >> it; } setValues(values); } @@ -695,8 +703,8 @@ struct DistanceInspection Base::Vector3f pnt = actual->getPoint(index); float fMinDist=FLT_MAX; - for (std::vector::const_iterator it = nominal.begin(); it != nominal.end(); ++it) { - float fDist = (*it)->getDistance(pnt); + for (auto it : nominal) { + float fDist = it->getDistance(pnt); if (fabs(fDist) < fabs(fMinDist)) fMinDist = fDist; } @@ -792,19 +800,19 @@ App::DocumentObjectExecReturn* Feature::execute() // get a list of nominals std::vector inspectNominal; const std::vector& nominals = Nominals.getValues(); - for (std::vector::const_iterator it = nominals.begin(); it != nominals.end(); ++it) { + for (auto it : nominals) { InspectNominalGeometry* nominal = nullptr; - if ((*it)->getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) { - Mesh::Feature* mesh = static_cast(*it); + if (it->getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) { + Mesh::Feature* mesh = static_cast(it); nominal = new InspectNominalMesh(mesh->Mesh.getValue(), this->SearchRadius.getValue()); } - else if ((*it)->getTypeId().isDerivedFrom(Points::Feature::getClassTypeId())) { - Points::Feature* pts = static_cast(*it); + else if (it->getTypeId().isDerivedFrom(Points::Feature::getClassTypeId())) { + Points::Feature* pts = static_cast(it); nominal = new InspectNominalPoints(pts->Points.getValue(), this->SearchRadius.getValue()); } - else if ((*it)->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + else if (it->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { useMultithreading = false; - Part::Feature* part = static_cast(*it); + Part::Feature* part = static_cast(it); nominal = new InspectNominalShape(part->Shape.getValue(), this->SearchRadius.getValue()); } @@ -875,8 +883,8 @@ App::DocumentObjectExecReturn* Feature::execute() Base::Vector3f pnt = actual->getPoint(index); float fMinDist = FLT_MAX; - for (std::vector::iterator it = inspectNominal.begin(); it != inspectNominal.end(); ++it) { - float fDist = (*it)->getDistance(pnt); + for (auto it : inspectNominal) { + float fDist = it->getDistance(pnt); if (fabs(fDist) < fabs(fMinDist)) fMinDist = fDist; } @@ -934,8 +942,8 @@ App::DocumentObjectExecReturn* Feature::execute() #endif delete actual; - for (std::vector::iterator it = inspectNominal.begin(); it != inspectNominal.end(); ++it) - delete *it; + for (auto it : inspectNominal) + delete it; return nullptr; } diff --git a/src/Mod/Inspection/App/PreCompiled.h b/src/Mod/Inspection/App/PreCompiled.h index 7b2059b4e3..29e9553e2b 100644 --- a/src/Mod/Inspection/App/PreCompiled.h +++ b/src/Mod/Inspection/App/PreCompiled.h @@ -46,6 +46,9 @@ #include #include +// boost +#include + // Qt #include #include diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index 2ee9f4e69f..9abc815d84 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -269,8 +269,8 @@ void ViewProviderInspection::setupNormals(const std::vector& nor SbVec3f* norm = normalNode->vector.startEditing(); std::size_t i=0; - for (std::vector::const_iterator it = normals.begin(); it != normals.end(); ++it) { - norm[i++].setValue(it->x, it->y, it->z); + for (const auto& it : normals) { + norm[i++].setValue(it.x, it.y, it.z); } normalNode->vector.finishEditing(); @@ -456,8 +456,8 @@ public: QObject::tr("Do you want to remove all annotations?"), QMessageBox::Yes,QMessageBox::No); if (ret == QMessageBox::Yes) { - for (QList::iterator it = flags.begin(); it != flags.end(); ++it) - (*it)->deleteLater(); + for (auto it : flags) + it->deleteLater(); } } } diff --git a/src/Mod/Inspection/Gui/VisualInspection.cpp b/src/Mod/Inspection/Gui/VisualInspection.cpp index d8bf609bf7..26b9fd0dc4 100644 --- a/src/Mod/Inspection/Gui/VisualInspection.cpp +++ b/src/Mod/Inspection/Gui/VisualInspection.cpp @@ -115,21 +115,21 @@ VisualInspection::VisualInspection(QWidget* parent, Qt::WindowFlags fl) Base::Type point = Base::Type::fromName("Points::Feature"); Base::Type mesh = Base::Type::fromName("Mesh::Feature"); Base::Type shape = Base::Type::fromName("Part::Feature"); - for (std::vector::iterator it = obj.begin(); it != obj.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(point) || - (*it)->getTypeId().isDerivedFrom(mesh) || - (*it)->getTypeId().isDerivedFrom(shape)) { - Gui::ViewProvider* view = gui->getViewProvider(*it); + for (auto it : obj) { + if (it->getTypeId().isDerivedFrom(point) || + it->getTypeId().isDerivedFrom(mesh) || + it->getTypeId().isDerivedFrom(shape)) { + Gui::ViewProvider* view = gui->getViewProvider(it); QIcon px = view->getIcon(); SingleSelectionItem* item1 = new SingleSelectionItem(ui->treeWidgetActual); - item1->setText(0, QString::fromUtf8((*it)->Label.getValue())); - item1->setData(0, Qt::UserRole, QString::fromLatin1((*it)->getNameInDocument())); + item1->setText(0, QString::fromUtf8(it->Label.getValue())); + item1->setData(0, Qt::UserRole, QString::fromLatin1(it->getNameInDocument())); item1->setCheckState(0, Qt::Unchecked); item1->setIcon(0, px); SingleSelectionItem* item2 = new SingleSelectionItem(ui->treeWidgetNominal); - item2->setText(0, QString::fromUtf8((*it)->Label.getValue())); - item2->setData(0, Qt::UserRole, QString::fromLatin1((*it)->getNameInDocument())); + item2->setText(0, QString::fromUtf8(it->Label.getValue())); + item2->setData(0, Qt::UserRole, QString::fromLatin1(it->getNameInDocument())); item2->setCheckState(0, Qt::Unchecked); item2->setIcon(0, px); @@ -245,9 +245,9 @@ void VisualInspection::accept() "App_activeDocument___activeObject___Nominals=list()\n" "App.ActiveDocument.ActiveObject.SearchRadius=%.3f\n" "App.ActiveDocument.ActiveObject.Thickness=%.3f\n", (const char*)actualName.toLatin1(), searchRadius, thickness); - for (QStringList::Iterator it = nominalNames.begin(); it != nominalNames.end(); ++it) { + for (const auto& it : nominalNames) { Gui::Command::doCommand(Gui::Command::App, - "App_activeDocument___activeObject___Nominals.append(App.ActiveDocument.%s)\n", (const char*)(*it).toLatin1()); + "App_activeDocument___activeObject___Nominals.append(App.ActiveDocument.%s)\n", (const char*)it.toLatin1()); } Gui::Command::doCommand(Gui::Command::App, "App.ActiveDocument.ActiveObject.Nominals=App_activeDocument___activeObject___Nominals\n"