From 7ec2ce7c1e4e6b89c2cabbc045a6506fedfa2fd4 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Tue, 25 Apr 2017 00:23:41 +0200 Subject: [PATCH] Replace with for-range-loop where possible. --- Applications/ApplicationsLib/ProjectData.cpp | 4 +- .../DataExplorer/Base/RecentFiles.cpp | 10 ++--- .../DataExplorer/DataView/ColorTableModel.cpp | 7 ++-- .../DataView/CondFromRasterDialog.cpp | 10 ++--- .../DataView/DiagramView/DetailWindow.cpp | 4 +- .../DiagramView/DiagramPrefsDialog.cpp | 12 +++--- .../DataView/DiagramView/DiagramScene.cpp | 40 +++++++++---------- .../DataView/DirectConditionGenerator.cpp | 4 +- .../DataView/ElementTreeModel.cpp | 10 +++-- .../DataExplorer/DataView/GMSHPrefsDialog.cpp | 20 +++++----- .../DataView/GeoOnMeshMappingDialog.cpp | 4 +- .../DataExplorer/DataView/GeoTreeModel.cpp | 18 ++++----- .../DataExplorer/DataView/LineEditDialog.cpp | 16 ++++---- .../DataView/MergeGeometriesDialog.cpp | 16 ++++---- .../DataView/MeshAnalysisDialog.cpp | 4 +- .../DataView/MeshElementRemovalDialog.cpp | 9 +++-- .../DataView/SelectMeshDialog.cpp | 4 +- .../DataView/StationTreeModel.cpp | 6 +-- .../DataExplorer/DataView/StationTreeView.cpp | 14 ++++--- .../VtkVis/VtkAlgorithmProperties.cpp | 4 +- .../VtkCompositeNodeSelectionFilter.cpp | 10 +++-- .../DataExplorer/VtkVis/VtkPointsSource.cpp | 8 ++-- .../VtkVis/VtkPolylinesSource.cpp | 6 +-- .../DataExplorer/VtkVis/VtkStationSource.cpp | 19 +++++---- .../DataExplorer/VtkVis/VtkSurfacesSource.cpp | 6 +-- .../DataExplorer/VtkVis/VtkVisPipeline.cpp | 10 ++--- Applications/DataExplorer/mainwindow.cpp | 4 +- Applications/FileIO/AsciiRasterInterface.cpp | 5 +-- Applications/FileIO/CsvInterface.cpp | 4 +- Applications/FileIO/Gmsh/GMSHInterface.cpp | 12 +++--- Applications/FileIO/Gmsh/GMSHPolygonTree.cpp | 14 ++++--- Applications/FileIO/Gmsh/GmshReader.cpp | 5 ++- .../Utils/OGSFileConverter/FileListDialog.cpp | 4 +- .../OGSFileConverter/OGSFileConverter.cpp | 34 +++++++++------- GeoLib/EarClippingTriangulation.cpp | 9 +++-- GeoLib/GEOObjects.cpp | 28 +++++++------ GeoLib/PointVec.cpp | 4 +- GeoLib/Polygon.cpp | 20 ++++------ GeoLib/QuadTree.h | 31 +++++++------- GeoLib/Surface.cpp | 6 +-- .../Fluid/Viscosity/WaterViscosityIAPWS.cpp | 4 +- MeshGeoToolsLib/GeoMapper.cpp | 6 +-- MeshGeoToolsLib/HeuristicSearchLength.cpp | 9 +++-- MeshLib/IO/Legacy/MeshIO.cpp | 4 +- MeshLib/Mesh.cpp | 16 ++++---- MeshLib/MeshEditing/MeshRevision.cpp | 8 ++-- MeshLib/MeshInformation.cpp | 4 +- MeshLib/MeshSurfaceExtraction.cpp | 16 ++++---- MeshLib/Properties.cpp | 7 ++-- MeshLib/Vtk/VtkMappedMeshSource.cpp | 8 ++-- NumLib/DOF/MeshComponentMap.cpp | 12 +++--- Tests/FileIO/TestGmlInterface.h | 5 ++- Tests/GeoLib/TestAABB.cpp | 8 ++-- 53 files changed, 288 insertions(+), 274 deletions(-) diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index 30808b73ccf..5d46ecea825 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -195,8 +195,8 @@ bool ProjectData::isMeshNameUniqueAndProvideUniqueName(std::string& name) const if (count > 1) cpName = cpName + "-" + std::to_string(count); - for (auto it = _mesh_vec.begin(); it != _mesh_vec.end(); ++it) - if (cpName.compare((*it)->getName()) == 0) + for (auto it : _mesh_vec) + if (cpName.compare(it->getName()) == 0) isUnique = false; } diff --git a/Applications/DataExplorer/Base/RecentFiles.cpp b/Applications/DataExplorer/Base/RecentFiles.cpp index 625ac741986..feafc8a55ba 100644 --- a/Applications/DataExplorer/Base/RecentFiles.cpp +++ b/Applications/DataExplorer/Base/RecentFiles.cpp @@ -22,12 +22,12 @@ RecentFiles::RecentFiles( QObject* parent, const char* slot, QString settingsNa : QObject(parent), _settingsName(settingsName) { _filesMenu = new QMenu(tr("Recent files")); - for (int i = 0; i < _maxFiles; i++) + for (auto& _fileAction : _fileActions) { - _fileActions[i] = new QAction(this); - _fileActions[i]->setVisible(false); - connect(_fileActions[i], SIGNAL(triggered()), parent, slot); - _filesMenu->addAction(_fileActions[i]); + _fileAction = new QAction(this); + _fileAction->setVisible(false); + connect(_fileAction, SIGNAL(triggered()), parent, slot); + _filesMenu->addAction(_fileAction); } updateRecentFileActions(); } diff --git a/Applications/DataExplorer/DataView/ColorTableModel.cpp b/Applications/DataExplorer/DataView/ColorTableModel.cpp index f7a6d986d3f..d28f5d3a3ac 100644 --- a/Applications/DataExplorer/DataView/ColorTableModel.cpp +++ b/Applications/DataExplorer/DataView/ColorTableModel.cpp @@ -80,11 +80,10 @@ bool ColorTableModel::buildTable(const std::map<std::string, DataHolderLib::Colo int count = 0; beginInsertRows(QModelIndex(), 0, colorLookupTable.size() - 1); - for (auto it = colorLookupTable.begin(); - it != colorLookupTable.end(); ++it) + for (const auto& it : colorLookupTable) { - QColor color((*(it->second))[0], (*(it->second))[1], (*(it->second))[2]); - QString name(QString::fromStdString(it->first)); + QColor color((*(it.second))[0], (*(it.second))[1], (*(it.second))[2]); + QString name(QString::fromStdString(it.first)); /* Saudi Arabia strat names * if (it->first.compare("1")==0) name="Buweib"; diff --git a/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp b/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp index 93b0a3f2df5..bc74da0480a 100644 --- a/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp +++ b/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp @@ -32,8 +32,8 @@ CondFromRasterDialog::CondFromRasterDialog(const std::vector<MeshLib::Mesh*> &ms this->scalingEdit->setText("1.0"); this->scalingEdit->setValidator (_scale_validator); - for (auto it = _msh_vec.begin(); it != _msh_vec.end(); ++it) - this->meshBox->addItem(QString::fromStdString((*it)->getName())); + for (auto it : _msh_vec) + this->meshBox->addItem(QString::fromStdString(it->getName())); this->directButton->setChecked(true); } @@ -84,10 +84,10 @@ void CondFromRasterDialog::accept() } MeshLib::Mesh* mesh(nullptr); - for (std::size_t i=0; i<_msh_vec.size(); i++) - if (_msh_vec[i]->getName().compare(mesh_name) == 0) + for (auto i : _msh_vec) + if (i->getName().compare(mesh_name) == 0) { - mesh = _msh_vec[i]; + mesh = i; break; } diff --git a/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp b/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp index dfff7acf165..a059da9ac1d 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp @@ -74,8 +74,8 @@ DetailWindow::DetailWindow(QString filename, QWidget* parent) : QWidget(parent) std::vector<DiagramList*> lists; DiagramList::readList(filename, lists); - for (std::size_t i = 0; i < lists.size(); i++) - stationView->addGraph(lists[i]); + for (auto& list : lists) + stationView->addGraph(list); resizeWindow(); } diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp index 8b2508c24ee..9e9069eb262 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp @@ -129,14 +129,14 @@ int DiagramPrefsDialog::loadFile(const QString &filename) { if (DiagramList::readList(filename, _list)) { - for (std::size_t i = 0; i < _list.size(); i++) + for (auto& i : _list) { //_list[i]->setName(stationTypeLabel->text() + ": " + stationNameLabel->text()); - _list[i]->setXLabel("Time"); + i->setXLabel("Time"); //_list[i]->setYLabel("Water Level"); - _list[i]->setXUnit("day"); + i->setXUnit("day"); //_list[i]->setYUnit("metres"); - _list[i]->setColor(QColor(Qt::red)); + i->setColor(QColor(Qt::red)); } fromDateLine->setText(_list[0]->getStartDate().toString("dd.MM.yyyy")); //QString::number(_list[0]->minXValue())); QDateTime endDate = @@ -170,9 +170,9 @@ int DiagramPrefsDialog::loadList(const std::vector< std::pair<QDateTime, float> void DiagramPrefsDialog::createVisibilityCheckboxes() { - for (std::size_t i = 0; i < _list.size(); i++) + for (auto& i : _list) { - QCheckBox* box = new QCheckBox(_list[i]->getName()); + QCheckBox* box = new QCheckBox(i->getName()); box->setChecked(true); this->CheckBoxLayout->addWidget(box); _visability.push_back(box); diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp index 3a2780daad4..b0b39e049ad 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp @@ -50,20 +50,20 @@ DiagramScene::~DiagramScene() delete _yLabel; delete _xUnit; delete _yUnit; - for (int i = 0; i < _graphCaptions.size(); i++) - delete _graphCaptions[i]; + for (auto& _graphCaption : _graphCaptions) + delete _graphCaption; _graphCaptions.clear(); - for (int i = 0; i < _graphs.size(); i++) - delete _graphs[i]; + for (auto& _graph : _graphs) + delete _graph; _graphs.clear(); - for (int i = 0; i < _xTicksText.size(); i++) - delete _xTicksText[i]; + for (auto& i : _xTicksText) + delete i; _xTicksText.clear(); - for (int i = 0; i < _yTicksText.size(); i++) - delete _yTicksText[i]; + for (auto& i : _yTicksText) + delete i; _yTicksText.clear(); - for (int i = 0; i < _lists.size(); i++) - delete _lists[i]; + for (auto& _list : _lists) + delete _list; _lists.clear(); } @@ -105,8 +105,8 @@ void DiagramScene::addGraph(DiagramList* list) constructGrid(); _lists.push_back(list); - for (int i = 0; i < _lists.size(); i++) - drawGraph(_lists[i]); + for (auto& _list : _lists) + drawGraph(_list); update(); } @@ -163,14 +163,14 @@ void DiagramScene::clearGrid() { removeItem(_grid); - for (int i = 0; i < _xTicksText.size(); ++i) - removeItem(_xTicksText[i]); - for (int j = 0; j < _yTicksText.size(); ++j) - removeItem(_yTicksText[j]); - for (int k = 0; k < _graphs.size(); k++) - removeItem(_graphs[k]); - for (int l = 0; l < _graphCaptions.size(); l++) - removeItem(_graphCaptions[l]); + for (auto& i : _xTicksText) + removeItem(i); + for (auto& j : _yTicksText) + removeItem(j); + for (auto& _graph : _graphs) + removeItem(_graph); + for (auto& _graphCaption : _graphCaptions) + removeItem(_graphCaption); _xTicksText.clear(); _yTicksText.clear(); diff --git a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp index 328d247ba56..023e946777f 100644 --- a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp +++ b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp @@ -127,8 +127,8 @@ int DirectConditionGenerator::writeToFile(const std::string &name) const if (out) { - for (auto it = _direct_values.begin(); it != _direct_values.end(); ++it) - out << it->first << "\t" << it->second << "\n"; + for (const auto& _direct_value : _direct_values) + out << _direct_value.first << "\t" << _direct_value.second << "\n"; out.close(); } diff --git a/Applications/DataExplorer/DataView/ElementTreeModel.cpp b/Applications/DataExplorer/DataView/ElementTreeModel.cpp index fa7ec445fda..2450cd08b0e 100644 --- a/Applications/DataExplorer/DataView/ElementTreeModel.cpp +++ b/Applications/DataExplorer/DataView/ElementTreeModel.cpp @@ -167,16 +167,18 @@ void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh) _rootItem->appendChild(edge_item); std::vector<std::string> const& vec_names (mesh.getProperties().getPropertyVectorNames()); - for (std::size_t i=0; i<vec_names.size(); ++i) + for (const auto& vec_name : vec_names) { QList<QVariant> array_info; - array_info << QString::fromStdString(vec_names[i]) + ": "; - auto vec_bounds (MeshLib::MeshInformation::getValueBounds<int>(mesh, vec_names[i])); + array_info << QString::fromStdString(vec_name) + ": "; + auto vec_bounds( + MeshLib::MeshInformation::getValueBounds<int>(mesh, vec_name)); if (vec_bounds.second != std::numeric_limits<int>::max()) array_info << "[" + QString::number(vec_bounds.first) + "," << QString::number(vec_bounds.second) + "]" << ""; else { - auto vec_bounds (MeshLib::MeshInformation::getValueBounds<double>(mesh, vec_names[i])); + auto vec_bounds(MeshLib::MeshInformation::getValueBounds<double>( + mesh, vec_name)); if (vec_bounds.second != std::numeric_limits<double>::max()) array_info << "[" + QString::number(vec_bounds.first) + "," << QString::number(vec_bounds.second) + "]" << ""; } diff --git a/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp b/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp index 9e6141c079e..dd45779a6f7 100644 --- a/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp +++ b/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp @@ -57,8 +57,8 @@ GMSHPrefsDialog::GMSHPrefsDialog(GeoLib::GEOObjects const& geoObjects, QDialog* std::vector<std::string> geo_station_names; geoObjects.getStationVectorNames(geo_station_names); - for (unsigned k(0); k < geo_station_names.size(); ++k) - geoNames.push_back (geo_station_names[k]); + for (auto& geo_station_name : geo_station_names) + geoNames.push_back(geo_station_name); std::size_t nGeoObjects(geoNames.size()); @@ -90,11 +90,11 @@ void GMSHPrefsDialog::on_selectGeoButton_pressed() QModelIndexList selected = this->allGeoView->selectionModel()->selectedIndexes(); QStringList list = _selGeo->stringList(); - for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) + for (auto& it : selected) { - list.append(it->data().toString()); + list.append(it.data().toString()); - _allGeo->removeRow(it->row()); + _allGeo->removeRow(it.row()); } _selGeo->setStringList(list); } @@ -104,11 +104,11 @@ void GMSHPrefsDialog::on_deselectGeoButton_pressed() QModelIndexList selected = this->selectedGeoView->selectionModel()->selectedIndexes(); QStringList list = _allGeo->stringList(); - for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) + for (auto& it : selected) { - list.append(it->data().toString()); + list.append(it.data().toString()); - _selGeo->removeRow(it->row()); + _selGeo->removeRow(it.row()); } _allGeo->setStringList(list); } @@ -179,7 +179,7 @@ void GMSHPrefsDialog::reject() std::vector<std::string> GMSHPrefsDialog::getSelectedObjects(QStringList list) { std::vector<std::string> indexList; - for (QStringList::iterator it = list.begin(); it != list.end(); ++it) - indexList.push_back(it->toStdString()); + for (auto& it : list) + indexList.push_back(it.toStdString()); return indexList; } diff --git a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp index 868444abc2f..b246bcedac7 100644 --- a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp +++ b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp @@ -26,8 +26,8 @@ GeoOnMeshMappingDialog::GeoOnMeshMappingDialog( { setupUi(this); - for (std::size_t i=0; i<mesh_vec.size(); ++i) - this->meshNameComboBox->addItem(QString::fromStdString(mesh_vec[i]->getName())); + for (const auto& i : mesh_vec) + this->meshNameComboBox->addItem(QString::fromStdString(i->getName())); } GeoOnMeshMappingDialog::~GeoOnMeshMappingDialog() = default; diff --git a/Applications/DataExplorer/DataView/GeoTreeModel.cpp b/Applications/DataExplorer/DataView/GeoTreeModel.cpp index 80fa09536d9..81e94ad1197 100644 --- a/Applications/DataExplorer/DataView/GeoTreeModel.cpp +++ b/Applications/DataExplorer/DataView/GeoTreeModel.cpp @@ -110,13 +110,12 @@ void GeoTreeModel::addPolylineList(QString geoName, GeoLib::PolylineVec const& p void GeoTreeModel::appendPolylines(const std::string &name, GeoLib::PolylineVec const& polylineVec) { - for (std::size_t i = 0; i < _lists.size(); i++) + for (auto& _list : _lists) { - if ( name.compare( _lists[i]->data(0).toString().toStdString() ) == 0 ) - for (int j = 0; j < _lists[i]->childCount(); j++) + if (name.compare(_list->data(0).toString().toStdString()) == 0) + for (int j = 0; j < _list->childCount(); j++) { - auto* parent = - static_cast<GeoObjectListItem*>(_lists[i]->child(j)); + auto* parent = static_cast<GeoObjectListItem*>(_list->child(j)); if (GeoLib::GEOTYPE::POLYLINE == parent->getType()) { beginResetModel(); @@ -201,15 +200,14 @@ void GeoTreeModel::addSurfaceList(QString geoName, GeoLib::SurfaceVec const& sur void GeoTreeModel::appendSurfaces(const std::string &name, GeoLib::SurfaceVec const& surfaceVec) { - for (std::size_t i = 0; i < _lists.size(); i++) + for (auto& _list : _lists) { - if ( name.compare( _lists[i]->data(0).toString().toStdString() ) == 0 ) + if (name.compare(_list->data(0).toString().toStdString()) == 0) { - int nChildren = _lists[i]->childCount(); + int nChildren = _list->childCount(); for (int j = 0; j < nChildren; j++) { - auto* parent = - static_cast<GeoObjectListItem*>(_lists[i]->child(j)); + auto* parent = static_cast<GeoObjectListItem*>(_list->child(j)); if (GeoLib::GEOTYPE::SURFACE == parent->getType()) { beginResetModel(); diff --git a/Applications/DataExplorer/DataView/LineEditDialog.cpp b/Applications/DataExplorer/DataView/LineEditDialog.cpp index f3f653a8fa7..54e4e719b06 100644 --- a/Applications/DataExplorer/DataView/LineEditDialog.cpp +++ b/Applications/DataExplorer/DataView/LineEditDialog.cpp @@ -50,11 +50,11 @@ void LineEditDialog::on_selectPlyButton_pressed() QModelIndexList selected = this->allPlyView->selectionModel()->selectedIndexes(); QStringList list = _selPly->stringList(); - for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) + for (auto& it : selected) { - list.append(it->data().toString()); + list.append(it.data().toString()); - _allPly->removeRow(it->row()); + _allPly->removeRow(it.row()); } _selPly->setStringList(list); } @@ -64,11 +64,11 @@ void LineEditDialog::on_deselectPlyButton_pressed() QModelIndexList selected = this->selectedPlyView->selectionModel()->selectedIndexes(); QStringList list = _allPly->stringList(); - for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) + for (auto& it : selected) { - list.append(it->data().toString()); + list.append(it.data().toString()); - _selPly->removeRow(it->row()); + _selPly->removeRow(it.row()); } _allPly->setStringList(list); } @@ -105,9 +105,9 @@ void LineEditDialog::reject() std::vector<std::size_t> LineEditDialog::getSelectedIndeces(QStringList list) { std::vector<std::size_t> indexList; - for (QStringList::iterator it = list.begin(); it != list.end(); ++it) + for (auto& it : list) { - QString s = it->mid(5, it->indexOf(" ") - 5); + QString s = it.mid(5, it.indexOf(" ") - 5); indexList.push_back(s.toInt()); } return indexList; diff --git a/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp b/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp index db133e1f2d8..171935d53d4 100644 --- a/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp +++ b/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp @@ -68,11 +68,11 @@ void MergeGeometriesDialog::on_selectGeoButton_pressed() QModelIndexList selected = this->allGeoView->selectionModel()->selectedIndexes(); QStringList list = _selGeo->stringList(); - for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) + for (auto& it : selected) { - list.append(it->data().toString()); + list.append(it.data().toString()); - _allGeo->removeRow(it->row()); + _allGeo->removeRow(it.row()); } _selGeo->setStringList(list); } @@ -82,11 +82,11 @@ void MergeGeometriesDialog::on_deselectGeoButton_pressed() QModelIndexList selected = this->selectedGeoView->selectionModel()->selectedIndexes(); QStringList list = _allGeo->stringList(); - for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) + for (auto& it : selected) { - list.append(it->data().toString()); + list.append(it.data().toString()); - _selGeo->removeRow(it->row()); + _selGeo->removeRow(it.row()); } _allGeo->setStringList(list); } @@ -108,8 +108,8 @@ std::vector<std::string> const MergeGeometriesDialog::getSelectedGeometries() co { std::vector<std::string> indexList; QStringList const& list (_selGeo->stringList()); - for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it) - indexList.push_back(it->toStdString()); + for (const auto& it : list) + indexList.push_back(it.toStdString()); return indexList; } diff --git a/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp b/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp index 7aab30599ab..85df5da4562 100644 --- a/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp @@ -32,8 +32,8 @@ MeshAnalysisDialog::MeshAnalysisDialog( if (mesh_vec.empty()) this->startButton->setDisabled(true); - for (std::size_t i=0; i<mesh_vec.size(); ++i) - this->meshListBox->addItem(QString::fromStdString(mesh_vec[i]->getName())); + for (const auto& i : mesh_vec) + this->meshListBox->addItem(QString::fromStdString(i->getName())); auto* collapse_threshold_validator = new StrictDoubleValidator(0, 1000000, 7, this); diff --git a/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp index e1c792c793a..dfcd451863a 100644 --- a/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp @@ -65,15 +65,16 @@ void MeshElementRemovalDialog::accept() if (this->elementTypeCheckBox->isChecked()) { QList<QListWidgetItem*> items = this->elementTypeListWidget->selectedItems(); - for (int i=0; i<items.size(); ++i) - ex.searchByElementType(MeshLib::String2MeshElemType(items[i]->text().toStdString())); + for (auto& item : items) + ex.searchByElementType( + MeshLib::String2MeshElemType(item->text().toStdString())); anything_checked = true; } if (this->materialIDCheckBox->isChecked()) { QList<QListWidgetItem*> items = this->materialListWidget->selectedItems(); - for (int i=0; i<items.size(); ++i) - ex.searchByPropertyValue(items[i]->text().toInt()); + for (auto& item : items) + ex.searchByPropertyValue(item->text().toInt()); anything_checked = true; } if (this->boundingBoxCheckBox->isChecked()) diff --git a/Applications/DataExplorer/DataView/SelectMeshDialog.cpp b/Applications/DataExplorer/DataView/SelectMeshDialog.cpp index 2e47d615b45..5291ee97d30 100644 --- a/Applications/DataExplorer/DataView/SelectMeshDialog.cpp +++ b/Applications/DataExplorer/DataView/SelectMeshDialog.cpp @@ -44,8 +44,8 @@ void SelectMeshDialog::setupDialog(const std::list<std::string> &msh_names) _msh_names = new QComboBox(); - for (auto it = msh_names.begin(); it != msh_names.end(); ++it) - _msh_names->addItem(QString::fromStdString(*it)); + for (const auto& msh_name : msh_names) + _msh_names->addItem(QString::fromStdString(msh_name)); setWindowTitle("Select Mesh..."); _layout->addWidget( _txt_label ); diff --git a/Applications/DataExplorer/DataView/StationTreeModel.cpp b/Applications/DataExplorer/DataView/StationTreeModel.cpp index 5370efd4bff..bca445cdf68 100644 --- a/Applications/DataExplorer/DataView/StationTreeModel.cpp +++ b/Applications/DataExplorer/DataView/StationTreeModel.cpp @@ -178,7 +178,7 @@ void StationTreeModel::removeStationList(QModelIndex index) */ void StationTreeModel::removeStationList(const std::string &name) { - for (std::size_t i = 0; i < _lists.size(); i++) - if ( name.compare( _lists[i]->data(0).toString().toStdString() ) == 0 ) - removeStationList(createIndex(_lists[i]->row(), 0, _lists[i])); + for (auto& _list : _lists) + if (name.compare(_list->data(0).toString().toStdString()) == 0) + removeStationList(createIndex(_list->row(), 0, _list)); } diff --git a/Applications/DataExplorer/DataView/StationTreeView.cpp b/Applications/DataExplorer/DataView/StationTreeView.cpp index e8e00ad498a..a9eb0800143 100644 --- a/Applications/DataExplorer/DataView/StationTreeView.cpp +++ b/Applications/DataExplorer/DataView/StationTreeView.cpp @@ -254,15 +254,17 @@ void StationTreeView::writeStratigraphiesAsImages(QString listName) std::vector<GeoLib::Point*> const& stations = *dynamic_cast<BaseItem*>(lists[i]->getItem())->getStations(); - for (std::size_t i = 0; i < stations.size(); i++) + for (auto station : stations) { - auto* stratView = new StratWindow( - static_cast<GeoLib::StationBorehole*>(stations[i]), - &colorLookupTable); + auto* stratView = + new StratWindow(static_cast<GeoLib::StationBorehole*>(station), + &colorLookupTable); stratView->setAttribute(Qt::WA_DeleteOnClose); stratView->show(); - stratView->stationView->saveAsImage(QString::fromStdString( - static_cast<GeoLib::StationBorehole*>(stations[i])->getName()) + ".jpg"); + stratView->stationView->saveAsImage( + QString::fromStdString( + static_cast<GeoLib::StationBorehole*>(station)->getName()) + + ".jpg"); stratView->close(); } } diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp index 023d00c7401..3a5f5297cd8 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp @@ -41,8 +41,8 @@ VtkAlgorithmProperties::~VtkAlgorithmProperties() _property->Delete(); if (_texture != nullptr) _texture->Delete(); - for (auto it = _lut.begin(); it != _lut.end(); ++it) - it->second->Delete(); + for (auto& it : _lut) + it.second->Delete(); delete _algorithmUserProperties; delete _algorithmUserVectorProperties; } diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp index 3e73af59b04..c7f37840f6a 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp @@ -33,8 +33,8 @@ VtkCompositeNodeSelectionFilter::VtkCompositeNodeSelectionFilter( vtkAlgorithm* VtkCompositeNodeSelectionFilter::~VtkCompositeNodeSelectionFilter() { - for (unsigned i=0; i<_selection.size(); ++i) - delete _selection[i]; + for (auto& i : _selection) + delete i; } void VtkCompositeNodeSelectionFilter::init() @@ -62,9 +62,11 @@ void VtkCompositeNodeSelectionFilter::init() void VtkCompositeNodeSelectionFilter::setSelectionArray(const std::vector<unsigned> &point_indeces) { - for (unsigned i=0; i<point_indeces.size(); ++i) + for (unsigned int point_indece : point_indeces) { - double * coords = static_cast<vtkDataSetAlgorithm*>(_inputAlgorithm)->GetOutput()->GetPoint(point_indeces[i]); + double* coords = static_cast<vtkDataSetAlgorithm*>(_inputAlgorithm) + ->GetOutput() + ->GetPoint(point_indece); auto* p(new GeoLib::Point(coords[0], coords[1], coords[2])); _selection.push_back(p); } diff --git a/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp b/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp index 8832400f508..23552d614fc 100644 --- a/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp @@ -51,9 +51,9 @@ void VtkPointsSource::PrintSelf( ostream& os, vtkIndent indent ) os << indent << "== VtkPointsSource ==" << "\n"; int i = 0; - for (auto it = _points->begin(); it != _points->end(); ++it) + for (auto _point : *_points) { - const double* coords = (*it)->getCoords(); + const double* coords = _point->getCoords(); os << indent << "Point " << i << " (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")\n"; i++; @@ -95,9 +95,9 @@ int VtkPointsSource::RequestData( vtkInformation* request, // Generate points and vertices unsigned i = 0; - for (auto it = _points->begin(); it != _points->end(); ++it) + for (auto _point : *_points) { - double coords[3] = {(*(*it))[0], (*(*it))[1], (*(*it))[2]}; + double coords[3] = {(*_point)[0], (*_point)[1], (*_point)[2]}; newPoints->SetPoint(i, coords); newVerts->InsertNextCell(1); newVerts->InsertCellPoint(i); diff --git a/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp b/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp index 4f0b79471af..747da52d917 100644 --- a/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp @@ -54,13 +54,13 @@ void VtkPolylinesSource::PrintSelf( ostream& os, vtkIndent indent ) if (_polylines->size() == 0) return; - for (auto it = _polylines->begin(); it != _polylines->end(); ++it) + for (auto _polyline : *_polylines) { os << indent << "== Polyline ==" << "\n"; - int numPoints = (*it)->getNumberOfPoints(); + int numPoints = _polyline->getNumberOfPoints(); for (int i = 0; i < numPoints; i++) { - const GeoLib::Point* point = (*it)->getPoint(i); + const GeoLib::Point* point = _polyline->getPoint(i); const double* coords = point->getCoords(); os << indent << "Point " << i << " (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")\n"; diff --git a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp index ea9e379cdf1..18813e77199 100644 --- a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp @@ -54,9 +54,9 @@ void VtkStationSource::PrintSelf( ostream& os, vtkIndent indent ) os << indent << "== VtkStationSource ==" << "\n"; int i = 0; - for (auto it = _stations->begin(); it != _stations->end(); ++it) + for (auto _station : *_stations) { - const double* coords = (*it)->getCoords(); + const double* coords = _station->getCoords(); os << indent << "Station " << i << " (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")\n"; i++; @@ -122,22 +122,23 @@ int VtkStationSource::RequestData( vtkInformation* request, std::size_t site_count(0); // Generate graphic objects - for (auto it = _stations->begin(); it != _stations->end(); ++it) + for (auto _station : *_stations) { - double coords[3] = { (*(*it))[0], (*(*it))[1], (*(*it))[2] }; + double coords[3] = {(*_station)[0], (*_station)[1], (*_station)[2]}; vtkIdType sid = newStations->InsertNextPoint(coords); station_ids->InsertNextValue(site_count); if (useStationValues) - station_values->InsertNextValue(static_cast<GeoLib::Station*>(*it)->getStationValue()); + station_values->InsertNextValue( + static_cast<GeoLib::Station*>(_station)->getStationValue()); if (!isBorehole) newVerts->InsertNextCell(1, &sid); else { std::vector<GeoLib::Point*> profile = - static_cast<GeoLib::StationBorehole*>(*it)->getProfile(); + static_cast<GeoLib::StationBorehole*>(_station)->getProfile(); std::vector<std::string> soilNames = - static_cast<GeoLib::StationBorehole*>(*it)->getSoilNames(); + static_cast<GeoLib::StationBorehole*>(_station)->getSoilNames(); const std::size_t nLayers = profile.size(); for (std::size_t i = 1; i < nLayers; i++) @@ -153,7 +154,9 @@ int VtkStationSource::RequestData( vtkInformation* request, ++lastMaxIndex); // end of boreholelayer strat_ids->InsertNextValue(this->GetIndexByName(soilNames[i])); if (useStationValues) - station_values->InsertNextValue(static_cast<GeoLib::Station*>(*it)->getStationValue()); + station_values->InsertNextValue( + static_cast<GeoLib::Station*>(_station) + ->getStationValue()); } lastMaxIndex++; } diff --git a/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp b/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp index 498f2503905..28f4362f1e3 100644 --- a/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp @@ -91,16 +91,16 @@ int VtkSurfacesSource::RequestData( vtkInformation* request, } vtkIdType count(0); - for (auto it = _surfaces->begin(); it != _surfaces->end(); ++it) + for (auto _surface : *_surfaces) { - const std::size_t nTriangles = (*it)->getNumberOfTriangles(); + const std::size_t nTriangles = _surface->getNumberOfTriangles(); for (std::size_t i = 0; i < nTriangles; ++i) { vtkTriangle* new_tri = vtkTriangle::New(); new_tri->GetPointIds()->SetNumberOfIds(3); - const GeoLib::Triangle* triangle = (**it)[i]; + const GeoLib::Triangle* triangle = (*_surface)[i]; for (std::size_t j = 0; j < 3; ++j) new_tri->GetPointIds()->SetId(j, ((*triangle)[j])); newPolygons->InsertNextCell(new_tri); diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp index de4bf4fc8a2..67dab85f550 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp @@ -91,9 +91,9 @@ bool VtkVisPipeline::setData( const QModelIndex &index, const QVariant &value, void VtkVisPipeline::addLight(const GeoLib::Point &pos) { double lightPos[3]; - for (auto it = _lights.begin(); it != _lights.end(); ++it) + for (auto& _light : _lights) { - (*it)->GetPosition(lightPos); + _light->GetPosition(lightPos); if (pos[0] == lightPos[0] && pos[1] == lightPos[1] && pos[2] == lightPos[2]) return; } @@ -106,11 +106,11 @@ void VtkVisPipeline::addLight(const GeoLib::Point &pos) vtkLight* VtkVisPipeline::getLight(const GeoLib::Point &pos) const { double lightPos[3]; - for (auto it = _lights.begin(); it != _lights.end(); ++it) + for (auto _light : _lights) { - (*it)->GetPosition(lightPos); + _light->GetPosition(lightPos); if (pos[0] == lightPos[0] && pos[1] == lightPos[1] && pos[2] == lightPos[2]) - return *it; + return _light; } return nullptr; } diff --git a/Applications/DataExplorer/mainwindow.cpp b/Applications/DataExplorer/mainwindow.cpp index c5a7f8daea5..21c11b6f59e 100644 --- a/Applications/DataExplorer/mainwindow.cpp +++ b/Applications/DataExplorer/mainwindow.cpp @@ -466,8 +466,8 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) _project.getGEOObjects(), unique_name, errors)) { - for (std::size_t k(0); k<errors.size(); k++) - OGSError::box(QString::fromStdString(errors[k])); + for (auto& error : errors) + OGSError::box(QString::fromStdString(error)); } } else if (fi.suffix().toLower() == "gsp") diff --git a/Applications/FileIO/AsciiRasterInterface.cpp b/Applications/FileIO/AsciiRasterInterface.cpp index 374a43431dc..e62c6711482 100644 --- a/Applications/FileIO/AsciiRasterInterface.cpp +++ b/Applications/FileIO/AsciiRasterInterface.cpp @@ -226,10 +226,9 @@ void AsciiRasterInterface::writeRasterAsASC(GeoLib::Raster const& raster, std::s /// Checks if all raster files actually exist static bool allRastersExist(std::vector<std::string> const& raster_paths) { - for (auto raster = raster_paths.begin(); raster != raster_paths.end(); - ++raster) + for (const auto& raster_path : raster_paths) { - std::ifstream file_stream(*raster, std::ifstream::in); + std::ifstream file_stream(raster_path, std::ifstream::in); if (!file_stream.good()) return false; file_stream.close(); } diff --git a/Applications/FileIO/CsvInterface.cpp b/Applications/FileIO/CsvInterface.cpp index cd9b2001eff..d1f462ec568 100644 --- a/Applications/FileIO/CsvInterface.cpp +++ b/Applications/FileIO/CsvInterface.cpp @@ -175,9 +175,9 @@ std::size_t CsvInterface::findColumn(std::string const& line, char delim, std::s return std::numeric_limits<std::size_t>::max(); std::size_t count(0); - for (auto it = fields.cbegin(); it != fields.cend(); ++it) + for (const auto& field : fields) { - if ((*it).compare(column_name) == 0) + if (field.compare(column_name) == 0) break; else count++; diff --git a/Applications/FileIO/Gmsh/GMSHInterface.cpp b/Applications/FileIO/Gmsh/GMSHInterface.cpp index ef4cc3c6e3c..f935da9c038 100644 --- a/Applications/FileIO/Gmsh/GMSHInterface.cpp +++ b/Applications/FileIO/Gmsh/GMSHInterface.cpp @@ -192,9 +192,9 @@ int GMSHInterface::writeGMSHInputFile(std::ostream& out) } // *** init mesh density strategies - for (auto it(_polygon_tree_list.begin()); - it != _polygon_tree_list.end(); ++it) { - (*it)->initMeshDensityStrategy(); + for (auto& it : _polygon_tree_list) + { + it->initMeshDensityStrategy(); } // *** create GMSH data structures @@ -203,9 +203,9 @@ int GMSHInterface::writeGMSHInputFile(std::ostream& out) for (std::size_t k(0); k<n_merged_pnts; k++) { _gmsh_pnts[k] = nullptr; } - for (auto it(_polygon_tree_list.begin()); - it != _polygon_tree_list.end(); ++it) { - (*it)->createGMSHPoints(_gmsh_pnts); + for (auto& it : _polygon_tree_list) + { + it->createGMSHPoints(_gmsh_pnts); } // *** finally write data :-) diff --git a/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp b/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp index a7c6df94168..14c4db24ef1 100644 --- a/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp +++ b/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp @@ -53,8 +53,9 @@ void GMSHPolygonTree::markSharedSegments() if (_parent == nullptr) return; - for (auto it(_children.begin()); it != _children.end(); it++) { - std::size_t const n_pnts((*it)->getPolygon()->getNumberOfPoints()); + for (auto& it : _children) + { + std::size_t const n_pnts(it->getPolygon()->getNumberOfPoints()); for (std::size_t k(1); k<n_pnts; k++) { if (GeoLib::containsEdge(*(_parent->getPolygon()), _node_polygon->getPointID(k-1), @@ -280,9 +281,9 @@ void GMSHPolygonTree::createGMSHPoints(std::vector<GMSHPoint*> & gmsh_pnts) cons } // walk through children - for (auto it(_children.begin()); it != _children.end(); ++it) + for (auto it : _children) { - dynamic_cast<GMSHPolygonTree*>((*it))->createGMSHPoints(gmsh_pnts); + dynamic_cast<GMSHPolygonTree*>(it)->createGMSHPoints(gmsh_pnts); } } @@ -333,9 +334,10 @@ void GMSHPolygonTree::writeLineConstraints(std::size_t& line_offset, void GMSHPolygonTree::writeSubPolygonsAsLineConstraints(std::size_t &line_offset, std::size_t sfc_number, std::ostream& out) const { - for (auto it(_children.begin()); it != _children.end(); ++it) + for (auto it : _children) { - dynamic_cast<GMSHPolygonTree*>((*it))->writeSubPolygonsAsLineConstraints(line_offset, sfc_number, out); + dynamic_cast<GMSHPolygonTree*>(it)->writeSubPolygonsAsLineConstraints( + line_offset, sfc_number, out); } if (_parent != nullptr) diff --git a/Applications/FileIO/Gmsh/GmshReader.cpp b/Applications/FileIO/Gmsh/GmshReader.cpp index 6717e85031b..fab12ea7df9 100644 --- a/Applications/FileIO/Gmsh/GmshReader.cpp +++ b/Applications/FileIO/Gmsh/GmshReader.cpp @@ -235,8 +235,9 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname) } in.close(); if (elements.empty()) { - for (auto it(nodes.begin()); it != nodes.end(); ++it) { - delete *it; + for (auto& node : nodes) + { + delete node; } return nullptr; } diff --git a/Applications/Utils/OGSFileConverter/FileListDialog.cpp b/Applications/Utils/OGSFileConverter/FileListDialog.cpp index 9792fe0d32f..184f53e1d97 100644 --- a/Applications/Utils/OGSFileConverter/FileListDialog.cpp +++ b/Applications/Utils/OGSFileConverter/FileListDialog.cpp @@ -61,8 +61,8 @@ void FileListDialog::on_addButton_pressed() void FileListDialog::on_removeButton_pressed() { QModelIndexList selected = this->listView->selectionModel()->selectedIndexes(); - for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) - this->_allFiles.removeRow(it->row()); + for (auto& it : selected) + this->_allFiles.removeRow(it.row()); } void FileListDialog::on_browseButton_pressed() diff --git a/Applications/Utils/OGSFileConverter/OGSFileConverter.cpp b/Applications/Utils/OGSFileConverter/OGSFileConverter.cpp index 1ee6b5a5ab8..a18a3d57f2f 100644 --- a/Applications/Utils/OGSFileConverter/OGSFileConverter.cpp +++ b/Applications/Utils/OGSFileConverter/OGSFileConverter.cpp @@ -45,15 +45,15 @@ void OGSFileConverter::convertGML2GLI(const QStringList &input, const QString &o GeoLib::GEOObjects geo_objects; GeoLib::IO::XmlGmlInterface xml(geo_objects); - for (QStringList::const_iterator it=input.begin(); it!=input.end(); ++it) + for (const auto& it : input) { - const QFileInfo fi(*it); + const QFileInfo fi(it); const std::string output_str = QString(output + "/" + fi.completeBaseName() + ".gli").toStdString(); if (fileExists(output_str)) continue; - if (!xml.readFile(*it)) + if (!xml.readFile(it)) { OGSError::box("Error reading geometry " + fi.fileName()); continue; @@ -76,9 +76,9 @@ void OGSFileConverter::convertGLI2GML(const QStringList &input, const QString &o GeoLib::GEOObjects geo_objects; GeoLib::IO::XmlGmlInterface xml(geo_objects); - for (QStringList::const_iterator it=input.begin(); it!=input.end(); ++it) + for (const auto& it : input) { - const QFileInfo fi(*it); + const QFileInfo fi(it); const std::string output_str = QString(output + "/" + fi.completeBaseName() + ".gml").toStdString(); if (fileExists(output_str)) @@ -87,10 +87,12 @@ void OGSFileConverter::convertGLI2GML(const QStringList &input, const QString &o std::string unique_name; std::vector<std::string> errors; - GeoLib::IO::Legacy::readGLIFileV4(it->toStdString(), geo_objects, unique_name, errors); + GeoLib::IO::Legacy::readGLIFileV4(it.toStdString(), geo_objects, + unique_name, errors); if (errors.empty() || (errors.size()==1 && errors[0].compare("[readSurface] polyline for surface not found!")==0)) { - std::string const geo_name = BaseLib::extractBaseName(it->toStdString()); + std::string const geo_name = + BaseLib::extractBaseName(it.toStdString()); xml.setNameForExport(geo_name); xml.writeToFile(output_str); geo_objects.removeSurfaceVec(geo_name); @@ -98,8 +100,8 @@ void OGSFileConverter::convertGLI2GML(const QStringList &input, const QString &o geo_objects.removePointVec(geo_name); } else - for (std::size_t k(0); k<errors.size(); ++k) - OGSError::box(QString::fromStdString(errors[k])); + for (auto& error : errors) + OGSError::box(QString::fromStdString(error)); } OGSError::box("File conversion finished"); } @@ -109,15 +111,16 @@ void OGSFileConverter::convertVTU2MSH(const QStringList &input, const QString &o if (input.empty()) return; - for (QStringList::const_iterator it=input.begin(); it!=input.end(); ++it) + for (const auto& it : input) { - const QFileInfo fi(*it); + const QFileInfo fi(it); const std::string output_str = QString(output + "/" + fi.completeBaseName() + ".msh").toStdString(); if (fileExists(output_str)) continue; - MeshLib::Mesh const*const mesh (MeshLib::IO::VtuInterface::readVTUFile(it->toStdString().c_str())); + MeshLib::Mesh const* const mesh( + MeshLib::IO::VtuInterface::readVTUFile(it.toStdString().c_str())); if (mesh == nullptr) { OGSError::box("Error reading mesh " + fi.fileName()); @@ -136,16 +139,17 @@ void OGSFileConverter::convertMSH2VTU(const QStringList &input, const QString &o if (input.empty()) return; - for (QStringList::const_iterator it=input.begin(); it!=input.end(); ++it) + for (const auto& it : input) { - const QFileInfo fi(*it); + const QFileInfo fi(it); const std::string output_str = QString(output + "/" + fi.completeBaseName() + ".vtu").toStdString(); if (fileExists(output_str)) continue; MeshLib::IO::Legacy::MeshIO meshIO; - MeshLib::Mesh const*const mesh (meshIO.loadMeshFromFile(it->toStdString())); + MeshLib::Mesh const* const mesh( + meshIO.loadMeshFromFile(it.toStdString())); if (mesh == nullptr) { OGSError::box("Error reading mesh " + fi.fileName()); diff --git a/GeoLib/EarClippingTriangulation.cpp b/GeoLib/EarClippingTriangulation.cpp index eb1bb2b5dfa..a6d34a3a296 100644 --- a/GeoLib/EarClippingTriangulation.cpp +++ b/GeoLib/EarClippingTriangulation.cpp @@ -114,10 +114,13 @@ void EarClippingTriangulation::ensureCWOrientation () bool EarClippingTriangulation::isEar(std::size_t v0, std::size_t v1, std::size_t v2) const { - for (auto it(_vertex_list.begin()); it != _vertex_list.end(); ++it) + for (unsigned long it : _vertex_list) { - if (*it != v0 && *it != v1 && *it != v2) { - if (MathLib::isPointInTriangle (*_pnts[*it], *_pnts[v0], *_pnts[v1], *_pnts[v2])) { + if (it != v0 && it != v1 && it != v2) + { + if (MathLib::isPointInTriangle(*_pnts[it], *_pnts[v0], *_pnts[v1], + *_pnts[v2])) + { return false; } } diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index 83651e18883..dff35a46c87 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -105,10 +105,12 @@ void GEOObjects::addStationVec(std::unique_ptr<std::vector<Point*>> stations, const std::vector<GeoLib::Point*>* GEOObjects::getStationVec( const std::string& name) const { - for (auto it(_pnt_vecs.begin()); it != _pnt_vecs.end(); ++it) + for (auto _pnt_vec : _pnt_vecs) { - if ((*it)->getName().compare(name) == 0 && (*it)->getType() == PointVec::PointType::STATION) { - return (*it)->getVector(); + if (_pnt_vec->getName().compare(name) == 0 && + _pnt_vec->getType() == PointVec::PointType::STATION) + { + return _pnt_vec->getVector(); } } DBUG("GEOObjects::getStationVec() - No entry found with name \"%s\".", name.c_str()); @@ -311,14 +313,14 @@ bool GEOObjects::isUniquePointVecName(std::string &name) bool GEOObjects::isPntVecUsed (const std::string &name) const { // search dependent data structures (Polyline) - for (auto it(_ply_vecs.begin()); it != _ply_vecs.end(); ++it) + for (auto _ply_vec : _ply_vecs) { - if (((*it)->getName()).compare(name) == 0) + if ((_ply_vec->getName()).compare(name) == 0) return true; } - for (auto it(_sfc_vecs.begin()); it != _sfc_vecs.end(); ++it) + for (auto _sfc_vec : _sfc_vecs) { - if (((*it)->getName()).compare(name) == 0) + if ((_sfc_vec->getName()).compare(name) == 0) return true; } @@ -327,17 +329,17 @@ bool GEOObjects::isPntVecUsed (const std::string &name) const void GEOObjects::getStationVectorNames(std::vector<std::string>& names) const { - for (auto it(_pnt_vecs.begin()); it != _pnt_vecs.end(); ++it) - if ((*it)->getType() == PointVec::PointType::STATION) - names.push_back((*it)->getName()); + for (auto _pnt_vec : _pnt_vecs) + if (_pnt_vec->getType() == PointVec::PointType::STATION) + names.push_back(_pnt_vec->getName()); } void GEOObjects::getGeometryNames (std::vector<std::string>& names) const { names.clear (); - for (auto it(_pnt_vecs.begin()); it != _pnt_vecs.end(); ++it) - if ((*it)->getType() == PointVec::PointType::POINT) - names.push_back((*it)->getName()); + for (auto _pnt_vec : _pnt_vecs) + if (_pnt_vec->getType() == PointVec::PointType::POINT) + names.push_back(_pnt_vec->getName()); } const std::string GEOObjects::getElementNameByID(const std::string &geometry_name, GeoLib::GEOTYPE type, std::size_t id) const diff --git a/GeoLib/PointVec.cpp b/GeoLib/PointVec.cpp index 7e619040b58..2f4cf4e5b64 100644 --- a/GeoLib/PointVec.cpp +++ b/GeoLib/PointVec.cpp @@ -199,9 +199,9 @@ void PointVec::correctNameIDMapping() { // create mapping id -> name using the std::vector id_names std::vector<std::string> id_names(_pnt_id_map.size(), std::string("")); - for (auto it = _name_id_map->begin(); it != _name_id_map->end(); ++it) + for (auto& it : *_name_id_map) { - id_names[it->second] = it->first; + id_names[it.second] = it.first; } for (auto it = _name_id_map->begin(); it != _name_id_map->end();) diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index 935f6a7aabf..df98e74747c 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -48,12 +48,10 @@ Polygon::Polygon(Polygon const& other) Polygon::~Polygon() { // remove polygons from list - for (auto it(_simple_polygon_list.begin()); - it != _simple_polygon_list.end(); - ++it) + for (auto& it : _simple_polygon_list) // the first entry of the list can be a pointer the object itself - if (*it != this) - delete *it; + if (it != this) + delete it; } bool Polygon::initialise () @@ -235,11 +233,9 @@ bool Polygon::getNextIntersectionPointPolygonLine( } } } else { - for (auto polygon_it(_simple_polygon_list.begin()); - polygon_it != _simple_polygon_list.end(); - ++polygon_it) + for (auto polygon_it : _simple_polygon_list) { - Polygon const& polygon(*(*polygon_it)); + Polygon const& polygon(*polygon_it); for (auto seg_it(polygon.begin()); seg_it != polygon.end(); ++seg_it) { if (GeoLib::lineSegmentIntersect(*seg_it, seg, intersection)) { @@ -262,10 +258,8 @@ void Polygon::computeListOfSimplePolygons () splitPolygonAtPoint (_simple_polygon_list.begin()); splitPolygonAtIntersection (_simple_polygon_list.begin()); - for (auto it(_simple_polygon_list.begin()); - it != _simple_polygon_list.end(); - ++it) - (*it)->initialise (); + for (auto& it : _simple_polygon_list) + it->initialise(); } EdgeType Polygon::getEdgeType (std::size_t k, GeoLib::Point const & pnt) const diff --git a/GeoLib/QuadTree.h b/GeoLib/QuadTree.h index de71d952ef1..7b9878635d7 100644 --- a/GeoLib/QuadTree.h +++ b/GeoLib/QuadTree.h @@ -54,8 +54,8 @@ public: assert (_max_points_per_leaf > 0); // init children - for (std::size_t k(0); k < 4; k++) - _children[k] = nullptr; + for (auto& k : _children) + k = nullptr; if ((_ur[0] - _ll[0]) > (_ur[1] - _ll[1])) _ur[1] = _ll[1] + _ur[0] - _ll[0]; @@ -70,8 +70,9 @@ public: */ ~QuadTree() { - for (std::size_t k(0); k < 4; k++) { - delete _children[k]; + for (auto& k : _children) + { + delete k; } } @@ -89,8 +90,9 @@ public: if ((*pnt)[1] >= _ur[1]) return false; if (!_is_leaf) { - for (std::size_t k(0); k < 4; k++) { - if (_children[k]->addPoint (pnt)) + for (auto& k : _children) + { + if (k->addPoint(pnt)) return true; } return false; @@ -182,9 +184,8 @@ public: if (_is_leaf) leaf_list.push_back (this); else - for (std::size_t k(0); k < 4; k++) - _children[k]->getLeafs (leaf_list); - + for (auto& k : _children) + k->getLeafs(leaf_list); } const std::vector<POINT const*>& getPoints () const { return _pnts; } @@ -241,9 +242,11 @@ public: if (max_depth < _depth) max_depth = _depth; - for (std::size_t k(0); k<4; k++) { - if (_children[k]) { - _children[k]->getMaxDepth(max_depth); + for (auto& k : _children) + { + if (k) + { + k->getMaxDepth(max_depth); } } } @@ -374,8 +377,8 @@ private: _max_points_per_leaf (max_points_per_leaf) { // init children - for (std::size_t k(0); k < 4; k++) - _children[k] = nullptr; + for (auto& k : _children) + k = nullptr; } void splitNode () diff --git a/GeoLib/Surface.cpp b/GeoLib/Surface.cpp index 3a541fdef33..1e6f511df08 100644 --- a/GeoLib/Surface.cpp +++ b/GeoLib/Surface.cpp @@ -109,12 +109,10 @@ Surface* Surface::createSurface(const Polyline& ply) // create surfaces from simple polygons const std::list<GeoLib::Polygon*>& list_of_simple_polygons( polygon->getListOfSimplePolygons()); - for (auto simple_polygon_it(list_of_simple_polygons.begin()); - simple_polygon_it != list_of_simple_polygons.end(); - ++simple_polygon_it) + for (auto list_of_simple_polygon : list_of_simple_polygons) { std::list<GeoLib::Triangle> triangles; - GeoLib::EarClippingTriangulation(*simple_polygon_it, triangles); + GeoLib::EarClippingTriangulation(list_of_simple_polygon, triangles); // add Triangles to Surface std::list<GeoLib::Triangle>::const_iterator it(triangles.begin()); diff --git a/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp b/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp index 065d84cc958..75647228355 100644 --- a/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp +++ b/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp @@ -79,9 +79,9 @@ double computeBarMu0Factor(const double barT) { double sum_val = 0.; double barT_i = 1.; - for (int i = 0; i < 4; i++) + for (double i : Hi) { - sum_val += (Hi[i] / barT_i); + sum_val += (i / barT_i); barT_i *= barT; } return sum_val; diff --git a/MeshGeoToolsLib/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp index 3a1f3740e04..f8c8eadce94 100644 --- a/MeshGeoToolsLib/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -562,9 +562,9 @@ void GeoMapper::advancedMapOnMesh(MeshLib::Mesh const& mesh) // 3. map each polyline auto org_lines(_geo_objects.getPolylineVec(_geo_name)); auto org_points(_geo_objects.getPointVecObj(_geo_name)); - for (std::size_t k(0); k<org_lines->size(); ++k) { - mapPolylineOnSurfaceMesh(*((*org_lines)[k]), *org_points, - mesh_element_grid); + for (auto org_line : *org_lines) + { + mapPolylineOnSurfaceMesh(*org_line, *org_points, mesh_element_grid); } } diff --git a/MeshGeoToolsLib/HeuristicSearchLength.cpp b/MeshGeoToolsLib/HeuristicSearchLength.cpp index fedfdd6b99b..261cc63951b 100644 --- a/MeshGeoToolsLib/HeuristicSearchLength.cpp +++ b/MeshGeoToolsLib/HeuristicSearchLength.cpp @@ -28,11 +28,12 @@ HeuristicSearchLength::HeuristicSearchLength(MeshLib::Mesh const& mesh, LengthTy std::vector<MeshLib::Element*> const& elements(_mesh.getElements()); if (length_type==LengthType::Edge) { - for (auto it(elements.cbegin()); - it != elements.cend(); ++it) { - std::size_t const n_edges((*it)->getNumberOfEdges()); + for (auto element : elements) + { + std::size_t const n_edges(element->getNumberOfEdges()); for (std::size_t k(0); k<n_edges; k++) { - auto edge = (*it)->getEdge(k); // allocation inside getEdge(). + auto edge = + element->getEdge(k); // allocation inside getEdge(). double const len = edge->getContent(); delete edge; sum += len; diff --git a/MeshLib/IO/Legacy/MeshIO.cpp b/MeshLib/IO/Legacy/MeshIO.cpp index dc2d15dfffe..426c032864e 100644 --- a/MeshLib/IO/Legacy/MeshIO.cpp +++ b/MeshLib/IO/Legacy/MeshIO.cpp @@ -120,8 +120,8 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) if (elements.empty()) { ERR ("MeshIO::loadMeshFromFile() - File did not contain element information."); - for (auto it = nodes.begin(); it!=nodes.end(); ++it) - delete *it; + for (auto& node : nodes) + delete node; return nullptr; } diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp index a3a0b0e6420..542d01a96fb 100644 --- a/MeshLib/Mesh.cpp +++ b/MeshLib/Mesh.cpp @@ -144,19 +144,19 @@ void Mesh::setDimension() void Mesh::setElementsConnectedToNodes() { - for (auto e = _elements.begin(); e != _elements.end(); ++e) + for (auto& _element : _elements) { - const unsigned nNodes ((*e)->getNumberOfNodes()); + const unsigned nNodes(_element->getNumberOfNodes()); for (unsigned j=0; j<nNodes; ++j) - (*e)->_nodes[j]->addElement(*e); + _element->_nodes[j]->addElement(_element); } } void Mesh::resetElementsConnectedToNodes() { - for (auto node = _nodes.begin(); node != _nodes.end(); ++node) - if (*node) - (*node)->clearElements(); + for (auto& _node : _nodes) + if (_node) + _node->clearElements(); this->setElementsConnectedToNodes(); } @@ -180,11 +180,9 @@ void Mesh::calcEdgeLengthRange() void Mesh::setElementNeighbors() { std::vector<Element*> neighbors; - for (auto it = _elements.begin(); it != _elements.end(); ++it) + for (auto element : _elements) { // create vector with all elements connected to current element (includes lots of doubles!) - Element *const element = *it; - const std::size_t nNodes (element->getNumberOfBaseNodes()); for (unsigned n(0); n<nNodes; ++n) { diff --git a/MeshLib/MeshEditing/MeshRevision.cpp b/MeshLib/MeshEditing/MeshRevision.cpp index 44a3edd9050..c7a9877cadd 100644 --- a/MeshLib/MeshEditing/MeshRevision.cpp +++ b/MeshLib/MeshEditing/MeshRevision.cpp @@ -858,11 +858,11 @@ unsigned MeshRevision::lutPrismThirdNode(unsigned id1, unsigned id2) const void MeshRevision::cleanUp(std::vector<MeshLib::Node*> &new_nodes, std::vector<MeshLib::Element*> &new_elements) const { - for (auto elem = new_elements.begin(); elem != new_elements.end(); ++elem) - delete *elem; + for (auto& new_element : new_elements) + delete new_element; - for (auto node = new_nodes.begin(); node != new_nodes.end(); ++node) - delete *node; + for (auto& new_node : new_nodes) + delete new_node; } } // end namespace MeshLib diff --git a/MeshLib/MeshInformation.cpp b/MeshLib/MeshInformation.cpp index 33c5d92467e..3e78cc0d41d 100644 --- a/MeshLib/MeshInformation.cpp +++ b/MeshLib/MeshInformation.cpp @@ -28,9 +28,9 @@ const std::array<unsigned, 7> MeshInformation::getNumberOfElementTypes(const Mes { std::array<unsigned, 7> n_element_types = {{0, 0, 0, 0, 0, 0, 0}}; const std::vector<MeshLib::Element*> &elements (mesh.getElements()); - for (auto it = elements.begin(); it != elements.end(); ++it) + for (auto element : elements) { - MeshElemType t = (*it)->getGeomType(); + MeshElemType t = element->getGeomType(); if (t == MeshElemType::LINE) n_element_types[0]++; if (t == MeshElemType::TRIANGLE) n_element_types[1]++; if (t == MeshElemType::QUAD) n_element_types[2]++; diff --git a/MeshLib/MeshSurfaceExtraction.cpp b/MeshLib/MeshSurfaceExtraction.cpp index ba14e2fd1d6..b478f489b72 100644 --- a/MeshLib/MeshSurfaceExtraction.cpp +++ b/MeshLib/MeshSurfaceExtraction.cpp @@ -100,19 +100,20 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshSurface( // create new elements vector with newly created nodes std::vector<MeshLib::Element*> new_elements; new_elements.reserve(sfc_elements.size()); - for (auto elem = sfc_elements.cbegin(); elem != sfc_elements.cend(); ++elem) + for (auto sfc_element : sfc_elements) { - unsigned const n_elem_nodes ((*elem)->getNumberOfBaseNodes()); + unsigned const n_elem_nodes(sfc_element->getNumberOfBaseNodes()); auto** new_nodes = new MeshLib::Node*[n_elem_nodes]; for (unsigned k(0); k<n_elem_nodes; k++) - new_nodes[k] = sfc_nodes[node_id_map[(*elem)->getNode(k)->getID()]]; - if ((*elem)->getGeomType() == MeshElemType::TRIANGLE) + new_nodes[k] = + sfc_nodes[node_id_map[sfc_element->getNode(k)->getID()]]; + if (sfc_element->getGeomType() == MeshElemType::TRIANGLE) new_elements.push_back(new MeshLib::Tri(new_nodes)); else { - assert((*elem)->getGeomType() == MeshElemType::QUAD); + assert(sfc_element->getGeomType() == MeshElemType::QUAD); new_elements.push_back(new MeshLib::Quad(new_nodes)); } - delete *elem; + delete sfc_element; } std::vector<std::size_t> id_map; @@ -166,9 +167,8 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshBoundary(const MeshLib::Mesh &mesh) std::vector<MeshLib::Element*> boundary_elements; std::vector<MeshLib::Element*> const& org_elems (mesh.getElements()); - for (auto it=org_elems.begin(); it!=org_elems.end(); ++it) + for (auto elem : org_elems) { - MeshLib::Element* elem (*it); std::size_t const n_edges (elem->getNumberOfEdges()); for (std::size_t i=0; i<n_edges; ++i) if (elem->getNeighbor(i) == nullptr) diff --git a/MeshLib/Properties.cpp b/MeshLib/Properties.cpp index 1a50474fdc2..7cdd6beae9f 100644 --- a/MeshLib/Properties.cpp +++ b/MeshLib/Properties.cpp @@ -94,9 +94,10 @@ Properties::Properties(Properties const& properties) : _properties(properties._properties) { std::vector<std::size_t> exclude_positions; - for (auto it(_properties.begin()); it != _properties.end(); ++it) { - PropertyVectorBase *t(it->second->clone(exclude_positions)); - it->second = t; + for (auto& _propertie : _properties) + { + PropertyVectorBase* t(_propertie.second->clone(exclude_positions)); + _propertie.second = t; } } diff --git a/MeshLib/Vtk/VtkMappedMeshSource.cpp b/MeshLib/Vtk/VtkMappedMeshSource.cpp index 1c7a7a07227..cb85f45ec12 100644 --- a/MeshLib/Vtk/VtkMappedMeshSource.cpp +++ b/MeshLib/Vtk/VtkMappedMeshSource.cpp @@ -81,13 +81,13 @@ int VtkMappedMeshSource::RequestData(vtkInformation*, // Cells auto elems = _mesh->getElements(); output->Allocate(elems.size()); - for (std::size_t cell = 0; cell < elems.size(); cell++) + for (auto& cell : elems) { - auto cellType = OGSToVtkCellType(elems[cell]->getCellType()); + auto cellType = OGSToVtkCellType(cell->getCellType()); - const MeshLib::Element* const elem = (elems)[cell]; + const MeshLib::Element* const elem = cell; const unsigned numNodes(elem->getNumberOfNodes()); - const MeshLib::Node* const* nodes = elems[cell]->getNodes(); + const MeshLib::Node* const* nodes = cell->getNodes(); vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); ptIds->SetNumberOfIds(numNodes); diff --git a/NumLib/DOF/MeshComponentMap.cpp b/NumLib/DOF/MeshComponentMap.cpp index 401a3834476..629e5698428 100644 --- a/NumLib/DOF/MeshComponentMap.cpp +++ b/NumLib/DOF/MeshComponentMap.cpp @@ -234,9 +234,9 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByLocation( global_indices.reserve(ls.size()); auto const &m = _dict.get<ByLocation>(); - for (auto l = ls.cbegin(); l != ls.cend(); ++l) + for (const auto& l : ls) { - auto const p = m.equal_range(Line(*l)); + auto const p = m.equal_range(Line(l)); for (auto itr = p.first; itr != p.second; ++itr) global_indices.push_back(itr->global_index); } @@ -254,9 +254,9 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByComponent( // Create a sub dictionary containing all lines with location from ls. auto const &m = _dict.get<ByLocation>(); - for (auto l = ls.cbegin(); l != ls.cend(); ++l) + for (const auto& l : ls) { - auto const p = m.equal_range(Line(*l)); + auto const p = m.equal_range(Line(l)); for (auto itr = p.first; itr != p.second; ++itr) pairs.emplace_back(itr->comp_id, itr->global_index); } @@ -272,8 +272,8 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByComponent( std::vector<GlobalIndexType> global_indices; global_indices.reserve(pairs.size()); - for (auto p = pairs.cbegin(); p != pairs.cend(); ++p) - global_indices.push_back(p->second); + for (const auto& pair : pairs) + global_indices.push_back(pair.second); return global_indices; } diff --git a/Tests/FileIO/TestGmlInterface.h b/Tests/FileIO/TestGmlInterface.h index 47de4c320ab..a312ff756d4 100644 --- a/Tests/FileIO/TestGmlInterface.h +++ b/Tests/FileIO/TestGmlInterface.h @@ -99,8 +99,9 @@ public: { auto const & pnt_id_map(pnt_vec.getIDMap()); lines[line_id] = new GeoLib::Polyline(*(pnt_vec.getVector())); - for (std::size_t k(0); k<pnt_ids.size(); ++k) { - lines[line_id]->addPoint(pnt_id_map[pnt_ids[k]]); + for (unsigned long pnt_id : pnt_ids) + { + lines[line_id]->addPoint(pnt_id_map[pnt_id]); } if (!name.empty()) diff --git a/Tests/GeoLib/TestAABB.cpp b/Tests/GeoLib/TestAABB.cpp index 68b83ed2087..cf027302461 100644 --- a/Tests/GeoLib/TestAABB.cpp +++ b/Tests/GeoLib/TestAABB.cpp @@ -54,9 +54,9 @@ TEST(GeoLibAABB, RandomNumberOfPointersToRandomPoints) ASSERT_GE(half_box_size, max_pnt[1]) << "coordinate 1 of max_pnt is greater than " << half_box_size; ASSERT_GE(half_box_size, max_pnt[2]) << "coordinate 2 of max_pnt is greater than " << half_box_size; - for (auto it(pnts_list.begin()); it != pnts_list.end(); it++) + for (auto& it : pnts_list) { - delete *it; + delete it; } } @@ -123,9 +123,9 @@ TEST(GeoLibAABB, RandomNumberOfPointersToRandomPointsInAVector) ASSERT_GE(half_box_size, max_pnt[1]) << "coordinate 1 of max_pnt is greater than " << half_box_size; ASSERT_GE(half_box_size, max_pnt[2]) << "coordinate 2 of max_pnt is greater than " << half_box_size; - for (auto it(pnts.begin()); it != pnts.end(); it++) + for (auto& pnt : pnts) { - delete *it; + delete pnt; } } -- GitLab