From 3e8f4d941f5e00433518f534b37e0a933bc9e7de Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 15 Aug 2023 15:28:17 +0200 Subject: [PATCH] Points: modernize C++: use range-based for loop --- src/Mod/Points/App/Points.cpp | 41 +++++++++-------- src/Mod/Points/App/PointsAlgos.cpp | 32 +++++++------- src/Mod/Points/App/PointsGrid.cpp | 24 +++++----- src/Mod/Points/App/PointsPyImp.cpp | 14 +++--- src/Mod/Points/App/Properties.cpp | 56 ++++++++++++------------ src/Mod/Points/Gui/Command.cpp | 4 +- src/Mod/Points/Gui/ViewProvider.cpp | 68 ++++++++++++++--------------- 7 files changed, 122 insertions(+), 117 deletions(-) diff --git a/src/Mod/Points/App/Points.cpp b/src/Mod/Points/App/Points.cpp index d95381f666..3b84a64851 100644 --- a/src/Mod/Points/App/Points.cpp +++ b/src/Mod/Points/App/Points.cpp @@ -112,8 +112,9 @@ Base::BoundBox3d PointKernel::getBoundBox()const bnd.Add(lbb); }); #else - for (const_point_iterator it = begin(); it != end(); ++it) - bnd.Add(*it); + for (const auto & it : *this) { + bnd.Add(it); + } #endif return bnd; } @@ -135,11 +136,12 @@ unsigned int PointKernel::getMemSize () const PointKernel::size_type PointKernel::countValid() const { size_type num = 0; - for (const_point_iterator it = begin(); it != end(); ++it) { - if (!(boost::math::isnan(it->x) || - boost::math::isnan(it->y) || - boost::math::isnan(it->z))) + for (const auto & it : *this) { + if (!(boost::math::isnan(it.x) || + boost::math::isnan(it.y) || + boost::math::isnan(it.z))) { num++; + } } return num; } @@ -148,14 +150,15 @@ std::vector PointKernel::getValidPoints() const { std::vector valid; valid.reserve(countValid()); - for (const_point_iterator it = begin(); it != end(); ++it) { - if (!(boost::math::isnan(it->x) || - boost::math::isnan(it->y) || - boost::math::isnan(it->z))) + for (const auto & it : *this) { + if (!(boost::math::isnan(it.x) || + boost::math::isnan(it.y) || + boost::math::isnan(it.z))) { valid.emplace_back( - static_cast(it->x), - static_cast(it->y), - static_cast(it->z)); + static_cast(it.x), + static_cast(it.y), + static_cast(it.z)); + } } return valid; } @@ -175,8 +178,8 @@ void PointKernel::SaveDocFile (Base::Writer &writer) const uint32_t uCt = (uint32_t)size(); str << uCt; // store the data without transforming it - for (std::vector::const_iterator it = _Points.begin(); it != _Points.end(); ++it) { - str << it->x << it->y << it->z; + for (const auto& pnt : _Points) { + str << pnt.x << pnt.y << pnt.z; } } @@ -204,7 +207,9 @@ void PointKernel::RestoreDocFile(Base::Reader &reader) str >> uCt; _Points.resize(uCt); for (unsigned long i=0; i < uCt; i++) { - float x, y, z; + float x; + float y; + float z; str >> x >> y >> z; _Points[i].Set(x,y,z); } @@ -224,8 +229,8 @@ void PointKernel::load(const char* file) void PointKernel::save(std::ostream& out) const { out << "# ASCII" << std::endl; - for (std::vector::const_iterator it = _Points.begin(); it != _Points.end(); ++it) { - out << it->x << " " << it->y << " " << it->z << std::endl; + for (const auto& pnt : _Points) { + out << pnt.x << " " << pnt.y << " " << pnt.z << std::endl; } } diff --git a/src/Mod/Points/App/PointsAlgos.cpp b/src/Mod/Points/App/PointsAlgos.cpp index 2085d93ba6..470ddaf0d5 100644 --- a/src/Mod/Points/App/PointsAlgos.cpp +++ b/src/Mod/Points/App/PointsAlgos.cpp @@ -761,30 +761,30 @@ std::size_t PlyReader::readHeader(std::istream& in, number.push_back(list[1]); } - for (std::list::iterator it = number.begin(); it != number.end(); ++it) { + for (const auto & it : number) { int size = 0; - if (*it == "char" || *it == "int8") { + if (it == "char" || it == "int8") { size = 1; } - else if (*it == "uchar" || *it == "uint8") { + else if (it == "uchar" || it == "uint8") { size = 1; } - else if (*it == "short" || *it == "int16") { + else if (it == "short" || it == "int16") { size = 2; } - else if (*it == "ushort" || *it == "uint16") { + else if (it == "ushort" || it == "uint16") { size = 2; } - else if (*it == "int" || *it == "int32") { + else if (it == "int" || it == "int32") { size = 4; } - else if (*it == "uint" || *it == "uint32") { + else if (it == "uint" || it == "uint32") { size = 4; } - else if (*it == "float" || *it == "float32") { + else if (it == "float" || it == "float32") { size = 4; } - else if (*it == "double" || *it == "float64") { + else if (it == "double" || it == "float64") { size = 8; } else { @@ -795,7 +795,7 @@ std::size_t PlyReader::readHeader(std::istream& in, if (element == "vertex") { // store the property name and type fields.push_back(name); - types.push_back(*it); + types.push_back(it); sizes.push_back(size); } else if (!count_props.empty()) { @@ -1980,8 +1980,8 @@ void PlyWriter::write(const std::string& filename) out << "element vertex " << numValid << std::endl; // the properties - for (std::list::iterator it = properties.begin(); it != properties.end(); ++it) - out << "property " << *it << std::endl; + for (const auto & prop : properties) + out << "property " << prop << std::endl; out << "end_header" << std::endl; for (std::size_t r=0; r::iterator it = fields.begin(); it != fields.end(); ++it) - out << " " << *it; + for (const auto & field : fields) + out << " " << field; out << std::endl; // the sizes @@ -2140,8 +2140,8 @@ void PcdWriter::write(const std::string& filename) // the types out << "TYPE"; - for (std::list::iterator it = types.begin(); it != types.end(); ++it) - out << " " << *it; + for (const auto & type : types) + out << " " << type; out << std::endl; // the count diff --git a/src/Mod/Points/App/PointsGrid.cpp b/src/Mod/Points/App/PointsGrid.cpp index b15605b9fb..2716b88b9e 100644 --- a/src/Mod/Points/App/PointsGrid.cpp +++ b/src/Mod/Points/App/PointsGrid.cpp @@ -74,8 +74,8 @@ PointsGrid::PointsGrid (const PointKernel &rclM, double fGridLen) _fMinX(0.0f), _fMinY(0.0f), _fMinZ(0.0f) { Base::BoundBox3d clBBPts;// = _pclPoints->GetBoundBox(); - for (PointKernel::const_iterator it = _pclPoints->begin(); it != _pclPoints->end(); ++it ) - clBBPts.Add(*it); + for (const auto & pnt : *_pclPoints) + clBBPts.Add(pnt); Rebuild(std::max((unsigned long)(clBBPts.LengthX() / fGridLen), 1), std::max((unsigned long)(clBBPts.LengthY() / fGridLen), 1), std::max((unsigned long)(clBBPts.LengthZ() / fGridLen), 1)); @@ -131,8 +131,8 @@ void PointsGrid::InitGrid () // { Base::BoundBox3d clBBPts;// = _pclPoints->GetBoundBox(); - for (PointKernel::const_iterator it = _pclPoints->begin(); it != _pclPoints->end(); ++it ) - clBBPts.Add(*it); + for (const auto & pnt : *_pclPoints) + clBBPts.Add(pnt); double fLengthX = clBBPts.LengthX(); double fLengthY = clBBPts.LengthY(); @@ -289,8 +289,8 @@ void PointsGrid::CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMa // There should be about 10 (?!?!) facets per grid // or max grids should not exceed 10000 Base::BoundBox3d clBBPtsEnlarged;// = _pclPoints->GetBoundBox(); - for (PointKernel::const_iterator it = _pclPoints->begin(); it != _pclPoints->end(); ++it ) - clBBPtsEnlarged.Add(*it); + for (const auto & pnt : *_pclPoints) + clBBPtsEnlarged.Add(pnt); double fVolElem; if (_ulCtElements > (ulMaxGrids * ulCtGrid)) @@ -326,8 +326,8 @@ void PointsGrid::CalculateGridLength (int iCtGridPerAxis) // There should be about 10 (?!?!) facets per grid // or max grids should not exceed 10000 Base::BoundBox3d clBBPts;// = _pclPoints->GetBoundBox(); - for (PointKernel::const_iterator it = _pclPoints->begin(); it != _pclPoints->end(); ++it ) - clBBPts.Add(*it); + for (const auto & pnt : *_pclPoints) + clBBPts.Add(pnt); double fLenghtX = clBBPts.LengthX(); double fLenghtY = clBBPts.LengthY(); @@ -669,9 +669,9 @@ bool PointsGrid::Verify() const { std::vector aulElements; it.GetElements( aulElements ); - for ( std::vector::iterator itP = aulElements.begin(); itP != aulElements.end(); ++itP ) + for (unsigned long element : aulElements) { - const Base::Vector3d& cP = _pclPoints->getPoint(*itP); + const Base::Vector3d& cP = _pclPoints->getPoint(element); if (!it.GetBoundBox().IsInBox(cP)) return false; // point doesn't lie inside the grid element } @@ -689,9 +689,9 @@ void PointsGrid::RebuildGrid () // Fill data structure unsigned long i = 0; - for (PointKernel::const_iterator it = _pclPoints->begin(); it != _pclPoints->end(); ++it ) + for (const auto & pnt : *_pclPoints) { - AddPoint(*it, i++); + AddPoint(pnt, i++); } } diff --git a/src/Mod/Points/App/PointsPyImp.cpp b/src/Mod/Points/App/PointsPyImp.cpp index 9b9112b240..d3c05d1d8d 100644 --- a/src/Mod/Points/App/PointsPyImp.cpp +++ b/src/Mod/Points/App/PointsPyImp.cpp @@ -130,8 +130,8 @@ PyObject* PointsPy::writeInventor(PyObject * args) std::vector points; PointKernel* kernel = getPointKernelPtr(); points.reserve(kernel->size()); - for (Points::PointKernel::const_iterator it = kernel->begin(); it != kernel->end(); ++it) { - points.push_back(Base::convertTo(*it)); + for (const auto & it : *kernel) { + points.push_back(Base::convertTo(it)); } builder.addNode(Base::Coordinate3Item{points}); builder.addNode(Base::PointSetItem{}); @@ -210,9 +210,9 @@ PyObject* PointsPy::fromValid(PyObject * args) const PointKernel* points = getPointKernelPtr(); std::unique_ptr pts(new PointKernel()); pts->reserve(points->size()); - for (PointKernel::const_iterator it = points->begin(); it != points->end(); ++it) { - if (!boost::math::isnan(it->x) && !boost::math::isnan(it->y) && !boost::math::isnan(it->z)) - pts->push_back(*it); + for (const auto & point : *points) { + if (!boost::math::isnan(point.x) && !boost::math::isnan(point.y) && !boost::math::isnan(point.z)) + pts->push_back(point); } return new PointsPy(pts.release()); @@ -232,8 +232,8 @@ Py::List PointsPy::getPoints() const { Py::List PointList; const PointKernel* points = getPointKernelPtr(); - for (PointKernel::const_point_iterator it = points->begin(); it != points->end(); ++it) { - PointList.append(Py::asObject(new Base::VectorPy(*it))); + for (const auto & point : *points) { + PointList.append(Py::asObject(new Base::VectorPy(point))); } return PointList; } diff --git a/src/Mod/Points/App/Properties.cpp b/src/Mod/Points/App/Properties.cpp index 2ea0366762..a304e96839 100644 --- a/src/Mod/Points/App/Properties.cpp +++ b/src/Mod/Points/App/Properties.cpp @@ -156,8 +156,8 @@ void PropertyGreyValueList::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; } } @@ -167,8 +167,8 @@ void PropertyGreyValueList::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 & value : values) { + str >> value; } setValues(values); } @@ -330,8 +330,8 @@ void PropertyNormalList::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->x << it->y << it->z; + for (const auto& it : _lValueList) { + str << it.x << it.y << it.z; } } @@ -341,8 +341,8 @@ void PropertyNormalList::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->x >> it->y >> it->z; + for (auto & value : values) { + str >> value.x >> value.y >> value.z; } setValues(values); } @@ -466,35 +466,35 @@ std::vector PropertyCurvatureList::getCurvature( int mode ) const // Mean curvature if (mode == MeanCurvature) { - for (std::vector::const_iterator it=fCurvInfo.begin();it!=fCurvInfo.end(); ++it) { - fValues.push_back( 0.5f*(it->fMaxCurvature+it->fMinCurvature) ); + for (const auto & it : fCurvInfo) { + fValues.push_back( 0.5f*(it.fMaxCurvature+it.fMinCurvature) ); } } // Gaussian curvature else if (mode == GaussCurvature) { - for (std::vector::const_iterator it=fCurvInfo.begin();it!=fCurvInfo.end(); ++it) { - fValues.push_back( it->fMaxCurvature * it->fMinCurvature ); + for (const auto & it : fCurvInfo) { + fValues.push_back( it.fMaxCurvature * it.fMinCurvature ); } } // Maximum curvature else if (mode == MaxCurvature) { - for (std::vector::const_iterator it=fCurvInfo.begin();it!=fCurvInfo.end(); ++it) { - fValues.push_back( it->fMaxCurvature ); + for (const auto & it : fCurvInfo) { + fValues.push_back( it.fMaxCurvature ); } } // Minimum curvature else if (mode == MinCurvature) { - for (std::vector::const_iterator it=fCurvInfo.begin();it!=fCurvInfo.end(); ++it) { - fValues.push_back( it->fMinCurvature ); + for (const auto & it : fCurvInfo) { + fValues.push_back( it.fMinCurvature ); } } // Absolute curvature else if (mode == AbsCurvature) { - for (std::vector::const_iterator it=fCurvInfo.begin();it!=fCurvInfo.end(); ++it) { - if (fabs(it->fMaxCurvature) > fabs(it->fMinCurvature)) - fValues.push_back( it->fMaxCurvature ); + for (const auto & it : fCurvInfo) { + if (fabs(it.fMaxCurvature) > fabs(it.fMinCurvature)) + fValues.push_back( it.fMaxCurvature ); else - fValues.push_back( it->fMinCurvature ); + fValues.push_back( it.fMinCurvature ); } } @@ -597,10 +597,10 @@ void PropertyCurvatureList::SaveDocFile (Base::Writer &writer) const uint32_t uCt = (uint32_t)getSize(); str << uCt; if (uCt > 0) - for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { - str << it->fMaxCurvature << it->fMinCurvature; - str << it->cMaxCurvDir.x << it->cMaxCurvDir.y << it->cMaxCurvDir.z; - str << it->cMinCurvDir.x << it->cMinCurvDir.y << it->cMinCurvDir.z; + for (const auto & it : _lValueList) { + str << it.fMaxCurvature << it.fMinCurvature; + str << it.cMaxCurvDir.x << it.cMaxCurvDir.y << it.cMaxCurvDir.z; + str << it.cMinCurvDir.x << it.cMinCurvDir.y << it.cMinCurvDir.z; } } @@ -610,10 +610,10 @@ void PropertyCurvatureList::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->fMaxCurvature >> it->fMinCurvature; - str >> it->cMaxCurvDir.x >> it->cMaxCurvDir.y >> it->cMaxCurvDir.z; - str >> it->cMinCurvDir.x >> it->cMinCurvDir.y >> it->cMinCurvDir.z; + for (auto & value : values) { + str >> value.fMaxCurvature >> value.fMinCurvature; + str >> value.cMaxCurvDir.x >> value.cMaxCurvDir.y >> value.cMaxCurvDir.z; + str >> value.cMinCurvDir.x >> value.cMinCurvDir.y >> value.cMinCurvDir.z; } setValues(values); diff --git a/src/Mod/Points/Gui/Command.cpp b/src/Mod/Points/Gui/Command.cpp index d2e7ecd339..98b3bb5800 100644 --- a/src/Mod/Points/Gui/Command.cpp +++ b/src/Mod/Points/Gui/Command.cpp @@ -123,7 +123,7 @@ void CmdPointsExport::activated(int iMsg) addModule(Command::App, "Points"); std::vector points = getSelection().getObjectsOfType(Points::Feature::getClassTypeId()); - for (std::vector::const_iterator it = points.begin(); it != points.end(); ++it) { + for (auto point : points) { QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), QString::fromLatin1("%1 (*.asc *.pcd *.ply);;%2 (*.*)") .arg(QObject::tr("Point formats"), QObject::tr("All Files"))); @@ -133,7 +133,7 @@ void CmdPointsExport::activated(int iMsg) if (!fn.isEmpty()) { fn = Base::Tools::escapeEncodeFilename(fn); doCommand(Command::Doc, "Points.export([App.ActiveDocument.%s], \"%s\")", - (*it)->getNameInDocument(), fn.toUtf8().data()); + point->getNameInDocument(), fn.toUtf8().data()); } } } diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index 4fc30f6e01..e9fa723855 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -118,8 +118,8 @@ void ViewProviderPoints::setVertexColorMode(App::PropertyColorList* pcProperty) SbColor* col = pcColorMat->diffuseColor.startEditing(); std::size_t i=0; - for (std::vector::const_iterator it = val.begin(); it != val.end(); ++it) { - col[i++].setValue(it->r, it->g, it->b); + for (const auto& it : val) { + col[i++].setValue(it.r, it.g, it.b); } pcColorMat->diffuseColor.finishEditing(); @@ -133,8 +133,8 @@ void ViewProviderPoints::setVertexGreyvalueMode(Points::PropertyGreyValueList* p SbColor* col = pcColorMat->diffuseColor.startEditing(); std::size_t i=0; - for (std::vector::const_iterator it = val.begin(); it != val.end(); ++it) { - col[i++].setValue(*it, *it, *it); + for (float it : val) { + col[i++].setValue(it, it, it); } pcColorMat->diffuseColor.finishEditing(); @@ -148,8 +148,8 @@ void ViewProviderPoints::setVertexNormalMode(Points::PropertyNormalList* pcPrope SbVec3f* norm = pcPointsNormal->vector.startEditing(); std::size_t i=0; - for (std::vector::const_iterator it = val.begin(); it != val.end(); ++it) { - norm[i++].setValue(it->x, it->y, it->z); + for (const auto& it : val) { + norm[i++].setValue(it.x, it.y, it.z); } pcPointsNormal->vector.finishEditing(); @@ -162,10 +162,10 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName) if (strcmp("Color",ModeName) == 0) { std::map Map; pcObject->getPropertyMap(Map); - for (std::map::iterator it = Map.begin(); it != Map.end(); ++it) { - Base::Type type = it->second->getTypeId(); + for (auto & it : Map) { + Base::Type type = it.second->getTypeId(); if (type == App::PropertyColorList::getClassTypeId()) { - App::PropertyColorList* colors = static_cast(it->second); + App::PropertyColorList* colors = static_cast(it.second); if (numPoints != colors->getSize()) { #ifdef FC_DEBUG SoDebugError::postWarning("ViewProviderPoints::setDisplayMode", @@ -185,10 +185,10 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName) else if (strcmp("Intensity",ModeName) == 0) { std::map Map; pcObject->getPropertyMap(Map); - for (std::map::iterator it = Map.begin(); it != Map.end(); ++it) { - Base::Type type = it->second->getTypeId(); + for (const auto& it : Map) { + Base::Type type = it.second->getTypeId(); if (type == Points::PropertyGreyValueList::getClassTypeId()) { - Points::PropertyGreyValueList* greyValues = static_cast(it->second); + Points::PropertyGreyValueList* greyValues = static_cast(it.second); if (numPoints != greyValues->getSize()) { #ifdef FC_DEBUG SoDebugError::postWarning("ViewProviderPoints::setDisplayMode", @@ -198,7 +198,7 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName) setDisplayMaskMode("Point"); } else { - setVertexGreyvalueMode((Points::PropertyGreyValueList*)it->second); + setVertexGreyvalueMode((Points::PropertyGreyValueList*)it.second); setDisplayMaskMode("Color"); } break; @@ -208,10 +208,10 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName) else if (strcmp("Shaded",ModeName) == 0) { std::map Map; pcObject->getPropertyMap(Map); - for (std::map::iterator it = Map.begin(); it != Map.end(); ++it) { - Base::Type type = it->second->getTypeId(); + for (const auto& it : Map) { + Base::Type type = it.second->getTypeId(); if (type == Points::PropertyNormalList::getClassTypeId()) { - Points::PropertyNormalList* normals = static_cast(it->second); + Points::PropertyNormalList* normals = static_cast(it.second); if (numPoints != normals->getSize()) { #ifdef FC_DEBUG SoDebugError::postWarning("ViewProviderPoints::setDisplayMode", @@ -327,8 +327,8 @@ void ViewProviderPoints::clipPointsCallback(void *, SoEventCallback * n) clPoly.push_back(clPoly.front()); std::vector views = view->getViewProvidersOfType(ViewProviderPoints::getClassTypeId()); - for (std::vector::iterator it = views.begin(); it != views.end(); ++it) { - ViewProviderPoints* that = static_cast(*it); + for (auto it : views) { + ViewProviderPoints* that = static_cast(it); if (that->getEditingMode() > -1) { that->finishEditing(); that->cut(clPoly, *view); @@ -424,8 +424,8 @@ void ViewProviderScattered::cut(const std::vector& picked, Gui::View3DI { // create the polygon from the picked points Base::Polygon2d cPoly; - for (std::vector::const_iterator it = picked.begin(); it != picked.end(); ++it) { - cPoly.Add(Base::Vector2d((*it)[0],(*it)[1])); + for (const auto& it : picked) { + cPoly.Add(Base::Vector2d(it[0],it[1])); } // get a reference to the point feature @@ -461,17 +461,17 @@ void ViewProviderScattered::cut(const std::vector& picked, Gui::View3DI std::map Map; pcObject->getPropertyMap(Map); - for (std::map::iterator it = Map.begin(); it != Map.end(); ++it) { - Base::Type type = it->second->getTypeId(); + for (const auto& it : Map) { + Base::Type type = it.second->getTypeId(); if (type == Points::PropertyNormalList::getClassTypeId()) { - static_cast(it->second)->removeIndices(removeIndices); + static_cast(it.second)->removeIndices(removeIndices); } else if (type == Points::PropertyGreyValueList::getClassTypeId()) { - static_cast(it->second)->removeIndices(removeIndices); + static_cast(it.second)->removeIndices(removeIndices); } else if (type == App::PropertyColorList::getClassTypeId()) { //static_cast(it->second)->removeIndices(removeIndices); - const std::vector& colors = static_cast(it->second)->getValues(); + const std::vector& colors = static_cast(it.second)->getValues(); if (removeIndices.size() > colors.size()) break; @@ -490,7 +490,7 @@ void ViewProviderScattered::cut(const std::vector& picked, Gui::View3DI ++pos; } - static_cast(it->second)->setValues(remainValue); + static_cast(it.second)->setValues(remainValue); } } @@ -576,8 +576,8 @@ void ViewProviderStructured::cut(const std::vector& picked, Gui::View3D { // create the polygon from the picked points Base::Polygon2d cPoly; - for (std::vector::const_iterator it = picked.begin(); it != picked.end(); ++it) { - cPoly.Add(Base::Vector2d((*it)[0],(*it)[1])); + for (const auto& it : picked) { + cPoly.Add(Base::Vector2d(it[0],it[1])); } // get a reference to the point feature @@ -593,11 +593,11 @@ void ViewProviderStructured::cut(const std::vector& picked, Gui::View3D bool invalidatePoints = false; double nan = std::numeric_limits::quiet_NaN(); - for (Points::PointKernel::const_iterator jt = points.begin(); jt != points.end(); ++jt) { + for (const auto & point : points) { // valid point? - Base::Vector3d vec(*jt); - if (!(boost::math::isnan(jt->x) || boost::math::isnan(jt->y) || boost::math::isnan(jt->z))) { - SbVec3f pt(jt->x,jt->y,jt->z); + Base::Vector3d vec(point); + if (!(boost::math::isnan(point.x) || boost::math::isnan(point.y) || boost::math::isnan(point.z))) { + SbVec3f pt(point.x,point.y,point.z); // project from 3d to 2d vol.projectToScreen(pt, pt); @@ -703,8 +703,8 @@ void ViewProviderPointsBuilder::createPoints(const App::Property* prop, SoCoordi idx=0; points->coordIndex.setNum(indices.size()); int32_t* pos = points->coordIndex.startEditing(); - for (std::vector::iterator it = indices.begin(); it != indices.end(); ++it) { - pos[idx++] = *it; + for (int32_t index : indices) { + pos[idx++] = index; } points->coordIndex.finishEditing(); }