diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index 9dd8e4c06ebfb2b728c59bae1ee3542ed22dd81f..f53fe81d669e4300d8bb26c0bc5f6afffd81c807 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -151,14 +151,14 @@ std::vector<MeshLib::Mesh*>::iterator ProjectData::findMeshByName( const MeshLib::Mesh* ProjectData::getMesh(const std::string& name) const { - std::vector<MeshLib::Mesh*>::const_iterator it = findMeshByName(name); + auto it = findMeshByName(name); return (it == _mesh_vec.end() ? nullptr : *it); } bool ProjectData::removeMesh(const std::string& name) { bool mesh_found = false; - std::vector<MeshLib::Mesh*>::iterator it = findMeshByName(name); + auto it = findMeshByName(name); while (it != _mesh_vec.end()) { delete *it; @@ -195,10 +195,8 @@ bool ProjectData::isMeshNameUniqueAndProvideUniqueName(std::string& name) const if (count > 1) cpName = cpName + "-" + std::to_string(count); - for (std::vector<MeshLib::Mesh*>::const_iterator it = _mesh_vec.begin(); - it != _mesh_vec.end(); - ++it) - if (cpName.compare((*it)->getName()) == 0) + for (auto mesh : _mesh_vec) + if (cpName.compare(mesh->getName()) == 0) isUnique = false; } diff --git a/Applications/DataExplorer/Base/CheckboxDelegate.cpp b/Applications/DataExplorer/Base/CheckboxDelegate.cpp index 4c34a87244de0ed022a4cd29eede8d9a60e7a2d7..3da3aa9a9e65e5b91268cbaa9f62bedd7f4c0dcb 100644 --- a/Applications/DataExplorer/Base/CheckboxDelegate.cpp +++ b/Applications/DataExplorer/Base/CheckboxDelegate.cpp @@ -57,7 +57,7 @@ bool CheckboxDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, if ((event->type() == QEvent::MouseButtonRelease) || (event->type() == QEvent::MouseButtonDblClick)) { - QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event); + auto* mouse_event = static_cast<QMouseEvent*>(event); if (mouse_event->button() != Qt::LeftButton || !checkboxRect(option).contains(mouse_event->pos())) return false; diff --git a/Applications/DataExplorer/Base/CheckboxDelegate.h b/Applications/DataExplorer/Base/CheckboxDelegate.h index 0e82581b7c8c870db8496d61918634edaf3cdbcc..89aedb2ec5756ac179c29f90d77a04edaae87163 100644 --- a/Applications/DataExplorer/Base/CheckboxDelegate.h +++ b/Applications/DataExplorer/Base/CheckboxDelegate.h @@ -31,17 +31,19 @@ class CheckboxDelegate : public QItemDelegate public: /// \brief Constructor - CheckboxDelegate (QObject* parent = 0); + CheckboxDelegate(QObject* parent = nullptr); /// \brief Paints a checkbox. This overrides the default painting of a combo box. void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; + const QModelIndex& index) const override; /// \brief Handles the click events and sets the model data. bool editorEvent(QEvent* event, QAbstractItemModel* model, - const QStyleOptionViewItem &option, const QModelIndex &index); + const QStyleOptionViewItem& option, + const QModelIndex& index) override; - QSize sizeHint (const QStyleOptionViewItem & option, const QModelIndex & index) const; + QSize sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const override; private: QRect checkboxRect(const QStyleOptionViewItem& viewItemStyleOptions) const; diff --git a/Applications/DataExplorer/Base/ColorPickerPushButton.cpp b/Applications/DataExplorer/Base/ColorPickerPushButton.cpp index d66c2e4142b9db692330d5b2f1acb7d3377b55c6..980e05a6fa700844bd095d2c7fa70594ab2eb303 100644 --- a/Applications/DataExplorer/Base/ColorPickerPushButton.cpp +++ b/Applications/DataExplorer/Base/ColorPickerPushButton.cpp @@ -27,7 +27,7 @@ ColorPickerPushButton::ColorPickerPushButton( QWidget* parent /*= 0*/ ) void ColorPickerPushButton::mouseReleaseEvent(QMouseEvent* e) { Q_UNUSED(e); - QColor newColor = QColorDialog::getColor(_color, NULL, "Choose a color"); + QColor newColor = QColorDialog::getColor(_color, nullptr, "Choose a color"); if (!newColor.isValid()) return; diff --git a/Applications/DataExplorer/Base/ColorPickerPushButton.h b/Applications/DataExplorer/Base/ColorPickerPushButton.h index 5596d767fc7e1888fc5aee51627799b4af9ed121..1f298bba4d0ce35b503458db8a08f9e09770d144 100644 --- a/Applications/DataExplorer/Base/ColorPickerPushButton.h +++ b/Applications/DataExplorer/Base/ColorPickerPushButton.h @@ -30,11 +30,11 @@ class ColorPickerPushButton : public QPushButton Q_OBJECT public: - ColorPickerPushButton(QWidget* parent = 0); + ColorPickerPushButton(QWidget* parent = nullptr); public slots: /// Calls the QColorDialog - void mouseReleaseEvent(QMouseEvent* e); + void mouseReleaseEvent(QMouseEvent* e) override; /// Sets the color. void setColor(QColor color); diff --git a/Applications/DataExplorer/Base/OGSError.cpp b/Applications/DataExplorer/Base/OGSError.cpp index 96d7b1471a290e68f5ec0f5b33ae80430a4c9eea..8c2321f0c75df2efebf1f3309189142325a9a8cf 100644 --- a/Applications/DataExplorer/Base/OGSError.cpp +++ b/Applications/DataExplorer/Base/OGSError.cpp @@ -16,11 +16,9 @@ #include <QMessageBox> #include <QString> -OGSError::OGSError() -{} +OGSError::OGSError() = default; -OGSError::~OGSError() -{} +OGSError::~OGSError() = default; void OGSError::box(const QString &e) { diff --git a/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.cpp b/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.cpp index 79c341135ce38670e3cdd9c803b4990a2efa18ef..05aa2ac61a8147aa6b45451847353c7ee518326f 100644 --- a/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.cpp +++ b/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.cpp @@ -36,9 +36,7 @@ QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem(const QString & text, setFlag(QGraphicsItem::ItemIgnoresTransformations, true); } -QNonScalableGraphicsTextItem::~QNonScalableGraphicsTextItem() -{ -} +QNonScalableGraphicsTextItem::~QNonScalableGraphicsTextItem() = default; /// Paints the text item. void QNonScalableGraphicsTextItem::paint(QPainter* painter, diff --git a/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.h b/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.h index ce9d3677f00f64f4aca6b5dad957ffc09ee62a94..f8014011968874cd43255e372c38b2b66004be02 100644 --- a/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.h +++ b/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.h @@ -24,10 +24,13 @@ class QNonScalableGraphicsTextItem : public QGraphicsTextItem { public: - QNonScalableGraphicsTextItem(QGraphicsItem* parent = 0); - QNonScalableGraphicsTextItem(const QString &text, QGraphicsItem* parent = 0); - ~QNonScalableGraphicsTextItem(); + QNonScalableGraphicsTextItem(QGraphicsItem* parent = nullptr); + QNonScalableGraphicsTextItem(const QString& text, + QGraphicsItem* parent = nullptr); + ~QNonScalableGraphicsTextItem() override; - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); - virtual QRectF boundingRect() const; + void paint(QPainter* painter, + const QStyleOptionGraphicsItem* option, + QWidget* widget) override; + QRectF boundingRect() const override; }; diff --git a/Applications/DataExplorer/Base/QValueTooltipSlider.h b/Applications/DataExplorer/Base/QValueTooltipSlider.h index bdd247503c41a41897b4f8aa66372bb36b685f65..5b07d677659322859b20b313db8f5e93e4423533 100644 --- a/Applications/DataExplorer/Base/QValueTooltipSlider.h +++ b/Applications/DataExplorer/Base/QValueTooltipSlider.h @@ -23,7 +23,7 @@ class QValueTooltipSlider : public QSlider Q_OBJECT public: - QValueTooltipSlider(QWidget* parent = 0); + QValueTooltipSlider(QWidget* parent = nullptr); public slots: void setTooltipValue(int value); diff --git a/Applications/DataExplorer/Base/RecentFiles.cpp b/Applications/DataExplorer/Base/RecentFiles.cpp index 625ac74198673edc3398dc9f21234a9ed91a43e5..cd42c62b60245bb826e8245a57225907decb2c65 100644 --- a/Applications/DataExplorer/Base/RecentFiles.cpp +++ b/Applications/DataExplorer/Base/RecentFiles.cpp @@ -17,17 +17,19 @@ #include <QFileInfo> #include <QSettings> +#include <utility> -RecentFiles::RecentFiles( QObject* parent, const char* slot, QString settingsName) - : QObject(parent), _settingsName(settingsName) +RecentFiles::RecentFiles(QObject* parent, const char* slot, + QString settingsName) + : QObject(parent), _settingsName(std::move(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/Base/RecentFiles.h b/Applications/DataExplorer/Base/RecentFiles.h index ec8d6b5456f490455e9fbfecfcc9cc54b816ac2e..06aeeb2dd0a50f42446135fff96f03ef15b79458 100644 --- a/Applications/DataExplorer/Base/RecentFiles.h +++ b/Applications/DataExplorer/Base/RecentFiles.h @@ -49,7 +49,7 @@ public: * \param settingsName The setting key */ RecentFiles(QObject* parent, const char* slot, QString settingsName); - ~RecentFiles(); + ~RecentFiles() override; /// Returns the created menu. Add this menu to your QMainWindow menu. QMenu* menu(); diff --git a/Applications/DataExplorer/Base/StrictDoubleValidator.h b/Applications/DataExplorer/Base/StrictDoubleValidator.h index bb3cd3b105052b0db7df80ef0d3c97db3edf6365..19273c5948a2494b03ac2ff294c261e7208a5661 100644 --- a/Applications/DataExplorer/Base/StrictDoubleValidator.h +++ b/Applications/DataExplorer/Base/StrictDoubleValidator.h @@ -30,7 +30,7 @@ public: QDoubleValidator( parent) {} - QValidator::State validate(QString & input, int &pos) const + QValidator::State validate(QString& input, int& pos) const override { if (input.isEmpty() || input == "." || input == "-") return Intermediate; diff --git a/Applications/DataExplorer/Base/StrictIntValidator.h b/Applications/DataExplorer/Base/StrictIntValidator.h index bb1ba32ab526b57fc2629c58c8065b37d2255d44..a4ee5f54e50f46a4e915f3f0b98839b830ac6cde 100644 --- a/Applications/DataExplorer/Base/StrictIntValidator.h +++ b/Applications/DataExplorer/Base/StrictIntValidator.h @@ -23,11 +23,11 @@ class StrictIntValidator : public QIntValidator { public: - StrictIntValidator ( int min, int max, QObject* parent = 0) : - QIntValidator( min, max, parent) + StrictIntValidator(int min, int max, QObject* parent = nullptr) + : QIntValidator(min, max, parent) {} - QValidator::State validate(QString & input, int &pos) const + QValidator::State validate(QString& input, int& pos) const override { if (input.isEmpty()) return Intermediate; diff --git a/Applications/DataExplorer/Base/TreeItem.cpp b/Applications/DataExplorer/Base/TreeItem.cpp index b0efd8b7e49c32d3280de8fe7de45405aec76efc..67960c2f927ee0019260421ce9efae1b97ae39d7 100644 --- a/Applications/DataExplorer/Base/TreeItem.cpp +++ b/Applications/DataExplorer/Base/TreeItem.cpp @@ -12,14 +12,16 @@ * */ +#include <utility> + #include "TreeItem.h" /** * The constructor is only used to record the item's parent * and the data associated with each column. */ -TreeItem::TreeItem(const QList<QVariant> &data, TreeItem* parent) -: _itemData(data), _parentItem(parent) +TreeItem::TreeItem(QList<QVariant> data, TreeItem* parent) + : _itemData(std::move(data)), _parentItem(parent) { } @@ -45,14 +47,14 @@ void TreeItem::appendChild(TreeItem* item) /** * Returns the child that corresponds to the specified row number * in the item's list of child items - * Returns NULL if that child does not exist. + * Returns nullptr if that child does not exist. */ TreeItem* TreeItem::child(int row) const { if (_childItems.count() > row) return _childItems.value(row); else - return NULL; + return nullptr; } /** diff --git a/Applications/DataExplorer/Base/TreeItem.h b/Applications/DataExplorer/Base/TreeItem.h index 362c1789e19ae9d61a41d6f2bdd860ed1211e691..6741e97bc1c18b03fc0c18ae2423eeeb318f950e 100644 --- a/Applications/DataExplorer/Base/TreeItem.h +++ b/Applications/DataExplorer/Base/TreeItem.h @@ -27,7 +27,7 @@ class TreeItem { public: - TreeItem(const QList<QVariant> &data, TreeItem* parent); + TreeItem(QList<QVariant> data, TreeItem* parent); virtual ~TreeItem(); void appendChild(TreeItem* child); diff --git a/Applications/DataExplorer/Base/TreeModel.cpp b/Applications/DataExplorer/Base/TreeModel.cpp index 1e41dc09147cd374bac5e64e1d5910510da58206..1017e9c21dffdda2b857c521942a43269811c68a 100644 --- a/Applications/DataExplorer/Base/TreeModel.cpp +++ b/Applications/DataExplorer/Base/TreeModel.cpp @@ -29,7 +29,7 @@ TreeModel::TreeModel( QObject* parent ) //_modelType = TREE_MODEL; QList<QVariant> rootData; rootData << "1" << "2" << "3"; - _rootItem = new TreeItem(rootData, NULL); + _rootItem = new TreeItem(rootData, nullptr); //setupModelData(data, _rootItem); } @@ -75,7 +75,7 @@ QModelIndex TreeModel::parent(const QModelIndex &index) const if (!index.isValid()) return QModelIndex(); - TreeItem* childItem = static_cast<TreeItem*>(index.internalPointer()); + auto* childItem = static_cast<TreeItem*>(index.internalPointer()); TreeItem* parentItem = childItem->parentItem(); if (parentItem == _rootItem) @@ -127,7 +127,7 @@ QVariant TreeModel::data(const QModelIndex &index, int role) const if (role == Qt::EditRole || role == Qt::DisplayRole) { - TreeItem* item = static_cast<TreeItem*>(index.internalPointer()); + auto* item = static_cast<TreeItem*>(index.internalPointer()); return item->data(index.column()); } @@ -142,7 +142,7 @@ bool TreeModel::setData( const QModelIndex &index, const QVariant &value, int ro if (role == Qt::EditRole) { - TreeItem* item = static_cast<TreeItem*>(index.internalPointer()); + auto* item = static_cast<TreeItem*>(index.internalPointer()); item->setData(index.column(), value); return true; } @@ -151,7 +151,7 @@ bool TreeModel::setData( const QModelIndex &index, const QVariant &value, int ro Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return nullptr; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } @@ -163,7 +163,7 @@ TreeItem* TreeModel::getItem(const QModelIndex &index) const { if (index.isValid()) { - TreeItem* item = static_cast<TreeItem*>(index.internalPointer()); + auto* item = static_cast<TreeItem*>(index.internalPointer()); if (item) return item; } diff --git a/Applications/DataExplorer/Base/TreeModel.h b/Applications/DataExplorer/Base/TreeModel.h index 1323babbc78683af82df7df83c8c013d45373b48..b0bc52b9fdb1f6c55940f9b093c5d4a4d17620de 100644 --- a/Applications/DataExplorer/Base/TreeModel.h +++ b/Applications/DataExplorer/Base/TreeModel.h @@ -31,20 +31,22 @@ class TreeModel : public QAbstractItemModel Q_OBJECT public: - TreeModel(QObject* parent = 0); - virtual ~TreeModel(); + TreeModel(QObject* parent = nullptr); + ~TreeModel() override; - QVariant data(const QModelIndex &index, int role) const; - bool setData(const QModelIndex &index, const QVariant &value, int role /* = Qt::EditRole */); - Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant data(const QModelIndex& index, int role) const override; + bool setData(const QModelIndex& index, const QVariant& value, + int role /* = Qt::EditRole */) override; + Qt::ItemFlags flags(const QModelIndex& index) const override; TreeItem* getItem(const QModelIndex &index) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = - Qt::DisplayRole) const; - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; - bool removeRows(int row, int count, const QModelIndex & parent); - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; + QModelIndex index(int row, int column, + const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex& index) const override; + bool removeRows(int row, int count, const QModelIndex& parent) override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; TreeItem* rootItem() const; diff --git a/Applications/DataExplorer/Base/TreeModelIterator.cpp b/Applications/DataExplorer/Base/TreeModelIterator.cpp index 050c85ae05825c586a9d020ccd7cd7b7d7591156..1335f54acd4a9801451572088d39a00f14c84074 100644 --- a/Applications/DataExplorer/Base/TreeModelIterator.cpp +++ b/Applications/DataExplorer/Base/TreeModelIterator.cpp @@ -18,8 +18,8 @@ #include "TreeItem.h" #include "TreeModel.h" -TreeModelIterator::TreeModelIterator( TreeModel* model ) - : _current(NULL), _model(model) +TreeModelIterator::TreeModelIterator(TreeModel* model) + : _current(nullptr), _model(model) { if (_model->rootItem()->childCount() > 0) { @@ -46,9 +46,9 @@ TreeModelIterator& TreeModelIterator::operator++() TreeItem* TreeModelIterator::next( const TreeItem* current ) { if (!current) - return NULL; + return nullptr; - TreeItem* next = NULL; + TreeItem* next = nullptr; if (current->childCount()) { // walk the child diff --git a/Applications/DataExplorer/Base/TreeModelIterator.h b/Applications/DataExplorer/Base/TreeModelIterator.h index 7ed76018637051807535dc3e9423922494a5ff2a..c040a811fc9a9f1d0349ef9e2aa265375336914f 100644 --- a/Applications/DataExplorer/Base/TreeModelIterator.h +++ b/Applications/DataExplorer/Base/TreeModelIterator.h @@ -38,7 +38,7 @@ public: TreeModelIterator(TreeModel* model); /// \brief Dereferencing the iterator to retrieve the current TreeItem. - /// Returns NULL if the iterator is at the end. + /// Returns nullptr if the iterator is at the end. TreeItem* operator* () const; /// \brief Advance the iterator to the next TreeItem. diff --git a/Applications/DataExplorer/DataView/AddLayerToMeshDialog.cpp b/Applications/DataExplorer/DataView/AddLayerToMeshDialog.cpp index 7b67fcf2e2bd9c960143175a5c2c22a098f10679..16d6ec7af1343cf7ce1ceb3e408d619408bc320f 100644 --- a/Applications/DataExplorer/DataView/AddLayerToMeshDialog.cpp +++ b/Applications/DataExplorer/DataView/AddLayerToMeshDialog.cpp @@ -22,7 +22,7 @@ AddLayerToMeshDialog::AddLayerToMeshDialog(QDialog* parent) { setupUi(this); - StrictDoubleValidator* thickness_validator = new StrictDoubleValidator(0, 1000000, 7, this); + auto* thickness_validator = new StrictDoubleValidator(0, 1000000, 7, this); this->thicknessEdit->setValidator (thickness_validator); } diff --git a/Applications/DataExplorer/DataView/AddLayerToMeshDialog.h b/Applications/DataExplorer/DataView/AddLayerToMeshDialog.h index 1563895a2112e24dfd816c3789bae705b0dc9b28..08a3c6504dc77dcc7980f83bf47ab5cd72d1fcd8 100644 --- a/Applications/DataExplorer/DataView/AddLayerToMeshDialog.h +++ b/Applications/DataExplorer/DataView/AddLayerToMeshDialog.h @@ -40,8 +40,8 @@ public: private slots: /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; }; diff --git a/Applications/DataExplorer/DataView/BaseItem.h b/Applications/DataExplorer/DataView/BaseItem.h index b5f897282b8d7fbe045cb63a34655f1e4bb6f041..c2e1a34401d2c98ac2a6b1801dc4eb3a1de0ca73 100644 --- a/Applications/DataExplorer/DataView/BaseItem.h +++ b/Applications/DataExplorer/DataView/BaseItem.h @@ -28,7 +28,8 @@ class BaseItem { public: - BaseItem(const QString &listName, const std::vector<GeoLib::Point*>* stations = NULL ) + BaseItem(const QString& listName, + const std::vector<GeoLib::Point*>* stations = nullptr) : _stations(stations), _vtkSource(VtkStationSource::New()) { // create the vtk-object for 3d-visualisation of this list diff --git a/Applications/DataExplorer/DataView/ColorTableModel.cpp b/Applications/DataExplorer/DataView/ColorTableModel.cpp index da9bf39b7f9175333a093d091f9573e97c6d4404..b8ff1fc4ee6f30c18e095c4cb031f8d0cfacc8e6 100644 --- a/Applications/DataExplorer/DataView/ColorTableModel.cpp +++ b/Applications/DataExplorer/DataView/ColorTableModel.cpp @@ -22,9 +22,7 @@ ColorTableModel::ColorTableModel( const std::map<std::string, DataHolderLib::Col this->buildTable(colorLookupTable); } -ColorTableModel::~ColorTableModel() -{ -} +ColorTableModel::~ColorTableModel() = default; int ColorTableModel::columnCount( const QModelIndex& parent /*= QModelIndex()*/ ) const { @@ -82,11 +80,10 @@ bool ColorTableModel::buildTable(const std::map<std::string, DataHolderLib::Colo int count = 0; beginInsertRows(QModelIndex(), 0, colorLookupTable.size() - 1); - for (std::map<std::string, DataHolderLib::Color*>::const_iterator it = colorLookupTable.begin(); - it != colorLookupTable.end(); ++it) + for (const auto& row : colorLookupTable) { - QColor color((*(it->second))[0], (*(it->second))[1], (*(it->second))[2]); - QString name(QString::fromStdString(it->first)); + QColor color((*row.second)[0], (*row.second)[1], (*row.second)[2]); + QString name(QString::fromStdString(row.first)); /* Saudi Arabia strat names * if (it->first.compare("1")==0) name="Buweib"; diff --git a/Applications/DataExplorer/DataView/ColorTableModel.h b/Applications/DataExplorer/DataView/ColorTableModel.h index 97a94ac11d076924e1e0c9fb6aa9fbcc403c206b..cb44582e7e95dba4a8b7267c1979da7906744b6a 100644 --- a/Applications/DataExplorer/DataView/ColorTableModel.h +++ b/Applications/DataExplorer/DataView/ColorTableModel.h @@ -27,22 +27,23 @@ class ColorTableModel : public QAbstractTableModel Q_OBJECT public: - ColorTableModel( const std::map<std::string, DataHolderLib::Color*> &colorLookupTable, - QObject* parent = 0 ); - ~ColorTableModel(); + ColorTableModel( + const std::map<std::string, DataHolderLib::Color*>& colorLookupTable, + QObject* parent = nullptr); + ~ColorTableModel() override; - int columnCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data( const QModelIndex& index, int role ) const; + QVariant data(const QModelIndex& index, int role) const override; - int rowCount(const QModelIndex& parent = QModelIndex()) const + int rowCount(const QModelIndex& parent = QModelIndex()) const override { Q_UNUSED (parent); return _listOfPairs.size(); } - QVariant headerData( int section, Qt::Orientation orientation, - int role /*= Qt::DisplayRole*/ ) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role /*= Qt::DisplayRole*/) const override; private: bool buildTable( const std::map<std::string, DataHolderLib::Color*> &colorLookupTable ); diff --git a/Applications/DataExplorer/DataView/ColorTableView.h b/Applications/DataExplorer/DataView/ColorTableView.h index 3892db6945cc61cd8ae52c8185a7d521a2457a24..0d51773824d5dbe598d53c4d9a5ec3f45a78fd0b 100644 --- a/Applications/DataExplorer/DataView/ColorTableView.h +++ b/Applications/DataExplorer/DataView/ColorTableView.h @@ -25,7 +25,7 @@ class ColorTableView : public QTableView public: /// Constructor - ColorTableView(QWidget* parent = 0); + ColorTableView(QWidget* parent = nullptr); }; /** @@ -37,11 +37,11 @@ class ColorTableViewDelegate : public QItemDelegate public: /// Constructor - ColorTableViewDelegate(QWidget* parent = 0) : QItemDelegate(parent) {} - + ColorTableViewDelegate(QWidget* parent = nullptr) : QItemDelegate(parent) {} /// Overwrites the paint-method to set user-defined properties instead of the default properties. - void paint(QPainter* painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + void paint(QPainter* painter, const QStyleOptionViewItem& option, + const QModelIndex& index) const override; - QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const; + QSize sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const override; }; diff --git a/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp b/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp index 66679ef301e47dbcad589237562cad56c4831f61..9656c54c7d834d89b732dce99cb3cbde97f19747 100644 --- a/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp +++ b/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp @@ -17,13 +17,15 @@ #include <QFileDialog> #include <QSettings> +#include <utility> #include "DirectConditionGenerator.h" #include "OGSError.h" #include "StrictDoubleValidator.h" -CondFromRasterDialog::CondFromRasterDialog(const std::vector<MeshLib::Mesh*> &msh_vec, QDialog* parent) - : QDialog(parent), _msh_vec(msh_vec) +CondFromRasterDialog::CondFromRasterDialog(std::vector<MeshLib::Mesh*> msh_vec, + QDialog* parent) + : QDialog(parent), _msh_vec(std::move(msh_vec)) { setupUi(this); @@ -32,8 +34,8 @@ CondFromRasterDialog::CondFromRasterDialog(const std::vector<MeshLib::Mesh*> &ms this->scalingEdit->setText("1.0"); this->scalingEdit->setValidator (_scale_validator); - for (std::vector<MeshLib::Mesh*>::const_iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it) - this->meshBox->addItem(QString::fromStdString((*it)->getName())); + for (auto mesh : _msh_vec) + this->meshBox->addItem(QString::fromStdString(mesh->getName())); this->directButton->setChecked(true); } @@ -83,11 +85,11 @@ void CondFromRasterDialog::accept() return; } - MeshLib::Mesh* mesh (NULL); - for (std::size_t i=0; i<_msh_vec.size(); i++) - if (_msh_vec[i]->getName().compare(mesh_name) == 0) + MeshLib::Mesh* mesh(nullptr); + for (auto mesh_ : _msh_vec) + if (mesh_->getName().compare(mesh_name) == 0) { - mesh = _msh_vec[i]; + mesh = mesh_; break; } @@ -105,7 +107,7 @@ void CondFromRasterDialog::accept() OGSError::box("No valid scaling factor given."); return; } - MeshLib::Mesh* new_mesh = const_cast<MeshLib::Mesh*>(mesh); + auto* new_mesh = const_cast<MeshLib::Mesh*>(mesh); DirectConditionGenerator dcg; direct_values = dcg.directWithSurfaceIntegration(*new_mesh, raster_name, scaling_factor); diff --git a/Applications/DataExplorer/DataView/CondFromRasterDialog.h b/Applications/DataExplorer/DataView/CondFromRasterDialog.h index 4be6b081793635256a7ccf178e0669abf9d6ae0f..d3a291ff4d61ba94857f749717a22a82615b4ce0 100644 --- a/Applications/DataExplorer/DataView/CondFromRasterDialog.h +++ b/Applications/DataExplorer/DataView/CondFromRasterDialog.h @@ -31,8 +31,9 @@ class CondFromRasterDialog : public QDialog, private Ui_CondFromRaster Q_OBJECT public: - CondFromRasterDialog(const std::vector<MeshLib::Mesh*> &msh_vec, QDialog* parent = 0); - ~CondFromRasterDialog(void); + CondFromRasterDialog(std::vector<MeshLib::Mesh*> msh_vec, + QDialog* parent = nullptr); + ~CondFromRasterDialog(void) override; private: const std::vector<MeshLib::Mesh*> _msh_vec; @@ -43,10 +44,10 @@ private slots: void on_selectButton_pressed(); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; signals: void directNodesWritten(std::string); diff --git a/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp b/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp index d47b7cf4cb7e2e647b72c6f053727c2b8f48f142..8315f36de4414163ac955f573efa4f8e3a98e85c 100644 --- a/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp +++ b/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp @@ -31,25 +31,25 @@ CreateStructuredGridDialog::CreateStructuredGridDialog(QDialog* parent) : QDialo void CreateStructuredGridDialog::setValidators() { - StrictDoubleValidator* origin_x_validator = new StrictDoubleValidator(this); + auto* origin_x_validator = new StrictDoubleValidator(this); this->xOriginEdit->setValidator (origin_x_validator); - StrictDoubleValidator* origin_y_validator = new StrictDoubleValidator(this); + auto* origin_y_validator = new StrictDoubleValidator(this); this->yOriginEdit->setValidator (origin_y_validator); - StrictDoubleValidator* origin_z_validator = new StrictDoubleValidator(this); + auto* origin_z_validator = new StrictDoubleValidator(this); this->zOriginEdit->setValidator (origin_z_validator); - StrictDoubleValidator* x_length_validator = new StrictDoubleValidator(0, 10000000, 10, this); + auto* x_length_validator = new StrictDoubleValidator(0, 10000000, 10, this); this->xLengthEdit->setValidator (x_length_validator); - StrictDoubleValidator* y_length_validator = new StrictDoubleValidator(0, 10000000, 10, this); + auto* y_length_validator = new StrictDoubleValidator(0, 10000000, 10, this); this->yLengthEdit->setValidator (y_length_validator); - StrictDoubleValidator* z_length_validator = new StrictDoubleValidator(0, 10000000, 10, this); + auto* z_length_validator = new StrictDoubleValidator(0, 10000000, 10, this); this->zLengthEdit->setValidator (z_length_validator); - QIntValidator* x_n_elem_validator = new QIntValidator(1, 10000000, this); + auto* x_n_elem_validator = new QIntValidator(1, 10000000, this); this->xElemEdit->setValidator (x_n_elem_validator); - QIntValidator* y_n_elem_validator = new QIntValidator(1, 10000000, this); + auto* y_n_elem_validator = new QIntValidator(1, 10000000, this); this->yElemEdit->setValidator (y_n_elem_validator); - QIntValidator* z_n_elem_validator = new QIntValidator(1, 10000000, this); + auto* z_n_elem_validator = new QIntValidator(1, 10000000, this); this->zElemEdit->setValidator (z_n_elem_validator); } diff --git a/Applications/DataExplorer/DataView/CreateStructuredGridDialog.h b/Applications/DataExplorer/DataView/CreateStructuredGridDialog.h index 29b9ae6cfd82635dcd1376a5d37ad20c800db55b..e150c5590c1bea0f0afdecf52a2c8ea14e070cf7 100644 --- a/Applications/DataExplorer/DataView/CreateStructuredGridDialog.h +++ b/Applications/DataExplorer/DataView/CreateStructuredGridDialog.h @@ -27,7 +27,7 @@ class CreateStructuredGridDialog : public QDialog, private Ui_CreateStructuredGr Q_OBJECT public: - CreateStructuredGridDialog(QDialog* parent = 0); + CreateStructuredGridDialog(QDialog* parent = nullptr); private slots: void on_lineButton_toggled() const; @@ -39,10 +39,10 @@ private slots: void on_elemExtentButton_toggled(); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject() { this->done(QDialog::Rejected); }; + void reject() override { this->done(QDialog::Rejected); }; private: void enable2dWidgets() const; diff --git a/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.cpp b/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.cpp index c7109edcd9609eb6f3f17332316ebfeb36a8bff5..623b4b52d94ad0ab53e4c7257803d86d8e4c55c1 100644 --- a/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.cpp +++ b/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.cpp @@ -30,9 +30,7 @@ DataExplorerSettingsDialog::DataExplorerSettingsDialog(QDialog* parent) : QDialo this->gmshPathEdit->setText(settings.value("DataExplorerGmshPath").toString()); } -DataExplorerSettingsDialog::~DataExplorerSettingsDialog() -{ -} +DataExplorerSettingsDialog::~DataExplorerSettingsDialog() = default; void DataExplorerSettingsDialog::on_gmshPathButton_clicked() { diff --git a/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.h b/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.h index ed40b7a5dc904f1d65693ec9239a6ee86294a327..3259d38b4ddb994494e8c13d24588d1e8ef26f2f 100644 --- a/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.h +++ b/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.h @@ -25,17 +25,15 @@ class DataExplorerSettingsDialog : public QDialog, private Ui_DataExplorerSettin Q_OBJECT public: - DataExplorerSettingsDialog(QDialog* parent = 0); - ~DataExplorerSettingsDialog(void); - + DataExplorerSettingsDialog(QDialog* parent = nullptr); + ~DataExplorerSettingsDialog(void) override; private slots: void on_gmshPathButton_clicked(); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject() { this->done(QDialog::Rejected); }; - + void reject() override { this->done(QDialog::Rejected); }; }; diff --git a/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp b/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp index 0dbe53f5193e27927b065393e7226042174293b7..6f5cb6e5b16e1ebb39687e317a15f359c78e59ae 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(); } @@ -95,9 +95,10 @@ DetailWindow::DetailWindow(std::vector<std::size_t> data, QWidget* parent) : QWi std::vector< std::pair<float, float> > list_data(nEntries); for (std::size_t i=0; i<nEntries; i++) - list_data.push_back(std::pair<float, float>(static_cast<float>(i), static_cast<float>(data[i]))); + list_data.emplace_back(static_cast<float>(i), + static_cast<float>(data[i])); - DiagramList* list = new DiagramList(); + auto* list = new DiagramList(); list->setList(list_data); list->setXUnit("Value"); list->setYUnit("Amount"); @@ -107,9 +108,7 @@ DetailWindow::DetailWindow(std::vector<std::size_t> data, QWidget* parent) : QWi resizeWindow(); } -DetailWindow::~DetailWindow() -{ -} +DetailWindow::~DetailWindow() = default; void DetailWindow::on_closeButton_clicked() { @@ -147,7 +146,7 @@ void DetailWindow::on_addDataButton_clicked() { QDir dir = QDir(fileName); settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); - DiagramPrefsDialog* prefs = new DiagramPrefsDialog(fileName, this); + auto* prefs = new DiagramPrefsDialog(fileName, this); prefs->setAttribute(Qt::WA_DeleteOnClose); prefs->show(); } diff --git a/Applications/DataExplorer/DataView/DiagramView/DetailWindow.h b/Applications/DataExplorer/DataView/DiagramView/DetailWindow.h index 48f1c55414b83b22b71de4b90f31a853677bd4e6..230c6370d02751b9f7dd300328fccfbfa66a65c3 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DetailWindow.h +++ b/Applications/DataExplorer/DataView/DiagramView/DetailWindow.h @@ -27,24 +27,24 @@ class DetailWindow : public QWidget, private Ui_DetailWindow public: /// Creates an empty diagram window. - DetailWindow(QWidget* parent = 0); + DetailWindow(QWidget* parent = nullptr); /** * Creates a window containing a diagram. * \param filename ASCII file containing x and y values for the graph to be displayed. * \param parent The parent QWidget. */ - DetailWindow(QString filename, QWidget* parent = 0); + DetailWindow(QString filename, QWidget* parent = nullptr); /** * Creates a window containing a diagram * \param list A QDiagramList containing all the data points and necessary metainformation for a graph to be displayed * \param parent The parent QWidget. */ - DetailWindow(DiagramList* list, QWidget* parent = 0); + DetailWindow(DiagramList* list, QWidget* parent = nullptr); - DetailWindow(std::vector<std::size_t> data, QWidget* parent = 0); + DetailWindow(std::vector<std::size_t> data, QWidget* parent = nullptr); - ~DetailWindow(void); + ~DetailWindow(void) override; /** * Adds another plot to window. Axes are automatically resized, a random color is used. diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp index c6621a8504ebab92489e4dad524ef16da3794238..7372ffc74ad8fc551368898035861f312dadb4ee 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp @@ -28,9 +28,7 @@ DiagramList::DiagramList() : _maxX(0), _maxY(0), _minX(0), _minY(0), _xLabel("") { } -DiagramList::~DiagramList() -{ -} +DiagramList::~DiagramList() = default; float DiagramList::calcMinXValue() { @@ -164,7 +162,7 @@ int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists) fields.takeFirst(); for (int i = 0; i < nLists; i++) { - DiagramList* l = new DiagramList; + auto* l = new DiagramList; l->setName(fields.takeFirst()); //value = strtod(BaseLib::replaceStringreplaceString(",", ".", fields.takeFirst().toStdString()).c_str(),0); //l->setStartDate(startDate); @@ -200,7 +198,11 @@ int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists) for (int i = 0; i < nLists; i++) { - value = strtod(BaseLib::replaceString(",", ".",fields.takeFirst().toStdString()).c_str(),0); + value = + strtod(BaseLib::replaceString( + ",", ".", fields.takeFirst().toStdString()) + .c_str(), + nullptr); lists[i]->addNextPoint(numberOfSecs,value); } } @@ -254,7 +256,7 @@ int DiagramList::readList(const SensorData* data, std::vector<DiagramList*> &lis for (int i = 0; i < nLists; i++) { - DiagramList* l = new DiagramList; + auto* l = new DiagramList; l->setName(QString::fromStdString(SensorData::convertSensorDataType2String(time_series_names[i]))); l->setXLabel("Time"); lists.push_back(l); @@ -291,13 +293,14 @@ void DiagramList::setList(std::vector< std::pair<QDateTime, float> > coords) int numberOfDays; this->_startDate = coords[0].first; - _coords.push_back(std::pair<float, float>(0.0f, coords[0].second)); + _coords.emplace_back(0.0f, coords[0].second); std::size_t nCoords = coords.size(); for (std::size_t i = 1; i < nCoords; i++) { numberOfDays = this->_startDate.daysTo(coords[i].first); - _coords.push_back(std::pair<float, float>(static_cast<float>(numberOfDays), coords[i].second)); + _coords.emplace_back(static_cast<float>(numberOfDays), + coords[i].second); } update(); diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramList.h b/Applications/DataExplorer/DataView/DiagramView/DiagramList.h index 1471bb6e66e57a4238114fce9882aba32f85fee6..319b9b199fbbafe5bd919ad47826e4df1fa26bbc 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramList.h +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramList.h @@ -106,8 +106,7 @@ public: void setName(QString name) { _name = name; } /// Adds a point at (x,y) to the list - void addNextPoint(float x, float y) { _coords.push_back(std::pair<float, float>(x, y)); } - + void addNextPoint(float x, float y) { _coords.emplace_back(x, y); } /// Sets the start date (i.e. the min-value of the x-axis). void setStartDate(QDateTime date) { _startDate = date; } diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp index d59280d6f2b46236df7ebb854dda7b923652f81a..1b7b3f6d7b71ec5b80482848c155cc31a06a4030 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp @@ -74,7 +74,7 @@ void DiagramPrefsDialog::accept() if (_list[0]->size() > 0) { bool window_is_empty(false); - if (_window == NULL) + if (_window == nullptr) { _window = new DetailWindow(); _window->setAttribute(Qt::WA_DeleteOnClose); @@ -96,7 +96,7 @@ void DiagramPrefsDialog::accept() else { delete _window; - _window = NULL; + _window = nullptr; OGSError::box("No dataset selected."); } } @@ -129,14 +129,15 @@ int DiagramPrefsDialog::loadFile(const QString &filename) { if (DiagramList::readList(filename, _list)) { - for (std::size_t i = 0; i < _list.size(); i++) + for (auto& item : _list) { - //_list[i]->setName(stationTypeLabel->text() + ": " + stationNameLabel->text()); - _list[i]->setXLabel("Time"); - //_list[i]->setYLabel("Water Level"); - _list[i]->setXUnit("day"); - //_list[i]->setYUnit("metres"); - _list[i]->setColor(QColor(Qt::red)); + // item->setName(stationTypeLabel->text() + ": " + + // stationNameLabel->text()); + item->setXLabel("Time"); + // item->setYLabel("Water Level"); + item->setXUnit("day"); + // item->setYUnit("metres"); + item->setColor(QColor(Qt::red)); } fromDateLine->setText(_list[0]->getStartDate().toString("dd.MM.yyyy")); //QString::number(_list[0]->minXValue())); QDateTime endDate = @@ -154,7 +155,7 @@ int DiagramPrefsDialog::loadList(const std::vector< std::pair<QDateTime, float> { if (!coords.empty()) { - DiagramList* l = new DiagramList; + auto* l = new DiagramList; l->setName(stationTypeLabel->text() + ": " + stationNameLabel->text()); l->setXLabel("Time"); //l->setYLabel("Water Level"); @@ -170,9 +171,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& item : _list) { - QCheckBox* box = new QCheckBox(_list[i]->getName()); + QCheckBox* box = new QCheckBox(item->getName()); box->setChecked(true); this->CheckBoxLayout->addWidget(box); _visability.push_back(box); diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.h b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.h index 696e81b577c9d45437cdc670925bff507b75afbc..b2570c79e1370dee40143ec0fb99f2b1adb67508 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.h +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.h @@ -49,16 +49,16 @@ public: * \param parent The parent QDialog. */ DiagramPrefsDialog(const GeoLib::Station* stn, - const QString &listName, - //DatabaseConnection* db, - QDialog* parent = 0); + const QString& listName, + // DatabaseConnection* db, + QDialog* parent = nullptr); /** * Opens a new dialog and automatically reads data from the associated station object. * \param stn The station object associated the diagram. * \param parent The parent QDialog. */ - DiagramPrefsDialog(GeoLib::Station* stn, QDialog* parent = 0); + DiagramPrefsDialog(GeoLib::Station* stn, QDialog* parent = nullptr); /** * Opens a new dialog and automatically reads data from the specified file. The diagram is not associated @@ -67,11 +67,11 @@ public: * \param[out] window Returns the created DetailWindow. * \param parent The parent QDialog. */ - DiagramPrefsDialog(const QString &filename, - DetailWindow* window = NULL, - QDialog* parent = 0); + DiagramPrefsDialog(const QString& filename, + DetailWindow* window = nullptr, + QDialog* parent = nullptr); - ~DiagramPrefsDialog(void); + ~DiagramPrefsDialog(void) override; private: /** @@ -104,10 +104,10 @@ private: private slots: /// Instructions if the OK-Button has been pressed. /// Note: Clicking the "Load from file"-button overrides the database input! - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; /// Instructions if the "Load File"-Button has been pressed. void on_loadFileButton_clicked(); diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp index 57f6e8fc21302e35ca2f6b16638fbe87903efbd6..30830295d15e1ac92df3e1429cc8a45106238315 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp @@ -50,27 +50,27 @@ 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& text : _xTicksText) + delete text; _xTicksText.clear(); - for (int i = 0; i < _yTicksText.size(); i++) - delete _yTicksText[i]; + for (auto& text : _yTicksText) + delete text; _yTicksText.clear(); - for (int i = 0; i < _lists.size(); i++) - delete _lists[i]; + for (auto& list : _lists) + delete list; _lists.clear(); } /// Adds an arrow object to the diagram which might be used as a coordinate axis, etc. QArrow* DiagramScene::addArrow(float length, float angle, QPen &pen) { - QArrow* arrow = new QArrow(length, angle, 8, 5, pen); + auto* arrow = new QArrow(length, angle, 8, 5, pen); addItem(arrow); return arrow; } @@ -78,7 +78,7 @@ QArrow* DiagramScene::addArrow(float length, float angle, QPen &pen) /// Adds a caption for a graph beneath the actual diagram. void DiagramScene::addCaption(const QString &name, QPen &pen) { - QGraphicsItemGroup* caption = new QGraphicsItemGroup(NULL); + auto* caption = new QGraphicsItemGroup(nullptr); QGraphicsLineItem* l = addLine(0,0,100,0,pen); QGraphicsTextItem* t = addText(name); l->setPos(0,0); @@ -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(); } @@ -123,7 +123,7 @@ QGraphicsGrid* DiagramScene::addGrid(const QRectF &rect, int xTicks, int yTicks, QNonScalableGraphicsTextItem* DiagramScene::addNonScalableText(const QString &text, const QFont &font) { - QNonScalableGraphicsTextItem* item = new QNonScalableGraphicsTextItem(text); + auto* item = new QNonScalableGraphicsTextItem(text); item->setFont(font); addItem(item); return item; @@ -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& text : _xTicksText) + removeItem(text); + for (auto& text : _yTicksText) + removeItem(text); + for (auto& graph : _graphs) + removeItem(graph); + for (auto& graphCaption : _graphCaptions) + removeItem(graphCaption); _xTicksText.clear(); _yTicksText.clear(); @@ -206,8 +206,9 @@ void DiagramScene::constructGrid() { for (int i = 0; i <= numXTicks; ++i) { - int x = static_cast<int>(_bounds.left() / _scaleX + - (i * (_bounds.width() / _scaleX) / numXTicks)); + auto x = + static_cast<int>(_bounds.left() / _scaleX + + (i * (_bounds.width() / _scaleX) / numXTicks)); _xTicksText.push_back(addNonScalableText(QString::number(x))); _xTicksText.last()->setPos(x * _scaleX, _bounds.bottom() + 15); } @@ -216,10 +217,12 @@ void DiagramScene::constructGrid() { for (int i = 0; i <= numXTicks; ++i) { - int x = static_cast<int>(_bounds.left() / _scaleX + - (i * (_bounds.width() / _scaleX) / numXTicks)); + auto x = + static_cast<int>(_bounds.left() / _scaleX + + (i * (_bounds.width() / _scaleX) / numXTicks)); QDateTime currentDate = _startDate.addSecs(x); - _xTicksText.push_back(addNonScalableText(currentDate.toString("dd.MM.yyyy"))); + _xTicksText.push_back( + addNonScalableText(currentDate.toString("dd.MM.yyyy"))); _xTicksText.last()->setPos(x * _scaleX, _bounds.bottom() + 15); } } @@ -346,8 +349,8 @@ void DiagramScene::update() for (int i = 0; i < _graphs.size(); i++) { rect = _graphs[i]->boundingRect(); - int offset = static_cast<int>(fabs(rect.bottom() - _bounds.bottom()) - - fabs(rect.top() - _bounds.top())); + auto offset = static_cast<int>(fabs(rect.bottom() - _bounds.bottom()) - + fabs(rect.top() - _bounds.top())); _graphs[i]->setPos(0, offset); rect = itemsBoundingRect(); diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramScene.h b/Applications/DataExplorer/DataView/DiagramView/DiagramScene.h index 511ed66e63fb6dc10930eac953e96f743730b98c..ef7f40cc4314d85462f96261528a2f3c30755a25 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramScene.h +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramScene.h @@ -28,9 +28,9 @@ class QDateTime; class DiagramScene : public QGraphicsScene { public: - DiagramScene(QObject* parent = 0); - DiagramScene(DiagramList* list, QObject* parent = 0); - ~DiagramScene(); + DiagramScene(QObject* parent = nullptr); + DiagramScene(DiagramList* list, QObject* parent = nullptr); + ~DiagramScene() override; QArrow* addArrow(float length, float angle, QPen &pen); void addGraph(DiagramList* list); diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramView.h b/Applications/DataExplorer/DataView/DiagramView/DiagramView.h index 927eaa98daac3b3d9e497ff43a7fb8cfc94ae197..d43065b4122dad35a9359d74eba7571dee34b206 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramView.h +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramView.h @@ -31,14 +31,14 @@ public: /** * Creates an empty view. */ - DiagramView(QWidget* parent = 0); + DiagramView(QWidget* parent = nullptr); /** * Creates a view already containing a graph * \param list Contains a list of data points and metainformation to be displayed by the scene. * \param parent The parent QWidget. */ - DiagramView(DiagramList* list, QWidget* parent = 0); - ~DiagramView(); + DiagramView(DiagramList* list, QWidget* parent = nullptr); + ~DiagramView() override; /// Adds a new graph to the scene. void addGraph(DiagramList* list); @@ -49,13 +49,13 @@ public: protected: /// Resizes the scene. - void resizeEvent(QResizeEvent* event); + void resizeEvent(QResizeEvent* event) override; private: void initialize(); void keepItemAspectRatio(); - QSize minimumSizeHint() const; - QSize sizeHint() const; + QSize minimumSizeHint() const override; + QSize sizeHint() const override; void update(); DiagramScene* _scene; diff --git a/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp b/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp index 422b89cd51148f51faaf7c33fbcf154d94a3b160..0d5b46d668f4f299ff5b85f26bd978f75376fcad 100644 --- a/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp @@ -51,9 +51,7 @@ QArrow::QArrow(float l, float a, QPen &pen, QGraphicsItem* parent) : QGraphicsIt _arrowPen = pen; } -QArrow::~QArrow() -{ -} +QArrow::~QArrow() = default; double QArrow::calcCos(double angle) { @@ -101,10 +99,10 @@ void QArrow::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QW double theta2 = (ddeltaX < 0.0) ? (theta + PI) : theta; int lengthdeltaX = -static_cast<int>(cos(theta2) * _headLength); int lengthdeltaY = -static_cast<int>(sin(theta2) * _headLength); - int widthdeltaX = static_cast<int>(sin(theta2) * _headWidth); - int widthdeltaY = static_cast<int>(cos(theta2) * _headWidth); - int deltaX = static_cast<int>(ddeltaX); - int deltaY = static_cast<int>(ddeltaY); + auto widthdeltaX = static_cast<int>(sin(theta2) * _headWidth); + auto widthdeltaY = static_cast<int>(cos(theta2) * _headWidth); + auto deltaX = static_cast<int>(ddeltaX); + auto deltaY = static_cast<int>(ddeltaY); painter->setPen(_arrowPen); painter->drawLine(0, 0, deltaX, deltaY); painter->drawLine(deltaX, diff --git a/Applications/DataExplorer/DataView/DiagramView/QArrow.h b/Applications/DataExplorer/DataView/DiagramView/QArrow.h index 8df5ac7f365cf5ec171fde7a7f113e769029658c..1db5b959a5cce42b3200294e401309961290d206 100644 --- a/Applications/DataExplorer/DataView/DiagramView/QArrow.h +++ b/Applications/DataExplorer/DataView/DiagramView/QArrow.h @@ -25,14 +25,16 @@ const double PI = 3.14159265; class QArrow : public QGraphicsItem { public: - QArrow(float l, float a, float hl, float hw, QPen &pen, QGraphicsItem* parent = 0); - QArrow(float l, float a, QPen &pen, QGraphicsItem* parent = 0); - ~QArrow(); + QArrow(float l, float a, float hl, float hw, QPen& pen, + QGraphicsItem* parent = nullptr); + QArrow(float l, float a, QPen& pen, QGraphicsItem* parent = nullptr); + ~QArrow() override; double getLength(); double getAngle(); - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); - QRectF boundingRect() const; + void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, + QWidget* widget) override; + QRectF boundingRect() const override; void setAngle(double a); void setLength(double l); diff --git a/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.cpp b/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.cpp index 1d4aa4b8f699b35e5d4c3be6299561a27a1447a5..67678f9563234d12897d896f47bbd0017a4f8eca 100644 --- a/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.cpp @@ -129,9 +129,7 @@ QGraphicsGrid::QGraphicsGrid(int x, _inside.setCosmetic(true); } -QGraphicsGrid::~QGraphicsGrid() -{ -} +QGraphicsGrid::~QGraphicsGrid() = default; /// Returns the bounding rectangle of the grid. QRectF QGraphicsGrid::boundingRect() const @@ -169,9 +167,8 @@ void QGraphicsGrid::paint(QPainter* painter, /* draw horizontal lines */ for (int i = 0; i <= _numberOfXCells; ++i) { - int x = - static_cast<int>(_bounds.left() + - (i * (_bounds.width() - 1) / _numberOfXCells)); + auto x = static_cast<int>( + _bounds.left() + (i * (_bounds.width() - 1) / _numberOfXCells)); if (i > 0 && i < _numberOfXCells) { @@ -193,9 +190,8 @@ void QGraphicsGrid::paint(QPainter* painter, /* draw vertical lines */ for (int j = 0; j <= _numberOfYCells; ++j) { - int y = - static_cast<int>(_bounds.bottom() - - (j * (_bounds.height() - 1) / _numberOfYCells)); + auto y = static_cast<int>( + _bounds.bottom() - (j * (_bounds.height() - 1) / _numberOfYCells)); if (j > 0 && j < _numberOfYCells) { diff --git a/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.h b/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.h index ba529f9c648f233e79991876f2ff08be46f74022..df90d639ee7044dc5d12127c5dee7d1f2b8c4746 100644 --- a/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.h +++ b/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.h @@ -25,20 +25,23 @@ class QGraphicsGrid : public QGraphicsItem { public: - QGraphicsGrid(QRectF rect, int xCells, int yCells, QGraphicsItem* parent = 0); + QGraphicsGrid(QRectF rect, + int xCells, + int yCells, + QGraphicsItem* parent = nullptr); QGraphicsGrid(int x, int y, int width, int height, int xCells, int yCells, - QGraphicsItem* parent = 0); + QGraphicsItem* parent = nullptr); QGraphicsGrid(QRectF rect, int xCells, int yCells, bool ticks, QPen pen, - QGraphicsItem* parent = 0); + QGraphicsItem* parent = nullptr); QGraphicsGrid(int x, int y, int width, @@ -47,11 +50,13 @@ public: int yCells, bool ticks, QPen pen, - QGraphicsItem* parent = 0); - ~QGraphicsGrid(); + QGraphicsItem* parent = nullptr); + ~QGraphicsGrid() override; - QRectF boundingRect() const; - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); + QRectF boundingRect() const override; + void paint(QPainter* painter, + const QStyleOptionGraphicsItem* option, + QWidget* widget) override; void setNumberOfXCells(int xCells); void setNumberOfYCells(int yCells); void setRect(QRectF rect); diff --git a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp index 756a0fbfeb4bef1fe3d37c1a7613b82f892f182e..cb218b176b633cedcd2c6e7a297686a7b37c43da 100644 --- a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp +++ b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp @@ -113,8 +113,7 @@ const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::di { double val(raster->getValueAtPoint(*surface_nodes[i])); val = (val == no_data) ? 0 : ((val*node_area_vec[i])/scaling); - _direct_values.push_back( - std::pair<std::size_t, double>((*node_id_pv)[i], val)); + _direct_values.emplace_back((*node_id_pv)[i], val); } return _direct_values; @@ -127,8 +126,8 @@ int DirectConditionGenerator::writeToFile(const std::string &name) const if (out) { - for (std::vector< std::pair<std::size_t,double> >::const_iterator 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/DirectConditionGenerator.h b/Applications/DataExplorer/DataView/DirectConditionGenerator.h index 0985f0875a1d10f32a2bcb1ed5722fcc28ec4f54..9872c3449770dbd02573729bcbf32de24288d340 100644 --- a/Applications/DataExplorer/DataView/DirectConditionGenerator.h +++ b/Applications/DataExplorer/DataView/DirectConditionGenerator.h @@ -24,14 +24,17 @@ namespace MeshLib { class DirectConditionGenerator { public: - DirectConditionGenerator() {}; - ~DirectConditionGenerator() {}; + DirectConditionGenerator() = default; + ~DirectConditionGenerator() = default; - const std::vector< std::pair<std::size_t,double> >& directToSurfaceNodes(const MeshLib::Mesh &mesh, const std::string &filename); + const std::vector<std::pair<std::size_t, double>>& directToSurfaceNodes( + const MeshLib::Mesh& mesh, const std::string& filename); - const std::vector< std::pair<std::size_t,double> >& directWithSurfaceIntegration(MeshLib::Mesh &mesh, const std::string &filename, double scaling); + const std::vector<std::pair<std::size_t, double>>& + directWithSurfaceIntegration(MeshLib::Mesh& mesh, + const std::string& filename, double scaling); - int writeToFile(const std::string &name) const; + int writeToFile(const std::string& name) const; private: std::vector< std::pair<std::size_t,double> > _direct_values; diff --git a/Applications/DataExplorer/DataView/ElementTreeModel.cpp b/Applications/DataExplorer/DataView/ElementTreeModel.cpp index 5e184e87993b13b10b3072ac2149ccaedef881d4..2450cd08b0e9640c1e9b1a43ca79b14df13bf841 100644 --- a/Applications/DataExplorer/DataView/ElementTreeModel.cpp +++ b/Applications/DataExplorer/DataView/ElementTreeModel.cpp @@ -37,9 +37,7 @@ ElementTreeModel::ElementTreeModel( QObject* parent ) _rootItem = new TreeItem(rootData, nullptr); } -ElementTreeModel::~ElementTreeModel() -{ -} +ElementTreeModel::~ElementTreeModel() = default; void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, const unsigned elem_index) { @@ -48,8 +46,8 @@ void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, _mesh_source = grid; this->clearView(); - MeshLib::VtkMappedMeshSource const*const source = - dynamic_cast<MeshLib::VtkMappedMeshSource const*const>(grid); + auto const* const source = + dynamic_cast<MeshLib::VtkMappedMeshSource const* const>(grid); if (!source) return; @@ -59,12 +57,12 @@ void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, QList<QVariant> elemData; elemData << "Element " + QString::number(elem_index) << "" << "" << ""; - TreeItem* elemItem = new TreeItem(elemData, _rootItem); + auto* elemItem = new TreeItem(elemData, _rootItem); _rootItem->appendChild(elemItem); QList<QVariant> typeData; typeData << "Element Type: " << QString::fromStdString(MeshElemType2String(elem->getGeomType())); - TreeItem* typeItem = new TreeItem(typeData, elemItem); + auto* typeItem = new TreeItem(typeData, elemItem); elemItem->appendChild(typeItem); MeshLib::PropertyVector<int> const*const mat_ids = @@ -74,18 +72,18 @@ void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, QString matIdString = !mat_ids ? QString("not defined") : QString::number((*mat_ids)[elem->getID()]); QList<QVariant> materialData; materialData << "MaterialID: " << matIdString; - TreeItem* matItem = new TreeItem(materialData, elemItem); + auto* matItem = new TreeItem(materialData, elemItem); elemItem->appendChild(matItem); QList<QVariant> volData; volData << "Area/Volume: " << QString::number(mesh->getElement(elem_index)->getContent()); - TreeItem* volItem = new TreeItem(volData, elemItem); + auto* volItem = new TreeItem(volData, elemItem); elemItem->appendChild(volItem); QList<QVariant> nodeListData; nodeListData << "Nodes" << "" << "" << ""; - TreeItem* nodeListItem = new TreeItem(nodeListData, elemItem); + auto* nodeListItem = new TreeItem(nodeListData, elemItem); elemItem->appendChild(nodeListItem); //const std::vector<MeshLib::Node*> nodes_vec = grid->getNodes(); @@ -97,7 +95,7 @@ void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, nodeData << "Node " + QString::number(node->getID()) << QString::number((*node)[0]) << QString::number((*node)[1]) << QString::number((*node)[2]); - TreeItem* nodeItem = new TreeItem(nodeData, nodeListItem); + auto* nodeItem = new TreeItem(nodeData, nodeListItem); nodeListItem->appendChild(nodeItem); } endResetModel(); @@ -118,17 +116,17 @@ void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh) QList<QVariant> mesh_name; mesh_name << "Name:" << QString::fromStdString(mesh.getName()) << "" << "" << ""; - TreeItem* name_item = new TreeItem(mesh_name, _rootItem); + auto* name_item = new TreeItem(mesh_name, _rootItem); _rootItem->appendChild(name_item); QList<QVariant> nodes_number; nodes_number << "#Nodes: " << QString::number(mesh.getNumberOfNodes()) << "" << ""; - TreeItem* nodes_item = new TreeItem(nodes_number, _rootItem); + auto* nodes_item = new TreeItem(nodes_number, _rootItem); _rootItem->appendChild(nodes_item); QList<QVariant> elements_number; elements_number << "#Elements: " << QString::number(mesh.getNumberOfElements()) << "" << ""; - TreeItem* elements_item = new TreeItem(elements_number, _rootItem); + auto* elements_item = new TreeItem(elements_number, _rootItem); _rootItem->appendChild(elements_item); const std::array<QString, 7> n_element_names = {{ "Lines:", "Triangles:", "Quads:", "Tetrahedra:", "Hexahedra:", "Pyramids:", "Prisms:" }}; @@ -139,14 +137,14 @@ void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh) { QList<QVariant> elements_number; elements_number << n_element_names[i] << QString::number(n_element_types[i]) << "" << ""; - TreeItem* type_item = new TreeItem(elements_number, elements_item); + auto* type_item = new TreeItem(elements_number, elements_item); elements_item->appendChild(type_item); } } QList<QVariant> bounding_box; bounding_box << "Bounding Box" << "" << "" << ""; - TreeItem* aabb_item = new TreeItem(bounding_box, _rootItem); + auto* aabb_item = new TreeItem(bounding_box, _rootItem); _rootItem->appendChild(aabb_item); const GeoLib::AABB aabb (MeshLib::MeshInformation::getBoundingBox(mesh)); @@ -155,36 +153,38 @@ void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh) QList<QVariant> min_aabb; min_aabb << "Min:" << QString::number(min[0], 'f') << QString::number(min[1], 'f') << QString::number(min[2], 'f'); - TreeItem* min_item = new TreeItem(min_aabb, aabb_item); + auto* min_item = new TreeItem(min_aabb, aabb_item); aabb_item->appendChild(min_item); QList<QVariant> max_aabb; max_aabb << "Max:" << QString::number(max[0], 'f') << QString::number(max[1], 'f') << QString::number(max[2], 'f'); - TreeItem* max_item = new TreeItem(max_aabb, aabb_item); + auto* max_item = new TreeItem(max_aabb, aabb_item); aabb_item->appendChild(max_item); QList<QVariant> edges; edges << "Edge Length: " << "[" + QString::number(mesh.getMinEdgeLength(), 'f') + "," << QString::number(mesh.getMaxEdgeLength(), 'f') + "]" << ""; - TreeItem* edge_item = new TreeItem(edges, _rootItem); + auto* edge_item = new TreeItem(edges, _rootItem); _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) + "]" << ""; } if (array_info.size() == 1) array_info << "[ ?" << "? ]" << ""; - TreeItem* vec_item = new TreeItem(array_info, _rootItem); + auto* vec_item = new TreeItem(array_info, _rootItem); _rootItem->appendChild(vec_item); } diff --git a/Applications/DataExplorer/DataView/ElementTreeModel.h b/Applications/DataExplorer/DataView/ElementTreeModel.h index eb860ac957387254c213e874fd7ce1084c95e3f5..3ce6059b58dd4ed8dee884fe3f9c36f93ee6dbaa 100644 --- a/Applications/DataExplorer/DataView/ElementTreeModel.h +++ b/Applications/DataExplorer/DataView/ElementTreeModel.h @@ -32,8 +32,8 @@ class ElementTreeModel : public TreeModel Q_OBJECT public: - ElementTreeModel( QObject* parent = 0 ); - ~ElementTreeModel(); + ElementTreeModel(QObject* parent = nullptr); + ~ElementTreeModel() override; vtkUnstructuredGridAlgorithm const* getSource() const { return _mesh_source; }; diff --git a/Applications/DataExplorer/DataView/ElementTreeView.cpp b/Applications/DataExplorer/DataView/ElementTreeView.cpp index db7813459feac8f40dab81153d79e38d6fa496ae..085a8acd1255fe811b7f18d08d36e82fed6eb1f8 100644 --- a/Applications/DataExplorer/DataView/ElementTreeView.cpp +++ b/Applications/DataExplorer/DataView/ElementTreeView.cpp @@ -29,7 +29,8 @@ void ElementTreeView::updateView() { setAlternatingRowColors(true); setColumnWidth(0,125); - std::size_t nColumns = (this->model() != NULL) ? this->model()->columnCount() : 0; + std::size_t nColumns = + (this->model() != nullptr) ? this->model()->columnCount() : 0; for (std::size_t i = 1; i < nColumns; i++) resizeColumnToContents(i); this->expandAll(); diff --git a/Applications/DataExplorer/DataView/ElementTreeView.h b/Applications/DataExplorer/DataView/ElementTreeView.h index a3531ba226d4fa0404801ed1985ea7f69525c3e1..af980f1c31ce8d8ee38949f34fffb179a9d46986 100644 --- a/Applications/DataExplorer/DataView/ElementTreeView.h +++ b/Applications/DataExplorer/DataView/ElementTreeView.h @@ -26,14 +26,15 @@ class ElementTreeView : public QTreeView public: /// Constructor - ElementTreeView(QWidget* parent = 0); + ElementTreeView(QWidget* parent = nullptr); public slots: void updateView(); protected slots: /// Is called when the selection of this view changes. - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + void selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) override; signals: void nodeSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool); diff --git a/Applications/DataExplorer/DataView/GEOModels.cpp b/Applications/DataExplorer/DataView/GEOModels.cpp index 85918f506afc1f589a2f98315dc2a42b3e67939f..96a5c30d1f7d4e91ae1e5ba5cdefe81fd3d0b30e 100644 --- a/Applications/DataExplorer/DataView/GEOModels.cpp +++ b/Applications/DataExplorer/DataView/GEOModels.cpp @@ -226,29 +226,26 @@ void GEOModels::addNameForObjectPoints(const std::string &geometry_name, GeoLib::PointVec* pnt_vec = _geo_objects.getPointVecObj(geometry_name); if (object_type == GeoLib::GEOTYPE::POLYLINE) { - const GeoLib::Polyline* ply = dynamic_cast<const GeoLib::Polyline*>(obj); + const auto* ply = dynamic_cast<const GeoLib::Polyline*>(obj); std::size_t nPoints = ply->getNumberOfPoints(); for (std::size_t i = 0; i < nPoints; i++) - pnt_vec->setNameForElement(ply->getPointID( - i), new_name + "_Point" + - std::to_string(ply->getPointID(i))); + pnt_vec->setNameForElement( + ply->getPointID(i), + new_name + "_Point" + std::to_string(ply->getPointID(i))); } else if (object_type == GeoLib::GEOTYPE::SURFACE) { - const GeoLib::Surface* sfc = dynamic_cast<const GeoLib::Surface*>(obj); + const auto* sfc = dynamic_cast<const GeoLib::Surface*>(obj); std::size_t nTriangles = sfc->getNumberOfTriangles(); for (std::size_t i = 0; i < nTriangles; i++) { const GeoLib::Triangle* tri = (*sfc)[i]; - pnt_vec->setNameForElement((*tri)[0], - new_name + "_Point" + - std::to_string((*tri)[0])); - pnt_vec->setNameForElement((*tri)[1], - new_name + "_Point" + - std::to_string((*tri)[1])); - pnt_vec->setNameForElement((*tri)[2], - new_name + "_Point" + - std::to_string((*tri)[2])); + pnt_vec->setNameForElement( + (*tri)[0], new_name + "_Point" + std::to_string((*tri)[0])); + pnt_vec->setNameForElement( + (*tri)[1], new_name + "_Point" + std::to_string((*tri)[1])); + pnt_vec->setNameForElement( + (*tri)[2], new_name + "_Point" + std::to_string((*tri)[2])); } } else diff --git a/Applications/DataExplorer/DataView/GEOModels.h b/Applications/DataExplorer/DataView/GEOModels.h index eebcf35cba6ca8419c6c7365cd3fdc74ef59032c..54981a89ab2fb13a42cdb65e806d3dfffce13b55 100644 --- a/Applications/DataExplorer/DataView/GEOModels.h +++ b/Applications/DataExplorer/DataView/GEOModels.h @@ -39,7 +39,7 @@ class GEOModels : public QObject public: GEOModels(GeoLib::GEOObjects& geo_objects, QObject* parent = nullptr); - ~GEOModels(); + ~GEOModels() override; GeoTreeModel* getGeoModel() { return _geoModel; } StationTreeModel* getStationModel() { return _stationModel; } diff --git a/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp b/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp index 125b004040e29a5083d162bc28c1e17cd6806108..ce656d0089999b8ba6968fccaa4089a1ad32c8dc 100644 --- a/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp +++ b/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp @@ -38,25 +38,16 @@ GMSHPrefsDialog::GMSHPrefsDialog(GeoLib::GEOObjects const& geoObjects, QDialog* this->param4->setText("0"); // object will be deleted by Qt - StrictIntValidator* max_number_of_points_in_quadtree_leaf_validator (new StrictIntValidator ( - 1, - 1000, - this->param1)); + auto* max_number_of_points_in_quadtree_leaf_validator( + new StrictIntValidator(1, 1000, this->param1)); param1->setValidator (max_number_of_points_in_quadtree_leaf_validator); // object will be deleted by Qt - StrictDoubleValidator* mesh_density_scaling_pnts_validator(new StrictDoubleValidator ( - 1e-10, - 1.0, - 5, - this - ->param2)); + auto* mesh_density_scaling_pnts_validator( + new StrictDoubleValidator(1e-10, 1.0, 5, this->param2)); param2->setValidator (mesh_density_scaling_pnts_validator); // object will be deleted by Qt# - StrictDoubleValidator* mesh_density_scaling_stations_validator(new StrictDoubleValidator ( - 1e-10, - 1.0, - 5, - this->param3)); + auto* mesh_density_scaling_stations_validator( + new StrictDoubleValidator(1e-10, 1.0, 5, this->param3)); param3->setValidator (mesh_density_scaling_stations_validator); std::vector<std::string> geoNames; @@ -66,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()); @@ -99,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& index : selected) { - list.append(it->data().toString()); + list.append(index.data().toString()); - _allGeo->removeRow(it->row()); + _allGeo->removeRow(index.row()); } _selGeo->setStringList(list); } @@ -113,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& index : selected) { - list.append(it->data().toString()); + list.append(index.data().toString()); - _selGeo->removeRow(it->row()); + _selGeo->removeRow(index.row()); } _allGeo->setStringList(list); } @@ -188,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& index : list) + indexList.push_back(index.toStdString()); return indexList; } diff --git a/Applications/DataExplorer/DataView/GMSHPrefsDialog.h b/Applications/DataExplorer/DataView/GMSHPrefsDialog.h index 768b7d688624a01384189dd14da33d5e85d483de..80ba02e8afce059a736f69dcc3232098b2fdd5c7 100644 --- a/Applications/DataExplorer/DataView/GMSHPrefsDialog.h +++ b/Applications/DataExplorer/DataView/GMSHPrefsDialog.h @@ -33,7 +33,7 @@ class GMSHPrefsDialog : public QDialog, private Ui_GMSHPrefs public: GMSHPrefsDialog(GeoLib::GEOObjects const& geoObjects, QDialog* parent = nullptr); - ~GMSHPrefsDialog(void); + ~GMSHPrefsDialog(void) override; private: std::vector<std::string> getSelectedObjects(QStringList list); @@ -47,10 +47,10 @@ private slots: void on_radioAdaptive_toggled(bool isTrue); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; signals: void requestMeshing(std::vector<std::string> &, unsigned, double, double, double, bool); diff --git a/Applications/DataExplorer/DataView/GeoObjectListItem.h b/Applications/DataExplorer/DataView/GeoObjectListItem.h index a85c9b86b89f399f24b047f81b2b8d78a0e6d48f..9f5655e21a4e9f4d1ac7f1ef6a6a5f485e8ce67d 100644 --- a/Applications/DataExplorer/DataView/GeoObjectListItem.h +++ b/Applications/DataExplorer/DataView/GeoObjectListItem.h @@ -34,11 +34,13 @@ class GeoObjectListItem : public TreeItem { public: /// Constructor for the TreeItem specifying the "Points"-subtree of a geometry. - GeoObjectListItem(const QList<QVariant> &data, + GeoObjectListItem(const QList<QVariant>& data, TreeItem* parent, - const std::vector<GeoLib::Point*>* geo_data = NULL, + const std::vector<GeoLib::Point*>* geo_data = nullptr, GeoLib::GEOTYPE type = GeoLib::GEOTYPE::POINT) - : TreeItem(data, parent), _vtkSource(VtkPointsSource::New()), _type(type) + : TreeItem(data, parent), + _vtkSource(VtkPointsSource::New()), + _type(type) { QString geo_name = parent->data(0).toString(); static_cast<VtkPointsSource*>(_vtkSource)->setPoints(geo_data); @@ -46,11 +48,13 @@ public: } /// Constructor for the TreeItem specifying the "Polylines"-subtree of a geometry. - GeoObjectListItem(const QList<QVariant> &data, + GeoObjectListItem(const QList<QVariant>& data, TreeItem* parent, - const std::vector<GeoLib::Polyline*>* geo_data = NULL, + const std::vector<GeoLib::Polyline*>* geo_data = nullptr, GeoLib::GEOTYPE type = GeoLib::GEOTYPE::POLYLINE) - : TreeItem(data, parent), _vtkSource(VtkPolylinesSource::New()), _type(type) + : TreeItem(data, parent), + _vtkSource(VtkPolylinesSource::New()), + _type(type) { QString geo_name = parent->data(0).toString(); static_cast<VtkPolylinesSource*>(_vtkSource)->setPolylines(geo_data); @@ -58,22 +62,20 @@ public: } /// Constructor for the TreeItem specifying the "Surfaces"-subtree of a geometry. - GeoObjectListItem(const QList<QVariant> &data, + GeoObjectListItem(const QList<QVariant>& data, TreeItem* parent, - const std::vector<GeoLib::Surface*>* geo_data = NULL, + const std::vector<GeoLib::Surface*>* geo_data = nullptr, GeoLib::GEOTYPE type = GeoLib::GEOTYPE::SURFACE) - : TreeItem(data, parent), _vtkSource(VtkSurfacesSource::New()), _type(type) + : TreeItem(data, parent), + _vtkSource(VtkSurfacesSource::New()), + _type(type) { QString geo_name = parent->data(0).toString(); static_cast<VtkSurfacesSource*>(_vtkSource)->setSurfaces(geo_data); static_cast<VtkSurfacesSource*>(_vtkSource)->SetName(geo_name + " - Surfaces"); } - ~GeoObjectListItem() - { - _vtkSource->Delete(); - } - + ~GeoObjectListItem() override { _vtkSource->Delete(); } /// Returns the type of geo-objects contained in the subtree of this item. GeoLib::GEOTYPE getType() { return _type; } diff --git a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp index 93622e36d691b1f53b0e65600bfa6ff41f89169a..6edb41fb1f3154f40221813651e2a34ddf3384e6 100644 --- a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp +++ b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp @@ -26,13 +26,12 @@ 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& mesh : mesh_vec) + this->meshNameComboBox->addItem( + QString::fromStdString(mesh->getName())); } -GeoOnMeshMappingDialog::~GeoOnMeshMappingDialog() -{ -} +GeoOnMeshMappingDialog::~GeoOnMeshMappingDialog() = default; int GeoOnMeshMappingDialog::getDataSetChoice() const { diff --git a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.h b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.h index 985c6cde38868580322fc7f0bf103af6bf31d8b1..40c0efa147733aa0b1f7cbd53e15bba96a408b05 100644 --- a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.h +++ b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.h @@ -33,8 +33,8 @@ class GeoOnMeshMappingDialog : public QDialog, private Ui_GeoOnMeshMapping public: GeoOnMeshMappingDialog( std::vector<std::unique_ptr<MeshLib::Mesh>> const& mesh_vec, - QDialog* parent = 0); - ~GeoOnMeshMappingDialog(void); + QDialog* parent = nullptr); + ~GeoOnMeshMappingDialog(void) override; std::string const& getNewGeoName() const { return _new_geo_name; }; int getDataSetChoice() const; @@ -48,9 +48,8 @@ private slots: void on_meshNameComboBox_currentIndexChanged(int idx); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject() { this->done(QDialog::Rejected); }; - + void reject() override { this->done(QDialog::Rejected); }; }; diff --git a/Applications/DataExplorer/DataView/GeoTabWidget.h b/Applications/DataExplorer/DataView/GeoTabWidget.h index 825a3916c6845eb105d3cc0f03ffe698217e7f37..7a742e966aca4a13fce65686d28fbd05d679c3c0 100644 --- a/Applications/DataExplorer/DataView/GeoTabWidget.h +++ b/Applications/DataExplorer/DataView/GeoTabWidget.h @@ -25,7 +25,7 @@ class GeoTabWidget : public QWidget, public Ui_GeoTabWidgetBase Q_OBJECT public: - GeoTabWidget(QWidget* parent = 0); + GeoTabWidget(QWidget* parent = nullptr); private: diff --git a/Applications/DataExplorer/DataView/GeoTreeItem.h b/Applications/DataExplorer/DataView/GeoTreeItem.h index 45d3c41a2c9d4153e10aa656b7c9d13eaf1ec565..52011079b1c956317de1039d4891dfd514161159 100644 --- a/Applications/DataExplorer/DataView/GeoTreeItem.h +++ b/Applications/DataExplorer/DataView/GeoTreeItem.h @@ -32,10 +32,13 @@ public: * \param parent The parent item in the tree * \param item The GeoObject (i.e. Point, Polyline or Surface) */ - GeoTreeItem(const QList<QVariant> &data, + GeoTreeItem(const QList<QVariant>& data, TreeItem* parent, - const GeoLib::GeoObject* item = NULL) : TreeItem(data, parent), _item(item) {} - ~GeoTreeItem() {} + const GeoLib::GeoObject* item = nullptr) + : TreeItem(data, parent), _item(item) + { + } + ~GeoTreeItem() override = default; /// Returns the geo-object associated with this item (i.e. a point, polyline or surface). const GeoLib::GeoObject* getGeoObject() const { return _item; } diff --git a/Applications/DataExplorer/DataView/GeoTreeModel.cpp b/Applications/DataExplorer/DataView/GeoTreeModel.cpp index b5c6f6a91c66e9ab785f841f720f88fa4e980c66..1b412c53f9bb81f1449f292c41e724a6082d238d 100644 --- a/Applications/DataExplorer/DataView/GeoTreeModel.cpp +++ b/Applications/DataExplorer/DataView/GeoTreeModel.cpp @@ -30,12 +30,10 @@ GeoTreeModel::GeoTreeModel( QObject* parent ) QList<QVariant> rootData; delete _rootItem; rootData << "Id" << "x" << "y" << "z" << "name "; - _rootItem = new GeoTreeItem(rootData, NULL, NULL); + _rootItem = new GeoTreeItem(rootData, nullptr, nullptr); } -GeoTreeModel::~GeoTreeModel() -{ -} +GeoTreeModel::~GeoTreeModel() = default; void GeoTreeModel::addPointList(QString geoName, GeoLib::PointVec const& pointVec) { @@ -45,13 +43,14 @@ void GeoTreeModel::addPointList(QString geoName, GeoLib::PointVec const& pointVe QList<QVariant> geoData; geoData << QVariant(geoName) << "" << "" << "" << ""; - GeoTreeItem* geo (new GeoTreeItem(geoData, _rootItem)); + auto* geo(new GeoTreeItem(geoData, _rootItem)); _lists.push_back(geo); _rootItem->appendChild(geo); QList<QVariant> pointData; pointData << "Points" << "" << "" << "" << ""; - GeoObjectListItem* pointList = new GeoObjectListItem(pointData, geo, points, GeoLib::GEOTYPE::POINT); + auto* pointList = + new GeoObjectListItem(pointData, geo, points, GeoLib::GEOTYPE::POINT); geo->appendChild(pointList); std::size_t nPoints = points->size(); @@ -84,14 +83,14 @@ void GeoTreeModel::addPolylineList(QString geoName, GeoLib::PolylineVec const& p beginResetModel(); int nLists = _rootItem->childCount(); - TreeItem* geo(NULL); + TreeItem* geo(nullptr); for (int i = 0; i < nLists; i++) { if (_rootItem->child(i)->data(0).toString().compare(geoName) == 0) geo = _rootItem->child(i); } - if (geo == NULL) + if (geo == nullptr) { ERR("GeoTreeModel::addPolylineList(): No corresponding geometry for \"%s\" found.", geoName.toStdString().c_str()); return; @@ -101,7 +100,8 @@ void GeoTreeModel::addPolylineList(QString geoName, GeoLib::PolylineVec const& p QList<QVariant> plyData; plyData << "Polylines" << "" << "" << ""; - GeoObjectListItem* plyList = new GeoObjectListItem(plyData, geo, lines, GeoLib::GEOTYPE::POLYLINE); + auto* plyList = + new GeoObjectListItem(plyData, geo, lines, GeoLib::GEOTYPE::POLYLINE); geo->appendChild(plyList); this->addChildren(plyList, polylineVec, 0, lines->size()); @@ -110,18 +110,16 @@ 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++) { - GeoObjectListItem* parent = - static_cast<GeoObjectListItem*>(_lists[i]->child(j)); + auto* parent = static_cast<GeoObjectListItem*>(list->child(j)); if (GeoLib::GEOTYPE::POLYLINE == parent->getType()) { beginResetModel(); - this->addChildren(parent, polylineVec, - parent->childCount(), + this->addChildren(parent, polylineVec, parent->childCount(), polylineVec.getVector()->size()); endResetModel(); parent->vtkSource()->Modified(); @@ -146,10 +144,10 @@ void GeoTreeModel::addChildren(GeoObjectListItem* plyList, line_data << "Line " + QString::number(i) << "" << "" << ""; const GeoLib::Polyline &line(*(lines[i])); - GeoTreeItem* lineItem(new GeoTreeItem(line_data, plyList, &line)); + auto* lineItem(new GeoTreeItem(line_data, plyList, &line)); plyList->appendChild(lineItem); - int nPoints = static_cast<int>(lines[i]->getNumberOfPoints()); + auto nPoints = static_cast<int>(lines[i]->getNumberOfPoints()); for (int j = 0; j < nPoints; j++) { const GeoLib::Point pnt(*(line.getPoint(j))); @@ -175,7 +173,7 @@ void GeoTreeModel::addSurfaceList(QString geoName, GeoLib::SurfaceVec const& sur beginResetModel(); int nLists = _rootItem->childCount(); - TreeItem* geo(NULL); + TreeItem* geo(nullptr); for (int i = 0; i < nLists; i++) { if (_rootItem->child(i)->data(0).toString().compare(geoName) == 0) @@ -192,7 +190,8 @@ void GeoTreeModel::addSurfaceList(QString geoName, GeoLib::SurfaceVec const& sur QList<QVariant> sfcData; sfcData << "Surfaces" << "" << "" << ""; - GeoObjectListItem* sfcList = new GeoObjectListItem(sfcData, geo, surfaces, GeoLib::GEOTYPE::SURFACE); + auto* sfcList = + new GeoObjectListItem(sfcData, geo, surfaces, GeoLib::GEOTYPE::SURFACE); geo->appendChild(sfcList); this->addChildren(sfcList, surfaceVec, 0, surfaces->size()); @@ -201,20 +200,18 @@ 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++) { - GeoObjectListItem* parent = - static_cast<GeoObjectListItem*>(_lists[i]->child(j)); + auto* parent = static_cast<GeoObjectListItem*>(list->child(j)); if (GeoLib::GEOTYPE::SURFACE == parent->getType()) { beginResetModel(); - this->addChildren(parent, surfaceVec, - parent->childCount(), + this->addChildren(parent, surfaceVec, parent->childCount(), surfaceVec.getVector()->size()); parent->vtkSource()->Modified(); endResetModel(); @@ -242,10 +239,10 @@ void GeoTreeModel::addChildren(GeoObjectListItem* sfcList, "" << ""; const GeoLib::Surface &sfc(*(*surfaces)[i]); - GeoTreeItem* surfaceItem(new GeoTreeItem(surface, sfcList, &sfc)); + auto* surfaceItem(new GeoTreeItem(surface, sfcList, &sfc)); sfcList->appendChild(surfaceItem); - int nElems = static_cast<int>((*surfaces)[i]->getNumberOfTriangles()); + auto nElems = static_cast<int>((*surfaces)[i]->getNumberOfTriangles()); for (int j = 0; j < nElems; j++) { QList<QVariant> elem; @@ -254,7 +251,7 @@ void GeoTreeModel::addChildren(GeoObjectListItem* sfcList, elem << j << static_cast<int>(triangle[0]) << static_cast<int>(triangle[1]) << static_cast<int>(triangle[2]); - TreeItem* child(new TreeItem(elem, surfaceItem)); + auto* child(new TreeItem(elem, surfaceItem)); surfaceItem->appendChild(child); for (int k = 0; k < 3; k++) @@ -310,13 +307,13 @@ vtkPolyDataAlgorithm* GeoTreeModel::vtkSource(const std::string &name, GeoLib::G if ( name.compare( _lists[i]->data(0).toString().toStdString() ) == 0 ) for (int j = 0; j < _lists[i]->childCount(); j++) { - GeoObjectListItem* item = - dynamic_cast<GeoObjectListItem*>(_lists[i]->child(j)); + auto* item = + dynamic_cast<GeoObjectListItem*>(_lists[i]->child(j)); if (item->getType() == type) return item->vtkSource(); } } - return NULL; + return nullptr; } void GeoTreeModel::setNameForItem(const std::string &name, diff --git a/Applications/DataExplorer/DataView/GeoTreeModel.h b/Applications/DataExplorer/DataView/GeoTreeModel.h index 543a77ef9cf1683a84b1e41e4834a28fe1080486..8135af2dc1c901cb002e5d9c77028517ed9ccbb3 100644 --- a/Applications/DataExplorer/DataView/GeoTreeModel.h +++ b/Applications/DataExplorer/DataView/GeoTreeModel.h @@ -42,8 +42,8 @@ class GeoTreeModel : public TreeModel Q_OBJECT public: - GeoTreeModel( QObject* parent = 0 ); - ~GeoTreeModel(); + GeoTreeModel(QObject* parent = nullptr); + ~GeoTreeModel() override; /** * Inserts a new subtree under _rootItem for a geometry with the given name along with a subtree named "Points" for that new geometry. diff --git a/Applications/DataExplorer/DataView/GeoTreeView.cpp b/Applications/DataExplorer/DataView/GeoTreeView.cpp index c52cd8898a066dc0ff796b37eaf941372b8b271c..b228cdc69c6c54fa42eefd0a2788dc6b59a3c0ef 100644 --- a/Applications/DataExplorer/DataView/GeoTreeView.cpp +++ b/Applications/DataExplorer/DataView/GeoTreeView.cpp @@ -70,13 +70,15 @@ void GeoTreeView::selectionChanged( const QItemSelection &selected, else // line points or surface triangles { emit enableSaveButton(false); - const GeoObjectListItem* geo_type = dynamic_cast<const GeoObjectListItem*>(tree_item); + const auto* geo_type = + dynamic_cast<const GeoObjectListItem*>(tree_item); if (geo_type) // geometry list item emit enableRemoveButton(true); else { // highlight a point for an expanded polyline - GeoObjectListItem* list_item = dynamic_cast<GeoObjectListItem*>(tree_item->parentItem()->parentItem()); + auto* list_item = dynamic_cast<GeoObjectListItem*>( + tree_item->parentItem()->parentItem()); if (list_item && list_item->getType() == GeoLib::GEOTYPE::POLYLINE) geoItemSelected( dynamic_cast<GeoObjectListItem*>(tree_item->parentItem()->parentItem()->parentItem()->child(0))->vtkSource(), @@ -115,15 +117,15 @@ void GeoTreeView::selectionChangedFromOutside( const QItemSelection &selected, void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) { QModelIndex index = this->selectionModel()->currentIndex(); - TreeItem* item = static_cast<TreeItem*>(index.internalPointer()); + auto* item = static_cast<TreeItem*>(index.internalPointer()); - GeoObjectListItem* list = dynamic_cast<GeoObjectListItem*>(item); + auto* list = dynamic_cast<GeoObjectListItem*>(item); QMenu menu; // The current index is a list of points/polylines/surfaces - if (list != NULL) + if (list != nullptr) { - QAction* connectPlyAction(NULL); + QAction* connectPlyAction(nullptr); if (list->getType() == GeoLib::GEOTYPE::POLYLINE) { connectPlyAction = menu.addAction("Connect Polylines..."); @@ -139,10 +141,10 @@ void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) if (!item) // Otherwise sometimes it crashes when (unmotivated ;-) ) clicking in a treeview return; - GeoObjectListItem* parent = dynamic_cast<GeoObjectListItem*>(item->parentItem()); + auto* parent = dynamic_cast<GeoObjectListItem*>(item->parentItem()); // The current index refers to a geo-object - if (parent != NULL) + if (parent != nullptr) { QMenu* cond_menu = new QMenu("Set FEM Condition"); //menu.addMenu(cond_menu); @@ -201,7 +203,7 @@ void GeoTreeView::removeGeometry() else { TreeItem* item = static_cast<GeoTreeModel*>(model())->getItem(index); - GeoObjectListItem* list = dynamic_cast<GeoObjectListItem*>(item); + auto* list = dynamic_cast<GeoObjectListItem*>(item); if (list) { emit listRemoved((item->parentItem()->data( 0).toString()).toStdString(), list->getType()); @@ -260,7 +262,8 @@ void GeoTreeView::writeToFile() const file_type.append(";;Legacy geometry file (*.gli)"); #endif // DEBUG QString geoName = item->data(0).toString(); - QString fileName = QFileDialog::getSaveFileName(NULL, "Save geometry as", + QString fileName = QFileDialog::getSaveFileName( + nullptr, "Save geometry as", LastSavedFileDirectory::getDir() + geoName, file_type); if (!fileName.isEmpty()) { diff --git a/Applications/DataExplorer/DataView/GeoTreeView.h b/Applications/DataExplorer/DataView/GeoTreeView.h index dd4f27cb9dfbb300557fd5d68029e315c665c9bb..ed096bf84afd00ffcd2fcbc2fc0229649e947212 100644 --- a/Applications/DataExplorer/DataView/GeoTreeView.h +++ b/Applications/DataExplorer/DataView/GeoTreeView.h @@ -31,14 +31,15 @@ class GeoTreeView : public QTreeView public: /// Constructor - GeoTreeView(QWidget* parent = 0); + GeoTreeView(QWidget* parent = nullptr); /// Update the view to visualise changes made to the underlying data void updateView(); protected slots: /// Instructions if the selection of items in the view has changed. - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + void selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) override; /// Instructions if the selection of items in the view has changed by events outside the view (i.e. by actions made in the visualisation). void selectionChangedFromOutside(const QItemSelection &selected, @@ -46,7 +47,7 @@ protected slots: private: /// Actions to be taken after a right mouse click is performed in the station view. - void contextMenuEvent( QContextMenuEvent* e ); + void contextMenuEvent(QContextMenuEvent* e) override; /// Calls a FEMConditionSetupDialog. void setElementAsCondition(bool set_on_points = false); diff --git a/Applications/DataExplorer/DataView/LicenseDialog.h b/Applications/DataExplorer/DataView/LicenseDialog.h index 0e9b60923e7f49b5378df97b6bb5591f0f011e01..08f88f5e1780522698c1f94dbbd7b80702c8039d 100644 --- a/Applications/DataExplorer/DataView/LicenseDialog.h +++ b/Applications/DataExplorer/DataView/LicenseDialog.h @@ -25,8 +25,9 @@ class LicenseDialog : public QDialog, private Ui_License Q_OBJECT public: - LicenseDialog(QDialog* parent = 0); - ~LicenseDialog() {}; + LicenseDialog(QDialog* parent = nullptr); + ~LicenseDialog() override = default; + ; private: void setText(); diff --git a/Applications/DataExplorer/DataView/LineEditDialog.cpp b/Applications/DataExplorer/DataView/LineEditDialog.cpp index 56215c54dac7ec3a39e3e7ded5e76bb961dddbc2..abed2ee8e3fabf81d53e4359809a7f679e68c64c 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& index : selected) { - list.append(it->data().toString()); + list.append(index.data().toString()); - _allPly->removeRow(it->row()); + _allPly->removeRow(index.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& index : selected) { - list.append(it->data().toString()); + list.append(index.data().toString()); - _selPly->removeRow(it->row()); + _selPly->removeRow(index.row()); } _allPly->setStringList(list); } @@ -80,7 +80,8 @@ void LineEditDialog::accept() if (!selectedIndeces.empty()) { std::string prox_string = this->proximityEdit->text().toStdString(); - double prox = (prox_string.empty()) ? 0.0 : strtod( prox_string.c_str(), 0 ); + double prox = + (prox_string.empty()) ? 0.0 : strtod(prox_string.c_str(), nullptr); std::string ply_name = (plyNameEdit->text().toStdString().empty()) ? "" : plyNameEdit->text(). toStdString(); @@ -104,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& index : list) { - QString s = it->mid(5, it->indexOf(" ") - 5); + QString s = index.mid(5, index.indexOf(" ") - 5); indexList.push_back(s.toInt()); } return indexList; diff --git a/Applications/DataExplorer/DataView/LineEditDialog.h b/Applications/DataExplorer/DataView/LineEditDialog.h index 8db79316cf0ccc13511ddce08aaf43ec75dfda7a..ff0da51b8c808ca0774ab86d1d558105896a71a3 100644 --- a/Applications/DataExplorer/DataView/LineEditDialog.h +++ b/Applications/DataExplorer/DataView/LineEditDialog.h @@ -31,8 +31,9 @@ class LineEditDialog : public QDialog, private Ui_LineEdit Q_OBJECT public: - LineEditDialog(const GeoLib::PolylineVec &ply_vec, QDialog* parent = 0); - ~LineEditDialog(void); + LineEditDialog(const GeoLib::PolylineVec& ply_vec, + QDialog* parent = nullptr); + ~LineEditDialog(void) override; private: std::vector<std::size_t> getSelectedIndeces(QStringList list); @@ -49,10 +50,10 @@ private slots: void on_deselectPlyButton_pressed(); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; signals: void connectPolylines(const std::string&, diff --git a/Applications/DataExplorer/DataView/LinearEditDialog.cpp b/Applications/DataExplorer/DataView/LinearEditDialog.cpp index 6cf1f8c4c280d8bd3c8968ebe0e8def5abfbcece..19dc2ab7d9b27cf4c86d8e1aa5fd9dd089059a90 100644 --- a/Applications/DataExplorer/DataView/LinearEditDialog.cpp +++ b/Applications/DataExplorer/DataView/LinearEditDialog.cpp @@ -45,9 +45,7 @@ void LinearEditDialog::setupDialog(const std::vector<std::size_t> &dis_nodes, tableWidget->item(dis_nodes[i],0)->setText(QString::number(dis_values[i])); } -LinearEditDialog::~LinearEditDialog() -{ -} +LinearEditDialog::~LinearEditDialog() = default; void LinearEditDialog::on_comboBox_currentIndexChanged(int index) { @@ -68,7 +66,7 @@ void LinearEditDialog::accept() { QString row_text (tableWidget->item(i,0)->text()); if (row_text.length() > 0) - linear_values.push_back( std::pair<std::size_t, double>(i, row_text.toDouble()) ); + linear_values.emplace_back(i, row_text.toDouble()); } emit transmitDisValues(linear_values); diff --git a/Applications/DataExplorer/DataView/LinearEditDialog.h b/Applications/DataExplorer/DataView/LinearEditDialog.h index d35d57bb0a186d04a940511b6c30410d081234b3..8c35c7d5c9ac4c56b19ffba064350e8c9e7b207a 100644 --- a/Applications/DataExplorer/DataView/LinearEditDialog.h +++ b/Applications/DataExplorer/DataView/LinearEditDialog.h @@ -27,8 +27,11 @@ class LinearEditDialog : public QDialog, private Ui_LinearEdit Q_OBJECT public: - LinearEditDialog(const GeoLib::Polyline &line, const std::vector<std::size_t> &dis_nodes, const std::vector<double> &dis_values, QDialog* parent = 0); - ~LinearEditDialog(void); + LinearEditDialog(const GeoLib::Polyline& line, + const std::vector<std::size_t>& dis_nodes, + const std::vector<double>& dis_values, + QDialog* parent = nullptr); + ~LinearEditDialog(void) override; private: void setupDialog(const std::vector<std::size_t> &dis_nodes, const std::vector<double> &dis_values); @@ -39,10 +42,10 @@ private slots: void on_comboBox_currentIndexChanged(int index); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; signals: void transmitDisValues(std::vector< std::pair<std::size_t,double> >); diff --git a/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp b/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp index db133e1f2d899474352e541949edd39087f8ebcd..b82b4ca295978973f7c2a3ac6fe8007bd0ce656d 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& index : selected) { - list.append(it->data().toString()); + list.append(index.data().toString()); - _allGeo->removeRow(it->row()); + _allGeo->removeRow(index.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& index : selected) { - list.append(it->data().toString()); + list.append(index.data().toString()); - _selGeo->removeRow(it->row()); + _selGeo->removeRow(index.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& index : list) + indexList.push_back(index.toStdString()); return indexList; } diff --git a/Applications/DataExplorer/DataView/MergeGeometriesDialog.h b/Applications/DataExplorer/DataView/MergeGeometriesDialog.h index ad9c1bac5f555bf455d4212f1fca51b35a9b19c4..5c1462e4b9c59a2a999d2adb507753befd69e071 100644 --- a/Applications/DataExplorer/DataView/MergeGeometriesDialog.h +++ b/Applications/DataExplorer/DataView/MergeGeometriesDialog.h @@ -32,8 +32,9 @@ class MergeGeometriesDialog : public QDialog, private Ui_MergeGeometries Q_OBJECT public: - MergeGeometriesDialog(GeoLib::GEOObjects& geoObjects, QDialog* parent = 0); - ~MergeGeometriesDialog(void); + MergeGeometriesDialog(GeoLib::GEOObjects& geoObjects, + QDialog* parent = nullptr); + ~MergeGeometriesDialog(void) override; /// Returns a vector of selected geometries std::vector<std::string> const getSelectedGeometries() const; @@ -51,8 +52,8 @@ private slots: void on_deselectGeoButton_pressed(); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; }; diff --git a/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp b/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp index d6f149b15e7c1b0ed6ea180d7fdb80a9bc0d3fba..18539fe97dba7073417c2ccf03edefb6f969e593 100644 --- a/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp @@ -32,19 +32,19 @@ 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& mesh : mesh_vec) + this->meshListBox->addItem(QString::fromStdString(mesh->getName())); - StrictDoubleValidator* collapse_threshold_validator = new StrictDoubleValidator(0, 1000000, 7, this); + auto* collapse_threshold_validator = + new StrictDoubleValidator(0, 1000000, 7, this); this->collapsibleNodesThreshold->setValidator (collapse_threshold_validator); - StrictDoubleValidator* volume_threshold_validator = new StrictDoubleValidator(0, 1e10, 10, this); + auto* volume_threshold_validator = + new StrictDoubleValidator(0, 1e10, 10, this); this->zeroVolumeThreshold->setValidator (volume_threshold_validator); } -MeshAnalysisDialog::~MeshAnalysisDialog() -{ -} +MeshAnalysisDialog::~MeshAnalysisDialog() = default; void MeshAnalysisDialog::on_startButton_pressed() { diff --git a/Applications/DataExplorer/DataView/MeshAnalysisDialog.h b/Applications/DataExplorer/DataView/MeshAnalysisDialog.h index 7fde240dc4323065714905fb20c670dd0b49fff3..d6c0180eebf2668b3db035002c090293198c226c 100644 --- a/Applications/DataExplorer/DataView/MeshAnalysisDialog.h +++ b/Applications/DataExplorer/DataView/MeshAnalysisDialog.h @@ -36,7 +36,7 @@ public: MeshAnalysisDialog( std::vector<std::unique_ptr<MeshLib::Mesh>> const& mesh_vec, QDialog* parent = nullptr); - ~MeshAnalysisDialog(void); + ~MeshAnalysisDialog(void) override; private: /// Prepares the output for the node message window diff --git a/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp index 660a8a6f66ccdd3671e4ff2db217c03c183cef62..dfcd451863a401cfb8d76779405b31c4d1d51425 100644 --- a/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp @@ -48,9 +48,7 @@ MeshElementRemovalDialog::MeshElementRemovalDialog(DataHolderLib::Project const& } } -MeshElementRemovalDialog::~MeshElementRemovalDialog() -{ -} +MeshElementRemovalDialog::~MeshElementRemovalDialog() = default; void MeshElementRemovalDialog::accept() { @@ -67,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/MeshElementRemovalDialog.h b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.h index d08232f9c5914a5a44f8a932ae1162bc9d5e84e1..2a4b5fb8380e33c89379eb3c95664084f7305441 100644 --- a/Applications/DataExplorer/DataView/MeshElementRemovalDialog.h +++ b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.h @@ -36,8 +36,9 @@ class MeshElementRemovalDialog : public QDialog, private Ui_MeshElementRemoval Q_OBJECT public: - MeshElementRemovalDialog(DataHolderLib::Project const& project, QDialog* parent = 0); - ~MeshElementRemovalDialog(void); + MeshElementRemovalDialog(DataHolderLib::Project const& project, + QDialog* parent = nullptr); + ~MeshElementRemovalDialog(void) override; private slots: void on_boundingBoxCheckBox_toggled(bool is_checked); @@ -50,8 +51,8 @@ private slots: void on_yMaxEdit_textChanged() { aabb_edits[3] = true; } void on_zMinEdit_textChanged() { aabb_edits[4] = true; } void on_zMaxEdit_textChanged() { aabb_edits[5] = true; } - void accept(); - void reject(); + void accept() override; + void reject() override; private: DataHolderLib::Project const& _project; diff --git a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp index 77d9eb5fae85a3a59a8e390eea580a65e1c333b3..d89d9ab9d7d4b003dd21529985424f141bbf95f6 100644 --- a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp @@ -64,9 +64,7 @@ MeshLayerEditDialog::MeshLayerEditDialog(const MeshLib::Mesh* mesh, QDialog* par this->_layerSelectionLayout->setColumnStretch(2, 10); } -MeshLayerEditDialog::~MeshLayerEditDialog() -{ -} +MeshLayerEditDialog::~MeshLayerEditDialog() = default; void MeshLayerEditDialog::nextButtonPressed() { @@ -81,7 +79,7 @@ void MeshLayerEditDialog::nextButtonPressed() _layerEdit->setEnabled(false); _nextButton->setEnabled(false); - QVBoxLayout* _radiobuttonLayout (new QVBoxLayout(_radioButtonBox)); + auto* _radiobuttonLayout(new QVBoxLayout(_radioButtonBox)); QRadioButton* selectButton1 (new QRadioButton("Add layers based on raster files", _radioButtonBox)); QRadioButton* selectButton2 (new QRadioButton("Add layers with static thickness", _radioButtonBox)); _radioButtonBox = new QGroupBox(this); @@ -109,7 +107,7 @@ void MeshLayerEditDialog::createWithRasters() if (i==0) text = "Surface"; else if (i == _n_layers) text = "Layer" + QString::number(_n_layers) + "-Bottom"; else text="Layer" + QString::number(i+1) + "-Top"; - QLineEdit* edit (new QLineEdit(this)); + auto* edit(new QLineEdit(this)); QPushButton* button (new QPushButton("...", _layerBox)); this->_edits.push_back(edit); @@ -149,9 +147,9 @@ void MeshLayerEditDialog::createStatic() void MeshLayerEditDialog::createMeshToolSelection() { - QGroupBox* meshToolSelectionBox (new QGroupBox(this)); + auto* meshToolSelectionBox(new QGroupBox(this)); meshToolSelectionBox->setTitle("Output element type"); - QGridLayout* meshToolSelectionLayout (new QGridLayout(meshToolSelectionBox)); + auto* meshToolSelectionLayout(new QGridLayout(meshToolSelectionBox)); _ogsMeshButton = new QRadioButton("Prisms", meshToolSelectionBox); QRadioButton* tetgenMeshButton = new QRadioButton("Tetrahedra", meshToolSelectionBox); tetgenMeshButton->setFixedWidth(150); @@ -159,7 +157,8 @@ void MeshLayerEditDialog::createMeshToolSelection() minThicknessLabel->setText("Minimum thickness of layers:"); _minThicknessEdit = new QLineEdit(meshToolSelectionBox); _minThicknessEdit->setText("1.0"); - QDoubleValidator* min_thickness_validator = new QDoubleValidator(0, 1000000, 15, _minThicknessEdit); + auto* min_thickness_validator = + new QDoubleValidator(0, 1000000, 15, _minThicknessEdit); _minThicknessEdit->setValidator(min_thickness_validator); _minThicknessEdit->setMaximumWidth(100); _minThicknessEdit->setFixedWidth(100); @@ -305,11 +304,12 @@ void MeshLayerEditDialog::reject() void MeshLayerEditDialog::getFileName() { - QPushButton* button = dynamic_cast<QPushButton*>(this->sender()); + auto* button = dynamic_cast<QPushButton*>(this->sender()); QSettings settings; - QString filename = QFileDialog::getOpenFileName(this, "Select raster file to open", - settings.value("lastOpenedRasterFileDirectory").toString(), - "ASCII raster files (*.asc);;All files (* *.*)"); + QString filename = QFileDialog::getOpenFileName( + this, "Select raster file to open", + settings.value("lastOpenedRasterFileDirectory").toString(), + "ASCII raster files (*.asc);;All files (* *.*)"); _fileButtonMap[button]->setText(filename); QFileInfo fi(filename); settings.setValue("lastOpenedRasterFileDirectory", fi.absolutePath()); diff --git a/Applications/DataExplorer/DataView/MeshLayerEditDialog.h b/Applications/DataExplorer/DataView/MeshLayerEditDialog.h index bca05f792bf9ad7b6ff958745edff1b679a575a1..32d8850dbdffc84f3cb8fe1efd7888371366f7ef 100644 --- a/Applications/DataExplorer/DataView/MeshLayerEditDialog.h +++ b/Applications/DataExplorer/DataView/MeshLayerEditDialog.h @@ -39,8 +39,8 @@ class MeshLayerEditDialog : public QDialog, private Ui_MeshLayerEdit Q_OBJECT public: - MeshLayerEditDialog(const MeshLib::Mesh* mesh, QDialog* parent = 0); - ~MeshLayerEditDialog(void); + MeshLayerEditDialog(const MeshLib::Mesh* mesh, QDialog* parent = nullptr); + ~MeshLayerEditDialog(void) override; private: void createMeshToolSelection(); @@ -72,10 +72,10 @@ private slots: void createStatic(); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; signals: void mshEditFinished(MeshLib::Mesh*); diff --git a/Applications/DataExplorer/DataView/MeshMapping2DDialog.cpp b/Applications/DataExplorer/DataView/MeshMapping2DDialog.cpp index 728331317955d67918b2c948d3c62d67238212e5..0a1ebd7ff820c606ffa49264deb8c491dd3ebcd7 100644 --- a/Applications/DataExplorer/DataView/MeshMapping2DDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshMapping2DDialog.cpp @@ -19,9 +19,9 @@ MeshMapping2DDialog::MeshMapping2DDialog(QDialog* parent) { setupUi(this); - StrictDoubleValidator* no_data_validator = new StrictDoubleValidator(this); + auto* no_data_validator = new StrictDoubleValidator(this); this->noDataValueEdit->setValidator (no_data_validator); - StrictDoubleValidator* static_value_validator = new StrictDoubleValidator(this); + auto* static_value_validator = new StrictDoubleValidator(this); this->staticValueEdit->setValidator (static_value_validator); } diff --git a/Applications/DataExplorer/DataView/MeshMapping2DDialog.h b/Applications/DataExplorer/DataView/MeshMapping2DDialog.h index 7702cd357b47c1eb4f72758c6d2180d65b19a79c..f113ec3bcc2dc7e0ef0c078a300f7e6277da3b3f 100644 --- a/Applications/DataExplorer/DataView/MeshMapping2DDialog.h +++ b/Applications/DataExplorer/DataView/MeshMapping2DDialog.h @@ -37,8 +37,8 @@ private slots: void on_rasterSelectButton_pressed(); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject() { this->done(QDialog::Rejected); } + void reject() override { this->done(QDialog::Rejected); } }; diff --git a/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.cpp b/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.cpp index 74c1c37c3e67608716175081c104f27f135a80d8..f65d2d502cd970c8fc4f90e2a740b99192eee442 100644 --- a/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.cpp @@ -27,9 +27,7 @@ MeshQualitySelectionDialog::MeshQualitySelectionDialog(QDialog* parent) this->choiceEdges->toggle(); } -MeshQualitySelectionDialog::~MeshQualitySelectionDialog() -{ -} +MeshQualitySelectionDialog::~MeshQualitySelectionDialog() = default; void MeshQualitySelectionDialog::on_histogramCheckBox_toggled(bool is_checked) const { diff --git a/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.h b/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.h index 725028376249e9f70f0f11850e2568afc84240b3..32e907707dbff181666a6b06278aa323ee577166 100644 --- a/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.h +++ b/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.h @@ -28,8 +28,8 @@ class MeshQualitySelectionDialog : public QDialog, private Ui_MeshQualitySelecti Q_OBJECT public: - MeshQualitySelectionDialog(QDialog* parent = 0); - ~MeshQualitySelectionDialog(void); + MeshQualitySelectionDialog(QDialog* parent = nullptr); + ~MeshQualitySelectionDialog(void) override; /// Returns selected metric MeshLib::MeshQualityType getSelectedMetric() const { return _metric; } @@ -48,6 +48,6 @@ private slots: void on_histogramCheckBox_toggled(bool is_checked) const; void on_histogramPathButton_pressed(); - void accept(); - void reject(); + void accept() override; + void reject() override; }; diff --git a/Applications/DataExplorer/DataView/MeshValueEditDialog.cpp b/Applications/DataExplorer/DataView/MeshValueEditDialog.cpp index f9ca52af285ea151fb91a4247f61db3961a3e04f..6f476a6cd87d10cc2b4cc0a955ff5165403341f8 100644 --- a/Applications/DataExplorer/DataView/MeshValueEditDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshValueEditDialog.cpp @@ -26,9 +26,7 @@ MeshValueEditDialog::MeshValueEditDialog(MeshLib::Mesh* mesh, QDialog* parent) this->replaceCheckBox->setEnabled(false); } -MeshValueEditDialog::~MeshValueEditDialog(void) -{ -} +MeshValueEditDialog::~MeshValueEditDialog(void) = default; void MeshValueEditDialog::accept() { diff --git a/Applications/DataExplorer/DataView/MeshValueEditDialog.h b/Applications/DataExplorer/DataView/MeshValueEditDialog.h index df4de5b0a15868cde7af5a199e3a64f1f0d715f8..fbbf2d7bc4486d92f9180d9dedab380543e4e587 100644 --- a/Applications/DataExplorer/DataView/MeshValueEditDialog.h +++ b/Applications/DataExplorer/DataView/MeshValueEditDialog.h @@ -31,19 +31,19 @@ class MeshValueEditDialog : public QDialog, private Ui_MeshValueEdit public: /// Constructor for creating a new FEM condition. - MeshValueEditDialog(MeshLib::Mesh* mesh, QDialog* parent = 0); + MeshValueEditDialog(MeshLib::Mesh* mesh, QDialog* parent = nullptr); - ~MeshValueEditDialog(void); + ~MeshValueEditDialog(void) override; private: MeshLib::Mesh* _mesh; private slots: /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; void on_replaceButton_toggled(bool isSelected); diff --git a/Applications/DataExplorer/DataView/ModelTreeItem.cpp b/Applications/DataExplorer/DataView/ModelTreeItem.cpp index 803c89d3f6271e8431c2c9b684853b7c5a92f07c..67132a7eb15aa0892121aefb4e08fd69a55e8bae 100644 --- a/Applications/DataExplorer/DataView/ModelTreeItem.cpp +++ b/Applications/DataExplorer/DataView/ModelTreeItem.cpp @@ -21,8 +21,8 @@ ModelTreeItem::ModelTreeItem(const QList<QVariant> &data, TreeItem* parent, Base BaseItem* ModelTreeItem::getItem() const { - if (_item != NULL) + if (_item != nullptr) return _item; - return NULL; + return nullptr; } diff --git a/Applications/DataExplorer/DataView/ModelTreeItem.h b/Applications/DataExplorer/DataView/ModelTreeItem.h index 58a86176b424cd37fe22ff929d5a510f72422785..c33f9b988a143703b0a7ae76a8b5c35e32ed2794 100644 --- a/Applications/DataExplorer/DataView/ModelTreeItem.h +++ b/Applications/DataExplorer/DataView/ModelTreeItem.h @@ -32,9 +32,9 @@ public: * \param parent The parent item in the tree * \param item The ModelItem-object */ - ModelTreeItem(const QList<QVariant> &data, TreeItem* parent, BaseItem* item = NULL); - ~ModelTreeItem() { delete _item; } - + ModelTreeItem(const QList<QVariant>& data, TreeItem* parent, + BaseItem* item = nullptr); + ~ModelTreeItem() override { delete _item; } /// Returns the station object from which this item has been constructed GeoLib::Station* getStation() { return _stn; } diff --git a/Applications/DataExplorer/DataView/ModellingTabWidget.h b/Applications/DataExplorer/DataView/ModellingTabWidget.h index 87bcb53b3881b5667a153f2874ea6f2f114b3b42..af7e6a1f4fc8e1753de7ffa5911d08d6ae894faf 100644 --- a/Applications/DataExplorer/DataView/ModellingTabWidget.h +++ b/Applications/DataExplorer/DataView/ModellingTabWidget.h @@ -25,7 +25,7 @@ class ModellingTabWidget : public QWidget, public Ui_ModellingTabWidgetBase Q_OBJECT public: - ModellingTabWidget(QWidget* parent = 0); + ModellingTabWidget(QWidget* parent = nullptr); private slots: diff --git a/Applications/DataExplorer/DataView/MshEditDialog.cpp b/Applications/DataExplorer/DataView/MshEditDialog.cpp index ebf5bcc71fdb803175c81cd6db0860945a27daee..8a1dfca4266d1357bc5f26decc80639e89e2e470 100644 --- a/Applications/DataExplorer/DataView/MshEditDialog.cpp +++ b/Applications/DataExplorer/DataView/MshEditDialog.cpp @@ -29,17 +29,19 @@ #include <QVBoxLayout> MshEditDialog::MshEditDialog(const MeshLib::Mesh* mesh, QDialog* parent) - : QDialog(parent), _msh(mesh), _noDataDeleteBox(NULL), - _nLayerLabel (new QLabel("Please specify the number of layers to add:")), - _nLayerExplanation (new QLabel("(select \"0\" for surface mapping)")), - _layerEdit (new QLineEdit("0")), - _nextButton (new QPushButton("Next")), - _layerBox (NULL), - _radioButtonBox (NULL), - _layerSelectionLayout (new QGridLayout), - _radiobuttonLayout (new QVBoxLayout), - _selectButton1 (new QRadioButton("Add layers based on raster files")), - _selectButton2 (new QRadioButton("Add layers with static thickness")), + : QDialog(parent), + _msh(mesh), + _noDataDeleteBox(nullptr), + _nLayerLabel(new QLabel("Please specify the number of layers to add:")), + _nLayerExplanation(new QLabel("(select \"0\" for surface mapping)")), + _layerEdit(new QLineEdit("0")), + _nextButton(new QPushButton("Next")), + _layerBox(nullptr), + _radioButtonBox(nullptr), + _layerSelectionLayout(new QGridLayout), + _radiobuttonLayout(new QVBoxLayout), + _selectButton1(new QRadioButton("Add layers based on raster files")), + _selectButton2(new QRadioButton("Add layers with static thickness")), _n_layers(0), _use_rasters(true) { @@ -187,7 +189,7 @@ void MshEditDialog::accept() { int result(1); const unsigned nLayers = _layerEdit->text().toInt(); - MeshLib::Mesh* new_mesh (NULL); + MeshLib::Mesh* new_mesh(nullptr); if (nLayers==0) { diff --git a/Applications/DataExplorer/DataView/MshItem.h b/Applications/DataExplorer/DataView/MshItem.h index be5eb456ecad908074c7414634e0545c2e36589a..a88201ccc7af4c6438a45c92ab7a40eea7a5d458 100644 --- a/Applications/DataExplorer/DataView/MshItem.h +++ b/Applications/DataExplorer/DataView/MshItem.h @@ -36,7 +36,7 @@ public: /// \param mesh The mesh associated with this item MshItem(const QList<QVariant>& data, TreeItem* parent, const MeshLib::Mesh* mesh); - ~MshItem(); + ~MshItem() override; /// Returns the mesh. MeshLib::Mesh const* getMesh() const { return _mesh_source->GetMesh(); } diff --git a/Applications/DataExplorer/DataView/MshModel.cpp b/Applications/DataExplorer/DataView/MshModel.cpp index 5b07f989f9af8167c60747bc9786efe9b4b93ad4..3626e926f243147372025e691a1f82885c89cbc9 100644 --- a/Applications/DataExplorer/DataView/MshModel.cpp +++ b/Applications/DataExplorer/DataView/MshModel.cpp @@ -69,12 +69,12 @@ void MshModel::addMeshObject(const MeshLib::Mesh* mesh) QVariant const display_name (QString::fromStdString(mesh->getName())); QList<QVariant> meshData; meshData << display_name << "" << ""; - MshItem *const newMesh = new MshItem(meshData, _rootItem, mesh); + auto* const newMesh = new MshItem(meshData, _rootItem, mesh); _rootItem->appendChild(newMesh); // display elements std::vector<MeshLib::Element*> const& elems = mesh->getElements(); - int const nElems (static_cast<int>(elems.size())); + auto const nElems(static_cast<int>(elems.size())); for (int i = 0; i < nElems; i++) { @@ -92,7 +92,7 @@ const MeshLib::Mesh* MshModel::getMesh(const QModelIndex &idx) const { if (idx.isValid()) { - MshItem* item = dynamic_cast<MshItem*>(this->getItem(idx)); + auto* item = dynamic_cast<MshItem*>(this->getItem(idx)); if (item) return item->getMesh(); else @@ -106,7 +106,7 @@ const MeshLib::Mesh* MshModel::getMesh(const std::string &name) const { for (int i = 0; i < _rootItem->childCount(); i++) { - MshItem* item = static_cast<MshItem*>(_rootItem->child(i)); + auto* item = static_cast<MshItem*>(_rootItem->child(i)); if (item->data(0).toString().toStdString().compare(name) == 0) return item->getMesh(); } @@ -119,7 +119,7 @@ bool MshModel::removeMesh(const QModelIndex &idx) { if (idx.isValid()) { - MshItem* item = dynamic_cast<MshItem*>(this->getItem(idx)); + auto* item = dynamic_cast<MshItem*>(this->getItem(idx)); if (item) return this->removeMesh(item->getMesh()->getName()); return false; @@ -182,7 +182,7 @@ vtkUnstructuredGridAlgorithm* MshModel::vtkSource(const QModelIndex &idx) const { if (idx.isValid()) { - MshItem* item = static_cast<MshItem*>(this->getItem(idx)); + auto* item = static_cast<MshItem*>(this->getItem(idx)); return item->vtkSource(); } @@ -194,7 +194,7 @@ vtkUnstructuredGridAlgorithm* MshModel::vtkSource(const std::string &name) const { for (int i = 0; i < _rootItem->childCount(); i++) { - MshItem* item = static_cast<MshItem*>(_rootItem->child(i)); + auto* item = static_cast<MshItem*>(_rootItem->child(i)); if (item->data(0).toString().toStdString().compare(name) == 0) return item->vtkSource(); } diff --git a/Applications/DataExplorer/DataView/MshModel.h b/Applications/DataExplorer/DataView/MshModel.h index 5f2ac09098d2c7e8d6219d42be425f0d56df7d99..d18de6974674a4a6371d956c9331e0c0efa6eb4a 100644 --- a/Applications/DataExplorer/DataView/MshModel.h +++ b/Applications/DataExplorer/DataView/MshModel.h @@ -39,13 +39,13 @@ class MshModel : public TreeModel Q_OBJECT public: - MshModel(DataHolderLib::Project &project, QObject* parent = 0); + MshModel(DataHolderLib::Project& project, QObject* parent = nullptr); /// Adds a new mesh void addMesh(std::unique_ptr<MeshLib::Mesh> mesh); /// Returns the number of columns used for the data list - int columnCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; public slots: /// Adds a new mesh (using no unique_ptr as this interferes with Qt's signal/slot policy) diff --git a/Applications/DataExplorer/DataView/MshTabWidget.h b/Applications/DataExplorer/DataView/MshTabWidget.h index ec7b8196214707873a8cee714f9f3937e6fab325..4064ea215cf54e74025ae250e00c30251c11e405 100644 --- a/Applications/DataExplorer/DataView/MshTabWidget.h +++ b/Applications/DataExplorer/DataView/MshTabWidget.h @@ -25,7 +25,7 @@ class MshTabWidget : public QWidget, public Ui_MshTabWidgetBase Q_OBJECT public: - MshTabWidget(QWidget* parent = 0); + MshTabWidget(QWidget* parent = nullptr); private slots: void enableSaveButton(bool enable) { this->saveMeshPushButton->setEnabled(enable); }; diff --git a/Applications/DataExplorer/DataView/MshView.cpp b/Applications/DataExplorer/DataView/MshView.cpp index 61be12c0daf7f798bc9581a4612fb42c0e993ba9..4eb6417c486c5f67561ef3771cd1691dc330f358 100644 --- a/Applications/DataExplorer/DataView/MshView.cpp +++ b/Applications/DataExplorer/DataView/MshView.cpp @@ -54,9 +54,7 @@ MshView::MshView( QWidget* parent /*= 0*/ ) //resizeRowsToContents(); } -MshView::~MshView() -{ -} +MshView::~MshView() = default; void MshView::updateView() { @@ -76,7 +74,7 @@ void MshView::selectionChanged( const QItemSelection &selected, const QItemSelec const QModelIndex idx = *(selected.indexes().begin()); const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx); - const MshItem* list_item = dynamic_cast<const MshItem*>(tree_item); + const auto* list_item = dynamic_cast<const MshItem*>(tree_item); if (list_item) { emit enableSaveButton(true); @@ -203,7 +201,7 @@ void MshView::openValuesEditDialog() { MshModel const*const model = static_cast<MshModel*>(this->model()); QModelIndex const index = this->selectionModel()->currentIndex(); - MeshLib::Mesh* mesh = const_cast<MeshLib::Mesh*>(model->getMesh(index)); + auto* mesh = const_cast<MeshLib::Mesh*>(model->getMesh(index)); MeshValueEditDialog valueEdit(mesh); connect(&valueEdit, SIGNAL(valueEditFinished(MeshLib::Mesh*)), diff --git a/Applications/DataExplorer/DataView/MshView.h b/Applications/DataExplorer/DataView/MshView.h index 4eb055ebcd18dee33982fe8e1e2ed98e96d4e4da..a0c43ba320555330a8a61fb5d86e4745e1d1c0db 100644 --- a/Applications/DataExplorer/DataView/MshView.h +++ b/Applications/DataExplorer/DataView/MshView.h @@ -37,15 +37,16 @@ class MshView : public QTreeView Q_OBJECT public: - MshView(QWidget* parent = 0); - ~MshView(); + MshView(QWidget* parent = nullptr); + ~MshView() override; public slots: void updateView(); protected slots: /// Is called when the selection of this view changes. - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + void selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) override; private: struct MeshAction @@ -55,7 +56,7 @@ private: unsigned max_dim; }; - void contextMenuEvent( QContextMenuEvent* event ); + void contextMenuEvent(QContextMenuEvent* event) override; private slots: /// Opens a dialog for mapping 2d meshes. diff --git a/Applications/DataExplorer/DataView/NetCdfConfigureDialog.cpp b/Applications/DataExplorer/DataView/NetCdfConfigureDialog.cpp index 013ec3475ddbb60f76e1e4c6b2a995c0c34b8100..50d962384db39d77b4e1fe3546a34a67095ecddf 100644 --- a/Applications/DataExplorer/DataView/NetCdfConfigureDialog.cpp +++ b/Applications/DataExplorer/DataView/NetCdfConfigureDialog.cpp @@ -40,9 +40,7 @@ NetCdfConfigureDialog::NetCdfConfigureDialog(std::string const& fileName, QDialo this->radioMesh->setChecked(true); } -NetCdfConfigureDialog::~NetCdfConfigureDialog() -{ -} +NetCdfConfigureDialog::~NetCdfConfigureDialog() = default; // Instructions if the OK-Button has been pressed. void NetCdfConfigureDialog::accept() @@ -221,7 +219,7 @@ void NetCdfConfigureDialog::setDimensionSelect() void NetCdfConfigureDialog::getDimEdges(int dimId, unsigned &size, double &firstValue, double &lastValue) { - if ((_currentFile->get_var(_currentVar->get_dim(dimId)->name())) != NULL) + if ((_currentFile->get_var(_currentVar->get_dim(dimId)->name())) != nullptr) { NcVar *tmpVarOfDim = _currentFile->get_var(_currentVar->get_dim(dimId)->name()); if ((tmpVarOfDim->num_dims()) == 1) @@ -249,12 +247,12 @@ void NetCdfConfigureDialog::getDimEdges(int dimId, unsigned &size, double &first void NetCdfConfigureDialog::getDaysTime(double minSince, QTime &time, int &days) { - long tmpMin = (long) minSince; + auto tmpMin = (long)minSince; long minuits = tmpMin % 60; long tmpHours = tmpMin / 60; long hours = tmpHours % 24; - days = (int) (tmpHours / 24); - time.setHMS(hours,minuits,0); + days = (int)(tmpHours / 24); + time.setHMS(hours, minuits, 0); } long NetCdfConfigureDialog::convertDateToMinutes(QDateTime initialDateTime, QDate selectedDate, QTime selectedTime) @@ -313,7 +311,7 @@ double NetCdfConfigureDialog::getResolution() void NetCdfConfigureDialog::createDataObject() { - std::size_t* length = new std::size_t[_currentVar->num_dims()]; + auto* length = new std::size_t[_currentVar->num_dims()]; double originLon = 0, originLat = 0; double lastLon = 0, lastLat = 0; unsigned sizeLon = 0, sizeLat = 0; @@ -328,13 +326,13 @@ void NetCdfConfigureDialog::createDataObject() length[comboBoxDim2->currentIndex()]=sizeLon; // set up array - double* data_array = new double[sizeLat*sizeLon]; + auto* data_array = new double[sizeLat * sizeLon]; for(std::size_t i=0; i < (sizeLat*sizeLon); i++) data_array[i]=0; //Time-Dimension: if (_currentVar->num_dims() > 2) { - long* newOrigin = new long[_currentVar->num_dims()]; + auto* newOrigin = new long[_currentVar->num_dims()]; for (int i=0; i < _currentVar->num_dims(); i++) newOrigin[i]=0; newOrigin[comboBoxDim3->currentIndex()] = getTimeStep(); //set origin to selected time _currentVar->set_cur(newOrigin); @@ -409,7 +407,7 @@ std::string NetCdfConfigureDialog::getName() void NetCdfConfigureDialog::reverseNorthSouth(double* data, std::size_t width, std::size_t height) { - double* cp_array = new double[width*height]; + auto* cp_array = new double[width * height]; for (std::size_t i=0; i<height; i++) { diff --git a/Applications/DataExplorer/DataView/NetCdfConfigureDialog.h b/Applications/DataExplorer/DataView/NetCdfConfigureDialog.h index 6371f44127d85714bf6237f43fa74c139c45ae22..bbfbdf3be08cc4a650780f20420566649cb1aead 100644 --- a/Applications/DataExplorer/DataView/NetCdfConfigureDialog.h +++ b/Applications/DataExplorer/DataView/NetCdfConfigureDialog.h @@ -33,15 +33,16 @@ class NetCdfConfigureDialog : public QDialog, private Ui_NetCdfConfigure Q_OBJECT public: - NetCdfConfigureDialog(const std::string &fileName, QDialog* parent = 0); - ~NetCdfConfigureDialog(void); + NetCdfConfigureDialog(const std::string& fileName, + QDialog* parent = nullptr); + ~NetCdfConfigureDialog(void) override; MeshLib::Mesh* getMesh() { return _currentMesh; }; std::string getName(); VtkGeoImageSource* getRaster() { return _currentRaster; }; private slots: - void accept(); - void reject(); + void accept() override; + void reject() override; void on_comboBoxVariable_currentIndexChanged(int id); void on_comboBoxDim1_currentIndexChanged(int id); void on_comboBoxDim2_currentIndexChanged(int id); diff --git a/Applications/DataExplorer/DataView/SHPImportDialog.h b/Applications/DataExplorer/DataView/SHPImportDialog.h index 2b67a363c5d7d0f8726075cae9a6e30989925813..06005556061b926087940a00854efacd15b6fae8 100644 --- a/Applications/DataExplorer/DataView/SHPImportDialog.h +++ b/Applications/DataExplorer/DataView/SHPImportDialog.h @@ -43,7 +43,7 @@ public: /// Constructor SHPImportDialog(std::string filename, GeoLib::GEOObjects& geo_objects, QDialog* parent = nullptr); - ~SHPImportDialog(); + ~SHPImportDialog() override; QDialogButtonBox* _buttonBox; /// The buttons used in this dialog. @@ -62,10 +62,10 @@ private: private slots: /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; signals: void shpLoaded(QString); diff --git a/Applications/DataExplorer/DataView/SaveMeshDialog.h b/Applications/DataExplorer/DataView/SaveMeshDialog.h index 0e371636be7e7bc495298c2d887b8a342e8eea75..0f58d56ecf01211602a9ad1a5275e4b58ddea7b6 100644 --- a/Applications/DataExplorer/DataView/SaveMeshDialog.h +++ b/Applications/DataExplorer/DataView/SaveMeshDialog.h @@ -29,8 +29,8 @@ class SaveMeshDialog : public QDialog, private Ui_SaveMesh Q_OBJECT public: - SaveMeshDialog(MeshLib::Mesh const& mesh, QDialog* parent = 0); - ~SaveMeshDialog() {} + SaveMeshDialog(MeshLib::Mesh const& mesh, QDialog* parent = nullptr); + ~SaveMeshDialog() override = default; private slots: /// Selection of path to save file @@ -39,10 +39,10 @@ private slots: void on_dataModeBox_currentIndexChanged(int index); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject() { this->done(QDialog::Rejected); }; + void reject() override { this->done(QDialog::Rejected); }; private: MeshLib::Mesh const& _mesh; diff --git a/Applications/DataExplorer/DataView/SelectMeshDialog.cpp b/Applications/DataExplorer/DataView/SelectMeshDialog.cpp index d63f3934569a44668c2923ffe9ff4049a8ae199c..5291ee97d307c63bd9841e985be269fbb800ab25 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 (std::list<std::string>::const_iterator 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/SelectMeshDialog.h b/Applications/DataExplorer/DataView/SelectMeshDialog.h index dcc1c4e1f94938f324e95cdb389e2b2ea9cc3385..434aab877a5de18c248bc6614ba17909ce0f88a4 100644 --- a/Applications/DataExplorer/DataView/SelectMeshDialog.h +++ b/Applications/DataExplorer/DataView/SelectMeshDialog.h @@ -35,9 +35,9 @@ class SelectMeshDialog : public QDialog public: /// Constructor SelectMeshDialog(const GeoLib::GeoObject* geo_object, - const std::list<std::string> &msh_names, - QDialog* parent = 0); - ~SelectMeshDialog(); + const std::list<std::string>& msh_names, + QDialog* parent = nullptr); + ~SelectMeshDialog() override; QDialogButtonBox* _buttonBox; /// The buttons used in this dialog. @@ -53,10 +53,10 @@ private: private slots: /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; signals: //void requestNameChange(const std::string&, const GeoLib::GEOTYPE, std::size_t, std::string); diff --git a/Applications/DataExplorer/DataView/SetNameDialog.h b/Applications/DataExplorer/DataView/SetNameDialog.h index 5afe0ea52d4368ae1bc8e780264e824d75a5eedd..fea7b06c955e0778833c690894a0412c3bf4ff62 100644 --- a/Applications/DataExplorer/DataView/SetNameDialog.h +++ b/Applications/DataExplorer/DataView/SetNameDialog.h @@ -32,8 +32,9 @@ class SetNameDialog : public QDialog public: /// Constructor - SetNameDialog(const std::string &geo_object_type, std::size_t id, const std::string &old_name, QDialog* parent = 0); - ~SetNameDialog(); + SetNameDialog(const std::string& geo_object_type, std::size_t id, + const std::string& old_name, QDialog* parent = nullptr); + ~SetNameDialog() override; std::string getNewName(); @@ -48,8 +49,8 @@ private: private slots: /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; }; diff --git a/Applications/DataExplorer/DataView/StationTabWidget.h b/Applications/DataExplorer/DataView/StationTabWidget.h index 2cfefb80502ec26cdb05144bde582d2d38523fb0..088329da3ab0b58c58ef72a30c661fcf7563781f 100644 --- a/Applications/DataExplorer/DataView/StationTabWidget.h +++ b/Applications/DataExplorer/DataView/StationTabWidget.h @@ -25,7 +25,7 @@ class StationTabWidget : public QWidget, public Ui_StationTabWidgetBase Q_OBJECT public: - StationTabWidget(QWidget* parent = 0); + StationTabWidget(QWidget* parent = nullptr); private: diff --git a/Applications/DataExplorer/DataView/StationTreeModel.cpp b/Applications/DataExplorer/DataView/StationTreeModel.cpp index 4020cdbd2d9cc2ea11ed15921d879cc4730fc6be..c80ac9421853bccecdcc3836b719eca20df504d6 100644 --- a/Applications/DataExplorer/DataView/StationTreeModel.cpp +++ b/Applications/DataExplorer/DataView/StationTreeModel.cpp @@ -34,9 +34,7 @@ StationTreeModel::StationTreeModel( QObject* parent ) _rootItem = new ModelTreeItem(rootData, nullptr, nullptr); } -StationTreeModel::~StationTreeModel() -{ -} +StationTreeModel::~StationTreeModel() = default; /** * Returns the model index of an item in the tree. @@ -58,7 +56,7 @@ QModelIndex StationTreeModel::index( int row, int column, else parentItem = static_cast<ModelTreeItem*>(parent.internalPointer()); - ModelTreeItem* childItem = (ModelTreeItem*)(parentItem->child(row)); + auto* childItem = (ModelTreeItem*)(parentItem->child(row)); if (childItem) { QModelIndex newIndex = createIndex(row, column, childItem); @@ -83,7 +81,7 @@ GeoLib::Station* StationTreeModel::stationFromIndex( const QModelIndex& index, { if (index.isValid()) { - ModelTreeItem* treeItem = static_cast<ModelTreeItem*>(index.internalPointer()); + auto* treeItem = static_cast<ModelTreeItem*>(index.internalPointer()); TreeItem* parentItem = treeItem->parentItem(); listName = parentItem->data(0).toString(); return treeItem->getStation(); @@ -132,7 +130,8 @@ void StationTreeModel::addStationList(QString listName, const std::vector<GeoLib listName.append(QString::number(rowCount() + 1)); } grpName << listName << "" << "" << ""; - ModelTreeItem* group = new ModelTreeItem(grpName, _rootItem, new BaseItem(listName, stations)); + auto* group = + new ModelTreeItem(grpName, _rootItem, new BaseItem(listName, stations)); _lists.push_back(group); _rootItem->appendChild(group); int vectorSize = stations->size(); @@ -145,7 +144,7 @@ void StationTreeModel::addStationList(QString listName, const std::vector<GeoLib << QString::number((*(*stations)[i])[1],'f') << QString::number((*(*stations)[i])[2],'f'); - ModelTreeItem* child = new ModelTreeItem(stn, group); + auto* child = new ModelTreeItem(stn, group); child->setStation(static_cast<GeoLib::Station*>((*stations)[i])); group->appendChild(child); } @@ -162,7 +161,7 @@ void StationTreeModel::removeStationList(QModelIndex index) { if (index.isValid()) // { - ModelTreeItem* item = static_cast<ModelTreeItem*>(getItem(index)); + auto* item = static_cast<ModelTreeItem*>(getItem(index)); // also delete the lists entry in the list directory of the model for (std::size_t i = 0; i < _lists.size(); i++) @@ -179,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/StationTreeModel.h b/Applications/DataExplorer/DataView/StationTreeModel.h index a303250304a768eeb14f82ff6ce95e68a0c1ba01..9197fffb5fcdca3bc182d610f2b22a889f708e17 100644 --- a/Applications/DataExplorer/DataView/StationTreeModel.h +++ b/Applications/DataExplorer/DataView/StationTreeModel.h @@ -43,12 +43,13 @@ class StationTreeModel : public TreeModel Q_OBJECT public: - StationTreeModel(QObject* parent = 0); - ~StationTreeModel(); + StationTreeModel(QObject* parent = nullptr); + ~StationTreeModel() override; void addStationList(QString listName, const std::vector<GeoLib::Point*>* stations); const std::vector<ModelTreeItem*> &getLists() { return _lists; } - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex index(int row, int column, + const QModelIndex& parent = QModelIndex()) const override; //BaseItem* itemFromIndex( const QModelIndex& index ) const; void removeStationList(QModelIndex index); void removeStationList(const std::string &name); diff --git a/Applications/DataExplorer/DataView/StationTreeView.cpp b/Applications/DataExplorer/DataView/StationTreeView.cpp index 12324f68eda2ddd35c184524145ab23269931cef..a9eb0800143639e66f0b3f4653df264ba37d44f9 100644 --- a/Applications/DataExplorer/DataView/StationTreeView.cpp +++ b/Applications/DataExplorer/DataView/StationTreeView.cpp @@ -50,7 +50,8 @@ void StationTreeView::selectionChanged( const QItemSelection &selected, const QModelIndex idx = *(selected.indexes().begin()); const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx); - const ModelTreeItem* list_item = dynamic_cast<const ModelTreeItem*>(tree_item->parentItem()); + const auto* list_item = + dynamic_cast<const ModelTreeItem*>(tree_item->parentItem()); if (list_item->getItem()) { if (list_item) @@ -85,7 +86,7 @@ void StationTreeView::selectionChangedFromOutside( const QItemSelection &selecte void StationTreeView::contextMenuEvent( QContextMenuEvent* event ) { QModelIndex index = this->selectionModel()->currentIndex(); - ModelTreeItem* item = static_cast<ModelTreeItem*>(index.internalPointer()); + auto* item = static_cast<ModelTreeItem*>(index.internalPointer()); if (!item) // Otherwise sometimes it crashes when (unmotivated ;-) ) clicking in a treeview return; @@ -147,8 +148,11 @@ void StationTreeView::displayStratigraphy() std::map<std::string, DataHolderLib::Color> colorLookupTable = static_cast<VtkStationSource*>(static_cast<StationTreeModel*> (model())->vtkSource(temp_name.toStdString()))->getColorLookupTable(); - StratWindow* stratView = new StratWindow(static_cast<GeoLib::StationBorehole*> - (static_cast<StationTreeModel*>(model())->stationFromIndex(index,temp_name)), &colorLookupTable); + auto* stratView = new StratWindow( + static_cast<GeoLib::StationBorehole*>( + static_cast<StationTreeModel*>(model())->stationFromIndex( + index, temp_name)), + &colorLookupTable); stratView->setAttribute(Qt::WA_DeleteOnClose); // this fixes the memory leak shown by cppcheck stratView->show(); } @@ -250,14 +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) { - StratWindow* 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/DataView/StationTreeView.h b/Applications/DataExplorer/DataView/StationTreeView.h index 3b5ed7c73e3b526c7e44d3b45213aac92684b2c5..f2155fd7c7cfa35117d245410b91d5cad2722a04 100644 --- a/Applications/DataExplorer/DataView/StationTreeView.h +++ b/Applications/DataExplorer/DataView/StationTreeView.h @@ -31,7 +31,7 @@ class StationTreeView : public QTreeView public: /// Constructor - StationTreeView(QWidget* parent = 0); + StationTreeView(QWidget* parent = nullptr); /// Update the view to visualise changes made to the underlying data void updateView(); @@ -41,7 +41,8 @@ public slots: protected slots: /// Instructions if the selection of items in the view has changed. - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + void selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) override; /// Instructions if the selection of items in the view has changed by events outside the view (i.e. by actions made in the visualisation). void selectionChangedFromOutside(const QItemSelection &selected, @@ -49,7 +50,7 @@ protected slots: private: /// Actions to be taken after a right mouse click is performed in the station view. - void contextMenuEvent( QContextMenuEvent* e ); + void contextMenuEvent(QContextMenuEvent* e) override; /// Create image files from all stratigraphies in a borehole vector void writeStratigraphiesAsImages(QString listName); diff --git a/Applications/DataExplorer/DataView/StratView/StratBar.h b/Applications/DataExplorer/DataView/StratView/StratBar.h index 66b39987ab20ea4468161e92cbd7617016861ecd..1362a7a936838d4386aea68a81b68a30f6c5f1a0 100644 --- a/Applications/DataExplorer/DataView/StratView/StratBar.h +++ b/Applications/DataExplorer/DataView/StratView/StratBar.h @@ -37,14 +37,16 @@ public: */ StratBar(GeoLib::StationBorehole* station, std::map<std::string, DataHolderLib::Color>* stratColors = nullptr, - QGraphicsItem* parent = 0); - ~StratBar(); + QGraphicsItem* parent = nullptr); + ~StratBar() override; /// Returns the bounding rectangle of the bar. - QRectF boundingRect() const; + QRectF boundingRect() const override; /// Paints the bar. - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); + void paint(QPainter* painter, + const QStyleOptionGraphicsItem* option, + QWidget* widget) override; private: /** diff --git a/Applications/DataExplorer/DataView/StratView/StratScene.cpp b/Applications/DataExplorer/DataView/StratView/StratScene.cpp index 698ce49999ccafd99cc9ba0c82442522359154e3..6ad50d170bfa038758b7eea8b2d675661719e591 100644 --- a/Applications/DataExplorer/DataView/StratView/StratScene.cpp +++ b/Applications/DataExplorer/DataView/StratView/StratScene.cpp @@ -58,14 +58,12 @@ StratScene::StratScene(GeoLib::StationBorehole* station, addDepthLabels(station->getProfile(), stratBarOffset + stratBarBounds.width()); - if (station->getSoilNames().size() > 0) + if (!station->getSoilNames().empty()) addSoilNameLabels(station->getSoilNames(), station->getProfile(), stratBarOffset + (stratBarBounds.width() / 2)); } -StratScene::~StratScene() -{ -} +StratScene::~StratScene() = default; void StratScene::addDepthLabels(std::vector<GeoLib::Point*> profile, double offset) { @@ -87,7 +85,7 @@ void StratScene::addDepthLabels(std::vector<GeoLib::Point*> profile, double offs QNonScalableGraphicsTextItem* StratScene::addNonScalableText(const QString &text, const QFont &font) { - QNonScalableGraphicsTextItem* item = new QNonScalableGraphicsTextItem(text); + auto* item = new QNonScalableGraphicsTextItem(text); item->setFont(font); addItem(item); return item; @@ -117,7 +115,7 @@ void StratScene::addSoilNameLabels(std::vector<std::string> soilNames, StratBar* StratScene::addStratBar(GeoLib::StationBorehole* station, std::map<std::string, DataHolderLib::Color>* stratColors) { - StratBar* b = new StratBar(station, stratColors); + auto* b = new StratBar(station, stratColors); addItem(b); return b; } diff --git a/Applications/DataExplorer/DataView/StratView/StratScene.h b/Applications/DataExplorer/DataView/StratView/StratScene.h index 03fb668834335cb265190715b55f57017156c65d..8bcf28e3e291b58e93e253215a6602a98e348985 100644 --- a/Applications/DataExplorer/DataView/StratView/StratScene.h +++ b/Applications/DataExplorer/DataView/StratView/StratScene.h @@ -29,10 +29,11 @@ class StratScene : public QGraphicsScene { public: /// Constructor - StratScene(GeoLib::StationBorehole* station, - std::map<std::string, DataHolderLib::Color>* stratColors = nullptr, - QObject* parent = 0); - ~StratScene(); + StratScene( + GeoLib::StationBorehole* station, + std::map<std::string, DataHolderLib::Color>* stratColors = nullptr, + QObject* parent = nullptr); + ~StratScene() override; /// The margin between the boundary of the scene and the bounding box of all items within the scene static const int MARGIN = 50; diff --git a/Applications/DataExplorer/DataView/StratView/StratView.h b/Applications/DataExplorer/DataView/StratView/StratView.h index b55b30db4eb436cfd4281c84c23d13d9e41d0257..d405a8fc94445a56121499f6b1b2dc7cf92b9c9e 100644 --- a/Applications/DataExplorer/DataView/StratView/StratView.h +++ b/Applications/DataExplorer/DataView/StratView/StratView.h @@ -34,8 +34,8 @@ public: /** * Creates an empty view. */ - StratView(QWidget* parent = 0) : _scene(NULL) {Q_UNUSED(parent); } - ~StratView(); + StratView(QWidget* parent = nullptr) : _scene(nullptr) { Q_UNUSED(parent); } + ~StratView() override; /// Sets the Borehole whose data should be visualised. void setStation(GeoLib::StationBorehole* station, @@ -51,17 +51,23 @@ public: protected: /// Resizes the scene. - void resizeEvent(QResizeEvent* event); + void resizeEvent(QResizeEvent* event) override; private: /// Initialises the view. void initialize(); /// The minimum size of the window. - QSize minimumSizeHint() const { return QSize(3 * _scene->MARGIN,2 * _scene->MARGIN); } + QSize minimumSizeHint() const override + { + return QSize(3 * _scene->MARGIN, 2 * _scene->MARGIN); + } /// The default size of the window. - QSize sizeHint() const { return QSize(6 * _scene->MARGIN, 4 * _scene->MARGIN); } + QSize sizeHint() const override + { + return QSize(6 * _scene->MARGIN, 4 * _scene->MARGIN); + } /// Updates the view automatically when a Borehole is added or when the window containing the view changes its state. void update(); diff --git a/Applications/DataExplorer/DataView/StratView/StratWindow.h b/Applications/DataExplorer/DataView/StratView/StratWindow.h index 16da35d466fd9ed4b98ee03533571a8c727a70a1..741e382a19774ce11a48fe8062769c87555a98cf 100644 --- a/Applications/DataExplorer/DataView/StratView/StratWindow.h +++ b/Applications/DataExplorer/DataView/StratView/StratWindow.h @@ -36,10 +36,11 @@ public: * \param stratColors A color map. * \param parent The parent QWidget. */ - StratWindow(GeoLib::StationBorehole* station, - std::map<std::string, DataHolderLib::Color>* stratColors = nullptr, - QWidget* parent = 0); - ~StratWindow(void) { this->destroy(); } + StratWindow( + GeoLib::StationBorehole* station, + std::map<std::string, DataHolderLib::Color>* stratColors = nullptr, + QWidget* parent = nullptr); + ~StratWindow(void) override { this->destroy(); } private: /// Automatically resize window based on the measurements of the borehole. diff --git a/Applications/DataExplorer/DataView/SurfaceExtractionDialog.h b/Applications/DataExplorer/DataView/SurfaceExtractionDialog.h index ad482c3b457ec8a9c7067e08fe61cbb399bfd93b..c395fe0dfbdb4983ea197a5677fba442972dad95 100644 --- a/Applications/DataExplorer/DataView/SurfaceExtractionDialog.h +++ b/Applications/DataExplorer/DataView/SurfaceExtractionDialog.h @@ -31,18 +31,18 @@ class SurfaceExtractionDialog : public QDialog, private Ui_SurfaceExtraction Q_OBJECT public: - SurfaceExtractionDialog(QDialog* parent = 0); - ~SurfaceExtractionDialog() {} + SurfaceExtractionDialog(QDialog* parent = nullptr); + ~SurfaceExtractionDialog() override = default; int getTolerance() const { return _tolerance; } MathLib::Vector3 const& getNormal() const { return _dir; } private slots: /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject() { this->done(QDialog::Rejected); }; + void reject() override { this->done(QDialog::Rejected); }; private: int _tolerance; diff --git a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp index dffd5363bf08a12fdec578723ae41104b61a0d6c..9d4b1536f444e99fd626f1a6e3d931fbc646104a 100644 --- a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp +++ b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp @@ -26,11 +26,7 @@ MeshFromRasterDialog::MeshFromRasterDialog(QDialog* parent) this->mshNameEdit->setText("RasterDataMesh"); } - -MeshFromRasterDialog::~MeshFromRasterDialog() -{ -} - +MeshFromRasterDialog::~MeshFromRasterDialog() = default; void MeshFromRasterDialog::accept() { diff --git a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.h b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.h index e474792a216fd377f608970cbedffbfd4d148977..2933ef04c093fe1f4882d11bb68532930dd702ec 100644 --- a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.h +++ b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.h @@ -34,8 +34,8 @@ class MeshFromRasterDialog : public QDialog, private Ui_MeshFromRaster public: /// Constructor - MeshFromRasterDialog(QDialog* parent = 0); - ~MeshFromRasterDialog(void); + MeshFromRasterDialog(QDialog* parent = nullptr); + ~MeshFromRasterDialog(void) override; std::string getMeshName() const { return _mesh_name; } std::string getArrayName() const { return _array_name; } @@ -44,10 +44,10 @@ public: private slots: /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); + void reject() override; private: std::string _mesh_name; diff --git a/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.cpp b/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.cpp index 713b12a9ade385f9b6513e0c711e39ce3e7a7772..cc08997b3a0ff2de71ff5d3c5ab3314e48615889 100644 --- a/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.cpp +++ b/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.cpp @@ -19,14 +19,11 @@ vtkStandardNewMacro(QVtkDataSetMapper); -QVtkDataSetMapper::QVtkDataSetMapper() - : QObject(NULL) +QVtkDataSetMapper::QVtkDataSetMapper() : QObject(nullptr) { } -QVtkDataSetMapper::~QVtkDataSetMapper() -{ -} +QVtkDataSetMapper::~QVtkDataSetMapper() = default; void QVtkDataSetMapper::PrintSelf(ostream& os, vtkIndent indent) { diff --git a/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.h b/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.h index 99d2fc1ffb377d66439779c859e03dffa92293e1..b1be9f97073941c0b029b002938bb3ca5133eade 100644 --- a/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.h +++ b/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.h @@ -34,7 +34,7 @@ public: public slots: /// @brief Sets the scalar visibility on this mapper. virtual void SetScalarVisibility(bool on); - virtual void SetScalarVisibility(int on) override + void SetScalarVisibility(int on) override { SetScalarVisibility(static_cast<bool>(on)); } @@ -44,7 +44,7 @@ protected: QVtkDataSetMapper(); /// @brief Destructor. - virtual ~QVtkDataSetMapper(); + ~QVtkDataSetMapper() override; private: QVtkDataSetMapper(const QVtkDataSetMapper&); // Not implemented. diff --git a/Applications/DataExplorer/VtkVis/VisualizationWidget.h b/Applications/DataExplorer/VtkVis/VisualizationWidget.h index 68aadb2abcf4f590a393955b0e22004a93c4cc69..4689cb336c58ee94e23961839a4ea6f438d3a98b 100644 --- a/Applications/DataExplorer/VtkVis/VisualizationWidget.h +++ b/Applications/DataExplorer/VtkVis/VisualizationWidget.h @@ -32,10 +32,10 @@ class VisualizationWidget : public QWidget, public Ui_VisualizationWidgetBase public: /// @brief Constructor. - VisualizationWidget(QWidget* parent = 0); + VisualizationWidget(QWidget* parent = nullptr); /// @brief Destructor. - ~VisualizationWidget(); + ~VisualizationWidget() override; /// @brief Returns the VtkCustomInteractorStyle. VtkCustomInteractorStyle* interactorStyle() const; diff --git a/Applications/DataExplorer/VtkVis/VtkAddFilterDialog.cpp b/Applications/DataExplorer/VtkVis/VtkAddFilterDialog.cpp index ed7d9165e3ef81bdaa42bd5ac4064572b5bddae9..f5772e222350f98b80bc06808d735153822bc867 100644 --- a/Applications/DataExplorer/VtkVis/VtkAddFilterDialog.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAddFilterDialog.cpp @@ -38,8 +38,8 @@ VtkAddFilterDialog::VtkAddFilterDialog( VtkVisPipeline &pipeline, setupUi(this); filterListWidget->setSelectionMode(QAbstractItemView::SingleSelection); - VtkVisPipelineItem* parentItem = - static_cast<VtkVisPipelineItem*>(_pipeline.getItem(parentIndex)); + auto* parentItem = + static_cast<VtkVisPipelineItem*>(_pipeline.getItem(parentIndex)); vtkDataObject* parentDataObject = parentItem->algorithm()->GetOutputDataObject(0); int parentDataObjectType = parentDataObject->GetDataObjectType(); @@ -74,8 +74,8 @@ void VtkAddFilterDialog::on_buttonBox_accepted() break; } } - VtkVisPipelineItem* parentItem = - static_cast<VtkVisPipelineItem*>(_pipeline.getItem(_parentIndex)); + auto* parentItem = + static_cast<VtkVisPipelineItem*>(_pipeline.getItem(_parentIndex)); QList<QVariant> itemData; itemData << filterListWidget->currentItem()->text() << true; diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp index 946c2ba30b58437875e962a6d606814563c537f7..2891723f45194e5f6186ab5d0327e084637fb578 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp @@ -41,16 +41,15 @@ VtkAlgorithmProperties::~VtkAlgorithmProperties() _property->Delete(); if (_texture != nullptr) _texture->Delete(); - for (std::map<QString, vtkLookupTable*>::iterator it = _lut.begin(); - it != _lut.end(); ++it) - it->second->Delete(); + for (auto& row : _lut) + row.second->Delete(); delete _algorithmUserProperties; delete _algorithmUserVectorProperties; } vtkLookupTable* VtkAlgorithmProperties::GetLookupTable(const QString& array_name) { - std::map<QString, vtkLookupTable*>::iterator it = _lut.find(array_name); + auto it = _lut.find(array_name); if (it != _lut.end()) return it->second; else @@ -59,7 +58,7 @@ vtkLookupTable* VtkAlgorithmProperties::GetLookupTable(const QString& array_name void VtkAlgorithmProperties::RemoveLookupTable(const QString& array_name) { - std::map<QString, vtkLookupTable*>::iterator it = _lut.find(array_name); + auto it = _lut.find(array_name); if (it != _lut.end()) { it->second->Delete(); diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.h b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.h index 56be66388ad586430d205fcd091ce02e9ad4c141..e78dafe30bc11ccc7313ce0892e550ff868fda0a 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.h +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.h @@ -140,9 +140,9 @@ class VtkAlgorithmProperties : public QObject public: /// Constructor (sets default values) - VtkAlgorithmProperties(QObject* parent = NULL); + VtkAlgorithmProperties(QObject* parent = nullptr); - virtual ~VtkAlgorithmProperties(); + ~VtkAlgorithmProperties() override; /// @brief Returns the vtk properties vtkProperty* GetProperties() const { return _property; } diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.cpp index 8b94191ded896be564de23d411dfb735bb25f90c..490728c3ecb2ead5005f272ef9093d70e40be4d8 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.cpp @@ -13,26 +13,27 @@ */ // ** INCLUDES ** +#include <utility> + #include "VtkAlgorithmPropertyCheckbox.h" #include "VtkAlgorithmProperties.h" -VtkAlgorithmPropertyCheckbox::VtkAlgorithmPropertyCheckbox(const bool value, - const QString& name, - VtkAlgorithmProperties* algProps, - QWidget* parent /*= 0*/ ) - : QCheckBox(parent), _name(name), _algProps(algProps) +VtkAlgorithmPropertyCheckbox::VtkAlgorithmPropertyCheckbox( + const bool value, + QString name, + VtkAlgorithmProperties* algProps, + QWidget* parent /*= 0*/) + : QCheckBox(parent), _name(std::move(name)), _algProps(algProps) { this->setChecked(value); connect(this, SIGNAL(stateChanged(int)), this, SLOT(setNewValue(int))); } -VtkAlgorithmPropertyCheckbox::~VtkAlgorithmPropertyCheckbox() -{ -} +VtkAlgorithmPropertyCheckbox::~VtkAlgorithmPropertyCheckbox() = default; void VtkAlgorithmPropertyCheckbox::setNewValue( int state ) { - bool boolState = (bool)state; + auto boolState = (bool)state; _algProps->SetUserProperty(_name, QVariant(boolState)); } diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.h b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.h index 3ed35df96e37b38e1b484e12202f750238be7c33..1ea61b6c950616337d30df605de91799046e3fb2 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.h +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.h @@ -30,11 +30,12 @@ public: /// @param name The name of the user property to set. /// @param algProps The VtkAlgorithmProperties object. /// @param parent The parent widget. - VtkAlgorithmPropertyCheckbox(const bool value, const QString& name, - VtkAlgorithmProperties* algProps, QWidget* parent = 0); + VtkAlgorithmPropertyCheckbox(const bool value, QString name, + VtkAlgorithmProperties* algProps, + QWidget* parent = nullptr); /// @brief Destructor. - virtual ~VtkAlgorithmPropertyCheckbox(); + ~VtkAlgorithmPropertyCheckbox() override; private: const QString _name; diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.cpp index 8b38bb492d0d62253ff3203d66d55857747c6f15..3877f75d24e4e5771c7fca26c74dcdedb9510213 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.cpp @@ -19,13 +19,18 @@ #include <QDoubleValidator> #include <QIntValidator> - -VtkAlgorithmPropertyLineEdit::VtkAlgorithmPropertyLineEdit(const QString& contents, - const QString& name, - QVariant::Type type, - VtkAlgorithmProperties* algProps, - QWidget* parent /*= 0*/) - : QLineEdit(contents, parent), _name(name), _algProps(algProps), _type(type) +#include <utility> + +VtkAlgorithmPropertyLineEdit::VtkAlgorithmPropertyLineEdit( + const QString& contents, + QString name, + QVariant::Type type, + VtkAlgorithmProperties* algProps, + QWidget* parent /*= 0*/) + : QLineEdit(contents, parent), + _name(std::move(name)), + _algProps(algProps), + _type(type) { switch(_type) { @@ -44,9 +49,7 @@ VtkAlgorithmPropertyLineEdit::VtkAlgorithmPropertyLineEdit(const QString& conten connect(this, SIGNAL(editingFinished()), this, SLOT(setNewValue())); } -VtkAlgorithmPropertyLineEdit::~VtkAlgorithmPropertyLineEdit() -{ -} +VtkAlgorithmPropertyLineEdit::~VtkAlgorithmPropertyLineEdit() = default; void VtkAlgorithmPropertyLineEdit::setNewValue() { diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.h b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.h index 6045b33e291b29f11d61ec44e99caefbf296f225..d34ab370662825b7fc9a871e78c285d40cef8aff 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.h +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.h @@ -34,11 +34,11 @@ public: /// @param algProps The VtkAlgorithmProperties object. /// @param parent The parent widget. VtkAlgorithmPropertyLineEdit(const QString& contents, - const QString& name, + QString name, QVariant::Type type, VtkAlgorithmProperties* algProps, - QWidget* parent = 0); - virtual ~VtkAlgorithmPropertyLineEdit(); + QWidget* parent = nullptr); + ~VtkAlgorithmPropertyLineEdit() override; private: const QString _name; diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.cpp index 433e06cf8ed5da7cea1055330afe2078c65a1cbc..b278a4b4ca5a81b101231f0a1911535dee310b53 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.cpp @@ -22,21 +22,23 @@ #include <QIntValidator> #include <QLineEdit> #include <QSize> +#include <utility> -VtkAlgorithmPropertyVectorEdit::VtkAlgorithmPropertyVectorEdit( const QList<QString> contents, - const QString& name, - QVariant::Type type, - VtkAlgorithmProperties* algProps, - QWidget* parent /*= 0*/ ) - : QWidget(parent), _name(name), _algProps(algProps), _type(type) +VtkAlgorithmPropertyVectorEdit::VtkAlgorithmPropertyVectorEdit( + const QList<QString> contents, + QString name, + QVariant::Type type, + VtkAlgorithmProperties* algProps, + QWidget* parent /*= 0*/) + : QWidget(parent), _name(std::move(name)), _algProps(algProps), _type(type) { - QHBoxLayout* layout = new QHBoxLayout; + auto* layout = new QHBoxLayout; layout->setSpacing(3); layout->setContentsMargins(0, 0, 0, 0); foreach(QString content, contents) { - QLineEdit* lineEdit = new QLineEdit(content, this); + auto* lineEdit = new QLineEdit(content, this); layout->addWidget(lineEdit); switch(_type) @@ -60,9 +62,7 @@ VtkAlgorithmPropertyVectorEdit::VtkAlgorithmPropertyVectorEdit( const QList<QStr this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); } -VtkAlgorithmPropertyVectorEdit::~VtkAlgorithmPropertyVectorEdit() -{ -} +VtkAlgorithmPropertyVectorEdit::~VtkAlgorithmPropertyVectorEdit() = default; void VtkAlgorithmPropertyVectorEdit::setNewValue() { @@ -70,7 +70,7 @@ void VtkAlgorithmPropertyVectorEdit::setNewValue() QList<QVariant> list; for (int i = 0; i < layout->count(); ++i) { - QLineEdit* lineEdit = static_cast<QLineEdit*>(layout->itemAt(i)->widget()); + auto* lineEdit = static_cast<QLineEdit*>(layout->itemAt(i)->widget()); list.push_back(QVariant(lineEdit->text())); } diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.h b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.h index c697818960a5dcb5b8ddedcd0ba54cae3a9f2f37..04223b83f888576c9ab9674875111a05f6835d9c 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.h +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.h @@ -34,11 +34,11 @@ public: /// @param algProps The VtkAlgorithmProperties object. /// @param parent The parent widget. VtkAlgorithmPropertyVectorEdit(const QList<QString> contents, - const QString& name, + QString name, QVariant::Type type, VtkAlgorithmProperties* algProps, - QWidget* parent = 0); - virtual ~VtkAlgorithmPropertyVectorEdit(); + QWidget* parent = nullptr); + ~VtkAlgorithmPropertyVectorEdit() override; private: const QString _name; diff --git a/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.cpp b/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.cpp index 2c4ae55b67402c8be4a1e23e04f46e5ffda94488..76c39d92adb6890379363b96624f5263834c5ab8 100644 --- a/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.cpp @@ -29,13 +29,9 @@ vtkStandardNewMacro(VtkAppendArrayFilter); -VtkAppendArrayFilter::VtkAppendArrayFilter() -{ -} +VtkAppendArrayFilter::VtkAppendArrayFilter() = default; -VtkAppendArrayFilter::~VtkAppendArrayFilter() -{ -} +VtkAppendArrayFilter::~VtkAppendArrayFilter() = default; void VtkAppendArrayFilter::PrintSelf( ostream& os, vtkIndent indent ) { diff --git a/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.h b/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.h index 46e04876f82004c7efd6313187f930b306aca667..176b040572d09dcda381855a47c2a5747145c401 100644 --- a/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.h @@ -46,7 +46,7 @@ public: protected: VtkAppendArrayFilter(); - ~VtkAppendArrayFilter(); + ~VtkAppendArrayFilter() override; /// @brief The filter logic. int RequestData(vtkInformation* request, diff --git a/Applications/DataExplorer/VtkVis/VtkBGImageSource.cpp b/Applications/DataExplorer/VtkVis/VtkBGImageSource.cpp index b5e55bbed71fb6c976539ef696d98c0ac5c2369f..844500b2454cc8368ddf3a8a29883e5a8cbe52cf 100644 --- a/Applications/DataExplorer/VtkVis/VtkBGImageSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkBGImageSource.cpp @@ -34,9 +34,7 @@ VtkBGImageSource::VtkBGImageSource() : _origin(0,0), _cellsize(1) { } -VtkBGImageSource::~VtkBGImageSource() -{ -} +VtkBGImageSource::~VtkBGImageSource() = default; void VtkBGImageSource::SetRaster(vtkImageAlgorithm *img, double x0, double y0, double scalingFactor) { diff --git a/Applications/DataExplorer/VtkVis/VtkBGImageSource.h b/Applications/DataExplorer/VtkVis/VtkBGImageSource.h index 897122f87ee7cf31164500c2364487be2821c8e6..5c5b8d49b2fa39f4148fe0f87ed1bc7950bccc9a 100644 --- a/Applications/DataExplorer/VtkVis/VtkBGImageSource.h +++ b/Applications/DataExplorer/VtkVis/VtkBGImageSource.h @@ -36,11 +36,11 @@ public: /// Sets the raster/image to be used as a texture map void SetRaster(vtkImageAlgorithm *img, double x0, double y0, double scalingFactor); - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; protected: VtkBGImageSource(); - ~VtkBGImageSource(); + ~VtkBGImageSource() override; private: diff --git a/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.cpp b/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.cpp index 7b85f0b657ed0236cc9ebd82dab876cf4a5e8fb7..6c4771cc976323500c9c935d2cd4d97dd25a1016 100644 --- a/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.cpp @@ -37,9 +37,7 @@ VtkColorByHeightFilter::VtkColorByHeightFilter() { } -VtkColorByHeightFilter::~VtkColorByHeightFilter() -{ -} +VtkColorByHeightFilter::~VtkColorByHeightFilter() = default; void VtkColorByHeightFilter::PrintSelf( ostream& os, vtkIndent indent ) { diff --git a/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.h b/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.h index e23e3beaec3c587e3db635fec953427bb04d96a5..76e738a44cf9d3d528201f5c594bf631e5e6f95e 100644 --- a/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.h @@ -49,7 +49,7 @@ public: vtkGetObjectMacro(ColorLookupTable,VtkColorLookupTable); /// @brief This filter gets updated when the color look-up table was modified. - virtual vtkMTimeType GetMTime() override; + vtkMTimeType GetMTime() override; /// @brief Sets user properties. void SetUserProperty(QString name, QVariant value) override @@ -67,7 +67,7 @@ public: protected: VtkColorByHeightFilter(); - ~VtkColorByHeightFilter(); + ~VtkColorByHeightFilter() override; /// @brief The filter logic. int RequestData(vtkInformation* request, diff --git a/Applications/DataExplorer/VtkVis/VtkColorLookupTable.cpp b/Applications/DataExplorer/VtkVis/VtkColorLookupTable.cpp index 2adcfed1ca70ff5601817c03c784c91c3913983a..f18205aaaeef1f35cc02a0d0fecfdaccb1d944b1 100644 --- a/Applications/DataExplorer/VtkVis/VtkColorLookupTable.cpp +++ b/Applications/DataExplorer/VtkVis/VtkColorLookupTable.cpp @@ -66,26 +66,33 @@ void VtkColorLookupTable::Build() std::pair<std::size_t, unsigned char*> lastValue(0, startcolor); std::size_t nextIndex(0); - for (std::map<double, unsigned char*>::const_iterator it = _dict.begin(); it != _dict.end(); ++it) + for (auto it = _dict.begin(); it != _dict.end(); ++it) { - double val = (it->first < range[0]) ? range[0] : ((it->first > range[1]) ? range[1] : it->first); - nextIndex = static_cast<std::size_t>( std::floor(val-range[0]) ); + double val = (it->first < range[0]) + ? range[0] + : ((it->first > range[1]) ? range[1] : it->first); + nextIndex = static_cast<std::size_t>(std::floor(val - range[0])); this->SetTableValueRGBA(nextIndex, it->second); - if ( nextIndex - lastValue.first > 0 ) + if (nextIndex - lastValue.first > 0) for (std::size_t i = lastValue.first + 1; i < nextIndex; i++) { unsigned char int_rgba[4]; - double pos = (i - lastValue.first) / (static_cast<double>(nextIndex - lastValue.first)); + double pos = + (i - lastValue.first) / + (static_cast<double>(nextIndex - lastValue.first)); if (_type == DataHolderLib::LUTType::LINEAR) for (std::size_t j = 0; j < 4; j++) - int_rgba[j] = linInterpolation( (lastValue.second)[j], (it->second)[j], pos); + int_rgba[j] = linInterpolation( + (lastValue.second)[j], (it->second)[j], pos); else if (_type == DataHolderLib::LUTType::EXPONENTIAL) for (std::size_t j = 0; j < 4; j++) - int_rgba[j] = expInterpolation((lastValue.second)[j], (it->second)[j], 0.2, pos); - else // no interpolation + int_rgba[j] = + expInterpolation((lastValue.second)[j], + (it->second)[j], 0.2, pos); + else // no interpolation for (std::size_t j = 0; j < 4; j++) int_rgba[j] = (lastValue.second)[j]; @@ -150,7 +157,7 @@ void VtkColorLookupTable::GetTableValue(vtkIdType idx, unsigned char rgba[4]) void VtkColorLookupTable::setColor(double pos, DataHolderLib::Color const& color) { - unsigned char* dict_rgba = new unsigned char[4]; + auto* dict_rgba = new unsigned char[4]; for (std::size_t i = 0; i < 4; i++) dict_rgba[i] = color[i]; _dict.insert( std::pair<double, unsigned char*>(pos, dict_rgba) ); diff --git a/Applications/DataExplorer/VtkVis/VtkColorLookupTable.h b/Applications/DataExplorer/VtkVis/VtkColorLookupTable.h index 7745fb883846af6fe2e0de4fd281d944854b250b..9fe7fc48ec0c306f2cbf14a7f4c013ac672157f5 100644 --- a/Applications/DataExplorer/VtkVis/VtkColorLookupTable.h +++ b/Applications/DataExplorer/VtkVis/VtkColorLookupTable.h @@ -82,7 +82,7 @@ protected: VtkColorLookupTable(); /// Destructor - ~VtkColorLookupTable(); + ~VtkColorLookupTable() override; private: /// Interpolates values linearly. diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeColorByHeightFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeColorByHeightFilter.h index 09a6254222a56b0d99c8a76fc3015cd43d5ecc9a..05e8788b2eee1db9a74da85169cdd6038983a052 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeColorByHeightFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeColorByHeightFilter.h @@ -23,11 +23,11 @@ class VtkCompositeColorByHeightFilter : public VtkCompositeFilter { public: VtkCompositeColorByHeightFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeColorByHeightFilter() {} + ~VtkCompositeColorByHeightFilter() override = default; - virtual void init() override; + void init() override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; protected: }; diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.cpp index 29d4cea5e64b688c3d27f0d0db1e61a87f836071..35b75e94f9f7bf0a09b9532a879f300e29a36769 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.cpp @@ -33,9 +33,8 @@ VtkCompositeColormapToImageFilter::VtkCompositeColormapToImageFilter( vtkAlgorit this->init(); } -VtkCompositeColormapToImageFilter::~VtkCompositeColormapToImageFilter() -{ -} +VtkCompositeColormapToImageFilter::~VtkCompositeColormapToImageFilter() = + default; void VtkCompositeColormapToImageFilter::init() { @@ -44,7 +43,7 @@ void VtkCompositeColormapToImageFilter::init() vtkSmartPointer<VtkColorLookupTable> colormap = vtkSmartPointer<VtkColorLookupTable>::New(); - QWidget* parent = 0; + QWidget* parent = nullptr; QSettings settings; QString fileName = QFileDialog::getOpenFileName(parent, "Select color lookup table", settings.value("lastOpenedLookupTableFileDirectory").toString(), @@ -90,7 +89,7 @@ void VtkCompositeColormapToImageFilter::SetUserProperty( QString name, QVariant { VtkAlgorithmProperties::SetUserProperty(name, value); - vtkImageMapToColors* map = static_cast<vtkImageMapToColors*>(_outputAlgorithm); + auto* map = static_cast<vtkImageMapToColors*>(_outputAlgorithm); if (name.compare("PassAlphaToOutput") == 0) map->SetPassAlphaToOutput(value.toBool()); else if (name.compare("NumberOfColors") == 0) @@ -101,7 +100,7 @@ void VtkCompositeColormapToImageFilter::SetUserVectorProperty( QString name, QLi { VtkAlgorithmProperties::SetUserVectorProperty(name, values); - vtkImageMapToColors* map = static_cast<vtkImageMapToColors*>(_outputAlgorithm); + auto* map = static_cast<vtkImageMapToColors*>(_outputAlgorithm); if (name.compare("TableRange") == 0) static_cast<vtkLookupTable*>(map->GetLookupTable())->SetTableRange( values[0].toInt(), values[1].toInt()); diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.h index 2b139b2f65153a1ced663c67fef8f6b617a30346..c2b69f90a47b8bc4decf0db1f658bd80d19bdd51 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.h @@ -21,14 +21,13 @@ class VtkCompositeColormapToImageFilter : public VtkCompositeFilter { public: VtkCompositeColormapToImageFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeColormapToImageFilter(); + ~VtkCompositeColormapToImageFilter() override; - virtual void init() override; + void init() override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; - virtual void SetUserVectorProperty(QString name, - QList<QVariant> values) override; + void SetUserVectorProperty(QString name, QList<QVariant> values) override; private: }; diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.cpp index e2182c5ac5e57e5149fd2f483cb170a46ccbd1c1..2aa5fbacf66b46d7bcd8ba5b4fa090136b27de30 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.cpp @@ -28,9 +28,7 @@ VtkCompositeContourFilter::VtkCompositeContourFilter( vtkAlgorithm* inputAlgorit this->init(); } -VtkCompositeContourFilter::~VtkCompositeContourFilter() -{ -} +VtkCompositeContourFilter::~VtkCompositeContourFilter() = default; void VtkCompositeContourFilter::init() { diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.h index ee979efe806d21fd715d57167964a83b83169823..79747df7e6df00b2e7c77ae065b2a80753ec65b2 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.h @@ -23,11 +23,11 @@ class VtkCompositeContourFilter : public VtkCompositeFilter { public: VtkCompositeContourFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeContourFilter(); + ~VtkCompositeContourFilter() override; - virtual void init() override; + void init() override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; void SetUserVectorProperty(QString name, QList<QVariant> values) override; diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.cpp index 072576cc14c80b4299de63b909c91aa6ca9e77d7..133188ae9b0f96d3eca5402639970cf75f17113e 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.cpp @@ -41,7 +41,7 @@ void VtkCompositeElementSelectionFilter::init() this->_outputDataObjectType = VTK_UNSTRUCTURED_GRID; this->SetLookUpTable(QString::fromStdString(_selection_name), this->GetLookupTable()); - vtkSmartPointer<VtkAppendArrayFilter> selFilter (NULL); + vtkSmartPointer<VtkAppendArrayFilter> selFilter(nullptr); if (!_selection.empty()) { selFilter = vtkSmartPointer<VtkAppendArrayFilter>::New(); diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.h index 12c9901ba702310c8fcb24e6917e6aa8e0751887..72085bcfc7c1cf271a16796cedf497a1f5ab72a5 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.h @@ -27,16 +27,16 @@ class VtkCompositeElementSelectionFilter : public VtkCompositeFilter { public: VtkCompositeElementSelectionFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeElementSelectionFilter() {} + ~VtkCompositeElementSelectionFilter() override = default; - virtual void init(); + void init() override; // Sets the range for the quality measure (default is [0,1] but this may vary for area- and volume-metrics). void setRange(double min_val, double max_val) { _range = std::make_pair(min_val, max_val); } void setSelectionArray(const std::string &selection_name, const std::vector<double> &selection = std::vector<double>()); - virtual void SetUserVectorProperty(QString name, QList<QVariant> values); + void SetUserVectorProperty(QString name, QList<QVariant> values) override; private: /// Returns a colour lookup table optimised for quality measures diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeFilter.h index d475240b9194bf9f4e4acff4f36e7fe8e1e8ca6e..061977926d724873056d675e3ccb853f76fccc27 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeFilter.h @@ -46,7 +46,7 @@ public: VtkCompositeFilter(vtkAlgorithm* inputAlgorithm); /// @brief Destructor. - virtual ~VtkCompositeFilter(); + ~VtkCompositeFilter() override; /// @return the type of the data input. /// Can be compared with diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.cpp index 9426aa2df0576b2fa2d3976f84d77b03fb6946d1..3f8bcb6f4e29114a06f3d67983e837a805a595b3 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.cpp @@ -39,11 +39,11 @@ VtkCompositeGeoObjectFilter::VtkCompositeGeoObjectFilter( vtkAlgorithm* inputAlg { vtkAlgorithm* parentAlg = ao->GetProducer(); - if (dynamic_cast<VtkPolylinesSource*>(parentAlg) != NULL) + if (dynamic_cast<VtkPolylinesSource*>(parentAlg) != nullptr) _type = GeoLib::GEOTYPE::POLYLINE; - else if (dynamic_cast<VtkSurfacesSource*>(parentAlg) != NULL) + else if (dynamic_cast<VtkSurfacesSource*>(parentAlg) != nullptr) _type = GeoLib::GEOTYPE::SURFACE; - else if (dynamic_cast<VtkStationSource*>(parentAlg) != NULL) + else if (dynamic_cast<VtkStationSource*>(parentAlg) != nullptr) { /* TODO if (dynamic_cast<VtkStationSource*>(parentAlg)->getType() == GeoLib::Station::StationType::BOREHOLE) @@ -55,9 +55,7 @@ VtkCompositeGeoObjectFilter::VtkCompositeGeoObjectFilter( vtkAlgorithm* inputAlg } } -VtkCompositeGeoObjectFilter::~VtkCompositeGeoObjectFilter() -{ -} +VtkCompositeGeoObjectFilter::~VtkCompositeGeoObjectFilter() = default; void VtkCompositeGeoObjectFilter::init() { diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.h index 10545a299b3cc5df58427173d45d6d23e717f7af..7187f293f2ea11271772ce04fcacd9a5dfc65ccf 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.h @@ -24,9 +24,9 @@ class VtkCompositeGeoObjectFilter : public VtkCompositeFilter { public: VtkCompositeGeoObjectFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeGeoObjectFilter(); + ~VtkCompositeGeoObjectFilter() override; - virtual void init() override; + void init() override; /// @brief Sets user properties. void SetUserProperty(QString name, QVariant value) override diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeImageToCylindersFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeImageToCylindersFilter.h index 19ba34e4bb785ec721af07a9510c6c6a691e0d0a..d9377af952c2e2325d48e3f4149105939b772f2f 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeImageToCylindersFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeImageToCylindersFilter.h @@ -25,11 +25,11 @@ class VtkCompositeImageToCylindersFilter : public VtkCompositeFilter { public: VtkCompositeImageToCylindersFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeImageToCylindersFilter(); + ~VtkCompositeImageToCylindersFilter() override; - virtual void init() override; + void init() override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; void SetUserVectorProperty(QString name, QList<QVariant> values) override; diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.cpp index e8903717456ef0962345d6c8621b6d22f4e57b17..72539abf2486b7d3e97e18bfee2d2b5b3b9172ef 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.cpp @@ -25,9 +25,7 @@ VtkCompositeLineToTubeFilter::VtkCompositeLineToTubeFilter( vtkAlgorithm* inputA this->init(); } -VtkCompositeLineToTubeFilter::~VtkCompositeLineToTubeFilter() -{ -} +VtkCompositeLineToTubeFilter::~VtkCompositeLineToTubeFilter() = default; void VtkCompositeLineToTubeFilter::init() { diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.h index 6d4dda3ab49b40e9c7ad09e48f623790c5b62c17..11ab5d1d69ea0517a28283e5363a1f9c9f647eac 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.h @@ -21,11 +21,11 @@ class VtkCompositeLineToTubeFilter : public VtkCompositeFilter { public: VtkCompositeLineToTubeFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeLineToTubeFilter(); + ~VtkCompositeLineToTubeFilter() override; - virtual void init() override; + void init() override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; private: diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp index a650cf1d569aadfcbc93212ce3f9ba8fd1996e85..e791d1abbce740eb9102d51ef75daa17fde9a622 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& item : _selection) + delete item; } void VtkCompositeNodeSelectionFilter::init() @@ -62,10 +62,12 @@ 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_index : point_indeces) { - double * coords = static_cast<vtkDataSetAlgorithm*>(_inputAlgorithm)->GetOutput()->GetPoint(point_indeces[i]); - GeoLib::Point* p (new GeoLib::Point(coords[0], coords[1], coords[2])); + double* coords = static_cast<vtkDataSetAlgorithm*>(_inputAlgorithm) + ->GetOutput() + ->GetPoint(point_index); + auto* p(new GeoLib::Point(coords[0], coords[1], coords[2])); _selection.push_back(p); } init(); diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.h index d3dce1d7d4342903e88b21589e0dcc746b718293..cad0cdac583472faeaa5bcab5e92d8cde1034fae 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.h @@ -24,11 +24,11 @@ class VtkCompositeNodeSelectionFilter : public VtkCompositeFilter { public: VtkCompositeNodeSelectionFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeNodeSelectionFilter(); + ~VtkCompositeNodeSelectionFilter() override; - virtual void init(); + void init() override; - /// Sets the point indeces to be highlighted + /// Sets the point indices to be highlighted void setSelectionArray(const std::vector<unsigned> &point_indeces); private: diff --git a/Applications/DataExplorer/VtkVis/VtkCompositePointToGlyphFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositePointToGlyphFilter.h index 003f20d97984bcbb64c96f89f389f859c067237f..f2c9eba1f2668dfc618c2aa918f0f240c4aed7cc 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositePointToGlyphFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositePointToGlyphFilter.h @@ -23,11 +23,11 @@ class VtkCompositePointToGlyphFilter : public VtkCompositeFilter { public: VtkCompositePointToGlyphFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositePointToGlyphFilter(); + ~VtkCompositePointToGlyphFilter() override; - virtual void init() override; + void init() override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; private: vtkSphereSource* _glyphSource; diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.cpp index b4d355f453e64fe7302d69887fce2db930300fb8..e87948dbb0b51d2947e45f896700de7aee5fcc1f 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.cpp @@ -39,9 +39,8 @@ VtkCompositeTextureOnSurfaceFilter::VtkCompositeTextureOnSurfaceFilter( this->init(); } -VtkCompositeTextureOnSurfaceFilter::~VtkCompositeTextureOnSurfaceFilter() -{ -} +VtkCompositeTextureOnSurfaceFilter::~VtkCompositeTextureOnSurfaceFilter() = + default; void VtkCompositeTextureOnSurfaceFilter::init() { @@ -60,7 +59,7 @@ void VtkCompositeTextureOnSurfaceFilter::init() else surface->SetInputConnection(_inputAlgorithm->GetOutputPort()); - QWidget* parent = 0; + QWidget* parent = nullptr; QSettings settings; QString fileName = QFileDialog::getOpenFileName(parent, "Select raster file to apply as texture", settings.value("lastOpenedTextureFileDirectory").toString(), @@ -84,7 +83,7 @@ void VtkCompositeTextureOnSurfaceFilter::init() { NetCdfConfigureDialog dlg(fileName.toStdString().c_str()); dlg.exec(); - if (dlg.getRaster() != NULL) + if (dlg.getRaster() != nullptr) { VtkGeoImageSource* image = dlg.getRaster(); double origin[3]; diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.h index 779ff87fcce3032f1d3c4b06d2cd730f26512ff9..63570b3b79b442074823bd4d5380a5258766d3ca 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.h @@ -23,11 +23,11 @@ class VtkCompositeTextureOnSurfaceFilter : public VtkCompositeFilter { public: VtkCompositeTextureOnSurfaceFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeTextureOnSurfaceFilter(); + ~VtkCompositeTextureOnSurfaceFilter() override; - virtual void init() override; + void init() override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; private: }; diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.cpp index 798a0c6509096c5456e3690b57be1828d9bb63c3..bdea9f34dc7e43fb03f93b2b50ea802cf2e8f8d2 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.cpp @@ -27,9 +27,7 @@ VtkCompositeThresholdFilter::VtkCompositeThresholdFilter( vtkAlgorithm* inputAlg this->init(); } -VtkCompositeThresholdFilter::~VtkCompositeThresholdFilter() -{ -} +VtkCompositeThresholdFilter::~VtkCompositeThresholdFilter() = default; void VtkCompositeThresholdFilter::init() { diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.h b/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.h index aa7109ed3e7b860d6eea0cbd85591099252549c8..0d4017bd2e1ce78d89c5dc62ae83612dc16921d1 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.h @@ -23,11 +23,11 @@ class VtkCompositeThresholdFilter : public VtkCompositeFilter { public: VtkCompositeThresholdFilter(vtkAlgorithm* inputAlgorithm); - virtual ~VtkCompositeThresholdFilter(); + ~VtkCompositeThresholdFilter() override; - virtual void init() override; + void init() override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; void SetUserVectorProperty(QString name, QList<QVariant> values) override; diff --git a/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp b/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp index 33a13964855537fc31fa8acd6eff78689a2b3060..125b180ae2aa8daa654e421287f18f981e224116 100644 --- a/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp +++ b/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp @@ -20,15 +20,10 @@ vtkStandardNewMacro(VtkConsoleOutputWindow); //---------------------------------------------------------------------------- -VtkConsoleOutputWindow::VtkConsoleOutputWindow() -{ - -} +VtkConsoleOutputWindow::VtkConsoleOutputWindow() = default; //---------------------------------------------------------------------------- -VtkConsoleOutputWindow::~VtkConsoleOutputWindow() -{ -} +VtkConsoleOutputWindow::~VtkConsoleOutputWindow() = default; //---------------------------------------------------------------------------- // Display text in the window, and translate the \n to \r\n. diff --git a/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.h b/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.h index 701987ef1a2902d78ee89a83300c4352851aa60b..f69d0f7c035bdcfa3268026efbbb0d7c70bea6aa 100644 --- a/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.h +++ b/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.h @@ -23,13 +23,14 @@ public: void PrintSelf(ostream& os, vtkIndent indent) override; static VtkConsoleOutputWindow * New(); - virtual void DisplayText(const char*) override; + void DisplayText(const char*) override; protected: VtkConsoleOutputWindow(); - virtual ~VtkConsoleOutputWindow(); + ~VtkConsoleOutputWindow() override; private: - VtkConsoleOutputWindow(const VtkConsoleOutputWindow &); // Not implemented. - void operator=(const VtkConsoleOutputWindow &); // Not implemented. + VtkConsoleOutputWindow(const VtkConsoleOutputWindow&) = + delete; // Not implemented. + void operator=(const VtkConsoleOutputWindow&) = delete; // Not implemented. }; diff --git a/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.cpp b/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.cpp index 72403ab34ca86a9220606d89f2bbb82ccb30b5a3..d11450ed5c49830bf873fcd5db017c81ae220dee 100644 --- a/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.cpp @@ -186,7 +186,8 @@ void VtkCustomInteractorStyle::OnLeftButtonDown() // check if the underlying object is a mesh and if so, send a signal to the element model for display of information about the picked element. vtkAlgorithm* data_set = picker->GetActor()->GetMapper()->GetInputConnection(0, 0)->GetProducer()->GetInputConnection(0,0)->GetProducer(); - vtkUnstructuredGridAlgorithm* source = dynamic_cast<vtkUnstructuredGridAlgorithm*>(data_set); + auto* source = + dynamic_cast<vtkUnstructuredGridAlgorithm*>(data_set); if (source) emit elementPicked(source, static_cast<unsigned>(picker->GetCellId())); else diff --git a/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.h b/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.h index 5d4015608565927cad9a517b019ba8c222d7be5e..44d087f98a662319c6625a982e794180adfcc416 100644 --- a/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.h +++ b/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.h @@ -41,19 +41,19 @@ public: vtkTypeMacro (VtkCustomInteractorStyle, vtkInteractorStyleTrackballCamera); /// @brief Handles key press events. - virtual void OnChar() override; + void OnChar() override; /// @brief Handles key down events. - virtual void OnKeyDown() override; + void OnKeyDown() override; /// @brief Handles key up events. - virtual void OnKeyUp() override; + void OnKeyUp() override; /// @brief Handles left mouse button events (picking). - virtual void OnLeftButtonDown() override; + void OnLeftButtonDown() override; /// @brief Handles middle mouse button events (rotation point picking). - virtual void OnRightButtonDown() override; + void OnRightButtonDown() override; public slots: void highlightActor(vtkProp3D* prop); @@ -68,7 +68,7 @@ public slots: protected: VtkCustomInteractorStyle(); - virtual ~VtkCustomInteractorStyle(); + ~VtkCustomInteractorStyle() override; /// @brief The vtk object to pick. vtkDataObject* _data; diff --git a/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp b/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp index e1b0e226cfac294df90c2166832994510b270558..22690d918757eb1d5d840c1f2777ec1c34d2f602 100644 --- a/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp +++ b/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp @@ -133,7 +133,7 @@ VtkCompositeFilter* VtkFilterFactory::CreateCompositeFilter( QString type, return new VtkCompositeGeoObjectFilter(inputAlgorithm); else - return NULL; + return nullptr; } vtkAlgorithm* VtkFilterFactory::CreateSimpleFilter( QString type ) @@ -143,5 +143,5 @@ vtkAlgorithm* VtkFilterFactory::CreateSimpleFilter( QString type ) if (type.compare(QString("vtkDataSetSurfaceFilter")) == 0) return vtkDataSetSurfaceFilter::New(); - return NULL; + return nullptr; } diff --git a/Applications/DataExplorer/VtkVis/VtkGeoImageSource.cpp b/Applications/DataExplorer/VtkVis/VtkGeoImageSource.cpp index 627b124b4b35200bcb5cedbe3c59096256b3c190..68e429f15641d55b52ff994f40f56ec15c54760a 100644 --- a/Applications/DataExplorer/VtkVis/VtkGeoImageSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkGeoImageSource.cpp @@ -56,7 +56,7 @@ void vtkSimpleImageFilterExampleExecute(vtkImageData* input, } VtkGeoImageSource::VtkGeoImageSource() -: _imageSource(NULL), _x0(0), _y0(0), _z0(0), _spacing(1) + : _imageSource(nullptr), _x0(0), _y0(0), _z0(0), _spacing(1) { } diff --git a/Applications/DataExplorer/VtkVis/VtkGeoImageSource.h b/Applications/DataExplorer/VtkVis/VtkGeoImageSource.h index 2b445096b251e074d93a65ffc4871007a6c554db..abbec8dea77f0c8e081e925eef5a062b35a63b08 100644 --- a/Applications/DataExplorer/VtkVis/VtkGeoImageSource.h +++ b/Applications/DataExplorer/VtkVis/VtkGeoImageSource.h @@ -56,22 +56,21 @@ public: /// @brief Returns the spacing between two pixels. double getSpacing() const; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; protected: /// @brief Constructor. VtkGeoImageSource(); /// @brief Destructor. - virtual ~VtkGeoImageSource(); + ~VtkGeoImageSource() override; /// @brief Filter execution. - virtual void SimpleExecute(vtkImageData* input, - vtkImageData* output) override; + void SimpleExecute(vtkImageData* input, vtkImageData* output) override; private: - VtkGeoImageSource(const VtkGeoImageSource&); // Not implemented. - void operator=(const VtkGeoImageSource&); // Not implemented + VtkGeoImageSource(const VtkGeoImageSource&) = delete; // Not implemented. + void operator=(const VtkGeoImageSource&) = delete; // Not implemented vtkImageAlgorithm* _imageSource; diff --git a/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.cpp b/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.cpp index e3b02d570c8d43d19eb6882e7028fb13a8b0c1ba..fa49a538b8c52b5ef0b9930b3d04917964402e35 100644 --- a/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.cpp @@ -33,9 +33,7 @@ VtkImageDataToLinePolyDataFilter::VtkImageDataToLinePolyDataFilter() : this->SetLengthScaleFactor(1.0); } -VtkImageDataToLinePolyDataFilter::~VtkImageDataToLinePolyDataFilter() -{ -} +VtkImageDataToLinePolyDataFilter::~VtkImageDataToLinePolyDataFilter() = default; void VtkImageDataToLinePolyDataFilter::PrintSelf(ostream& os, vtkIndent indent) { diff --git a/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.h b/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.h index 094679900911a48977e0d2828244f21ff136009f..1a47590f606d8de70afa5519a63a452689c67dfc 100644 --- a/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.h @@ -39,7 +39,7 @@ public: ogsUserPropertyMacro(LengthScaleFactor,double); /// @brief Sets a user property. - virtual void SetUserProperty(QString name, QVariant value) override + void SetUserProperty(QString name, QVariant value) override { if (name.compare("LengthScaleFactor") == 0) SetLengthScaleFactor(value.toDouble()); @@ -53,20 +53,21 @@ protected: VtkImageDataToLinePolyDataFilter(); /// @brief Destructor. - virtual ~VtkImageDataToLinePolyDataFilter(); + ~VtkImageDataToLinePolyDataFilter() override; /// @brief Sets input port to vtkImageData. - virtual int FillInputPortInformation(int port, - vtkInformation* info) override; + int FillInputPortInformation(int port, vtkInformation* info) override; /// @brief Converts the image data to lines - virtual int RequestData(vtkInformation* request, vtkInformationVector** inputVector, - vtkInformationVector* outputVector) override; + int RequestData(vtkInformation* request, vtkInformationVector** inputVector, + vtkInformationVector* outputVector) override; /// @brief The spacing of the image double ImageSpacing; private: - VtkImageDataToLinePolyDataFilter(const VtkImageDataToLinePolyDataFilter&); // Not implemented. - void operator=(const VtkImageDataToLinePolyDataFilter&); // Not implemented + VtkImageDataToLinePolyDataFilter(const VtkImageDataToLinePolyDataFilter&) = + delete; // Not implemented. + void operator=(const VtkImageDataToLinePolyDataFilter&) = + delete; // Not implemented }; diff --git a/Applications/DataExplorer/VtkVis/VtkPickCallback.cpp b/Applications/DataExplorer/VtkVis/VtkPickCallback.cpp index fd8d8e199fffff7fc668d08bae7a3786dc44d6e2..ba40e2b1b2973c08df61caf5ac984fbf57abd80a 100644 --- a/Applications/DataExplorer/VtkVis/VtkPickCallback.cpp +++ b/Applications/DataExplorer/VtkVis/VtkPickCallback.cpp @@ -28,7 +28,7 @@ VtkPickCallback* VtkPickCallback::New() void VtkPickCallback::Execute( vtkObject* caller, unsigned long vtkNotUsed( eventId), void* vtkNotUsed(callData) ) { - vtkCellPicker* picker = static_cast<vtkCellPicker*>(caller); + auto* picker = static_cast<vtkCellPicker*>(caller); if (picker->GetCellId() < 0) { // Nothing is picked diff --git a/Applications/DataExplorer/VtkVis/VtkPickCallback.h b/Applications/DataExplorer/VtkVis/VtkPickCallback.h index baaaf9e8b9cfc7ac49bb8b63077c826353192773..5038fa7cbae3ea99e792b48757b7cdaa2d9e733c 100644 --- a/Applications/DataExplorer/VtkVis/VtkPickCallback.h +++ b/Applications/DataExplorer/VtkVis/VtkPickCallback.h @@ -32,7 +32,8 @@ class VtkPickCallback : public QObject, public vtkCommand public: static VtkPickCallback* New(); - void Execute(vtkObject* caller, unsigned long eventId, void* callData); + void Execute(vtkObject* caller, unsigned long eventId, + void* callData) override; protected: VtkPickCallback(); diff --git a/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp b/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp index 38b708709edd30d5b65b134de800ffc4866fe5c0..8d5639d15b3f177f61c5eb7d3c56ffcf35f6fc68 100644 --- a/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp @@ -32,8 +32,7 @@ vtkStandardNewMacro(VtkPointsSource); -VtkPointsSource::VtkPointsSource() - : _points(NULL) +VtkPointsSource::VtkPointsSource() : _points(nullptr) { _removable = false; // From VtkAlgorithmProperties this->SetNumberOfInputPorts(0); @@ -46,16 +45,15 @@ void VtkPointsSource::PrintSelf( ostream& os, vtkIndent indent ) { this->Superclass::PrintSelf(os,indent); - if (_points->size() == 0) + if (_points->empty()) return; os << indent << "== VtkPointsSource ==" << "\n"; int i = 0; - for (std::vector<GeoLib::Point*>::const_iterator 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++; @@ -97,10 +95,9 @@ int VtkPointsSource::RequestData( vtkInformation* request, // Generate points and vertices unsigned i = 0; - for (std::vector<GeoLib::Point*>::const_iterator 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/VtkPointsSource.h b/Applications/DataExplorer/VtkVis/VtkPointsSource.h index 0f1181da09f62dd58dc8ad0e75c1718cd306d446..410924c5c3206856f387d6316fca4f43c776150b 100644 --- a/Applications/DataExplorer/VtkVis/VtkPointsSource.h +++ b/Applications/DataExplorer/VtkVis/VtkPointsSource.h @@ -39,11 +39,11 @@ public: /// Prints its data on a stream. void PrintSelf(ostream& os, vtkIndent indent) override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; protected: VtkPointsSource(); - ~VtkPointsSource() {} + ~VtkPointsSource() override = default; /// Computes the polygonal data object. int RequestData(vtkInformation* request, diff --git a/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp b/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp index bbefb00504d6ffe52a82943c71d878b0d77b81c3..cc4e73e062f0c8018a5d893f224abcdc6a86b5dc 100644 --- a/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp @@ -36,8 +36,7 @@ vtkStandardNewMacro(VtkPolylinesSource); -VtkPolylinesSource::VtkPolylinesSource() - : _polylines(NULL) +VtkPolylinesSource::VtkPolylinesSource() : _polylines(nullptr) { _removable = false; // From VtkAlgorithmProperties this->SetNumberOfInputPorts(0); @@ -46,25 +45,22 @@ VtkPolylinesSource::VtkPolylinesSource() GetProperties()->SetColor(c[0] / 255.0, c[1] / 255.0, c[2] / 255.0); } -VtkPolylinesSource::~VtkPolylinesSource() -{ -} +VtkPolylinesSource::~VtkPolylinesSource() = default; void VtkPolylinesSource::PrintSelf( ostream& os, vtkIndent indent ) { this->Superclass::PrintSelf(os,indent); - if (_polylines->size() == 0) + if (_polylines->empty()) return; - for (std::vector<GeoLib::Polyline*>::const_iterator 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"; @@ -81,7 +77,7 @@ int VtkPolylinesSource::RequestData( vtkInformation* request, if (!_polylines) return 0; - if (_polylines->size() == 0) + if (_polylines->empty()) { ERR("VtkPolylineSource::RequestData(): Size of polyline vector is 0"); return 0; diff --git a/Applications/DataExplorer/VtkVis/VtkPolylinesSource.h b/Applications/DataExplorer/VtkVis/VtkPolylinesSource.h index 689878e5e012e7352e951bb6aba18d02d6a5d15d..22a9508d92f69455ae4e266d706e914d52d2c0bb 100644 --- a/Applications/DataExplorer/VtkVis/VtkPolylinesSource.h +++ b/Applications/DataExplorer/VtkVis/VtkPolylinesSource.h @@ -42,11 +42,11 @@ public: /// Prints its data on a stream. void PrintSelf(ostream& os, vtkIndent indent) override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; protected: VtkPolylinesSource(); - ~VtkPolylinesSource(); + ~VtkPolylinesSource() override; /// Computes the polygonal data object. int RequestData(vtkInformation* request, diff --git a/Applications/DataExplorer/VtkVis/VtkRaster.cpp b/Applications/DataExplorer/VtkVis/VtkRaster.cpp index 1b5989b4b6ad16515abce57139a7cd7dbcc20f89..9ce56065c3de0fbdbc28f90fce24c59ec32a803a 100644 --- a/Applications/DataExplorer/VtkVis/VtkRaster.cpp +++ b/Applications/DataExplorer/VtkVis/VtkRaster.cpp @@ -67,7 +67,7 @@ vtkImageAlgorithm* VtkRaster::loadImage(const std::string &fileName, vtkImageImport* VtkRaster::loadImageFromArray(double const*const data_array, GeoLib::RasterHeader header) { const unsigned length = header.n_rows*header.n_cols; - float* data = new float[length*2]; + auto* data = new float[length * 2]; float max_val = *std::max_element(data_array, data_array+length); for (unsigned j=0; j<length; ++j) { @@ -109,7 +109,7 @@ vtkImageImport* VtkRaster::loadImageFromTIFF(const std::string &fileName, if (geoTiff) { int imgWidth = 0, imgHeight = 0, nImages = 0, pntCount = 0; - double* pnts = 0; + double* pnts = nullptr; // get actual number of images in the tiff file do { @@ -139,8 +139,8 @@ vtkImageImport* VtkRaster::loadImageFromTIFF(const std::string &fileName, } // read pixel values - uint32* pixVal = - (uint32*) _TIFFmalloc(imgWidth * imgHeight * sizeof (uint32)); + auto* pixVal = + (uint32*)_TIFFmalloc(imgWidth * imgHeight * sizeof(uint32)); if ((imgWidth > 0) && (imgHeight > 0)) if (!TIFFReadRGBAImage(tiff, imgWidth, imgHeight, pixVal, 0)) { @@ -162,8 +162,8 @@ vtkImageImport* VtkRaster::loadImageFromTIFF(const std::string &fileName, &cmap_green, &cmap_blue); - float* data = new float[imgWidth * imgHeight * 4]; - int* pxl (new int[4]); + auto* data = new float[imgWidth * imgHeight * 4]; + auto* pxl(new int[4]); for (int j = 0; j < imgHeight; ++j) { int lineindex = j * imgWidth; diff --git a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp index 767211555672c396069454a01cbaf5eeaebaf687..2fce1f466606ec5dbec86f2899bc8f6b7b5b8dbc 100644 --- a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp @@ -35,8 +35,7 @@ vtkStandardNewMacro(VtkStationSource); -VtkStationSource::VtkStationSource() - : _stations(NULL) +VtkStationSource::VtkStationSource() : _stations(nullptr) { _removable = false; // From VtkAlgorithmProperties this->SetNumberOfInputPorts(0); @@ -49,16 +48,15 @@ void VtkStationSource::PrintSelf( ostream& os, vtkIndent indent ) { this->Superclass::PrintSelf(os,indent); - if (_stations->size() == 0) + if (_stations->empty()) return; os << indent << "== VtkStationSource ==" << "\n"; int i = 0; - for (std::vector<GeoLib::Point*>::const_iterator 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++; @@ -124,37 +122,41 @@ int VtkStationSource::RequestData( vtkInformation* request, std::size_t site_count(0); // Generate graphic objects - for (std::vector<GeoLib::Point*>::const_iterator 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++) { - double* pCoords = const_cast<double*>(profile[i]->getCoords()); - double loc[3] = { pCoords[0], pCoords[1], pCoords[2] }; + auto* pCoords = const_cast<double*>(profile[i]->getCoords()); + double loc[3] = {pCoords[0], pCoords[1], pCoords[2]}; newStations->InsertNextPoint(loc); station_ids->InsertNextValue(site_count); newLines->InsertNextCell(2); - newLines->InsertCellPoint(lastMaxIndex); // start of borehole-layer - newLines->InsertCellPoint(++lastMaxIndex); //end of boreholelayer + newLines->InsertCellPoint( + lastMaxIndex); // start of borehole-layer + newLines->InsertCellPoint( + ++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++; } @@ -200,8 +202,7 @@ void VtkStationSource::SetUserProperty( QString name, QVariant value ) std::size_t VtkStationSource::GetIndexByName( std::string const& name ) { vtkIdType max_key(0); - for (std::map<std::string, vtkIdType>::const_iterator it = _id_map.begin(); - it != _id_map.end(); ++it) + for (auto it = _id_map.begin(); it != _id_map.end(); ++it) { if (name.compare(it->first) == 0) return it->second; diff --git a/Applications/DataExplorer/VtkVis/VtkStationSource.h b/Applications/DataExplorer/VtkVis/VtkStationSource.h index b4d3acd2907e7fff059352cc343404372e275c4e..da95c5e538253b4b2be4ee28286a268d9c117e75 100644 --- a/Applications/DataExplorer/VtkVis/VtkStationSource.h +++ b/Applications/DataExplorer/VtkVis/VtkStationSource.h @@ -50,7 +50,7 @@ public: /// Prints its data on a stream. void PrintSelf(ostream& os, vtkIndent indent) override; - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; protected: VtkStationSource(); diff --git a/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp b/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp index 45a6684c5ef8fa363e9000c65be59c41dd9cd7b2..86067186e9450c6ee39ef023bdfb07018ce69d6c 100644 --- a/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp @@ -32,8 +32,7 @@ vtkStandardNewMacro(VtkSurfacesSource); -VtkSurfacesSource::VtkSurfacesSource() - : _surfaces(NULL) +VtkSurfacesSource::VtkSurfacesSource() : _surfaces(nullptr) { _removable = false; // From VtkAlgorithmProperties this->SetNumberOfInputPorts(0); @@ -49,7 +48,7 @@ void VtkSurfacesSource::PrintSelf( ostream& os, vtkIndent indent ) { this->Superclass::PrintSelf(os,indent); - if (_surfaces->size() == 0) + if (_surfaces->empty()) return; os << indent << "== VtkSurfacesSource ==" << "\n"; @@ -92,17 +91,16 @@ int VtkSurfacesSource::RequestData( vtkInformation* request, } vtkIdType count(0); - for (std::vector<GeoLib::Surface*>::const_iterator 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/VtkSurfacesSource.h b/Applications/DataExplorer/VtkVis/VtkSurfacesSource.h index 03ab0ff1ea08eb1e1c99f63bee57cc0b235beb47..d0c4ae6c83cb4bdcad878814f58d66570fcd1792 100644 --- a/Applications/DataExplorer/VtkVis/VtkSurfacesSource.h +++ b/Applications/DataExplorer/VtkVis/VtkSurfacesSource.h @@ -43,11 +43,11 @@ public: */ //ogsUserPropertyMacro(ColorBySurface,bool); - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; protected: VtkSurfacesSource(); - ~VtkSurfacesSource() {} + ~VtkSurfacesSource() override = default; /// Computes the polygonal data object. int RequestData(vtkInformation* request, diff --git a/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.cpp b/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.cpp index dbb319e709f6ecac98dbc7d7cc9581c82859e8d8..9a087b47300607f7da703826c6bfddd1e8a40453 100644 --- a/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.cpp @@ -39,9 +39,7 @@ VtkTextureOnSurfaceFilter::VtkTextureOnSurfaceFilter() : _origin(.0f,.0f), _scal { } -VtkTextureOnSurfaceFilter::~VtkTextureOnSurfaceFilter() -{ -} +VtkTextureOnSurfaceFilter::~VtkTextureOnSurfaceFilter() = default; void VtkTextureOnSurfaceFilter::PrintSelf( ostream& os, vtkIndent indent ) { diff --git a/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.h b/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.h index 718e2e073cf23b3f55b0590d9d82f3f1fc2c0a4b..c3aff14a3dfdf983356f7c4851933107ebd76ff8 100644 --- a/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.h +++ b/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.h @@ -48,11 +48,11 @@ public: /// Sets the raster/image to be used as a texture map void SetRaster(vtkImageAlgorithm* img, double x0, double y0, double scalingFactor); - virtual void SetUserProperty(QString name, QVariant value) override; + void SetUserProperty(QString name, QVariant value) override; protected: VtkTextureOnSurfaceFilter(); - ~VtkTextureOnSurfaceFilter(); + ~VtkTextureOnSurfaceFilter() override; /// Copies the input data and calculates texture coordinates (this requires that SetRaster() has /// been called before this method is executed. diff --git a/Applications/DataExplorer/VtkVis/VtkVisImageItem.cpp b/Applications/DataExplorer/VtkVis/VtkVisImageItem.cpp index 1320f0ac251cbc558394dd00b5f8e4de135ee8b6..02591fa96aa4581ebdb336155bd9aa6be9f38603 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisImageItem.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisImageItem.cpp @@ -38,16 +38,17 @@ #include <vtkXMLImageDataWriter.h> VtkVisImageItem::VtkVisImageItem( - vtkAlgorithm* algorithm, TreeItem* parentItem, - const QList<QVariant> data /*= QList<QVariant>()*/) - : VtkVisPipelineItem(algorithm, parentItem, data), _transformFilter(NULL) + vtkAlgorithm* algorithm, TreeItem* parentItem, + const QList<QVariant> data /*= QList<QVariant>()*/) + : VtkVisPipelineItem(algorithm, parentItem, data), _transformFilter(nullptr) { } VtkVisImageItem::VtkVisImageItem( - VtkCompositeFilter* compositeFilter, TreeItem* parentItem, - const QList<QVariant> data /*= QList<QVariant>()*/) - : VtkVisPipelineItem(compositeFilter, parentItem, data), _transformFilter(NULL) + VtkCompositeFilter* compositeFilter, TreeItem* parentItem, + const QList<QVariant> data /*= QList<QVariant>()*/) + : VtkVisPipelineItem(compositeFilter, parentItem, data), + _transformFilter(nullptr) { } @@ -58,28 +59,28 @@ VtkVisImageItem::~VtkVisImageItem() void VtkVisImageItem::Initialize(vtkRenderer* renderer) { - vtkImageAlgorithm* img = dynamic_cast<vtkImageAlgorithm*>(_algorithm); + auto* img = dynamic_cast<vtkImageAlgorithm*>(_algorithm); img->Update(); - //VtkGeoImageSource* img = dynamic_cast<VtkGeoImageSource*>(_algorithm); + // VtkGeoImageSource* img = dynamic_cast<VtkGeoImageSource*>(_algorithm); double origin[3]; double spacing[3]; double range[2]; img->GetOutput()->GetOrigin(origin); img->GetOutput()->GetSpacing(spacing); - //img->getRange(range); + // img->getRange(range); img->GetOutput()->GetPointData()->GetScalars()->GetRange(range); vtkImageShiftScale* scale = vtkImageShiftScale::New(); scale->SetOutputScalarTypeToUnsignedChar(); scale->SetInputConnection(img->GetOutputPort()); scale->SetShift(-range[0]); - scale->SetScale(255.0/(range[1]-range[0])); + scale->SetScale(255.0 / (range[1] - range[0])); _transformFilter = vtkImageChangeInformation::New(); _transformFilter->SetInputConnection(scale->GetOutputPort()); - //double origin[3]; - //img->getOrigin(origin); - //double spacing = img->getSpacing(); + // double origin[3]; + // img->getOrigin(origin); + // double spacing = img->getSpacing(); //_transformFilter->SetOutputOrigin(origin2); //_transformFilter->SetOutputSpacing(spacing2); _transformFilter->Update(); @@ -93,26 +94,27 @@ void VtkVisImageItem::Initialize(vtkRenderer* renderer) _renderer->AddActor(_actor); // Set pre-set properties - VtkAlgorithmProperties* vtkProps = dynamic_cast<VtkAlgorithmProperties*>(_algorithm); + auto* vtkProps = dynamic_cast<VtkAlgorithmProperties*>(_algorithm); if (vtkProps) setVtkProperties(vtkProps); - VtkVisPipelineItem* parentItem = dynamic_cast<VtkVisPipelineItem*>(this->parentItem()); + auto* parentItem = dynamic_cast<VtkVisPipelineItem*>(this->parentItem()); while (parentItem) { - VtkAlgorithmProperties* parentProps = - dynamic_cast<VtkAlgorithmProperties*>(parentItem->algorithm()); + auto* parentProps = + dynamic_cast<VtkAlgorithmProperties*>(parentItem->algorithm()); if (parentProps) { - VtkAlgorithmProperties* newProps = new VtkAlgorithmProperties(); + auto* newProps = new VtkAlgorithmProperties(); newProps->SetScalarVisibility(parentProps->GetScalarVisibility()); newProps->SetTexture(parentProps->GetTexture()); setVtkProperties(newProps); vtkProps = newProps; - parentItem = NULL; + parentItem = nullptr; } else - parentItem = dynamic_cast<VtkVisPipelineItem*>(parentItem->parentItem()); + parentItem = + dynamic_cast<VtkVisPipelineItem*>(parentItem->parentItem()); } // Set active scalar to the desired one from VtkAlgorithmProperties @@ -123,11 +125,11 @@ void VtkVisImageItem::Initialize(vtkRenderer* renderer) this->SetActiveAttribute(vtkProps->GetActiveAttribute()); else { - VtkVisPipelineItem* visParentItem = - dynamic_cast<VtkVisPipelineItem*>(this->parentItem()); + auto* visParentItem = + dynamic_cast<VtkVisPipelineItem*>(this->parentItem()); if (visParentItem) this->SetActiveAttribute(visParentItem->GetActiveAttribute()); - if (vtkProps->GetTexture() != NULL) + if (vtkProps->GetTexture() != nullptr) this->SetActiveAttribute("Solid Color"); } } @@ -142,7 +144,7 @@ void VtkVisImageItem::setVtkProperties(VtkAlgorithmProperties* vtkProps) int VtkVisImageItem::callVTKWriter(vtkAlgorithm* algorithm, const std::string &filename) const { std::string file_name_cpy(filename); - vtkImageAlgorithm* algID = dynamic_cast<vtkImageAlgorithm*>(algorithm); + auto* algID = dynamic_cast<vtkImageAlgorithm*>(algorithm); if (algID) { vtkSmartPointer<vtkXMLImageDataWriter> iWriter = diff --git a/Applications/DataExplorer/VtkVis/VtkVisImageItem.h b/Applications/DataExplorer/VtkVis/VtkVisImageItem.h index e24a9098d9457133bcce14a1e94fc4225222b65c..984725de3300d4c4635a939d4aa0e9f6f2112395 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisImageItem.h +++ b/Applications/DataExplorer/VtkVis/VtkVisImageItem.h @@ -45,19 +45,20 @@ public: VtkVisImageItem(VtkCompositeFilter* compositeFilter, TreeItem* parentItem, const QList<QVariant> data = QList<QVariant>()); - ~VtkVisImageItem(); + ~VtkVisImageItem() override; /// @brief Initializes vtkMapper and vtkActor necessary for visualization of /// the item and sets the item's properties. - void Initialize(vtkRenderer* renderer); + void Initialize(vtkRenderer* renderer) override; - void setTranslation(double x, double y, double z) const; + void setTranslation(double x, double y, double z) const override; - vtkAlgorithm* transformFilter() const; + vtkAlgorithm* transformFilter() const override; protected: /// Selects the appropriate VTK-Writer object and writes the object to a file with the given name. - virtual int callVTKWriter(vtkAlgorithm* algorithm, const std::string &filename) const; + int callVTKWriter(vtkAlgorithm* algorithm, + const std::string& filename) const override; void setVtkProperties(VtkAlgorithmProperties* vtkProps); private: diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp index 2b3d52aed62d6da7d93f48fdc6e7aea48991ed5b..d54472e5101b1e8f5a5f4c7f34c58172c7d7b6eb 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp @@ -70,7 +70,7 @@ VtkVisPipeline::VtkVisPipeline( vtkRenderer* renderer, QObject* parent /*= 0*/ ) QList<QVariant> rootData; rootData << "Object name" << "Visible"; delete _rootItem; - _rootItem = new TreeItem(rootData, NULL); + _rootItem = new TreeItem(rootData, nullptr); QSettings settings; QVariant backgroundColorVariant = settings.value("VtkBackgroundColor"); @@ -91,9 +91,9 @@ bool VtkVisPipeline::setData( const QModelIndex &index, const QVariant &value, void VtkVisPipeline::addLight(const GeoLib::Point &pos) { double lightPos[3]; - for (std::list<vtkLight*>::iterator 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,19 +106,19 @@ void VtkVisPipeline::addLight(const GeoLib::Point &pos) vtkLight* VtkVisPipeline::getLight(const GeoLib::Point &pos) const { double lightPos[3]; - for (std::list<vtkLight*>::const_iterator 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 NULL; + return nullptr; } void VtkVisPipeline::removeLight(const GeoLib::Point &pos) { double lightPos[3]; - for (std::list<vtkLight*>::iterator it = _lights.begin(); it != _lights.end(); ++it) + for (auto it = _lights.begin(); it != _lights.end(); ++it) { (*it)->GetPosition(lightPos); if (pos[0] == lightPos[0] && pos[1] == lightPos[1] && pos[2] == lightPos[2]) @@ -233,7 +233,7 @@ void VtkVisPipeline::setGlobalSuperelevation(double factor) const // iterate over all source items for (int i = 0; i < _rootItem->childCount(); ++i) { - VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); + auto* item = static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); item->setScale(1.0, 1.0, factor); // recursively set on all child items @@ -248,7 +248,7 @@ void VtkVisPipeline::setGlobalBackfaceCulling(bool enable) const // iterate over all source items for (int i = 0; i < _rootItem->childCount(); ++i) { - VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); + auto* item = static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); item->setBackfaceCulling(enable); // recursively set on all child items @@ -286,7 +286,8 @@ QModelIndex VtkVisPipeline::addPipelineItem(VtkVisPipelineItem* item, const QMod if (!parent.isValid()) // Set global superelevation on source objects { QSettings settings; - if (dynamic_cast<vtkImageAlgorithm*>(item->algorithm()) == NULL) // if not an image + if (dynamic_cast<vtkImageAlgorithm*>(item->algorithm()) == + nullptr) // if not an image item->setScale(1.0, 1.0, settings.value("globalSuperelevation", 1.0).toDouble()); } @@ -314,12 +315,11 @@ QModelIndex VtkVisPipeline::addPipelineItem( vtkAlgorithm* source, QModelIndex p if (!parent.isValid()) // if source object { - vtkGenericDataObjectReader* old_reader = dynamic_cast<vtkGenericDataObjectReader*>(source); - vtkXMLReader* new_reader = dynamic_cast<vtkXMLReader*>(source); - vtkImageReader2* image_reader = dynamic_cast<vtkImageReader2*>(source); - VtkAlgorithmProperties* props = dynamic_cast<VtkAlgorithmProperties*>(source); - MeshLib::VtkMappedMeshSource* meshSource = - dynamic_cast<MeshLib::VtkMappedMeshSource*>(source); + auto* old_reader = dynamic_cast<vtkGenericDataObjectReader*>(source); + auto* new_reader = dynamic_cast<vtkXMLReader*>(source); + auto* image_reader = dynamic_cast<vtkImageReader2*>(source); + auto* props = dynamic_cast<VtkAlgorithmProperties*>(source); + auto* meshSource = dynamic_cast<MeshLib::VtkMappedMeshSource*>(source); if (old_reader) itemName = old_reader->GetFileName(); else if (new_reader) @@ -338,7 +338,7 @@ QModelIndex VtkVisPipeline::addPipelineItem( vtkAlgorithm* source, QModelIndex p QList<QVariant> itemData; itemData << QString::fromStdString(itemName) << true; - VtkVisPipelineItem* item(NULL); + VtkVisPipelineItem* item(nullptr); if (dynamic_cast<vtkImageAlgorithm*>(source)) item = new VtkVisImageItem(source, getItem(parent), itemData); else @@ -376,11 +376,12 @@ void VtkVisPipeline::removeSourceItem(StationTreeModel* model, const std::string void VtkVisPipeline::removeSourceItem(MshModel* model, const QModelIndex &idx) { - MshItem* sItem = static_cast<MshItem*>(model->getItem(idx)); + auto* sItem = static_cast<MshItem*>(model->getItem(idx)); for (int i = 0; i < _rootItem->childCount(); i++) { - VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>(getItem(index(i, 0))); + VtkVisPipelineItem* item = + static_cast<VtkVisPipelineItem*>(getItem(index(i, 0))); if (item->algorithm() == sItem->vtkSource()) { removePipelineItem(index(i, 0)); @@ -442,22 +443,25 @@ void VtkVisPipeline::showMeshElementQuality( int const nSources = this->_rootItem->childCount(); for (int i = 0; i < nSources; i++) { - VtkVisPipelineItem* parentItem = - static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); + auto* parentItem = + static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); if (parentItem->algorithm() != source) continue; QList<QVariant> itemData; - itemData << "MeshQuality: " + QString::fromStdString( - MeshQualityType2String(t)) << true; + itemData << "MeshQuality: " + + QString::fromStdString(MeshQualityType2String(t)) + << true; - VtkCompositeFilter* filter = - VtkFilterFactory::CreateCompositeFilter("VtkCompositeElementSelectionFilter", - parentItem->transformFilter()); + VtkCompositeFilter* filter = VtkFilterFactory::CreateCompositeFilter( + "VtkCompositeElementSelectionFilter", + parentItem->transformFilter()); if (t == MeshLib::MeshQualityType::ELEMENTSIZE) { - auto const range (std::minmax_element(quality.cbegin(), quality.cend())); - static_cast<VtkCompositeElementSelectionFilter*>(filter)->setRange(*range.first, *range.second); + auto const range( + std::minmax_element(quality.cbegin(), quality.cend())); + static_cast<VtkCompositeElementSelectionFilter*>(filter)->setRange( + *range.first, *range.second); } static_cast<VtkCompositeElementSelectionFilter*>(filter)->setSelectionArray("Selection", quality); VtkVisPointSetItem* item = new VtkVisPointSetItem(filter, parentItem, itemData); @@ -472,18 +476,22 @@ void VtkVisPipeline::highlightGeoObject(const vtkPolyDataAlgorithm* source, int int nSources = this->_rootItem->childCount(); for (int i = 0; i < nSources; i++) { - VtkVisPipelineItem* parentItem = static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); + auto* parentItem = + static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); if (parentItem->algorithm() == source) { QList<QVariant> itemData; itemData << "Selected GeoObject" << true; - VtkCompositeFilter* filter = VtkFilterFactory::CreateCompositeFilter( - "VtkCompositeGeoObjectFilter", - parentItem->transformFilter()); + VtkCompositeFilter* filter = + VtkFilterFactory::CreateCompositeFilter( + "VtkCompositeGeoObjectFilter", + parentItem->transformFilter()); static_cast<VtkCompositeGeoObjectFilter*>(filter)->SetIndex(index); - VtkVisPointSetItem* item = new VtkVisPointSetItem(filter, parentItem, itemData); - QModelIndex parent_index = static_cast<TreeModel*>(this)->index(i, 0, QModelIndex()); + VtkVisPointSetItem* item = + new VtkVisPointSetItem(filter, parentItem, itemData); + QModelIndex parent_index = + static_cast<TreeModel*>(this)->index(i, 0, QModelIndex()); _highlighted_geo_index = this->addPipelineItem(item, parent_index); break; } @@ -504,7 +512,8 @@ void VtkVisPipeline::highlightMeshComponent(vtkUnstructuredGridAlgorithm const*c int nSources = this->_rootItem->childCount(); for (int i = 0; i < nSources; i++) { - VtkVisPipelineItem* parentItem = static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); + auto* parentItem = + static_cast<VtkVisPipelineItem*>(_rootItem->child(i)); if (parentItem->algorithm() == source) { QList<QVariant> itemData; @@ -512,25 +521,34 @@ void VtkVisPipeline::highlightMeshComponent(vtkUnstructuredGridAlgorithm const*c QList<QVariant> selected_index; selected_index << index << index; - VtkCompositeFilter* filter (nullptr); + VtkCompositeFilter* filter(nullptr); if (is_element) { - filter = VtkFilterFactory::CreateCompositeFilter("VtkCompositeElementSelectionFilter", - parentItem->transformFilter()); - static_cast<VtkCompositeElementSelectionFilter*>(filter)->setSelectionArray("vtkIdFilter_Ids"); - static_cast<VtkCompositeElementSelectionFilter*>(filter)->SetUserVectorProperty("Threshold Between", selected_index); + filter = VtkFilterFactory::CreateCompositeFilter( + "VtkCompositeElementSelectionFilter", + parentItem->transformFilter()); + static_cast<VtkCompositeElementSelectionFilter*>(filter) + ->setSelectionArray("vtkIdFilter_Ids"); + static_cast<VtkCompositeElementSelectionFilter*>(filter) + ->SetUserVectorProperty("Threshold Between", + selected_index); } else { - filter = VtkFilterFactory::CreateCompositeFilter("VtkCompositeNodeSelectionFilter", - parentItem->transformFilter()); + filter = VtkFilterFactory::CreateCompositeFilter( + "VtkCompositeNodeSelectionFilter", + parentItem->transformFilter()); std::vector<unsigned> indeces(1); indeces[0] = index; - static_cast<VtkCompositeNodeSelectionFilter*>(filter)->setSelectionArray(indeces); + static_cast<VtkCompositeNodeSelectionFilter*>(filter) + ->setSelectionArray(indeces); } - VtkVisPointSetItem* item = new VtkVisPointSetItem(filter, parentItem, itemData); - QModelIndex parent_index = static_cast<TreeModel*>(this)->index(i, 0, QModelIndex()); - _highlighted_mesh_component = this->addPipelineItem(item, parent_index); + VtkVisPointSetItem* item = + new VtkVisPointSetItem(filter, parentItem, itemData); + QModelIndex parent_index = + static_cast<TreeModel*>(this)->index(i, 0, QModelIndex()); + _highlighted_mesh_component = + this->addPipelineItem(item, parent_index); break; } } diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipeline.h b/Applications/DataExplorer/VtkVis/VtkVisPipeline.h index 4c49675531117003d7db22c8fb01ce095c16945d..40846f9846ddbede3e03a75992726bce82e10add 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipeline.h +++ b/Applications/DataExplorer/VtkVis/VtkVisPipeline.h @@ -57,15 +57,16 @@ class VtkVisPipeline : public TreeModel Q_OBJECT public: - VtkVisPipeline(vtkRenderer* renderer, QObject* parent = 0); + VtkVisPipeline(vtkRenderer* renderer, QObject* parent = nullptr); /// \brief Emits vtkVisPipelineChanged() and calls base class method. - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + bool setData(const QModelIndex& index, const QVariant& value, + int role = Qt::EditRole) override; /// \brief Adds a light to the scene at the given coordinates. void addLight(const GeoLib::Point &pos); - /// \brief Returns a light (or NULL) for the given coordinates. + /// \brief Returns a light (or nullptr) for the given coordinates. vtkLight* getLight(const GeoLib::Point &pos) const; /// \brief Removes a light at the given coordinates (if possible). @@ -81,7 +82,7 @@ public: /// is the given one. QModelIndex getIndex(vtkProp3D* actor); - Qt::ItemFlags flags( const QModelIndex &index ) const; + Qt::ItemFlags flags(const QModelIndex& index) const override; /// \brief Loads a vtk object from the given file and adds it to the pipeline. void loadFromFile(QString filename); diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp index 03c50e84d64eefa686aa76314f408579c2b64803..787d9eef6b7299eca0b05967ede3589693e4be45 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp @@ -45,21 +45,29 @@ extern FbxScene* lScene; #endif VtkVisPipelineItem::VtkVisPipelineItem( - vtkAlgorithm* algorithm, TreeItem* parentItem, - const QList<QVariant> data /*= QList<QVariant>()*/) - : TreeItem(data, parentItem), _actor(NULL), _algorithm(algorithm), - _renderer(NULL), _compositeFilter(NULL), _vtkProps(NULL) -{ - VtkVisPipelineItem* visParentItem = dynamic_cast<VtkVisPipelineItem*>(parentItem); + vtkAlgorithm* algorithm, TreeItem* parentItem, + const QList<QVariant> data /*= QList<QVariant>()*/) + : TreeItem(data, parentItem), + _actor(nullptr), + _algorithm(algorithm), + _renderer(nullptr), + _compositeFilter(nullptr), + _vtkProps(nullptr) +{ + auto* visParentItem = dynamic_cast<VtkVisPipelineItem*>(parentItem); if (parentItem->parentItem()) - _algorithm->SetInputConnection(visParentItem->algorithm()->GetOutputPort()); + _algorithm->SetInputConnection( + visParentItem->algorithm()->GetOutputPort()); } VtkVisPipelineItem::VtkVisPipelineItem( - VtkCompositeFilter* compositeFilter, TreeItem* parentItem, - const QList<QVariant> data /*= QList<QVariant>()*/) - : TreeItem(data, parentItem), _actor(NULL), _renderer(NULL), _compositeFilter(compositeFilter), - _vtkProps(NULL) + VtkCompositeFilter* compositeFilter, TreeItem* parentItem, + const QList<QVariant> data /*= QList<QVariant>()*/) + : TreeItem(data, parentItem), + _actor(nullptr), + _renderer(nullptr), + _compositeFilter(compositeFilter), + _vtkProps(nullptr) { _algorithm = _compositeFilter->GetOutputAlgorithm(); } @@ -77,7 +85,7 @@ VtkVisPipelineItem* VtkVisPipelineItem::child( int row ) const if (treeItem) return dynamic_cast<VtkVisPipelineItem*>(treeItem); else - return NULL; + return nullptr; } QVariant VtkVisPipelineItem::data( int column ) const @@ -138,7 +146,8 @@ int VtkVisPipelineItem::writeToFile(const std::string &filename) const } } else - QMessageBox::warning(NULL, "Conversion to FBX not possible", + QMessageBox::warning( + nullptr, "Conversion to FBX not possible", "It is not possible to convert an vtkImageData based object \ to FBX. If you want to convert raster data import it via \" \ File / Import / Raster Files as PolyData\"!"); diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.h b/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.h index e0393d886a05c9e465ff6427d6de258811fd42c2..489bb4d091c36d7bdfb08c9619fe7ac70bc61228 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.h +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.h @@ -56,7 +56,7 @@ public: VtkVisPipelineItem(VtkCompositeFilter* compositeFilter, TreeItem* parentItem, const QList<QVariant> data = QList<QVariant>()); - ~VtkVisPipelineItem(); + ~VtkVisPipelineItem() override; /// @brief Returns a VtkVisPipelineItem. VtkVisPipelineItem* child(int row) const; @@ -65,8 +65,8 @@ public: /// the item and sets the item's properties. virtual void Initialize(vtkRenderer* renderer) = 0; - QVariant data(int column) const; - bool setData(int column, const QVariant &value); + QVariant data(int column) const override; + bool setData(int column, const QVariant& value) override; /// @brief Returns the algorithm object vtkAlgorithm* algorithm() const { return _algorithm; } diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp index 60d23124016816e7f3aeeba61908c87c98539705..44d471ecd2f942ba18ed9b6ed75baed76171af6a 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp @@ -54,7 +54,7 @@ VtkVisPipelineView::VtkVisPipelineView( QWidget* parent /*= 0*/ ) : QTreeView(parent) { this->setItemsExpandable(false); - CheckboxDelegate* checkboxDelegate = new CheckboxDelegate(this); + auto* checkboxDelegate = new CheckboxDelegate(this); this->setItemDelegateForColumn(1, checkboxDelegate); this->header()->setStretchLastSection(false); this->header()->setSectionResizeMode(QHeaderView::ResizeToContents); @@ -85,8 +85,8 @@ void VtkVisPipelineView::contextMenuEvent( QContextMenuEvent* event ) QMenu menu; QAction* addFilterAction = menu.addAction("Add filter..."); - QAction* addLUTAction(NULL); - QAction* addMeshingAction(NULL); + QAction* addLUTAction(nullptr); + QAction* addMeshingAction(nullptr); if (objectType == VTK_IMAGE_DATA) { // this exception is needed as image object are only displayed in the vis-pipeline @@ -101,7 +101,7 @@ void VtkVisPipelineView::contextMenuEvent( QContextMenuEvent* event ) connect(addLUTAction, SIGNAL(triggered()), this, SLOT(addColorTable())); } - QAction* addConvertToMeshAction(NULL); + QAction* addConvertToMeshAction(nullptr); if (objectType == VTK_UNSTRUCTURED_GRID) { addConvertToMeshAction = menu.addAction("Convert to Mesh..."); @@ -113,7 +113,7 @@ void VtkVisPipelineView::contextMenuEvent( QContextMenuEvent* event ) #ifdef VTKFBXCONVERTER_FOUND QAction* exportFbxAction = menu.addAction("Export as Fbx"); #endif - QAction* removeAction = NULL; + QAction* removeAction = nullptr; if (!isSourceItem || vtkProps->IsRemovable()) { menu.addSeparator(); @@ -209,8 +209,7 @@ void VtkVisPipelineView::convertVTKToOGSMesh() static_cast<VtkVisPipeline*>(this->model())->getItem(this->selectionModel()->currentIndex())); vtkSmartPointer<vtkAlgorithm> algorithm = item->algorithm(); - - vtkUnstructuredGrid* grid(NULL); + vtkUnstructuredGrid* grid(nullptr); vtkUnstructuredGridAlgorithm* ugAlg = vtkUnstructuredGridAlgorithm::SafeDownCast(algorithm); if (ugAlg) grid = ugAlg->GetOutput(); @@ -243,7 +242,7 @@ void VtkVisPipelineView::selectionChanged( const QItemSelection &selected, QModelIndex index = *selected.indexes().begin(); if (index.isValid()) { - VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>(index.internalPointer()); + auto* item = static_cast<VtkVisPipelineItem*>(index.internalPointer()); emit actorSelected(item->actor()); emit itemSelected(item); if (item->transformFilter()) @@ -252,9 +251,9 @@ void VtkVisPipelineView::selectionChanged( const QItemSelection &selected, } else { - emit actorSelected(NULL); - emit itemSelected(NULL); - emit dataObjectSelected(NULL); + emit actorSelected(nullptr); + emit itemSelected(nullptr); + emit dataObjectSelected(nullptr); } } @@ -288,7 +287,7 @@ void VtkVisPipelineView::addColorTable() if (fi.suffix().toLower() == "xml") { - VtkVisPointSetItem* pointSetItem = dynamic_cast<VtkVisPointSetItem*>(item); + auto* pointSetItem = dynamic_cast<VtkVisPointSetItem*>(item); if (pointSetItem) { VtkAlgorithmProperties* props = pointSetItem->getVtkProperties(); @@ -300,8 +299,10 @@ void VtkVisPipelineView::addColorTable() } } else - QMessageBox::warning(NULL, "Color lookup table could not be applied.", - "Color lookup tables can only be applied to VtkVisPointSetItem."); + QMessageBox::warning(nullptr, + "Color lookup table could not be applied.", + "Color lookup tables can only be applied to " + "VtkVisPointSetItem."); QDir dir = QDir(filename); settings.setValue("lastOpenedLutFileDirectory", dir.absolutePath()); } diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.h b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.h index cf93faf6725754b330d71e4f077d57b5e2959956..64f8ecbef4b45c931ce12224b75f0063469b2b6f 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.h +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.h @@ -40,20 +40,21 @@ class VtkVisPipelineView : public QTreeView public: /// @brief Constructor. - VtkVisPipelineView(QWidget* parent = 0); + VtkVisPipelineView(QWidget* parent = nullptr); /// @brief Overridden to set model specific header properties. - virtual void setModel(QAbstractItemModel* model); + void setModel(QAbstractItemModel* model) override; protected slots: /// Emits itemSelected() signals when an items was selected. - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + void selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) override; void selectItem(vtkProp3D* actor); void selectItem(const QModelIndex &index); private: /// Creates a menu on right-clicking on an item. - void contextMenuEvent(QContextMenuEvent* event); + void contextMenuEvent(QContextMenuEvent* event) override; private slots: /// Adds a color lookup table to the current scalar array of the selected pipeline item. diff --git a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp index 97b8072c51aa274b1e82729487ba7e567a1f48dd..7235847531202acfcb848d09aa0af5b766893e6e 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp @@ -61,19 +61,20 @@ VtkVisPointSetItem::VtkVisPointSetItem( : VtkVisPipelineItem(algorithm, parentItem, data), _mapper(nullptr), _transformFilter(nullptr), _onPointData(true), _activeArrayName("") { - VtkVisPipelineItem* visParentItem = dynamic_cast<VtkVisPipelineItem*>(parentItem); + auto* visParentItem = dynamic_cast<VtkVisPipelineItem*>(parentItem); if (parentItem->parentItem()) { - // special case if parent is image but child is not (e.g. Image2BarChartFilter) + // special case if parent is image but child is not (e.g. + // Image2BarChartFilter) if (dynamic_cast<vtkImageAlgorithm*>(visParentItem->algorithm())) - _algorithm->SetInputConnection(visParentItem->algorithm()->GetOutputPort()); + _algorithm->SetInputConnection( + visParentItem->algorithm()->GetOutputPort()); else { - VtkVisPointSetItem* pointSetItem = - dynamic_cast<VtkVisPointSetItem*>(parentItem); + auto* pointSetItem = dynamic_cast<VtkVisPointSetItem*>(parentItem); if (pointSetItem) _algorithm->SetInputConnection( - pointSetItem->transformFilter()->GetOutputPort()); + pointSetItem->transformFilter()->GetOutputPort()); } } } @@ -120,7 +121,7 @@ void VtkVisPointSetItem::Initialize(vtkRenderer* renderer) // Determine the right pre-set properties // Order is: _algorithm, _compositeFilter, create a new one with props copied from parent - VtkAlgorithmProperties* vtkProps = dynamic_cast<VtkAlgorithmProperties*>(_algorithm); + auto* vtkProps = dynamic_cast<VtkAlgorithmProperties*>(_algorithm); if (!vtkProps) { vtkProps = dynamic_cast<VtkAlgorithmProperties*>(_compositeFilter); @@ -128,22 +129,28 @@ void VtkVisPointSetItem::Initialize(vtkRenderer* renderer) // Copy properties from parent or create a new VtkAlgorithmProperties if (!vtkProps) { - VtkVisPipelineItem* parentItem = dynamic_cast<VtkVisPipelineItem*>(this->parentItem()); + auto* parentItem = + dynamic_cast<VtkVisPipelineItem*>(this->parentItem()); while (parentItem) { VtkAlgorithmProperties* parentProps = nullptr; - if(dynamic_cast<VtkVisPointSetItem*>(parentItem)) - parentProps = dynamic_cast<VtkVisPointSetItem*>(parentItem)->getVtkProperties(); + if (dynamic_cast<VtkVisPointSetItem*>(parentItem)) + parentProps = dynamic_cast<VtkVisPointSetItem*>(parentItem) + ->getVtkProperties(); if (parentProps) { - vtkProps = new VtkAlgorithmProperties(); // TODO memory leak? - vtkProps->SetScalarVisibility(parentProps->GetScalarVisibility()); + vtkProps = + new VtkAlgorithmProperties(); // TODO memory leak? + vtkProps->SetScalarVisibility( + parentProps->GetScalarVisibility()); vtkProps->SetTexture(parentProps->GetTexture()); - vtkProps->SetActiveAttribute(parentProps->GetActiveAttribute()); + vtkProps->SetActiveAttribute( + parentProps->GetActiveAttribute()); parentItem = nullptr; } else - parentItem = dynamic_cast<VtkVisPipelineItem*>(parentItem->parentItem()); + parentItem = dynamic_cast<VtkVisPipelineItem*>( + parentItem->parentItem()); } // Has no parents @@ -198,7 +205,7 @@ void VtkVisPointSetItem::setVtkProperties(VtkAlgorithmProperties* vtkProps) QObject::connect(vtkProps, SIGNAL(ScalarVisibilityChanged(bool)), _mapper, SLOT(SetScalarVisibility(bool))); - vtkActor* actor = dynamic_cast<vtkActor*>(_actor); + auto* actor = dynamic_cast<vtkActor*>(_actor); if (actor) { if (vtkProps->GetTexture() != nullptr) @@ -221,7 +228,7 @@ void VtkVisPointSetItem::setVtkProperties(VtkAlgorithmProperties* vtkProps) int VtkVisPointSetItem::callVTKWriter(vtkAlgorithm* algorithm, const std::string &filename) const { std::string file_name_cpy(filename); - vtkPolyDataAlgorithm* algPD = dynamic_cast<vtkPolyDataAlgorithm*>(algorithm); + auto* algPD = dynamic_cast<vtkPolyDataAlgorithm*>(algorithm); if (algPD) { vtkSmartPointer<vtkXMLPolyDataWriter> pdWriter = @@ -233,7 +240,7 @@ int VtkVisPointSetItem::callVTKWriter(vtkAlgorithm* algorithm, const std::string return pdWriter->Write(); } - vtkUnstructuredGridAlgorithm* algUG = dynamic_cast<vtkUnstructuredGridAlgorithm*>(algorithm); + auto* algUG = dynamic_cast<vtkUnstructuredGridAlgorithm*>(algorithm); if (algUG) { vtkSmartPointer<vtkXMLUnstructuredGridWriter> ugWriter = @@ -300,7 +307,7 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) _mapper->ScalarVisibilityOn(); _mapper->UseLookupTableScalarRangeOn(); - QVtkDataSetMapper* mapper = dynamic_cast<QVtkDataSetMapper*>(_mapper); + auto* mapper = dynamic_cast<QVtkDataSetMapper*>(_mapper); if (mapper) { // Create a default color table when there is no lookup table for this attribute @@ -340,7 +347,7 @@ void VtkVisPointSetItem::setScale(double x, double y, double z) const { if (this->transformFilter()) { - vtkTransform* transform = + auto* transform = static_cast<vtkTransform*>(this->_transformFilter->GetTransform()); double* trans = transform->GetPosition(); transform->Identity(); @@ -354,7 +361,7 @@ void VtkVisPointSetItem::setTranslation(double x, double y, double z) const { if (this->transformFilter()) { - vtkTransform* transform = + auto* transform = static_cast<vtkTransform*>(this->_transformFilter->GetTransform()); double* scale = transform->GetScale(); transform->Identity(); diff --git a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.h b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.h index 3c5e37d15ea9ea398e3e46f1633a4a158200f9e8..d487f76dc3b34c53776be6030e4171b0dcc4d98b 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.h +++ b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.h @@ -49,31 +49,31 @@ public: VtkVisPointSetItem(VtkCompositeFilter* compositeFilter, TreeItem* parentItem, const QList<QVariant> data = QList<QVariant>()); - ~VtkVisPointSetItem(); + ~VtkVisPointSetItem() override; /// @brief Gets the last selected attribute. - const QString GetActiveAttribute() const; + const QString GetActiveAttribute() const override; /// @brief Get the scalar range for the active attribute void GetRangeForActiveAttribute(double range[2]) const; /// @brief Initializes vtkMapper and vtkActor necessary for visualization of /// the item and sets the item's properties. - void Initialize(vtkRenderer* renderer); + void Initialize(vtkRenderer* renderer) override; - vtkAlgorithm* transformFilter() const; + vtkAlgorithm* transformFilter() const override; /// @brief Sets the selected attribute array for the visualisation of the data set. - void SetActiveAttribute(const QString& name); + void SetActiveAttribute(const QString& name) override; /// @brief Scales the data in visualisation-space. - void setScale(double x, double y, double z) const; + void setScale(double x, double y, double z) const override; /// @brief Translates the item in visualisation-space. - void setTranslation(double x, double y, double z) const; + void setTranslation(double x, double y, double z) const override; /// @brief Enables / disables backface culling. - void setBackfaceCulling(bool enable) const; + void setBackfaceCulling(bool enable) const override; protected: QVtkDataSetMapper* _mapper; @@ -82,7 +82,8 @@ protected: std::string _activeArrayName; /// Selects the appropriate VTK-Writer object and writes the object to a file with the given name. - virtual int callVTKWriter(vtkAlgorithm* algorithm, const std::string &filename) const; + int callVTKWriter(vtkAlgorithm* algorithm, + const std::string& filename) const override; void SetScalarVisibility(bool on); diff --git a/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp b/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp index 0a9b4a99ead7ec1b2a61412cafae39d6a8fae7a9..4c3e61bb59c237d8428fb38e5fc56e64202a5b9b 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp @@ -66,7 +66,8 @@ void VtkVisTabWidget::setActiveItem( VtkVisPipelineItem* item ) _item = item; transformTabWidget->setEnabled(true); - vtkTransformFilter* transform_filter = dynamic_cast<vtkTransformFilter*>(_item->transformFilter()); + auto* transform_filter = + dynamic_cast<vtkTransformFilter*>(_item->transformFilter()); if (transform_filter) // if data set { actorPropertiesGroupBox->setEnabled(true); @@ -76,8 +77,8 @@ void VtkVisTabWidget::setActiveItem( VtkVisPipelineItem* item ) edgeColorPickerButton->setColor(vtkProps->GetEdgeColor()); opacitySlider->setValue((int)(vtkProps->GetOpacity() * 100.0)); - vtkTransform* transform = - static_cast<vtkTransform*>(transform_filter->GetTransform()); + auto* transform = + static_cast<vtkTransform*>(transform_filter->GetTransform()); if (transform) { double scale[3]; @@ -119,7 +120,8 @@ void VtkVisTabWidget::setActiveItem( VtkVisPipelineItem* item ) { const VtkVisImageItem* img = static_cast<VtkVisImageItem*>(_item); actorPropertiesGroupBox->setEnabled(false); - vtkImageChangeInformation* transform = static_cast<vtkImageChangeInformation*>(img->transformFilter()); + auto* transform = + static_cast<vtkImageChangeInformation*>(img->transformFilter()); double trans[3]; transform->GetOriginTranslation(trans); this->transX->blockSignals(true); @@ -197,13 +199,13 @@ void VtkVisTabWidget::on_scaleZ_textChanged(const QString &text) VtkVisPipelineItem* childItem = _item->child(i); if (childItem) { - VtkCompositeColorByHeightFilter* colorFilter = - dynamic_cast<VtkCompositeColorByHeightFilter*> - (childItem->compositeFilter()); + auto* colorFilter = + dynamic_cast<VtkCompositeColorByHeightFilter*>( + childItem->compositeFilter()); if (colorFilter) VtkColorByHeightFilter::SafeDownCast( - colorFilter->GetOutputAlgorithm())-> - SetTableRangeScaling(scale); + colorFilter->GetOutputAlgorithm()) + ->SetTableRangeScaling(scale); } } @@ -229,12 +231,13 @@ void VtkVisTabWidget::translateItem() void VtkVisTabWidget::buildProportiesDialog(VtkVisPipelineItem* item) { - QFormLayout* layout = static_cast<QFormLayout*>(this->scrollAreaWidgetContents->layout()); - while(layout->count()) + auto* layout = + static_cast<QFormLayout*>(this->scrollAreaWidgetContents->layout()); + while (layout->count()) delete layout->takeAt(0)->widget(); - QMap<QString, QVariant>* propMap = NULL; - QMap<QString, QList<QVariant> >* propVecMap = NULL; + QMap<QString, QVariant>* propMap = nullptr; + QMap<QString, QList<QVariant>>* propVecMap = nullptr; VtkAlgorithmProperties* algProps = item->getVtkProperties(); if (algProps == nullptr) @@ -244,7 +247,8 @@ void VtkVisTabWidget::buildProportiesDialog(VtkVisPipelineItem* item) if (item->compositeFilter()) { propMap = item->compositeFilter()->GetAlgorithmUserProperties(); - propVecMap = item->compositeFilter()->GetAlgorithmUserVectorProperties(); + propVecMap = + item->compositeFilter()->GetAlgorithmUserVectorProperties(); } else { @@ -315,7 +319,7 @@ void VtkVisTabWidget::buildProportiesDialog(VtkVisPipelineItem* item) QList<QVariant> values = i.value(); VtkAlgorithmPropertyVectorEdit* vectorEdit; - if (values.size() > 0) + if (!values.empty()) { QList<QString> valuesAsString; foreach (QVariant variant, values) diff --git a/Applications/DataExplorer/VtkVis/VtkVisTabWidget.h b/Applications/DataExplorer/VtkVis/VtkVisTabWidget.h index d815a25ecc762b6bbf25a59121e5f44272fced34..51e498fcc87ecd204025ebd8ec9fe7ec38b44dca 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisTabWidget.h +++ b/Applications/DataExplorer/VtkVis/VtkVisTabWidget.h @@ -30,7 +30,7 @@ class VtkVisTabWidget : public QWidget, public Ui_VtkVisTabWidgetBase public: /// Constructor - VtkVisTabWidget(QWidget* parent = 0); + VtkVisTabWidget(QWidget* parent = nullptr); protected slots: /// Updates the property panels to show informations on the given VtkVisPipelineItem. diff --git a/Applications/DataExplorer/main.cpp b/Applications/DataExplorer/main.cpp index 6c0d9aa1112950596fa124eabfa8ed3a1e12f82d..0e7bc1a981597df5e0b72c8dab83244d4d089cdd 100644 --- a/Applications/DataExplorer/main.cpp +++ b/Applications/DataExplorer/main.cpp @@ -8,8 +8,8 @@ #ifdef VTKFBXCONVERTER_FOUND #include <fbxsdk.h> #include "Common.h" -FbxManager* lSdkManager = NULL; -FbxScene* lScene = NULL; +FbxManager* lSdkManager = nullptr; +FbxScene* lScene = nullptr; #endif #include <vtkSmartPointer.h> @@ -27,8 +27,8 @@ int main(int argc, char* argv[]) vtkOutputWindow::SetInstance(myOutputWindow); LOGOG_INITIALIZE(); - logog::Cout* logogCout = new logog::Cout; - BaseLib::LogogSimpleFormatter* formatter = new BaseLib::LogogSimpleFormatter; + auto* logogCout = new logog::Cout; + auto* formatter = new BaseLib::LogogSimpleFormatter; logogCout->SetFormatter(*formatter); QApplication a(argc, argv); QApplication::setApplicationName("OpenGeoSys - Data Explorer"); diff --git a/Applications/DataExplorer/mainwindow.cpp b/Applications/DataExplorer/mainwindow.cpp index 5c826f142d21994ed6459e79eb2dce060ad660be..905df83a4af9b245f4f7d6c66101e9fa6ad0cbcb 100644 --- a/Applications/DataExplorer/mainwindow.cpp +++ b/Applications/DataExplorer/mainwindow.cpp @@ -321,7 +321,7 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) menuWindows->addAction(showVisDockAction); // Presentation mode - QMenu* presentationMenu = new QMenu(this); + auto* presentationMenu = new QMenu(this); presentationMenu->setTitle("Presentation on"); connect(presentationMenu, SIGNAL(aboutToShow()), this, SLOT(createPresentationMenu())); @@ -379,7 +379,7 @@ void MainWindow::showVisDockWidget(bool show) void MainWindow::open(int file_type) { QSettings settings; - ImportFileType::type t = static_cast<ImportFileType::type>(file_type); + auto t = static_cast<ImportFileType::type>(file_type); QString type_str = QString::fromStdString((ImportFileType::convertImportFileTypeToString(t))); QString fileName = QFileDialog::getOpenFileName(this, "Select " + type_str + " file to import", settings.value("lastOpenedFileDirectory").toString(), @@ -395,7 +395,7 @@ void MainWindow::open(int file_type) void MainWindow::openRecentFile() { - QAction* action = qobject_cast<QAction*> (sender()); + auto* action = qobject_cast<QAction*>(sender()); if (action) loadFile(ImportFileType::OGS, action->data().toString()); } @@ -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") @@ -699,7 +699,7 @@ void MainWindow::about() QMenu* MainWindow::createImportFilesMenu() { - QSignalMapper* signal_mapper = new QSignalMapper(this); //owned by MainWindow + auto* signal_mapper = new QSignalMapper(this); // owned by MainWindow QMenu* importFiles = new QMenu("&Import Files", this); QAction* feflowFiles = importFiles->addAction("&FEFLOW Files..."); connect(feflowFiles, SIGNAL(triggered()), signal_mapper, SLOT(map())); @@ -746,7 +746,7 @@ void MainWindow::loadPetrelFiles() this, "Select surface data file(s) to import", "", "Petrel files (*)"); QStringList well_path_file_names = QFileDialog::getOpenFileNames( this, "Select well path data file(s) to import", "", "Petrel files (*)"); - if (sfc_file_names.size() != 0 || well_path_file_names.size() != 0) + if (!sfc_file_names.empty() || !well_path_file_names.empty()) { QStringList::const_iterator it = sfc_file_names.begin(); std::list<std::string> sfc_files; @@ -926,8 +926,7 @@ void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, gmsh_io.writeToFile(fileName.toStdString()); } - - if (system(NULL) != 0) // command processor available + if (system(nullptr) != 0) // command processor available { QSettings settings; std::string gmsh_path = settings.value("DataExplorerGmshPath").toString().toStdString(); @@ -968,7 +967,7 @@ void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, void MainWindow::showFileConverter() { - OGSFileConverter* dlg = new OGSFileConverter(this); + auto* dlg = new OGSFileConverter(this); dlg->setAttribute(Qt::WA_DeleteOnClose); dlg->show(); dlg->raise(); @@ -982,7 +981,7 @@ void MainWindow::showDiagramPrefsDialog(QModelIndex &index) if ((stn->type() == GeoLib::Station::StationType::STATION) && stn->getSensorData()) { - DiagramPrefsDialog* prefs ( new DiagramPrefsDialog(stn) ); + auto* prefs(new DiagramPrefsDialog(stn)); prefs->setAttribute(Qt::WA_DeleteOnClose); prefs->show(); } @@ -1000,7 +999,7 @@ void MainWindow::showDiagramPrefsDialog() { QDir dir = QDir(fileName); settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); - DiagramPrefsDialog* prefs = new DiagramPrefsDialog(fileName); + auto* prefs = new DiagramPrefsDialog(fileName); prefs->setAttribute(Qt::WA_DeleteOnClose); prefs->show(); } @@ -1021,7 +1020,7 @@ void MainWindow::showGeoNameDialog(const std::string &geometry_name, const GeoLi void MainWindow::showStationNameDialog(const std::string& stn_vec_name, std::size_t id) { std::vector<GeoLib::Point*> const* stations = _project.getGEOObjects().getStationVec(stn_vec_name); - GeoLib::Station *const stn = static_cast<GeoLib::Station*>((*stations)[id]); + auto* const stn = static_cast<GeoLib::Station*>((*stations)[id]); SetNameDialog dlg("Station", id, stn->getName()); if (dlg.exec() != QDialog::Accepted) return; @@ -1048,7 +1047,7 @@ void MainWindow::showMeshElementRemovalDialog() void MainWindow::showMeshAnalysisDialog() { - MeshAnalysisDialog* dlg = new MeshAnalysisDialog(this->_project.getMeshObjects()); + auto* dlg = new MeshAnalysisDialog(this->_project.getMeshObjects()); dlg->exec(); } @@ -1204,12 +1203,13 @@ void MainWindow::on_actionExportObj_triggered(bool checked /*= false*/) void MainWindow::createPresentationMenu() { - QMenu* menu = static_cast<QMenu*> (QObject::sender()); + auto* menu = static_cast<QMenu*>(QObject::sender()); menu->clear(); if (!_vtkWidget->parent()) { QAction* action = new QAction("Quit presentation mode", menu); - connect(action, SIGNAL(triggered()), this, SLOT(quitPresentationMode())); + connect(action, SIGNAL(triggered()), this, + SLOT(quitPresentationMode())); action->setShortcutContext(Qt::WidgetShortcut); action->setShortcut(QKeySequence(Qt::Key_Escape)); menu->addAction(action); @@ -1245,7 +1245,7 @@ void MainWindow::startPresentationMode() // Move the widget to the screen and maximize it // Real fullscreen hides the menu - _vtkWidget->setParent(NULL, Qt::Window); + _vtkWidget->setParent(nullptr, Qt::Window); _vtkWidget->move(QPoint(_screenGeometries[screen].x(), _screenGeometries[screen].y())); //_vtkWidget->showFullScreen(); @@ -1284,7 +1284,7 @@ QString MainWindow::getLastUsedDir() QSettings settings; QString fileName(""); QStringList files = settings.value("recentFileList").toStringList(); - if (files.size() != 0) + if (!files.empty()) return QFileInfo(files[0]).absolutePath(); else return QDir::homePath(); diff --git a/Applications/DataExplorer/mainwindow.h b/Applications/DataExplorer/mainwindow.h index 414359274e5b1d127b742b5377e6c81d1c69f155..f1ce0b3d15151fea533c200ae4f7092fcc658bb5 100644 --- a/Applications/DataExplorer/mainwindow.h +++ b/Applications/DataExplorer/mainwindow.h @@ -45,14 +45,14 @@ class MainWindow : public QMainWindow, public Ui_MainWindowClass Q_OBJECT public: - MainWindow(QWidget* parent = 0); + MainWindow(QWidget* parent = nullptr); void ShowWindow(); void HideWindow(); void loadFileOnStartUp(const QString &fileName); protected: - void closeEvent( QCloseEvent* event ); + void closeEvent(QCloseEvent* event) override; protected slots: void showGeoDockWidget( bool show ); diff --git a/Applications/DataHolderLib/Color.cpp b/Applications/DataHolderLib/Color.cpp index 193c18d208353dc0435e4a163848251e01e88171..e651d72f6020de72e534fff4dc856421e69102fa 100644 --- a/Applications/DataHolderLib/Color.cpp +++ b/Applications/DataHolderLib/Color.cpp @@ -44,7 +44,7 @@ Color getRandomColor() Color const getColor(const std::string &id, std::map<std::string, Color> &colors) { - for (std::map<std::string, Color>::const_iterator it=colors.begin(); it !=colors.end(); ++it) + for (auto it = colors.begin(); it != colors.end(); ++it) { if (id.compare(it->first) == 0) return it->second; diff --git a/Applications/DataHolderLib/ColorLookupTable.cpp b/Applications/DataHolderLib/ColorLookupTable.cpp index 31fdd0726e47d4936c893540ac244589a357e382..0e8778d4bd3763d5a5354fb45d013f9ba718ed45 100644 --- a/Applications/DataHolderLib/ColorLookupTable.cpp +++ b/Applications/DataHolderLib/ColorLookupTable.cpp @@ -30,12 +30,12 @@ void ColorLookupTable::setTableRange(double min, double max) void ColorLookupTable::setColor(double id, DataHolderLib::Color const& color) { if ((id>_range.first) && (id<_range.second)) - _lut.push_back(std::make_tuple(id, color, "")); + _lut.emplace_back(id, color, ""); } void ColorLookupTable::setColor(std::string const& name, DataHolderLib::Color const& color) { - _lut.push_back(std::make_tuple(0, color, name)); + _lut.emplace_back(0, color, name); } diff --git a/Applications/FileIO/AsciiRasterInterface.cpp b/Applications/FileIO/AsciiRasterInterface.cpp index 495189c6e4fcefcb5929b7a9f22435fc11b71fc5..e62c67114823419066700e45fc2010be6eddadfe 100644 --- a/Applications/FileIO/AsciiRasterInterface.cpp +++ b/Applications/FileIO/AsciiRasterInterface.cpp @@ -47,15 +47,15 @@ GeoLib::Raster* AsciiRasterInterface::getRasterFromASCFile(std::string const& fn // header information GeoLib::RasterHeader header; if (readASCHeader(in, header)) { - double* values = new double[header.n_cols*header.n_rows]; + auto* values = new double[header.n_cols * header.n_rows]; std::string s; // read the data into the double-array for (std::size_t j(0); j < header.n_rows; ++j) { const std::size_t idx ((header.n_rows - j - 1) * header.n_cols); for (std::size_t i(0); i < header.n_cols; ++i) { in >> s; - values[idx+i] = strtod(BaseLib::replaceString(",", ".", s).c_str(),0); - + values[idx + i] = strtod( + BaseLib::replaceString(",", ".", s).c_str(), nullptr); } } in.close(); @@ -87,26 +87,30 @@ bool AsciiRasterInterface::readASCHeader(std::ifstream &in, GeoLib::RasterHeader in >> tag; if (tag.compare("xllcorner") == 0 || tag.compare("xllcenter") == 0) { in >> value; - header.origin[0] = strtod(BaseLib::replaceString(",", ".", value).c_str(), 0); + header.origin[0] = + strtod(BaseLib::replaceString(",", ".", value).c_str(), nullptr); } else return false; in >> tag; if (tag.compare("yllcorner") == 0 || tag.compare("yllcenter") == 0) { in >> value; - header.origin[1] = strtod(BaseLib::replaceString(",", ".", value).c_str(), 0); + header.origin[1] = + strtod(BaseLib::replaceString(",", ".", value).c_str(), nullptr); } else return false; header.origin[2] = 0; in >> tag; if (tag.compare("cellsize") == 0) { in >> value; - header.cell_size = strtod(BaseLib::replaceString(",", ".", value).c_str(), 0); + header.cell_size = + strtod(BaseLib::replaceString(",", ".", value).c_str(), nullptr); } else return false; in >> tag; if (tag.compare("NODATA_value") == 0 || tag.compare("nodata_value") == 0) { in >> value; - header.no_data = strtod(BaseLib::replaceString(",", ".", value).c_str(), 0); + header.no_data = + strtod(BaseLib::replaceString(",", ".", value).c_str(), nullptr); } else return false; return true; @@ -128,7 +132,7 @@ GeoLib::Raster* AsciiRasterInterface::getRasterFromSurferFile(std::string const& if (readSurferHeader(in, header, min, max)) { const double no_data_val (min-1); - double* values = new double[header.n_cols*header.n_rows]; + auto* values = new double[header.n_cols * header.n_rows]; std::string s; // read the data into the double-array for (std::size_t j(0); j < header.n_rows; ++j) @@ -137,7 +141,8 @@ GeoLib::Raster* AsciiRasterInterface::getRasterFromSurferFile(std::string const& for (std::size_t i(0); i < header.n_cols; ++i) { in >> s; - const double val (strtod(BaseLib::replaceString(",", ".", s).c_str(),0)); + const double val(strtod( + BaseLib::replaceString(",", ".", s).c_str(), nullptr)); values[idx+i] = (val > max || val < min) ? no_data_val : val; } } @@ -221,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 cd9b2001effdc0a07b16f67b70d5170e38e466dd..d1f462ec568df9e76862186ce86818aff256c1be 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/CsvInterface.h b/Applications/FileIO/CsvInterface.h index fe87228764eb1fba16c25439711dbb5e638683dc..2103e73306c32f866f9340314f5e29d72e325c8e 100644 --- a/Applications/FileIO/CsvInterface.h +++ b/Applications/FileIO/CsvInterface.h @@ -80,7 +80,7 @@ public: } /// Writes the CSV file. - bool write(); + bool write() override; /** * Reads 3D points from a CSV file. It is assumed that the file has a header diff --git a/Applications/FileIO/FEFLOW/FEFLOWGeoInterface.cpp b/Applications/FileIO/FEFLOW/FEFLOWGeoInterface.cpp index d926833ae2c6d5686976b519122b771f10c7ec2a..ed934f0a32f424063ea326229ecd6dc1f75fc554 100644 --- a/Applications/FileIO/FEFLOW/FEFLOWGeoInterface.cpp +++ b/Applications/FileIO/FEFLOW/FEFLOWGeoInterface.cpp @@ -200,7 +200,7 @@ void FEFLOWGeoInterface::readSuperMesh(std::ifstream& in, const std::size_t n_points = str.toLong(); QString str_ptId_list = xmlEle.text().simplified(); { - GeoLib::Polyline* line = new GeoLib::Polyline(*points); + auto* line = new GeoLib::Polyline(*points); lines->push_back(line); std::istringstream ss(str_ptId_list.toStdString()); for (std::size_t i = 0; i < n_points; i++) diff --git a/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp b/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp index 78c1c4d084e31feb38446da656ea6ea74beb25fe..1a85ecedf565248d058b5867542952ca26598fd2 100644 --- a/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp +++ b/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp @@ -351,7 +351,7 @@ std::vector<std::size_t> FEFLOWMeshInterface::getIndexList( else if (is_range) { const std::size_t start = vec_node_IDs.back(); - const std::size_t end = BaseLib::str2number<std::size_t>(str); + const auto end = BaseLib::str2number<std::size_t>(str); for (std::size_t i = start + 1; i < end + 1; i++) vec_node_IDs.push_back(i); is_range = false; @@ -477,7 +477,7 @@ MeshLib::Element* FEFLOWMeshInterface::readElement( unsigned idx[8]; for (std::size_t i = 0; i < n_nodes_of_element; ++i) ss >> idx[i]; - MeshLib::Node** ele_nodes = new MeshLib::Node*[n_nodes_of_element]; + auto** ele_nodes = new MeshLib::Node*[n_nodes_of_element]; switch (elem_type) { @@ -518,7 +518,7 @@ MeshLib::Element* FEFLOWMeshInterface::readElement( unsigned idx[8]; for (std::size_t i = 0; i < fem_dim.n_nodes_of_element; ++i) ss >> idx[i]; - MeshLib::Node** ele_nodes = new MeshLib::Node*[fem_dim.n_nodes_of_element]; + auto** ele_nodes = new MeshLib::Node*[fem_dim.n_nodes_of_element]; switch (elem_type) { diff --git a/Applications/FileIO/GMSInterface.cpp b/Applications/FileIO/GMSInterface.cpp index 5ef41b250fbcebfe4e19ced8f3c17da7c3de37f3..1a2f2fbcf737f4aef32a79cdf3eaa37e05ad92ef 100644 --- a/Applications/FileIO/GMSInterface.cpp +++ b/Applications/FileIO/GMSInterface.cpp @@ -41,8 +41,8 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, double depth(-9999.0); std::string line(""), cName(""), sName(""); std::list<std::string>::const_iterator it; - GeoLib::Point* pnt = new GeoLib::Point(); - GeoLib::StationBorehole* newBorehole = NULL; + auto* pnt = new GeoLib::Point(); + GeoLib::StationBorehole* newBorehole = nullptr; std::ifstream in( filename.c_str() ); if (!in.is_open()) @@ -64,9 +64,9 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, if (fields.begin()->compare(cName) == 0) // add new layer { it = fields.begin(); - (*pnt)[0] = strtod((++it)->c_str(), 0); - (*pnt)[1] = strtod((++it)->c_str(), 0); - (*pnt)[2] = strtod((++it)->c_str(), 0); + (*pnt)[0] = strtod((++it)->c_str(), nullptr); + (*pnt)[1] = strtod((++it)->c_str(), nullptr); + (*pnt)[2] = strtod((++it)->c_str(), nullptr); // check if current layer has a thickness of 0.0. // if so skip it since it will mess with the vtk-visualisation later on! @@ -85,16 +85,16 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, } else // add new borehole { - if (newBorehole != NULL) + if (newBorehole != nullptr) { newBorehole->setDepth((*newBorehole)[2] - depth); boreholes->push_back(newBorehole); } cName = *fields.begin(); it = fields.begin(); - (*pnt)[0] = strtod((++it)->c_str(), 0); - (*pnt)[1] = strtod((++it)->c_str(), 0); - (*pnt)[2] = strtod((++it)->c_str(), 0); + (*pnt)[0] = strtod((++it)->c_str(), nullptr); + (*pnt)[1] = strtod((++it)->c_str(), nullptr); + (*pnt)[2] = strtod((++it)->c_str(), nullptr); sName = (*(++it)); newBorehole = GeoLib::StationBorehole::createStation(cName, (*pnt)[0], @@ -107,7 +107,7 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, ERR("GMSInterface::readBoreholeFromGMS(): Error reading format."); } // write the last borehole from the file - if (newBorehole != NULL) + if (newBorehole != nullptr) { newBorehole->setDepth((*newBorehole)[2] - depth); boreholes->push_back(newBorehole); @@ -142,26 +142,24 @@ void GMSInterface::writeBoreholesToGMS(const std::vector<GeoLib::Point*>* statio for (auto station_as_point : *stations) { - GeoLib::StationBorehole* station = - static_cast<GeoLib::StationBorehole*>(station_as_point); + auto* station = static_cast<GeoLib::StationBorehole*>(station_as_point); std::vector<GeoLib::Point*> profile = station->getProfile(); - std::vector<std::string> soilNames = station->getSoilNames(); - //std::size_t idx = 0; + std::vector<std::string> soilNames = station->getSoilNames(); + // std::size_t idx = 0; std::string current_soil_name(""); std::size_t nLayers = profile.size(); for (std::size_t i = 1; i < nLayers; i++) { - if ( (i > 1) && (soilNames[i].compare(soilNames[i - 1]) == 0) ) + if ((i > 1) && (soilNames[i].compare(soilNames[i - 1]) == 0)) continue; - //idx = getSoilID(soilID, soilNames[i]); + // idx = getSoilID(soilID, soilNames[i]); current_soil_name = soilNames[i]; out << station->getName() << "\t" << std::fixed - << (*(profile[i - 1]))[0] << "\t" - << (*(profile[i - 1]))[1] << "\t" - << (*(profile[i - 1]))[2] << "\t" - << current_soil_name/*idx*/ << "\n"; + << (*(profile[i - 1]))[0] << "\t" << (*(profile[i - 1]))[1] + << "\t" << (*(profile[i - 1]))[2] << "\t" + << current_soil_name /*idx*/ << "\n"; } out << station->getName() << "\t" << std::fixed << (*(profile[nLayers - 1]))[0] << "\t" @@ -226,7 +224,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) if (!in.is_open()) { ERR("GMSInterface::readGMS3DMMesh(): Could not open file %s.", filename.c_str()); - return NULL; + return nullptr; } // Read data from file @@ -234,7 +232,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) if (line.compare("MESH3D") != 0) { ERR("GMSInterface::readGMS3DMMesh(): Could not read expected file header."); - return NULL; + return nullptr; } INFO("GMSInterface::readGMS3DMMesh(): Read GMS-3DM mesh."); @@ -255,7 +253,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) { std::stringstream str(line); str >> dummy >> id >> x[0] >> x[1] >> x[2]; - MeshLib::Node* node = new MeshLib::Node(x, id); + auto* node = new MeshLib::Node(x, id); id_map.insert(std::pair<unsigned, unsigned>(id,count++)); nodes.push_back(node); } @@ -278,7 +276,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) str >> dummy >> id >> node_idx[0] >> node_idx[1] >> node_idx[2] >> node_idx[3] >> node_idx[4] >> node_idx[5] >> mat_id; - MeshLib::Node** prism_nodes = new MeshLib::Node*[6]; + auto** prism_nodes = new MeshLib::Node*[6]; for (unsigned k(0); k<6; k++) { prism_nodes[k] = nodes[id_map.find(node_idx[k])->second]; } @@ -289,7 +287,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) { str >> dummy >> id >> node_idx[0] >> node_idx[1] >> node_idx[2] >> node_idx[3] >> mat_id; - MeshLib::Node** tet_nodes = new MeshLib::Node*[4]; + auto** tet_nodes = new MeshLib::Node*[4]; for (unsigned k(0); k<4; k++) { tet_nodes[k] = nodes[id_map.find(node_idx[k])->second]; } @@ -300,7 +298,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) { str >> dummy >> id >> node_idx[0] >> node_idx[1] >> node_idx[2] >> node_idx[3] >> node_idx[4] >> mat_id; - MeshLib::Node** pyramid_nodes = new MeshLib::Node*[5]; + auto** pyramid_nodes = new MeshLib::Node*[5]; for (unsigned k(0); k<5; k++) { pyramid_nodes[k] = nodes[id_map.find(node_idx[k])->second]; } @@ -314,7 +312,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) { WARN("GMSInterface::readGMS3DMMesh() - Element type \"%s\" not recognised.", element_id.c_str()); - return NULL; + return nullptr; } } diff --git a/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.cpp b/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.cpp index b8e42c1ff6da14a1da17e41ec5cb16b9bb57c106..202a16998a659084488246c67d2cf448b700f951 100644 --- a/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.cpp +++ b/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.cpp @@ -30,11 +30,13 @@ namespace FileIO { namespace GMSH { - -GMSHAdaptiveMeshDensity::GMSHAdaptiveMeshDensity(double pnt_density, double station_density, - std::size_t max_pnts_per_leaf) : - _pnt_density(pnt_density), _station_density(station_density), - _max_pnts_per_leaf(max_pnts_per_leaf), _quad_tree(NULL) +GMSHAdaptiveMeshDensity::GMSHAdaptiveMeshDensity(double pnt_density, + double station_density, + std::size_t max_pnts_per_leaf) + : _pnt_density(pnt_density), + _station_density(station_density), + _max_pnts_per_leaf(max_pnts_per_leaf), + _quad_tree(nullptr) { } diff --git a/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.h b/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.h index 3b3680eff7714da83d16ded14debf6afac51ce94..93de9473ba91d6f442b9aebef26ec632f21a185a 100644 --- a/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.h +++ b/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.h @@ -33,11 +33,11 @@ public: GMSHAdaptiveMeshDensity(double pnt_density, double station_density, std::size_t max_pnts_per_leaf); - virtual ~GMSHAdaptiveMeshDensity(); - void initialize(std::vector<GeoLib::Point const*> const& pnts); - double getMeshDensityAtPoint(GeoLib::Point const* const pnt) const; + ~GMSHAdaptiveMeshDensity() override; + void initialize(std::vector<GeoLib::Point const*> const& pnts) override; + double getMeshDensityAtPoint(GeoLib::Point const* const pnt) const override; void addPoints(std::vector<GeoLib::Point const*> const& pnts); - double getMeshDensityAtStation(GeoLib::Point const* const) const; + double getMeshDensityAtStation(GeoLib::Point const* const) const override; void getSteinerPoints (std::vector<GeoLib::Point*> & pnts, std::size_t additional_levels = 0) const; #ifndef NDEBUG diff --git a/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.h b/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.h index fb4fb2bea08e18b9245d3ecf3635a4a2688cfcae..a9b927c942c62a2380c161e74e6e66a32f0732c8 100644 --- a/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.h +++ b/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.h @@ -21,10 +21,10 @@ class GMSHFixedMeshDensity : public GMSHMeshDensityStrategy { public: GMSHFixedMeshDensity(double mesh_density); - void initialize(std::vector<GeoLib::Point const*> const& vec); - double getMeshDensityAtPoint(GeoLib::Point const*const) const; - double getMeshDensityAtStation(GeoLib::Point const*const) const; - virtual ~GMSHFixedMeshDensity() {} + void initialize(std::vector<GeoLib::Point const*> const& vec) override; + double getMeshDensityAtPoint(GeoLib::Point const* const) const override; + double getMeshDensityAtStation(GeoLib::Point const* const) const override; + ~GMSHFixedMeshDensity() override = default; private: double _mesh_density; diff --git a/Applications/FileIO/Gmsh/GMSHInterface.cpp b/Applications/FileIO/Gmsh/GMSHInterface.cpp index ee7bb0e948c2cfb325c25ed3ef37ac4dfb08a2b3..43e497936b7eb3f4fd998cfb08c4a776f5343932 100644 --- a/Applications/FileIO/Gmsh/GMSHInterface.cpp +++ b/Applications/FileIO/Gmsh/GMSHInterface.cpp @@ -93,9 +93,8 @@ int GMSHInterface::writeGMSHInputFile(std::ostream& out) _keep_preprocessed_geometry = true; } - std::vector<GeoLib::Point*>* merged_pnts( - const_cast<std::vector<GeoLib::Point*>*>( - _geo_objs.getPointVec(_gmsh_geo_name))); + auto* merged_pnts(const_cast<std::vector<GeoLib::Point*>*>( + _geo_objs.getPointVec(_gmsh_geo_name))); if (! merged_pnts) { ERR("GMSHInterface::writeGMSHInputFile(): Did not found any points."); return 2; @@ -193,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& polygon_tree : _polygon_tree_list) + { + polygon_tree->initMeshDensityStrategy(); } // *** create GMSH data structures @@ -204,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& polygon_tree : _polygon_tree_list) + { + polygon_tree->createGMSHPoints(_gmsh_pnts); } // *** finally write data :-) diff --git a/Applications/FileIO/Gmsh/GMSHInterface.h b/Applications/FileIO/Gmsh/GMSHInterface.h index ef6a7dc5c59bd747718c4e1dbd9564930edc9c31..ae356a1a87da2976bf51da13f89b1985364c48f6 100644 --- a/Applications/FileIO/Gmsh/GMSHInterface.h +++ b/Applications/FileIO/Gmsh/GMSHInterface.h @@ -75,10 +75,10 @@ public: GMSHInterface& operator=(GMSHInterface const&) = delete; GMSHInterface& operator=(GMSHInterface &&) = delete; - ~GMSHInterface(); + ~GMSHInterface() override; protected: - bool write(); + bool write() override; private: /** diff --git a/Applications/FileIO/Gmsh/GMSHMeshDensityStrategy.h b/Applications/FileIO/Gmsh/GMSHMeshDensityStrategy.h index 3b14475dabf9492eb19adacb5dcfa45e319af86d..c0725adfdfe4a4f1485484418cecf555bc1d624e 100644 --- a/Applications/FileIO/Gmsh/GMSHMeshDensityStrategy.h +++ b/Applications/FileIO/Gmsh/GMSHMeshDensityStrategy.h @@ -28,7 +28,7 @@ namespace GMSH class GMSHMeshDensityStrategy { public: - virtual ~GMSHMeshDensityStrategy() {} + virtual ~GMSHMeshDensityStrategy() = default; virtual void initialize(std::vector<GeoLib::Point const*> const&) = 0; virtual double getMeshDensityAtPoint(GeoLib::Point const*const) const = 0; virtual double getMeshDensityAtStation(GeoLib::Point const*const) const = 0; diff --git a/Applications/FileIO/Gmsh/GMSHPoint.h b/Applications/FileIO/Gmsh/GMSHPoint.h index f1a4f11c1d915ea9ab6bcdf04b589e334463b208..5de076664f9315e8bc272c59731c1798e9cdb572 100644 --- a/Applications/FileIO/Gmsh/GMSHPoint.h +++ b/Applications/FileIO/Gmsh/GMSHPoint.h @@ -21,7 +21,8 @@ class GMSHPoint final : public GeoLib::Point { public: GMSHPoint(GeoLib::Point const& pnt, std::size_t id, double mesh_density); - void write(std::ostream &os) const; + void write(std::ostream& os) const override; + private: double _mesh_density; }; diff --git a/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp b/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp index c45b9e14f1404b6a6c776afd4e764c04f2b498ae..f89729114b4c150e335c35d2b66697c1d987e4a8 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& child : _children) + { + std::size_t const n_pnts(child->getPolygon()->getNumberOfPoints()); for (std::size_t k(1); k<n_pnts; k++) { if (GeoLib::containsEdge(*(_parent->getPolygon()), _node_polygon->getPointID(k-1), @@ -280,8 +281,9 @@ void GMSHPolygonTree::createGMSHPoints(std::vector<GMSHPoint*> & gmsh_pnts) cons } // walk through children - for (std::list<SimplePolygonTree*>::const_iterator it (_children.begin()); it != _children.end(); ++it) { - dynamic_cast<GMSHPolygonTree*>((*it))->createGMSHPoints(gmsh_pnts); + for (auto child : _children) + { + dynamic_cast<GMSHPolygonTree*>(child)->createGMSHPoints(gmsh_pnts); } } @@ -332,11 +334,14 @@ 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 (std::list<SimplePolygonTree*>::const_iterator it (_children.begin()); it != _children.end(); ++it) { - dynamic_cast<GMSHPolygonTree*>((*it))->writeSubPolygonsAsLineConstraints(line_offset, sfc_number, out); + for (auto child : _children) + { + dynamic_cast<GMSHPolygonTree*>(child) + ->writeSubPolygonsAsLineConstraints(line_offset, sfc_number, out); } - if (_parent != NULL) { + if (_parent != nullptr) + { const std::size_t n_pnts(_node_polygon->getNumberOfPoints()); std::size_t first_pnt_id(_node_polygon->getPointID(0)), second_pnt_id; for (std::size_t k(1); k<n_pnts; k++) { diff --git a/Applications/FileIO/Gmsh/GMSHPolygonTree.h b/Applications/FileIO/Gmsh/GMSHPolygonTree.h index 0ed605482b77af64948668c10a01329eb1daf743..dac4afa61abc6c44be4aec740f1091d3108f3724 100644 --- a/Applications/FileIO/Gmsh/GMSHPolygonTree.h +++ b/Applications/FileIO/Gmsh/GMSHPolygonTree.h @@ -37,7 +37,7 @@ public: GMSHPolygonTree(GeoLib::PolygonWithSegmentMarker* polygon, GMSHPolygonTree * parent, GeoLib::GEOObjects &geo_objs, std::string const& geo_name, GMSHMeshDensityStrategy * mesh_density_strategy); - virtual ~GMSHPolygonTree(); + ~GMSHPolygonTree() override; /** Mark the segments shared by several polygons. */ void markSharedSegments(); diff --git a/Applications/FileIO/Gmsh/GmshReader.cpp b/Applications/FileIO/Gmsh/GmshReader.cpp index 6717e85031bd680db6ed56e6af7e3fead0815482..fab12ea7df974d00664f65158047194949fa2d62 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/FileIO/PetrelInterface.cpp b/Applications/FileIO/PetrelInterface.cpp index adc1f2679de2596ff9a8d9f0ac582fdce5438326..60a507b864a8300ad459e3a032be7397ebf4baeb 100644 --- a/Applications/FileIO/PetrelInterface.cpp +++ b/Applications/FileIO/PetrelInterface.cpp @@ -67,11 +67,11 @@ PetrelInterface::PetrelInterface(std::list<std::string> &sfc_fnames, // store data in GEOObject geo_obj->addPointVec(std::unique_ptr<std::vector<GeoLib::Point*>>(pnt_vec), _unique_name); - if (well_vec->size() > 0) + if (!well_vec->empty()) geo_obj->addStationVec( std::unique_ptr<std::vector<GeoLib::Point*>>(well_vec), _unique_name); - if (ply_vec->size() > 0) + if (!ply_vec->empty()) geo_obj->addPolylineVec( std::unique_ptr<std::vector<GeoLib::Polyline*>>(ply_vec), _unique_name); @@ -210,7 +210,7 @@ void PetrelInterface::readPetrelWellTraceData(std::istream &in) // read column information std::list<std::string> str_list = BaseLib::splitString(line, ' '); - std::list<std::string>::const_iterator it = str_list.begin(); + auto it = str_list.begin(); while (it != str_list.end()) { INFO("PetrelInterface::readPetrelWellTraceData(): column information: %s.", it->c_str()); ++it; diff --git a/Applications/FileIO/SHPInterface.cpp b/Applications/FileIO/SHPInterface.cpp index c1589b7f95d858e9160bf6d408ef7ba1baa37e16..5e3969bd7d790eed88d510ec23fc7c8cbdcec7f1 100644 --- a/Applications/FileIO/SHPInterface.cpp +++ b/Applications/FileIO/SHPInterface.cpp @@ -79,9 +79,9 @@ void SHPInterface::readPoints(const SHPHandle &hSHP, int numberOfElements, std:: for (int i = 0; i < numberOfElements; i++) { hSHPObject = SHPReadObject(hSHP, i); - GeoLib::Point* pnt = - new GeoLib::Point(*(hSHPObject->padfX), *(hSHPObject->padfY), - *(hSHPObject->padfZ)); + auto* pnt = + new GeoLib::Point(*(hSHPObject->padfX), *(hSHPObject->padfY), + *(hSHPObject->padfZ)); points->push_back(pnt); } @@ -158,7 +158,7 @@ void SHPInterface::readPolylines(const SHPHandle &hSHP, int numberOfElements, st int const lastPnt = (p<(noOfParts - 1)) ? *(hSHPObject->panPartStart + p + 1) : noOfPoints; - GeoLib::Polyline* line = new GeoLib::Polyline(*points.getVector()); + auto* line = new GeoLib::Polyline(*points.getVector()); // create polyline for (int j = firstPnt; j < lastPnt; ++j) { @@ -262,7 +262,9 @@ bool SHPInterface::write2dMeshToSHP(const std::string &file_name, const MeshLib: DBFWriteIntegerAttribute(hDBF, polygon_id, node1_field, e->getNode(1)->getID()); DBFWriteIntegerAttribute(hDBF, polygon_id, node2_field, e->getNode(2)->getID()); - SHPObject *object = SHPCreateObject(SHPT_POLYGON, polygon_id++, 0, 0, NULL, ++nNodes, padfX, padfY, padfZ, NULL); + SHPObject* object = + SHPCreateObject(SHPT_POLYGON, polygon_id++, 0, nullptr, nullptr, + ++nNodes, padfX, padfY, padfZ, nullptr); SHPWriteObject(hSHP, -1, object); // Note: cleaning up the coordinate arrays padfX, -Y, -Z results in a crash, I assume that shapelib removes them diff --git a/Applications/FileIO/TetGenInterface.cpp b/Applications/FileIO/TetGenInterface.cpp index 215a6f91b4853a8c53fe221fba6e2bf08d6c3486..c19ad9e90627bb13e1e50ac4ca6cbd3017428c05 100644 --- a/Applications/FileIO/TetGenInterface.cpp +++ b/Applications/FileIO/TetGenInterface.cpp @@ -106,8 +106,8 @@ std::size_t TetGenInterface::getNFacets(std::ifstream &input) continue; const std::list<std::string> fields = BaseLib::splitString(line, ' '); - std::list<std::string>::const_iterator it = fields.begin(); - const std::size_t nFacets (BaseLib::str2number<std::size_t> (*it)); + auto it = fields.begin(); + const auto nFacets(BaseLib::str2number<std::size_t>(*it)); if (fields.size() > 1) _boundary_markers = (BaseLib::str2number<std::size_t> (*(++it)) == 0) ? false : true; return nFacets; @@ -147,7 +147,7 @@ bool TetGenInterface::parseSmeshFacets(std::ifstream &input, // read facets const std::list<std::string> point_fields = BaseLib::splitString(line, ' '); it = point_fields.begin(); - const std::size_t nPoints = BaseLib::str2number<std::size_t>(*it); + const auto nPoints = BaseLib::str2number<std::size_t>(*it); if (nPoints != 3) { ERR ("Smesh-files are currently only supported for triangle meshes."); @@ -306,7 +306,7 @@ bool TetGenInterface::parseNodes(std::ifstream &ins, std::size_t dim) { std::string line; - double* coordinates (new double[dim]); + auto* coordinates(new double[dim]); nodes.reserve(n_nodes); std::size_t k(0); @@ -435,7 +435,8 @@ bool TetGenInterface::parseElements(std::ifstream& ins, bool region_attribute) const { std::string line; - std::size_t* ids (static_cast<std::size_t*>(alloca (sizeof (std::size_t) * n_nodes_per_tet))); + auto* ids(static_cast<std::size_t*>( + alloca(sizeof(std::size_t) * n_nodes_per_tet))); elements.reserve(n_tets); materials.reserve(n_tets); @@ -495,7 +496,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins, } } // insert new element into vector - MeshLib::Node** tet_nodes = new MeshLib::Node*[4]; + auto** tet_nodes = new MeshLib::Node*[4]; for (unsigned k(0); k<4; k++) { tet_nodes[k] = nodes[ids[k]]; } @@ -662,7 +663,9 @@ void TetGenInterface::write3dElements(std::ofstream &out, this->writeElementToFacets(out, *face, element_count, mat_id_str); } if (materialIds) - attribute_points.push_back(MeshLib::Node(elements[i]->getCenterOfGravity().getCoords(), (*materialIds)[i])); + attribute_points.emplace_back( + elements[i]->getCenterOfGravity().getCoords(), + (*materialIds)[i]); } // add number of facets at correct position and jump back const std::streamoff after_elems_pos (out.tellp()); diff --git a/Applications/FileIO/XmlIO/Qt/XmlGspInterface.h b/Applications/FileIO/XmlIO/Qt/XmlGspInterface.h index 720a1ad53a1c86631e0ac8fa2adb19d500e2f867..d7283805ece2aeb39ba1e88abf92d8090076d2b7 100644 --- a/Applications/FileIO/XmlIO/Qt/XmlGspInterface.h +++ b/Applications/FileIO/XmlIO/Qt/XmlGspInterface.h @@ -36,18 +36,21 @@ class XmlGspInterface : public BaseLib::IO::XMLInterface, public: XmlGspInterface(DataHolderLib::Project &project); - virtual ~XmlGspInterface() {} + ~XmlGspInterface() override = default; /// Reads an xml-file containing a GeoSys project. /// Project files currently cover only geo-, msh- and station-data. This will be expanded in the future. - int readFile(const QString &fileName); + int readFile(const QString& fileName) override; - bool readFile(std::string const& fname) { return readFile(QString(fname.c_str())) != 0; } + bool readFile(std::string const& fname) override + { + return readFile(QString(fname.c_str())) != 0; + } int writeToFile(const std::string& filename); protected: - bool write(); + bool write() override; private: std::string _filename; diff --git a/Applications/FileIO/XmlIO/Qt/XmlNumInterface.h b/Applications/FileIO/XmlIO/Qt/XmlNumInterface.h index e4a10027469fdad343c911abed83de052bf8b97e..18e260f49686166219fba8618a0e906089a7d430 100644 --- a/Applications/FileIO/XmlIO/Qt/XmlNumInterface.h +++ b/Applications/FileIO/XmlIO/Qt/XmlNumInterface.h @@ -25,18 +25,20 @@ class XmlNumInterface : public BaseLib::IO::XMLInterface, public BaseLib::IO::XM public: XmlNumInterface(); - virtual ~XmlNumInterface() {} + ~XmlNumInterface() override = default; - int readFile(QString const& fileName); + int readFile(QString const& fileName) override; - bool readFile(std::string const& fname) { return readFile(QString(fname.c_str())) != 0; } + bool readFile(std::string const& fname) override + { + return readFile(QString(fname.c_str())) != 0; + } protected: void readLinearSolverConfiguration(QDomElement const& lin_root); void readIterationScheme(QDomElement const& iteration_root); void readConvergenceCriteria(QDomElement const& convergence_root); - bool write(); - + bool write() override; }; } diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h index db7fb985b15ea307c4ce53cce4c7c3d9dbcd2ded..42c995ad3c9710e3245ceafe78f3ee021d723b57 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h +++ b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h @@ -42,7 +42,7 @@ struct Partition class NodeWiseMeshPartitioner { public: - typedef long IntegerType; + using IntegerType = long; public: /*! diff --git a/Applications/Utils/OGSFileConverter/FileListDialog.cpp b/Applications/Utils/OGSFileConverter/FileListDialog.cpp index c3330d95102f5f4d5a4bca8c7959c2104677a454..2b4cee0d2511f890bdbad261fc49ef415931ba49 100644 --- a/Applications/Utils/OGSFileConverter/FileListDialog.cpp +++ b/Applications/Utils/OGSFileConverter/FileListDialog.cpp @@ -33,9 +33,7 @@ FileListDialog::FileListDialog(FileType input, FileType output, QWidget* parent) this->listView->setModel(&_allFiles); } -FileListDialog::~FileListDialog() -{ -} +FileListDialog::~FileListDialog() = default; void FileListDialog::on_addButton_pressed() { @@ -63,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& item : selected) + this->_allFiles.removeRow(item.row()); } void FileListDialog::on_browseButton_pressed() diff --git a/Applications/Utils/OGSFileConverter/FileListDialog.h b/Applications/Utils/OGSFileConverter/FileListDialog.h index cfe7b07925073b353c2935d34391d5f1a35eb942..81783da7a5b0bffdb15d2bc7873056510f5d5e3f 100644 --- a/Applications/Utils/OGSFileConverter/FileListDialog.h +++ b/Applications/Utils/OGSFileConverter/FileListDialog.h @@ -37,7 +37,7 @@ public: /// Constructor FileListDialog(FileType input, FileType output, QWidget* parent = nullptr); /// Destructor - ~FileListDialog(void); + ~FileListDialog(void) override; /// Returns list of all selected files const QStringList getInputFileList() const { return _allFiles.stringList(); }; @@ -61,9 +61,8 @@ private slots: void on_browseButton_pressed(); /// Instructions if the OK-Button has been pressed. - void accept(); + void accept() override; /// Instructions if the Cancel-Button has been pressed. - void reject(); - + void reject() override; }; diff --git a/Applications/Utils/OGSFileConverter/OGSFileConverter.cpp b/Applications/Utils/OGSFileConverter/OGSFileConverter.cpp index 3cc6ed57dda9110e674a4ab3d251bfc47e0dcfef..1dd6515885f7f518b1ae70165dd9cfcae2944301 100644 --- a/Applications/Utils/OGSFileConverter/OGSFileConverter.cpp +++ b/Applications/Utils/OGSFileConverter/OGSFileConverter.cpp @@ -35,9 +35,7 @@ OGSFileConverter::OGSFileConverter(QWidget* parent) setupUi(this); } -OGSFileConverter::~OGSFileConverter() -{ -} +OGSFileConverter::~OGSFileConverter() = default; void OGSFileConverter::convertGML2GLI(const QStringList &input, const QString &output) const { @@ -47,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& input_string : input) { - const QFileInfo fi(*it); + const QFileInfo fi(input_string); const std::string output_str = QString(output + "/" + fi.completeBaseName() + ".gli").toStdString(); if (fileExists(output_str)) continue; - if (!xml.readFile(*it)) + if (!xml.readFile(input_string)) { OGSError::box("Error reading geometry " + fi.fileName()); continue; @@ -78,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& input_string : input) { - const QFileInfo fi(*it); + const QFileInfo fi(input_string); const std::string output_str = QString(output + "/" + fi.completeBaseName() + ".gml").toStdString(); if (fileExists(output_str)) @@ -89,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(input_string.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(input_string.toStdString()); xml.setNameForExport(geo_name); xml.writeToFile(output_str); geo_objects.removeSurfaceVec(geo_name); @@ -100,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"); } @@ -111,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& input_string : input) { - const QFileInfo fi(*it); + const QFileInfo fi(input_string); 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( + input_string.toStdString().c_str())); if (mesh == nullptr) { OGSError::box("Error reading mesh " + fi.fileName()); @@ -138,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& input_string : input) { - const QFileInfo fi(*it); + const QFileInfo fi(input_string); 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(input_string.toStdString())); if (mesh == nullptr) { OGSError::box("Error reading mesh " + fi.fileName()); diff --git a/Applications/Utils/OGSFileConverter/OGSFileConverter.h b/Applications/Utils/OGSFileConverter/OGSFileConverter.h index 99f6ed0227132266f047d9fe71e38b75558c8de5..af516b82d93a9a42e68a315e9cb59b8d34d74be6 100644 --- a/Applications/Utils/OGSFileConverter/OGSFileConverter.h +++ b/Applications/Utils/OGSFileConverter/OGSFileConverter.h @@ -28,7 +28,7 @@ public: /// Constructor OGSFileConverter(QWidget* parent = nullptr); /// Destructor - ~OGSFileConverter(void); + ~OGSFileConverter(void) override; private: /// Checks if a given file already exists diff --git a/Applications/Utils/OGSFileConverter/main.cpp b/Applications/Utils/OGSFileConverter/main.cpp index 17625cfbc294c3594e0814772851429d755c5573..a8cd544602f740ef7fdb40e678a96e7ee947f5aa 100644 --- a/Applications/Utils/OGSFileConverter/main.cpp +++ b/Applications/Utils/OGSFileConverter/main.cpp @@ -22,7 +22,7 @@ int main(int argc, char* argv[]) QApplication app(argc, argv); setlocale(LC_NUMERIC,"C"); - OGSFileConverter* fc = new OGSFileConverter(); + auto* fc = new OGSFileConverter(); fc->setWindowTitle( fc->windowTitle() ); fc->show(); int returncode = app.exec(); diff --git a/BaseLib/ConfigTree-impl.h b/BaseLib/ConfigTree-impl.h index 4a51a7cda127fed4be4a3cef819842289a8156b1..79cdcf73e7e37aefac85d2f0cc85c6fd61e061f0 100644 --- a/BaseLib/ConfigTree-impl.h +++ b/BaseLib/ConfigTree-impl.h @@ -10,6 +10,7 @@ #include "ConfigTree.h" #include <sstream> +#include <utility> namespace BaseLib { @@ -20,7 +21,7 @@ class Range { public: explicit Range(Iterator begin, Iterator end) - : _begin(begin), _end(end) + : _begin(std::move(begin)), _end(std::move(end)) {} Iterator begin() const { return _begin; } diff --git a/BaseLib/ConfigTree.cpp b/BaseLib/ConfigTree.cpp index db7c849e4d28a236b1843f360cc470d6b3aaa7cb..e287b015142fef1e82f4f7547f06ec17ed95694f 100644 --- a/BaseLib/ConfigTree.cpp +++ b/BaseLib/ConfigTree.cpp @@ -11,6 +11,7 @@ #include <forward_list> #include <logog/include/logog.hpp> +#include <utility> #include "Error.h" @@ -30,12 +31,14 @@ const char ConfigTree::pathseparator = '/'; const std::string ConfigTree::key_chars_start = "abcdefghijklmnopqrstuvwxyz"; const std::string ConfigTree::key_chars = key_chars_start + "_0123456789"; -ConfigTree:: -ConfigTree(PTree const& tree, - std::string const& filename, - Callback const& error_cb, - Callback const& warning_cb) - : _tree(&tree), _filename(filename), _onerror(error_cb), _onwarning(warning_cb) +ConfigTree::ConfigTree(PTree const& tree, + std::string filename, + Callback error_cb, + Callback warning_cb) + : _tree(&tree), + _filename(std::move(filename)), + _onerror(std::move(error_cb)), + _onwarning(std::move(warning_cb)) { if (!_onerror) { OGS_FATAL("ConfigTree: No valid error handler provided."); diff --git a/BaseLib/ConfigTree.h b/BaseLib/ConfigTree.h index 8f8bcc20fb045191a5e38cd6d014cf8734c0b05d..90d40954287212da524d2bed6f826d241f89fd83 100644 --- a/BaseLib/ConfigTree.h +++ b/BaseLib/ConfigTree.h @@ -14,6 +14,7 @@ #include <functional> #include <memory> +#include <utility> #include <vector> #include <boost/property_tree/ptree.hpp> @@ -105,9 +106,9 @@ public: public: using Iterator = boost::property_tree::ptree::const_assoc_iterator; - explicit SubtreeIterator(Iterator it, std::string const& root, + explicit SubtreeIterator(Iterator it, std::string root, ConfigTree const& parent) - : _it(it), _tagname(root), _parent(parent) + : _it(it), _tagname(std::move(root)), _parent(parent) {} SubtreeIterator& operator++() { @@ -189,9 +190,9 @@ public: public: using Iterator = boost::property_tree::ptree::const_assoc_iterator; - explicit ValueIterator(Iterator it, std::string const& root, + explicit ValueIterator(Iterator it, std::string root, ConfigTree const& parent) - : _it(it), _tagname(root), _parent(parent) + : _it(it), _tagname(std::move(root)), _parent(parent) {} ValueIterator<ValueType>& operator++() { @@ -255,9 +256,9 @@ public: * i.e., warnings will also result in program abortion! */ explicit ConfigTree(PTree const& tree, - std::string const& filename, - Callback const& error_cb, - Callback const& warning_cb); + std::string filename, + Callback error_cb, + Callback warning_cb); /*! This constructor is deleted in order to prevent the user from passing * temporary instances of \c PTree. diff --git a/BaseLib/DateTools.cpp b/BaseLib/DateTools.cpp index d330b3d82106245b787ede4ddeaee6c2400548aa..6e0f6cec8095d79116ca9742c4f1a76ce28d3839 100644 --- a/BaseLib/DateTools.cpp +++ b/BaseLib/DateTools.cpp @@ -43,8 +43,8 @@ std::string int2date(int date) { if (date > 10000000 && date < 22000000) { - int y = static_cast<int>(std::floor(date / 10000.0)); - int m = static_cast<int>(std::floor((date - (y * 10000)) / 100.0)); + auto y = static_cast<int>(std::floor(date / 10000.0)); + auto m = static_cast<int>(std::floor((date - (y * 10000)) / 100.0)); int d = date - (y * 10000) - (m * 100); std::stringstream ss; if (d < 10) @@ -66,10 +66,10 @@ std::string date2string(double ddate) return "0.0.0000"; } - int rest (static_cast<int>(ddate)); - int y = static_cast<int>(std::floor(rest / 10000.0)); + auto rest(static_cast<int>(ddate)); + auto y = static_cast<int>(std::floor(rest / 10000.0)); rest = rest % (y * 10000); - int m = static_cast<int>(std::floor(rest / 100.0)); + auto m = static_cast<int>(std::floor(rest / 100.0)); if (m < 1 || m > 12) WARN("date2String(): month not in [1:12]."); rest = rest % (m * 100); diff --git a/BaseLib/FileFinder.cpp b/BaseLib/FileFinder.cpp index bdfe1d8ebcebdc70008c250b794288dd081c34f8..5656d51b68eb3f66f1aa7e5fbc91b10151f01c11 100644 --- a/BaseLib/FileFinder.cpp +++ b/BaseLib/FileFinder.cpp @@ -40,7 +40,7 @@ void FileFinder::addDirectory(std::string const& dir) return; if (dir[dir.size() - 1] != '/') - _directories.push_back(std::string(dir + "/")); + _directories.emplace_back(dir + "/"); else _directories.push_back(dir); } diff --git a/BaseLib/Histogram.h b/BaseLib/Histogram.h index 5c7155a896feb10ab68156f33d54c93bbb7d333a..4a86f9bdaf06e3a6964b2f277b61c62410a0bc92 100644 --- a/BaseLib/Histogram.h +++ b/BaseLib/Histogram.h @@ -14,9 +14,10 @@ #include <algorithm> #include <cmath> -#include <iterator> -#include <iosfwd> #include <fstream> +#include <iosfwd> +#include <iterator> +#include <utility> #include <vector> #include <logog/include/logog.hpp> @@ -32,7 +33,8 @@ template <typename T> class Histogram { public: - typedef typename std::vector<T> Data; /// Underlying input data vector type. + using Data = + typename std::vector<double>; /// Underlying input data vector type. public: /** Creates histogram of the given element in the range \c [first, last). @@ -59,9 +61,9 @@ public: * \param computeHistogram Compute histogram if set. If not set user must call * \c update() before accessing data. */ - Histogram(std::vector<T> const& data, const unsigned int nr_bins = 16, + Histogram(std::vector<T> data, const unsigned int nr_bins = 16, const bool computeHistogram = true) - : _data(data), _nr_bins(nr_bins) + : _data(std::move(data)), _nr_bins(nr_bins) { init(computeHistogram); } @@ -83,13 +85,11 @@ public: _bin_width = (_max - _min) / _nr_bins; - typedef typename Data::const_iterator DataCI; - DataCI it = _data.begin(); - DataCI itEnd; + auto it = _data.begin(); for (unsigned int bin = 0; bin < _nr_bins; bin++) { - itEnd = std::upper_bound(it, (DataCI)_data.end(), - _min + (bin + 1) * _bin_width); + auto itEnd = std::upper_bound(it, _data.end(), + _min + (bin + 1) * _bin_width); _histogram[bin] = std::distance(it, itEnd); it = itEnd; } diff --git a/BaseLib/IO/Writer.h b/BaseLib/IO/Writer.h index 0dabb332349bf43675a4a32ee6a89cf634aa4013..02f34fce013d994317cbb65e2ad2e018305d81bd 100644 --- a/BaseLib/IO/Writer.h +++ b/BaseLib/IO/Writer.h @@ -32,7 +32,7 @@ class Writer { public: Writer(); - virtual ~Writer() {} + virtual ~Writer() = default; /// @brief Writes the object to a string. std::string writeToString(); diff --git a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp index 7661895544a349afad4d9455549da6f1066c8770..4fa8ed79033e5dfe46e9e827702584a9a3adf1e1 100644 --- a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp +++ b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp @@ -23,14 +23,14 @@ #include <QCryptographicHash> #include <logog/include/logog.hpp> +#include <utility> namespace BaseLib { namespace IO { - -XMLQtInterface::XMLQtInterface(const std::string &schemaFile) : - _schemaName(schemaFile) +XMLQtInterface::XMLQtInterface(std::string schemaFile) + : _schemaName(std::move(schemaFile)) {} int XMLQtInterface::readFile(const QString &fileName) diff --git a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.h b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.h index e290c0643397e90bdcd39cc1cf7a19ef7f264645..7c21fcf9ac0933e4bfcc28be452c8e99582393f8 100644 --- a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.h +++ b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.h @@ -30,8 +30,8 @@ namespace IO class XMLQtInterface { public: - XMLQtInterface(const std::string &schemaFile = ""); - virtual ~XMLQtInterface() {} + XMLQtInterface(std::string schemaFile = ""); + virtual ~XMLQtInterface() = default; /// As QXMLStreamWriter seems currently unable to include style-file links into xml-files, this method will workaround this issue and include the stylefile link. int insertStyleFileDefinition(const QString &fileName) const; diff --git a/BaseLib/IO/XmlIO/XMLInterface.h b/BaseLib/IO/XmlIO/XMLInterface.h index d8c8cbb98706109a616d7768c78b7e011c3eaa91..ba6ccc07f084afb657d2eb577829593b49d1b263 100644 --- a/BaseLib/IO/XmlIO/XMLInterface.h +++ b/BaseLib/IO/XmlIO/XMLInterface.h @@ -29,7 +29,7 @@ class XMLInterface : public BaseLib::IO::Writer { public: XMLInterface(); - virtual ~XMLInterface() {} + ~XMLInterface() override = default; void setNameForExport(std::string const& name) { _exportName = name; } virtual bool readFile(std::string const& fname) = 0; diff --git a/BaseLib/LogogSimpleFormatter.h b/BaseLib/LogogSimpleFormatter.h index eeaab28468e7aaa5018c7adc795b5f7c739fd030..98051eb2d0ffc045497a5f082b8f77e151bdd828 100644 --- a/BaseLib/LogogSimpleFormatter.h +++ b/BaseLib/LogogSimpleFormatter.h @@ -25,7 +25,7 @@ namespace BaseLib **/ class LogogSimpleFormatter : public logog::FormatterMSVC { - virtual TOPIC_FLAGS GetTopicFlags(const logog::Topic& topic) + TOPIC_FLAGS GetTopicFlags(const logog::Topic& topic) override { return (logog::Formatter::GetTopicFlags(topic) & ~(TOPIC_FILE_NAME_FLAG | TOPIC_LINE_NUMBER_FLAG)); diff --git a/BaseLib/RunTime.h b/BaseLib/RunTime.h index 197ec678baf43a6067e09d5ae7811ee27af59ea2..295c06b51e863cd8bd0f5be5ed8698021bf6cd30 100644 --- a/BaseLib/RunTime.h +++ b/BaseLib/RunTime.h @@ -40,7 +40,7 @@ class RunTime #else #ifndef _MSC_VER timeval t; - gettimeofday(&t, 0); + gettimeofday(&t, nullptr); _start_time = t.tv_sec + t.tv_usec/1000000.0; #else _start_time = timeGetTime(); @@ -56,7 +56,7 @@ class RunTime #else #ifndef _MSC_VER timeval t; - gettimeofday(&t, 0); + gettimeofday(&t, nullptr); return t.tv_sec + t.tv_usec/1000000.0 - _start_time; #else return (timeGetTime() - _start_time)/1000.0; diff --git a/BaseLib/Subdivision.h b/BaseLib/Subdivision.h index dbfa4c576e01c7ad438374eb0ca7d4014fa17b70..625c1efe76800ea712466366a799cd71dfa46db1 100644 --- a/BaseLib/Subdivision.h +++ b/BaseLib/Subdivision.h @@ -23,7 +23,7 @@ public: /// Returns a vector of subdivided points virtual std::vector<double> operator()() const = 0; - virtual ~ISubdivision() {} + virtual ~ISubdivision() = default; }; /** @@ -41,7 +41,7 @@ public: : _length(length), _n_subdivision(n_subdivision) {} /// Returns a vector of subdivided points - std::vector<double> operator()() const + std::vector<double> operator()() const override { std::vector<double> x; x.reserve(_n_subdivision+1); @@ -77,7 +77,7 @@ public: : _length(L), _dL0(dL0), _max_dL(max_dL), _multiplier(multiplier) {} /// Returns a vector of subdivided points - std::vector<double> operator()() const + std::vector<double> operator()() const override { std::vector<double> vec_x; diff --git a/BaseLib/TMPUtil.h b/BaseLib/TMPUtil.h index 1b0d8fdb0a32161fdc62506f608564252c497259..1e916d79ee525807540e39d7273a8503887ab647 100644 --- a/BaseLib/TMPUtil.h +++ b/BaseLib/TMPUtil.h @@ -22,12 +22,12 @@ struct IntegerSequence { template <int N, int... S> struct GenerateIntegerSequence { // effectively pushes N-1 from the left to the list int... S of integers. - typedef typename GenerateIntegerSequence<N - 1, N - 1, S...>::type type; + using type = typename GenerateIntegerSequence<N - 1, N - 1, S...>::type; }; template <int... S> struct GenerateIntegerSequence<0, S...> { - typedef IntegerSequence<S...> type; + using type = IntegerSequence<S...>; }; /* The template metaprogram proceeds in the following way: * diff --git a/BaseLib/TemplateLogogFormatterSuppressedGCC.h b/BaseLib/TemplateLogogFormatterSuppressedGCC.h index 52730d867da576c7d8522588675aace9216f6985..0936631516223a3a4c6b5f8d1f2cbe59fa21be74 100644 --- a/BaseLib/TemplateLogogFormatterSuppressedGCC.h +++ b/BaseLib/TemplateLogogFormatterSuppressedGCC.h @@ -38,13 +38,14 @@ public: TemplateLogogFormatterSuppressedGCC(MPI_Comm mpi_comm = MPI_COMM_WORLD); #endif - virtual TOPIC_FLAGS GetTopicFlags( const logog::Topic &topic ) + TOPIC_FLAGS GetTopicFlags(const logog::Topic& topic) override { return ( logog::Formatter::GetTopicFlags( topic ) & ~( T_SUPPPRESS_TOPIC_FLAG )); } - virtual LOGOG_STRING &Format( const logog::Topic &topic, const logog::Target &target ); + LOGOG_STRING& Format(const logog::Topic& topic, + const logog::Target& target) override; private: #ifdef USE_MPI diff --git a/GeoLib/AABB.h b/GeoLib/AABB.h index 4abf643ff398e427528f6ca821e40abbbd3ec1c9..6842b06d96828d1ead161235ba81bfdd26f05bee 100644 --- a/GeoLib/AABB.h +++ b/GeoLib/AABB.h @@ -70,9 +70,7 @@ public: * copy constructor. * @param src an axis aligned bounding box * */ - AABB(AABB const& src) : - _min_pnt(src._min_pnt), _max_pnt(src._max_pnt) - {} + AABB(AABB const& src) = default; /** * Construction of object using input iterators. In contrast to give a vector diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index e308faa69e1dad246ee5c3dcff42e55c88912aff..d78b3d6ad371a4e8b61e9fbc5274f2561bc98da4 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -351,7 +351,7 @@ GeoLib::Polygon rotatePolygonToXY(GeoLib::Polygon const& polygon_in, MathLib::Vector3 & plane_normal) { // 1 copy all points - std::vector<GeoLib::Point*> *polygon_pnts(new std::vector<GeoLib::Point*>); + auto* polygon_pnts(new std::vector<GeoLib::Point*>); for (std::size_t k(0); k < polygon_in.getNumberOfPoints(); k++) polygon_pnts->push_back (new GeoLib::Point (*(polygon_in.getPoint(k)))); diff --git a/GeoLib/DuplicateGeometry.cpp b/GeoLib/DuplicateGeometry.cpp index 1240c8b23b988bb5586e1c4f33cac4e1cebfddae..8ea38744140a4582fd89031b5717e03116c8b7d8 100644 --- a/GeoLib/DuplicateGeometry.cpp +++ b/GeoLib/DuplicateGeometry.cpp @@ -10,6 +10,7 @@ #include "DuplicateGeometry.h" #include <logog/include/logog.hpp> +#include <utility> #include "GeoLib/GEOObjects.h" #include "GeoLib/Point.h" @@ -20,11 +21,10 @@ namespace GeoLib { - -DuplicateGeometry::DuplicateGeometry(GeoLib::GEOObjects &geo_objects, - std::string const& input_name, - std::string const& output_name) -: _output_name(output_name), _geo_objects(geo_objects) +DuplicateGeometry::DuplicateGeometry(GeoLib::GEOObjects& geo_objects, + std::string const& input_name, + std::string output_name) + : _output_name(std::move(output_name)), _geo_objects(geo_objects) { duplicate(input_name); } diff --git a/GeoLib/DuplicateGeometry.h b/GeoLib/DuplicateGeometry.h index 820f09a3df5fe9a554875ca5665a2324b1540eff..7550f0337644b659926b31da860e523d52d4fb09 100644 --- a/GeoLib/DuplicateGeometry.h +++ b/GeoLib/DuplicateGeometry.h @@ -33,9 +33,9 @@ public: * \param input_name The geometry to be copied * \param output_name The name of the copy (note: this might be modified by GEOObjects) */ - DuplicateGeometry(GeoLib::GEOObjects &geo_objects, - std::string const& input_name, - std::string const& output_name); + DuplicateGeometry(GeoLib::GEOObjects& geo_objects, + std::string const& input_name, + std::string output_name); // Returns the (possibly modified) output name of the new geometry. std::string const& getFinalizedOutputName() const { return _output_name; } diff --git a/GeoLib/EarClippingTriangulation.cpp b/GeoLib/EarClippingTriangulation.cpp index d52964bc07a17c41f3475e29680bd8518c8a6d0b..ff94ca1fb9f982622539d5d1cbc2e8fee3c4baa2 100644 --- a/GeoLib/EarClippingTriangulation.cpp +++ b/GeoLib/EarClippingTriangulation.cpp @@ -45,7 +45,7 @@ EarClippingTriangulation::EarClippingTriangulation(const GeoLib::Polygon* polygo const std::size_t i0 (polygon->getPointID ((*it)[0])); const std::size_t i1 (polygon->getPointID ((*it)[1])); const std::size_t i2 (polygon->getPointID ((*it)[2])); - triangles.push_back (GeoLib::Triangle (ref_pnts_vec, i0, i1, i2)); + triangles.emplace_back(ref_pnts_vec, i0, i1, i2); ++it; } } else { @@ -54,7 +54,7 @@ EarClippingTriangulation::EarClippingTriangulation(const GeoLib::Polygon* polygo const std::size_t i0 (polygon->getPointID (n_pnts - (*it)[0])); const std::size_t i1 (polygon->getPointID (n_pnts - (*it)[1])); const std::size_t i2 (polygon->getPointID (n_pnts - (*it)[2])); - triangles.push_back (GeoLib::Triangle (ref_pnts_vec, i0, i1, i2)); + triangles.emplace_back(ref_pnts_vec, i0, i1, i2); ++it; } } @@ -114,10 +114,13 @@ void EarClippingTriangulation::ensureCWOrientation () bool EarClippingTriangulation::isEar(std::size_t v0, std::size_t v1, std::size_t v2) const { - for (std::list<std::size_t>::const_iterator it (_vertex_list.begin ()); - it != _vertex_list.end(); ++it) { - if (*it != v0 && *it != v1 && *it != v2) { - if (MathLib::isPointInTriangle (*_pnts[*it], *_pnts[v0], *_pnts[v1], *_pnts[v2])) { + for (unsigned long v : _vertex_list) + { + if (v != v0 && v != v1 && v != v2) + { + if (MathLib::isPointInTriangle(*_pnts[v], *_pnts[v0], *_pnts[v1], + *_pnts[v2])) + { return false; } } @@ -194,7 +197,7 @@ void EarClippingTriangulation::clipEars() --prev; } // add triangle - _triangles.push_back(GeoLib::Triangle(_pnts, *prev, *next, ear)); + _triangles.emplace_back(_pnts, *prev, *next, ear); // check the orientation of prevprev, prev, next std::list<std::size_t>::iterator prevprev; @@ -287,9 +290,9 @@ void EarClippingTriangulation::clipEars() return; if (getOrientation(_pnts[*prev], _pnts[*it], _pnts[*next]) == GeoLib::CCW) - _triangles.push_back(GeoLib::Triangle(_pnts, *prev, *it, *next)); + _triangles.emplace_back(_pnts, *prev, *it, *next); else - _triangles.push_back(GeoLib::Triangle(_pnts, *prev, *next, *it)); + _triangles.emplace_back(_pnts, *prev, *next, *it); } } // end namespace GeoLib diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index 7e67bd13835044f5156a2b32f7b516f0efaea42e..5fbe3e6322e107bf07e50a06c3f8165d40df73c7 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -23,21 +23,19 @@ namespace GeoLib { -GEOObjects::GEOObjects() -{ -} +GEOObjects::GEOObjects() = default; GEOObjects::~GEOObjects() { // delete surfaces - for (auto & _sfc_vec : _sfc_vecs) - delete _sfc_vec; + for (auto& surface : _sfc_vecs) + delete surface; // delete polylines - for (auto & _ply_vec : _ply_vecs) - delete _ply_vec; + for (auto& polyline : _ply_vecs) + delete polyline; // delete points - for (auto & _pnt_vec : _pnt_vecs) - delete _pnt_vec; + for (auto& point : _pnt_vecs) + delete point; } void GEOObjects::addPointVec( @@ -84,8 +82,7 @@ bool GEOObjects::removePointVec(std::string const& name) return false; } - for (std::vector<PointVec*>::iterator it(_pnt_vecs.begin()); - it != _pnt_vecs.end(); ++it) + for (auto it(_pnt_vecs.begin()); it != _pnt_vecs.end(); ++it) if ((*it)->getName().compare(name) == 0) { _callbacks->removePointVec(name); @@ -108,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 (std::vector<PointVec*>::const_iterator it(_pnt_vecs.begin()); - it != _pnt_vecs.end(); ++it) { - if ((*it)->getName().compare(name) == 0 && (*it)->getType() == PointVec::PointType::STATION) { - return (*it)->getVector(); + for (auto point : _pnt_vecs) + { + if (point->getName().compare(name) == 0 && + point->getType() == PointVec::PointType::STATION) + { + return point->getVector(); } } DBUG("GEOObjects::getStationVec() - No entry found with name \"%s\".", name.c_str()); @@ -123,12 +122,11 @@ void GEOObjects::addPolylineVec(std::unique_ptr<std::vector<Polyline*>> lines, std::map<std::string, std::size_t>* ply_names) { assert(lines); - for (std::vector<Polyline*>::iterator it (lines->begin()); - it != lines->end(); ) + for (auto it(lines->begin()); it != lines->end();) { if ((*it)->getNumberOfPoints() < 2) { - std::vector<Polyline*>::iterator it_erase (it); + auto it_erase(it); it = lines->erase (it_erase); } else @@ -191,8 +189,7 @@ const PolylineVec* GEOObjects::getPolylineVecObj(const std::string &name) const bool GEOObjects::removePolylineVec(std::string const& name) { _callbacks->removePolylineVec(name); - for (std::vector<PolylineVec*>::iterator it = _ply_vecs.begin(); - it != _ply_vecs.end(); ++it) + for (auto it = _ply_vecs.begin(); it != _ply_vecs.end(); ++it) if ((*it)->getName().compare(name) == 0) { delete *it; @@ -258,8 +255,7 @@ const std::vector<Surface*>* GEOObjects::getSurfaceVec(const std::string &name) bool GEOObjects::removeSurfaceVec(const std::string &name) { _callbacks->removeSurfaceVec(name); - for (std::vector<SurfaceVec*>::iterator it (_sfc_vecs.begin()); - it != _sfc_vecs.end(); ++it) + for (auto it(_sfc_vecs.begin()); it != _sfc_vecs.end(); ++it) if ((*it)->getName().compare (name) == 0) { delete *it; @@ -298,8 +294,8 @@ bool GEOObjects::isUniquePointVecName(std::string &name) if (count > 1) cpName = cpName + "-" + std::to_string(count); - for (auto & _pnt_vec : _pnt_vecs) - if ( cpName.compare(_pnt_vec->getName()) == 0 ) + for (auto& point : _pnt_vecs) + if (cpName.compare(point->getName()) == 0) isUnique = false; } @@ -317,16 +313,14 @@ bool GEOObjects::isUniquePointVecName(std::string &name) bool GEOObjects::isPntVecUsed (const std::string &name) const { // search dependent data structures (Polyline) - for (std::vector<PolylineVec*>::const_iterator it ( _ply_vecs.begin()); it != _ply_vecs.end(); - ++it) + for (auto polyline : _ply_vecs) { - if (((*it)->getName()).compare(name) == 0) + if ((polyline->getName()).compare(name) == 0) return true; } - for (std::vector<SurfaceVec*>::const_iterator it ( _sfc_vecs.begin()); it != _sfc_vecs.end(); - ++it) + for (auto surface : _sfc_vecs) { - if (((*it)->getName()).compare(name) == 0) + if ((surface->getName()).compare(name) == 0) return true; } @@ -335,19 +329,17 @@ bool GEOObjects::isPntVecUsed (const std::string &name) const void GEOObjects::getStationVectorNames(std::vector<std::string>& names) const { - for (std::vector<PointVec*>::const_iterator it(_pnt_vecs.begin()); it != _pnt_vecs.end(); - ++it) - if ((*it)->getType() == PointVec::PointType::STATION) - names.push_back((*it)->getName()); + for (auto point : _pnt_vecs) + if (point->getType() == PointVec::PointType::STATION) + names.push_back(point->getName()); } void GEOObjects::getGeometryNames (std::vector<std::string>& names) const { names.clear (); - for (std::vector<PointVec*>::const_iterator it(_pnt_vecs.begin()); it != _pnt_vecs.end(); - ++it) - if ((*it)->getType() == PointVec::PointType::POINT) - names.push_back((*it)->getName()); + for (auto point : _pnt_vecs) + if (point->getType() == PointVec::PointType::POINT) + names.push_back(point->getName()); } const std::string GEOObjects::getElementNameByID(const std::string &geometry_name, GeoLib::GEOTYPE type, std::size_t id) const @@ -394,7 +386,7 @@ bool GEOObjects::mergePoints(std::vector<std::string> const & geo_names, auto merged_points = std::unique_ptr<std::vector<GeoLib::Point*>>( new std::vector<GeoLib::Point*>); - std::map<std::string, std::size_t>* merged_pnt_names(new std::map<std::string, std::size_t>); + auto* merged_pnt_names(new std::map<std::string, std::size_t>); for (std::size_t j(0); j < n_geo_names; ++j) { GeoLib::PointVec const*const pnt_vec(this->getPointVecObj(geo_names[j])); @@ -437,7 +429,7 @@ void GEOObjects::mergePolylines(std::vector<std::string> const & geo_names, auto merged_polylines = std::unique_ptr<std::vector<GeoLib::Polyline*>>( new std::vector<GeoLib::Polyline*>); - std::map<std::string, std::size_t>* merged_ply_names(new std::map<std::string, std::size_t>); + auto* merged_ply_names(new std::map<std::string, std::size_t>); std::vector<GeoLib::Point*> const* merged_points(this->getPointVecObj(merged_geo_name)->getVector()); std::vector<std::size_t> const& id_map (this->getPointVecObj(merged_geo_name)->getIDMap ()); @@ -447,7 +439,7 @@ void GEOObjects::mergePolylines(std::vector<std::string> const & geo_names, if (plys) { std::string tmp_name; for (std::size_t k(0); k < plys->size(); k++) { - GeoLib::Polyline* kth_ply_new(new GeoLib::Polyline (*merged_points)); + auto* kth_ply_new(new GeoLib::Polyline(*merged_points)); GeoLib::Polyline const* const kth_ply_old ((*plys)[k]); const std::size_t size_of_kth_ply (kth_ply_old->getNumberOfPoints()); // copy point ids from old ply to new ply (considering the offset) @@ -483,13 +475,13 @@ void GEOObjects::mergeSurfaces(std::vector<std::string> const & geo_names, std::vector<std::size_t> sfc_offsets(n_geo_names, 0); auto merged_sfcs = std::unique_ptr<std::vector<GeoLib::Surface*>>( new std::vector<GeoLib::Surface*>); - std::map<std::string, std::size_t>* merged_sfc_names(new std::map<std::string, std::size_t>); + auto* merged_sfc_names(new std::map<std::string, std::size_t>); for (std::size_t j(0); j < n_geo_names; j++) { const std::vector<GeoLib::Surface*>* sfcs (this->getSurfaceVec(geo_names[j])); if (sfcs) { std::string tmp_name; for (std::size_t k(0); k < sfcs->size(); k++) { - GeoLib::Surface* kth_sfc_new(new GeoLib::Surface (*merged_points)); + auto* kth_sfc_new(new GeoLib::Surface(*merged_points)); GeoLib::Surface const* const kth_sfc_old ((*sfcs)[k]); const std::size_t size_of_kth_sfc (kth_sfc_old->getNumberOfTriangles()); // clone surface elements using new ids diff --git a/GeoLib/Grid.h b/GeoLib/Grid.h index fba64e6089b9bb4039f8b6aecc5ab6f155e00501..050f489a5c7597c5ad11b74cdd07d09426609ab2 100644 --- a/GeoLib/Grid.h +++ b/GeoLib/Grid.h @@ -329,35 +329,35 @@ void Grid<POINT>::createGridGeometry(GeoLib::GEOObjects* geo_obj) const auto plys = std::unique_ptr<std::vector<GeoLib::Polyline*>>( new std::vector<GeoLib::Polyline*>); auto const& points = *geo_obj->getPointVec(grid_names.back()); - GeoLib::Polyline* ply0 (new GeoLib::Polyline(points)); + auto* ply0(new GeoLib::Polyline(points)); for (std::size_t l(0); l < 4; l++) ply0->addPoint(l); ply0->addPoint(0); plys->push_back(ply0); - GeoLib::Polyline* ply1 (new GeoLib::Polyline(points)); + auto* ply1(new GeoLib::Polyline(points)); for (std::size_t l(4); l < 8; l++) ply1->addPoint(l); ply1->addPoint(4); plys->push_back(ply1); - GeoLib::Polyline* ply2 (new GeoLib::Polyline(points)); + auto* ply2(new GeoLib::Polyline(points)); ply2->addPoint(0); ply2->addPoint(4); plys->push_back(ply2); - GeoLib::Polyline* ply3 (new GeoLib::Polyline(points)); + auto* ply3(new GeoLib::Polyline(points)); ply3->addPoint(1); ply3->addPoint(5); plys->push_back(ply3); - GeoLib::Polyline* ply4 (new GeoLib::Polyline(points)); + auto* ply4(new GeoLib::Polyline(points)); ply4->addPoint(2); ply4->addPoint(6); plys->push_back(ply4); - GeoLib::Polyline* ply5 (new GeoLib::Polyline(points)); + auto* ply5(new GeoLib::Polyline(points)); ply5->addPoint(3); ply5->addPoint(7); plys->push_back(ply5); diff --git a/GeoLib/IO/Legacy/OGSIOVer4.cpp b/GeoLib/IO/Legacy/OGSIOVer4.cpp index eb483416930214dc71f831ee3184cd667ce059e3..8ee236a70762392a50a95d934e5d2b5e784adbb6 100644 --- a/GeoLib/IO/Legacy/OGSIOVer4.cpp +++ b/GeoLib/IO/Legacy/OGSIOVer4.cpp @@ -155,7 +155,7 @@ std::string readPolyline(std::istream &in, std::vector<std::string> &errors) { std::string line, name_of_ply; - GeoLib::Polyline* ply(new GeoLib::Polyline(pnt_vec)); + auto* ply(new GeoLib::Polyline(pnt_vec)); std::size_t type = 2; // need an initial value // Schleife ueber alle Phasen bzw. Komponenten @@ -174,7 +174,7 @@ std::string readPolyline(std::istream &in, if (line.find("$TYPE") != std::string::npos) // subkeyword found { in >> line; // read value - type = static_cast<std::size_t> (strtol(line.c_str(), NULL, 0)); + type = static_cast<std::size_t>(strtol(line.c_str(), nullptr, 0)); } //.................................................................... if (line.find("$EPSILON") != std::string::npos) // subkeyword found @@ -187,17 +187,17 @@ std::string readPolyline(std::istream &in, { // read the point ids in >> line; if (type != 100) - while (!in.eof() && !in.fail() && line.size() != 0 - && (line.find('#') == std::string::npos) - && (line.find('$') == std::string::npos)) + while (!in.eof() && !in.fail() && !line.empty() && + (line.find('#') == std::string::npos) && + (line.find('$') == std::string::npos)) { - std::size_t pnt_id(BaseLib::str2number<std::size_t> (line)); + auto pnt_id(BaseLib::str2number<std::size_t>(line)); if (!zero_based_indexing) pnt_id--; // one based indexing - std::size_t ply_size (ply->getNumberOfPoints()); + std::size_t ply_size(ply->getNumberOfPoints()); if (ply_size > 0) { - if (ply->getPointID (ply_size - 1) != pnt_id_map[pnt_id]) + if (ply->getPointID(ply_size - 1) != pnt_id_map[pnt_id]) ply->addPoint(pnt_id_map[pnt_id]); } else @@ -206,7 +206,9 @@ std::string readPolyline(std::istream &in, } else { WARN("readPolyline(): polyline is an arc *** reading not implemented"); - errors.push_back ("[readPolyline] reading polyline as an arc is not implemented"); + errors.emplace_back( + "[readPolyline] reading polyline as an arc is not " + "implemented"); } // empty line or the keyword or subkeyword or end of file } @@ -217,7 +219,7 @@ std::string readPolyline(std::istream &in, line = path + line; readPolylinePointVector(line, pnt_vec, ply, path, errors); } // subkeyword found - } while (line.find('#') == std::string::npos && line.size() != 0 && in); + } while (line.find('#') == std::string::npos && !line.empty() && in); if (type != 100) { @@ -280,7 +282,7 @@ std::string readSurface(std::istream &in, std::string const& path, std::vector<std::string>& errors) { std::string line; - GeoLib::Surface* sfc(NULL); + GeoLib::Surface* sfc(nullptr); int type (-1); std::string name; @@ -301,7 +303,7 @@ std::string readSurface(std::istream &in, if (line.find("$TYPE") != std::string::npos) // subkeyword found { in >> line; // read value - type = strtol(line.c_str(), NULL, 0); + type = strtol(line.c_str(), nullptr, 0); } //.................................................................... if (line.find("$EPSILON") != std::string::npos) // subkeyword found @@ -320,12 +322,12 @@ std::string readSurface(std::istream &in, if (line.find("$POLYLINES") != std::string::npos) // subkeyword found { // read the name of the polyline(s) in >> line; - while (!in.eof() && !in.fail() && line.size() != 0 - && (line.find('#') == std::string::npos) - && (line.find('$') == std::string::npos)) + while (!in.eof() && !in.fail() && !line.empty() && + (line.find('#') == std::string::npos) && + (line.find('$') == std::string::npos)) { // we did read the name of a polyline -> search the id for polyline - std::map<std::string,std::size_t>::const_iterator it (ply_vec_names.find (line)); + auto it(ply_vec_names.find(line)); if (it != ply_vec_names.end()) ply_id = it->second; else @@ -333,22 +335,27 @@ std::string readSurface(std::istream &in, if (ply_id == ply_vec.size()) { WARN("readSurface(): polyline for surface not found!"); - errors.push_back("[readSurface] polyline for surface not found!"); + errors.emplace_back( + "[readSurface] polyline for surface not found!"); } else { if (type == 3) { WARN("readSurface(): surface type 3: flat surface with any normal direction - reading not implemented."); - errors.push_back("[readSurface] surface type 3: flat surface with any normal direction - reading not implemented"); + errors.emplace_back( + "[readSurface] surface type 3: flat surface with " + "any normal direction - reading not implemented"); } if (type == 2) { WARN("readSurface(): vertical surface (type 2) - reading not implemented"); - errors.push_back("[readSurface] vertical surface (type 2) - reading not implemented"); + errors.emplace_back( + "[readSurface] vertical surface (type 2) - reading " + "not implemented"); } } in >> line; } // empty line or a keyword is found } - } while (line.find('#') == std::string::npos && line.size() != 0 && in); + } while (line.find('#') == std::string::npos && !line.empty() && in); if (!name.empty()) sfc_names.insert(std::pair<std::string,std::size_t>(name,sfc_vec.size())); @@ -449,7 +456,7 @@ bool readGLIFileV4(const std::string& fname, getline (in, tag); // read names of points into vector of strings - std::map<std::string,std::size_t>* pnt_id_names_map (new std::map<std::string,std::size_t>); + auto* pnt_id_names_map(new std::map<std::string, std::size_t>); bool zero_based_idx(true); auto pnt_vec = std::unique_ptr<std::vector<GeoLib::Point*>>( new std::vector<GeoLib::Point*>); @@ -465,13 +472,13 @@ bool readGLIFileV4(const std::string& fname, const std::string path = BaseLib::extractPath(fname); // read names of plys into temporary string-vec - std::map<std::string,std::size_t>* ply_names (new std::map<std::string,std::size_t>); + auto* ply_names(new std::map<std::string, std::size_t>); auto ply_vec = std::unique_ptr<std::vector<GeoLib::Polyline*>>( new std::vector<GeoLib::Polyline*>); GeoLib::PointVec & point_vec( *const_cast<GeoLib::PointVec*>(geo.getPointVecObj(unique_name))); - std::vector<GeoLib::Point*>* geo_pnt_vec(const_cast<std::vector<GeoLib::Point*>*>( - point_vec.getVector())); + auto* geo_pnt_vec( + const_cast<std::vector<GeoLib::Point*>*>(point_vec.getVector())); if (tag.find("#POLYLINE") != std::string::npos && in) { INFO("GeoLib::readGLIFile(): read polylines from stream."); @@ -485,7 +492,7 @@ bool readGLIFileV4(const std::string& fname, auto sfc_vec = std::unique_ptr<std::vector<GeoLib::Surface*>>( new std::vector<GeoLib::Surface*>); - std::map<std::string,std::size_t>* sfc_names (new std::map<std::string,std::size_t>); + auto* sfc_names(new std::map<std::string, std::size_t>); if (tag.find("#SURFACE") != std::string::npos && in) { INFO("GeoLib::readGLIFile(): read surfaces from stream."); diff --git a/GeoLib/IO/TINInterface.cpp b/GeoLib/IO/TINInterface.cpp index 7f98521c7b2e72d2569d5bcf9ed92f7e4e7ba902..551dcb14b5dadc2f06f5f8b173bcf5e4845944ee 100644 --- a/GeoLib/IO/TINInterface.cpp +++ b/GeoLib/IO/TINInterface.cpp @@ -40,7 +40,7 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname, return nullptr; } - GeoLib::Surface* sfc = new GeoLib::Surface(*(pnt_vec.getVector())); + auto* sfc = new GeoLib::Surface(*(pnt_vec.getVector())); std::size_t id; MathLib::Point3d p0, p1, p2; std::string line; diff --git a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h index 9e478ba4285011df30050863c90b5739dea32eed..f2fdf6a682572d9be55d9a5b2a65d031b07103fb 100644 --- a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h +++ b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h @@ -36,14 +36,14 @@ class BoostXmlGmlInterface : public BaseLib::IO::XMLInterface { public: BoostXmlGmlInterface(GeoLib::GEOObjects& geo_objs); - virtual ~BoostXmlGmlInterface() {} + ~BoostXmlGmlInterface() override = default; /// Reads an xml-file containing OGS geometry - bool readFile(const std::string &fname); + bool readFile(const std::string& fname) override; protected: /// Required method for writing geometry. This is not implemented here, use the Qt class for writing. - bool write(); + bool write() override; private: /// Reads GeoLib::Point-objects from an xml-file diff --git a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp index 2aa89e4aa6eb44990194e940efa52a88b8453c4c..16ec0472d81b8c3d936e6817e24d0be472974e5c 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp +++ b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp @@ -56,9 +56,9 @@ int XmlGmlInterface::readFile(const QString &fileName) auto surfaces = std::unique_ptr<std::vector<GeoLib::Surface*>>( new std::vector<GeoLib::Surface*>); - std::map<std::string, std::size_t>* pnt_names = new std::map<std::string, std::size_t>; - std::map<std::string, std::size_t>* ply_names = new std::map<std::string, std::size_t>; - std::map<std::string, std::size_t>* sfc_names = new std::map<std::string, std::size_t>; + auto* pnt_names = new std::map<std::string, std::size_t>; + auto* ply_names = new std::map<std::string, std::size_t>; + auto* sfc_names = new std::map<std::string, std::size_t>; QDomNodeList geoTypes = docElement.childNodes(); for (int i = 0; i < geoTypes.count(); i++) @@ -124,7 +124,7 @@ void XmlGmlInterface::readPoints(const QDomNode &pointsRoot, std::vector<GeoLib: point = point.nextSiblingElement(); } - // if names-map is empty, set it to NULL because it is not needed + // if names-map is empty, set it to nullptr because it is not needed if (pnt_names->empty()) { delete pnt_names; @@ -170,7 +170,7 @@ void XmlGmlInterface::readPolylines(const QDomNode &polylinesRoot, polyline = polyline.nextSiblingElement(); } - // if names-map is empty, set it to NULL because it is not needed + // if names-map is empty, set it to nullptr because it is not needed if (ply_names->empty()) { delete ply_names; @@ -206,7 +206,7 @@ void XmlGmlInterface::readSurfaces(const QDomNode &surfacesRoot, surface = surface.nextSiblingElement(); } - // if names-map is empty, set it to NULL because it is not needed + // if names-map is empty, set it to nullptr because it is not needed if (sfc_names->empty()) { delete sfc_names; diff --git a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.h b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.h index 1f41bb3d9487b7e57f8be0bc72da69290588e777..18aa35dab14e135107f7f10ea0256afe759566a0 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.h +++ b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.h @@ -35,15 +35,18 @@ class XmlGmlInterface : public BaseLib::IO::XMLInterface, public: XmlGmlInterface(GeoLib::GEOObjects& geo_objs); - virtual ~XmlGmlInterface() {} + ~XmlGmlInterface() override = default; /// Reads an xml-file containing geometric object definitions into the GEOObjects used in the contructor - int readFile(const QString &fileName); + int readFile(const QString& fileName) override; - bool readFile(std::string const& fname) { return readFile(QString(fname.c_str())) != 0; } + bool readFile(std::string const& fname) override + { + return readFile(QString(fname.c_str())) != 0; + } protected: - bool write(); + bool write() override; private: /// Reads GeoLib::Point-objects from an xml-file diff --git a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp index 96b3872c6139327455e7f575f77f567baccd17aa..3e645faffa36e02450fe48ceb5d8c3a50f725260 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp +++ b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp @@ -331,7 +331,7 @@ int XmlStnInterface::rapidReadFile(const std::string &fileName) in.seekg(0, std::ios::end); std::size_t length = in.tellg(); in.seekg(0, std::ios::beg); - char* buffer = new char[length + 1]; + auto* buffer = new char[length + 1]; in.read(buffer, length); buffer[in.gcount()] = '\0'; in.close(); @@ -388,7 +388,8 @@ void XmlStnInterface::rapidReadStations(const rapidxml::xml_node<>* station_root { double zVal(0.0); if (station_node->first_attribute("z")) - zVal = strtod(station_node->first_attribute("z")->value(), 0); + zVal = strtod(station_node->first_attribute("z")->value(), + nullptr); std::string station_name(""), sensor_data_file_name(""), bdate_str("0000-00-00"); double station_value(0.0), borehole_depth(0.0); @@ -398,16 +399,19 @@ void XmlStnInterface::rapidReadStations(const rapidxml::xml_node<>* station_root sensor_data_file_name = station_node->first_node("sensordata")->value(); if (station_node->first_node("value")) - station_value = strtod(station_node->first_node("value")->value(), 0); + station_value = + strtod(station_node->first_node("value")->value(), nullptr); /* add other station features here */ if (std::string(station_node->name()).compare("station") == 0) { - GeoLib::Station* s = new GeoLib::Station( - strtod(station_node->first_attribute("x")->value(), 0), - strtod(station_node->first_attribute("y")->value(), 0), - zVal, - station_name); + auto* s = new GeoLib::Station( + strtod(station_node->first_attribute("x")->value(), + nullptr), + strtod(station_node->first_attribute("y")->value(), + nullptr), + zVal, + station_name); s->setStationValue(station_value); if (!sensor_data_file_name.empty()) s->addSensorDataFromCSV(BaseLib::copyPathToFileName( @@ -418,15 +422,19 @@ void XmlStnInterface::rapidReadStations(const rapidxml::xml_node<>* station_root else if (std::string(station_node->name()).compare("borehole") == 0) { if (station_node->first_node("bdepth")) - borehole_depth = strtod(station_node->first_node("bdepth")->value(), 0); + borehole_depth = strtod( + station_node->first_node("bdepth")->value(), nullptr); if (station_node->first_node("bdate")) bdate_str = station_node->first_node("bdate")->value(); /* add other borehole features here */ - GeoLib::StationBorehole* s = GeoLib::StationBorehole::createStation( + GeoLib::StationBorehole* s = + GeoLib::StationBorehole::createStation( station_name, - strtod(station_node->first_attribute("x")->value(), 0), - strtod(station_node->first_attribute("y")->value(), 0), + strtod(station_node->first_attribute("x")->value(), + nullptr), + strtod(station_node->first_attribute("y")->value(), + nullptr), zVal, borehole_depth, bdate_str); @@ -459,13 +467,17 @@ void XmlStnInterface::rapidReadStratigraphy( const rapidxml::xml_node<>* strat_r horizon_name = horizon_node->first_node("name")->value(); /* add other horizon features here */ - double depth (strtod(horizon_node->first_attribute("z")->value(), 0)); + double depth( + strtod(horizon_node->first_attribute("z")->value(), nullptr)); if (fabs(depth - depth_check) > std::numeric_limits<double>::epsilon()) // skip soil-layer if its thickness is zero { - borehole->addSoilLayer(strtod(horizon_node->first_attribute("x")->value(), 0), - strtod(horizon_node->first_attribute("y")->value(), 0), - depth, - horizon_name); + borehole->addSoilLayer( + strtod(horizon_node->first_attribute("x")->value(), + nullptr), + strtod(horizon_node->first_attribute("y")->value(), + nullptr), + depth, + horizon_name); depth_check = depth; } else diff --git a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.h b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.h index c9e0bff0d8dca8b573d2b463ed5a10e59ed48ac1..5266a1301c85d87caea7022458fe0a1a367d0c5e 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.h +++ b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.h @@ -39,15 +39,18 @@ public: XmlStnInterface(GeoLib::GEOObjects& geo_objs); /// Reads an xml-file containing station object definitions into the GEOObjects used in the contructor (requires Qt) - int readFile(const QString &fileName); + int readFile(const QString& fileName) override; - bool readFile(std::string const& fname) { return readFile(QString(fname.c_str())) != 0; } + bool readFile(std::string const& fname) override + { + return readFile(QString(fname.c_str())) != 0; + } /// Reads an xml-file using the RapidXML parser integrated in the source code (i.e. this function is usable without Qt) int rapidReadFile(const std::string &fileName); protected: - bool write(); + bool write() override; private: /// Reads GeoLib::Station- or StationBorehole-objects from an xml-file diff --git a/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp b/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp index a07d262f79b057b84a7a25bc4ba554c75853d97f..ee2d47560fb39b95fce743199807af727b488458 100644 --- a/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp +++ b/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp @@ -29,19 +29,19 @@ namespace IO std::vector<GeoLib::Point*> *RapidStnInterface::readStationFile(const std::string &fileName) { - std::vector<GeoLib::Point*> *stations = new std::vector<GeoLib::Point*>; + auto* stations = new std::vector<GeoLib::Point*>; std::ifstream in(fileName.c_str()); if (in.fail()) { ERR("XmlStnInterface::rapidReadFile() - Can't open xml-file."); - return NULL; + return nullptr; } // buffer file in.seekg(0, std::ios::end); std::size_t length = in.tellg(); in.seekg(0, std::ios::beg); - char* buffer = new char[length+1]; + auto* buffer = new char[length + 1]; in.read(buffer, length); buffer[in.gcount()] = '\0'; in.close(); @@ -54,7 +54,7 @@ std::vector<GeoLib::Point*> *RapidStnInterface::readStationFile(const std::strin if (std::string(doc.first_node()->name()).compare("OpenGeoSysSTN") != 0) { ERR("XmlStnInterface::readFile() - Unexpected XML root."); - return NULL; + return nullptr; } // iterate over all station lists @@ -146,7 +146,8 @@ void RapidStnInterface::readStations(const rapidxml::xml_node<>* station_root, s { double zVal(0.0); if (station_node->first_attribute("z")) - zVal = strtod(station_node->first_attribute("z")->value(), 0); + zVal = strtod(station_node->first_attribute("z")->value(), + nullptr); std::string station_name(""), sensor_data_file_name(""), bdate_str("0000-00-00"); double station_value(0.0), borehole_depth(0.0); @@ -155,16 +156,19 @@ void RapidStnInterface::readStations(const rapidxml::xml_node<>* station_root, s if (station_node->first_node("sensordata")) sensor_data_file_name = station_node->first_node("sensordata")->value(); if (station_node->first_node("value")) - station_value = strtod(station_node->first_node("value")->value(), 0); + station_value = + strtod(station_node->first_node("value")->value(), nullptr); /* add other station features here */ if (std::string(station_node->name()).compare("station") == 0) { - GeoLib::Station* s = new GeoLib::Station( - strtod(station_node->first_attribute("x")->value(), 0), - strtod(station_node->first_attribute("y")->value(), 0), - zVal, - station_name); + auto* s = new GeoLib::Station( + strtod(station_node->first_attribute("x")->value(), + nullptr), + strtod(station_node->first_attribute("y")->value(), + nullptr), + zVal, + station_name); s->setStationValue(station_value); if (!sensor_data_file_name.empty()) s->addSensorDataFromCSV(BaseLib::copyPathToFileName(sensor_data_file_name, file_name)); @@ -173,15 +177,19 @@ void RapidStnInterface::readStations(const rapidxml::xml_node<>* station_root, s else if (std::string(station_node->name()).compare("borehole") == 0) { if (station_node->first_node("bdepth")) - borehole_depth = strtod(station_node->first_node("bdepth")->value(), 0); + borehole_depth = strtod( + station_node->first_node("bdepth")->value(), nullptr); if (station_node->first_node("bdate")) bdate_str = station_node->first_node("bdate")->value(); /* add other borehole features here */ - GeoLib::StationBorehole* s = GeoLib::StationBorehole::createStation( + GeoLib::StationBorehole* s = + GeoLib::StationBorehole::createStation( station_name, - strtod(station_node->first_attribute("x")->value(), 0), - strtod(station_node->first_attribute("y")->value(), 0), + strtod(station_node->first_attribute("x")->value(), + nullptr), + strtod(station_node->first_attribute("y")->value(), + nullptr), zVal, borehole_depth, bdate_str); @@ -217,13 +225,17 @@ void RapidStnInterface::readStratigraphy( const rapidxml::xml_node<>* strat_root horizon_name = horizon_node->first_node("name")->value(); /* add other horizon features here */ - double depth (strtod(horizon_node->first_attribute("z")->value(), 0)); + double depth( + strtod(horizon_node->first_attribute("z")->value(), nullptr)); if (fabs(depth - depth_check) > std::numeric_limits<double>::epsilon()) // skip soil-layer if its thickness is zero { - borehole->addSoilLayer(strtod(horizon_node->first_attribute("x")->value(), 0), - strtod(horizon_node->first_attribute("y")->value(), 0), - depth, - horizon_name); + borehole->addSoilLayer( + strtod(horizon_node->first_attribute("x")->value(), + nullptr), + strtod(horizon_node->first_attribute("y")->value(), + nullptr), + depth, + horizon_name); depth_check = depth; } else diff --git a/GeoLib/MinimalBoundingSphere.cpp b/GeoLib/MinimalBoundingSphere.cpp index f16603efb9b942009cf13d4b34ae75ac15a29a78..c016239eb5718d1268554d1842e4b42d00a4fdbd 100644 --- a/GeoLib/MinimalBoundingSphere.cpp +++ b/GeoLib/MinimalBoundingSphere.cpp @@ -187,7 +187,7 @@ double MinimalBoundingSphere::pointDistanceSquared(MathLib::Point3d const& pnt) std::vector<MathLib::Point3d*>* MinimalBoundingSphere::getRandomSpherePoints(std::size_t n_points) const { - std::vector<MathLib::Point3d*> *pnts = new std::vector<MathLib::Point3d*>; + auto* pnts = new std::vector<MathLib::Point3d*>; pnts->reserve(n_points); srand ( static_cast<unsigned>(time(nullptr)) ); diff --git a/GeoLib/Point.h b/GeoLib/Point.h index 3d61d4ee2b1a2cbb3c0cb6d5c2c94370a63deaef..c0a8fd6a3e3102d82608eef18dac68aadd4b7e40 100644 --- a/GeoLib/Point.h +++ b/GeoLib/Point.h @@ -52,7 +52,7 @@ public: {} /// return a geometry type - virtual GEOTYPE getGeoType() const {return GEOTYPE::POINT;} + GEOTYPE getGeoType() const override { return GEOTYPE::POINT; } protected: friend PointVec; diff --git a/GeoLib/PointVec.cpp b/GeoLib/PointVec.cpp index 7e619040b585d2d58f3be3b6b964f602b4a953f5..19fab788d5c8eb221c24f0bf53f29c9145f57b37 100644 --- a/GeoLib/PointVec.cpp +++ b/GeoLib/PointVec.cpp @@ -124,7 +124,7 @@ PointVec::PointVec(const std::string& name, std::size_t PointVec::push_back(Point* pnt) { _pnt_id_map.push_back(uniqueInsert(pnt)); - _id_to_name_map.push_back(""); + _id_to_name_map.emplace_back(""); return _pnt_id_map[_pnt_id_map.size() - 1]; } @@ -133,7 +133,7 @@ void PointVec::push_back(Point* pnt, std::string const* const name) if (name == nullptr) { _pnt_id_map.push_back(uniqueInsert(pnt)); - _id_to_name_map.push_back(""); + _id_to_name_map.emplace_back(""); return; } @@ -141,7 +141,7 @@ void PointVec::push_back(Point* pnt, std::string const* const name) _name_id_map->find(*name)); if (it != _name_id_map->end()) { - _id_to_name_map.push_back(""); + _id_to_name_map.emplace_back(""); WARN("PointVec::push_back(): two points share the name %s.", name->c_str()); return; @@ -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& id_name_pair : *_name_id_map) { - id_names[it->second] = it->first; + id_names[id_name_pair.second] = id_name_pair.first; } for (auto it = _name_id_map->begin(); it != _name_id_map->end();) diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index 70f95c854c92d5671ecb4a222776026c34b25af6..daa2a28aa491939dc91d3663c53a5460763819c5 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -48,11 +48,10 @@ Polygon::Polygon(Polygon const& other) Polygon::~Polygon() { // remove polygons from list - for (std::list<Polygon*>::iterator it (_simple_polygon_list.begin()); - it != _simple_polygon_list.end(); ++it) + for (auto& polygon : _simple_polygon_list) // the first entry of the list can be a pointer the object itself - if (*it != this) - delete *it; + if (polygon != this) + delete polygon; } bool Polygon::initialise () @@ -101,8 +100,7 @@ bool Polygon::isPntInPolygon (GeoLib::Point const & pnt) const if (n_intersections % 2 == 1) return true; } else { - for (std::list<Polygon*>::const_iterator it( - _simple_polygon_list.begin()++); + for (auto it(_simple_polygon_list.begin()++); it != _simple_polygon_list.end(); ++it) { @@ -235,12 +233,10 @@ bool Polygon::getNextIntersectionPointPolygonLine( } } } else { - for (auto polygon_it(_simple_polygon_list.begin()); - polygon_it != _simple_polygon_list.end(); - ++polygon_it) + for (auto polygon : _simple_polygon_list) { - Polygon const& polygon(*(*polygon_it)); - for (auto seg_it(polygon.begin()); seg_it != polygon.end(); ++seg_it) + for (auto seg_it(polygon->begin()); seg_it != polygon->end(); + ++seg_it) { if (GeoLib::lineSegmentIntersect(*seg_it, seg, intersection)) { seg_num = seg_it.getSegmentNumber(); @@ -262,9 +258,8 @@ void Polygon::computeListOfSimplePolygons () splitPolygonAtPoint (_simple_polygon_list.begin()); splitPolygonAtIntersection (_simple_polygon_list.begin()); - for (std::list<Polygon*>::iterator it (_simple_polygon_list.begin()); - it != _simple_polygon_list.end(); ++it) - (*it)->initialise (); + for (auto& polygon : _simple_polygon_list) + polygon->initialise(); } EdgeType Polygon::getEdgeType (std::size_t k, GeoLib::Point const & pnt) const @@ -467,7 +462,7 @@ GeoLib::Polygon* createPolygonFromCircle (GeoLib::Point const& middle_pnt, doubl double angle (boost::math::double_constants::two_pi / resolution); for (std::size_t k(0); k < resolution; k++) { - GeoLib::Point* pnt(new GeoLib::Point(middle_pnt)); + auto* pnt(new GeoLib::Point(middle_pnt)); (*pnt)[0] += radius * cos (k * angle); (*pnt)[1] += radius * sin (k * angle); pnts.push_back (pnt); diff --git a/GeoLib/Polygon.h b/GeoLib/Polygon.h index 08a7267f4b8741fdc882901864d54683d4c3a6a3..ed6593176dc631eb8bbfb0ba53a2e71a8003f393 100644 --- a/GeoLib/Polygon.h +++ b/GeoLib/Polygon.h @@ -54,7 +54,7 @@ public: Polygon(Polygon const& other); Polygon& operator=(Polygon const& rhs) = delete; - virtual ~Polygon(); + ~Polygon() override; bool initialise (); diff --git a/GeoLib/PolygonWithSegmentMarker.h b/GeoLib/PolygonWithSegmentMarker.h index 6d91c215ad8a3ad5ee3cb5c4bb38bb1a4c8ad664..b42a46c2e261f0de9c425820046367767058f1b6 100644 --- a/GeoLib/PolygonWithSegmentMarker.h +++ b/GeoLib/PolygonWithSegmentMarker.h @@ -38,14 +38,14 @@ public: * corresponding line segment. * @see Polyline::addPoint() */ - virtual bool addPoint(std::size_t pnt_id) override; + bool addPoint(std::size_t pnt_id) override; /** * Method calls the @see Polyline::insertPoint() and initializes the inserted line * segment with the same value the previous line segment had. * @see Polyline::insertPoint() */ - virtual bool insertPoint(std::size_t pos, std::size_t pnt_id) override; + bool insertPoint(std::size_t pos, std::size_t pnt_id) override; private: std::vector<bool> _marker; diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp index abcfe70494e0b731375435b77be8ad4164ea4403..90a863039a4c6d3deb24e00fbc8e9724ab6ac812 100644 --- a/GeoLib/Polyline.cpp +++ b/GeoLib/Polyline.cpp @@ -90,9 +90,9 @@ bool Polyline::insertPoint(std::size_t pos, std::size_t pnt_id) } } - std::vector<std::size_t>::difference_type const pos_dt( + auto const pos_dt( static_cast<std::vector<std::size_t>::difference_type>(pos)); - std::vector<std::size_t>::iterator it(_ply_pnt_ids.begin() + pos_dt); + auto it(_ply_pnt_ids.begin() + pos_dt); _ply_pnt_ids.insert(it, pnt_id); if (_ply_pnt_ids.size() > 1) { @@ -131,7 +131,7 @@ bool Polyline::insertPoint(std::size_t pos, std::size_t pnt_id) double update_dist( len_seg0 + len_seg1 - (_length[pos] - dist_until_now)); _length[pos] = dist_until_now + len_seg0; - std::vector<double>::iterator it1(_length.begin() + pos_dt + 1); + auto it1(_length.begin() + pos_dt + 1); _length.insert(it1, _length[pos] + len_seg1); for (it1 = _length.begin() + pos_dt + 2; it1 != _length.end(); ++it1) @@ -147,7 +147,7 @@ void Polyline::removePoint(std::size_t pos) if (pos >= _ply_pnt_ids.size()) return; - std::vector<std::size_t>::difference_type const pos_dt( + auto const pos_dt( static_cast<std::vector<std::size_t>::difference_type>(pos)); _ply_pnt_ids.erase(_ply_pnt_ids.begin() + pos_dt); @@ -270,7 +270,7 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & { std::size_t nLines = ply_vec.size(); - Polyline* new_ply = new Polyline(*ply_vec[0]); + auto* new_ply = new Polyline(*ply_vec[0]); std::vector<GeoLib::Point*> pnt_vec(new_ply->getPointsVec()); std::vector<Polyline*> local_ply_vec; @@ -281,8 +281,7 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & { bool ply_found(false); prox *= prox; // square distance once to save time later - for (std::vector<Polyline*>::iterator it = local_ply_vec.begin(); - it != local_ply_vec.end(); ++it) + for (auto it = local_ply_vec.begin(); it != local_ply_vec.end(); ++it) { if (pnt_vec == (*it)->getPointsVec()) { @@ -292,7 +291,7 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & if (pointsAreIdentical(pnt_vec, new_ply->getPointID(0), (*it)->getPointID(0), prox)) { - Polyline* tmp = new Polyline((*it)->getPointsVec()); + auto* tmp = new Polyline((*it)->getPointsVec()); for (std::size_t k = 0; k < nPoints; k++) tmp->addPoint((*it)->getPointID(nPoints - k - 1)); @@ -307,7 +306,7 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & else if (pointsAreIdentical(pnt_vec, new_ply->getPointID(0), (*it)->getPointID(nPoints - 1), prox)) { - Polyline* tmp = new Polyline(**it); + auto* tmp = new Polyline(**it); std::size_t new_ply_size(new_ply->getNumberOfPoints()); for (std::size_t k = 1; k < new_ply_size; k++) tmp->addPoint(new_ply->getPointID(k)); diff --git a/GeoLib/Polyline.h b/GeoLib/Polyline.h index 5113d1e085fbc9516c196874ce790d1c65e62fab..e71ce75a629b8d5148d82df34f790b210a78e5c0 100644 --- a/GeoLib/Polyline.h +++ b/GeoLib/Polyline.h @@ -101,11 +101,10 @@ public: Polyline(const Polyline& ply); Polyline& operator=(Polyline const& other) = delete; - virtual ~Polyline() {} + ~Polyline() override = default; /// return a geometry type - virtual GEOTYPE getGeoType() const {return GEOTYPE::POLYLINE;} - + GEOTYPE getGeoType() const override { return GEOTYPE::POLYLINE; } /** write the points to the stream */ void write(std::ostream &os) const; diff --git a/GeoLib/PolylineVec.h b/GeoLib/PolylineVec.h index cd09252f3ae0080b8961a26aebf765d55e18fc44..bbd9732e92e31b03bed8e129d7cf9fd552bf9f1d 100644 --- a/GeoLib/PolylineVec.h +++ b/GeoLib/PolylineVec.h @@ -26,6 +26,6 @@ namespace GeoLib { * additional one can give the vector of polylines a name * */ -typedef TemplateVec<Polyline> PolylineVec; +using PolylineVec = TemplateVec<GeoLib::Polyline>; } // end namespace diff --git a/GeoLib/PolylineWithSegmentMarker.h b/GeoLib/PolylineWithSegmentMarker.h index a7f72b4da0d60c1d641ab86c4ab75c8deef617bf..a751a48c9114ff2c53f5b3a0e1b742f9e3eaabb9 100644 --- a/GeoLib/PolylineWithSegmentMarker.h +++ b/GeoLib/PolylineWithSegmentMarker.h @@ -44,14 +44,14 @@ public: * corresponding line segment. * @see Polyline::addPoint() */ - virtual bool addPoint(std::size_t pnt_id) override; + bool addPoint(std::size_t pnt_id) override; /** * Method calls the @see Polyline::insertPoint() and initializes the inserted line segment with the same * value the previous line segment had. * @see Polyline::insertPoint() */ - virtual bool insertPoint(std::size_t pos, std::size_t pnt_id) override; + bool insertPoint(std::size_t pos, std::size_t pnt_id) override; private: std::vector<bool> _marker; diff --git a/GeoLib/QuadTree.h b/GeoLib/QuadTree.h index de71d952ef123e0d13abca6c079f404f524fd59f..4a40d60ccf88d2bef2c33255df9e9672a84c872a 100644 --- a/GeoLib/QuadTree.h +++ b/GeoLib/QuadTree.h @@ -17,6 +17,7 @@ #include <limits> #include <logog/include/logog.hpp> +#include <utility> namespace GeoLib { @@ -47,15 +48,19 @@ public: * @param ur upper right point of the square * @param max_points_per_leaf maximum number of points per leaf */ - QuadTree(POINT const& ll, POINT const& ur, std::size_t max_points_per_leaf) : - _father (nullptr), _ll (ll), _ur (ur), _depth (0), _is_leaf (true), - _max_points_per_leaf (max_points_per_leaf) + QuadTree(POINT ll, POINT ur, std::size_t max_points_per_leaf) + : _father(nullptr), + _ll(std::move(ll)), + _ur(std::move(ur)), + _depth(0), + _is_leaf(true), + _max_points_per_leaf(max_points_per_leaf) { assert (_max_points_per_leaf > 0); // init children - for (std::size_t k(0); k < 4; k++) - _children[k] = nullptr; + for (auto& child : _children) + child = nullptr; if ((_ur[0] - _ll[0]) > (_ur[1] - _ll[1])) _ur[1] = _ll[1] + _ur[0] - _ll[0]; @@ -70,8 +75,9 @@ public: */ ~QuadTree() { - for (std::size_t k(0); k < 4; k++) { - delete _children[k]; + for (auto& child : _children) + { + delete child; } } @@ -89,8 +95,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& child : _children) + { + if (child->addPoint(pnt)) return true; } return false; @@ -182,9 +189,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& child : _children) + child->getLeafs(leaf_list); } const std::vector<POINT const*>& getPoints () const { return _pnts; } @@ -241,9 +247,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& child : _children) + { + if (child) + { + child->getMaxDepth(max_depth); } } } @@ -365,17 +373,21 @@ private: * @param max_points_per_leaf maximum number of points per leaf * @return */ - QuadTree (POINT const& ll, - POINT const& ur, - QuadTree* father, - std::size_t depth, - std::size_t max_points_per_leaf) : - _father (father), _ll (ll), _ur (ur), _depth (depth), _is_leaf (true), - _max_points_per_leaf (max_points_per_leaf) + QuadTree(POINT ll, + POINT ur, + QuadTree* father, + std::size_t depth, + std::size_t max_points_per_leaf) + : _father(father), + _ll(std::move(ll)), + _ur(std::move(ur)), + _depth(depth), + _is_leaf(true), + _max_points_per_leaf(max_points_per_leaf) { // init children - for (std::size_t k(0); k < 4; k++) - _children[k] = nullptr; + for (auto& child : _children) + child = nullptr; } void splitNode () diff --git a/GeoLib/Raster.cpp b/GeoLib/Raster.cpp index aa23861a09732c50f8b5dfbb71c718ff33aafa22..8c2b5e8624608b4d13b9e83019422b8967be10ed 100644 --- a/GeoLib/Raster.cpp +++ b/GeoLib/Raster.cpp @@ -27,7 +27,8 @@ namespace GeoLib { void Raster::refineRaster(std::size_t scaling) { - double *new_raster_data(new double[_header.n_rows*_header.n_cols*scaling*scaling]); + auto* new_raster_data( + new double[_header.n_rows * _header.n_cols * scaling * scaling]); for (std::size_t row(0); row<_header.n_rows; row++) { for (std::size_t col(0); col<_header.n_cols; col++) { @@ -62,7 +63,7 @@ Raster* Raster::getRasterFromSurface(Surface const& sfc, double cell_size, doubl const std::size_t n_cols = static_cast<std::size_t>(std::abs(ur[0]-ll[0]) / cell_size)+1; const std::size_t n_rows = static_cast<std::size_t>(std::abs(ur[1]-ll[1]) / cell_size)+1; const std::size_t n_triangles(sfc.getNumberOfTriangles()); - double *z_vals (new double[n_cols*n_rows]); + auto* z_vals(new double[n_cols * n_rows]); std::size_t k(0); for (std::size_t r(0); r < n_cols; r++) { @@ -93,16 +94,21 @@ double Raster::getValueAtPoint(const MathLib::Point3d &pnt) const if (pnt[0]>=_header.origin[0] && pnt[0]<(_header.origin[0]+(_header.cell_size*_header.n_cols)) && pnt[1]>=_header.origin[1] && pnt[1]<(_header.origin[1]+(_header.cell_size*_header.n_rows))) { - int cell_x = static_cast<int>(std::floor((pnt[0] - _header.origin[0])/_header.cell_size)); - int cell_y = static_cast<int>(std::floor((pnt[1] - _header.origin[1])/_header.cell_size)); - - // use raster boundary values if node is outside raster due to rounding errors or floating point arithmetic - cell_x = (cell_x < 0) ? 0 : ((cell_x > static_cast<int>(_header.n_cols)) ? - static_cast<int>(_header.n_cols-1) : cell_x); - cell_y = (cell_y < 0) ? 0 : ((cell_y > static_cast<int>(_header.n_rows)) ? - static_cast<int>(_header.n_rows-1) : cell_y); - - const std::size_t index = cell_y*_header.n_cols+cell_x; + auto cell_x = static_cast<int>( + std::floor((pnt[0] - _header.origin[0]) / _header.cell_size)); + auto cell_y = static_cast<int>( + std::floor((pnt[1] - _header.origin[1]) / _header.cell_size)); + + // use raster boundary values if node is outside raster due to rounding + // errors or floating point arithmetic + cell_x = (cell_x < 0) ? 0 : ((cell_x > static_cast<int>(_header.n_cols)) + ? static_cast<int>(_header.n_cols - 1) + : cell_x); + cell_y = (cell_y < 0) ? 0 : ((cell_y > static_cast<int>(_header.n_rows)) + ? static_cast<int>(_header.n_rows - 1) + : cell_y); + + const std::size_t index = cell_y * _header.n_cols + cell_x; return _raster_data[index]; } return _header.no_data; diff --git a/GeoLib/Raster.h b/GeoLib/Raster.h index 386ab2ecb59c2a7532b04202d0577b811c9b7ad6..07a5914c199b1cb9bad4425e90eded11e89716ca 100644 --- a/GeoLib/Raster.h +++ b/GeoLib/Raster.h @@ -13,6 +13,8 @@ #pragma once +#include <utility> + #include "Surface.h" namespace GeoLib { @@ -37,8 +39,8 @@ struct RasterHeader */ class Raster { public: - typedef double const* const_iterator; - typedef double* iterator; + using const_iterator = const double*; + using iterator = double*; /** * @brief Constructor for an object of class Raster. The raster data have @@ -49,9 +51,10 @@ public: * @param begin input iterator pointing to the first element of the data * @param end input iterator pointing to the last element of the data, end have to be reachable from begin */ - template<typename InputIterator> - Raster(RasterHeader header, InputIterator begin, InputIterator end) : - _header(header), _raster_data(new double[_header.n_cols*_header.n_rows]) + template <typename InputIterator> + Raster(RasterHeader header, InputIterator begin, InputIterator end) + : _header(std::move(header)), + _raster_data(new double[_header.n_cols * _header.n_rows]) { iterator raster_it(_raster_data); for (InputIterator it(begin); it != end; ++it) { diff --git a/GeoLib/SensorData.cpp b/GeoLib/SensorData.cpp index 04614f348d6a82b3843f9257d7b137471770bfea..dcf368718105a0122fa9113b258b4fb9b710a900 100644 --- a/GeoLib/SensorData.cpp +++ b/GeoLib/SensorData.cpp @@ -123,8 +123,8 @@ int SensorData::readDataFromFile(const std::string &file_name) for (std::size_t i=0; i<nDataArrays; i++) { this->_vec_names.push_back(SensorData::convertString2SensorDataType(*++it)); - this->_data_unit_string.push_back(""); - std::vector<float> *data = new std::vector<float>; + this->_data_unit_string.emplace_back(""); + auto* data = new std::vector<float>; this->_data_vecs.push_back(data); } @@ -140,7 +140,8 @@ int SensorData::readDataFromFile(const std::string &file_name) this->_time_steps.push_back(current_time_step); for (std::size_t i=0; i<nDataArrays; i++) - this->_data_vecs[i]->push_back(static_cast<float>(strtod((it++)->c_str(), 0))); + this->_data_vecs[i]->push_back( + static_cast<float>(strtod((it++)->c_str(), nullptr))); } else return 0; diff --git a/GeoLib/SimplePolygonTree.h b/GeoLib/SimplePolygonTree.h index eb53dd8a786565f83a246a2042ec055aac906845..e76232be6ea3659e31d8234f78ce7a57e4aeb2f4 100644 --- a/GeoLib/SimplePolygonTree.h +++ b/GeoLib/SimplePolygonTree.h @@ -85,11 +85,11 @@ private: template <typename POLYGONTREETYPE> void createPolygonTrees (std::list<POLYGONTREETYPE*>& list_of_simple_polygon_hierarchies) { - typedef typename std::list<POLYGONTREETYPE*>::const_iterator CIT; - typedef typename std::list<POLYGONTREETYPE*>::iterator IT; - for (CIT it0(list_of_simple_polygon_hierarchies.begin()); - it0 != list_of_simple_polygon_hierarchies.end(); ++it0) { - IT it1 = list_of_simple_polygon_hierarchies.begin(); + for (auto it0 = list_of_simple_polygon_hierarchies.begin(); + it0 != list_of_simple_polygon_hierarchies.end(); + ++it0) + { + auto it1 = list_of_simple_polygon_hierarchies.begin(); while (it1 != list_of_simple_polygon_hierarchies.end()) { if (it0 == it1) { // don't check same polygons ++it1; diff --git a/GeoLib/Station.cpp b/GeoLib/Station.cpp index 2f786943505cdb42b547dcd527c1fd5a3aaced11..27332304b9dca38b4f139bd143fa4eaa815ab093 100644 --- a/GeoLib/Station.cpp +++ b/GeoLib/Station.cpp @@ -23,14 +23,20 @@ namespace GeoLib { -Station::Station(double x, double y, double z, std::string const& name) : - Point (x,y,z), _name(name), _type(Station::StationType::STATION), - _station_value(0.0), _sensor_data(nullptr) +Station::Station(double x, double y, double z, std::string name) + : Point(x, y, z), + _name(std::move(name)), + _type(Station::StationType::STATION), + _station_value(0.0), + _sensor_data(nullptr) {} -Station::Station(Point* coords, std::string const& name) : - Point (*coords), _name(name), _type(Station::StationType::STATION), - _station_value(0.0), _sensor_data(nullptr) +Station::Station(Point* coords, std::string name) + : Point(*coords), + _name(std::move(name)), + _type(Station::StationType::STATION), + _station_value(0.0), + _sensor_data(nullptr) {} Station::Station(Station const& src) : @@ -78,7 +84,7 @@ Station* Station::createStation(const std::string &name, double x, double y, dou bool isStation(GeoLib::Point const* pnt) { - GeoLib::Station const* bh(dynamic_cast<GeoLib::Station const*>(pnt)); + auto const* bh(dynamic_cast<GeoLib::Station const*>(pnt)); return bh != nullptr; } diff --git a/GeoLib/Station.h b/GeoLib/Station.h index adca976c61b3cffe809e6d1f62cf01eec2b570e7..05cf9e70bd47f864910507d0ebf1881537bd802c 100644 --- a/GeoLib/Station.h +++ b/GeoLib/Station.h @@ -55,9 +55,9 @@ public: Station(double x = 0.0, double y = 0.0, double z = 0.0, - std::string const& name = ""); + std::string name = ""); - Station(Point* coords, std::string const& name = ""); + Station(Point* coords, std::string name = ""); /** * Constructor copies the source object @@ -65,7 +65,7 @@ public: */ Station(Station const& src); - virtual ~Station(); + ~Station() override; /// Returns the name of the station. std::string const& getName() const { return _name; } diff --git a/GeoLib/StationBorehole.cpp b/GeoLib/StationBorehole.cpp index 24c05347380cf6d9a07b1fd79969a94faf51ef9a..57671ab879f46aad59a7bb925e5d30e1cfb8e502 100644 --- a/GeoLib/StationBorehole.cpp +++ b/GeoLib/StationBorehole.cpp @@ -37,7 +37,7 @@ StationBorehole::StationBorehole(double x, double y, double z, const std::string // add first point of borehole _profilePntVec.push_back(this); - _soilName.push_back(""); + _soilName.emplace_back(""); } StationBorehole::~StationBorehole(void) @@ -123,7 +123,9 @@ int StationBorehole::addLayer(std::list<std::string> fields, StationBorehole* bo fields.pop_front(); ERR("StationBorehole::addLayer - assuming correct order"); - double thickness(strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), 0)); + double thickness( + strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), + nullptr)); fields.pop_front(); borehole->addSoilLayer(thickness, fields.front()); } @@ -138,7 +140,7 @@ int StationBorehole::addLayer(std::list<std::string> fields, StationBorehole* bo int StationBorehole::addStratigraphy(const std::vector<Point*> &profile, const std::vector<std::string> &soil_names) { - if (((profile.size()-1) == soil_names.size()) && (soil_names.size()>0)) + if (((profile.size() - 1) == soil_names.size()) && (!soil_names.empty())) { this->_profilePntVec.push_back(profile[0]); std::size_t nLayers = soil_names.size(); @@ -178,8 +180,9 @@ int StationBorehole::addStratigraphies(const std::string &path, std::vector<Poin fields.pop_front(); //the method just assumes that layers are read in correct order fields.pop_front(); - double thickness (strtod(BaseLib::replaceString(",", ".", - fields.front()).c_str(), 0)); + double thickness(strtod( + BaseLib::replaceString(",", ".", fields.front()).c_str(), + nullptr)); fields.pop_front(); std::string soil_name (fields.front()); fields.pop_front(); @@ -255,7 +258,7 @@ void StationBorehole::createSurrogateStratigraphies(std::vector<Point*>* borehol std::size_t nBoreholes = boreholes->size(); for (std::size_t i = 0; i < nBoreholes; i++) { - StationBorehole* bore = static_cast<StationBorehole*>((*boreholes)[i]); + auto* bore = static_cast<StationBorehole*>((*boreholes)[i]); bore->addSoilLayer(bore->getDepth(), "depth"); } } @@ -295,8 +298,7 @@ void StationBorehole::addSoilLayer ( double x, double y, double z, const std::st bool isBorehole(GeoLib::Point const* pnt) { - GeoLib::StationBorehole const* bh( - dynamic_cast<GeoLib::StationBorehole const*>(pnt)); + auto const* bh(dynamic_cast<GeoLib::StationBorehole const*>(pnt)); return bh != nullptr; } diff --git a/GeoLib/StationBorehole.h b/GeoLib/StationBorehole.h index 725d62c80f605eba399dae07c6a059031f1889fb..fbb2ea47140143d882f14c7d1ed3b093a21217c6 100644 --- a/GeoLib/StationBorehole.h +++ b/GeoLib/StationBorehole.h @@ -33,7 +33,7 @@ class StationBorehole : public Station public: /** constructor initialises the borehole with the given coordinates */ StationBorehole(double x = 0.0, double y = 0.0, double z = 0.0, const std::string &name = ""); - ~StationBorehole(void); + ~StationBorehole(void) override; /// Creates a StationBorehole-object from a string (assuming the string has the right format) static StationBorehole* createStation(const std::string &line); diff --git a/GeoLib/Surface.cpp b/GeoLib/Surface.cpp index 536962fe03c37cde3b18fe8063b3aabef6b511a0..e3d8b72f799601303402b9f024bd51bc4e1bf3e5 100644 --- a/GeoLib/Surface.cpp +++ b/GeoLib/Surface.cpp @@ -101,21 +101,18 @@ Surface* Surface::createSurface(const Polyline& ply) } // create empty surface - Surface* sfc(new Surface(ply.getPointsVec())); + auto* sfc(new Surface(ply.getPointsVec())); - Polygon* polygon(new Polygon(ply)); + auto* polygon(new Polygon(ply)); polygon->computeListOfSimplePolygons(); // create surfaces from simple polygons const std::list<GeoLib::Polygon*>& list_of_simple_polygons( polygon->getListOfSimplePolygons()); - for (std::list<GeoLib::Polygon*>::const_iterator simple_polygon_it( - list_of_simple_polygons.begin()); - simple_polygon_it != list_of_simple_polygons.end(); - ++simple_polygon_it) + for (auto simple_polygon : list_of_simple_polygons) { std::list<GeoLib::Triangle> triangles; - GeoLib::EarClippingTriangulation(*simple_polygon_it, triangles); + GeoLib::EarClippingTriangulation(simple_polygon, triangles); // add Triangles to Surface std::list<GeoLib::Triangle>::const_iterator it(triangles.begin()); diff --git a/GeoLib/Surface.h b/GeoLib/Surface.h index 0dccba5e65b73941c9986a66dec807cc5e327b00..54f3a455cde56eb3bb4270d6f0c5659bf4ec4218 100644 --- a/GeoLib/Surface.h +++ b/GeoLib/Surface.h @@ -36,7 +36,7 @@ class Surface final : public GeoObject public: explicit Surface(const std::vector<Point*>& pnt_vec); Surface(Surface const& src); - ~Surface(); + ~Surface() override; Surface(Surface && src) = delete; Surface& operator=(Surface const& src) = delete; diff --git a/GeoLib/SurfaceVec.h b/GeoLib/SurfaceVec.h index abd452a3a83ce1ecb0977d5ff6065d79d8c0be80..b1f5a21589dd82f02d543a1eabc272efcb775902 100644 --- a/GeoLib/SurfaceVec.h +++ b/GeoLib/SurfaceVec.h @@ -24,6 +24,6 @@ namespace GeoLib { * and a name. * */ -typedef TemplateVec<Surface> SurfaceVec; +using SurfaceVec = TemplateVec<GeoLib::Surface>; } // end namespace diff --git a/GeoLib/TemplateVec.h b/GeoLib/TemplateVec.h index 36a0ba2ab4ca7b96e47e1eecd87014fdb84404c8..4faf27f4fdc1689b7f105201c00c51f77c11655e 100644 --- a/GeoLib/TemplateVec.h +++ b/GeoLib/TemplateVec.h @@ -20,6 +20,7 @@ #include <map> #include <memory> #include <string> +#include <utility> #include <vector> #include <logog/include/logog.hpp> @@ -39,8 +40,9 @@ namespace GeoLib template <class T> class TemplateVec { protected: - typedef std::pair<std::string, std::size_t> NameIdPair; - typedef std::map<std::string, std::size_t> NameIdMap; + using NameIdPair = std::pair<std::string, std::size_t>; + using NameIdMap = std::map<std::string, std::size_t>; + public: /** * Constructor of class TemlateVec. @@ -55,9 +57,11 @@ public: * of the element and the value for std::size_t stands for an index in * the data_vec. */ - TemplateVec (const std::string &name, std::unique_ptr<std::vector<T*>> data_vec, - NameIdMap* elem_name_map = nullptr) : - _name(name), _data_vec(std::move(data_vec)), _name_id_map (elem_name_map) + TemplateVec(std::string name, std::unique_ptr<std::vector<T*>> data_vec, + NameIdMap* elem_name_map = nullptr) + : _name(std::move(name)), + _data_vec(std::move(data_vec)), + _name_id_map(elem_name_map) { if (_data_vec == nullptr) { diff --git a/MaterialLib/Adsorption/Adsorption.h b/MaterialLib/Adsorption/Adsorption.h index 685d6bbfc417d7a9f5737d1fb2adf735b810fcf7..2ab89082a4404b47e0cb80506d6992a490e01b0c 100644 --- a/MaterialLib/Adsorption/Adsorption.h +++ b/MaterialLib/Adsorption/Adsorption.h @@ -34,9 +34,11 @@ public: double getEquilibriumLoading(const double p_Ads, const double T_Ads, const double M_Ads) const override; - virtual double getEnthalpy(const double p_Ads, const double T_Ads, const double M_Ads) const override; - virtual double getReactionRate(const double p_Ads, const double T_Ads, - const double M_Ads, const double loading) const override; + double getEnthalpy(const double p_Ads, const double T_Ads, + const double M_Ads) const override; + double getReactionRate(const double p_Ads, const double T_Ads, + const double M_Ads, + const double loading) const override; /** * @brief get_d_reaction_rate * @param p_Ads diff --git a/MaterialLib/Adsorption/Density100MPa.h b/MaterialLib/Adsorption/Density100MPa.h index ecd5d099abf90d3b66afc1a8bd0d6ac6e1f9b021..6921c89c300e5fb8e4773ae0569d172ccde90c9b 100644 --- a/MaterialLib/Adsorption/Density100MPa.h +++ b/MaterialLib/Adsorption/Density100MPa.h @@ -17,10 +17,10 @@ namespace Adsorption class Density100MPa : public AdsorptionReaction { public: - double getAdsorbateDensity(const double T_Ads) const; - double getAlphaT(const double T_Ads) const; - double characteristicCurve(const double A) const; - double dCharacteristicCurve(const double A) const; + double getAdsorbateDensity(const double T_Ads) const override; + double getAlphaT(const double T_Ads) const override; + double characteristicCurve(const double A) const override; + double dCharacteristicCurve(const double A) const override; }; } diff --git a/MaterialLib/Adsorption/DensityConst.h b/MaterialLib/Adsorption/DensityConst.h index 97a20104426108fd716294111374a9237f9ef7be..1bc60c77b8d28af7f09ba48997547ec873669271 100644 --- a/MaterialLib/Adsorption/DensityConst.h +++ b/MaterialLib/Adsorption/DensityConst.h @@ -17,10 +17,10 @@ namespace Adsorption class DensityConst : public AdsorptionReaction { public: - double getAdsorbateDensity(const double T_Ads) const; - double getAlphaT(const double T_Ads) const; - double characteristicCurve(const double A) const; - double dCharacteristicCurve(const double A) const; + double getAdsorbateDensity(const double T_Ads) const override; + double getAlphaT(const double T_Ads) const override; + double characteristicCurve(const double A) const override; + double dCharacteristicCurve(const double A) const override; }; } diff --git a/MaterialLib/Adsorption/DensityCook.h b/MaterialLib/Adsorption/DensityCook.h index 35722161f6c64937a914b0d2ec34ae6d755aed91..b9215f8dc1ceb05027ffebf6d80cf77696370462 100644 --- a/MaterialLib/Adsorption/DensityCook.h +++ b/MaterialLib/Adsorption/DensityCook.h @@ -17,10 +17,10 @@ namespace Adsorption class DensityCook : public AdsorptionReaction { public: - double getAdsorbateDensity(const double T_Ads) const; - double getAlphaT(const double T_Ads) const; - double characteristicCurve(const double A) const; - double dCharacteristicCurve(const double A) const; + double getAdsorbateDensity(const double T_Ads) const override; + double getAlphaT(const double T_Ads) const override; + double characteristicCurve(const double A) const override; + double dCharacteristicCurve(const double A) const override; }; inline double rhoWaterDean(const double T_Ads) diff --git a/MaterialLib/Adsorption/DensityDubinin.h b/MaterialLib/Adsorption/DensityDubinin.h index a66bb696bb83bcab6645c41284f78a978635e303..5cbb239d561344f2ddfe7f5fb36ca2cac04000c6 100644 --- a/MaterialLib/Adsorption/DensityDubinin.h +++ b/MaterialLib/Adsorption/DensityDubinin.h @@ -17,10 +17,10 @@ namespace Adsorption class DensityDubinin : public AdsorptionReaction { public: - double getAdsorbateDensity(const double T_Ads) const; - double getAlphaT(const double T_Ads) const; - double characteristicCurve(const double A) const; - double dCharacteristicCurve(const double A) const; + double getAdsorbateDensity(const double T_Ads) const override; + double getAlphaT(const double T_Ads) const override; + double characteristicCurve(const double A) const override; + double dCharacteristicCurve(const double A) const override; }; } diff --git a/MaterialLib/Adsorption/DensityHauer.h b/MaterialLib/Adsorption/DensityHauer.h index 1bf9d1995c53b63cf9b9a19f65125c26c98131f4..5b47e5cec28365c7739fd7bb144c982dd4539fb9 100644 --- a/MaterialLib/Adsorption/DensityHauer.h +++ b/MaterialLib/Adsorption/DensityHauer.h @@ -18,10 +18,10 @@ namespace Adsorption class DensityHauer : public AdsorptionReaction { public: - double getAdsorbateDensity(const double T_Ads) const; - double getAlphaT(const double T_Ads) const; - double characteristicCurve(const double A) const; - double dCharacteristicCurve(const double A) const; + double getAdsorbateDensity(const double T_Ads) const override; + double getAlphaT(const double T_Ads) const override; + double characteristicCurve(const double A) const override; + double dCharacteristicCurve(const double A) const override; }; inline double rhoWaterHauer(const double T_Ads) diff --git a/MaterialLib/Adsorption/DensityLegacy.h b/MaterialLib/Adsorption/DensityLegacy.h index b75632a8393a5d55d3897f39b38e8eb3149dc366..a818e73f206340cd8d39c9289562a50c201640e6 100644 --- a/MaterialLib/Adsorption/DensityLegacy.h +++ b/MaterialLib/Adsorption/DensityLegacy.h @@ -17,10 +17,10 @@ namespace Adsorption class DensityLegacy : public AdsorptionReaction { public: - double getAdsorbateDensity(const double T_Ads) const; - double getAlphaT(const double T_Ads) const; - double characteristicCurve(const double A) const; - double dCharacteristicCurve(const double A) const; + double getAdsorbateDensity(const double T_Ads) const override; + double getAlphaT(const double T_Ads) const override; + double characteristicCurve(const double A) const override; + double dCharacteristicCurve(const double A) const override; }; } diff --git a/MaterialLib/Adsorption/DensityMette.h b/MaterialLib/Adsorption/DensityMette.h index 0ec144f1f57fbebc374b2e5f871448e199064f3d..27e4a702d21db2a376646bfc403951078b79e3e3 100644 --- a/MaterialLib/Adsorption/DensityMette.h +++ b/MaterialLib/Adsorption/DensityMette.h @@ -17,10 +17,10 @@ namespace Adsorption class DensityMette : public AdsorptionReaction { public: - double getAdsorbateDensity(const double T_Ads) const; - double getAlphaT(const double T_Ads) const; - double characteristicCurve(const double A) const; - double dCharacteristicCurve(const double A) const; + double getAdsorbateDensity(const double T_Ads) const override; + double getAlphaT(const double T_Ads) const override; + double characteristicCurve(const double A) const override; + double dCharacteristicCurve(const double A) const override; }; } diff --git a/MaterialLib/Adsorption/DensityNunez.h b/MaterialLib/Adsorption/DensityNunez.h index 7e4e4e71b8805ef8333247aa1a7ec33cff93f597..ad7e2a0c24f82dfaaa1b3301964364a834091363 100644 --- a/MaterialLib/Adsorption/DensityNunez.h +++ b/MaterialLib/Adsorption/DensityNunez.h @@ -17,10 +17,10 @@ namespace Adsorption class DensityNunez : public AdsorptionReaction { public: - double getAdsorbateDensity(const double T_Ads) const; - double getAlphaT(const double T_Ads) const; - double characteristicCurve(const double A) const; - double dCharacteristicCurve(const double A) const; + double getAdsorbateDensity(const double T_Ads) const override; + double getAlphaT(const double T_Ads) const override; + double characteristicCurve(const double A) const override; + double dCharacteristicCurve(const double A) const override; }; } diff --git a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp index 34f87172b33f812de08aaa3c6b93175d86209902..629444347b749be44b194e9d089e8dbfa88d310c 100644 --- a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp +++ b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp @@ -39,15 +39,15 @@ static std::unique_ptr<FluidProperty> createLiquidDensity( config.checkConfigParameter("type", "LiquidDensity"); //! \ogs_file_param{material__fluid__density__LiquidDensity__beta} - const double beta = config.getConfigParameter<double>("beta"); + const auto beta = config.getConfigParameter<double>("beta"); //! \ogs_file_param{material__fluid__density__LiquidDensity__rho0} - const double rho0 = config.getConfigParameter<double>("rho0"); + const auto rho0 = config.getConfigParameter<double>("rho0"); //! \ogs_file_param{material__fluid__density__LiquidDensity__temperature0} - const double T0 = config.getConfigParameter<double>("temperature0"); + const auto T0 = config.getConfigParameter<double>("temperature0"); //! \ogs_file_param{material__fluid__density__LiquidDensity__p0} - const double p0 = config.getConfigParameter<double>("p0"); + const auto p0 = config.getConfigParameter<double>("p0"); //! \ogs_file_param{material__fluid__density__LiquidDensity__bulk_modulus} - const double E = config.getConfigParameter<double>("bulk_modulus"); + const auto E = config.getConfigParameter<double>("bulk_modulus"); return std::unique_ptr<FluidProperty>( new LiquidDensity(beta, rho0, T0, p0, E)); } @@ -64,11 +64,11 @@ static std::unique_ptr<FluidProperty> createLinearTemperatureDependentDensity( config.checkConfigParameter("type", "TemperatureDependent"); //! \ogs_file_param{material__fluid__density__TemperatureDependent__rho0} - const double rho0 = config.getConfigParameter<double>("rho0"); + const auto rho0 = config.getConfigParameter<double>("rho0"); //! \ogs_file_param{material__fluid__density__TemperatureDependent__temperature0} - const double T0 = config.getConfigParameter<double>("temperature0"); + const auto T0 = config.getConfigParameter<double>("temperature0"); //! \ogs_file_param{material__fluid__density__TemperatureDependent__beta} - const double beta = config.getConfigParameter<double>("beta"); + const auto beta = config.getConfigParameter<double>("beta"); return std::unique_ptr<FluidProperty>( new LinearTemperatureDependentDensity(rho0, T0, beta)); } diff --git a/MaterialLib/Fluid/FluidProperties/FluidProperties.h b/MaterialLib/Fluid/FluidProperties/FluidProperties.h index 72192805b6df0b28f265e86c2fadc4f444db51b3..339afb6ae7c6265f9d3dcebac1ef73c308db2d0d 100644 --- a/MaterialLib/Fluid/FluidProperties/FluidProperties.h +++ b/MaterialLib/Fluid/FluidProperties/FluidProperties.h @@ -40,7 +40,7 @@ const unsigned FluidPropertyTypeNumber = class FluidProperties { public: - typedef std::array<double, PropertyVariableNumber> ArrayType; + using ArrayType = std::array<double, PropertyVariableNumber>; FluidProperties( std::unique_ptr<MaterialLib::Fluid::FluidProperty>&& density, diff --git a/MaterialLib/Fluid/FluidProperty.h b/MaterialLib/Fluid/FluidProperty.h index 6ed6593373d92c060544f72a3b48cd7521268211..3633597714c9fcca4f0cee9938392d3a05e2bfb3 100644 --- a/MaterialLib/Fluid/FluidProperty.h +++ b/MaterialLib/Fluid/FluidProperty.h @@ -25,9 +25,9 @@ namespace Fluid class FluidProperty { public: - typedef std::array<double, PropertyVariableNumber> ArrayType; + using ArrayType = std::array<double, PropertyVariableNumber>; - virtual ~FluidProperty() {} + virtual ~FluidProperty() = default; /// Get model name. virtual std::string getName() const = 0; diff --git a/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp b/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp index 23c44a98bcfd0012244ca4e57f3b86e0b0b52193..c50768bf4bb2e68bd03694b0249be9265ab65439 100644 --- a/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp +++ b/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp @@ -37,13 +37,13 @@ static std::unique_ptr<FluidProperty> createLinearPressureDependentViscosity( config.checkConfigParameter("type", "LinearPressure"); //! \ogs_file_param{material__fluid__viscosity__LinearPressure__mu0} - const double mu0 = config.getConfigParameter<double>("mu0"); + const auto mu0 = config.getConfigParameter<double>("mu0"); //! \ogs_file_param{material__fluid__viscosity__LinearPressure__p0} - const double p0 = config.getConfigParameter<double>("p0"); + const auto p0 = config.getConfigParameter<double>("p0"); //! \ogs_file_param{material__fluid__viscosity__LinearPressure__gamma} - const double gamma = config.getConfigParameter<double>("gamma"); + const auto gamma = config.getConfigParameter<double>("gamma"); return std::unique_ptr<FluidProperty>( new LinearPressureDependentViscosity(mu0, p0, gamma)); @@ -61,13 +61,13 @@ static std::unique_ptr<FluidProperty> createTemperatureDependentViscosity( config.checkConfigParameter("type", "TemperatureDependent"); //! \ogs_file_param{material__fluid__viscosity__TemperatureDependent__mu0} - const double mu0 = config.getConfigParameter<double>("mu0"); + const auto mu0 = config.getConfigParameter<double>("mu0"); //! \ogs_file_param{material__fluid__viscosity__TemperatureDependent__tc} - const double Tc = config.getConfigParameter<double>("tc"); + const auto Tc = config.getConfigParameter<double>("tc"); //! \ogs_file_param{material__fluid__viscosity__TemperatureDependent__tv} - const double Tv = config.getConfigParameter<double>("tv"); + const auto Tv = config.getConfigParameter<double>("tv"); return std::unique_ptr<FluidProperty>( new TemperatureDependentViscosity(mu0, Tc, Tv)); @@ -87,11 +87,11 @@ std::unique_ptr<FluidProperty> createViscosityModel( //! \ogs_file_param{material__fluid__viscosity__Constant__value} config.getConfigParameter<double>("value"))); } - else if (type == "LinearPressure") + if (type == "LinearPressure") return createLinearPressureDependentViscosity(config); - else if (type == "TemperatureDependent") + if (type == "TemperatureDependent") return createTemperatureDependentViscosity(config); - else if (type == "Vogels") + if (type == "Vogels") { //! \ogs_file_param{material__fluid__viscosity__type} config.checkConfigParameter("type", "Vogels"); @@ -110,7 +110,7 @@ std::unique_ptr<FluidProperty> createViscosityModel( new VogelsLiquidDynamicViscosity<VogelsViscosityConstantsWater>( constants)); } - else if (fluid_type == "CO2") + if (fluid_type == "CO2") { //! \ogs_file_param{material__fluid__viscosity__Vogels__liquid_type} config.checkConfigParameter("liquid_type", "CO2"); @@ -119,7 +119,7 @@ std::unique_ptr<FluidProperty> createViscosityModel( new VogelsLiquidDynamicViscosity<VogelsViscosityConstantsCO2>( constants)); } - else if (fluid_type == "CH4") + if (fluid_type == "CH4") { //! \ogs_file_param{material__fluid__viscosity__Vogels__liquid_type} config.checkConfigParameter("liquid_type", "CH4"); @@ -128,28 +128,24 @@ std::unique_ptr<FluidProperty> createViscosityModel( new VogelsLiquidDynamicViscosity<VogelsViscosityConstantsCH4>( constants)); } - else - { - OGS_FATAL( - "The fluid type %s for Vogels model is unavailable.\n" - "The available fluid types are Water, CO2 and CH4\n", - fluid_type.data()); - } + + OGS_FATAL( + "The fluid type %s for Vogels model is unavailable.\n" + "The available fluid types are Water, CO2 and CH4\n", + fluid_type.data()); } - else if (type == "WaterViscosityIAPWS") + if (type == "WaterViscosityIAPWS") { //! \ogs_file_param{material__fluid__viscosity__type} config.checkConfigParameter("type", "WaterViscosityIAPWS"); return std::unique_ptr<FluidProperty>(new WaterViscosityIAPWS()); } - else - { - OGS_FATAL( - "The viscosity type %s is unavailable.\n" - "The available types are \n\tConstant, \n\tLinearPressure " - "\n\tTemperatureDependent, \n\tVogels\n", - type.data()); - } + + OGS_FATAL( + "The viscosity type %s is unavailable.\n" + "The available types are \n\tConstant, \n\tLinearPressure " + "\n\tTemperatureDependent, \n\tVogels\n", + type.data()); } } // end namespace diff --git a/MaterialLib/Fluid/Viscosity/VogelsLiquidDynamicViscosity.h b/MaterialLib/Fluid/Viscosity/VogelsLiquidDynamicViscosity.h index ed94b0fb825c6a06ddd7256f2a209104beb7d3a4..14865299bf62585777bfc0e765008713322d5895 100644 --- a/MaterialLib/Fluid/Viscosity/VogelsLiquidDynamicViscosity.h +++ b/MaterialLib/Fluid/Viscosity/VogelsLiquidDynamicViscosity.h @@ -13,10 +13,11 @@ #pragma once -#include <string> -#include <vector> #include <array> #include <cmath> +#include <string> +#include <utility> +#include <vector> #include "MaterialLib/Fluid/FluidProperty.h" @@ -37,8 +38,8 @@ public: * \param constants Constants of the fluid. * */ - explicit VogelsLiquidDynamicViscosity(const VogelsConstants& constants) - : _constants(constants) + explicit VogelsLiquidDynamicViscosity(VogelsConstants constants) + : _constants(std::move(constants)) { } diff --git a/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp b/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp index 065d84cc9587793d59e4cfe46ec377305e91d622..cdddd6b1ab2d4d8c5e0a36adb89e345a02d64b66 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 value : Hi) { - sum_val += (Hi[i] / barT_i); + sum_val += (value / barT_i); barT_i *= barT; } return sum_val; diff --git a/MaterialLib/FractureModels/FractureModelBase.h b/MaterialLib/FractureModels/FractureModelBase.h index f82f126f85041cf105458458b12626f0f7034226..80e211d1b91556feaa2c42d059257411a228f0d8 100644 --- a/MaterialLib/FractureModels/FractureModelBase.h +++ b/MaterialLib/FractureModels/FractureModelBase.h @@ -58,7 +58,7 @@ public: virtual std::unique_ptr<MaterialStateVariables> createMaterialStateVariables() = 0; - virtual ~FractureModelBase() {} + virtual ~FractureModelBase() = default; /** * Computation of the constitutive relation for specific material model. diff --git a/MaterialLib/FractureModels/LinearElasticIsotropic.h b/MaterialLib/FractureModels/LinearElasticIsotropic.h index 7c44ede3f584f2752ca600418adb7cd75af226f8..5ff80779689b1c3cae0a80aea8e42aaff48622e8 100644 --- a/MaterialLib/FractureModels/LinearElasticIsotropic.h +++ b/MaterialLib/FractureModels/LinearElasticIsotropic.h @@ -10,6 +10,7 @@ #pragma once #include <Eigen/Eigen> +#include <utility> #include "ProcessLib/Parameter/Parameter.h" @@ -42,7 +43,7 @@ public: struct MaterialStateVariables : public FractureModelBase<DisplacementDim>::MaterialStateVariables { - void pushBackState() {} + void pushBackState() override {} }; std::unique_ptr< @@ -55,9 +56,8 @@ public: } public: - explicit LinearElasticIsotropic( - MaterialProperties const& material_properties) - : _mp(material_properties) + explicit LinearElasticIsotropic(MaterialProperties material_properties) + : _mp(std::move(material_properties)) { } diff --git a/MaterialLib/FractureModels/MohrCoulomb.h b/MaterialLib/FractureModels/MohrCoulomb.h index a16744bd5acb38c6db4f5dbc4dd756868e487300..e2a8c1b2308bf2bb4dad636c6e9b3c235fb0cf79 100644 --- a/MaterialLib/FractureModels/MohrCoulomb.h +++ b/MaterialLib/FractureModels/MohrCoulomb.h @@ -10,6 +10,7 @@ #pragma once #include <Eigen/Eigen> +#include <utility> #include "ProcessLib/Parameter/Parameter.h" @@ -64,10 +65,8 @@ public: } public: - - explicit MohrCoulomb( - MaterialProperties const& material_properties) - : _mp(material_properties) + explicit MohrCoulomb(MaterialProperties material_properties) + : _mp(std::move(material_properties)) { } diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp index 1c2193b523f9101921ca83add6403d551b5f770e..0e4c98d1962f60f41a2863d787185cc2ac37b0a8 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp @@ -39,10 +39,10 @@ static std::unique_ptr<CapillaryPressureSaturation> createBrooksCorey( config.checkConfigParameter("type", "BrooksCorey"); //! \ogs_file_param{material__porous_medium__capillary_pressure__BrooksCorey__pd} - const double pd = config.getConfigParameter<double>("pd"); + const auto pd = config.getConfigParameter<double>("pd"); //! \ogs_file_param{material__porous_medium__capillary_pressure__BrooksCorey__sr} - const double Sr = config.getConfigParameter<double>("sr"); + const auto Sr = config.getConfigParameter<double>("sr"); double Sg_r = 0.0; //! \ogs_file_param{material__porous_medium__capillary_pressure__BrooksCorey__sg_r} @@ -55,10 +55,10 @@ static std::unique_ptr<CapillaryPressureSaturation> createBrooksCorey( Sg_r = *Sg_r_ptr; } //! \ogs_file_param{material__porous_medium__capillary_pressure__BrooksCorey__smax} - const double Smax = config.getConfigParameter<double>("smax"); + const auto Smax = config.getConfigParameter<double>("smax"); //! \ogs_file_param{material__porous_medium__capillary_pressure__BrooksCorey__m} - const double m = config.getConfigParameter<double>("m"); + const auto m = config.getConfigParameter<double>("m"); if (m < 1.0) // m >= 1 { OGS_FATAL( @@ -66,7 +66,7 @@ static std::unique_ptr<CapillaryPressureSaturation> createBrooksCorey( "saturation model, m, must not be smaller than 1"); } //! \ogs_file_param{material__porous_medium__capillary_pressure__BrooksCorey__pc_max} - const double Pc_max = config.getConfigParameter<double>("pc_max"); + const auto Pc_max = config.getConfigParameter<double>("pc_max"); return std::unique_ptr<CapillaryPressureSaturation>( new BrooksCoreyCapillaryPressureSaturation( @@ -85,10 +85,10 @@ static std::unique_ptr<CapillaryPressureSaturation> createVanGenuchten( config.checkConfigParameter("type", "vanGenuchten"); //! \ogs_file_param{material__porous_medium__capillary_pressure__vanGenuchten__pd} - const double pd = config.getConfigParameter<double>("pd"); + const auto pd = config.getConfigParameter<double>("pd"); //! \ogs_file_param{material__porous_medium__capillary_pressure__vanGenuchten__sr} - const double Sr = config.getConfigParameter<double>("sr"); + const auto Sr = config.getConfigParameter<double>("sr"); double Sg_r = 0.0; //! \ogs_file_param{material__porous_medium__capillary_pressure__vanGenuchten__sg_r} @@ -102,10 +102,10 @@ static std::unique_ptr<CapillaryPressureSaturation> createVanGenuchten( } //! \ogs_file_param{material__porous_medium__capillary_pressure__vanGenuchten__smax} - const double Smax = config.getConfigParameter<double>("smax"); + const auto Smax = config.getConfigParameter<double>("smax"); //! \ogs_file_param{material__porous_medium__capillary_pressure__vanGenuchten__m} - const double m = config.getConfigParameter<double>("m"); + const auto m = config.getConfigParameter<double>("m"); if (m < 0. || m > 1.0) { OGS_FATAL( @@ -113,7 +113,7 @@ static std::unique_ptr<CapillaryPressureSaturation> createVanGenuchten( "saturation model, m, must be in an interval of [0, 1]"); } //! \ogs_file_param{material__porous_medium__capillary_pressure__vanGenuchten__pc_max} - const double Pc_max = config.getConfigParameter<double>("pc_max"); + const auto Pc_max = config.getConfigParameter<double>("pc_max"); bool has_regularized = false; if (auto const has_regularized_conf = diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp index e4f43e1b3eaccf2324ca44540e1182c9928fda86..ffe7b4ed66623e85161a5e4065d15ac192a71e8f 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp @@ -46,13 +46,13 @@ std::unique_ptr<RelativePermeability> createWettingPhaseVanGenuchten( config.checkConfigParameter("type", "WettingPhaseVanGenuchten"); //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseVanGenuchten__sr} - const double Sr = config.getConfigParameter<double>("sr"); + const auto Sr = config.getConfigParameter<double>("sr"); //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseVanGenuchten__smax} - const double Smax = config.getConfigParameter<double>("smax"); + const auto Smax = config.getConfigParameter<double>("smax"); //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseVanGenuchten__m} - const double m = config.getConfigParameter<double>("m"); + const auto m = config.getConfigParameter<double>("m"); if (m < 0. || m > 1.0) { OGS_FATAL( @@ -60,7 +60,7 @@ std::unique_ptr<RelativePermeability> createWettingPhaseVanGenuchten( " permeability model, m, must be in an interval of [0, 1]"); } //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseVanGenuchten__krel_min} - const double krel_min = config.getConfigParameter<double>("krel_min"); + const auto krel_min = config.getConfigParameter<double>("krel_min"); return std::unique_ptr<RelativePermeability>( new WettingPhaseVanGenuchten(Sr, Smax, m, krel_min)); @@ -78,13 +78,13 @@ std::unique_ptr<RelativePermeability> createNonWettingPhaseVanGenuchten( config.checkConfigParameter("type", "NonWettingPhaseVanGenuchten"); //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseVanGenuchten__sr} - const double Sr = config.getConfigParameter<double>("sr"); + const auto Sr = config.getConfigParameter<double>("sr"); //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseVanGenuchten__smax} - const double Smax = config.getConfigParameter<double>("smax"); + const auto Smax = config.getConfigParameter<double>("smax"); //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseVanGenuchten__m} - const double m = config.getConfigParameter<double>("m"); + const auto m = config.getConfigParameter<double>("m"); if (m < 0. || m > 1.0) { OGS_FATAL( @@ -93,7 +93,7 @@ std::unique_ptr<RelativePermeability> createNonWettingPhaseVanGenuchten( } //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseVanGenuchten__krel_min} - const double krel_min = config.getConfigParameter<double>("krel_min"); + const auto krel_min = config.getConfigParameter<double>("krel_min"); return std::unique_ptr<RelativePermeability>( new NonWettingPhaseVanGenuchten(Sr, Smax, m, krel_min)); @@ -111,13 +111,13 @@ std::unique_ptr<RelativePermeability> createWettingPhaseBrooksCoreyOilGas( config.checkConfigParameter("type", "WettingPhaseBrooksCoreyOilGas"); //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseBrooksCoreyOilGas__sr} - const double Sr = config.getConfigParameter<double>("sr"); + const auto Sr = config.getConfigParameter<double>("sr"); //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseBrooksCoreyOilGas__smax} - const double Smax = config.getConfigParameter<double>("smax"); + const auto Smax = config.getConfigParameter<double>("smax"); //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseBrooksCoreyOilGas__m} - const double m = config.getConfigParameter<double>("m"); + const auto m = config.getConfigParameter<double>("m"); if (m < 1.0) // m >= 1 { OGS_FATAL( @@ -126,7 +126,7 @@ std::unique_ptr<RelativePermeability> createWettingPhaseBrooksCoreyOilGas( } //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseBrooksCoreyOilGas__krel_min} - const double krel_min = config.getConfigParameter<double>("krel_min"); + const auto krel_min = config.getConfigParameter<double>("krel_min"); return std::unique_ptr<RelativePermeability>( new WettingPhaseBrooksCoreyOilGas(Sr, Smax, m, krel_min)); @@ -144,13 +144,13 @@ std::unique_ptr<RelativePermeability> createNonWettingPhaseBrooksCoreyOilGas( config.checkConfigParameter("type", "NonWettingPhaseBrooksCoreyOilGas"); //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseBrooksCoreyOilGas__sr} - const double Sr = config.getConfigParameter<double>("sr"); + const auto Sr = config.getConfigParameter<double>("sr"); //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseBrooksCoreyOilGas__smax} - const double Smax = config.getConfigParameter<double>("smax"); + const auto Smax = config.getConfigParameter<double>("smax"); //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseBrooksCoreyOilGas__m} - const double m = config.getConfigParameter<double>("m"); + const auto m = config.getConfigParameter<double>("m"); if (m < 1.0) // m >= 1 { OGS_FATAL( @@ -159,7 +159,7 @@ std::unique_ptr<RelativePermeability> createNonWettingPhaseBrooksCoreyOilGas( } //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseBrooksCoreyOilGas__krel_min} - const double krel_min = config.getConfigParameter<double>("krel_min"); + const auto krel_min = config.getConfigParameter<double>("krel_min"); return std::unique_ptr<RelativePermeability>( new NonWettingPhaseBrooksCoreyOilGas(Sr, Smax, m, krel_min)); diff --git a/MaterialLib/SolidModels/CreateEhlers.h b/MaterialLib/SolidModels/CreateEhlers.h index 67709980a353a8d7405520d89a64b04406d84e22..bba68d8c13c81678275583d89f9a8703c525e1ed 100644 --- a/MaterialLib/SolidModels/CreateEhlers.h +++ b/MaterialLib/SolidModels/CreateEhlers.h @@ -26,13 +26,13 @@ inline NumLib::NewtonRaphsonSolverParameters createNewtonRaphsonSolverParameters(BaseLib::ConfigTree const& config) { DBUG("Create local nonlinear solver parameters."); - int const maximum_iterations = + auto const maximum_iterations = //! \ogs_file_param{material__solid__constitutive_relation__Ehlers__nonlinear_solver__maximum_iterations} config.getConfigParameter<int>("maximum_iterations"); DBUG("\tmaximum_iterations: %d.", maximum_iterations); - double const error_tolerance = + auto const error_tolerance = //! \ogs_file_param{material__solid__constitutive_relation__Ehlers__nonlinear_solver__error_tolerance} config.getConfigParameter<double>("error_tolerance"); diff --git a/MaterialLib/SolidModels/CreateLubby2.h b/MaterialLib/SolidModels/CreateLubby2.h index 49b0395d321d526d5a47274b63bfcabec98d3148..a9bc8d685af67b983c5e54b26d0b8d40620d4517 100644 --- a/MaterialLib/SolidModels/CreateLubby2.h +++ b/MaterialLib/SolidModels/CreateLubby2.h @@ -26,13 +26,13 @@ inline NumLib::NewtonRaphsonSolverParameters createNewtonRaphsonSolverParameters(BaseLib::ConfigTree const& config) { DBUG("Create local nonlinear solver parameters."); - int const maximum_iterations = + auto const maximum_iterations = //! \ogs_file_param{material__solid__constitutive_relation__Lubby2__nonlinear_solver__maximum_iterations} config.getConfigParameter<int>("maximum_iterations"); DBUG("\tmaximum_iterations: %d.", maximum_iterations); - double const error_tolerance = + auto const error_tolerance = //! \ogs_file_param{material__solid__constitutive_relation__Lubby2__nonlinear_solver__error_tolerance} config.getConfigParameter<double>("error_tolerance"); diff --git a/MaterialLib/SolidModels/Ehlers-impl.h b/MaterialLib/SolidModels/Ehlers-impl.h index a28ed14037f5e509da20d92d1be8729aa82be578..421f4154534039c76af00f41f98be0cc8122d966 100644 --- a/MaterialLib/SolidModels/Ehlers-impl.h +++ b/MaterialLib/SolidModels/Ehlers-impl.h @@ -441,7 +441,7 @@ void SolidEhlers<DisplacementDim>::updateDamage( { assert(dynamic_cast<MaterialStateVariables*>(&material_state_variables) != nullptr); - MaterialStateVariables& state = + auto& state = static_cast<MaterialStateVariables&>(material_state_variables); // Default case of the rate problem. Updated below if volumetric plastic @@ -546,7 +546,7 @@ bool SolidEhlers<DisplacementDim>::computeConstitutiveRelation( { assert(dynamic_cast<MaterialStateVariables*>(&material_state_variables) != nullptr); - MaterialStateVariables& _state = + auto& _state = static_cast<MaterialStateVariables&>(material_state_variables); _state.setInitialConditions(); diff --git a/MaterialLib/SolidModels/Ehlers.h b/MaterialLib/SolidModels/Ehlers.h index 3cac0f7dc6720b69cbfe6d22ca8377163e7807d1..9b5d9145312e67d0c934dec6d03abae66aedeaf2 100644 --- a/MaterialLib/SolidModels/Ehlers.h +++ b/MaterialLib/SolidModels/Ehlers.h @@ -27,6 +27,7 @@ #include <Eigen/Dense> #include <logog/include/logog.hpp> +#include <utility> #include "BaseLib/Error.h" #include "NumLib/NewtonRaphson.h" @@ -210,12 +211,11 @@ public: public: explicit SolidEhlers( - NumLib::NewtonRaphsonSolverParameters const& - nonlinear_solver_parameters, - MaterialProperties const& material_properties, + NumLib::NewtonRaphsonSolverParameters nonlinear_solver_parameters, + MaterialProperties material_properties, std::unique_ptr<EhlersDamageProperties>&& damage_properties) - : _nonlinear_solver_parameters(nonlinear_solver_parameters), - _mp(material_properties), + : _nonlinear_solver_parameters(std::move(nonlinear_solver_parameters)), + _mp(std::move(material_properties)), _damage_properties(std::move(damage_properties)) { } diff --git a/MaterialLib/SolidModels/LinearElasticIsotropic.h b/MaterialLib/SolidModels/LinearElasticIsotropic.h index 3342eb0b4387e186f999df9c3048c7155b250020..7bd96a7f28d470f1f5abcfea3c5a0cc237e3ab6c 100644 --- a/MaterialLib/SolidModels/LinearElasticIsotropic.h +++ b/MaterialLib/SolidModels/LinearElasticIsotropic.h @@ -9,6 +9,8 @@ #pragma once +#include <utility> + #include "MechanicsBase.h" namespace MaterialLib @@ -54,7 +56,7 @@ public: struct MaterialStateVariables : public MechanicsBase<DisplacementDim>::MaterialStateVariables { - void pushBackState() {} + void pushBackState() override {} }; std::unique_ptr< @@ -72,9 +74,8 @@ public: using KelvinVector = ProcessLib::KelvinVectorType<DisplacementDim>; using KelvinMatrix = ProcessLib::KelvinMatrixType<DisplacementDim>; - explicit LinearElasticIsotropic( - MaterialProperties const& material_properties) - : _mp(material_properties) + explicit LinearElasticIsotropic(MaterialProperties material_properties) + : _mp(std::move(material_properties)) { } diff --git a/MaterialLib/SolidModels/Lubby2-impl.h b/MaterialLib/SolidModels/Lubby2-impl.h index bd060a56d42a469f69fc1562fe2f3486699dde33..01106fdd31e42586734cecf68880745ab42e8a47 100644 --- a/MaterialLib/SolidModels/Lubby2-impl.h +++ b/MaterialLib/SolidModels/Lubby2-impl.h @@ -32,7 +32,7 @@ bool Lubby2<DisplacementDim>::computeConstitutiveRelation( assert(dynamic_cast<MaterialStateVariables*>(&material_state_variables) != nullptr); - MaterialStateVariables& state = + auto& state = static_cast<MaterialStateVariables&>(material_state_variables); state.setInitialConditions(); diff --git a/MaterialLib/SolidModels/Lubby2.h b/MaterialLib/SolidModels/Lubby2.h index a53392f25fbd4f9ab17fa2a309493347623efd4e..6ec6d0cdb915e33221aad7145126f62e00e422db 100644 --- a/MaterialLib/SolidModels/Lubby2.h +++ b/MaterialLib/SolidModels/Lubby2.h @@ -10,6 +10,7 @@ #pragma once #include <logog/include/logog.hpp> +#include <utility> #include "BaseLib/Error.h" #include "NumLib/NewtonRaphson.h" @@ -166,10 +167,10 @@ public: Eigen::RowMajor>; public: - explicit Lubby2(NumLib::NewtonRaphsonSolverParameters const& - nonlinear_solver_parameters, - Lubby2MaterialProperties& material_properties) - : _nonlinear_solver_parameters(nonlinear_solver_parameters), + explicit Lubby2( + NumLib::NewtonRaphsonSolverParameters nonlinear_solver_parameters, + Lubby2MaterialProperties& material_properties) + : _nonlinear_solver_parameters(std::move(nonlinear_solver_parameters)), _mp(material_properties) { } diff --git a/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp b/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp index 15bc7631967cf691acf56496f28857665e72b924..0b4c981f9268c0f6e185d46f4a348fbba6ae62f7 100644 --- a/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp +++ b/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp @@ -9,6 +9,7 @@ #include "TwoPhaseFlowWithPPMaterialProperties.h" #include <logog/include/logog.hpp> +#include <utility> #include "BaseLib/reorderVector.h" #include "MaterialLib/Fluid/FluidProperty.h" #include "MaterialLib/PorousMedium/Porosity/Porosity.h" @@ -46,7 +47,7 @@ TwoPhaseFlowWithPPMaterialProperties::TwoPhaseFlowWithPPMaterialProperties( _gas_density(std::move(gas_density)), _gas_viscosity(std::move(gas_viscosity)), _material_ids(material_ids), - _intrinsic_permeability_models(intrinsic_permeability_models), + _intrinsic_permeability_models(std::move(intrinsic_permeability_models)), _porosity_models(std::move(porosity_models)), _storage_models(std::move(storage_models)) { diff --git a/MathLib/GeometricBasics.h b/MathLib/GeometricBasics.h index 52d66619b6df356a01ac5dca7bb0bf684ddfef2a..e153d029f82fb659d43ef635410977cb7523940f 100644 --- a/MathLib/GeometricBasics.h +++ b/MathLib/GeometricBasics.h @@ -17,7 +17,7 @@ namespace MathLib { template <typename T, std::size_t DIM> class TemplatePoint; -typedef MathLib::TemplatePoint<double,3> Point3d; +using Point3d = MathLib::TemplatePoint<double, 3>; enum TriangleTest { diff --git a/MathLib/LinAlg/Dense/DenseMatrix-impl.h b/MathLib/LinAlg/Dense/DenseMatrix-impl.h index e143d78ecc2cf38d76ad8909b2d3f87dcae48e36..71696faae260b88d7a8228eb01b1edf850137774 100644 --- a/MathLib/LinAlg/Dense/DenseMatrix-impl.h +++ b/MathLib/LinAlg/Dense/DenseMatrix-impl.h @@ -120,7 +120,7 @@ FP_TYPE* DenseMatrix<FP_TYPE, IDX_TYPE>::operator* (FP_TYPE* const& x) const template<typename FP_TYPE, typename IDX_TYPE> FP_TYPE* DenseMatrix<FP_TYPE, IDX_TYPE>::operator* (FP_TYPE const* const& x) const { - FP_TYPE *y(new FP_TYPE[_n_rows]); + auto* y(new FP_TYPE[_n_rows]); for (IDX_TYPE i(0); i < _n_rows; i++) { y[i] = 0.0; for (IDX_TYPE j(0); j < _n_cols; j++) { diff --git a/MathLib/LinAlg/Dense/DenseMatrix.h b/MathLib/LinAlg/Dense/DenseMatrix.h index dd63ba7fdeebae5f820517332e75dce8611d22b9..3bd5a543259faf804e582380d4b130782fa0584c 100644 --- a/MathLib/LinAlg/Dense/DenseMatrix.h +++ b/MathLib/LinAlg/Dense/DenseMatrix.h @@ -24,8 +24,8 @@ namespace MathLib { template <typename FP_TYPE, typename IDX_TYPE = std::size_t> class DenseMatrix { public: - typedef FP_TYPE FP_T; - typedef IDX_TYPE IDX_T; + using FP_T = FP_TYPE; + using IDX_T = IDX_TYPE; public: /// Dense square matrix constructor. diff --git a/MathLib/LinAlg/Eigen/EigenVector.h b/MathLib/LinAlg/Eigen/EigenVector.h index d5c56e1f606ff7dc5260aab9985e3168b82cb07d..8266cdba9e3b160ea77beb9790f7b1bef31a6830 100644 --- a/MathLib/LinAlg/Eigen/EigenVector.h +++ b/MathLib/LinAlg/Eigen/EigenVector.h @@ -33,14 +33,14 @@ public: using IndexType = Eigen::SparseMatrix<double>::Index; // TODO: preliminary - EigenVector() {} + EigenVector() = default; /// Constructor for initialization of the number of rows /// @param length number of rows explicit EigenVector(std::size_t length) : _vec(length) {} /// copy constructor - EigenVector(EigenVector const &src) : _vec(src._vec) {} + EigenVector(EigenVector const& src) = default; /// return a vector length std::size_t size() const { return _vec.size(); } diff --git a/MathLib/LinAlg/RowColumnIndices.h b/MathLib/LinAlg/RowColumnIndices.h index f75587cf00aca801978fd01e8532f289983a19b1..3c9ccf734304c113a79464ff51ae762891bef084 100644 --- a/MathLib/LinAlg/RowColumnIndices.h +++ b/MathLib/LinAlg/RowColumnIndices.h @@ -17,7 +17,7 @@ namespace MathLib template <typename IDX_TYPE> struct RowColumnIndices { - typedef typename std::vector<IDX_TYPE> LineIndex; + using LineIndex = typename std::vector<IDX_TYPE>; RowColumnIndices(LineIndex const& rows_, LineIndex const& columns_) : rows(rows_), columns(columns_) { } diff --git a/MathLib/LinAlg/Solvers/GaussAlgorithm.h b/MathLib/LinAlg/Solvers/GaussAlgorithm.h index dbe67099badcee8ebffdd1e8f88e659bdaf8f34e..068b7494d7d786adcf8ca8c849ef425d26b0e3c1 100644 --- a/MathLib/LinAlg/Solvers/GaussAlgorithm.h +++ b/MathLib/LinAlg/Solvers/GaussAlgorithm.h @@ -35,8 +35,8 @@ template <typename MAT_T, typename VEC_T = typename MAT_T::FP_T*> class GaussAlgorithm { public: - typedef typename MAT_T::FP_T FP_T; - typedef typename MAT_T::IDX_T IDX_T; + using FP_T = typename MAT_T::FP_T; + using IDX_T = typename MAT_T::IDX_T; public: /** diff --git a/MathLib/LinAlg/Solvers/TriangularSolve-impl.h b/MathLib/LinAlg/Solvers/TriangularSolve-impl.h index 62867221e1830152d86f7c4e83f57ac51978f283..0836ce16e65e214ce9dbb86f566359f230795d5d 100644 --- a/MathLib/LinAlg/Solvers/TriangularSolve-impl.h +++ b/MathLib/LinAlg/Solvers/TriangularSolve-impl.h @@ -17,7 +17,7 @@ namespace MathLib { template <typename FP_T, typename VEC_T> void forwardSolve (const DenseMatrix <FP_T> &L, VEC_T& b) { - typedef typename DenseMatrix<FP_T>::IDX_T IDX_T; + using IDX_T = typename DenseMatrix<double>::IDX_T; IDX_T m (L.getNumberOfRows()); FP_T t; @@ -34,7 +34,7 @@ template <typename FP_T, typename VEC_T> void backwardSolve (const DenseMatrix <FP_T> &mat, VEC_T& b) { FP_T t; - typedef typename DenseMatrix<FP_T>::IDX_T IDX_T; + using IDX_T = typename DenseMatrix<double>::IDX_T; IDX_T m (mat.getNumberOfRows()), n(mat.getNumberOfColumns()); for (int r=m-1; r>=0; r--) { t = 0.0; @@ -48,7 +48,7 @@ void backwardSolve (const DenseMatrix <FP_T> &mat, VEC_T& b) template <typename FP_T, typename VEC_T> void backwardSolve ( DenseMatrix<FP_T> const& mat, VEC_T& x, VEC_T const& b) { - typedef typename DenseMatrix<FP_T>::IDX_T IDX_T; + using IDX_T = typename DenseMatrix<FP_T>::IDX_T; IDX_T n_cols (mat.getNumberOfColumns()); for (int r = (n_cols - 1); r >= 0; r--) { FP_T t = 0.0; diff --git a/MathLib/LinearFunction.h b/MathLib/LinearFunction.h index 1d5b593fc2096bae5109e7eded4d8b0590443e60..be6a25d58bced56e19472b09ccb5aa2ab1b417c1 100644 --- a/MathLib/LinearFunction.h +++ b/MathLib/LinearFunction.h @@ -14,6 +14,7 @@ #include <array> #include <numeric> +#include <utility> namespace MathLib { @@ -36,8 +37,8 @@ public: * \param coefficients an array of coefficients of a linear function. * The size of the coefficient array should equal to the number of variables + 1 */ - explicit LinearFunction(const std::array<T_TYPE, N_VARS+1> &coefficients) - : _coefficients(coefficients) + explicit LinearFunction(std::array<T_TYPE, N_VARS + 1> coefficients) + : _coefficients(std::move(coefficients)) {} /** diff --git a/MathLib/Point3d.h b/MathLib/Point3d.h index f8a4cda77e258304c1d361cc067c28f10b08ecff..9fea8f5fc530b06b4e93f96a1eb24a0507f0f779 100644 --- a/MathLib/Point3d.h +++ b/MathLib/Point3d.h @@ -20,7 +20,7 @@ namespace MathLib { -typedef MathLib::TemplatePoint<double,3> Point3d; +using Point3d = MathLib::TemplatePoint<double, 3>; extern const Point3d ORIGIN; /** diff --git a/MathLib/TemplatePoint.h b/MathLib/TemplatePoint.h index 92bc97d107f69c413a7b107536bd17fa14ed226c..7dd7b457858de5a67835b752f926d48a62021b07 100644 --- a/MathLib/TemplatePoint.h +++ b/MathLib/TemplatePoint.h @@ -15,12 +15,13 @@ #pragma once // STL -#include <array> #include <algorithm> +#include <array> +#include <cassert> #include <cmath> -#include <iterator> #include <istream> -#include <cassert> +#include <iterator> +#include <utility> namespace MathLib { @@ -33,7 +34,7 @@ namespace MathLib template <typename T, std::size_t DIM = 3> class TemplatePoint { public: - typedef T FP_T; + using FP_T = T; /** default constructor with zero coordinates */ TemplatePoint(); @@ -42,7 +43,7 @@ public: * * @param x std::array containing the coordinates of the point */ - explicit TemplatePoint(std::array<T,DIM> const& x); + explicit TemplatePoint(std::array<T, DIM> x); /** virtual destructor */ virtual ~TemplatePoint() = default; @@ -100,8 +101,7 @@ TemplatePoint<T,DIM>::TemplatePoint() : {} template <typename T, std::size_t DIM> -TemplatePoint<T,DIM>::TemplatePoint(std::array<T,DIM> const& x) : - _x(x) +TemplatePoint<T, DIM>::TemplatePoint(std::array<T, DIM> x) : _x(std::move(x)) {} /** Equality of TemplatePoint's up to an epsilon. diff --git a/MathLib/TemplateWeightedPoint.h b/MathLib/TemplateWeightedPoint.h index 318566c198041f6e651aa803b8bd1eba28f94d5d..05bf9ca0fdcbde68e911076399a783447e82f17f 100644 --- a/MathLib/TemplateWeightedPoint.h +++ b/MathLib/TemplateWeightedPoint.h @@ -34,8 +34,8 @@ private: W_T const _weight; }; -typedef TemplateWeightedPoint<double, double, 1> WeightedPoint1D; -typedef TemplateWeightedPoint<double, double, 2> WeightedPoint2D; -typedef TemplateWeightedPoint<double, double, 3> WeightedPoint3D; +using WeightedPoint1D = TemplateWeightedPoint<double, double, 1>; +using WeightedPoint2D = TemplateWeightedPoint<double, double, 2>; +using WeightedPoint3D = TemplateWeightedPoint<double, double, 3>; } // end namespace MathLib diff --git a/MathLib/Vector3.h b/MathLib/Vector3.h index e880b55a6a611471f916a481ef46384b4ba98e63..f5361c6f9e574d5a98496ea3b02dc317bf3f6697 100644 --- a/MathLib/Vector3.h +++ b/MathLib/Vector3.h @@ -185,7 +185,7 @@ template <typename T1> TemplateVector3<T1> operator*( return v * s; } -typedef TemplateVector3<double> Vector3; +using Vector3 = TemplateVector3<double>; /// Calculates the scalar triple (u x v) . w double scalarTriple(MathLib::Vector3 const& u, MathLib::Vector3 const& v, diff --git a/MeshGeoToolsLib/AppendLinesAlongPolyline.h b/MeshGeoToolsLib/AppendLinesAlongPolyline.h index 0940c886af3ae0e0fd550aea07dd82d038116062..078ecb0ce961b441f69897a9f49866a5040911be 100644 --- a/MeshGeoToolsLib/AppendLinesAlongPolyline.h +++ b/MeshGeoToolsLib/AppendLinesAlongPolyline.h @@ -14,7 +14,7 @@ namespace GeoLib { class Polyline; template <typename T> class TemplateVec; -typedef TemplateVec<Polyline> PolylineVec; +using PolylineVec = TemplateVec<GeoLib::Polyline>; } namespace MeshLib diff --git a/MeshGeoToolsLib/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp index 3a1f3740e046b5875f4fd91fdc9e58853eb6a019..98bd173a24c68a98863e0309131dec449e295162 100644 --- a/MeshGeoToolsLib/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -299,9 +299,9 @@ static std::vector<GeoLib::LineSegment> createSubSegmentsForElement( // added. if (MathLib::sqrDist(beg_pnt, intersections[0]) > std::numeric_limits<double>::epsilon()) - sub_segments.emplace_back(GeoLib::LineSegment{ - new GeoLib::Point{beg_pnt, 0}, - new GeoLib::Point{intersections[0], 0}, true}); + sub_segments.emplace_back(new GeoLib::Point{beg_pnt, 0}, + new GeoLib::Point{intersections[0], 0}, + true); } if (intersections.size() == 1 && elem == end_elem) @@ -311,9 +311,8 @@ static std::vector<GeoLib::LineSegment> createSubSegmentsForElement( // added. if (MathLib::sqrDist(end_pnt, intersections[0]) > std::numeric_limits<double>::epsilon()) - sub_segments.emplace_back( - GeoLib::LineSegment{new GeoLib::Point{intersections[0], 0}, - new GeoLib::Point{end_pnt, 0}, true}); + sub_segments.emplace_back(new GeoLib::Point{intersections[0], 0}, + new GeoLib::Point{end_pnt, 0}, true); } if (intersections.size() == 1 && (elem != beg_elem && elem != end_elem)) @@ -326,9 +325,8 @@ static std::vector<GeoLib::LineSegment> createSubSegmentsForElement( // create sub segment for the current element if (intersections.size() == 2) { - sub_segments.emplace_back( - GeoLib::LineSegment{new GeoLib::Point{intersections[0], 0}, - new GeoLib::Point{intersections[1], 0}, true}); + sub_segments.emplace_back(new GeoLib::Point{intersections[0], 0}, + new GeoLib::Point{intersections[1], 0}, true); } return sub_segments; } @@ -384,8 +382,7 @@ static std::vector<GeoLib::LineSegment> mapLineSegment( MathLib::sqrDist(beg_pnt, min_dist_segment->getEndPoint()) ? new GeoLib::Point{min_dist_segment->getBeginPoint()} : new GeoLib::Point{min_dist_segment->getEndPoint()}}; - sub_segments.emplace_back( - GeoLib::LineSegment{new GeoLib::Point{beg_pnt, 0}, pnt, true}); + sub_segments.emplace_back(new GeoLib::Point{beg_pnt, 0}, pnt, true); } // sort all sub segments for the given segment (beg_pnt, end_pnt) GeoLib::sortSegments(beg_pnt, sub_segments); @@ -562,9 +559,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 1cd0320c2939815bb44e76245f4068a9acf1bb5f..261cc63951b366a293cfc8f7571875b0b4f8f55e 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 (std::vector<MeshLib::Element*>::const_iterator 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/ElementCoordinatesMappingLocal.h b/MeshLib/ElementCoordinatesMappingLocal.h index 3185b911f3c8b273952d4cb5fe4b080719460f67..ff4e6c68ddab58f8e7b8615ebfd2abddb838dd17 100644 --- a/MeshLib/ElementCoordinatesMappingLocal.h +++ b/MeshLib/ElementCoordinatesMappingLocal.h @@ -19,7 +19,7 @@ namespace MeshLib namespace MeshLib { -typedef Eigen::Matrix<double, 3u, 3u, Eigen::RowMajor> RotationMatrix; +using RotationMatrix = Eigen::Matrix<double, 3u, 3u, Eigen::RowMajor>; /** * This class maps node coordinates on intrinsic coordinates of the given element. diff --git a/MeshLib/Elements/EdgeReturn.cpp b/MeshLib/Elements/EdgeReturn.cpp index 3066ce056ef23177316b30fc22dcb6b66bda4b94..1e740b17a230e79dbc1780eba73d7008d91d74c0 100644 --- a/MeshLib/Elements/EdgeReturn.cpp +++ b/MeshLib/Elements/EdgeReturn.cpp @@ -22,7 +22,7 @@ const Element* LinearEdgeReturn::getEdge(const Element* e, unsigned i) { if (i < e->getNumberOfEdges()) { - Node** nodes = new Node*[2]; + auto** nodes = new Node*[2]; nodes[0] = const_cast<Node*>(e->getEdgeNode(i,0)); nodes[1] = const_cast<Node*>(e->getEdgeNode(i,1)); return new Line(nodes); @@ -35,7 +35,7 @@ const Element* QuadraticEdgeReturn::getEdge(const Element* e, unsigned i) { if (i < e->getNumberOfEdges()) { - Node** nodes = new Node*[3]; + auto** nodes = new Node*[3]; nodes[0] = const_cast<Node*>(e->getEdgeNode(i,0)); nodes[1] = const_cast<Node*>(e->getEdgeNode(i,1)); nodes[2] = const_cast<Node*>(e->getEdgeNode(i,2)); diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index 1aefc52267a3e25aa976ce754b0cb220a7ead717..3c39f55ff9c65680e196622a69a67497ec5ee16a 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -62,7 +62,7 @@ public: * @param i local index of node, at most the number of nodes of the * element that you can obtain with Element::getNumberOfBaseNodes() * @return a pointer to the appropriate (and constant, i.e. not - * modifiable by the user) instance of class Node or a NULL pointer + * modifiable by the user) instance of class Node or a nullptr * @sa Element::getNodeIndex() */ const Node* getNode(unsigned i) const; diff --git a/MeshLib/Elements/Hex.h b/MeshLib/Elements/Hex.h index 9bb14dc6ab0d2bba0a5975b231a6feae4ab3cb73..91fa5997977e12b173b94228e3fa5243b09e4d24 100644 --- a/MeshLib/Elements/Hex.h +++ b/MeshLib/Elements/Hex.h @@ -22,6 +22,6 @@ extern template class MeshLib::TemplateElement<MeshLib::HexRule20>; extern template class MeshLib::TemplateElement<MeshLib::HexRule8>; namespace MeshLib { -typedef TemplateElement<HexRule8> Hex; -typedef TemplateElement<HexRule20> Hex20; +using Hex = TemplateElement<MeshLib::HexRule8>; +using Hex20 = TemplateElement<MeshLib::HexRule20>; } diff --git a/MeshLib/Elements/HexRule20.h b/MeshLib/Elements/HexRule20.h index efc53b437e4fedb6a9588ea20c4e1fe43982dd99..6d8f19b561f95fbc230d8de3499b87a19308919d 100644 --- a/MeshLib/Elements/HexRule20.h +++ b/MeshLib/Elements/HexRule20.h @@ -58,7 +58,7 @@ public: static const unsigned edge_nodes[12][3]; /// Returns the i-th edge of the element. - typedef QuadraticEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::QuadraticEdgeReturn; /// Returns the i-th face of the element. static const Element* getFace(const Element* e, unsigned i); diff --git a/MeshLib/Elements/HexRule8.h b/MeshLib/Elements/HexRule8.h index b1de7ac555680cabe440fbf3dd7460e8333e0026..0aba7560175c9798ef02dc572dae4190d71bae39 100644 --- a/MeshLib/Elements/HexRule8.h +++ b/MeshLib/Elements/HexRule8.h @@ -73,7 +73,7 @@ public: static const unsigned edge_nodes[12][2]; /// Returns the i-th edge of the element. - typedef LinearEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::LinearEdgeReturn; /// Returns the i-th face of the element. static const Element* getFace(const Element* e, unsigned i); diff --git a/MeshLib/Elements/Line.h b/MeshLib/Elements/Line.h index c4ef9440fa22d68597eeb3336a6f6ff0c1194340..f9e7892305efbb4d129eeb83eac81aeb774ae8fe 100644 --- a/MeshLib/Elements/Line.h +++ b/MeshLib/Elements/Line.h @@ -22,8 +22,6 @@ extern template class MeshLib::TemplateElement<MeshLib::LineRule2>; extern template class MeshLib::TemplateElement<MeshLib::LineRule3>; namespace MeshLib { - -typedef TemplateElement<LineRule2> Line; -typedef TemplateElement<LineRule3> Line3; - +using Line = TemplateElement<MeshLib::LineRule2>; +using Line3 = TemplateElement<MeshLib::LineRule3>; } diff --git a/MeshLib/Elements/LineRule2.h b/MeshLib/Elements/LineRule2.h index 52b6b494ede8a48d7e85b74ab84e18d42615b372..9f0fe8b5f25056e8cff737c64f1ce85ee41efa78 100644 --- a/MeshLib/Elements/LineRule2.h +++ b/MeshLib/Elements/LineRule2.h @@ -45,7 +45,7 @@ public: static const unsigned edge_nodes[1][2]; /// Edge rule - typedef LinearEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::LinearEdgeReturn; /** * \copydoc MeshLib::Element::isPntInElement() diff --git a/MeshLib/Elements/LineRule3.h b/MeshLib/Elements/LineRule3.h index 8489a8167faaf4497c1cc34e98a7fc7cec48a8fc..e4c4e9d381e2c38692c2cfe4e784bac8b205c996 100644 --- a/MeshLib/Elements/LineRule3.h +++ b/MeshLib/Elements/LineRule3.h @@ -31,7 +31,7 @@ public: static const CellType cell_type = CellType::LINE3; /// Edge rule - typedef QuadraticEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::QuadraticEdgeReturn; }; /* class */ } /* namespace */ diff --git a/MeshLib/Elements/PointRule1.h b/MeshLib/Elements/PointRule1.h index 59f89ec3e27bc31707686a8ee3cdc81da3872e46..bb1d368b4b2ab84f7dfa0d1d0fe1e24da7af3f5d 100644 --- a/MeshLib/Elements/PointRule1.h +++ b/MeshLib/Elements/PointRule1.h @@ -40,7 +40,7 @@ public: static const unsigned edge_nodes[1][1]; /// Edge rule - typedef NoEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::NoEdgeReturn; /// \copydoc MeshLib::Element::isPntInElement() /// diff --git a/MeshLib/Elements/Prism.h b/MeshLib/Elements/Prism.h index 7176cfd79970c42b1d276295aae22067a24b8fa5..f9324becb6f9180a6848ba4502718f09624ec4d9 100644 --- a/MeshLib/Elements/Prism.h +++ b/MeshLib/Elements/Prism.h @@ -22,8 +22,6 @@ extern template class MeshLib::TemplateElement<MeshLib::PrismRule15>; extern template class MeshLib::TemplateElement<MeshLib::PrismRule6>; namespace MeshLib { - -typedef TemplateElement<PrismRule6> Prism; -typedef TemplateElement<PrismRule15> Prism15; - +using Prism = TemplateElement<MeshLib::PrismRule6>; +using Prism15 = TemplateElement<MeshLib::PrismRule15>; } diff --git a/MeshLib/Elements/PrismRule15.cpp b/MeshLib/Elements/PrismRule15.cpp index 7b0ba0e472a4c428eea7db750908099b67fa84c7..edc1ac1eb18e9a0c0b09a47569f5cce58b2c5626 100644 --- a/MeshLib/Elements/PrismRule15.cpp +++ b/MeshLib/Elements/PrismRule15.cpp @@ -46,7 +46,7 @@ const Element* PrismRule15::getFace(const Element* e, unsigned i) if (i < n_faces) { unsigned nFaceNodes(PrismRule15::n_face_nodes[i]); - Node** nodes = new Node*[nFaceNodes]; + auto** nodes = new Node*[nFaceNodes]; for (unsigned j=0; j<nFaceNodes; j++) nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); diff --git a/MeshLib/Elements/PrismRule15.h b/MeshLib/Elements/PrismRule15.h index 4f6bb721b124e49f20f79020a0c5174c5a843c03..a8eb9561fe85fc4cc179199d3e90f1dcf6ef6c6d 100644 --- a/MeshLib/Elements/PrismRule15.h +++ b/MeshLib/Elements/PrismRule15.h @@ -59,7 +59,7 @@ public: static const unsigned n_face_nodes[5]; /// Returns the i-th edge of the element. - typedef QuadraticEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::QuadraticEdgeReturn; /// Returns the i-th face of the element. static const Element* getFace(const Element* e, unsigned i); diff --git a/MeshLib/Elements/PrismRule6.cpp b/MeshLib/Elements/PrismRule6.cpp index 844b651754e70ae9cfb58c6dd8f396520ac11477..3c4327add346a6c546459a1da35ddbbbb45c785d 100644 --- a/MeshLib/Elements/PrismRule6.cpp +++ b/MeshLib/Elements/PrismRule6.cpp @@ -48,7 +48,7 @@ const Element* PrismRule6::getFace(const Element* e, unsigned i) if (i < n_faces) { unsigned nFaceNodes(PrismRule6::n_face_nodes[i]); - Node** nodes = new Node*[nFaceNodes]; + auto** nodes = new Node*[nFaceNodes]; for (unsigned j=0; j<nFaceNodes; j++) nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); @@ -102,7 +102,7 @@ ElementErrorCode PrismRule6::validate(const Element* e) for (unsigned i=1; i<4; ++i) { - const MeshLib::Quad* quad (dynamic_cast<const MeshLib::Quad*>(e->getFace(i))); + const auto* quad(dynamic_cast<const MeshLib::Quad*>(e->getFace(i))); if (quad) error_code |= quad->validate(); else diff --git a/MeshLib/Elements/PrismRule6.h b/MeshLib/Elements/PrismRule6.h index aecd28b2159325d23fcd2332d2395edf55ce6830..0d3d1319de5cd47c8ae10d060f7c778ecab08964 100644 --- a/MeshLib/Elements/PrismRule6.h +++ b/MeshLib/Elements/PrismRule6.h @@ -74,7 +74,7 @@ public: static const unsigned n_face_nodes[5]; /// Returns the i-th edge of the element. - typedef LinearEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::LinearEdgeReturn; /// Returns the i-th face of the element. static const Element* getFace(const Element* e, unsigned i); diff --git a/MeshLib/Elements/Pyramid.h b/MeshLib/Elements/Pyramid.h index 3ae5204c4cc90a4f6b88269da8280ed484b68ac4..4bfc6387e60508e66abbe5994c376b5b1e4a12d8 100644 --- a/MeshLib/Elements/Pyramid.h +++ b/MeshLib/Elements/Pyramid.h @@ -22,8 +22,6 @@ extern template class MeshLib::TemplateElement<MeshLib::PyramidRule13>; extern template class MeshLib::TemplateElement<MeshLib::PyramidRule5>; namespace MeshLib { - -typedef TemplateElement<PyramidRule5> Pyramid; -typedef TemplateElement<PyramidRule13> Pyramid13; - +using Pyramid = TemplateElement<MeshLib::PyramidRule5>; +using Pyramid13 = TemplateElement<MeshLib::PyramidRule13>; } diff --git a/MeshLib/Elements/PyramidRule13.cpp b/MeshLib/Elements/PyramidRule13.cpp index ddd172792dd4a9f3397d0a2883679bf9915147b0..1960f12ad756dc119bad0fdecc866af14a06d4f8 100644 --- a/MeshLib/Elements/PyramidRule13.cpp +++ b/MeshLib/Elements/PyramidRule13.cpp @@ -45,7 +45,7 @@ const Element* PyramidRule13::getFace(const Element* e, unsigned i) if (i<e->getNumberOfFaces()) { unsigned nFaceNodes(PyramidRule13::n_face_nodes[i]); - Node** nodes = new Node*[nFaceNodes]; + auto** nodes = new Node*[nFaceNodes]; for (unsigned j=0; j<nFaceNodes; j++) nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); diff --git a/MeshLib/Elements/PyramidRule13.h b/MeshLib/Elements/PyramidRule13.h index 987a6fc17e7dcce0c6f4ed95dcbeb78090c4cee6..b0fee0b785450bf6c712cd48ff8a5a1f14a41c3f 100644 --- a/MeshLib/Elements/PyramidRule13.h +++ b/MeshLib/Elements/PyramidRule13.h @@ -58,7 +58,7 @@ public: static const unsigned n_face_nodes[5]; /// Returns the i-th edge of the element. - typedef QuadraticEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::QuadraticEdgeReturn; /// Returns the i-th face of the element. static const Element* getFace(const Element* e, unsigned i); diff --git a/MeshLib/Elements/PyramidRule5.cpp b/MeshLib/Elements/PyramidRule5.cpp index 28e35a349ff4665d88e39441648d78a7470c1319..cb2616461bc264fe2a4d18ee9a6024b248b2b966 100644 --- a/MeshLib/Elements/PyramidRule5.cpp +++ b/MeshLib/Elements/PyramidRule5.cpp @@ -47,7 +47,7 @@ const Element* PyramidRule5::getFace(const Element* e, unsigned i) if (i<e->getNumberOfFaces()) { unsigned nFaceNodes(PyramidRule5::n_face_nodes[i]); - Node** nodes = new Node*[nFaceNodes]; + auto** nodes = new Node*[nFaceNodes]; for (unsigned j=0; j<nFaceNodes; j++) nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); @@ -96,7 +96,7 @@ ElementErrorCode PyramidRule5::validate(const Element* e) ElementErrorCode error_code; error_code[ElementErrorFlag::ZeroVolume] = e->hasZeroVolume(); - const MeshLib::Quad* base (dynamic_cast<const MeshLib::Quad*>(e->getFace(4))); + const auto* base(dynamic_cast<const MeshLib::Quad*>(e->getFace(4))); if (base) { error_code |= base->validate(); diff --git a/MeshLib/Elements/PyramidRule5.h b/MeshLib/Elements/PyramidRule5.h index f1864743898ccb7e196e0ca1dfc7e01fca969f60..42a9c51bd2e55f2ed433c9064238a1a583ab23fd 100644 --- a/MeshLib/Elements/PyramidRule5.h +++ b/MeshLib/Elements/PyramidRule5.h @@ -73,7 +73,7 @@ public: static const unsigned n_face_nodes[5]; /// Returns the i-th edge of the element. - typedef LinearEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::LinearEdgeReturn; /// Returns the i-th face of the element. static const Element* getFace(const Element* e, unsigned i); diff --git a/MeshLib/Elements/Quad.h b/MeshLib/Elements/Quad.h index ad1cd724d0301d138987e5f988b57085945ddc98..4315590bc8816f3324d1791a2d8bd613ee1cd4ba 100644 --- a/MeshLib/Elements/Quad.h +++ b/MeshLib/Elements/Quad.h @@ -25,9 +25,7 @@ extern template class MeshLib::TemplateElement<MeshLib::QuadRule9>; namespace MeshLib { - -typedef TemplateElement<QuadRule4> Quad; -typedef TemplateElement<QuadRule8> Quad8; -typedef TemplateElement<QuadRule9> Quad9; - +using Quad = TemplateElement<MeshLib::QuadRule4>; +using Quad8 = TemplateElement<MeshLib::QuadRule8>; +using Quad9 = TemplateElement<MeshLib::QuadRule9>; } diff --git a/MeshLib/Elements/QuadRule4.h b/MeshLib/Elements/QuadRule4.h index 31af81dfe9ce7b5ad89e009868556231de64dd98..3a2a272dad0fdf4165d8dbee00a15f1095d36d7f 100644 --- a/MeshLib/Elements/QuadRule4.h +++ b/MeshLib/Elements/QuadRule4.h @@ -58,7 +58,7 @@ public: static const unsigned edge_nodes[4][2]; /// Returns the i-th edge of the element. - typedef LinearEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::LinearEdgeReturn; /** * \copydoc MeshLib::Element::isPntInElement() diff --git a/MeshLib/Elements/QuadRule8.h b/MeshLib/Elements/QuadRule8.h index e29b2d2fb6a72033382915d420675093ec64dfb9..a2e9e6fe52ddd6be9b690be7cfe1c43632cdf0b8 100644 --- a/MeshLib/Elements/QuadRule8.h +++ b/MeshLib/Elements/QuadRule8.h @@ -45,7 +45,7 @@ public: static const unsigned edge_nodes[4][3]; /// Returns the i-th edge of the element. - typedef QuadraticEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::QuadraticEdgeReturn; }; /* class */ diff --git a/MeshLib/Elements/TemplateElement.h b/MeshLib/Elements/TemplateElement.h index 1a69946aa186f09cebdf5e8497edf50f6ddfed7d..413f25cbe2fcc9108802064a9e46da9dd7e27f5c 100644 --- a/MeshLib/Elements/TemplateElement.h +++ b/MeshLib/Elements/TemplateElement.h @@ -60,51 +60,53 @@ public: TemplateElement(const TemplateElement &e); /// Destructor - virtual ~TemplateElement() {} + ~TemplateElement() override = default; /// Returns a copy of this object. - virtual Element* clone() const - { - return new TemplateElement(*this); - } - - virtual Element* clone(Node** nodes, std::size_t id) const + Element* clone() const override { return new TemplateElement(*this); } + Element* clone(Node** nodes, std::size_t id) const override { return new TemplateElement(nodes, id); } /// Get dimension of the mesh element. - unsigned getDimension() const { return dimension; } - + unsigned getDimension() const override { return dimension; } /// Returns the edge i of the element. - const Element* getEdge(unsigned i) const { return ELEMENT_RULE::EdgeReturn::getEdge(this, i); } + const Element* getEdge(unsigned i) const override + { + return ELEMENT_RULE::EdgeReturn::getEdge(this, i); + } /// Returns the face i of the element. - const Element* getFace(unsigned i) const { return ELEMENT_RULE::getFace(this, i); } + const Element* getFace(unsigned i) const override + { + return ELEMENT_RULE::getFace(this, i); + } /// Get the number of edges for this element. - unsigned getNumberOfEdges() const { return ELEMENT_RULE::n_edges; } - + unsigned getNumberOfEdges() const override { return ELEMENT_RULE::n_edges; } /// Get the number of faces for this element. - unsigned getNumberOfFaces() const { return ELEMENT_RULE::n_faces; } - + unsigned getNumberOfFaces() const override { return ELEMENT_RULE::n_faces; } /// Get the number of neighbors for this element. - unsigned getNumberOfNeighbors() const { return ELEMENT_RULE::n_neighbors; } + unsigned getNumberOfNeighbors() const override + { + return ELEMENT_RULE::n_neighbors; + } /// Get the number of linear nodes for this element. - virtual unsigned getNumberOfBaseNodes() const { return n_base_nodes; } - + unsigned getNumberOfBaseNodes() const override { return n_base_nodes; } /// Get the number of all nodes for this element. - virtual unsigned getNumberOfNodes() const { return n_all_nodes; } - + unsigned getNumberOfNodes() const override { return n_all_nodes; } /// Get the type of this element. - virtual MeshElemType getGeomType() const { return ELEMENT_RULE::mesh_elem_type; } + MeshElemType getGeomType() const override + { + return ELEMENT_RULE::mesh_elem_type; + } /// Get the FEM type of this element. - virtual CellType getCellType() const { return ELEMENT_RULE::cell_type; } - + CellType getCellType() const override { return ELEMENT_RULE::cell_type; } /// Returns true if these two indices form an edge and false otherwise - bool isEdge(unsigned idx1, unsigned idx2) const; + bool isEdge(unsigned idx1, unsigned idx2) const override; /** * \copydoc MeshLib::Element::isPntInElement() @@ -112,7 +114,9 @@ public: * This is actually calling the correct implementation of this function * passing the element's nodes. */ - bool isPntInElement(MathLib::Point3d const& pnt, double eps = std::numeric_limits<double>::epsilon()) const + bool isPntInElement( + MathLib::Point3d const& pnt, + double eps = std::numeric_limits<double>::epsilon()) const override { return ELEMENT_RULE::isPntInElement(this->_nodes, pnt, eps); } @@ -120,22 +124,25 @@ public: /** * Tests if the element is geometrically valid. */ - virtual ElementErrorCode validate() const + ElementErrorCode validate() const override { return ELEMENT_RULE::validate(this); } /// Returns the ID of a face given an array of nodes. - unsigned identifyFace(Node* nodes[3]) const + unsigned identifyFace(Node* nodes[3]) const override { return ELEMENT_RULE::identifyFace(this->_nodes, nodes); } /// Calculates the volume of a convex hexahedron by partitioning it into six tetrahedra. - virtual double computeVolume() {return ELEMENT_RULE::computeVolume(this->_nodes);} + double computeVolume() override + { + return ELEMENT_RULE::computeVolume(this->_nodes); + } /// Return a specific edge node. - virtual inline Node* getEdgeNode(unsigned edge_id, unsigned node_id) const + inline Node* getEdgeNode(unsigned edge_id, unsigned node_id) const override { if (getNumberOfEdges()>0) return const_cast<Node*>(this->_nodes[ELEMENT_RULE::edge_nodes[edge_id][node_id]]); @@ -147,7 +154,7 @@ public: * Checks if the node order of an element is correct by testing surface normals. * For 1D elements this always returns true. */ - virtual bool testElementNodeOrder() const + bool testElementNodeOrder() const override { return ELEMENT_RULE::testElementNodeOrder(this); } diff --git a/MeshLib/Elements/Tet.h b/MeshLib/Elements/Tet.h index ba4546c281eb188d228e1ac7236ca2509d0c3d25..1e1f497af87dbe97b1dd6ddc7fd4337ca9b85951 100644 --- a/MeshLib/Elements/Tet.h +++ b/MeshLib/Elements/Tet.h @@ -22,8 +22,6 @@ extern template class MeshLib::TemplateElement<MeshLib::TetRule10>; extern template class MeshLib::TemplateElement<MeshLib::TetRule4>; namespace MeshLib { - -typedef TemplateElement<TetRule4> Tet; -typedef TemplateElement<TetRule10> Tet10; - +using Tet = TemplateElement<MeshLib::TetRule4>; +using Tet10 = TemplateElement<MeshLib::TetRule10>; } diff --git a/MeshLib/Elements/TetRule10.h b/MeshLib/Elements/TetRule10.h index cbb57b58a72d8c4ed199924a0ce261e53de7cad4..f1a15b2fe7997236b96cca499e3323f3021c0080 100644 --- a/MeshLib/Elements/TetRule10.h +++ b/MeshLib/Elements/TetRule10.h @@ -53,7 +53,7 @@ public: static const unsigned edge_nodes[6][3]; /// Returns the i-th edge of the element. - typedef QuadraticEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::QuadraticEdgeReturn; /// Returns the i-th face of the element. static const Element* getFace(const Element* e, unsigned i); diff --git a/MeshLib/Elements/TetRule4.h b/MeshLib/Elements/TetRule4.h index 745b9326b54f20000893e489ad84e7eae13a3ab7..ebc0d9da600f71c10198f39f9c2b180215b7cfc7 100644 --- a/MeshLib/Elements/TetRule4.h +++ b/MeshLib/Elements/TetRule4.h @@ -68,7 +68,7 @@ public: static const unsigned edge_nodes[6][2]; /// Returns the i-th edge of the element. - typedef LinearEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::LinearEdgeReturn; /// Returns the i-th face of the element. static const Element* getFace(const Element* e, unsigned i); diff --git a/MeshLib/Elements/Tri.h b/MeshLib/Elements/Tri.h index ab67c61108466924b7b3a9273a8c2287f61083b5..29fed76029b52cae4a3f4df2fe2e9a4f27473f1d 100644 --- a/MeshLib/Elements/Tri.h +++ b/MeshLib/Elements/Tri.h @@ -23,8 +23,6 @@ extern template class MeshLib::TemplateElement<MeshLib::TriRule3>; extern template class MeshLib::TemplateElement<MeshLib::TriRule6>; namespace MeshLib { - -typedef TemplateElement<TriRule3> Tri; -typedef TemplateElement<TriRule6> Tri6; - +using Tri = TemplateElement<MeshLib::TriRule3>; +using Tri6 = TemplateElement<MeshLib::TriRule6>; } diff --git a/MeshLib/Elements/TriRule3.h b/MeshLib/Elements/TriRule3.h index f7f3c14c6c263ff8c5a6f08a8c6bba7aa173ba3b..157f8538d0a2dd2a9fce28cb367b20b4621fdb77 100644 --- a/MeshLib/Elements/TriRule3.h +++ b/MeshLib/Elements/TriRule3.h @@ -59,7 +59,7 @@ public: static const unsigned edge_nodes[3][2]; /// Returns the i-th edge of the element. - typedef LinearEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::LinearEdgeReturn; /** * \copydoc MeshLib::Element::isPntInElement() diff --git a/MeshLib/Elements/TriRule6.h b/MeshLib/Elements/TriRule6.h index d2b234cd0d2d9e7d6e11540d5fa453e2ed07d6ca..c34372bc900e0804df9428b2e52b0f2e7ef876fa 100644 --- a/MeshLib/Elements/TriRule6.h +++ b/MeshLib/Elements/TriRule6.h @@ -48,7 +48,7 @@ public: static const unsigned edge_nodes[3][3]; /// Returns the i-th edge of the element. - typedef QuadraticEdgeReturn EdgeReturn; + using EdgeReturn = MeshLib::QuadraticEdgeReturn; }; /* class */ diff --git a/MeshLib/IO/Legacy/MeshIO.cpp b/MeshLib/IO/Legacy/MeshIO.cpp index f68335d9133e11a661c431d12821b70f9bb6a82f..426c032864ed1d3bfd5ded2deb259e2de861e59a 100644 --- a/MeshLib/IO/Legacy/MeshIO.cpp +++ b/MeshLib/IO/Legacy/MeshIO.cpp @@ -83,7 +83,7 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) getline(in, line_string); std::stringstream iss(line_string); iss >> idx >> x >> y >> z; - MeshLib::Node* node(new MeshLib::Node(x, y, z, idx)); + auto* node(new MeshLib::Node(x, y, z, idx)); nodes.push_back(node); iss >> s; if (s.find("$AREA") != std::string::npos) @@ -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; } @@ -174,7 +174,7 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, elem_type = MeshLib::String2MeshElemType(elem_type_str); } while (elem_type == MeshLib::MeshElemType::INVALID); - unsigned* idx = new unsigned[8]; + auto* idx = new unsigned[8]; MeshLib::Element* elem; switch(elem_type) @@ -184,7 +184,7 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, if (!(in >> idx[i])) return nullptr; // edge_nodes array will be deleted from Line object - MeshLib::Node** edge_nodes = new MeshLib::Node*[2]; + auto** edge_nodes = new MeshLib::Node*[2]; for (unsigned k(0); k < 2; ++k) edge_nodes[k] = nodes[idx[k]]; elem = new MeshLib::Line(edge_nodes); @@ -194,7 +194,7 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, for (int i = 0; i < 3; ++i) if (!(in >> idx[i])) return nullptr; - MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; + auto** tri_nodes = new MeshLib::Node*[3]; for (unsigned k(0); k < 3; ++k) tri_nodes[k] = nodes[idx[k]]; elem = new MeshLib::Tri(tri_nodes); @@ -204,7 +204,7 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, for (int i = 0; i < 4; ++i) if (!(in >> idx[i])) return nullptr; - MeshLib::Node** quad_nodes = new MeshLib::Node*[4]; + auto** quad_nodes = new MeshLib::Node*[4]; for (unsigned k(0); k < 4; ++k) quad_nodes[k] = nodes[idx[k]]; elem = new MeshLib::Quad(quad_nodes); @@ -214,7 +214,7 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, for (int i = 0; i < 4; ++i) if (!(in >> idx[i])) return nullptr; - MeshLib::Node** tet_nodes = new MeshLib::Node*[4]; + auto** tet_nodes = new MeshLib::Node*[4]; for (unsigned k(0); k < 4; ++k) tet_nodes[k] = nodes[idx[k]]; elem = new MeshLib::Tet(tet_nodes); @@ -224,7 +224,7 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, for (int i = 0; i < 8; ++i) if (!(in >> idx[i])) return nullptr; - MeshLib::Node** hex_nodes = new MeshLib::Node*[8]; + auto** hex_nodes = new MeshLib::Node*[8]; for (unsigned k(0); k < 8; ++k) hex_nodes[k] = nodes[idx[k]]; elem = new MeshLib::Hex(hex_nodes); @@ -234,7 +234,7 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, for (int i = 0; i < 5; ++i) if (!(in >> idx[i])) return nullptr; - MeshLib::Node** pyramid_nodes = new MeshLib::Node*[5]; + auto** pyramid_nodes = new MeshLib::Node*[5]; for (unsigned k(0); k < 5; ++k) pyramid_nodes[k] = nodes[idx[k]]; elem = new MeshLib::Pyramid(pyramid_nodes); @@ -244,14 +244,14 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, for (int i = 0; i < 6; ++i) if (!(in >> idx[i])) return nullptr; - MeshLib::Node** prism_nodes = new MeshLib::Node*[6]; + auto** prism_nodes = new MeshLib::Node*[6]; for (unsigned k(0); k < 6; ++k) prism_nodes[k] = nodes[idx[k]]; elem = new MeshLib::Prism(prism_nodes); break; } default: - elem = NULL; + elem = nullptr; break; } diff --git a/MeshLib/IO/Legacy/MeshIO.h b/MeshLib/IO/Legacy/MeshIO.h index dca1fae9a54dce47245677e61ee7a788d3000461..9571e84f5e4c7c62d5ac4a0f7f7f80a156ab1d90 100644 --- a/MeshLib/IO/Legacy/MeshIO.h +++ b/MeshLib/IO/Legacy/MeshIO.h @@ -39,7 +39,7 @@ public: /// Constructor. MeshIO(); - virtual ~MeshIO() {} + ~MeshIO() override = default; /// Read mesh from file. MeshLib::Mesh* loadMeshFromFile(const std::string& fileName); @@ -49,7 +49,7 @@ public: protected: /// Write mesh to stream. - bool write(); + bool write() override; private: void writeElements(std::vector<MeshLib::Element*> const& ele_vec, diff --git a/MeshLib/IO/VtkIO/PVDFile.h b/MeshLib/IO/VtkIO/PVDFile.h index 1e7e30ea278d85a27f11440cc16f8ea03dfe7769..e0a7b8bdea84b9e56e11d38f6b879f9031259e9b 100644 --- a/MeshLib/IO/VtkIO/PVDFile.h +++ b/MeshLib/IO/VtkIO/PVDFile.h @@ -10,6 +10,7 @@ #pragma once #include <string> +#include <utility> #include <vector> namespace MeshLib @@ -24,7 +25,10 @@ class PVDFile { public: //! Set a PVD file path - explicit PVDFile(std::string const& pvd_fname) : _pvd_filename(pvd_fname) {} + explicit PVDFile(std::string pvd_fname) + : _pvd_filename(std::move(pvd_fname)) + { + } //! Add a VTU file to this PVD file. void addVTUFile(std::string const& vtu_fname, double timestep); diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp index a3a0b0e6420ad1f764d0b633afc4df1080c46a13..6710601d2508b827153a6372fe8812e1d4c7f29c 100644 --- a/MeshLib/Mesh.cpp +++ b/MeshLib/Mesh.cpp @@ -15,6 +15,7 @@ #include "Mesh.h" #include <memory> +#include <utility> #include "BaseLib/RunTime.h" @@ -28,23 +29,27 @@ namespace MeshLib { - -Mesh::Mesh(const std::string &name, - const std::vector<Node*> &nodes, - const std::vector<Element*> &elements, +Mesh::Mesh(std::string name, + std::vector<Node*> + nodes, + std::vector<Element*> + elements, Properties const& properties, const std::size_t n_base_nodes) - : _id(_counter_value-1), _mesh_dimension(0), + : _id(_counter_value - 1), + _mesh_dimension(0), _edge_length(std::numeric_limits<double>::max(), 0), _node_distance(std::numeric_limits<double>::max(), 0), - _name(name), _nodes(nodes), _elements(elements), + _name(std::move(name)), + _nodes(std::move(nodes)), + _elements(std::move(elements)), _n_base_nodes(n_base_nodes), _properties(properties) { - assert(n_base_nodes <= nodes.size()); + assert(_n_base_nodes <= _nodes.size()); this->resetNodeIDs(); this->resetElementIDs(); - if ((n_base_nodes==0 && hasNonlinearElement()) || isNonlinear()) + if ((_n_base_nodes == 0 && hasNonlinearElement()) || isNonlinear()) this->checkNonlinearNodeIDs(); this->setDimension(); this->setElementsConnectedToNodes(); @@ -144,19 +149,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 +185,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/Mesh.h b/MeshLib/Mesh.h index 2d7f63ca0dbb5bdf584e90f66cfd3f5cec602599..6f26b61c0de67fb66186eb037cbee927637d3a52 100644 --- a/MeshLib/Mesh.h +++ b/MeshLib/Mesh.h @@ -56,9 +56,11 @@ public: /// parameter for nonlinear case. If the parameter is /// set to zero, we consider there are no nonlinear /// nodes. - Mesh(const std::string &name, - const std::vector<Node*> &nodes, - const std::vector<Element*> &elements, + Mesh(std::string name, + std::vector<Node*> + nodes, + std::vector<Element*> + elements, Properties const& properties = Properties(), const std::size_t n_base_nodes = 0); diff --git a/MeshLib/MeshEditing/AddLayerToMesh.cpp b/MeshLib/MeshEditing/AddLayerToMesh.cpp index 594c0e81d2147be8aa19c9cbfd66e5dbfaf8db16..13e7454f3d7088a4d23fd9f8c9246e26cb98b8ef 100644 --- a/MeshLib/MeshEditing/AddLayerToMesh.cpp +++ b/MeshLib/MeshEditing/AddLayerToMesh.cpp @@ -53,7 +53,7 @@ MeshLib::Element* extrudeElement(std::vector<MeshLib::Node*> const& subsfc_nodes return nullptr; const unsigned nElemNodes(sfc_elem.getNumberOfBaseNodes()); - MeshLib::Node** new_nodes = new MeshLib::Node*[2*nElemNodes]; + auto** new_nodes = new MeshLib::Node*[2 * nElemNodes]; for (unsigned j=0; j<nElemNodes; ++j) { diff --git a/MeshLib/MeshEditing/ConvertToLinearMesh.cpp b/MeshLib/MeshEditing/ConvertToLinearMesh.cpp index 9d0e558be83a0f206db1849c47886f73744a5839..9b6cf62fe74234f8b018e5b157528f5533f4282b 100644 --- a/MeshLib/MeshEditing/ConvertToLinearMesh.cpp +++ b/MeshLib/MeshEditing/ConvertToLinearMesh.cpp @@ -32,7 +32,7 @@ T_ELEMENT* createLinearElement(MeshLib::Element const* e, std::vector<MeshLib::Node*> const& vec_new_nodes) { auto const n_base_nodes = T_ELEMENT::n_base_nodes; - MeshLib::Node** nodes = new MeshLib::Node*[n_base_nodes]; + auto** nodes = new MeshLib::Node*[n_base_nodes]; for (unsigned i=0; i<e->getNumberOfBaseNodes(); i++) nodes[i] = const_cast<MeshLib::Node*>(vec_new_nodes[e->getNode(i)->getID()]); return new T_ELEMENT(nodes); diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp index 91ab90155d0fc72d5c04dbb1d5a92fafd9013668..ade3934074bba7b4228026ea02c7bee96a668e0b 100644 --- a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp +++ b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp @@ -64,7 +64,7 @@ MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::v template <typename E> MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::vector<MeshLib::Node*> &nodes) { - MeshLib::Node** new_nodes = new MeshLib::Node*[element->getNumberOfNodes()]; + auto** new_nodes = new MeshLib::Node*[element->getNumberOfNodes()]; for (unsigned i=0; i<element->getNumberOfNodes(); ++i) new_nodes[i] = nodes[element->getNode(i)->getID()]; return new E(new_nodes); diff --git a/MeshLib/MeshEditing/FlipElements.cpp b/MeshLib/MeshEditing/FlipElements.cpp index aab4f09539dcb3b62e4e9e7799ec6d9ea97fad8d..4cac837513f3fc554e3b1e7fead251258cd00c51 100644 --- a/MeshLib/MeshEditing/FlipElements.cpp +++ b/MeshLib/MeshEditing/FlipElements.cpp @@ -25,7 +25,7 @@ std::unique_ptr<MeshLib::Element> createFlippedElement(MeshLib::Element const& e return nullptr; unsigned const n_nodes (elem.getNumberOfNodes()); - MeshLib::Node** elem_nodes = new MeshLib::Node*[n_nodes]; + auto** elem_nodes = new MeshLib::Node*[n_nodes]; for (unsigned i=0; i<n_nodes; ++i) elem_nodes[i] = nodes[elem.getNode(i)->getID()]; std::swap(elem_nodes[0], elem_nodes[1]); diff --git a/MeshLib/MeshEditing/MeshRevision.cpp b/MeshLib/MeshEditing/MeshRevision.cpp index 3d53c0df14483eae63db34c4af25a7da6d4bf798..c7a9877cadd81b37025df6d21c7445cad30a72b3 100644 --- a/MeshLib/MeshEditing/MeshRevision.cpp +++ b/MeshLib/MeshEditing/MeshRevision.cpp @@ -328,13 +328,13 @@ unsigned MeshRevision::subdivideQuad(MeshLib::Element const*const quad, std::vector<MeshLib::Node*> const& nodes, std::vector<MeshLib::Element*> &new_elements) const { - MeshLib::Node** tri1_nodes = new MeshLib::Node*[3]; + auto** tri1_nodes = new MeshLib::Node*[3]; tri1_nodes[0] = nodes[quad->getNode(0)->getID()]; tri1_nodes[1] = nodes[quad->getNode(1)->getID()]; tri1_nodes[2] = nodes[quad->getNode(2)->getID()]; new_elements.push_back(new MeshLib::Tri(tri1_nodes)); - MeshLib::Node** tri2_nodes = new MeshLib::Node*[3]; + auto** tri2_nodes = new MeshLib::Node*[3]; tri2_nodes[0] = nodes[quad->getNode(0)->getID()]; tri2_nodes[1] = nodes[quad->getNode(2)->getID()]; tri2_nodes[2] = nodes[quad->getNode(3)->getID()]; @@ -347,25 +347,25 @@ unsigned MeshRevision::subdivideHex(MeshLib::Element const*const hex, std::vector<MeshLib::Node*> const& nodes, std::vector<MeshLib::Element*> &new_elements) const { - MeshLib::Node** prism1_nodes = new MeshLib::Node*[6]; + auto** prism1_nodes = new MeshLib::Node*[6]; prism1_nodes[0] = nodes[hex->getNode(0)->getID()]; prism1_nodes[1] = nodes[hex->getNode(2)->getID()]; prism1_nodes[2] = nodes[hex->getNode(1)->getID()]; prism1_nodes[3] = nodes[hex->getNode(4)->getID()]; prism1_nodes[4] = nodes[hex->getNode(6)->getID()]; prism1_nodes[5] = nodes[hex->getNode(5)->getID()]; - MeshLib::Prism* prism1 (new MeshLib::Prism(prism1_nodes)); + auto* prism1(new MeshLib::Prism(prism1_nodes)); this->subdividePrism(prism1, nodes, new_elements); delete prism1; - MeshLib::Node** prism2_nodes = new MeshLib::Node*[6]; + auto** prism2_nodes = new MeshLib::Node*[6]; prism2_nodes[0] = nodes[hex->getNode(4)->getID()]; prism2_nodes[1] = nodes[hex->getNode(6)->getID()]; prism2_nodes[2] = nodes[hex->getNode(7)->getID()]; prism2_nodes[3] = nodes[hex->getNode(0)->getID()]; prism2_nodes[4] = nodes[hex->getNode(2)->getID()]; prism2_nodes[5] = nodes[hex->getNode(3)->getID()]; - MeshLib::Prism* prism2 (new MeshLib::Prism(prism2_nodes)); + auto* prism2(new MeshLib::Prism(prism2_nodes)); this->subdividePrism(prism2, nodes, new_elements); delete prism2; @@ -377,9 +377,8 @@ unsigned MeshRevision::subdividePyramid(MeshLib::Element const*const pyramid, std::vector<MeshLib::Element*> &new_elements) const { auto addTetrahedron = [&pyramid, &nodes, &new_elements]( - std::size_t id0, std::size_t id1, std::size_t id2, std::size_t id3) - { - MeshLib::Node** tet_nodes = new MeshLib::Node*[4]; + std::size_t id0, std::size_t id1, std::size_t id2, std::size_t id3) { + auto** tet_nodes = new MeshLib::Node*[4]; tet_nodes[0] = nodes[pyramid->getNode(id0)->getID()]; tet_nodes[1] = nodes[pyramid->getNode(id1)->getID()]; tet_nodes[2] = nodes[pyramid->getNode(id2)->getID()]; @@ -399,9 +398,8 @@ unsigned MeshRevision::subdividePrism(MeshLib::Element const*const prism, std::vector<MeshLib::Element*> &new_elements) const { auto addTetrahedron = [&prism, &nodes, &new_elements]( - std::size_t id0, std::size_t id1, std::size_t id2, std::size_t id3) - { - MeshLib::Node** tet_nodes = new MeshLib::Node*[4]; + std::size_t id0, std::size_t id1, std::size_t id2, std::size_t id3) { + auto** tet_nodes = new MeshLib::Node*[4]; tet_nodes[0] = nodes[prism->getNode(id0)->getID()]; tet_nodes[1] = nodes[prism->getNode(id1)->getID()]; tet_nodes[2] = nodes[prism->getNode(id2)->getID()]; @@ -436,7 +434,7 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, if (org_elem->getNode(i)->getID() == org_elem->getNode(j)->getID()) { const std::array<unsigned,4> base_nodes (this->lutHexCuttingQuadNodes(i,j)); - MeshLib::Node** pyr_nodes = new MeshLib::Node*[5]; + auto** pyr_nodes = new MeshLib::Node*[5]; pyr_nodes[0] = nodes[org_elem->getNode(base_nodes[0])->getID()]; pyr_nodes[1] = nodes[org_elem->getNode(base_nodes[1])->getID()]; pyr_nodes[2] = nodes[org_elem->getNode(base_nodes[2])->getID()]; @@ -445,7 +443,7 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, new_elements.push_back (new MeshLib::Pyramid(pyr_nodes)); if (i<4 && j>=4) std::swap(i,j); - MeshLib::Node** prism_nodes = new MeshLib::Node*[6]; + auto** prism_nodes = new MeshLib::Node*[6]; prism_nodes[0] = nodes[org_elem->getNode(base_nodes[0])->getID()]; prism_nodes[1] = nodes[org_elem->getNode(base_nodes[3])->getID()]; prism_nodes[2] = nodes[org_elem->getNode(this->lutHexDiametralNode(j))->getID()]; @@ -464,7 +462,7 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, const MeshLib::Element* face (org_elem->getFace(i)); if (face->getNode(0)->getID() == face->getNode(1)->getID() && face->getNode(2)->getID() == face->getNode(3)->getID()) { - MeshLib::Node** prism_nodes = new MeshLib::Node*[6]; + auto** prism_nodes = new MeshLib::Node*[6]; prism_nodes[0] = nodes[org_elem->getNode(this->lutHexDiametralNode(org_elem->getNodeIDinElement(face->getNode(0))))->getID()]; prism_nodes[1] = nodes[org_elem->getNode(this->lutHexDiametralNode(org_elem->getNodeIDinElement(face->getNode(1))))->getID()]; prism_nodes[2] = nodes[org_elem->getNode(org_elem->getNodeIDinElement(face->getNode(2)))->getID()]; @@ -477,7 +475,7 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, } if (face->getNode(0)->getID() == face->getNode(3)->getID() && face->getNode(1)->getID() == face->getNode(2)->getID()) { - MeshLib::Node** prism_nodes = new MeshLib::Node*[6]; + auto** prism_nodes = new MeshLib::Node*[6]; prism_nodes[0] = nodes[org_elem->getNode(this->lutHexDiametralNode(org_elem->getNodeIDinElement(face->getNode(0))))->getID()]; prism_nodes[1] = nodes[org_elem->getNode(this->lutHexDiametralNode(org_elem->getNodeIDinElement(face->getNode(3))))->getID()]; prism_nodes[2] = nodes[org_elem->getNode(org_elem->getNodeIDinElement(face->getNode(2)))->getID()]; @@ -507,25 +505,25 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, } std::array<unsigned, 4> cutting_plane (this->lutHexCuttingQuadNodes(back.first, back.second)); - MeshLib::Node** pris1_nodes = new MeshLib::Node*[6]; + auto** pris1_nodes = new MeshLib::Node*[6]; pris1_nodes[0] = const_cast<MeshLib::Node*>(org_elem->getNode(back.first)); pris1_nodes[1] = const_cast<MeshLib::Node*>(org_elem->getNode(cutting_plane[0])); pris1_nodes[2] = const_cast<MeshLib::Node*>(org_elem->getNode(cutting_plane[3])); pris1_nodes[3] = const_cast<MeshLib::Node*>(org_elem->getNode(back.second)); pris1_nodes[4] = const_cast<MeshLib::Node*>(org_elem->getNode(cutting_plane[1])); pris1_nodes[5] = const_cast<MeshLib::Node*>(org_elem->getNode(cutting_plane[2])); - MeshLib::Prism* prism1 (new MeshLib::Prism(pris1_nodes)); + auto* prism1(new MeshLib::Prism(pris1_nodes)); unsigned nNewElements = this->reducePrism(prism1, 5, nodes, new_elements, min_elem_dim); delete prism1; - MeshLib::Node** pris2_nodes = new MeshLib::Node*[6]; + auto** pris2_nodes = new MeshLib::Node*[6]; pris2_nodes[0] = const_cast<MeshLib::Node*>(org_elem->getNode(this->lutHexDiametralNode(back.first))); pris2_nodes[1] = const_cast<MeshLib::Node*>(org_elem->getNode(cutting_plane[0])); pris2_nodes[2] = const_cast<MeshLib::Node*>(org_elem->getNode(cutting_plane[3])); pris2_nodes[3] = const_cast<MeshLib::Node*>(org_elem->getNode(this->lutHexDiametralNode(back.second))); pris2_nodes[4] = const_cast<MeshLib::Node*>(org_elem->getNode(cutting_plane[1])); pris2_nodes[5] = const_cast<MeshLib::Node*>(org_elem->getNode(cutting_plane[2])); - MeshLib::Prism* prism2 (new MeshLib::Prism(pris2_nodes)); + auto* prism2(new MeshLib::Prism(pris2_nodes)); nNewElements += this->reducePrism(prism2, 5, nodes, new_elements, min_elem_dim); delete prism2; return nNewElements; @@ -543,7 +541,7 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, { delete tet1; tet_changed =true; - MeshLib::Node** tet1_nodes = new MeshLib::Node*[4]; + auto** tet1_nodes = new MeshLib::Node*[4]; tet1_nodes[0] = nodes[first_four_nodes[0]]; tet1_nodes[1] = nodes[first_four_nodes[1]]; tet1_nodes[2] = nodes[first_four_nodes[2]]; @@ -553,7 +551,7 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, else new_elements.push_back(tet1); - MeshLib::Node** tet2_nodes = new MeshLib::Node*[4]; + auto** tet2_nodes = new MeshLib::Node*[4]; tet2_nodes[0] = (tet_changed) ? nodes[first_four_nodes[0]] : nodes[first_four_nodes[1]]; tet2_nodes[1] = nodes[first_four_nodes[2]]; tet2_nodes[2] = nodes[first_four_nodes[3]]; @@ -609,9 +607,8 @@ unsigned MeshRevision::reducePrism(MeshLib::Element const*const org_elem, unsigned min_elem_dim) const { auto addTetrahedron = [&org_elem, &nodes, &new_elements]( - std::size_t id0, std::size_t id1, std::size_t id2, std::size_t id3) - { - MeshLib::Node** tet_nodes = new MeshLib::Node*[4]; + std::size_t id0, std::size_t id1, std::size_t id2, std::size_t id3) { + auto** tet_nodes = new MeshLib::Node*[4]; tet_nodes[0] = nodes[org_elem->getNode(id0)->getID()]; tet_nodes[1] = nodes[org_elem->getNode(id1)->getID()]; tet_nodes[2] = nodes[org_elem->getNode(id2)->getID()]; @@ -683,7 +680,7 @@ unsigned MeshRevision::reducePrism(MeshLib::Element const*const org_elem, MeshLib::Element* MeshRevision::constructLine(MeshLib::Element const*const element, const std::vector<MeshLib::Node*> &nodes) const { - MeshLib::Node** line_nodes = new MeshLib::Node*[2]; + auto** line_nodes = new MeshLib::Node*[2]; line_nodes[0] = nodes[element->getNode(0)->getID()]; line_nodes[1] = nullptr; for (unsigned i=1; i<element->getNumberOfBaseNodes(); ++i) @@ -704,7 +701,7 @@ MeshLib::Element* MeshRevision::constructTri(MeshLib::Element const*const elemen // TODO? // In theory three unique nodes could also be reduced to two lines e.g. with // a quad where two diametral nodes collapse. This case is currently not implemented! - MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; + auto** tri_nodes = new MeshLib::Node*[3]; tri_nodes[0] = nodes[element->getNode(0)->getID()]; tri_nodes[2] = nullptr; for (unsigned i = 1; i < element->getNumberOfBaseNodes(); ++i) @@ -732,7 +729,7 @@ MeshLib::Element* MeshRevision::constructFourNodeElement( std::vector<MeshLib::Node*> const& nodes, unsigned min_elem_dim) const { - MeshLib::Node** new_nodes = new MeshLib::Node*[4]; + auto** new_nodes = new MeshLib::Node*[4]; unsigned count(0); new_nodes[count++] = nodes[element->getNode(0)->getID()]; for (unsigned i=1; i<element->getNumberOfBaseNodes(); ++i) @@ -861,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/MeshEditing/MeshRevision.h b/MeshLib/MeshEditing/MeshRevision.h index 6eb0c294b5ea2339b6dc6a9125b0d2ece4257505..33d7dc18a9d9b176f3a492422802bbe4a25302e0 100644 --- a/MeshLib/MeshEditing/MeshRevision.h +++ b/MeshLib/MeshEditing/MeshRevision.h @@ -41,7 +41,7 @@ public: */ MeshRevision(MeshLib::Mesh &mesh); - virtual ~MeshRevision() {} + virtual ~MeshRevision() = default; /** * Collapsed all nodes with distance < eps but ignores elements diff --git a/MeshLib/MeshGenerators/LayeredVolume.cpp b/MeshLib/MeshGenerators/LayeredVolume.cpp index 58bb878ed24386155d0f067c7e936b59d4e9493d..ee2dbe76687268bedd8e927a77719f6d8ca62136 100644 --- a/MeshLib/MeshGenerators/LayeredVolume.cpp +++ b/MeshLib/MeshGenerators/LayeredVolume.cpp @@ -174,7 +174,11 @@ void LayeredVolume::removeCongruentElements(std::size_t nLayers, std::size_t nEl else { MeshLib::Node attr = high->getCenterOfGravity(); - _attribute_points.push_back(MeshLib::Node(attr[0], attr[1], (attr[2] + low->getCenterOfGravity()[2])/2.0, _materials[lower_offset+j])); + _attribute_points.emplace_back( + attr[0], + attr[1], + (attr[2] + low->getCenterOfGravity()[2]) / 2.0, + _materials[lower_offset + j]); } } } diff --git a/MeshLib/MeshGenerators/LayeredVolume.h b/MeshLib/MeshGenerators/LayeredVolume.h index a96a1a640196333da65bf8fd11495c4ffea51011..9557a930a5ee0505d2ee86f711e9909d9b76e922 100644 --- a/MeshLib/MeshGenerators/LayeredVolume.h +++ b/MeshLib/MeshGenerators/LayeredVolume.h @@ -31,28 +31,45 @@ namespace GeoLib { class LayeredVolume : public LayeredMeshGenerator { public: - LayeredVolume() {} - ~LayeredVolume() {} + LayeredVolume() = default; + ~LayeredVolume() override = default; /** - * Constructs a subsurface representation of a mesh using only 2D elements (i.e. layer boundaries are represented by surfaces) - * @param mesh The 2D surface mesh that is used as a basis for the subsurface mesh - * @param rasters Containing all the raster-data for the subsurface layers from bottom to top (starting with the bottom of the oldest layer and ending with the DEM) - * @param minimum_thickness Minimum thickness of each of the newly created layers (i.e. nodes with a vertical distance smaller than this will be collapsed) - * @param noDataReplacementValue Default z-coordinate if there are mesh nodes not located on the DEM raster (i.e. raster_paths[0]) - * @result true if the subsurface representation has been created, false if there was an error + * Constructs a subsurface representation of a mesh using only 2D elements + * (i.e. layer boundaries are represented by surfaces) + * @param mesh The 2D surface mesh that is used as a + * basis + * for the subsurface mesh + * @param rasters Containing all the raster-data for the + * subsurface layers from bottom to top (starting with the bottom of the + * oldest layer and ending with the DEM) + * @param minimum_thickness Minimum thickness of each of the newly + * created layers (i.e. nodes with a vertical distance smaller than this + * will + * be collapsed) + * @param noDataReplacementValue Default z-coordinate if there are mesh + * nodes + * not located on the DEM raster (i.e. raster_paths[0]) + * @result true if the subsurface representation has been created, false if + * there was an error */ - bool createRasterLayers(const MeshLib::Mesh &mesh, - const std::vector<GeoLib::Raster const*> &rasters, + bool createRasterLayers(const MeshLib::Mesh& mesh, + const std::vector<GeoLib::Raster const*>& rasters, double minimum_thickness, - double noDataReplacementValue = 0.0); + double noDataReplacementValue = 0.0) override; - /// Returns the region attribute vector necessary for assigning region attributes via TetGen - std::vector<MeshLib::Node> getAttributePoints() { return _attribute_points; } + /// Returns the region attribute vector necessary for assigning region + /// attributes via TetGen + std::vector<MeshLib::Node> getAttributePoints() + { + return _attribute_points; + } private: /// Adds another layer to the subsurface mesh - void addLayerToMesh(const MeshLib::Mesh &mesh_layer, unsigned layer_id, GeoLib::Raster const& raster); + void addLayerToMesh(const MeshLib::Mesh& mesh_layer, + unsigned layer_id, + GeoLib::Raster const& raster) override; /// Creates boundary surfaces between the mapped layers to make the volumes watertight void addLayerBoundaries(const MeshLib::Mesh &layer, std::size_t nLayers); diff --git a/MeshLib/MeshGenerators/MeshLayerMapper.cpp b/MeshLib/MeshGenerators/MeshLayerMapper.cpp index 754dcfc2c91ff8e58b6248d193ca43eb8dfed4de..b702b7a1bc88e7f3760ed38fc7663dea660d9d68 100644 --- a/MeshLib/MeshGenerators/MeshLayerMapper.cpp +++ b/MeshLib/MeshGenerators/MeshLayerMapper.cpp @@ -94,7 +94,7 @@ MeshLib::Mesh* MeshLayerMapper::createStaticLayers(MeshLib::Mesh const& mesh, st continue; const unsigned nElemNodes(sfc_elem->getNumberOfBaseNodes()); - MeshLib::Node** e_nodes = new MeshLib::Node*[2*nElemNodes]; + auto** e_nodes = new MeshLib::Node*[2 * nElemNodes]; for (unsigned j=0; j<nElemNodes; ++j) { @@ -127,11 +127,11 @@ bool MeshLayerMapper::createRasterLayers( return false; } - MeshLib::Mesh* top (new MeshLib::Mesh(mesh)); + auto* top(new MeshLib::Mesh(mesh)); if (!layerMapping(*top, *rasters.back(), noDataReplacementValue)) return false; - MeshLib::Mesh* bottom (new MeshLib::Mesh(mesh)); + auto* bottom(new MeshLib::Mesh(mesh)); if (!layerMapping(*bottom, *rasters[0], 0)) { delete top; diff --git a/MeshLib/MeshGenerators/MeshLayerMapper.h b/MeshLib/MeshGenerators/MeshLayerMapper.h index 382826b405eb0b71e1c9ef0da19442710aec3c95..e82c48adbe2b121b38dbda7176453a07b9a953df 100644 --- a/MeshLib/MeshGenerators/MeshLayerMapper.h +++ b/MeshLib/MeshGenerators/MeshLayerMapper.h @@ -25,7 +25,7 @@ namespace MeshLib class MeshLayerMapper : public LayeredMeshGenerator { public: - virtual ~MeshLayerMapper() = default; + ~MeshLayerMapper() override = default; /** * Based on a 2D triangle-or quad mesh this method creates a 3D mesh with a given number of prism- or hex-layers @@ -52,7 +52,7 @@ public: bool createRasterLayers(MeshLib::Mesh const& mesh, std::vector<GeoLib::Raster const*> const& rasters, double minimum_thickness, - double noDataReplacementValue = 0.0); + double noDataReplacementValue = 0.0) override; /** * Maps the elevation of nodes of a given 2D mesh according to the raster. At @@ -66,7 +66,9 @@ public: private: /// Adds another layer to a subsurface mesh - void addLayerToMesh(const MeshLib::Mesh &mesh_layer, unsigned layer_id, GeoLib::Raster const& raster); + void addLayerToMesh(const MeshLib::Mesh& mesh_layer, + unsigned layer_id, + GeoLib::Raster const& raster) override; }; } // end namespace MeshLib diff --git a/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp b/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp index f4d321714b55927d1caafedb785cd03baa261fc3..5d6b68ccbe68d7fd59997eac57bba4439d519c74 100644 --- a/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp +++ b/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp @@ -56,7 +56,7 @@ T_ELEMENT* createQuadraticElement( { auto const n_all_nodes = T_ELEMENT::n_all_nodes; auto const n_base_nodes = T_ELEMENT::n_base_nodes; - MeshLib::Node** nodes = new MeshLib::Node*[n_all_nodes]; + auto** nodes = new MeshLib::Node*[n_all_nodes]; for (unsigned i = 0; i < e->getNumberOfBaseNodes(); i++) nodes[i] = const_cast<MeshLib::Node*>(vec_new_nodes[e->getNode(i)->getID()]); diff --git a/MeshLib/MeshGenerators/RasterToMesh.cpp b/MeshLib/MeshGenerators/RasterToMesh.cpp index 7d80280d7ce20d87e3636a0c8ac493fd9dde61dd..dba1407c6c2dad86bc6b7c9cf5074129cf6cde57 100644 --- a/MeshLib/MeshGenerators/RasterToMesh.cpp +++ b/MeshLib/MeshGenerators/RasterToMesh.cpp @@ -179,7 +179,9 @@ std::vector<MeshLib::Node*> RasterToMesh::createNodeVector( continue; double const zValue = (use_elevation) ? elevation[index] : 0; - MeshLib::Node* node (new MeshLib::Node(x_offset + (header.cell_size * j), y_offset + (header.cell_size * i), zValue)); + auto* node(new MeshLib::Node(x_offset + (header.cell_size * j), + y_offset + (header.cell_size * i), + zValue)); nodes.push_back(node); node_idx_map[index] = node_idx_count; node_idx_count++; @@ -206,12 +208,12 @@ std::vector<MeshLib::Element*> RasterToMesh::createElementVector( int const idx = i * incWidth + j; if (elem_type == MeshElemType::TRIANGLE) { - MeshLib::Node** tri1_nodes = new MeshLib::Node*[3]; + auto** tri1_nodes = new MeshLib::Node*[3]; tri1_nodes[0] = nodes[node_idx_map[idx]]; tri1_nodes[1] = nodes[node_idx_map[idx+1]]; tri1_nodes[2] = nodes[node_idx_map[idx+incWidth]]; - MeshLib::Node** tri2_nodes = new MeshLib::Node*[3]; + auto** tri2_nodes = new MeshLib::Node*[3]; tri2_nodes[0] = nodes[node_idx_map[idx+1]]; tri2_nodes[1] = nodes[node_idx_map[idx+incWidth+1]]; tri2_nodes[2] = nodes[node_idx_map[idx+incWidth]]; @@ -221,7 +223,7 @@ std::vector<MeshLib::Element*> RasterToMesh::createElementVector( } else if (elem_type == MeshElemType::QUAD) { - MeshLib::Node** quad_nodes = new MeshLib::Node*[4]; + auto** quad_nodes = new MeshLib::Node*[4]; quad_nodes[0] = nodes[node_idx_map[idx]]; quad_nodes[1] = nodes[node_idx_map[idx + 1]]; quad_nodes[2] = nodes[node_idx_map[idx + incWidth + 1]]; diff --git a/MeshLib/MeshGenerators/RasterToMesh.h b/MeshLib/MeshGenerators/RasterToMesh.h index e386f9694169c777a0f2857edb30d290c8254fec..8ea537a749349eb4b79173c07e35faf2e8c19f84 100644 --- a/MeshLib/MeshGenerators/RasterToMesh.h +++ b/MeshLib/MeshGenerators/RasterToMesh.h @@ -118,7 +118,7 @@ private: { if (!pix_vis[i*imgWidth+j]) continue; - T val (static_cast<T>(pix_val[i*(imgWidth+1)+j])); + auto val(static_cast<T>(pix_val[i * (imgWidth + 1) + j])); if (elem_type == MeshElemType::TRIANGLE) { prop_vec.push_back(val); diff --git a/MeshLib/MeshGenerators/VtkMeshConverter.cpp b/MeshLib/MeshGenerators/VtkMeshConverter.cpp index 1d71cac97527dabebba047056ce38b3752b17ac6..2486a7f656ec16098993a559c9ca6443e67ca1ba 100644 --- a/MeshLib/MeshGenerators/VtkMeshConverter.cpp +++ b/MeshLib/MeshGenerators/VtkMeshConverter.cpp @@ -45,7 +45,7 @@ template <class T_ELEMENT> MeshLib::Element* createElementWithSameNodeOrder(const std::vector<MeshLib::Node*> &nodes, vtkIdList* const node_ids) { - MeshLib::Node** ele_nodes = new MeshLib::Node*[T_ELEMENT::n_all_nodes]; + auto** ele_nodes = new MeshLib::Node*[T_ELEMENT::n_all_nodes]; for (unsigned k(0); k<T_ELEMENT::n_all_nodes; k++) ele_nodes[k] = nodes[node_ids->GetId(k)]; return new T_ELEMENT(ele_nodes); @@ -92,7 +92,7 @@ MeshLib::Mesh* VtkMeshConverter::convertUnstructuredGrid(vtkUnstructuredGrid* gr break; } case VTK_PIXEL: { - MeshLib::Node** quad_nodes = new MeshLib::Node*[4]; + auto** quad_nodes = new MeshLib::Node*[4]; quad_nodes[0] = nodes[node_ids->GetId(0)]; quad_nodes[1] = nodes[node_ids->GetId(1)]; quad_nodes[2] = nodes[node_ids->GetId(3)]; @@ -109,7 +109,7 @@ MeshLib::Mesh* VtkMeshConverter::convertUnstructuredGrid(vtkUnstructuredGrid* gr break; } case VTK_VOXEL: { - MeshLib::Node** voxel_nodes = new MeshLib::Node*[8]; + auto** voxel_nodes = new MeshLib::Node*[8]; voxel_nodes[0] = nodes[node_ids->GetId(0)]; voxel_nodes[1] = nodes[node_ids->GetId(1)]; voxel_nodes[2] = nodes[node_ids->GetId(3)]; @@ -126,7 +126,7 @@ MeshLib::Mesh* VtkMeshConverter::convertUnstructuredGrid(vtkUnstructuredGrid* gr break; } case VTK_WEDGE: { - MeshLib::Node** prism_nodes = new MeshLib::Node*[6]; + auto** prism_nodes = new MeshLib::Node*[6]; for (unsigned i=0; i<3; ++i) { prism_nodes[i] = nodes[node_ids->GetId(i+3)]; @@ -164,7 +164,7 @@ MeshLib::Mesh* VtkMeshConverter::convertUnstructuredGrid(vtkUnstructuredGrid* gr break; } case VTK_QUADRATIC_WEDGE: { - MeshLib::Node** prism_nodes = new MeshLib::Node*[15]; + auto** prism_nodes = new MeshLib::Node*[15]; for (unsigned i=0; i<3; ++i) { prism_nodes[i] = nodes[node_ids->GetId(i+3)]; @@ -197,17 +197,19 @@ MeshLib::Mesh* VtkMeshConverter::convertUnstructuredGrid(vtkUnstructuredGrid* gr void VtkMeshConverter::convertScalarArrays(vtkUnstructuredGrid &grid, MeshLib::Mesh &mesh) { vtkPointData* point_data = grid.GetPointData(); - unsigned const n_point_arrays = static_cast<unsigned>(point_data->GetNumberOfArrays()); + auto const n_point_arrays = + static_cast<unsigned>(point_data->GetNumberOfArrays()); for (unsigned i=0; i<n_point_arrays; ++i) convertArray(*point_data->GetArray(i), mesh.getProperties(), MeshLib::MeshItemType::Node); vtkCellData* cell_data = grid.GetCellData(); - unsigned const n_cell_arrays = static_cast<unsigned>(cell_data->GetNumberOfArrays()); + auto const n_cell_arrays = + static_cast<unsigned>(cell_data->GetNumberOfArrays()); for (unsigned i=0; i<n_cell_arrays; ++i) convertArray(*cell_data->GetArray(i), mesh.getProperties(), MeshLib::MeshItemType::Cell); vtkFieldData* field_data = grid.GetFieldData(); - unsigned const n_field_arrays = + auto const n_field_arrays = static_cast<unsigned>(field_data->GetNumberOfArrays()); for (unsigned i = 0; i < n_field_arrays; ++i) convertArray( diff --git a/MeshLib/MeshGenerators/VtkMeshConverter.h b/MeshLib/MeshGenerators/VtkMeshConverter.h index 704c28cb131a9be12be1c14a7a7756b8276d686d..591c0a1b0226756413ea4bba205744467d1041e2 100644 --- a/MeshLib/MeshGenerators/VtkMeshConverter.h +++ b/MeshLib/MeshGenerators/VtkMeshConverter.h @@ -111,7 +111,7 @@ private: return; } vec->reserve(nTuples*nComponents); - T* data_array = static_cast<T*>(array.GetVoidPointer(0)); + auto* data_array = static_cast<T*>(array.GetVoidPointer(0)); std::copy(&data_array[0], &data_array[nTuples*nComponents], std::back_inserter(*vec)); return; } diff --git a/MeshLib/MeshInformation.cpp b/MeshLib/MeshInformation.cpp index 33c5d92467e2e99fd3d87503dfed70a2a3ed27c9..3e78cc0d41d53def02efad5e0cc4f274afe2843e 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/MeshQuality/AngleSkewMetric.h b/MeshLib/MeshQuality/AngleSkewMetric.h index c7eee5a98e7fbd74f6a956c355bf812c8ecf7c3b..8cd75df309836fc0791ea3911e206970ed9b4c83 100644 --- a/MeshLib/MeshQuality/AngleSkewMetric.h +++ b/MeshLib/MeshQuality/AngleSkewMetric.h @@ -27,7 +27,7 @@ class AngleSkewMetric final : public ElementQualityMetric public: AngleSkewMetric(Mesh const& mesh); - void calculateQuality(); + void calculateQuality() override; private: double checkTriangle(Element const& elem) const; diff --git a/MeshLib/MeshQuality/EdgeRatioMetric.h b/MeshLib/MeshQuality/EdgeRatioMetric.h index f7198e88d92b0fa3fc2020885a3eb198ef1ddf26..e8c9a025c07c19960fd1f7e10b2c2bb79e2338a7 100644 --- a/MeshLib/MeshQuality/EdgeRatioMetric.h +++ b/MeshLib/MeshQuality/EdgeRatioMetric.h @@ -27,9 +27,9 @@ class EdgeRatioMetric : public ElementQualityMetric { public: EdgeRatioMetric(Mesh const& mesh); - virtual ~EdgeRatioMetric () {} + ~EdgeRatioMetric() override = default; - virtual void calculateQuality (); + void calculateQuality() override; private: double checkTriangle (MathLib::Point3d const& a, diff --git a/MeshLib/MeshQuality/ElementQualityMetric.h b/MeshLib/MeshQuality/ElementQualityMetric.h index 3cc2607c5415721e72d798b10646c48a72754071..90dd0deb904b674870a4092ea21a826d92d90a43 100644 --- a/MeshLib/MeshQuality/ElementQualityMetric.h +++ b/MeshLib/MeshQuality/ElementQualityMetric.h @@ -34,7 +34,7 @@ class ElementQualityMetric public: ElementQualityMetric(Mesh const& mesh); - virtual ~ElementQualityMetric () {} + virtual ~ElementQualityMetric() = default; /// Calculates the quality metric for each element of the mesh virtual void calculateQuality () = 0; diff --git a/MeshLib/MeshQuality/ElementSizeMetric.h b/MeshLib/MeshQuality/ElementSizeMetric.h index f7aa062f54c75302406fdfc31769e9c2fa63dce2..6f1dadb4e15507adad7a6e88de99934754b1d2e3 100644 --- a/MeshLib/MeshQuality/ElementSizeMetric.h +++ b/MeshLib/MeshQuality/ElementSizeMetric.h @@ -26,9 +26,9 @@ class ElementSizeMetric : public ElementQualityMetric { public: ElementSizeMetric(Mesh const& mesh); - virtual ~ElementSizeMetric() {} + ~ElementSizeMetric() override = default; - virtual void calculateQuality (); + void calculateQuality() override; private: std::size_t calc1dQuality(); diff --git a/MeshLib/MeshQuality/MeshValidation.cpp b/MeshLib/MeshQuality/MeshValidation.cpp index 5e26d233205ec4e172ef065b2a19ab4b8b0505a8..af673d8a3d1525e2bc98ff550f6cccb3619fcb26 100644 --- a/MeshLib/MeshQuality/MeshValidation.cpp +++ b/MeshLib/MeshQuality/MeshValidation.cpp @@ -50,7 +50,8 @@ MeshValidation::MeshValidation(MeshLib::Mesh &mesh) std::vector<ElementErrorCode> MeshValidation::testElementGeometry(const MeshLib::Mesh &mesh, double min_volume) { INFO ("Testing mesh element geometry:"); - const std::size_t nErrorCodes (static_cast<std::size_t>(ElementErrorFlag::MaxValue)); + const auto nErrorCodes( + static_cast<std::size_t>(ElementErrorFlag::MaxValue)); unsigned error_count[nErrorCodes]; std::fill_n(error_count, 4, 0); const std::size_t nElements (mesh.getNumberOfElements()); @@ -78,7 +79,8 @@ std::vector<ElementErrorCode> MeshValidation::testElementGeometry(const MeshLib: error_code_vector[i].set(ElementErrorFlag::ZeroVolume); // output - const unsigned error_sum (static_cast<unsigned>(std::accumulate(error_count, error_count+nErrorCodes, 0.0))); + const auto error_sum(static_cast<unsigned>( + std::accumulate(error_count, error_count + nErrorCodes, 0.0))); if (error_sum != 0) { ElementErrorFlag flags[nErrorCodes] = { ElementErrorFlag::ZeroVolume, ElementErrorFlag::NonCoplanar, @@ -95,28 +97,32 @@ std::vector<ElementErrorCode> MeshValidation::testElementGeometry(const MeshLib: std::array<std::string, static_cast<std::size_t>(ElementErrorFlag::MaxValue)> MeshValidation::ElementErrorCodeOutput(const std::vector<ElementErrorCode> &error_codes) { - const std::size_t nErrorFlags (static_cast<std::size_t>(ElementErrorFlag::MaxValue)); - ElementErrorFlag flags[nErrorFlags] = { ElementErrorFlag::ZeroVolume, ElementErrorFlag::NonCoplanar, - ElementErrorFlag::NonConvex, ElementErrorFlag::NodeOrder }; - const std::size_t nElements (error_codes.size()); - std::array<std::string, static_cast<std::size_t>(ElementErrorFlag::MaxValue)> output; - - for (std::size_t i=0; i<nErrorFlags; ++i) + const auto nErrorFlags( + static_cast<std::size_t>(ElementErrorFlag::MaxValue)); + ElementErrorFlag flags[nErrorFlags] = { + ElementErrorFlag::ZeroVolume, ElementErrorFlag::NonCoplanar, + ElementErrorFlag::NonConvex, ElementErrorFlag::NodeOrder}; + const std::size_t nElements(error_codes.size()); + std::array<std::string, + static_cast<std::size_t>(ElementErrorFlag::MaxValue)> + output; + + for (std::size_t i = 0; i < nErrorFlags; ++i) { unsigned count(0); std::string elementIdStr(""); - for (std::size_t j=0; j<nElements; ++j) + for (std::size_t j = 0; j < nElements; ++j) { if (error_codes[j][flags[i]]) { elementIdStr += (std::to_string(j) + ", "); count++; } - } const std::string nErrorsStr = (count) ? std::to_string(count) : "No"; - output[i] = (nErrorsStr + " elements found with " + ElementErrorCode::toString(flags[i]) + ".\n"); + output[i] = (nErrorsStr + " elements found with " + + ElementErrorCode::toString(flags[i]) + ".\n"); if (count) output[i] += ("ElementIDs: " + elementIdStr + "\n"); @@ -134,7 +140,7 @@ unsigned MeshValidation::detectHoles(MeshLib::Mesh const& mesh) std::vector<unsigned> sfc_idx (elements.size(), std::numeric_limits<unsigned>::max()); unsigned current_surface_id (0); - std::vector<unsigned>::const_iterator it = sfc_idx.cbegin(); + auto it = sfc_idx.cbegin(); while (it != sfc_idx.cend()) { diff --git a/MeshLib/MeshQuality/MeshValidation.h b/MeshLib/MeshQuality/MeshValidation.h index 391c226a2f59d4d407c731a1b3268ba8668fce76..b5d56c28671aa17c3ab22ad5e1aaa930c6b707bc 100644 --- a/MeshLib/MeshQuality/MeshValidation.h +++ b/MeshLib/MeshQuality/MeshValidation.h @@ -33,7 +33,7 @@ public: /// Constructor /// \warning This might change the mesh when removing unused mesh nodes. MeshValidation(MeshLib::Mesh &mesh); - ~MeshValidation() {} + ~MeshValidation() = default; /** * Tests if elements are geometrically correct. diff --git a/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h index da9fc775685270ff50d712faf4d497be1162dafc..f872557c4f6da53969c985f19a1f0f79e7ecea30 100644 --- a/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h +++ b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h @@ -27,8 +27,8 @@ class RadiusEdgeRatioMetric : public ElementQualityMetric { public: RadiusEdgeRatioMetric(Mesh const& mesh); - virtual ~RadiusEdgeRatioMetric() {} + ~RadiusEdgeRatioMetric() override = default; - virtual void calculateQuality (); + void calculateQuality() override; }; } diff --git a/MeshLib/MeshQuality/SizeDifferenceMetric.h b/MeshLib/MeshQuality/SizeDifferenceMetric.h index 399fd2385b534f26219190a4eaa9375c63087fac..b2470c33166a7855d95cd3b53cda16e8d4065895 100644 --- a/MeshLib/MeshQuality/SizeDifferenceMetric.h +++ b/MeshLib/MeshQuality/SizeDifferenceMetric.h @@ -27,8 +27,8 @@ class SizeDifferenceMetric : public ElementQualityMetric { public: SizeDifferenceMetric(Mesh const& mesh); - virtual ~SizeDifferenceMetric() {} + ~SizeDifferenceMetric() override = default; - virtual void calculateQuality (); + void calculateQuality() override; }; } diff --git a/MeshLib/MeshSearch/MeshElementGrid.cpp b/MeshLib/MeshSearch/MeshElementGrid.cpp index cf37745b088c45f07f0705b5b91f02deb110b86b..f7e6c1f4304ee25e96aa805d4b3a4a06b4263b03 100644 --- a/MeshLib/MeshSearch/MeshElementGrid.cpp +++ b/MeshLib/MeshSearch/MeshElementGrid.cpp @@ -233,34 +233,34 @@ void getGridGeometry(MeshElementGrid const& grid, new std::vector<GeoLib::Polyline*>); auto & points = *geometries.getPointVec(cell_names.back()); - GeoLib::Polyline* ply_bottom(new GeoLib::Polyline(points)); + auto* ply_bottom(new GeoLib::Polyline(points)); for (std::size_t l(0); l < 4; ++l) ply_bottom->addPoint(l); ply_bottom->addPoint(0); // close to bottom surface plys->push_back(ply_bottom); - GeoLib::Polyline* ply_top(new GeoLib::Polyline(points)); + auto* ply_top(new GeoLib::Polyline(points)); for (std::size_t l(4); l<8; ++l) ply_top->addPoint(l); ply_top->addPoint(4); // close to top surface plys->push_back(ply_top); - GeoLib::Polyline* ply_04(new GeoLib::Polyline(points)); + auto* ply_04(new GeoLib::Polyline(points)); ply_04->addPoint(0); ply_04->addPoint(4); plys->push_back(ply_04); - GeoLib::Polyline* ply_15(new GeoLib::Polyline(points)); + auto* ply_15(new GeoLib::Polyline(points)); ply_15->addPoint(1); ply_15->addPoint(5); plys->push_back(ply_15); - GeoLib::Polyline* ply_26(new GeoLib::Polyline(points)); + auto* ply_26(new GeoLib::Polyline(points)); ply_26->addPoint(2); ply_26->addPoint(6); plys->push_back(ply_26); - GeoLib::Polyline* ply_37(new GeoLib::Polyline(points)); + auto* ply_37(new GeoLib::Polyline(points)); ply_37->addPoint(3); ply_37->addPoint(7); plys->push_back(ply_37); diff --git a/MeshLib/MeshSubset.h b/MeshLib/MeshSubset.h index b10bae59627cf7dae4649391c4f7e19115b4c600..5dc343f08bc052eaa781f48c5ee98c1ea952957b 100644 --- a/MeshLib/MeshSubset.h +++ b/MeshLib/MeshSubset.h @@ -137,7 +137,7 @@ public: MeshSubset* getIntersectionByNodes(std::vector<Node*> const& nodes) const { - std::vector<Node*>* active_nodes = new std::vector<Node*>; + auto* active_nodes = new std::vector<Node*>; if (_nodes == nullptr || _nodes->empty()) return new MeshSubset(_msh, active_nodes); // Empty mesh subset diff --git a/MeshLib/MeshSurfaceExtraction.cpp b/MeshLib/MeshSurfaceExtraction.cpp index 8843b41ffca103cd309e4277617895befe7d2555..b478f489b725dd2f4c612f3bc0b73038a6aa8b03 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()); - MeshLib::Node** new_nodes = new MeshLib::Node*[n_elem_nodes]; + 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-impl.h b/MeshLib/Properties-impl.h index e42ba563c06f53306c577286105564f8f99dda89..5e61698e1099c62a5291a5280f88e8229bddca4e 100644 --- a/MeshLib/Properties-impl.h +++ b/MeshLib/Properties-impl.h @@ -77,8 +77,7 @@ PropertyVector<T>* Properties::createNewPropertyVector( template <typename T> bool Properties::existsPropertyVector(std::string const& name) const { - std::map<std::string, PropertyVectorBase*>::const_iterator it( - _properties.find(name)); + auto it(_properties.find(name)); // Check that a PropertyVector with the approriate name exists. if (it == _properties.end()) { @@ -92,8 +91,7 @@ template <typename T> PropertyVector<T> const* Properties::getPropertyVector( std::string const& name) const { - std::map<std::string, PropertyVectorBase*>::const_iterator it( - _properties.find(name)); + auto it(_properties.find(name)); if (it == _properties.end()) { OGS_FATAL( @@ -113,8 +111,7 @@ PropertyVector<T> const* Properties::getPropertyVector( template <typename T> PropertyVector<T>* Properties::getPropertyVector(std::string const& name) { - std::map<std::string, PropertyVectorBase*>::iterator it( - _properties.find(name)); + auto it(_properties.find(name)); if (it == _properties.end()) { OGS_FATAL( diff --git a/MeshLib/Properties.cpp b/MeshLib/Properties.cpp index ced0d5659dd4db0c6859266d2a4eb22eee631015..5baeb162975abab5fcd8126cacc6b516ffdda186 100644 --- a/MeshLib/Properties.cpp +++ b/MeshLib/Properties.cpp @@ -32,9 +32,7 @@ void Properties::removePropertyVector(std::string const& name) bool Properties::hasPropertyVector(std::string const& name) const { - std::map<std::string, PropertyVectorBase*>::const_iterator it( - _properties.find(name) - ); + auto it(_properties.find(name)); if (it == _properties.end()) { return false; } @@ -54,19 +52,20 @@ Properties Properties::excludeCopyProperties( std::vector<std::size_t> const& exclude_node_ids) const { Properties exclude_copy; - for (auto property_vector : _properties) { - if (property_vector.second->getMeshItemType() == MeshItemType::Cell) { - exclude_copy._properties.insert( - std::make_pair(property_vector.first, - property_vector.second->clone(exclude_elem_ids)) - ); + for (auto name_vector_pair : _properties) + { + if (name_vector_pair.second->getMeshItemType() == MeshItemType::Cell) + { + exclude_copy._properties.insert(std::make_pair( + name_vector_pair.first, + name_vector_pair.second->clone(exclude_elem_ids))); } - else if (property_vector.second->getMeshItemType() == MeshItemType::Node) + else if (name_vector_pair.second->getMeshItemType() == + MeshItemType::Node) { - exclude_copy._properties.insert( - std::make_pair(property_vector.first, - property_vector.second->clone(exclude_node_ids)) - ); + exclude_copy._properties.insert(std::make_pair( + name_vector_pair.first, + name_vector_pair.second->clone(exclude_node_ids))); } } return exclude_copy; @@ -76,18 +75,18 @@ Properties Properties::excludeCopyProperties( std::vector<MeshItemType> const& exclude_mesh_item_types) const { Properties new_properties; - for (auto property_vector : _properties) { + for (auto name_vector_pair : _properties) + { if (std::find(exclude_mesh_item_types.begin(), exclude_mesh_item_types.end(), - property_vector.second->getMeshItemType()) != + name_vector_pair.second->getMeshItemType()) != exclude_mesh_item_types.end()) continue; std::vector<std::size_t> const exclude_positions{}; new_properties._properties.insert( - std::make_pair(property_vector.first, - property_vector.second->clone(exclude_positions)) - ); + std::make_pair(name_vector_pair.first, + name_vector_pair.second->clone(exclude_positions))); } return new_properties; } @@ -96,16 +95,19 @@ 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& name_vector_pair : _properties) + { + PropertyVectorBase* t( + name_vector_pair.second->clone(exclude_positions)); + name_vector_pair.second = t; } } Properties::~Properties() { - for (auto property_vector : _properties) { - delete property_vector.second; + for (auto name_vector_pair : _properties) + { + delete name_vector_pair.second; } } diff --git a/MeshLib/Properties.h b/MeshLib/Properties.h index 9c10c6a5348e3e4cadbd6f80483b77c440288e59..f4fb71be825aa2c2e4a23d223fba3b461dc9a1f8 100644 --- a/MeshLib/Properties.h +++ b/MeshLib/Properties.h @@ -118,7 +118,7 @@ public: Properties excludeCopyProperties( std::vector<MeshItemType> const& exclude_mesh_item_types) const; - Properties() {} + Properties() = default; Properties(Properties const& properties); diff --git a/MeshLib/PropertyVector.h b/MeshLib/PropertyVector.h index 37b285ccf9d180a1648feb82fdbb59c03594b284..a7ed674afee0c57748ea4959ff2072651d0bed92 100644 --- a/MeshLib/PropertyVector.h +++ b/MeshLib/PropertyVector.h @@ -14,6 +14,7 @@ #include <iterator> #include <ostream> #include <string> +#include <utility> #include <vector> #include "BaseLib/Error.h" @@ -35,12 +36,12 @@ public: std::size_t getNumberOfComponents() const { return _n_components; } protected: - PropertyVectorBase(std::string const& property_name, + PropertyVectorBase(std::string property_name, MeshItemType mesh_item_type, std::size_t n_components) : _n_components(n_components), _mesh_item_type(mesh_item_type), - _property_name(property_name) + _property_name(std::move(property_name)) {} std::size_t const _n_components; @@ -84,9 +85,9 @@ public: } PropertyVectorBase* clone( - std::vector<std::size_t> const& exclude_positions) const + std::vector<std::size_t> const& exclude_positions) const override { - PropertyVector<PROP_VAL_TYPE>* t(new PropertyVector<PROP_VAL_TYPE>( + auto* t(new PropertyVector<PROP_VAL_TYPE>( _property_name, _mesh_item_type, _n_components)); BaseLib::excludeObjectCopy(*this, exclude_positions, *t); return t; @@ -143,7 +144,7 @@ class PropertyVector<T*> : public std::vector<std::size_t>, friend class Properties; public: /// Destructor ensures the deletion of the heap-constructed objects. - ~PropertyVector() + ~PropertyVector() override { for (auto v : _values) delete [] v; @@ -166,7 +167,7 @@ public: if (_n_components != 1) OGS_FATAL("Single-component version of initPropertyValue() is called " "for a multi-components PropertyVector<T*>"); - T* p = new T[1]; + auto* p = new T[1]; p[0] = value; _values[group_id] = p; } @@ -177,7 +178,7 @@ public: OGS_FATAL("The size of provided values in initPropertyValue() is " "not same as the number of components in PropertyVector<T*>"); - T* p = new T[values.size()]; + auto* p = new T[values.size()]; for (unsigned i=0; i<values.size(); i++) p[i] = values[i]; _values[group_id] = p; @@ -194,7 +195,8 @@ public: return _n_components * std::vector<std::size_t>::size(); } - PropertyVectorBase* clone(std::vector<std::size_t> const& exclude_positions) const + PropertyVectorBase* clone( + std::vector<std::size_t> const& exclude_positions) const override { // create new PropertyVector with modified mapping PropertyVector<T*> *t(new PropertyVector<T*> @@ -254,11 +256,12 @@ protected: /// nodes or cells (see enumeration MeshItemType) /// @param n_components the number of elements of a tuple PropertyVector(std::size_t n_prop_groups, - std::vector<std::size_t> const& item2group_mapping, + std::vector<std::size_t> + item2group_mapping, std::string const& property_name, MeshItemType mesh_item_type, std::size_t n_components) - : std::vector<std::size_t>(item2group_mapping), + : std::vector<std::size_t>(std::move(item2group_mapping)), PropertyVectorBase(property_name, mesh_item_type, n_components), _values(n_prop_groups * n_components) {} diff --git a/MeshLib/Vtk/VtkMappedMeshSource.cpp b/MeshLib/Vtk/VtkMappedMeshSource.cpp index dcb2bb5ddd5feca92881201504b1535ba152596f..cb85f45ec12e383d76199ac9f13053758bd4ad98 100644 --- a/MeshLib/Vtk/VtkMappedMeshSource.cpp +++ b/MeshLib/Vtk/VtkMappedMeshSource.cpp @@ -31,7 +31,7 @@ namespace MeshLib { vtkStandardNewMacro(VtkMappedMeshSource) -void VtkMappedMeshSource::PrintSelf(std::ostream& os, vtkIndent indent) + void VtkMappedMeshSource::PrintSelf(std::ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); os << indent << "Mesh: " << (_mesh ? _mesh->getName() : "(none)") << endl; @@ -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); @@ -130,8 +130,7 @@ int VtkMappedMeshSource::RequestData(vtkInformation*, std::vector<std::string> const& propertyNames = properties.getPropertyVectorNames(); - for (std::vector<std::string>::const_iterator name = propertyNames.cbegin(); - name != propertyNames.cend(); + for (auto name = propertyNames.cbegin(); name != propertyNames.cend(); ++name) { if (addProperty<double>(properties, *name)) diff --git a/MeshLib/Vtk/VtkMappedMeshSource.h b/MeshLib/Vtk/VtkMappedMeshSource.h index 7fd70610a86a7b11b8a7b0782a18b944a6ae9027..d4443fe15982b8099d9c9f838946ea78fdebbc2d 100644 --- a/MeshLib/Vtk/VtkMappedMeshSource.h +++ b/MeshLib/Vtk/VtkMappedMeshSource.h @@ -72,8 +72,9 @@ protected: vtkInformationVector*) override; private: - VtkMappedMeshSource(const VtkMappedMeshSource&); // Not implemented. - void operator=(const VtkMappedMeshSource&); // Not implemented. + VtkMappedMeshSource(const VtkMappedMeshSource&) = + delete; // Not implemented. + void operator=(const VtkMappedMeshSource&) = delete; // Not implemented. /// Adds a zero-copy vtk array wrapper. /// \param properties MeshLib::Properties object diff --git a/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate-impl.h b/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate-impl.h index 0d4364d08f994fee67d7ce08424297ec5a044a8f..1627200757e8a6d5fe19af1aae4958d199efc2d2 100644 --- a/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate-impl.h +++ b/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate-impl.h @@ -44,9 +44,9 @@ template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::Initialize() { - this->_nodes = NULL; + this->_nodes = nullptr; delete [] this->TempDoubleArray; - this->TempDoubleArray = NULL; + this->TempDoubleArray = nullptr; this->MaxId = -1; this->Size = 0; this->NumberOfComponents = 1; @@ -114,7 +114,7 @@ template <class Scalar> vtkArrayIterator* VtkMeshNodalCoordinatesTemplate<Scalar ::NewIterator() { vtkErrorMacro(<<"Not implemented."); - return NULL; + return nullptr; } template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> @@ -373,9 +373,9 @@ template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> return; } -template <class Scalar> VtkMeshNodalCoordinatesTemplate<Scalar> -::VtkMeshNodalCoordinatesTemplate() - : _nodes(NULL), TempDoubleArray(NULL) +template <class Scalar> +VtkMeshNodalCoordinatesTemplate<Scalar>::VtkMeshNodalCoordinatesTemplate() + : _nodes(nullptr), TempDoubleArray(nullptr) { } diff --git a/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate.h b/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate.h index 350736b8f0b20ee31a819e9c7eb6f54fdad9a3b3..b0c01f0508e894f71a1552de113fed66aae7542d 100644 --- a/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate.h +++ b/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate.h @@ -47,7 +47,7 @@ public: vtkMappedDataArrayNewInstanceMacro(VtkMeshNodalCoordinatesTemplate<Scalar>); #endif // vtk version static VtkMeshNodalCoordinatesTemplate *New(); - virtual void PrintSelf(std::ostream &os, vtkIndent indent) override; + void PrintSelf(std::ostream& os, vtkIndent indent) override; /// Pass the nodes from OGS mesh void SetNodes(std::vector<MeshLib::Node*> const & nodes); @@ -117,14 +117,15 @@ public: protected: VtkMeshNodalCoordinatesTemplate(); - ~VtkMeshNodalCoordinatesTemplate(); + ~VtkMeshNodalCoordinatesTemplate() override; const std::vector<MeshLib::Node*>* _nodes; private: // Not implemented - VtkMeshNodalCoordinatesTemplate(const VtkMeshNodalCoordinatesTemplate &); - void operator=(const VtkMeshNodalCoordinatesTemplate &); + VtkMeshNodalCoordinatesTemplate(const VtkMeshNodalCoordinatesTemplate&) = + delete; + void operator=(const VtkMeshNodalCoordinatesTemplate&) = delete; vtkIdType Lookup(const Scalar &val, vtkIdType startIndex); double *TempDoubleArray; diff --git a/MeshLib/convertMeshToGeo.cpp b/MeshLib/convertMeshToGeo.cpp index 7b1f2b2562b1376173f66d7bedbf61fc9299d0bd..23d880bae577f9160426760ae2b3c206de0c1518 100644 --- a/MeshLib/convertMeshToGeo.cpp +++ b/MeshLib/convertMeshToGeo.cpp @@ -99,7 +99,7 @@ MeshLib::Mesh* convertSurfaceToMesh(const GeoLib::Surface &sfc, const std::strin for (std::size_t i=0; i<sfc.getNumberOfTriangles(); i++) { auto* tri = sfc[i]; - MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; + auto** tri_nodes = new MeshLib::Node*[3]; for (unsigned j=0; j<3; j++) tri_nodes[j] = new MeshLib::Node(tri->getPoint(j)->getCoords(), nodeId++); elements.push_back(new MeshLib::Tri(tri_nodes, i)); diff --git a/NumLib/DOF/ComponentGlobalIndexDict.h b/NumLib/DOF/ComponentGlobalIndexDict.h index e844601c7e2af75f482f33e43485a45cc1cb572a..f67d1adaa94fba27748cc0c8c44f4e88c7fa2c8d 100644 --- a/NumLib/DOF/ComponentGlobalIndexDict.h +++ b/NumLib/DOF/ComponentGlobalIndexDict.h @@ -18,6 +18,7 @@ #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index_container.hpp> +#include <utility> #include "MeshLib/Location.h" #include "NumLib/NumericsConfig.h" @@ -39,19 +40,20 @@ struct Line // Position in global matrix or vector GlobalIndexType global_index; - Line(MeshLib::Location const& l, std::size_t c, GlobalIndexType i) - : location(l), comp_id(c), global_index(i) + Line(MeshLib::Location l, std::size_t c, GlobalIndexType i) + : location(std::move(l)), comp_id(c), global_index(i) {} - Line(MeshLib::Location const& l, std::size_t c) - : location(l), comp_id(c), - global_index(std::numeric_limits<GlobalIndexType>::max()) + Line(MeshLib::Location l, std::size_t c) + : location(std::move(l)), + comp_id(c), + global_index(std::numeric_limits<GlobalIndexType>::max()) {} - explicit Line(MeshLib::Location const& l) - : location(l), - comp_id(std::numeric_limits<std::size_t>::max()), - global_index(std::numeric_limits<GlobalIndexType>::max()) + explicit Line(MeshLib::Location l) + : location(std::move(l)), + comp_id(std::numeric_limits<std::size_t>::max()), + global_index(std::numeric_limits<GlobalIndexType>::max()) {} friend std::ostream& operator<<(std::ostream& os, Line const& l) @@ -87,34 +89,23 @@ struct ByLocationAndComponent {}; struct ByComponent {}; struct ByGlobalIndex {}; -typedef boost::multi_index::multi_index_container< - Line, - boost::multi_index::indexed_by - < - boost::multi_index::ordered_unique - < - boost::multi_index::tag<ByLocationAndComponent>, - boost::multi_index::identity<Line>, - LineByLocationAndComponentComparator - >, - boost::multi_index::ordered_non_unique - < - boost::multi_index::tag<ByLocation>, - boost::multi_index::identity<Line>, - LineByLocationComparator - >, - boost::multi_index::ordered_non_unique - < - boost::multi_index::tag<ByComponent>, - boost::multi_index::member<Line, std::size_t, &Line::comp_id> - >, - boost::multi_index::ordered_non_unique - < - boost::multi_index::tag<ByGlobalIndex>, - boost::multi_index::member<Line, GlobalIndexType, &Line::global_index> - > - > - > ComponentGlobalIndexDict; +using ComponentGlobalIndexDict = boost::multi_index::multi_index_container< + Line, + boost::multi_index::indexed_by< + boost::multi_index::ordered_unique< + boost::multi_index::tag<ByLocationAndComponent>, + boost::multi_index::identity<Line>, + LineByLocationAndComponentComparator>, + boost::multi_index::ordered_non_unique< + boost::multi_index::tag<ByLocation>, + boost::multi_index::identity<Line>, LineByLocationComparator>, + boost::multi_index::ordered_non_unique< + boost::multi_index::tag<ByComponent>, + boost::multi_index::member<Line, std::size_t, &Line::comp_id>>, + boost::multi_index::ordered_non_unique< + boost::multi_index::tag<ByGlobalIndex>, + boost::multi_index::member<Line, GlobalIndexType, + &Line::global_index>>>>; } // namespace detail } // namespace NumLib diff --git a/NumLib/DOF/LocalToGlobalIndexMap.h b/NumLib/DOF/LocalToGlobalIndexMap.h index a5357bbb66836f5c5e1e78ba4e84a29680cfd144..8bfadc2191e1d53d30b820c725c660ca71cb7727 100644 --- a/NumLib/DOF/LocalToGlobalIndexMap.h +++ b/NumLib/DOF/LocalToGlobalIndexMap.h @@ -37,8 +37,8 @@ namespace NumLib class LocalToGlobalIndexMap final { public: - typedef MathLib::RowColumnIndices<GlobalIndexType> RowColumnIndices; - typedef RowColumnIndices::LineIndex LineIndex; + using RowColumnIndices = MathLib::RowColumnIndices<GlobalIndexType>; + using LineIndex = RowColumnIndices::LineIndex; public: /// Creates a MeshComponentMap internally and stores the global indices for diff --git a/NumLib/DOF/MeshComponentMap.cpp b/NumLib/DOF/MeshComponentMap.cpp index 401a383447657c947db61b007cc15e044fb9f04a..700767359373bd8e48c5448dd9d90ea530e235b8 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); } @@ -248,15 +248,15 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByComponent( std::vector<Location> const& ls) const { // vector of (Component, global Index) pairs. - typedef std::pair<std::size_t, GlobalIndexType> CIPair; + using CIPair = std::pair<std::size_t, GlobalIndexType>; std::vector<CIPair> pairs; pairs.reserve(ls.size()); // 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/NumLib/DOF/MeshComponentMap.h b/NumLib/DOF/MeshComponentMap.h index 9248a7461582397a83c271ef48d4b3dfe1484ac4..e4402cc7813055b34479cb47822852259cbed6cd 100644 --- a/NumLib/DOF/MeshComponentMap.h +++ b/NumLib/DOF/MeshComponentMap.h @@ -33,7 +33,8 @@ enum class ComponentOrder class MeshComponentMap final { public: - typedef MeshLib::Location Location; + using Location = MeshLib::Location; + public: /// \param components a vector of components /// \param order type of ordering values in a vector diff --git a/NumLib/DOF/SimpleMatrixVectorProvider.h b/NumLib/DOF/SimpleMatrixVectorProvider.h index c288742d2009fb2dbe71f3853169b0f806b66152..8f4ade72e7d2a90fd87705cfa55860f5f3ddcaa5 100644 --- a/NumLib/DOF/SimpleMatrixVectorProvider.h +++ b/NumLib/DOF/SimpleMatrixVectorProvider.h @@ -57,7 +57,7 @@ public: void releaseMatrix(GlobalMatrix const& A) override; - ~SimpleMatrixVectorProvider(); + ~SimpleMatrixVectorProvider() override; private: template<bool do_search, typename... Args> diff --git a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp index 26d97f7b7e85a378194f1914abd3c55c473924b9..5a53d633d54312048fa5afe8fad952f234ac5f77 100644 --- a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp +++ b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp @@ -88,7 +88,7 @@ void LocalLinearLeastSquaresExtrapolator::extrapolateElement( element_index, _integration_point_values_cache); auto const& N_0 = extrapolatables.getShapeMatrix(element_index, 0); - const unsigned num_nodes = static_cast<unsigned>(N_0.cols()); + const auto num_nodes = static_cast<unsigned>(N_0.cols()); const unsigned num_int_pts = integration_point_values.size(); assert(num_int_pts >= num_nodes && diff --git a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.h b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.h index a5f58e2910bc59c252a9e8475fa05cf4e02fb5d0..aa8929267d47411a80203c52aec28ee973a1013e 100644 --- a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.h +++ b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.h @@ -71,7 +71,7 @@ public: return _residuals; } - ~LocalLinearLeastSquaresExtrapolator() + ~LocalLinearLeastSquaresExtrapolator() override { NumLib::GlobalVectorProvider::provider.releaseVector( _nodal_values); diff --git a/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h b/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h index a74020f82594ff248a3c78146b0da097c68990db..486665226de2b6d97d5f2af407ba68da1bccbb16 100644 --- a/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h +++ b/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h @@ -42,10 +42,10 @@ enum class ShapeMatrixType template <class T_N, class T_DNDR, class T_J, class T_DNDX> struct ShapeMatrices { - typedef T_N ShapeType; - typedef T_DNDR DrShapeType; - typedef T_J JacobianType; - typedef T_DNDX DxShapeType; + using ShapeType = T_N; + using DrShapeType = T_DNDR; + using JacobianType = T_J; + using DxShapeType = T_DNDX; ShapeType N; ///< Vector of shape functions, N(r) DrShapeType dNdr; ///< Matrix of gradient of shape functions in natural coordinates, dN(r)/dr diff --git a/NumLib/Fem/FiniteElement/C0IsoparametricElements.h b/NumLib/Fem/FiniteElement/C0IsoparametricElements.h index 52b865bcec054a5a75c2b897cfc0b2cf425066fb..e10608059f248d5a16bce7cb4c56e04566066b46 100644 --- a/NumLib/Fem/FiniteElement/C0IsoparametricElements.h +++ b/NumLib/Fem/FiniteElement/C0IsoparametricElements.h @@ -33,101 +33,116 @@ namespace NumLib { - template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FePOINT1 { - typedef TemplateIsoparametric<ShapePoint1, T_SHAPE_MATRIX_POLICY<ShapePoint1>> type; + using type = + TemplateIsoparametric<ShapePoint1, T_SHAPE_MATRIX_POLICY<ShapePoint1>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeLINE2 { - typedef TemplateIsoparametric<ShapeLine2, T_SHAPE_MATRIX_POLICY<ShapeLine2>> type; + using type = + TemplateIsoparametric<ShapeLine2, T_SHAPE_MATRIX_POLICY<ShapeLine2>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeLINE3 { - typedef TemplateIsoparametric<ShapeLine3, T_SHAPE_MATRIX_POLICY<ShapeLine3>> type; + using type = + TemplateIsoparametric<ShapeLine3, T_SHAPE_MATRIX_POLICY<ShapeLine3>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeTRI3 { - typedef TemplateIsoparametric<ShapeTri3, T_SHAPE_MATRIX_POLICY<ShapeTri3>> type; + using type = + TemplateIsoparametric<ShapeTri3, T_SHAPE_MATRIX_POLICY<ShapeTri3>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeTRI6 { - typedef TemplateIsoparametric<ShapeTri6, T_SHAPE_MATRIX_POLICY<ShapeTri6>> type; + using type = + TemplateIsoparametric<ShapeTri6, T_SHAPE_MATRIX_POLICY<ShapeTri6>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeQUAD4 { - typedef TemplateIsoparametric<ShapeQuad4, T_SHAPE_MATRIX_POLICY<ShapeQuad4>> type; + using type = + TemplateIsoparametric<ShapeQuad4, T_SHAPE_MATRIX_POLICY<ShapeQuad4>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeQUAD8 { - typedef TemplateIsoparametric<ShapeQuad8, T_SHAPE_MATRIX_POLICY<ShapeQuad8>> type; + using type = + TemplateIsoparametric<ShapeQuad8, T_SHAPE_MATRIX_POLICY<ShapeQuad8>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeQUAD9 { - typedef TemplateIsoparametric<ShapeQuad9, T_SHAPE_MATRIX_POLICY<ShapeQuad9>> type; + using type = + TemplateIsoparametric<ShapeQuad9, T_SHAPE_MATRIX_POLICY<ShapeQuad9>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeHEX8 { - typedef TemplateIsoparametric<ShapeHex8, T_SHAPE_MATRIX_POLICY<ShapeHex8>> type; + using type = + TemplateIsoparametric<ShapeHex8, T_SHAPE_MATRIX_POLICY<ShapeHex8>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeHEX20 { - typedef TemplateIsoparametric<ShapeHex20, T_SHAPE_MATRIX_POLICY<ShapeHex20>> type; + using type = + TemplateIsoparametric<ShapeHex20, T_SHAPE_MATRIX_POLICY<ShapeHex20>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeTET4 { - typedef TemplateIsoparametric<ShapeTet4, T_SHAPE_MATRIX_POLICY<ShapeTet4>> type; + using type = + TemplateIsoparametric<ShapeTet4, T_SHAPE_MATRIX_POLICY<ShapeTet4>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FeTET10 { - typedef TemplateIsoparametric<ShapeTet10, T_SHAPE_MATRIX_POLICY<ShapeTet10>> type; + using type = + TemplateIsoparametric<ShapeTet10, T_SHAPE_MATRIX_POLICY<ShapeTet10>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FePRISM6 { - typedef TemplateIsoparametric<ShapePrism6, T_SHAPE_MATRIX_POLICY<ShapePrism6>> type; + using type = + TemplateIsoparametric<ShapePrism6, T_SHAPE_MATRIX_POLICY<ShapePrism6>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FePRISM15 { - typedef TemplateIsoparametric<ShapePrism15, T_SHAPE_MATRIX_POLICY<ShapePrism15>> type; + using type = TemplateIsoparametric<ShapePrism15, + T_SHAPE_MATRIX_POLICY<ShapePrism15>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FePYRA5 { - typedef TemplateIsoparametric<ShapePyra5, T_SHAPE_MATRIX_POLICY<ShapePyra5>> type; + using type = + TemplateIsoparametric<ShapePyra5, T_SHAPE_MATRIX_POLICY<ShapePyra5>>; }; template <template <typename> class T_SHAPE_MATRIX_POLICY> struct FePYRA13 { - typedef TemplateIsoparametric<ShapePyra13, T_SHAPE_MATRIX_POLICY<ShapePyra13>> type; + using type = + TemplateIsoparametric<ShapePyra13, T_SHAPE_MATRIX_POLICY<ShapePyra13>>; }; } // NumLib diff --git a/NumLib/Fem/FiniteElement/TemplateIsoparametric.h b/NumLib/Fem/FiniteElement/TemplateIsoparametric.h index a62e301d3988bd40674c7aad45490856f7162f25..854c1e1f7f61fe51bdaba2120f0510ade5143790 100644 --- a/NumLib/Fem/FiniteElement/TemplateIsoparametric.h +++ b/NumLib/Fem/FiniteElement/TemplateIsoparametric.h @@ -64,8 +64,7 @@ public: : _ele(&e) { } - - ~TemplateIsoparametric() {} + ~TemplateIsoparametric() = default; /// return current mesh element const MeshElementType* getMeshElement() const {return _ele;} diff --git a/NumLib/Fem/Integration/IntegrationGaussPrism.h b/NumLib/Fem/Integration/IntegrationGaussPrism.h index f2fdb573b6f18edb261b0b88f60816525a9f54c8..0e0b6d32f9f0bd3b819bcae99ca463190b50d680 100644 --- a/NumLib/Fem/Integration/IntegrationGaussPrism.h +++ b/NumLib/Fem/Integration/IntegrationGaussPrism.h @@ -20,8 +20,8 @@ namespace NumLib */ class IntegrationGaussPrism { - typedef MathLib::TemplateWeightedPoint<double, double, 3> - WeightedPoint; + using WeightedPoint = MathLib::TemplateWeightedPoint<double, double, 3>; + public: /** * Construct this object with the given integration order @@ -59,7 +59,7 @@ public: { (void)order; const unsigned gp_r = igp % 3; - const unsigned gp_t = (unsigned)(igp/3); + const auto gp_t = (unsigned)(igp / 3); std::array<double, 3> rst; rst[0] = MathLib::GaussLegendreTri<2>::X[gp_r][0]; rst[1] = MathLib::GaussLegendreTri<2>::X[gp_r][1]; diff --git a/NumLib/Fem/Integration/IntegrationGaussPyramid.h b/NumLib/Fem/Integration/IntegrationGaussPyramid.h index d8e0707f47c7503b9c74b0b097335381e3cba7d3..850c2bb3dd7873adb245aaa5784f21de682ce049 100644 --- a/NumLib/Fem/Integration/IntegrationGaussPyramid.h +++ b/NumLib/Fem/Integration/IntegrationGaussPyramid.h @@ -19,8 +19,8 @@ namespace NumLib */ class IntegrationGaussPyramid { - typedef MathLib::TemplateWeightedPoint<double, double, 3> - WeightedPoint; + using WeightedPoint = MathLib::TemplateWeightedPoint<double, double, 3>; + public: /** * Construct this object with the given integration order diff --git a/NumLib/Fem/Integration/IntegrationGaussRegular.h b/NumLib/Fem/Integration/IntegrationGaussRegular.h index 750ccf06dd63d815366f570187d3167b563dcab4..507374ed3d8732dc15195dc11d53851fb2833cfd 100644 --- a/NumLib/Fem/Integration/IntegrationGaussRegular.h +++ b/NumLib/Fem/Integration/IntegrationGaussRegular.h @@ -28,8 +28,9 @@ namespace NumLib template <unsigned N_DIM> class IntegrationGaussRegular { - typedef typename MathLib::TemplateWeightedPoint<double, double, N_DIM> - WeightedPoint; + using WeightedPoint = + typename MathLib::TemplateWeightedPoint<double, double, N_DIM>; + public: /// Create IntegrationGaussRegular of the given Gauss-Legendre integration /// order. diff --git a/NumLib/Fem/Integration/IntegrationGaussTet.h b/NumLib/Fem/Integration/IntegrationGaussTet.h index 29e93014463c5580661f19d71343bd8fe756bf23..8b50c03847780f09eb892231ddff67ab09dbf5f8 100644 --- a/NumLib/Fem/Integration/IntegrationGaussTet.h +++ b/NumLib/Fem/Integration/IntegrationGaussTet.h @@ -19,8 +19,8 @@ namespace NumLib */ class IntegrationGaussTet { - typedef MathLib::TemplateWeightedPoint<double, double, 3> - WeightedPoint; + using WeightedPoint = MathLib::TemplateWeightedPoint<double, double, 3>; + public: /** * Construct this object with the given integration order diff --git a/NumLib/Fem/Integration/IntegrationGaussTri.h b/NumLib/Fem/Integration/IntegrationGaussTri.h index 6d66790dd88db22b1297af49c1d5e2f626db3e52..d9a66480655a092046fd31ab0d3b35c673a15394 100644 --- a/NumLib/Fem/Integration/IntegrationGaussTri.h +++ b/NumLib/Fem/Integration/IntegrationGaussTri.h @@ -35,8 +35,8 @@ namespace NumLib */ class IntegrationGaussTri { - typedef MathLib::TemplateWeightedPoint<double, double, 2> - WeightedPoint; + using WeightedPoint = MathLib::TemplateWeightedPoint<double, double, 2>; + public: /** * Construct this object with the given integration order diff --git a/NumLib/Fem/Integration/IntegrationPoint.h b/NumLib/Fem/Integration/IntegrationPoint.h index eaaee68924b0d5271675d6bad3e15e0d8024b54e..fcc2bb816064c138692dc1d0a6a6c789841bac28 100644 --- a/NumLib/Fem/Integration/IntegrationPoint.h +++ b/NumLib/Fem/Integration/IntegrationPoint.h @@ -17,7 +17,7 @@ namespace NumLib /// It is only needed to satisfy the common integration rule concepts. class IntegrationPoint { - typedef MathLib::TemplateWeightedPoint<double, double, 1> WeightedPoint; + using WeightedPoint = MathLib::TemplateWeightedPoint<double, double, 1>; public: /// IntegrationPoint constructor for given order. diff --git a/NumLib/Function/ISpatialFunction.h b/NumLib/Function/ISpatialFunction.h index 0d3b37ab76b31c7c5216e3085cbc4f637d261d0a..11159263eec7eeccda136c4b649d6f457bf0cc2e 100644 --- a/NumLib/Function/ISpatialFunction.h +++ b/NumLib/Function/ISpatialFunction.h @@ -25,7 +25,7 @@ namespace NumLib class ISpatialFunction { public: - virtual ~ISpatialFunction(){} + virtual ~ISpatialFunction() = default; /** * return a value at the given point diff --git a/NumLib/Function/LinearInterpolationAlongPolyline.h b/NumLib/Function/LinearInterpolationAlongPolyline.h index 1e214df96f6fcc9329e2ad3c78dcb87e499c2616..db1143bbc0599ea41647073d93aab37eadac80a3 100644 --- a/NumLib/Function/LinearInterpolationAlongPolyline.h +++ b/NumLib/Function/LinearInterpolationAlongPolyline.h @@ -56,7 +56,7 @@ public: * @return interpolated value. A default value is returned if the given point * is not located on a polyline */ - double operator()(const MathLib::Point3d& pnt) const; + double operator()(const MathLib::Point3d& pnt) const override; private: /// construct an interpolation algorithm diff --git a/NumLib/Function/LinearInterpolationOnSurface.h b/NumLib/Function/LinearInterpolationOnSurface.h index 6529d273985fcddfde59937b39d24ad9de2d1df0..fb7c94f65d9c2556bee7d0b0430ae572d5ae9ab2 100644 --- a/NumLib/Function/LinearInterpolationOnSurface.h +++ b/NumLib/Function/LinearInterpolationOnSurface.h @@ -55,7 +55,7 @@ public: * @return interpolated value. A default value is returned if the given point * is not located on a surface */ - double operator()(const MathLib::Point3d& pnt) const; + double operator()(const MathLib::Point3d& pnt) const override; private: /// rotate a triangle to XY plane diff --git a/NumLib/Function/SpatialFunctionLinear.h b/NumLib/Function/SpatialFunctionLinear.h index d8975b58b972149dec0abf73dac0ddf47b55e381..780cf791647aa8971b539c1d1e47927769e208fb 100644 --- a/NumLib/Function/SpatialFunctionLinear.h +++ b/NumLib/Function/SpatialFunctionLinear.h @@ -19,6 +19,6 @@ namespace NumLib { /// Representation of linear functions f: R^3 -> R; f({x, y, z}) = a + bx + cy + dz -typedef TemplateSpatialFunction<MathLib::LinearFunction<double, 3> > SpatialFunctionLinear; - +using SpatialFunctionLinear = + TemplateSpatialFunction<MathLib::LinearFunction<double, 3>>; } diff --git a/NumLib/Function/TemplateSpatialFunction.h b/NumLib/Function/TemplateSpatialFunction.h index 8b372e1d64330cb2bcd3a1c8ce984e80896cae9a..209007687927807e772eddff9fe35afee5a9165f 100644 --- a/NumLib/Function/TemplateSpatialFunction.h +++ b/NumLib/Function/TemplateSpatialFunction.h @@ -12,6 +12,8 @@ #pragma once +#include <utility> + #include "ISpatialFunction.h" namespace NumLib @@ -30,15 +32,13 @@ public: * Constructor * @param f a function object */ - TemplateSpatialFunction(const T_FUNCTION &f) - : _f(f) {} - + TemplateSpatialFunction(T_FUNCTION f) : _f(std::move(f)) {} /** * evaluate a function * @param pnt a point object * @return evaluated value */ - virtual double operator()(const MathLib::Point3d& pnt) const + double operator()(const MathLib::Point3d& pnt) const override { return _f(pnt.getCoords()); } diff --git a/NumLib/NamedFunction.cpp b/NumLib/NamedFunction.cpp index 36e952cc375e747e2b227a1c361db10f9ec76174..b0111828cb795a1e85640bfc8444a540d02cf01b 100644 --- a/NumLib/NamedFunction.cpp +++ b/NumLib/NamedFunction.cpp @@ -33,7 +33,7 @@ double call_(void* function, std::vector<double> const& arguments) return (*fct)(args[Indices]...); } -typedef double (*CallerFunction) (void*, std::vector<double> const&); +using CallerFunction = double (*)(void*, const std::vector<double>&); //! Helps instantiating the call_() function. template <int... Indices> @@ -82,7 +82,7 @@ void delete_(void* function) delete fct; } -typedef void (*DeleterFunction) (void*); +using DeleterFunction = void (*)(void*); //! Helps instantiating the delete_() function. template <int... Indices> @@ -131,7 +131,7 @@ void* copy_(void* function) return new std::function<double(typename Double<Indices>::type...)>(*fct); } -typedef void* (*CopierFunction) (void*); +using CopierFunction = void* (*)(void*); //! Helps instantiating the copy_() function. template <int... Indices> diff --git a/NumLib/NamedFunction.h b/NumLib/NamedFunction.h index bea46bac736816048215cd8e63b55f50940f2e1a..a8771d1e53f2bd3a7b791233932f6dbbc11d9aee 100644 --- a/NumLib/NamedFunction.h +++ b/NumLib/NamedFunction.h @@ -14,6 +14,7 @@ #include <memory> #include <string> #include <type_traits> +#include <utility> #include <vector> namespace detail @@ -57,7 +58,7 @@ public: * \param function the actual function object */ template <typename ReturnType, typename... Arguments> - NamedFunction(std::string const& name, + NamedFunction(std::string name, std::vector<std::string>&& argument_names, std::function<ReturnType(Arguments...)>&& function); @@ -92,10 +93,10 @@ private: }; template <typename ReturnType, typename... Arguments> -NamedFunction::NamedFunction(std::string const& name, +NamedFunction::NamedFunction(std::string name, std::vector<std::string>&& argument_names, std::function<ReturnType(Arguments...)>&& function) - : _name(name), + : _name(std::move(name)), _argument_names(std::move(argument_names)), _function( new std::function<ReturnType(Arguments...)>(std::move(function))) diff --git a/NumLib/ODESolver/MatrixTranslator.h b/NumLib/ODESolver/MatrixTranslator.h index f4edf65943bf5aa0acfd6749b24ebefbdee25ec2..7565730d762354841c340e2d49c3b4a216a2b6a1 100644 --- a/NumLib/ODESolver/MatrixTranslator.h +++ b/NumLib/ODESolver/MatrixTranslator.h @@ -224,7 +224,7 @@ public: { } - ~MatrixTranslatorCrankNicolson() + ~MatrixTranslatorCrankNicolson() override { NumLib::GlobalMatrixProvider::provider.releaseMatrix( _M_bar); diff --git a/NumLib/ODESolver/TimeDiscretization.h b/NumLib/ODESolver/TimeDiscretization.h index ea6dd2ec6b641dba25dd623a56cfaabfcef434fd..0db170d920e23a839d14025ff862284e4f07e7d6 100644 --- a/NumLib/ODESolver/TimeDiscretization.h +++ b/NumLib/ODESolver/TimeDiscretization.h @@ -211,7 +211,7 @@ public: { } - ~BackwardEuler() + ~BackwardEuler() override { NumLib::GlobalVectorProvider::provider.releaseVector(_x_old); } @@ -260,7 +260,7 @@ public: { } - ~ForwardEuler() + ~ForwardEuler() override { NumLib::GlobalVectorProvider::provider.releaseVector(_x_old); } @@ -335,7 +335,7 @@ public: { } - ~CrankNicolson() + ~CrankNicolson() override { NumLib::GlobalVectorProvider::provider.releaseVector(_x_old); } @@ -422,7 +422,7 @@ public: _xs_old.reserve(num_steps); } - ~BackwardDifferentiationFormula() + ~BackwardDifferentiationFormula() override { for (auto* x : _xs_old) NumLib::GlobalVectorProvider::provider.releaseVector(*x); diff --git a/NumLib/ODESolver/TimeDiscretizedODESystem.h b/NumLib/ODESolver/TimeDiscretizedODESystem.h index 4aa4fcb345c38dd4f268cf7dc2510c540f31d207..122803064fa1e68f4c411ae1a9b32dc296a19e25 100644 --- a/NumLib/ODESolver/TimeDiscretizedODESystem.h +++ b/NumLib/ODESolver/TimeDiscretizedODESystem.h @@ -84,7 +84,7 @@ public: */ explicit TimeDiscretizedODESystem(ODE& ode, TimeDisc& time_discretization); - ~TimeDiscretizedODESystem(); + ~TimeDiscretizedODESystem() override; void assemble(const GlobalVector& x_new_timestep, ProcessLib::StaggeredCouplingTerm const& coupling_term) @@ -178,7 +178,7 @@ public: */ explicit TimeDiscretizedODESystem(ODE& ode, TimeDisc& time_discretization); - ~TimeDiscretizedODESystem(); + ~TimeDiscretizedODESystem() override; void assemble(const GlobalVector& x_new_timestep, ProcessLib::StaggeredCouplingTerm const& coupling_term) diff --git a/NumLib/TimeStepping/Algorithms/ITimeStepAlgorithm.h b/NumLib/TimeStepping/Algorithms/ITimeStepAlgorithm.h index 110aa331a5ce8ec08a7b7f4f8a2150a3eab3f7a4..2dda10b913d87b0b37b5d4df2923b3128405b9af 100644 --- a/NumLib/TimeStepping/Algorithms/ITimeStepAlgorithm.h +++ b/NumLib/TimeStepping/Algorithms/ITimeStepAlgorithm.h @@ -44,7 +44,7 @@ public: /// return a history of time step sizes virtual const std::vector<double>& getTimeStepSizeHistory() const = 0; - virtual ~ITimeStepAlgorithm() {} + virtual ~ITimeStepAlgorithm() = default; }; } //NumLib diff --git a/NumLib/TimeStepping/Algorithms/IterationNumberBasedAdaptiveTimeStepping.cpp b/NumLib/TimeStepping/Algorithms/IterationNumberBasedAdaptiveTimeStepping.cpp index e41318cf79a0eee3e2862912a0b9e06a37abba86..d6e27d960e357f54a1d690ce9fe0ea669dcfb62b 100644 --- a/NumLib/TimeStepping/Algorithms/IterationNumberBasedAdaptiveTimeStepping.cpp +++ b/NumLib/TimeStepping/Algorithms/IterationNumberBasedAdaptiveTimeStepping.cpp @@ -11,21 +11,31 @@ #include "IterationNumberBasedAdaptiveTimeStepping.h" -#include <limits> #include <algorithm> #include <cassert> #include <cmath> +#include <limits> +#include <utility> namespace NumLib { - -IterationNumberBasedAdaptiveTimeStepping::IterationNumberBasedAdaptiveTimeStepping(double t0, double tn, - double min_ts, double max_ts, double initial_ts, - const std::vector<std::size_t> &iter_times_vector, - const std::vector<double> &multiplier_vector) -: _t_initial(t0), _t_end(tn), _iter_times_vector(iter_times_vector), _multiplier_vector(multiplier_vector), - _min_ts(min_ts), _max_ts(max_ts), _initial_ts(initial_ts), _max_iter(_iter_times_vector.empty() ? 0 : _iter_times_vector.back()), - _iter_times(0), _ts_pre(t0), _ts_current(t0), _n_rejected_steps(0) +IterationNumberBasedAdaptiveTimeStepping:: + IterationNumberBasedAdaptiveTimeStepping( + double t0, double tn, double min_ts, double max_ts, double initial_ts, + std::vector<std::size_t> iter_times_vector, + std::vector<double> multiplier_vector) + : _t_initial(t0), + _t_end(tn), + _iter_times_vector(std::move(iter_times_vector)), + _multiplier_vector(std::move(multiplier_vector)), + _min_ts(min_ts), + _max_ts(max_ts), + _initial_ts(initial_ts), + _max_iter(_iter_times_vector.empty() ? 0 : _iter_times_vector.back()), + _iter_times(0), + _ts_pre(t0), + _ts_current(t0), + _n_rejected_steps(0) { assert(iter_times_vector.size() == multiplier_vector.size()); } diff --git a/NumLib/TimeStepping/Algorithms/IterationNumberBasedAdaptiveTimeStepping.h b/NumLib/TimeStepping/Algorithms/IterationNumberBasedAdaptiveTimeStepping.h index fe2c3db2e7df6ba4de69073fad5e077817a9fe48..38058e29d314b10b0cacf9fa6a4ccabddbc7b936 100644 --- a/NumLib/TimeStepping/Algorithms/IterationNumberBasedAdaptiveTimeStepping.h +++ b/NumLib/TimeStepping/Algorithms/IterationNumberBasedAdaptiveTimeStepping.h @@ -74,33 +74,36 @@ public: * (\f$a_1\f$, \f$a_2\f$, ..., \f$a_n\f$) corresponding to the intervals given by iter_times_vector. * A time step size is calculated by \f$\Delta t_{n+1} = a * \Delta t_{n}\f$ */ - IterationNumberBasedAdaptiveTimeStepping( double t_initial, - double t_end, - double min_ts, - double max_ts, - double initial_ts, - const std::vector<std::size_t> &iter_times_vector, - const std::vector<double> &multiplier_vector); - - virtual ~IterationNumberBasedAdaptiveTimeStepping() {} + IterationNumberBasedAdaptiveTimeStepping(double t_initial, + double t_end, + double min_ts, + double max_ts, + double initial_ts, + std::vector<std::size_t> + iter_times_vector, + std::vector<double> + multiplier_vector); + + ~IterationNumberBasedAdaptiveTimeStepping() override = default; /// return the beginning of time steps - virtual double begin() const {return _t_initial;} - + double begin() const override { return _t_initial; } /// return the end of time steps - virtual double end() const {return _t_end;} - + double end() const override { return _t_end; } /// return current time step - virtual const TimeStep getTimeStep() const; + const TimeStep getTimeStep() const override; /// move to the next time step - virtual bool next(); + bool next() override; /// return if the current step is accepted - virtual bool accepted() const; + bool accepted() const override; /// return a history of time step sizes - virtual const std::vector<double>& getTimeStepSizeHistory() const {return this->_dt_vector;} + const std::vector<double>& getTimeStepSizeHistory() const override + { + return this->_dt_vector; + } /// set the number of iterations void setNIterations(std::size_t n_itr) {this->_iter_times = n_itr;} diff --git a/NumLib/TimeStepping/TimeStep.h b/NumLib/TimeStepping/TimeStep.h index 07c66d869a4f59d72985e9c4eb36e4efb08a921a..1a593a7035b26c1923639d1552c76132ab4e9e1e 100644 --- a/NumLib/TimeStepping/TimeStep.h +++ b/NumLib/TimeStepping/TimeStep.h @@ -46,14 +46,7 @@ public: : _previous(src._previous), _current(src._current), _dt(_current-_previous), _steps(src._steps) {} /// copy a time step - TimeStep &operator=(const TimeStep &src) - { - _previous = src._previous; - _current = src._current; - _dt = src._dt; - _steps = src._steps; - return *this; - } + TimeStep& operator=(const TimeStep& src) = default; /// return a time step incremented by the given time step size TimeStep operator+(const double dt) const diff --git a/ProcessLib/BoundaryCondition/BoundaryCondition.h b/ProcessLib/BoundaryCondition/BoundaryCondition.h index ccf1b7ba364693eed93bf2077bef12447ae830c7..161f9ad721bea4e1e7ddc5c7c6e86a63cde624d7 100644 --- a/ProcessLib/BoundaryCondition/BoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/BoundaryCondition.h @@ -69,7 +69,7 @@ public: class BoundaryConditionBuilder { public: - virtual ~BoundaryConditionBuilder() {} + virtual ~BoundaryConditionBuilder() = default; virtual std::unique_ptr<BoundaryCondition> createBoundaryCondition( const BoundaryConditionConfig& config, diff --git a/ProcessLib/CachedSecondaryVariable.h b/ProcessLib/CachedSecondaryVariable.h index 3a8d3e790cec924aec76312137bb2e8378d85616..0c6b5335f6e8c1353cf7cc7343582033baa71d47 100644 --- a/ProcessLib/CachedSecondaryVariable.h +++ b/ProcessLib/CachedSecondaryVariable.h @@ -9,6 +9,8 @@ #pragma once +#include <utility> + #include "NumLib/Extrapolation/ExtrapolatableElementCollection.h" #include "NumLib/NamedFunctionProvider.h" #include "NumLib/NumericsConfig.h" @@ -36,17 +38,17 @@ public: template <typename LocalAssemblerCollection, typename IntegrationPointValuesMethod> CachedSecondaryVariable( - std::string const& internal_variable_name, + std::string internal_variable_name, NumLib::Extrapolator& extrapolator, LocalAssemblerCollection const& local_assemblers, IntegrationPointValuesMethod integration_point_values_method, SecondaryVariableContext const& context) - : _extrapolator(extrapolator) - , _extrapolatables(new NumLib::ExtrapolatableLocalAssemblerCollection< + : _extrapolator(extrapolator), + _extrapolatables(new NumLib::ExtrapolatableLocalAssemblerCollection< LocalAssemblerCollection>{ - local_assemblers, integration_point_values_method}) - , _context(context) - , _internal_variable_name(internal_variable_name) + local_assemblers, integration_point_values_method}), + _context(context), + _internal_variable_name(std::move(internal_variable_name)) { } diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h b/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h index 0fb418c1f621808313ceb34f8cb7c13b17ea534a..d9734be0888bb5b56d5a0f9a8be1b3dd2ff660d2 100644 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h +++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h @@ -190,7 +190,7 @@ public: std::vector<double> const& getIntPtDarcyVelocityX( std::vector<double>& /*cache*/) const override { - assert(_darcy_velocities.size() > 0); + assert(!_darcy_velocities.empty()); return _darcy_velocities[0]; } diff --git a/ProcessLib/HT/CreateHTProcess.cpp b/ProcessLib/HT/CreateHTProcess.cpp index 29076a86289e3049e94813bc336e1de387f71bea..987df379781e414f366560c0f468661a9b721b2b 100644 --- a/ProcessLib/HT/CreateHTProcess.cpp +++ b/ProcessLib/HT/CreateHTProcess.cpp @@ -139,7 +139,7 @@ std::unique_ptr<Process> createHTProcess( std::vector<double> const b = //! \ogs_file_param{prj__processes__process__HT__specific_body_force} config.getConfigParameter<std::vector<double>>("specific_body_force"); - assert(b.size() > 0 && b.size() < 4); + assert(!b.empty() && b.size() < 4); bool const has_gravity = MathLib::toVector(b).norm() > 0; if (has_gravity) std::copy_n(b.data(), b.size(), specific_body_force.data()); diff --git a/ProcessLib/HT/HTFEM.h b/ProcessLib/HT/HTFEM.h index 938ba3b1b06a3963deecb3806e76af6ead309e14..92ff83a8aaa995c68237c8b9455c751ad6253ce1 100644 --- a/ProcessLib/HT/HTFEM.h +++ b/ProcessLib/HT/HTFEM.h @@ -30,10 +30,12 @@ namespace HT template < typename NodalRowVectorType, typename GlobalDimNodalMatrixType> struct IntegrationPointData final { - IntegrationPointData(NodalRowVectorType const& N_, - GlobalDimNodalMatrixType const& dNdx_, + IntegrationPointData(NodalRowVectorType N_, + GlobalDimNodalMatrixType dNdx_, double const& integration_weight_) - : N(N_), dNdx(dNdx_), integration_weight(integration_weight_) + : N(std::move(N_)), + dNdx(std::move(dNdx_)), + integration_weight(integration_weight_) {} NodalRowVectorType const N; @@ -276,7 +278,7 @@ public: std::vector<double> const& getIntPtDarcyVelocityX( std::vector<double>& /*cache*/) const override { - assert(_darcy_velocities.size() > 0); + assert(!_darcy_velocities.empty()); return _darcy_velocities[0]; } diff --git a/ProcessLib/HT/HTProcessData.h b/ProcessLib/HT/HTProcessData.h index ea071ca707c0e8541026bf17129eb1bc24a8e216..f84c7e3ebdd3fb42e08c5c882425c6791dbcc606 100644 --- a/ProcessLib/HT/HTProcessData.h +++ b/ProcessLib/HT/HTProcessData.h @@ -10,6 +10,7 @@ #pragma once #include <memory> +#include <utility> #include "MaterialLib/Fluid/FluidProperty.h" #include "MaterialLib/PorousMedium/Porosity/Porosity.h" @@ -43,7 +44,7 @@ struct HTProcessData ProcessLib::Parameter<double> const& specific_heat_capacity_fluid_, ProcessLib::Parameter<double> const& thermal_conductivity_solid_, ProcessLib::Parameter<double> const& thermal_conductivity_fluid_, - Eigen::Vector3d const& specific_body_force_, + Eigen::Vector3d specific_body_force_, bool const has_gravity_) : porous_media_properties(std::move(porous_media_properties_)), viscosity_model(std::move(viscosity_model_)), @@ -56,7 +57,7 @@ struct HTProcessData thermal_dispersivity_transversal(thermal_dispersivity_transversal_), thermal_conductivity_solid(thermal_conductivity_solid_), thermal_conductivity_fluid(thermal_conductivity_fluid_), - specific_body_force(specific_body_force_), + specific_body_force(std::move(specific_body_force_)), has_gravity(has_gravity_) { } diff --git a/ProcessLib/HeatConduction/HeatConductionFEM-impl.h b/ProcessLib/HeatConduction/HeatConductionFEM-impl.h index 2110040f4a262e826a5365f4b4ff10c480b283da..f3bafbc7c1ccb7ad84e7747635e55f01fe733515 100644 --- a/ProcessLib/HeatConduction/HeatConductionFEM-impl.h +++ b/ProcessLib/HeatConduction/HeatConductionFEM-impl.h @@ -121,7 +121,7 @@ void LocalAssemblerData<ShapeFunction, IntegrationMethod, GlobalDim>:: dynamic_cast<const ProcessLib::LiquidFlow::LiquidFlowProcess*>( &(coupled_process_pair.second)) != nullptr); - ProcessLib::LiquidFlow::LiquidFlowProcess const& pcs = + auto const& pcs = static_cast<ProcessLib::LiquidFlow::LiquidFlowProcess const&>( coupled_process_pair.second); const auto liquid_flow_prop = pcs.getLiquidFlowMaterialProperties(); diff --git a/ProcessLib/HeatConduction/HeatConductionFEM.h b/ProcessLib/HeatConduction/HeatConductionFEM.h index 1afceed27c72ee287af4bacb2ddacbbf39e9a267..1dc74f69749763d78eee31d073304c1e49ee5b1e 100644 --- a/ProcessLib/HeatConduction/HeatConductionFEM.h +++ b/ProcessLib/HeatConduction/HeatConductionFEM.h @@ -171,7 +171,7 @@ public: std::vector<double> const& getIntPtHeatFluxX( std::vector<double>& /*cache*/) const override { - assert(_heat_fluxes.size() > 0); + assert(!_heat_fluxes.empty()); return _heat_fluxes[0]; } diff --git a/ProcessLib/HeatConduction/HeatConductionProcess.h b/ProcessLib/HeatConduction/HeatConductionProcess.h index ca7c77a8330ae39975bcc0c01cfa76fe1e80e5fb..55d2d7c151ae082a1b49a302cb0f7fc1858dbf6a 100644 --- a/ProcessLib/HeatConduction/HeatConductionProcess.h +++ b/ProcessLib/HeatConduction/HeatConductionProcess.h @@ -46,7 +46,7 @@ public: const double delta_t) override; // Get the solution of the previous time step. - virtual GlobalVector* getPreviousTimeStepSolution() const override + GlobalVector* getPreviousTimeStepSolution() const override { return _x_previous_timestep.get(); } diff --git a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h index 591cffa4b36ff56cd53ef99627105c3f6ce836b5..1914d9f8ff5c242cfc76c5ceccaf825014b85de0 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h @@ -539,7 +539,7 @@ public: std::vector<double> const& getIntPtDarcyVelocityX( std::vector<double>& /*cache*/) const override { - assert(_darcy_velocities.size() > 0); + assert(!_darcy_velocities.empty()); return _darcy_velocities[0]; } diff --git a/ProcessLib/HydroMechanics/HydroMechanicsProcessData.h b/ProcessLib/HydroMechanics/HydroMechanicsProcessData.h index 1172958b3afe7646f9d651306039310834cc9f30..2f7c1baebf3609f39eaa9db3e4d6a9f2c73452f2 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsProcessData.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsProcessData.h @@ -10,6 +10,7 @@ #pragma once #include <Eigen/Dense> +#include <utility> namespace MeshLib { @@ -33,7 +34,8 @@ struct HydroMechanicsProcessData Parameter<double> const& biot_coefficient_, Parameter<double> const& porosity_, Parameter<double> const& solid_density_, - Eigen::Matrix<double, DisplacementDim, 1> const& specific_body_force_) + Eigen::Matrix<double, DisplacementDim, 1> + specific_body_force_) : material{std::move(material_)}, intrinsic_permeability(intrinsic_permeability_), specific_storage(specific_storage_), @@ -42,7 +44,7 @@ struct HydroMechanicsProcessData biot_coefficient(biot_coefficient_), porosity(porosity_), solid_density(solid_density_), - specific_body_force(specific_body_force_) + specific_body_force(std::move(specific_body_force_)) { } diff --git a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcessData.h b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcessData.h index 920a9780727ba8f09f80d60689c3e0a647b7e535..f86382fe908cc4d5722ea5e3fbc250c59f6ad891 100644 --- a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcessData.h +++ b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcessData.h @@ -9,8 +9,9 @@ #pragma once -#include <memory> #include <Eigen/Dense> +#include <memory> +#include <utility> #include "MeshLib/ElementStatus.h" #include "MeshLib/PropertyVector.h" @@ -44,13 +45,14 @@ struct HydroMechanicsProcessData Parameter<double> const& biot_coefficient_, Parameter<double> const& porosity_, Parameter<double> const& solid_density_, - Eigen::Matrix<double, GlobalDim, 1> const& specific_body_force_, - std::unique_ptr<MaterialLib::Fracture::FractureModelBase<GlobalDim>>&& fracture_model, + Eigen::Matrix<double, GlobalDim, 1> + specific_body_force_, + std::unique_ptr<MaterialLib::Fracture::FractureModelBase<GlobalDim>>&& + fracture_model, std::unique_ptr<FractureProperty>&& fracture_prop, Parameter<double> const& initial_effective_stress_, Parameter<double> const& initial_fracture_effective_stress_, - bool const deactivate_matrix_in_flow_ - ) + bool const deactivate_matrix_in_flow_) : material{std::move(material_)}, intrinsic_permeability(intrinsic_permeability_), specific_storage(specific_storage_), @@ -59,7 +61,7 @@ struct HydroMechanicsProcessData biot_coefficient(biot_coefficient_), porosity(porosity_), solid_density(solid_density_), - specific_body_force(specific_body_force_), + specific_body_force(std::move(specific_body_force_)), fracture_model{std::move(fracture_model)}, fracture_property{std::move(fracture_prop)}, initial_effective_stress(initial_effective_stress_), diff --git a/ProcessLib/LIE/HydroMechanics/LocalAssembler/HydroMechanicsLocalAssemblerInterface.h b/ProcessLib/LIE/HydroMechanics/LocalAssembler/HydroMechanicsLocalAssemblerInterface.h index f30d8385a44de60f6f080676d36109e060eeffc9..d7dc816721750cb9b21ce1d4be0c0adb1c66f8b0 100644 --- a/ProcessLib/LIE/HydroMechanics/LocalAssembler/HydroMechanicsLocalAssemblerInterface.h +++ b/ProcessLib/LIE/HydroMechanics/LocalAssembler/HydroMechanicsLocalAssemblerInterface.h @@ -9,6 +9,7 @@ #pragma once +#include <utility> #include <vector> #include "BaseLib/Error.h" @@ -31,11 +32,12 @@ class HydroMechanicsLocalAssemblerInterface public NumLib::ExtrapolatableElement { public: - HydroMechanicsLocalAssemblerInterface( - MeshLib::Element const& element, - std::size_t n_local_size, - std::vector<unsigned> const& dofIndex_to_localIndex) - : _element(element), _dofIndex_to_localIndex(dofIndex_to_localIndex) + HydroMechanicsLocalAssemblerInterface(MeshLib::Element const& element, + std::size_t n_local_size, + std::vector<unsigned> + dofIndex_to_localIndex) + : _element(element), + _dofIndex_to_localIndex(std::move(dofIndex_to_localIndex)) { _local_u.resize(n_local_size); _local_udot.resize(n_local_size); @@ -53,15 +55,14 @@ public: "implemented."); } - virtual void assembleWithJacobian( - double const t, - std::vector<double> const& local_x_, - std::vector<double> const& local_xdot_, - const double /*dxdot_dx*/, const double /*dx_dx*/, - std::vector<double>& /*local_M_data*/, - std::vector<double>& /*local_K_data*/, - std::vector<double>& local_b_data, - std::vector<double>& local_Jac_data) override + void assembleWithJacobian(double const t, + std::vector<double> const& local_x_, + std::vector<double> const& local_xdot_, + const double /*dxdot_dx*/, const double /*dx_dx*/, + std::vector<double>& /*local_M_data*/, + std::vector<double>& /*local_K_data*/, + std::vector<double>& local_b_data, + std::vector<double>& local_Jac_data) override { auto const local_dof_size = local_x_.size(); diff --git a/ProcessLib/LIE/HydroMechanics/LocalAssembler/HydroMechanicsLocalAssemblerMatrix.h b/ProcessLib/LIE/HydroMechanics/LocalAssembler/HydroMechanicsLocalAssemblerMatrix.h index 1aed6ea753f88d7f7ba31b07b8e5c92c87604326..1854cb01d1fe08eb07f08d8ce0307806421e0915 100644 --- a/ProcessLib/LIE/HydroMechanics/LocalAssembler/HydroMechanicsLocalAssemblerMatrix.h +++ b/ProcessLib/LIE/HydroMechanics/LocalAssembler/HydroMechanicsLocalAssemblerMatrix.h @@ -63,12 +63,11 @@ public: } protected: - virtual void assembleWithJacobianConcrete( - double const t, - Eigen::VectorXd const& local_x, - Eigen::VectorXd const& local_x_dot, - Eigen::VectorXd& local_rhs, - Eigen::MatrixXd& local_Jac) override; + void assembleWithJacobianConcrete(double const t, + Eigen::VectorXd const& local_x, + Eigen::VectorXd const& local_x_dot, + Eigen::VectorXd& local_rhs, + Eigen::MatrixXd& local_Jac) override; void assembleBlockMatricesWithJacobian( double const t, diff --git a/ProcessLib/LIE/SmallDeformation/LocalAssembler/SmallDeformationLocalAssemblerInterface.h b/ProcessLib/LIE/SmallDeformation/LocalAssembler/SmallDeformationLocalAssemblerInterface.h index b082fa43bded15cf9a55af12a1ecde0dfaf14c0d..9f3aaf7c43c3fc478bea1a9ec605c2d99e701a68 100644 --- a/ProcessLib/LIE/SmallDeformation/LocalAssembler/SmallDeformationLocalAssemblerInterface.h +++ b/ProcessLib/LIE/SmallDeformation/LocalAssembler/SmallDeformationLocalAssemblerInterface.h @@ -9,6 +9,7 @@ #pragma once +#include <utility> #include <vector> #include "BaseLib/Error.h" @@ -30,27 +31,23 @@ class SmallDeformationLocalAssemblerInterface { public: SmallDeformationLocalAssemblerInterface() : _dofIndex_to_localIndex{} {} - SmallDeformationLocalAssemblerInterface( - std::size_t n_local_size, - std::vector<unsigned> const& dofIndex_to_localIndex) - : _dofIndex_to_localIndex(dofIndex_to_localIndex) + std::size_t n_local_size, std::vector<unsigned> dofIndex_to_localIndex) + : _dofIndex_to_localIndex(std::move(dofIndex_to_localIndex)) { _local_u.resize(n_local_size); _local_b.resize(_local_u.size()); _local_J.resize(_local_u.size(), _local_u.size()); } - - virtual void assembleWithJacobian( - double const t, - std::vector<double> const& local_x_, - std::vector<double> const& /*local_xdot*/, - const double /*dxdot_dx*/, const double /*dx_dx*/, - std::vector<double>& /*local_M_data*/, - std::vector<double>& /*local_K_data*/, - std::vector<double>& local_b_data, - std::vector<double>& local_Jac_data) override + void assembleWithJacobian(double const t, + std::vector<double> const& local_x_, + std::vector<double> const& /*local_xdot*/, + const double /*dxdot_dx*/, const double /*dx_dx*/, + std::vector<double>& /*local_M_data*/, + std::vector<double>& /*local_K_data*/, + std::vector<double>& local_b_data, + std::vector<double>& local_Jac_data) override { auto const local_dof_size = local_x_.size(); diff --git a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp index 1259fd9758491df54a628b9a015e07e361661176..577261fc04c6ffb5ca3e00cb6431ad989d41b257 100644 --- a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp +++ b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp @@ -58,11 +58,11 @@ std::unique_ptr<Process> createLiquidFlowProcess( // Get the gravity vector for the Darcy velocity //! \ogs_file_param{prj__processes__process__LIQUID_FLOW__darcy_gravity} auto const& darcy_g_config = config.getConfigSubtree("darcy_gravity"); - const int gravity_axis_id_input = + const auto gravity_axis_id_input = //! \ogs_file_param{prj__processes__process__LIQUID_FLOW__darcy_gravity__axis_id} darcy_g_config.getConfigParameter<int>("axis_id"); assert(gravity_axis_id_input < static_cast<int>(mesh.getDimension())); - const double g = + const auto g = //! \ogs_file_param{prj__processes__process__LIQUID_FLOW__darcy_gravity__g} darcy_g_config.getConfigParameter<double>("g"); assert(g >= 0.); diff --git a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h index d45f13017ee177600a76f56cf0147011fa6b60c6..c6adbf2bf321e66780af45afb02accca38680ec8 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h +++ b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h @@ -116,7 +116,7 @@ public: std::vector<double> const& getIntPtDarcyVelocityX( std::vector<double>& /*cache*/) const override { - assert(_darcy_velocities.size() > 0); + assert(!_darcy_velocities.empty()); return _darcy_velocities[0]; } diff --git a/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.h b/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.h index 90f5557e835eeb23e2810b8922d24748c49e62b6..0230ec5b632b5cec2ecc12a25fa39847953aa88c 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.h +++ b/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.h @@ -57,7 +57,7 @@ namespace LiquidFlow class LiquidFlowMaterialProperties { public: - typedef MaterialLib::Fluid::FluidProperty::ArrayType ArrayType; + using ArrayType = MaterialLib::Fluid::FluidProperty::ArrayType; LiquidFlowMaterialProperties( std::unique_ptr<MaterialLib::Fluid::FluidProperties>&& fluid_properties, diff --git a/ProcessLib/Output.h b/ProcessLib/Output.h index 8b655ecdd202cd23ae3f3a10bc5a50c818037c78..2d7e099e46130f5d1413f2c0657a62d152952e81 100644 --- a/ProcessLib/Output.h +++ b/ProcessLib/Output.h @@ -9,6 +9,8 @@ #pragma once +#include <utility> + #include "BaseLib/ConfigTree.h" #include "MeshLib/IO/VtkIO/PVDFile.h" #include "Process.h" @@ -82,9 +84,9 @@ private: MeshLib::IO::PVDFile pvd_file; }; - Output(std::string const& prefix, bool const compress_output, + Output(std::string prefix, bool const compress_output, bool const output_nonlinear_iteration_results) - : _output_file_prefix(prefix), + : _output_file_prefix(std::move(prefix)), _output_file_compression(compress_output), _output_nonlinear_iteration_results( output_nonlinear_iteration_results) diff --git a/ProcessLib/Parameter/ConstantParameter.h b/ProcessLib/Parameter/ConstantParameter.h index d754e75727db8b7f54769a1027c473b90890d943..cfc08b74205914668f296310c92dbf54c006c5a9 100644 --- a/ProcessLib/Parameter/ConstantParameter.h +++ b/ProcessLib/Parameter/ConstantParameter.h @@ -9,6 +9,8 @@ #pragma once +#include <utility> + #include "Parameter.h" namespace ProcessLib @@ -25,11 +27,10 @@ struct ConstantParameter final : public Parameter<T> /// Construction with a tuple. /// The given tuple must be non-empty. - explicit ConstantParameter(std::string const& name_, - std::vector<T> const& values) - : Parameter<T>(name_), _values(values) + explicit ConstantParameter(std::string const& name_, std::vector<T> values) + : Parameter<T>(name_), _values(std::move(values)) { - assert(!values.empty()); + assert(!_values.empty()); } bool isTimeDependent() const override { return false; } diff --git a/ProcessLib/Parameter/CurveScaledParameter.h b/ProcessLib/Parameter/CurveScaledParameter.h index 57d39ced101bf62bf0c9268adf55af274d4d691a..0891d69b16a302e05b4c71ee9f50fd54b3907cd4 100644 --- a/ProcessLib/Parameter/CurveScaledParameter.h +++ b/ProcessLib/Parameter/CurveScaledParameter.h @@ -10,6 +10,7 @@ #pragma once #include <map> +#include <utility> #include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h" #include "Parameter.h" #include "ProcessLib/Utils/ProcessUtils.h" @@ -20,10 +21,10 @@ template <typename T> struct CurveScaledParameter final : public Parameter<T> { CurveScaledParameter(std::string const& name_, MathLib::PiecewiseLinearInterpolation const& curve, - std::string const& referenced_parameter_name) + std::string referenced_parameter_name) : Parameter<T>(name_), _curve(curve), - _referenced_parameter_name(referenced_parameter_name) + _referenced_parameter_name(std::move(referenced_parameter_name)) { } diff --git a/ProcessLib/Parameter/GroupBasedParameter.cpp b/ProcessLib/Parameter/GroupBasedParameter.cpp index fdfff263dc07b5fbb579862c61e3224a5f5df934..df03fba721a8d5b52f8596cd1747018897b22dfa 100644 --- a/ProcessLib/Parameter/GroupBasedParameter.cpp +++ b/ProcessLib/Parameter/GroupBasedParameter.cpp @@ -31,8 +31,8 @@ std::unique_ptr<ParameterBase> createGroupBasedParameter( mesh.getProperties().getPropertyVector<int>(group_id_property_name); // parse mapping data - typedef std::vector<double> Values; - typedef std::pair<int, Values> Index_Values; + using Values = std::vector<double>; + using Index_Values = std::pair<int, Values>; std::vector<Index_Values> vec_index_values; //! \ogs_file_param{prj__parameters__parameter__Group__index_values} for (auto p : config.getConfigSubtreeList("index_values")) @@ -46,7 +46,7 @@ std::unique_ptr<ParameterBase> createGroupBasedParameter( if (value) { Values values(1, *value); - vec_index_values.push_back(Index_Values(index, values)); + vec_index_values.emplace_back(index, values); continue; } } @@ -58,7 +58,7 @@ std::unique_ptr<ParameterBase> createGroupBasedParameter( if (values.empty()) OGS_FATAL("No value available for constant parameter."); - vec_index_values.push_back(Index_Values(index, values)); + vec_index_values.emplace_back(index, values); } // check the input diff --git a/ProcessLib/Parameter/GroupBasedParameter.h b/ProcessLib/Parameter/GroupBasedParameter.h index aa336588c2d2c6fb8f8687f88e9982b8b8699d09..e31c28ceb1877c95df7ab18332a3422ad7cb2f1f 100644 --- a/ProcessLib/Parameter/GroupBasedParameter.h +++ b/ProcessLib/Parameter/GroupBasedParameter.h @@ -9,6 +9,8 @@ #pragma once +#include <utility> + #include "BaseLib/Error.h" #include "MeshLib/PropertyVector.h" @@ -39,10 +41,11 @@ struct GroupBasedParameter final */ GroupBasedParameter(std::string const& name_, MeshLib::PropertyVector<int> const& property, - std::vector<std::vector<double>> const& vec_values) + std::vector<std::vector<double>> + vec_values) : Parameter<T>(name_), _property_index(property), - _vec_values(vec_values) + _vec_values(std::move(vec_values)) { } diff --git a/ProcessLib/Parameter/Parameter.h b/ProcessLib/Parameter/Parameter.h index b9a818944143444c4325321616dcfca2f1771cba..73c94cf78f255b2b31bf9153da8352a564627889 100644 --- a/ProcessLib/Parameter/Parameter.h +++ b/ProcessLib/Parameter/Parameter.h @@ -11,6 +11,7 @@ #include <map> #include <memory> +#include <utility> #include <vector> #include "SpatialPosition.h" @@ -36,8 +37,7 @@ namespace ProcessLib /// Its property name helps addressing the right parameter. struct ParameterBase { - ParameterBase(std::string const& name_) : name(name_) {} - + ParameterBase(std::string name_) : name(std::move(name_)) {} virtual ~ParameterBase() = default; virtual bool isTimeDependent() const = 0; @@ -63,8 +63,7 @@ template <typename T> struct Parameter : public ParameterBase { Parameter(std::string const& name_) : ParameterBase(name_) {} - - virtual ~Parameter() = default; + ~Parameter() override = default; //! Returns the number of components this Parameter has at every position and //! point in time. diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index 674c898b132d1d6a4e56fbb8359e6c1192c6984e..7898b304856d003082935455962186203471c63c 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -56,37 +56,33 @@ public: /// Postprocessing after a complete timestep. void postTimestep(GlobalVector const& x); - void preIteration(const unsigned iter, - GlobalVector const& x) override final; + void preIteration(const unsigned iter, GlobalVector const& x) final; /// compute secondary variables for the coupled equations or for output. void computeSecondaryVariable(const double t, GlobalVector const& x, StaggeredCouplingTerm const& coupled_term); - NumLib::IterationResult postIteration(GlobalVector const& x) override final; + NumLib::IterationResult postIteration(GlobalVector const& x) final; void initialize(); void setInitialConditions(const double t, GlobalVector& x); - MathLib::MatrixSpecifications getMatrixSpecifications() - const override final; + MathLib::MatrixSpecifications getMatrixSpecifications() const final; void assemble(const double t, GlobalVector const& x, GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, - StaggeredCouplingTerm const& coupling_term) - override final; + StaggeredCouplingTerm const& coupling_term) final; void assembleWithJacobian(const double t, GlobalVector const& x, GlobalVector const& xdot, const double dxdot_dx, const double dx_dx, GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac, - StaggeredCouplingTerm const& coupling_term) - override final; + StaggeredCouplingTerm const& coupling_term) final; std::vector<NumLib::IndexValueVector<GlobalIndexType>> const* - getKnownSolutions(double const t) const override final + getKnownSolutions(double const t) const final { return _boundary_conditions.getKnownSolutions(t); } diff --git a/ProcessLib/RichardsFlow/RichardsFlowFEM.h b/ProcessLib/RichardsFlow/RichardsFlowFEM.h index 759c633880b7e5cf360f9575d67e09418d65b2fd..caf5a78f60533223ae539f9068584dd42d8a4c7a 100644 --- a/ProcessLib/RichardsFlow/RichardsFlowFEM.h +++ b/ProcessLib/RichardsFlow/RichardsFlowFEM.h @@ -235,14 +235,14 @@ public: std::vector<double> const& getIntPtSaturation( std::vector<double>& /*cache*/) const override { - assert(_saturation.size() > 0); + assert(!_saturation.empty()); return _saturation; } std::vector<double> const& getIntPtDarcyVelocityX( std::vector<double>& /*cache*/) const override { - assert(_darcy_velocities.size() > 0); + assert(!_darcy_velocities.empty()); return _darcy_velocities[0]; } diff --git a/ProcessLib/TES/TESLocalAssembler.h b/ProcessLib/TES/TESLocalAssembler.h index f92efd53962d447e668ffecec97cdcf7cb04e631..a69e42750aa9651b568e17da8134255ef718264f 100644 --- a/ProcessLib/TES/TESLocalAssembler.h +++ b/ProcessLib/TES/TESLocalAssembler.h @@ -26,7 +26,7 @@ class TESLocalAssemblerInterface public NumLib::ExtrapolatableElement { public: - virtual ~TESLocalAssemblerInterface() = default; + ~TESLocalAssemblerInterface() override = default; virtual bool checkBounds(std::vector<double> const& local_x, std::vector<double> const& local_x_prev_ts) = 0; diff --git a/ProcessLib/TES/TESReactionAdaptor.cpp b/ProcessLib/TES/TESReactionAdaptor.cpp index edd977ca082c123d1427a1fd798ad4037ddd805c..85bb8cdb16bcddff2f677579ada82b4434edc6b7 100644 --- a/ProcessLib/TES/TESReactionAdaptor.cpp +++ b/ProcessLib/TES/TESReactionAdaptor.cpp @@ -65,7 +65,7 @@ TESFEMReactionAdaptorAdsorption::TESFEMReactionAdaptorAdsorption( assert(dynamic_cast<Adsorption::AdsorptionReaction const*>( data.ap.react_sys.get()) != nullptr && "Reactive system has wrong type."); - assert(_bounds_violation.size() != 0); + assert(!_bounds_violation.empty()); } ReactionRate diff --git a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp index 03375787171a34c465f5c70acbbc1b8131f00a0e..8bd46d221fb931d9d53a2892092e080dbaa4d2d8 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp +++ b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp @@ -58,7 +58,7 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPPProcess( std::vector<double> const b = //! \ogs_file_param{prj__processes__process__TWOPHASE_FLOW_PP__specific_body_force} config.getConfigParameter<std::vector<double>>("specific_body_force"); - assert(b.size() > 0 && b.size() < 4); + assert(!b.empty() && b.size() < 4); Eigen::VectorXd specific_body_force(b.size()); bool const has_gravity = MathLib::toVector(b).norm() > 0; if (has_gravity) diff --git a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler.h b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler.h index 19104355f44326e69bc091a9f1e9336f33d4b6e3..9c53d8678c665a555f84731e16705ff95c8e4db1 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler.h +++ b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler.h @@ -32,11 +32,11 @@ template <typename NodalRowVectorType, typename GlobalDimNodalMatrixType, struct IntegrationPointData final { explicit IntegrationPointData( - NodalRowVectorType const& N_, GlobalDimNodalMatrixType const& dNdx_, + NodalRowVectorType N_, GlobalDimNodalMatrixType dNdx_, TwoPhaseFlowWithPPMaterialProperties& material_property_, double const& integration_weight_, NodalMatrixType const massOperator_) - : N(N_), - dNdx(dNdx_), + : N(std::move(N_)), + dNdx(std::move(dNdx_)), mat_property(material_property_), integration_weight(integration_weight_), massOperator(massOperator_) @@ -137,14 +137,14 @@ public: std::vector<double> const& getIntPtSaturation( std::vector<double>& /*cache*/) const override { - assert(_saturation.size() > 0); + assert(!_saturation.empty()); return _saturation; } std::vector<double> const& getIntPtWetPressure( std::vector<double>& /*cache*/) const override { - assert(_pressure_wet.size() > 0); + assert(!_pressure_wet.empty()); return _pressure_wet; } diff --git a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.cpp b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.cpp index c2ed90e5a791f7822116615a74ad4eaf2df7e688..369eec2abc51f0987acacd492b435a1d5c34c7b0 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.cpp +++ b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.cpp @@ -9,6 +9,7 @@ #include "TwoPhaseFlowWithPPMaterialProperties.h" #include <logog/include/logog.hpp> +#include <utility> #include "BaseLib/reorderVector.h" #include "MaterialLib/Fluid/FluidProperty.h" #include "MaterialLib/PorousMedium/Porosity/Porosity.h" @@ -53,7 +54,7 @@ TwoPhaseFlowWithPPMaterialProperties::TwoPhaseFlowWithPPMaterialProperties( _gas_density(std::move(gas_density)), _gas_viscosity(std::move(gas_viscosity)), _material_ids(material_ids), - _intrinsic_permeability_models(intrinsic_permeability_models), + _intrinsic_permeability_models(std::move(intrinsic_permeability_models)), _porosity_models(std::move(porosity_models)), _storage_models(std::move(storage_models)), _capillary_pressure_models(std::move(capillary_pressure_models)), diff --git a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp index 62288cf12b38b1d9311a70e6e0688fcd048c077d..2e794cf91d4c086817c4c4013bd00c83b1987fa6 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp +++ b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp @@ -58,7 +58,7 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPrhoProcess( std::vector<double> const b = //! \ogs_file_param{prj__processes__process__TWOPHASE_FLOW_PRHO__specific_body_force} config.getConfigParameter<std::vector<double>>("specific_body_force"); - assert(b.size() > 0 && b.size() < 4); + assert(!b.empty() && b.size() < 4); Eigen::VectorXd specific_body_force(b.size()); bool const has_gravity = MathLib::toVector(b).norm() > 0; if (has_gravity) diff --git a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler.h b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler.h index acd3f3c46e955f03f43b32eae353bc9631260f67..28c994d8f84c7f46d78b9e159c3f7f802d855aa0 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler.h +++ b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler.h @@ -140,14 +140,14 @@ public: std::vector<double> const& getIntPtSaturation( std::vector<double>& /*cache*/) const override { - assert(_saturation.size() > 0); + assert(!_saturation.empty()); return _saturation; } std::vector<double> const& getIntPtNonWettingPressure( std::vector<double>& /*cache*/) const override { - assert(_pressure_nonwetting.size() > 0); + assert(!_pressure_nonwetting.empty()); return _pressure_nonwetting; } diff --git a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.cpp b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.cpp index 242a565dd7c5977f748cdbfe1d0f7b84248e2d5f..687acf6062d0e6b7ea9f204554bbdf2308b20f67 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.cpp +++ b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.cpp @@ -9,6 +9,7 @@ #include "TwoPhaseFlowWithPrhoMaterialProperties.h" #include <logog/include/logog.hpp> +#include <utility> #include "BaseLib/reorderVector.h" #include "MaterialLib/Fluid/FluidProperty.h" #include "MaterialLib/PorousMedium/Porosity/Porosity.h" @@ -58,7 +59,7 @@ TwoPhaseFlowWithPrhoMaterialProperties::TwoPhaseFlowWithPrhoMaterialProperties( _gas_density(std::move(gas_density)), _gas_viscosity(std::move(gas_viscosity)), _material_ids(material_ids), - _intrinsic_permeability_models(intrinsic_permeability_models), + _intrinsic_permeability_models(std::move(intrinsic_permeability_models)), _porosity_models(std::move(porosity_models)), _storage_models(std::move(storage_models)), _capillary_pressure_models(std::move(capillary_pressure_models)), diff --git a/ProcessLib/VariableTransformation.h b/ProcessLib/VariableTransformation.h index 8c82fc497abf7b6d002365771d80a621490b4bd8..372db194bcd5f7b4bb123fc02143ba72ca1b99f3 100644 --- a/ProcessLib/VariableTransformation.h +++ b/ProcessLib/VariableTransformation.h @@ -80,6 +80,5 @@ private: double _factor; }; -typedef TrafoScale Trafo; - +using Trafo = ProcessLib::TrafoScale; } diff --git a/SimpleTests/MatrixTests/DenseGaussEliminationChecker.cpp b/SimpleTests/MatrixTests/DenseGaussEliminationChecker.cpp index 6903878f3801e8a5e901994c91ee1d6dad2e4a16..6586c0affc0d4cfcee90395f43eb5879a78e39ae 100644 --- a/SimpleTests/MatrixTests/DenseGaussEliminationChecker.cpp +++ b/SimpleTests/MatrixTests/DenseGaussEliminationChecker.cpp @@ -24,8 +24,8 @@ int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog::Cout *logogCout(new logog::Cout); + auto* custom_format(new BaseLib::LogogSimpleFormatter); + auto* logogCout(new logog::Cout); logogCout->SetFormatter(*custom_format); TCLAP::CmdLine cmd("Simple direct matrix solver test.\n\ diff --git a/SimpleTests/MeshTests/MeshRead.cpp b/SimpleTests/MeshTests/MeshRead.cpp index 886c0e1fbda015b3e3d497120d4f018726575f37..74e3770031cff679102ba8d7d832305c2216a143 100644 --- a/SimpleTests/MeshTests/MeshRead.cpp +++ b/SimpleTests/MeshTests/MeshRead.cpp @@ -31,8 +31,8 @@ int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog::Cout *logogCout(new logog::Cout); + auto* custom_format(new BaseLib::LogogSimpleFormatter); + auto* logogCout(new logog::Cout); logogCout->SetFormatter(*custom_format); TCLAP::CmdLine cmd("Simple mesh loading test", ' ', "0.1"); diff --git a/SimpleTests/MeshTests/MeshSearchTest.cpp b/SimpleTests/MeshTests/MeshSearchTest.cpp index f38981a1c77e7648241332c89003a5c0cc5c14ae..f9c08b47106b25575faebf9c2993b6f6b9089a2b 100644 --- a/SimpleTests/MeshTests/MeshSearchTest.cpp +++ b/SimpleTests/MeshTests/MeshSearchTest.cpp @@ -36,7 +36,7 @@ void testMeshGridAlgorithm(MeshLib::Mesh const*const mesh, std::size_t n_nodes(mesh->getNodes().size()); mesh_nodes.reserve(n_nodes); for (std::size_t k(0); k<n_nodes; k++) { - mesh_nodes.push_back(MeshLib::Node(*(mesh->getNodes()[k]))); + mesh_nodes.emplace_back(*(mesh->getNodes()[k])); } #ifndef WIN32 BaseLib::MemWatch mem_watch; @@ -91,8 +91,8 @@ void testMeshGridAlgorithm(MeshLib::Mesh const*const mesh, int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); + auto* logog_cout(new logog::Cout); + auto* custom_format(new BaseLib::LogogSimpleFormatter); logog_cout->SetFormatter(*custom_format); TCLAP::CmdLine cmd("Simple mesh search test", ' ', "0.1"); diff --git a/Tests/BaseLib/TestFunctional.cpp b/Tests/BaseLib/TestFunctional.cpp index 6c2b3a3781139fbc04e897c37ec27246d4ec71af..9d00332a1bdc5a8511776e38176c2ec35d85ffd6 100644 --- a/Tests/BaseLib/TestFunctional.cpp +++ b/Tests/BaseLib/TestFunctional.cpp @@ -17,7 +17,7 @@ class A : private InstanceCounter<A> { public: A(const double value) : _value(value) {} - A(A const& other) : InstanceCounter(other), _value(other._value) {} + A(A const& other) = default; A(A&& other) : InstanceCounter(std::move(other)), _value(other._value) {} A& operator=(A const& other) { _value = other._value; return *this; } A& operator=(A&& other) { _value = other._value; return *this; } diff --git a/Tests/BaseLib/TestQuicksort.cpp b/Tests/BaseLib/TestQuicksort.cpp index f41a4d2133ca7c7f178fe7f6d1eb33972e6a5e9d..56f287f7c023b3421404dfdc6f2023aea3bc53b3 100644 --- a/Tests/BaseLib/TestQuicksort.cpp +++ b/Tests/BaseLib/TestQuicksort.cpp @@ -29,7 +29,7 @@ namespace ac = autocheck; struct BaseLibQuicksort : public ::testing::Test { - virtual void SetUp() + void SetUp() override { cls.trivial([](const std::vector<int>& xs) { @@ -73,7 +73,7 @@ template <typename T> struct OrderedUniqueListGen { ac::generator<std::vector<T>> source; - typedef std::vector<T> result_type; + using result_type = std::vector<T>; std::vector<T> operator()(std::size_t size) { diff --git a/Tests/FileIO/TestCsvReader.cpp b/Tests/FileIO/TestCsvReader.cpp index f869ff36d1194e4c2b15694ae27c7f3417018594..20899151201ffec07c2526638344c4fbc8056b83 100644 --- a/Tests/FileIO/TestCsvReader.cpp +++ b/Tests/FileIO/TestCsvReader.cpp @@ -41,10 +41,7 @@ public: out.close(); } - ~CsvInterfaceTest() - { - std::remove(_file_name.c_str()); - } + ~CsvInterfaceTest() override { std::remove(_file_name.c_str()); } protected: int _result; diff --git a/Tests/FileIO/TestGmlInterface.h b/Tests/FileIO/TestGmlInterface.h index 9c367ac2e7ba31970bde93a38460548004e4b85c..a312ff756d4992a67529aed50f9627a3173e2eb9 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()) @@ -111,8 +112,7 @@ public: auto lines = std::unique_ptr<std::vector<GeoLib::Polyline*>>( new std::vector<GeoLib::Polyline*>(5)); - std::map<std::string, std::size_t>* name_map = - new std::map<std::string, std::size_t>; + auto* name_map = new std::map<std::string, std::size_t>; createPolyline(pnt_vec, *(lines.get()), 0, {0, 1, 2}, *name_map, "left"); createPolyline(pnt_vec, *(lines.get()), 1, {3, 4, 5}, *name_map, "center"); @@ -157,8 +157,7 @@ public: auto sfcs = std::unique_ptr<std::vector<GeoLib::Surface*>>( new std::vector<GeoLib::Surface*>(2)); - std::map<std::string, std::size_t>* sfc_names = - new std::map<std::string, std::size_t>; + auto* sfc_names = new std::map<std::string, std::size_t>; (*sfcs)[0] = new GeoLib::Surface(*points); (*sfcs)[0]->addTriangle(pnt_id_map[0], pnt_id_map[3], pnt_id_map[1]); (*sfcs)[0]->addTriangle(pnt_id_map[1], pnt_id_map[3], pnt_id_map[4]); diff --git a/Tests/GeoLib/AutoCheckGenerators.h b/Tests/GeoLib/AutoCheckGenerators.h index 28c799d09393e72b7cd5476f32e1217e63b9e6e2..99abfb6572efe6fc6c8b62aab9733cc2a175db92 100644 --- a/Tests/GeoLib/AutoCheckGenerators.h +++ b/Tests/GeoLib/AutoCheckGenerators.h @@ -11,6 +11,7 @@ #include <cmath> #include <memory> #include <random> +#include <utility> #include "autocheck/autocheck.hpp" #include "MathLib/Point3d.h" @@ -55,9 +56,8 @@ template <typename Gen = RandomCirclePointGeneratorXY<generator<double>>> struct SymmSegmentGeneratorXY { SymmSegmentGeneratorXY( - Gen s, - std::function<MathLib::Point3d(MathLib::Point3d const&)> f) - : source(s), function(f) + Gen s, std::function<MathLib::Point3d(MathLib::Point3d const&)> f) + : source(std::move(s)), function(std::move(f)) {} using result_type = GeoLib::LineSegment; @@ -82,7 +82,7 @@ struct PairSegmentGeneratorXY { PairSegmentGeneratorXY( Gen s, std::function<GeoLib::LineSegment(GeoLib::LineSegment const&)> f) - : segment_generator(s), function(f) + : segment_generator(std::move(s)), function(std::move(f)) { } diff --git a/Tests/GeoLib/IO/TestGLIReader.cpp b/Tests/GeoLib/IO/TestGLIReader.cpp index 07ded9b7bff8ee35d0e3cfd8d8499cff5a3198e5..74e4069786702eed4db2fb5360caab09f111abfd 100644 --- a/Tests/GeoLib/IO/TestGLIReader.cpp +++ b/Tests/GeoLib/IO/TestGLIReader.cpp @@ -37,10 +37,7 @@ public: gli_out.close(); } - ~OGSIOVer4InterfaceTest() - { - std::remove(_gli_fname.c_str()); - } + ~OGSIOVer4InterfaceTest() override { std::remove(_gli_fname.c_str()); } protected: std::string _gli_fname; diff --git a/Tests/GeoLib/TestAABB.cpp b/Tests/GeoLib/TestAABB.cpp index 09f233a1c76195f5c9c2d98f93c7af4749d8d644..31db275f6e220b1ff91872d6a37841a981b93972 100644 --- a/Tests/GeoLib/TestAABB.cpp +++ b/Tests/GeoLib/TestAABB.cpp @@ -54,8 +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 (std::list<GeoLib::Point*>::iterator it(pnts_list.begin()); it != pnts_list.end(); it++) { - delete *it; + for (auto& point : pnts_list) + { + delete point; } } @@ -71,7 +72,9 @@ TEST(GeoLibAABB, RandomNumberOfPointsRandomPointInAList) // fill list with points std::list<GeoLib::Point> pnts_list; for (int k(0); k<n; k++) { - pnts_list.push_back(GeoLib::Point(rand() % box_size - half_box_size, rand() % box_size - half_box_size, rand() % box_size - half_box_size)); + pnts_list.emplace_back(rand() % box_size - half_box_size, + rand() % box_size - half_box_size, + rand() % box_size - half_box_size); } // construct from list points a axis algined bounding box @@ -122,8 +125,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 (std::vector<GeoLib::Point*>::iterator it(pnts.begin()); it != pnts.end(); it++) { - delete *it; + for (auto& point : pnts) + { + delete point; } } @@ -139,7 +143,9 @@ TEST(GeoLibAABB, RandomNumberOfPointsRandomPointInAVector) // fill list with points std::list<GeoLib::Point> pnts; for (int k(0); k<n; k++) { - pnts.push_back(GeoLib::Point(rand() % box_size - half_box_size, rand() % box_size - half_box_size, rand() % box_size - half_box_size)); + pnts.emplace_back(rand() % box_size - half_box_size, + rand() % box_size - half_box_size, + rand() % box_size - half_box_size); } // construct from list points a axis algined bounding box @@ -170,14 +176,16 @@ TEST(GeoLibAABB, RandomNumberOfPointsRandomBox) double half_box_size_x(box_size_x/2); double half_box_size_y(box_size_y/2); double half_box_size_z(box_size_z/2); - int minus_half_box_size_x(static_cast<int>(-half_box_size_x)); - int minus_half_box_size_y(static_cast<int>(-half_box_size_y)); - int minus_half_box_size_z(static_cast<int>(-half_box_size_z)); + auto minus_half_box_size_x(static_cast<int>(-half_box_size_x)); + auto minus_half_box_size_y(static_cast<int>(-half_box_size_y)); + auto minus_half_box_size_z(static_cast<int>(-half_box_size_z)); // fill list with points std::list<GeoLib::Point> pnts; for (int k(0); k<n; k++) { - pnts.push_back(GeoLib::Point(rand() % box_size_x - half_box_size_x, rand() % box_size_y - half_box_size_y, rand() % box_size_z - half_box_size_z)); + pnts.emplace_back(rand() % box_size_x - half_box_size_x, + rand() % box_size_y - half_box_size_y, + rand() % box_size_z - half_box_size_z); } // construct from list points a axis aligned bounding box @@ -224,8 +232,8 @@ TEST(GeoLib, AABBAllPointsWithNegativeCoordinatesII) { std::vector<GeoLib::Point> pnts; - pnts.push_back(GeoLib::Point(-1, -1, -1)); - pnts.push_back(GeoLib::Point(-10, -10, -10)); + pnts.emplace_back(-1, -1, -1); + pnts.emplace_back(-10, -10, -10); // construct from points of the vector a axis aligned bounding box GeoLib::AABB aabb(pnts.begin(), pnts.end()); diff --git a/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp b/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp index 78bc6274fe099a2a83daece259b85632cd85cb5d..a2790dc9269c88518f958cf919095f0f10aafe29 100644 --- a/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp +++ b/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp @@ -49,13 +49,13 @@ TEST(GeoLib, TestComputeAndInsertAllIntersectionPoints) // *** create polylines auto& pnts = *geo_objs.getPointVec(geo_name); - GeoLib::Polyline* ply0(new GeoLib::Polyline(pnts)); + auto* ply0(new GeoLib::Polyline(pnts)); ply0->addPoint(0); ply0->addPoint(1); - GeoLib::Polyline* ply1(new GeoLib::Polyline(pnts)); + auto* ply1(new GeoLib::Polyline(pnts)); for (std::size_t k(2); k<pnts.size(); ++k) ply1->addPoint(k); - std::vector<GeoLib::Polyline*>* plys(new std::vector<GeoLib::Polyline*>); + auto* plys(new std::vector<GeoLib::Polyline*>); plys->push_back(ply0); plys->push_back(ply1); diff --git a/Tests/GeoLib/TestDuplicateGeometry.cpp b/Tests/GeoLib/TestDuplicateGeometry.cpp index 49e7f2d1eb019fc40ac4683fee7fb3d02ce11614..752e598870ac8b084115417275e4d00c8f6f73a3 100644 --- a/Tests/GeoLib/TestDuplicateGeometry.cpp +++ b/Tests/GeoLib/TestDuplicateGeometry.cpp @@ -72,7 +72,7 @@ TEST(GeoLib, DuplicateGeometry) for (std::size_t i=0; i<n_plys; ++i) { int n_ply_pnts (rand() % 100 + 2); - GeoLib::Polyline* line = new GeoLib::Polyline(*geo.getPointVec(input_name)); + auto* line = new GeoLib::Polyline(*geo.getPointVec(input_name)); for (std::size_t j=0; j<static_cast<std::size_t>(n_ply_pnts); ++j) line->addPoint(rand() % n_pnts); plys->push_back(line); @@ -110,7 +110,7 @@ TEST(GeoLib, DuplicateGeometry) for (std::size_t i=0; i<n_sfcs; ++i) { int n_tris (rand() % 10); - GeoLib::Surface* sfc = new GeoLib::Surface(*geo.getPointVec(input_name)); + auto* sfc = new GeoLib::Surface(*geo.getPointVec(input_name)); for (std::size_t j=0; j<static_cast<std::size_t>(n_tris); ++j) sfc->addTriangle(rand() % n_pnts, rand() % n_pnts, rand() % n_pnts); if (sfc->getNumberOfTriangles() > 0) @@ -146,7 +146,7 @@ TEST(GeoLib, DuplicateGeometry) mod_pnts.push_back(new GeoLib::Point(1,0,0,n_pnts)); mod_pnts.push_back(new GeoLib::Point(0,1,0,n_pnts+1)); mod_pnts.push_back(new GeoLib::Point(0,0,1,n_pnts+2)); - GeoLib::Surface* sfc = new GeoLib::Surface(mod_pnts); + auto* sfc = new GeoLib::Surface(mod_pnts); sfc->addTriangle(n_pnts, n_pnts+1, n_pnts+2); mod_sfcs.push_back(sfc); ASSERT_EQ(mod_sfcs.size(), sfcs->size() + 1); diff --git a/Tests/GeoLib/TestGEOObjectsMerge.cpp b/Tests/GeoLib/TestGEOObjectsMerge.cpp index 0d79affa1d36010dd1984e2b4264b3828cc4b6af..9c137a4425fbcb81e37f236b7e429c70bdccba1d 100644 --- a/Tests/GeoLib/TestGEOObjectsMerge.cpp +++ b/Tests/GeoLib/TestGEOObjectsMerge.cpp @@ -23,7 +23,7 @@ void createSetOfTestPointsAndAssociatedNames(GeoLib::GEOObjects & geo_objs, std: { auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( new std::vector<GeoLib::Point*>); - std::map<std::string, std::size_t>* pnt_name_map(new std::map< std::string, std::size_t>); + auto* pnt_name_map(new std::map<std::string, std::size_t>); const std::size_t pnts_per_edge(8); for (std::size_t k(0); k < pnts_per_edge; k++) { @@ -52,11 +52,11 @@ TEST(GeoLib, GEOObjectsMergePoints) // *** insert set of points number 0 GeoLib::Point shift (0.0,0.0,0.0); - names.push_back("PointSet0"); + names.emplace_back("PointSet0"); createSetOfTestPointsAndAssociatedNames(geo_objs, names[0], shift); // *** insert set of points number 1 - names.push_back("PointSet1"); + names.emplace_back("PointSet1"); createSetOfTestPointsAndAssociatedNames(geo_objs, names[1], shift); // *** merge geometries @@ -75,7 +75,7 @@ TEST(GeoLib, GEOObjectsMergePoints) // *** insert "shifted" set of points shift[0] += 1e-4; - names.push_back("ShiftedPointSet"); + names.emplace_back("ShiftedPointSet"); createSetOfTestPointsAndAssociatedNames(geo_objs, names[2], shift); // *** merge PointSet0, PointSet1 and ShiftedPointSet @@ -120,7 +120,7 @@ TEST(GeoLib, GEOObjectsMergePointsAndPolylines) geo_objs.addPointVec(std::move(pnts), geometry_0, nullptr, std::numeric_limits<double>::epsilon()); // *** insert polyline - GeoLib::Polyline* ply(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_0))); + auto* ply(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_0))); ply->addPoint(0); ply->addPoint(1); ply->addPoint(2); @@ -134,7 +134,7 @@ TEST(GeoLib, GEOObjectsMergePointsAndPolylines) // *** insert set of points number GeoLib::Point shift (0.0,0.0,0.0); - names.push_back("PointSet0"); + names.emplace_back("PointSet0"); createSetOfTestPointsAndAssociatedNames(geo_objs, names[1], shift); // *** merge geometries @@ -169,7 +169,7 @@ TEST(GeoLib, GEOObjectsMergePolylinesWithNames) std::numeric_limits<double>::epsilon()); // *** insert a named polyline into geometry - GeoLib::Polyline* ply_00(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_0))); + auto* ply_00(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_0))); ply_00->addPoint(0); ply_00->addPoint(1); ply_00->addPoint(2); @@ -178,7 +178,7 @@ TEST(GeoLib, GEOObjectsMergePolylinesWithNames) auto plys_0 = std::unique_ptr<std::vector<GeoLib::Polyline*>>( new std::vector<GeoLib::Polyline*>); plys_0->push_back(ply_00); - std::map<std::string, std::size_t> *names_map_0(new std::map<std::string, std::size_t>); + auto* names_map_0(new std::map<std::string, std::size_t>); names_map_0->insert(std::pair<std::string, std::size_t>("Polyline0FromGeometry0", 0)); geo_objs.addPolylineVec(std::move(plys_0), geometry_0, names_map_0); names.push_back(geometry_0); @@ -198,17 +198,17 @@ TEST(GeoLib, GEOObjectsMergePolylinesWithNames) std::numeric_limits<double>::epsilon()); // *** insert a named polyline into geometry - GeoLib::Polyline* ply_10(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_1))); + auto* ply_10(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_1))); ply_10->addPoint(0); ply_10->addPoint(1); - GeoLib::Polyline* ply_11(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_1))); + auto* ply_11(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_1))); ply_11->addPoint(2); ply_11->addPoint(3); auto plys_1 = std::unique_ptr<std::vector<GeoLib::Polyline*>>( new std::vector<GeoLib::Polyline*>); plys_1->push_back(ply_10); plys_1->push_back(ply_11); - std::map<std::string, std::size_t> *names_map_1(new std::map<std::string, std::size_t>); + auto* names_map_1(new std::map<std::string, std::size_t>); names_map_1->insert(std::pair<std::string, std::size_t>("Polyline0FromGeometry1", 0)); names_map_1->insert(std::pair<std::string, std::size_t>("Polyline1FromGeometry1", 1)); geo_objs.addPolylineVec(std::move(plys_1), geometry_1, names_map_1); diff --git a/Tests/GeoLib/TestOctTree.cpp b/Tests/GeoLib/TestOctTree.cpp index b2bd67de059042cbb3f719cb7651fd9a88a6fe34..420f286b6383c597fd193d707d9231b0d3e8c66b 100644 --- a/Tests/GeoLib/TestOctTree.cpp +++ b/Tests/GeoLib/TestOctTree.cpp @@ -18,12 +18,10 @@ class GeoLibOctTree : public testing::Test { public: - typedef std::vector<GeoLib::Point*> VectorOfPoints; + using VectorOfPoints = std::vector<GeoLib::Point*>; - GeoLibOctTree() - {} - - ~GeoLibOctTree() + GeoLibOctTree() = default; + ~GeoLibOctTree() override { for (auto p : ps_ptr) { delete p; diff --git a/Tests/GeoLib/TestPointVec.cpp b/Tests/GeoLib/TestPointVec.cpp index 9bed724baeac800fec3e83e3b73639bc03414242..cf6792dcc15caf8227687d46e8fe639677d0bf77 100644 --- a/Tests/GeoLib/TestPointVec.cpp +++ b/Tests/GeoLib/TestPointVec.cpp @@ -15,7 +15,7 @@ class PointVecTest : public testing::Test { public: - typedef std::vector<GeoLib::Point*> VectorOfPoints; + using VectorOfPoints = std::vector<GeoLib::Point*>; PointVecTest() : gen(std::random_device() ()), name("JustAName") diff --git a/Tests/GeoLib/TestPolygon.cpp b/Tests/GeoLib/TestPolygon.cpp index 1dff53f6f7234df32bcf1f53e6cd82ccfbb2da11..5070f65c72b248caddf5c8616c7a529c5f841a43 100644 --- a/Tests/GeoLib/TestPolygon.cpp +++ b/Tests/GeoLib/TestPolygon.cpp @@ -64,7 +64,7 @@ public: _polygon = new GeoLib::Polygon(ply); } - ~PolygonTest() + ~PolygonTest() override { delete _polygon; for (auto & _pnt : _pnts) diff --git a/Tests/GeoLib/TestSimplePolygonTree.cpp b/Tests/GeoLib/TestSimplePolygonTree.cpp index 59194f629f41563e23f24d6481248227b9fa1338..8ab47d9ae1ca979898b18727a7cb2e0815c5d4aa 100644 --- a/Tests/GeoLib/TestSimplePolygonTree.cpp +++ b/Tests/GeoLib/TestSimplePolygonTree.cpp @@ -86,7 +86,7 @@ public: _p3 = new GeoLib::Polygon(ply3); } - ~CreatePolygonTreesTest() + ~CreatePolygonTreesTest() override { delete _p0; delete _p1; @@ -106,8 +106,8 @@ protected: TEST_F(CreatePolygonTreesTest, P0AndP1) { - GeoLib::SimplePolygonTree *pt0(new GeoLib::SimplePolygonTree(_p0, nullptr)); - GeoLib::SimplePolygonTree *pt1(new GeoLib::SimplePolygonTree(_p1, nullptr)); + auto* pt0(new GeoLib::SimplePolygonTree(_p0, nullptr)); + auto* pt1(new GeoLib::SimplePolygonTree(_p1, nullptr)); std::list<GeoLib::SimplePolygonTree*> pt_list; pt_list.push_back(pt0); @@ -121,9 +121,9 @@ TEST_F(CreatePolygonTreesTest, P0AndP1) TEST_F(CreatePolygonTreesTest, P0AndP1AndP2) { - GeoLib::SimplePolygonTree *pt0(new GeoLib::SimplePolygonTree(_p0, nullptr)); - GeoLib::SimplePolygonTree *pt1(new GeoLib::SimplePolygonTree(_p1, nullptr)); - GeoLib::SimplePolygonTree *pt2(new GeoLib::SimplePolygonTree(_p2, nullptr)); + auto* pt0(new GeoLib::SimplePolygonTree(_p0, nullptr)); + auto* pt1(new GeoLib::SimplePolygonTree(_p1, nullptr)); + auto* pt2(new GeoLib::SimplePolygonTree(_p2, nullptr)); std::list<GeoLib::SimplePolygonTree*> pt_list; pt_list.push_back(pt0); @@ -146,10 +146,10 @@ TEST_F(CreatePolygonTreesTest, P0AndP1AndP2) TEST_F(CreatePolygonTreesTest, P0AndP1AndP2AndP3) { - GeoLib::SimplePolygonTree *pt0(new GeoLib::SimplePolygonTree(_p0, nullptr)); - GeoLib::SimplePolygonTree *pt1(new GeoLib::SimplePolygonTree(_p1, nullptr)); - GeoLib::SimplePolygonTree *pt2(new GeoLib::SimplePolygonTree(_p2, nullptr)); - GeoLib::SimplePolygonTree *pt3(new GeoLib::SimplePolygonTree(_p3, nullptr)); + auto* pt0(new GeoLib::SimplePolygonTree(_p0, nullptr)); + auto* pt1(new GeoLib::SimplePolygonTree(_p1, nullptr)); + auto* pt2(new GeoLib::SimplePolygonTree(_p2, nullptr)); + auto* pt3(new GeoLib::SimplePolygonTree(_p3, nullptr)); std::list<GeoLib::SimplePolygonTree*> pt_list; pt_list.push_back(pt0); diff --git a/Tests/GeoLib/TestSortSegments.cpp b/Tests/GeoLib/TestSortSegments.cpp index c6ca27d8d78cc3d345214f3e3fe5f080cbc00bda..9411d23c9d665c6c63d6c3ebc4c7b44e79e60a93 100644 --- a/Tests/GeoLib/TestSortSegments.cpp +++ b/Tests/GeoLib/TestSortSegments.cpp @@ -50,12 +50,12 @@ TEST_F(GeoLibSortLineSegments, SortSubSegments) for (auto sub_seg_id : sub_seg_ids) { double t(dt * sub_seg_id); - GeoLib::Point* sub_seg_begin_pnt(new GeoLib::Point{ + auto* sub_seg_begin_pnt(new GeoLib::Point{ (1 - t) * s0.getBeginPoint()[0] + t * s0.getEndPoint()[0], (1 - t) * s0.getBeginPoint()[1] + t * s0.getEndPoint()[1], (1 - t) * s0.getBeginPoint()[2] + t * s0.getEndPoint()[2]}); t += dt; - GeoLib::Point* sub_seg_end_pnt(new GeoLib::Point{ + auto* sub_seg_end_pnt(new GeoLib::Point{ (1 - t) * s0.getBeginPoint()[0] + t * s0.getEndPoint()[0], (1 - t) * s0.getBeginPoint()[1] + t * s0.getEndPoint()[1], (1 - t) * s0.getBeginPoint()[2] + t * s0.getEndPoint()[2]}); diff --git a/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp b/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp index 7fb4d0d0fee5bb6aed91f13d85ee928d2cb42991..b9eb573b814482265fb6c2b559375598f0314485 100644 --- a/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp +++ b/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp @@ -77,8 +77,8 @@ getRotMat(double alpha, double beta, double gamma) TEST(GeoLib, SurfaceIsPointInSurface) { std::vector<std::function<double(double, double)>> surface_functions; - surface_functions.push_back(constant); - surface_functions.push_back(coscos); + surface_functions.emplace_back(constant); + surface_functions.emplace_back(coscos); for (const auto& f : surface_functions) { std::random_device rd; diff --git a/Tests/MathLib/TestDenseGaussAlgorithm.cpp b/Tests/MathLib/TestDenseGaussAlgorithm.cpp index 42ad9e4c2e747222565f59d9e1891f95af2f56ee..f7a9703501ae4b6526639d66f3218124fe0d32f8 100644 --- a/Tests/MathLib/TestDenseGaussAlgorithm.cpp +++ b/Tests/MathLib/TestDenseGaussAlgorithm.cpp @@ -38,7 +38,7 @@ TEST(MathLib, DenseGaussAlgorithm) } // *** create solution vector, set all entries to 0.0 - double *x(new double[n_cols]); + auto* x(new double[n_cols]); std::fill(x,x+n_cols, 0.0); double *b0(mat * x); @@ -53,7 +53,7 @@ TEST(MathLib, DenseGaussAlgorithm) // right hand side and solution vector with random entries double *b3(mat * x); double *b3_copy(mat * x); - double *x3 (new double[n_cols]); + auto* x3(new double[n_cols]); std::generate(x3,x3+n_cols, std::rand); MathLib::GaussAlgorithm<MathLib::DenseMatrix<double, std::size_t>, double*> gauss; diff --git a/Tests/MeshLib/MeshProperties.cpp b/Tests/MeshLib/MeshProperties.cpp index db3a116880e77d69b8ef488ec879f82d9c76d849..8f4e8e5e99a3fb035117b8486c108471179bea77 100644 --- a/Tests/MeshLib/MeshProperties.cpp +++ b/Tests/MeshLib/MeshProperties.cpp @@ -26,11 +26,7 @@ public: mesh = MeshLib::MeshGenerator::generateRegularHexMesh(1.0, mesh_size); } - ~MeshLibProperties() - { - delete mesh; - } - + ~MeshLibProperties() override { delete mesh; } static std::size_t const mesh_size = 5; MeshLib::Mesh * mesh; }; @@ -145,17 +141,12 @@ TEST_F(MeshLibProperties, AddDoublePointerProperties) std::vector<std::size_t> prop_item2group_mapping(n_items); // create simple mat_group to index mapping for (std::size_t j(0); j<n_prop_val_groups; j++) { - std::size_t const lower( - static_cast<std::size_t>( - (static_cast<double>(j)/n_prop_val_groups)*n_items - ) - ); - std::size_t const upper( - static_cast<std::size_t>( - (static_cast<double>(j+1)/n_prop_val_groups)*n_items - ) - ); - for (std::size_t k(lower); k<upper; k++) { + auto const lower(static_cast<std::size_t>( + (static_cast<double>(j) / n_prop_val_groups) * n_items)); + auto const upper(static_cast<std::size_t>( + (static_cast<double>(j + 1) / n_prop_val_groups) * n_items)); + for (std::size_t k(lower); k < upper; k++) + { prop_item2group_mapping[k] = j; } } @@ -172,19 +163,14 @@ TEST_F(MeshLibProperties, AddDoublePointerProperties) } // check mapping to values for (std::size_t i(0); i<n_prop_val_groups; i++) { - std::size_t const lower( - static_cast<std::size_t>( - (static_cast<double>(i)/n_prop_val_groups)*n_items - ) - ); - std::size_t const upper( - static_cast<std::size_t>( - (static_cast<double>(i+1)/n_prop_val_groups)*n_items - ) - ); - for (std::size_t k(lower); k<upper; k++) { - ASSERT_NEAR(static_cast<double>(i+1), *(*group_properties)[k], - std::numeric_limits<double>::epsilon()); + auto const lower(static_cast<std::size_t>( + (static_cast<double>(i) / n_prop_val_groups) * n_items)); + auto const upper(static_cast<std::size_t>( + (static_cast<double>(i + 1) / n_prop_val_groups) * n_items)); + for (std::size_t k(lower); k < upper; k++) + { + ASSERT_NEAR(static_cast<double>(i + 1), *(*group_properties)[k], + std::numeric_limits<double>::epsilon()); } } @@ -213,17 +199,12 @@ TEST_F(MeshLibProperties, AddArrayPointerProperties) std::vector<std::size_t> prop_item2group_mapping(n_items); // create simple mat_group to index mapping for (std::size_t j(0); j<n_prop_val_groups; j++) { - std::size_t const lower( - static_cast<std::size_t>( - (static_cast<double>(j)/n_prop_val_groups)*n_items - ) - ); - std::size_t const upper( - static_cast<std::size_t>( - (static_cast<double>(j+1)/n_prop_val_groups)*n_items - ) - ); - for (std::size_t k(lower); k<upper; k++) { + auto const lower(static_cast<std::size_t>( + (static_cast<double>(j) / n_prop_val_groups) * n_items)); + auto const upper(static_cast<std::size_t>( + (static_cast<double>(j + 1) / n_prop_val_groups) * n_items)); + for (std::size_t k(lower); k < upper; k++) + { prop_item2group_mapping[k] = j; } } @@ -244,23 +225,18 @@ TEST_F(MeshLibProperties, AddArrayPointerProperties) } // check the mapping to values for (std::size_t i(0); i<n_prop_val_groups; i++) { - std::size_t const lower( - static_cast<std::size_t>( - (static_cast<double>(i)/n_prop_val_groups)*n_items - ) - ); - std::size_t const upper( - static_cast<std::size_t>( - (static_cast<double>(i+1)/n_prop_val_groups)*n_items - ) - ); - for (std::size_t k(lower); k<upper; k++) { + auto const lower(static_cast<std::size_t>( + (static_cast<double>(i) / n_prop_val_groups) * n_items)); + auto const upper(static_cast<std::size_t>( + (static_cast<double>(i + 1) / n_prop_val_groups) * n_items)); + for (std::size_t k(lower); k < upper; k++) + { ASSERT_NEAR(static_cast<double>(i), (*(*group_prop_vec)[k])[0], - std::numeric_limits<double>::epsilon()); - ASSERT_NEAR(static_cast<double>(i+1), (*(*group_prop_vec)[k])[1], - std::numeric_limits<double>::epsilon()); - ASSERT_NEAR(static_cast<double>(i+2), (*(*group_prop_vec)[k])[2], - std::numeric_limits<double>::epsilon()); + std::numeric_limits<double>::epsilon()); + ASSERT_NEAR(static_cast<double>(i + 1), (*(*group_prop_vec)[k])[1], + std::numeric_limits<double>::epsilon()); + ASSERT_NEAR(static_cast<double>(i + 2), (*(*group_prop_vec)[k])[2], + std::numeric_limits<double>::epsilon()); } } @@ -297,17 +273,12 @@ TEST_F(MeshLibProperties, AddVariousDifferentProperties) std::vector<std::size_t> prop_item2group_mapping(n_items); // create simple mat_group to index mapping for (std::size_t j(0); j<n_prop_val_groups; j++) { - std::size_t const lower( - static_cast<std::size_t>( - (static_cast<double>(j)/n_prop_val_groups)*n_items - ) - ); - std::size_t const upper( - static_cast<std::size_t>( - (static_cast<double>(j+1)/n_prop_val_groups)*n_items - ) - ); - for (std::size_t k(lower); k<upper; k++) { + auto const lower(static_cast<std::size_t>( + (static_cast<double>(j) / n_prop_val_groups) * n_items)); + auto const upper(static_cast<std::size_t>( + (static_cast<double>(j + 1) / n_prop_val_groups) * n_items)); + for (std::size_t k(lower); k < upper; k++) + { prop_item2group_mapping[k] = j; } } @@ -436,17 +407,12 @@ TEST_F(MeshLibProperties, CopyConstructor) std::vector<std::size_t> prop_item2group_mapping(n_items); // create simple mat_group to index mapping for (std::size_t j(0); j<n_prop_val_groups; j++) { - std::size_t const lower( - static_cast<std::size_t>( - (static_cast<double>(j)/n_prop_val_groups)*n_items - ) - ); - std::size_t const upper( - static_cast<std::size_t>( - (static_cast<double>(j+1)/n_prop_val_groups)*n_items - ) - ); - for (std::size_t k(lower); k<upper; k++) { + auto const lower(static_cast<std::size_t>( + (static_cast<double>(j) / n_prop_val_groups) * n_items)); + auto const upper(static_cast<std::size_t>( + (static_cast<double>(j + 1) / n_prop_val_groups) * n_items)); + for (std::size_t k(lower); k < upper; k++) + { prop_item2group_mapping[k] = j; } } diff --git a/Tests/MeshLib/TestAddLayerToMesh.cpp b/Tests/MeshLib/TestAddLayerToMesh.cpp index b27105f52326922182e911bdab46aa8a5965a8d6..47a74767081947b7940115bf238fb2869d862797 100644 --- a/Tests/MeshLib/TestAddLayerToMesh.cpp +++ b/Tests/MeshLib/TestAddLayerToMesh.cpp @@ -27,7 +27,8 @@ namespace AddLayerValidation { int const reduce_tests = (testNodeOrder) ? 0 : 1; - std::size_t const nErrorFlags (static_cast<std::size_t>(ElementErrorFlag::MaxValue)); + auto const nErrorFlags( + static_cast<std::size_t>(ElementErrorFlag::MaxValue)); ElementErrorFlag const flags[nErrorFlags] = {ElementErrorFlag::ZeroVolume, ElementErrorFlag::NonCoplanar, ElementErrorFlag::NonConvex, ElementErrorFlag::NodeOrder}; std::vector<ElementErrorCode> const codes (MeshLib::MeshValidation::testElementGeometry(mesh)); diff --git a/Tests/MeshLib/TestBoundaryElementSearch.cpp b/Tests/MeshLib/TestBoundaryElementSearch.cpp index ea2458c0913061f9a46c7c031fca4b646771094f..4ee32928d4758bb982755c2aad5d186786d5b422 100644 --- a/Tests/MeshLib/TestBoundaryElementSearch.cpp +++ b/Tests/MeshLib/TestBoundaryElementSearch.cpp @@ -47,7 +47,7 @@ public: _hex_mesh(MeshGenerator::generateRegularHexMesh(_geometric_size, _number_of_subdivisions_per_direction)) {} - ~MeshLibBoundaryElementSearchInSimpleHexMesh() + ~MeshLibBoundaryElementSearchInSimpleHexMesh() override { delete _hex_mesh; } diff --git a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp index 8bcb82a9b2b279a47b99c2030cc3b869c167cac0..87be1d7fa3d4a06c66fd8c4bf543ed69540d9277 100644 --- a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp +++ b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp @@ -34,16 +34,16 @@ namespace namespace TestLine2 { - typedef MeshLib::Line ElementType; - const unsigned e_nnodes = ElementType::n_all_nodes; +using ElementType = MeshLib::Line; +const unsigned e_nnodes = ElementType::n_all_nodes; - std::unique_ptr<MeshLib::Line> createLine( - std::array<double, 3> const& a, std::array<double, 3> const& b) - { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; - nodes[0] = new MeshLib::Node(a); - nodes[1] = new MeshLib::Node(b); - return std::unique_ptr<MeshLib::Line>{new MeshLib::Line(nodes)}; +std::unique_ptr<MeshLib::Line> createLine(std::array<double, 3> const& a, + std::array<double, 3> const& b) +{ + auto** nodes = new MeshLib::Node*[e_nnodes]; + nodes[0] = new MeshLib::Node(a); + nodes[1] = new MeshLib::Node(b); + return std::unique_ptr<MeshLib::Line>{new MeshLib::Line(nodes)}; } std::unique_ptr<MeshLib::Line> createY() @@ -72,19 +72,20 @@ namespace TestLine2 namespace TestQuad4 { // Element information - typedef MeshLib::Quad ElementType; - const unsigned e_nnodes = ElementType::n_all_nodes; +using ElementType = MeshLib::Quad; +const unsigned e_nnodes = ElementType::n_all_nodes; - std::unique_ptr<MeshLib::Quad> createQuad( - std::array<double, 3> const& a, std::array<double, 3> const& b, - std::array<double, 3> const& c, std::array<double, 3> const& d) - { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; - nodes[0] = new MeshLib::Node(a); - nodes[1] = new MeshLib::Node(b); - nodes[2] = new MeshLib::Node(c); - nodes[3] = new MeshLib::Node(d); - return std::unique_ptr<MeshLib::Quad>{new MeshLib::Quad(nodes)}; +std::unique_ptr<MeshLib::Quad> createQuad(std::array<double, 3> const& a, + std::array<double, 3> const& b, + std::array<double, 3> const& c, + std::array<double, 3> const& d) +{ + auto** nodes = new MeshLib::Node*[e_nnodes]; + nodes[0] = new MeshLib::Node(a); + nodes[1] = new MeshLib::Node(b); + nodes[2] = new MeshLib::Node(c); + nodes[3] = new MeshLib::Node(d); + return std::unique_ptr<MeshLib::Quad>{new MeshLib::Quad(nodes)}; } // 2.5D case: inclined diff --git a/Tests/MeshLib/TestLineMesh.cpp b/Tests/MeshLib/TestLineMesh.cpp index a26af03765c91dd2c8a35bff5c36d6685b974ae2..82d0323f12d949a9b8a914263cc14b3e9dd5915b 100644 --- a/Tests/MeshLib/TestLineMesh.cpp +++ b/Tests/MeshLib/TestLineMesh.cpp @@ -22,11 +22,7 @@ class MeshLibLineMesh : public ::testing::Test mesh = MeshLib::MeshGenerator::generateLineMesh(extent, mesh_size); } - ~MeshLibLineMesh() - { - delete mesh; - } - + ~MeshLibLineMesh() override { delete mesh; } static std::size_t const mesh_size = 9; double extent = 1.0; MeshLib::Mesh const* mesh; diff --git a/Tests/MeshLib/TestMeshNodeSearch.cpp b/Tests/MeshLib/TestMeshNodeSearch.cpp index 007974c9bbeb7d51c99285c05bcadb85a80fda28..c5e5190182955e4c04b33e64623a92e5fef08949 100644 --- a/Tests/MeshLib/TestMeshNodeSearch.cpp +++ b/Tests/MeshLib/TestMeshNodeSearch.cpp @@ -34,10 +34,7 @@ public: _quad_mesh(MeshGenerator::generateRegularQuadMesh(_geometric_size, _number_of_subdivisions_per_direction)) {} - ~MeshLibMeshNodeSearchInSimpleQuadMesh() - { - delete _quad_mesh; - } + ~MeshLibMeshNodeSearchInSimpleQuadMesh() override { delete _quad_mesh; } protected: const double _geometric_size; @@ -53,10 +50,7 @@ public: _hex_mesh(MeshGenerator::generateRegularHexMesh(_geometric_size, _number_of_subdivisions_per_direction)) {} - ~MeshLibMeshNodeSearchInSimpleHexMesh() - { - delete _hex_mesh; - } + ~MeshLibMeshNodeSearchInSimpleHexMesh() override { delete _hex_mesh; } protected: const double _geometric_size; diff --git a/Tests/MeshLib/TestMoveMeshNodes.cpp b/Tests/MeshLib/TestMoveMeshNodes.cpp index b1b940a95289b998c3f04320cadc57e98e00c846..c6971f012352feda48417c5875bbdd09c5560177 100644 --- a/Tests/MeshLib/TestMoveMeshNodes.cpp +++ b/Tests/MeshLib/TestMoveMeshNodes.cpp @@ -19,7 +19,7 @@ TEST(MeshLib, moveMeshNodes) { /* initialize random seed: */ - srand ( static_cast<unsigned>(time(NULL)) ); + srand(static_cast<unsigned>(time(nullptr))); std::size_t const size (16384); diff --git a/Tests/MeshLib/TestQuadMesh.cpp b/Tests/MeshLib/TestQuadMesh.cpp index f7802cf6149ac6e5131f7ded8842dd7298d736f1..a2bcf5120d7b145a757dcec1d52f9bb3cedddb45 100644 --- a/Tests/MeshLib/TestQuadMesh.cpp +++ b/Tests/MeshLib/TestQuadMesh.cpp @@ -23,11 +23,7 @@ class MeshLibQuadMesh : public ::testing::Test mesh = MeshLib::MeshGenerator::generateRegularQuadMesh(1.0, n_elements); } - ~MeshLibQuadMesh() - { - delete mesh; - } - + ~MeshLibQuadMesh() override { delete mesh; } static std::size_t const n_elements = 4; static std::size_t const n_nodes = n_elements + 1; static std::size_t const elements_stride = n_elements - 1; @@ -48,7 +44,7 @@ class MeshLibQuadMesh : public ::testing::Test return mesh->getNodes()[i * n_nodes + j]; } - typedef std::list<std::size_t> Indices; + using Indices = std::list<std::size_t>; Indices getNeighbor(std::size_t const i) const { std::list<std::size_t> result; diff --git a/Tests/MeshLib/TestQuadraticMesh.cpp b/Tests/MeshLib/TestQuadraticMesh.cpp index 5553a5727afd3638262c8999525deec93f17e3b3..2beafb3c85d88a77003a465cf3551574f2af74cd 100644 --- a/Tests/MeshLib/TestQuadraticMesh.cpp +++ b/Tests/MeshLib/TestQuadraticMesh.cpp @@ -119,7 +119,7 @@ TEST(MeshLib, QuadraticOrderMesh_LineQuad) std::vector<GeoLib::Point*> pnts; pnts.push_back(new GeoLib::Point(0,0.5,0,0)); pnts.push_back(new GeoLib::Point(1,0.5,0,1)); - GeoLib::Polyline* ply = new GeoLib::Polyline(pnts); + auto* ply = new GeoLib::Polyline(pnts); ply->addPoint(0); ply->addPoint(1); std::unique_ptr<std::vector<GeoLib::Polyline*>> plys(new std::vector<GeoLib::Polyline*>()); diff --git a/Tests/MeshLib/TestTriLineMesh.cpp b/Tests/MeshLib/TestTriLineMesh.cpp index 5d636af3753458119e6afd3fb9eeea7caaf25bc3..13d38fd1261afb94e52ae6a03bf7c022fe9b2194 100644 --- a/Tests/MeshLib/TestTriLineMesh.cpp +++ b/Tests/MeshLib/TestTriLineMesh.cpp @@ -45,7 +45,7 @@ class MeshLibTriLineMesh : public ::testing::Test mesh = new MeshLib::Mesh("M", nodes, elements); } - ~MeshLibTriLineMesh() + ~MeshLibTriLineMesh() override { /*std::remove_if(elements.begin(), elements.end(), [](MeshLib::Element* e) { delete e; return true; }); diff --git a/Tests/MeshLib/TestVtkMappedMeshSource.cpp b/Tests/MeshLib/TestVtkMappedMeshSource.cpp index deb5d6f879a07b64864653488dbdbc9bfa155b91..18dfde09c5bcd746d93147f8315a12d3afba4ef2 100644 --- a/Tests/MeshLib/TestVtkMappedMeshSource.cpp +++ b/Tests/MeshLib/TestVtkMappedMeshSource.cpp @@ -128,11 +128,7 @@ class InSituMesh : public ::testing::Test material_id_properties->begin(), material_id_properties->end(), 1); } - ~InSituMesh() - { - delete mesh; - } - + ~InSituMesh() override { delete mesh; } MeshLib::Mesh * mesh; const std::size_t subdivisions = 5; const double length = 1.0; diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestHex8.h b/Tests/NumLib/CoordinatesMappingTestData/TestHex8.h index 5072b65d4fb701d3587509fd22803910e2d79b61..726ab2713abc89523fbd69fec48d580298a43b2f 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestHex8.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestHex8.h @@ -18,47 +18,47 @@ class TestHex8 { public: // Element information - typedef MeshLib::Hex ElementType; - typedef NumLib::ShapeHex8 ShapeFunctionType; - static const unsigned global_dim = ElementType::dimension; - static const unsigned dim = 3; //ElementType::dimension; - static const unsigned e_nnodes = ElementType::n_all_nodes; - // Coordinates where shape functions are evaluated - static const double r[dim]; - // Expected results for natural shape - static const double nat_exp_N[e_nnodes]; - static const double nat_exp_dNdr[e_nnodes*dim]; - // Expected results for irregular shape - static const double ir_exp_J[dim*dim]; - static const double ir_exp_invJ[dim*dim]; - static const double ir_exp_detJ; - static const double ir_exp_dNdx[e_nnodes*dim]; - // Expected results for clock-wise node ordering - static const double cl_exp_J[dim*dim]; - // Expected results for zero volume - static const double cl_exp_detJ; - static const double ze_exp_J[dim*dim]; + using ElementType = MeshLib::Hex; + using ShapeFunctionType = NumLib::ShapeHex8; + static const unsigned global_dim = ElementType::dimension; + static const unsigned dim = 3; // ElementType::dimension; + static const unsigned e_nnodes = ElementType::n_all_nodes; + // Coordinates where shape functions are evaluated + static const double r[dim]; + // Expected results for natural shape + static const double nat_exp_N[e_nnodes]; + static const double nat_exp_dNdr[e_nnodes * dim]; + // Expected results for irregular shape + static const double ir_exp_J[dim * dim]; + static const double ir_exp_invJ[dim * dim]; + static const double ir_exp_detJ; + static const double ir_exp_dNdx[e_nnodes * dim]; + // Expected results for clock-wise node ordering + static const double cl_exp_J[dim * dim]; + // Expected results for zero volume + static const double cl_exp_detJ; + static const double ze_exp_J[dim * dim]; - // element shape identical to that in natural coordinates (see ShapeHex8.h) - MeshLib::Hex* createNaturalShape() - { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; - nodes[0] = new MeshLib::Node(-1.0, -1.0, -1.0); - nodes[1] = new MeshLib::Node( 1.0, -1.0, -1.0); - nodes[2] = new MeshLib::Node( 1.0, 1.0, -1.0); - nodes[3] = new MeshLib::Node(-1.0, 1.0, -1.0); - nodes[4] = new MeshLib::Node(-1.0, -1.0, 1.0); - nodes[5] = new MeshLib::Node( 1.0, -1.0, 1.0); - nodes[6] = new MeshLib::Node( 1.0, 1.0, 1.0); - nodes[7] = new MeshLib::Node(-1.0, 1.0, 1.0); - return new MeshLib::Hex(nodes); + // element shape identical to that in natural coordinates (see ShapeHex8.h) + MeshLib::Hex* createNaturalShape() + { + auto** nodes = new MeshLib::Node*[e_nnodes]; + nodes[0] = new MeshLib::Node(-1.0, -1.0, -1.0); + nodes[1] = new MeshLib::Node(1.0, -1.0, -1.0); + nodes[2] = new MeshLib::Node(1.0, 1.0, -1.0); + nodes[3] = new MeshLib::Node(-1.0, 1.0, -1.0); + nodes[4] = new MeshLib::Node(-1.0, -1.0, 1.0); + nodes[5] = new MeshLib::Node(1.0, -1.0, 1.0); + nodes[6] = new MeshLib::Node(1.0, 1.0, 1.0); + nodes[7] = new MeshLib::Node(-1.0, 1.0, 1.0); + return new MeshLib::Hex(nodes); } // element having irregular or skew shape MeshLib::Hex* createIrregularShape() { // two times longer in z direction than the natural - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(-1.0, -1.0, -1.0); nodes[1] = new MeshLib::Node( 1.0, -1.0, -1.0); nodes[2] = new MeshLib::Node( 1.0, 1.0, -1.0); @@ -73,7 +73,7 @@ class TestHex8 // invalid case: clock wise node ordering MeshLib::Hex* createClockWise() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(-1.0, -1.0, -1.0); nodes[3] = new MeshLib::Node( 1.0, -1.0, -1.0); nodes[2] = new MeshLib::Node( 1.0, 1.0, -1.0); @@ -88,7 +88,7 @@ class TestHex8 // invalid case: zero volume MeshLib::Hex* createZeroVolume() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(-1.0, -1.0, 1.0); nodes[1] = new MeshLib::Node( 1.0, -1.0, 1.0); nodes[2] = new MeshLib::Node( 1.0, 1.0, 1.0); diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestLine2.h b/Tests/NumLib/CoordinatesMappingTestData/TestLine2.h index a9ec867d8eb455cac4fd6be3ed394d82be9ee7f8..83e073ee7fcf474ce25d30459c3753139be76b26 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestLine2.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestLine2.h @@ -18,8 +18,8 @@ class TestLine2 { public: // Element information - typedef MeshLib::Line ElementType; - typedef NumLib::ShapeLine2 ShapeFunctionType; + using ElementType = MeshLib::Line; + using ShapeFunctionType = NumLib::ShapeLine2; static const unsigned global_dim = ElementType::dimension; static const unsigned dim = ElementType::dimension; static const unsigned e_nnodes = ElementType::n_all_nodes; @@ -42,7 +42,7 @@ public: // element shape identical to that in natural coordinates (see ShapeLine2.h) static MeshLib::Line* createNaturalShape() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(-1.0, 0.0, 0.0); nodes[1] = new MeshLib::Node( 1.0, 0.0, 0.0); return new MeshLib::Line(nodes); @@ -52,7 +52,7 @@ public: MeshLib::Line* createIrregularShape() { // two times longer than the natural - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(-2.0, 0.0, 0.0); nodes[1] = new MeshLib::Node( 2.0, 0.0, 0.0); return new MeshLib::Line(nodes); @@ -61,7 +61,7 @@ public: // invalid case: clock wise node ordering MeshLib::Line* createClockWise() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[1] = new MeshLib::Node(-1.0, 0.0, 0.0); nodes[0] = new MeshLib::Node( 1.0, 0.0, 0.0); return new MeshLib::Line(nodes); @@ -70,7 +70,7 @@ public: // invalid case: zero volume MeshLib::Line* createZeroVolume() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(0.0, 0.0, 0.0); return new MeshLib::Line(nodes); @@ -79,7 +79,7 @@ public: // 1.5d line static MeshLib::Line* createY() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, -1.0, 0.0); nodes[1] = new MeshLib::Node(0.0, 1.0, 0.0); return new MeshLib::Line(nodes); diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestLine3.h b/Tests/NumLib/CoordinatesMappingTestData/TestLine3.h index f15a1c8ce48d1604b86b4062e7492691c269823a..60dc84a34f1b7be54ff68bd1dcac28a524ea9177 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestLine3.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestLine3.h @@ -17,8 +17,8 @@ class TestLine3 { public: // Element information - typedef MeshLib::Line3 ElementType; - typedef NumLib::ShapeLine3 ShapeFunctionType; + using ElementType = MeshLib::Line3; + using ShapeFunctionType = NumLib::ShapeLine3; static const unsigned global_dim = ElementType::dimension; static const unsigned dim = ElementType::dimension; static const unsigned e_nnodes = ElementType::n_all_nodes; @@ -41,7 +41,7 @@ public: // element shape identical to that in natural coordinates (see ShapeLine3.h) static MeshLib::Line3* createNaturalShape() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(-1.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(1.0, 0.0, 0.0); nodes[2] = new MeshLib::Node(0.0, 0.0, 0.0); @@ -52,7 +52,7 @@ public: MeshLib::Line3* createIrregularShape() { // two times longer than the natural - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(-2.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(2.0, 0.0, 0.0); nodes[2] = new MeshLib::Node(0.0, 0.0, 0.0); @@ -62,7 +62,7 @@ public: // invalid case: clock wise node ordering MeshLib::Line3* createClockWise() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(1.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(-1.0, 0.0, 0.0); nodes[2] = new MeshLib::Node(0.0, 0.0, 0.0); @@ -72,7 +72,7 @@ public: // invalid case: zero volume MeshLib::Line3* createZeroVolume() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[2] = new MeshLib::Node(0.0, 0.0, 0.0); @@ -82,7 +82,7 @@ public: // 1.5d line static MeshLib::Line3* createY() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, -1.0, 0.0); nodes[1] = new MeshLib::Node(0.0, 1.0, 0.0); nodes[2] = new MeshLib::Node(0.0, 0.0, 0.0); diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestQuad4.h b/Tests/NumLib/CoordinatesMappingTestData/TestQuad4.h index 2e66f0f8d7b0e03fb34c39abe8f7e90e04075e4f..dfefceeb42550c2bbb5fb8b232b24fe7d8620786 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestQuad4.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestQuad4.h @@ -18,42 +18,42 @@ class TestQuad4 { public: // Element information - typedef MeshLib::Quad ElementType; - typedef NumLib::ShapeQuad4 ShapeFunctionType; - static const unsigned global_dim = ElementType::dimension; - static const unsigned dim = 2; //ElementType::dimension; - static const unsigned e_nnodes = ElementType::n_all_nodes; - // Coordinates where shape functions are evaluated - static const double r[dim]; - // Expected results for natural shape - static const double nat_exp_N[e_nnodes]; - static const double nat_exp_dNdr[e_nnodes*dim]; - // Expected results for irregular shape - static const double ir_exp_J[dim*dim]; - static const double ir_exp_invJ[dim*dim]; - static const double ir_exp_detJ; - static const double ir_exp_dNdx[e_nnodes*dim]; - // Expected results for clock-wise node ordering - static const double cl_exp_J[dim*dim]; - // Expected results for zero volume - static const double cl_exp_detJ; - static const double ze_exp_J[dim*dim]; + using ElementType = MeshLib::Quad; + using ShapeFunctionType = NumLib::ShapeQuad4; + static const unsigned global_dim = ElementType::dimension; + static const unsigned dim = 2; // ElementType::dimension; + static const unsigned e_nnodes = ElementType::n_all_nodes; + // Coordinates where shape functions are evaluated + static const double r[dim]; + // Expected results for natural shape + static const double nat_exp_N[e_nnodes]; + static const double nat_exp_dNdr[e_nnodes * dim]; + // Expected results for irregular shape + static const double ir_exp_J[dim * dim]; + static const double ir_exp_invJ[dim * dim]; + static const double ir_exp_detJ; + static const double ir_exp_dNdx[e_nnodes * dim]; + // Expected results for clock-wise node ordering + static const double cl_exp_J[dim * dim]; + // Expected results for zero volume + static const double cl_exp_detJ; + static const double ze_exp_J[dim * dim]; - // element shape identical to that in natural coordinates - MeshLib::Quad* createNaturalShape() - { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; - nodes[0] = new MeshLib::Node( 1.0, 1.0, 0.0); - nodes[1] = new MeshLib::Node(-1.0, 1.0, 0.0); - nodes[2] = new MeshLib::Node(-1.0, -1.0, 0.0); - nodes[3] = new MeshLib::Node( 1.0, -1.0, 0.0); - return new MeshLib::Quad(nodes); + // element shape identical to that in natural coordinates + MeshLib::Quad* createNaturalShape() + { + auto** nodes = new MeshLib::Node*[e_nnodes]; + nodes[0] = new MeshLib::Node(1.0, 1.0, 0.0); + nodes[1] = new MeshLib::Node(-1.0, 1.0, 0.0); + nodes[2] = new MeshLib::Node(-1.0, -1.0, 0.0); + nodes[3] = new MeshLib::Node(1.0, -1.0, 0.0); + return new MeshLib::Quad(nodes); } // element having irregular or skew shape MeshLib::Quad* createIrregularShape() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(-0.5, -0.5, 0.0); nodes[1] = new MeshLib::Node( 0.6, -0.6, 0.0); nodes[2] = new MeshLib::Node( 0.5, 0.4, 0.0); @@ -64,7 +64,7 @@ class TestQuad4 // invalid case: clock wise node ordering MeshLib::Quad* createClockWise() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node( 1.0, 1.0, 0.0); nodes[3] = new MeshLib::Node(-1.0, 1.0, 0.0); nodes[2] = new MeshLib::Node(-1.0, -1.0, 0.0); @@ -75,7 +75,7 @@ class TestQuad4 // invalid case: zero area MeshLib::Quad* createZeroVolume() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node( 1.0, 1.0, 0.0); nodes[1] = new MeshLib::Node(-1.0, 1.0, 0.0); nodes[2] = new MeshLib::Node(-1.0, 1.0, 0.0); diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestTri3.h b/Tests/NumLib/CoordinatesMappingTestData/TestTri3.h index 84269f1a474d11a301ed1b1aeea2c7aa77dd9817..78fa102d20c49d99884f18466d80845e45ad7263 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestTri3.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestTri3.h @@ -18,41 +18,41 @@ class TestTri3 { public: // Element information - typedef MeshLib::Tri ElementType; - typedef NumLib::ShapeTri3 ShapeFunctionType; - static const unsigned global_dim = ElementType::dimension; - static const unsigned dim = 2; //ElementType::dimension; - static const unsigned e_nnodes = ElementType::n_all_nodes; - // Coordinates where shape functions are evaluated - static const double r[dim]; - // Expected results for natural shape - static const double nat_exp_N[e_nnodes]; - static const double nat_exp_dNdr[e_nnodes*dim]; - // Expected results for irregular shape - static const double ir_exp_J[dim*dim]; - static const double ir_exp_invJ[dim*dim]; - static const double ir_exp_detJ; - static const double ir_exp_dNdx[e_nnodes*dim]; - // Expected results for clock-wise node ordering - static const double cl_exp_J[dim*dim]; - // Expected results for zero volume - static const double cl_exp_detJ; - static const double ze_exp_J[dim*dim]; + using ElementType = MeshLib::Tri; + using ShapeFunctionType = NumLib::ShapeTri3; + static const unsigned global_dim = ElementType::dimension; + static const unsigned dim = 2; // ElementType::dimension; + static const unsigned e_nnodes = ElementType::n_all_nodes; + // Coordinates where shape functions are evaluated + static const double r[dim]; + // Expected results for natural shape + static const double nat_exp_N[e_nnodes]; + static const double nat_exp_dNdr[e_nnodes * dim]; + // Expected results for irregular shape + static const double ir_exp_J[dim * dim]; + static const double ir_exp_invJ[dim * dim]; + static const double ir_exp_detJ; + static const double ir_exp_dNdx[e_nnodes * dim]; + // Expected results for clock-wise node ordering + static const double cl_exp_J[dim * dim]; + // Expected results for zero volume + static const double cl_exp_detJ; + static const double ze_exp_J[dim * dim]; - // element having shape identical to that in natural coordinates - MeshLib::Tri* createNaturalShape() - { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; - nodes[0] = new MeshLib::Node( 0.0, 0.0, 0.0); - nodes[1] = new MeshLib::Node( 1.0, 0.0, 0.0); - nodes[2] = new MeshLib::Node( 0.0, 1.0, 0.0); - return new MeshLib::Tri(nodes); + // element having shape identical to that in natural coordinates + MeshLib::Tri* createNaturalShape() + { + auto** nodes = new MeshLib::Node*[e_nnodes]; + nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); + nodes[1] = new MeshLib::Node(1.0, 0.0, 0.0); + nodes[2] = new MeshLib::Node(0.0, 1.0, 0.0); + return new MeshLib::Tri(nodes); } // element having irregular or skew shape MeshLib::Tri* createIrregularShape() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node( 0.1, 0.1, 0.0); nodes[1] = new MeshLib::Node( 2.0, -0.6, 0.0); nodes[2] = new MeshLib::Node( 1.5, 0.4, 0.0); @@ -62,7 +62,7 @@ class TestTri3 // invalid case: clock wise node ordering MeshLib::Tri* createClockWise() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node( 0.0, 0.0, 0.0); nodes[2] = new MeshLib::Node( 1.0, 0.0, 0.0); nodes[1] = new MeshLib::Node( 0.0, 1.0, 0.0); @@ -72,7 +72,7 @@ class TestTri3 // invalid case: zero area MeshLib::Tri* createZeroVolume() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node( 0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node( 1.0, 0.0, 0.0); nodes[2] = new MeshLib::Node( 1.0, 0.0, 0.0); diff --git a/Tests/NumLib/FeTestData/TestFeHEX8.h b/Tests/NumLib/FeTestData/TestFeHEX8.h index 1792de0bd46aa711e19bbbcf0bdb8f7b6b72df2b..571d5070c52c1d5d768ad0d802f146874385c6be 100644 --- a/Tests/NumLib/FeTestData/TestFeHEX8.h +++ b/Tests/NumLib/FeTestData/TestFeHEX8.h @@ -27,7 +27,7 @@ public: template <template <typename> class ShapeMatrixPolicy_> using FeType = NumLib::FeHEX8<ShapeMatrixPolicy_>; - typedef MeshLib::Hex MeshElementType; + using MeshElementType = MeshLib::Hex; static const unsigned dim = 3; //MeshElementType::dimension; static const unsigned e_nnodes = MeshElementType::n_all_nodes; static const unsigned n_sample_pt_order2 = 2*2*2; @@ -38,7 +38,7 @@ public: MeshLib::Hex* createMeshElement() { // cubic - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(1.0, 0.0, 0.0); nodes[2] = new MeshLib::Node(1.0, 1.0, 0.0); diff --git a/Tests/NumLib/FeTestData/TestFeLINE2.h b/Tests/NumLib/FeTestData/TestFeLINE2.h index b921646dcfaecb6a77777927a36ba78da178ae9b..16a2041aa9099fdb0a9b67994447a1ef1c7d6b78 100644 --- a/Tests/NumLib/FeTestData/TestFeLINE2.h +++ b/Tests/NumLib/FeTestData/TestFeLINE2.h @@ -27,7 +27,7 @@ public: template <template <typename> class ShapeMatrixPolicy_> using FeType = NumLib::FeLINE2<ShapeMatrixPolicy_>; - typedef MeshLib::Line MeshElementType; + using MeshElementType = MeshLib::Line; static const unsigned dim = MeshElementType::dimension; static const unsigned e_nnodes = MeshElementType::n_all_nodes; static const unsigned n_sample_pt_order2 = 2; @@ -37,7 +37,7 @@ public: /// create a mesh element MeshLib::Line* createMeshElement() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(1.0, 0.0, 0.0); return new MeshLib::Line(nodes); diff --git a/Tests/NumLib/FeTestData/TestFeLINE2Y.h b/Tests/NumLib/FeTestData/TestFeLINE2Y.h index 31e7c8a2dcc8e9fec1a0d2bc8a60dc5ee3ade70c..469081c9bf06ce2baf0eead468e25dd335950fcf 100644 --- a/Tests/NumLib/FeTestData/TestFeLINE2Y.h +++ b/Tests/NumLib/FeTestData/TestFeLINE2Y.h @@ -26,7 +26,7 @@ public: template <template <typename> class ShapeMatrixPolicy_> using FeType = NumLib::FeLINE2<ShapeMatrixPolicy_>; - typedef MeshLib::Line MeshElementType; + using MeshElementType = MeshLib::Line; static const unsigned dim = MeshElementType::dimension; static const unsigned e_nnodes = MeshElementType::n_all_nodes; static const unsigned n_sample_pt_order2 = 2; @@ -36,7 +36,7 @@ public: /// create a mesh element MeshLib::Line* createMeshElement() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(0.0, 1.0, 0.0); return new MeshLib::Line(nodes); diff --git a/Tests/NumLib/FeTestData/TestFeLINE3.h b/Tests/NumLib/FeTestData/TestFeLINE3.h index 7c396003c112f79aed09405932becf71428fa477..09458a62fb667cc7399780bd1c76981079f2f05c 100644 --- a/Tests/NumLib/FeTestData/TestFeLINE3.h +++ b/Tests/NumLib/FeTestData/TestFeLINE3.h @@ -26,7 +26,7 @@ public: template <template <typename> class ShapeMatrixPolicy_> using FeType = NumLib::FeLINE3<ShapeMatrixPolicy_>; - typedef MeshLib::Line3 MeshElementType; + using MeshElementType = MeshLib::Line3; static const unsigned dim = MeshElementType::dimension; static const unsigned e_nnodes = MeshElementType::n_all_nodes; static const unsigned n_sample_pt_order2 = 2; @@ -36,7 +36,7 @@ public: /// create a mesh element MeshElementType* createMeshElement() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(1.0, 0.0, 0.0); nodes[2] = new MeshLib::Node(0.5, 0.0, 0.0); diff --git a/Tests/NumLib/FeTestData/TestFePRISM6.h b/Tests/NumLib/FeTestData/TestFePRISM6.h index 114ff74de3dd1e95ce1e94fac41be496b25f261d..af0c7f25e081bb29cbd3db5e4e30cfe524925e56 100644 --- a/Tests/NumLib/FeTestData/TestFePRISM6.h +++ b/Tests/NumLib/FeTestData/TestFePRISM6.h @@ -26,7 +26,7 @@ public: template <template <typename> class ShapeMatrixPolicy_> using FeType = NumLib::FePRISM6<ShapeMatrixPolicy_>; - typedef MeshLib::Prism MeshElementType; + using MeshElementType = MeshLib::Prism; static const unsigned dim = 3; static const unsigned e_nnodes = MeshElementType::n_all_nodes; static const unsigned n_sample_pt_order2 = 6; @@ -37,7 +37,7 @@ public: MeshElementType* createMeshElement() { // cubic - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(0.5, 0.0, 0.0); nodes[2] = new MeshLib::Node(0.5, 0.5, 0.0); diff --git a/Tests/NumLib/FeTestData/TestFePYRA5.h b/Tests/NumLib/FeTestData/TestFePYRA5.h index 05c6b34b944684d99ece2e74adc35be3d7b23368..fec171e0a08179ff50acda08fce8e9a0476212bb 100644 --- a/Tests/NumLib/FeTestData/TestFePYRA5.h +++ b/Tests/NumLib/FeTestData/TestFePYRA5.h @@ -26,7 +26,7 @@ public: template <template <typename> class ShapeMatrixPolicy_> using FeType = NumLib::FePYRA5<ShapeMatrixPolicy_>; - typedef MeshLib::Pyramid MeshElementType; + using MeshElementType = MeshLib::Pyramid; static const unsigned dim = 3; //MeshElementType::dimension; static const unsigned e_nnodes = MeshElementType::n_all_nodes; static const unsigned n_sample_pt_order2 = 5; @@ -37,7 +37,7 @@ public: MeshElementType* createMeshElement() { // cubic - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.5); nodes[1] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[2] = new MeshLib::Node(0.0, 0.5, 0.0); diff --git a/Tests/NumLib/FeTestData/TestFeQUAD4.h b/Tests/NumLib/FeTestData/TestFeQUAD4.h index f67805edfe6536bb8f75afd214100bd916d59623..77bd09f50e355cab7ceebfb567aa41d6811a859b 100644 --- a/Tests/NumLib/FeTestData/TestFeQUAD4.h +++ b/Tests/NumLib/FeTestData/TestFeQUAD4.h @@ -27,7 +27,7 @@ public: template <template <typename> class ShapeMatrixPolicy_> using FeType = NumLib::FeQUAD4<ShapeMatrixPolicy_>; - typedef MeshLib::Quad MeshElementType; + using MeshElementType = MeshLib::Quad; static const unsigned dim = 2; //MeshElementType::dimension; static const unsigned e_nnodes = MeshElementType::n_all_nodes; static const unsigned n_sample_pt_order2 = 2*2; @@ -38,7 +38,7 @@ public: MeshLib::Quad* createMeshElement() { // square - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(1.0, 0.0, 0.0); nodes[2] = new MeshLib::Node(1.0, 1.0, 0.0); diff --git a/Tests/NumLib/FeTestData/TestFeTET4.h b/Tests/NumLib/FeTestData/TestFeTET4.h index 36a58ab0d6b383239e594f63a5ceae0a8641aa09..bee0537a9def6ddcd71afdd7f3e86f9e167b0a89 100644 --- a/Tests/NumLib/FeTestData/TestFeTET4.h +++ b/Tests/NumLib/FeTestData/TestFeTET4.h @@ -26,7 +26,7 @@ public: template <template <typename> class ShapeMatrixPolicy_> using FeType = NumLib::FeTET4<ShapeMatrixPolicy_>; - typedef MeshLib::Tet MeshElementType; + using MeshElementType = MeshLib::Tet; static const unsigned dim = 3; static const unsigned e_nnodes = MeshElementType::n_all_nodes; static const unsigned n_sample_pt_order2 = 5; @@ -36,7 +36,7 @@ public: /// create a mesh element MeshElementType* createMeshElement() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; + auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); nodes[1] = new MeshLib::Node(0.5, 0.5, 0.5); nodes[2] = new MeshLib::Node(0.5, 0.0, 0.5); diff --git a/Tests/NumLib/FeTestData/TestFeTRI3.h b/Tests/NumLib/FeTestData/TestFeTRI3.h index c118ba23ea517fea838c5fcf5b479af4c3670477..cbfd192084b658c22bbae585ecd637e30c1ff280 100644 --- a/Tests/NumLib/FeTestData/TestFeTRI3.h +++ b/Tests/NumLib/FeTestData/TestFeTRI3.h @@ -27,7 +27,7 @@ public: template <template <typename> class ShapeMatrixPolicy_> using FeType = NumLib::FeTRI3<ShapeMatrixPolicy_>; - typedef MeshLib::Tri MeshElementType; + using MeshElementType = MeshLib::Tri; static const unsigned dim = 2; //MeshElementType::dimension; static const unsigned e_nnodes = MeshElementType::n_all_nodes; static const unsigned n_sample_pt_order2 = 3; @@ -37,10 +37,10 @@ public: /// create a mesh element MeshElementType* createMeshElement() { - MeshLib::Node** nodes = new MeshLib::Node*[e_nnodes]; - nodes[0] = new MeshLib::Node( 0.0, 0.0, 0.0); - nodes[1] = new MeshLib::Node( 1.0, 0.0, 0.0); - nodes[2] = new MeshLib::Node( 0.0, 1.0, 0.0); + auto** nodes = new MeshLib::Node*[e_nnodes]; + nodes[0] = new MeshLib::Node(0.0, 0.0, 0.0); + nodes[1] = new MeshLib::Node(1.0, 0.0, 0.0); + nodes[2] = new MeshLib::Node(0.0, 1.0, 0.0); return new MeshLib::Tri(nodes); } diff --git a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp index 6777e610a70191f831bcafd9c205f8bd55fc88ee..908d622f288a0fc514868759a43418e16196c8b4 100644 --- a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp @@ -71,7 +71,7 @@ public: mesh_items_all_nodes->getIntersectionByNodes(nodes)); } - ~NumLibLocalToGlobalIndexMapMultiDOFTest() + ~NumLibLocalToGlobalIndexMapMultiDOFTest() override { for (auto e : boundary_elements) delete e; diff --git a/Tests/NumLib/TestCoordinatesMapping.cpp b/Tests/NumLib/TestCoordinatesMapping.cpp index bd71fd8e2e77497f3c62defa7aff7e882f66cee5..e17a215119c75ca7e0fc5db7c31e45204144897e 100644 --- a/Tests/NumLib/TestCoordinatesMapping.cpp +++ b/Tests/NumLib/TestCoordinatesMapping.cpp @@ -32,8 +32,8 @@ using namespace CoordinatesMappingTestData; namespace { // Element types to be tested -typedef ::testing::Types<TestLine2, TestLine3, TestTri3, TestQuad4, TestHex8> - TestTypes; +using TestTypes = + ::testing::Types<TestLine2, TestLine3, TestTri3, TestQuad4, TestHex8>; } template <class T_TEST> @@ -41,26 +41,25 @@ class NumLibFemNaturalCoordinatesMappingTest : public ::testing::Test, public T_TEST { public: - typedef typename T_TEST::ElementType ElementType; - typedef typename T_TEST::ShapeFunctionType ShapeFunctionType; + using ElementType = typename T_TEST::ElementType; + using ShapeFunctionType = typename T_TEST::ShapeFunctionType; static const unsigned dim = T_TEST::dim; static const unsigned e_nnodes = T_TEST::e_nnodes; static const unsigned global_dim = T_TEST::global_dim; // Matrix types - typedef typename ::detail::EigenMatrixType<1, e_nnodes>::type NodalVector; - typedef - typename ::detail::EigenMatrixType<dim, e_nnodes>::type DimNodalMatrix; - typedef typename ::detail::EigenMatrixType<dim, dim>::type DimMatrix; - typedef typename ::detail::EigenMatrixType<global_dim, e_nnodes>::type - GlobalDimNodalMatrix; + using NodalVector = typename ::detail::EigenMatrixType<1, e_nnodes>::type; + using DimNodalMatrix = + typename ::detail::EigenMatrixType<dim, e_nnodes>::type; + using DimMatrix = typename ::detail::EigenMatrixType<dim, dim>::type; + using GlobalDimNodalMatrix = + typename ::detail::EigenMatrixType<global_dim, e_nnodes>::type; // Shape data type - typedef ShapeMatrices<NodalVector, DimNodalMatrix, DimMatrix, - GlobalDimNodalMatrix> - ShapeMatricesType; + using ShapeMatricesType = ShapeMatrices<NodalVector, DimNodalMatrix, + DimMatrix, GlobalDimNodalMatrix>; // Natural coordinates mapping type - typedef NaturalCoordinatesMapping<ElementType, ShapeFunctionType, - ShapeMatricesType> - NaturalCoordsMappingType; + using NaturalCoordsMappingType = + NaturalCoordinatesMapping<ElementType, ShapeFunctionType, + ShapeMatricesType>; public: NumLibFemNaturalCoordinatesMappingTest() @@ -82,7 +81,7 @@ public: vec_nodes.push_back(e->getNode(i)); } - virtual ~NumLibFemNaturalCoordinatesMappingTest() + ~NumLibFemNaturalCoordinatesMappingTest() override { for (auto itr = vec_nodes.begin(); itr != vec_nodes.end(); ++itr) delete *itr; @@ -103,9 +102,9 @@ TYPED_TEST_CASE(NumLibFemNaturalCoordinatesMappingTest, TestTypes); TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_N) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); // only N @@ -121,9 +120,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_N) TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_DNDR) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); // dNdr @@ -140,9 +139,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_DNDR) TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_N_J) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); // N_J @@ -161,9 +160,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_N_J) TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_DNDR_J) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); // dNdr, J @@ -180,9 +179,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_DNDX) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); // DNDX @@ -199,9 +198,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_DNDX) TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_ALL) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); // ALL @@ -218,9 +217,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckFieldSpecification_ALL) TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckNaturalShape) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; // identical to natural coordinates ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); @@ -243,9 +242,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckNaturalShape) TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckIrregularShape) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; // irregular shape ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); @@ -268,9 +267,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckIrregularShape) TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckClockwise) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; // clockwise node ordering, which is invalid) ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); @@ -281,9 +280,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckClockwise) TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckZeroVolume) { - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; - typedef - typename TestFixture::NaturalCoordsMappingType NaturalCoordsMappingType; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; + using NaturalCoordsMappingType = + typename TestFixture::NaturalCoordsMappingType; ShapeMatricesType shape(this->dim, this->global_dim, this->e_nnodes); @@ -293,17 +292,15 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckZeroVolume) TEST(NumLib, FemNaturalCoordinatesMappingLineY) { - typedef ::detail::EigenMatrixType<1, 2>::type NodalVector; - typedef ::detail::EigenMatrixType<1, 2>::type DimNodalMatrix; - typedef ::detail::EigenMatrixType<1, 1>::type DimMatrix; - typedef ::detail::EigenMatrixType<2, 2>::type GlobalDimNodalMatrix; + using NodalVector = ::detail::EigenMatrixType<1, 2>::type; + using DimNodalMatrix = ::detail::EigenMatrixType<1, 2>::type; + using DimMatrix = ::detail::EigenMatrixType<1, 1>::type; + using GlobalDimNodalMatrix = ::detail::EigenMatrixType<2, 2>::type; // Shape data type - typedef ShapeMatrices<NodalVector, DimNodalMatrix, DimMatrix, - GlobalDimNodalMatrix> - ShapeMatricesType; - typedef NaturalCoordinatesMapping<MeshLib::Line, ShapeLine2, - ShapeMatricesType> - MappingType; + using ShapeMatricesType = ShapeMatrices<NodalVector, DimNodalMatrix, + DimMatrix, GlobalDimNodalMatrix>; + using MappingType = + NaturalCoordinatesMapping<MeshLib::Line, ShapeLine2, ShapeMatricesType>; double r[] = {0.5}; auto line = TestLine2::createY(); static const unsigned dim = 1; diff --git a/Tests/NumLib/TestDistribution.cpp b/Tests/NumLib/TestDistribution.cpp index 347bfd46cd0269d345202b39e46667631a19898e..0af55d1d0351b14477e789751b120af1d8a8b24b 100644 --- a/Tests/NumLib/TestDistribution.cpp +++ b/Tests/NumLib/TestDistribution.cpp @@ -51,7 +51,7 @@ public: _ply0->addPoint(1); plys->push_back(_ply0); - GeoLib::Polyline* ply1 = new GeoLib::Polyline(*pnts); + auto* ply1 = new GeoLib::Polyline(*pnts); ply1->addPoint(0); ply1->addPoint(1); ply1->addPoint(2); @@ -108,7 +108,7 @@ public: _ply0->addPoint(0); _ply0->addPoint(4); plys->push_back(_ply0); - GeoLib::Polyline* ply1 = new GeoLib::Polyline(*pnts); // polygon for left surface + auto* ply1 = new GeoLib::Polyline(*pnts); // polygon for left surface ply1->addPoint(0); ply1->addPoint(3); ply1->addPoint(7); diff --git a/Tests/NumLib/TestFe.cpp b/Tests/NumLib/TestFe.cpp index 1bfc22504b9dbfbd6e02e2970faa3ecc4f64c423..13a71fefa27771f9c5b45044b2afdf73a8d0def2 100644 --- a/Tests/NumLib/TestFe.cpp +++ b/Tests/NumLib/TestFe.cpp @@ -44,102 +44,102 @@ namespace template <class TestFeType_, template <typename, unsigned> class ShapeMatrixPolicy_> struct TestCase { - typedef TestFeType_ TestFeType; + using TestFeType = TestFeType_; static const unsigned GlobalDim = TestFeType::global_dim; using ShapeMatrixTypes = ShapeMatrixPolicy_<typename TestFeType::ShapeFunction, GlobalDim>; template <typename X> using ShapeMatrixPolicy = ShapeMatrixPolicy_<X, GlobalDim>; }; -typedef ::testing::Types< - TestCase<TestFeHEX8, EigenDynamicShapeMatrixPolicy>, - TestCase<TestFeLINE2, EigenDynamicShapeMatrixPolicy>, - TestCase<TestFeLINE2Y, EigenDynamicShapeMatrixPolicy>, - TestCase<TestFeLINE3, EigenDynamicShapeMatrixPolicy>, - TestCase<TestFePRISM6, EigenDynamicShapeMatrixPolicy>, - TestCase<TestFePYRA5, EigenDynamicShapeMatrixPolicy>, - TestCase<TestFeQUAD4, EigenDynamicShapeMatrixPolicy>, - TestCase<TestFeTET4, EigenDynamicShapeMatrixPolicy>, - TestCase<TestFeTRI3, EigenDynamicShapeMatrixPolicy>, - - TestCase<TestFeHEX8, EigenFixedShapeMatrixPolicy>, - TestCase<TestFeLINE2, EigenFixedShapeMatrixPolicy>, - TestCase<TestFeLINE2Y, EigenFixedShapeMatrixPolicy>, - TestCase<TestFeLINE3, EigenFixedShapeMatrixPolicy>, - TestCase<TestFePRISM6, EigenFixedShapeMatrixPolicy>, - TestCase<TestFePYRA5, EigenFixedShapeMatrixPolicy>, - TestCase<TestFeQUAD4, EigenFixedShapeMatrixPolicy>, - TestCase<TestFeTET4, EigenFixedShapeMatrixPolicy>, - TestCase<TestFeTRI3, EigenFixedShapeMatrixPolicy> - > TestTypes; +using TestTypes = + ::testing::Types<TestCase<TestFeHEX8, EigenDynamicShapeMatrixPolicy>, + TestCase<TestFeLINE2, EigenDynamicShapeMatrixPolicy>, + TestCase<TestFeLINE2Y, EigenDynamicShapeMatrixPolicy>, + TestCase<TestFeLINE3, EigenDynamicShapeMatrixPolicy>, + TestCase<TestFePRISM6, EigenDynamicShapeMatrixPolicy>, + TestCase<TestFePYRA5, EigenDynamicShapeMatrixPolicy>, + TestCase<TestFeQUAD4, EigenDynamicShapeMatrixPolicy>, + TestCase<TestFeTET4, EigenDynamicShapeMatrixPolicy>, + TestCase<TestFeTRI3, EigenDynamicShapeMatrixPolicy>, + + TestCase<TestFeHEX8, EigenFixedShapeMatrixPolicy>, + TestCase<TestFeLINE2, EigenFixedShapeMatrixPolicy>, + TestCase<TestFeLINE2Y, EigenFixedShapeMatrixPolicy>, + TestCase<TestFeLINE3, EigenFixedShapeMatrixPolicy>, + TestCase<TestFePRISM6, EigenFixedShapeMatrixPolicy>, + TestCase<TestFePYRA5, EigenFixedShapeMatrixPolicy>, + TestCase<TestFeQUAD4, EigenFixedShapeMatrixPolicy>, + TestCase<TestFeTET4, EigenFixedShapeMatrixPolicy>, + TestCase<TestFeTRI3, EigenFixedShapeMatrixPolicy>>; } template <class T> class NumLibFemIsoTest : public ::testing::Test, public T::TestFeType { public: - typedef typename T::ShapeMatrixTypes ShapeMatrixTypes; - typedef typename T::TestFeType TestFeType; - // Matrix types - typedef typename ShapeMatrixTypes::NodalMatrixType NodalMatrix; - typedef typename ShapeMatrixTypes::NodalVectorType NodalVector; - typedef typename ShapeMatrixTypes::DimNodalMatrixType DimNodalMatrix; - typedef typename ShapeMatrixTypes::DimMatrixType DimMatrix; - typedef typename ShapeMatrixTypes::GlobalDimMatrixType GlobalDimMatrixType; - - // Finite element type - template <typename X> - using ShapeMatrixPolicy = typename T::template ShapeMatrixPolicy<X>; - typedef typename TestFeType::template FeType<ShapeMatrixPolicy>::type FeType; - - // Shape matrix data type - typedef typename ShapeMatrixTypes::ShapeMatrices ShapeMatricesType; - typedef typename TestFeType::MeshElementType MeshElementType; - - static const unsigned dim = TestFeType::dim; - static const unsigned e_nnodes = TestFeType::e_nnodes; - static const unsigned n_sample_pt_order2 = TestFeType::n_sample_pt_order2; - static const unsigned n_sample_pt_order3 = TestFeType::n_sample_pt_order3; - - using IntegrationMethod = - typename NumLib::GaussIntegrationPolicy<MeshElementType>::IntegrationMethod; - + using ShapeMatrixTypes = typename T::ShapeMatrixTypes; + using TestFeType = typename T::TestFeType; + // Matrix types + using NodalMatrix = typename ShapeMatrixTypes::NodalMatrixType; + using NodalVector = typename ShapeMatrixTypes::NodalVectorType; + using DimNodalMatrix = typename ShapeMatrixTypes::DimNodalMatrixType; + using DimMatrix = typename ShapeMatrixTypes::DimMatrixType; + using GlobalDimMatrixType = typename ShapeMatrixTypes::GlobalDimMatrixType; + + // Finite element type + template <typename X> + using ShapeMatrixPolicy = typename T::template ShapeMatrixPolicy<X>; + using FeType = + typename TestFeType::template FeType<ShapeMatrixPolicy>::type; + + // Shape matrix data type + using ShapeMatricesType = typename ShapeMatrixTypes::ShapeMatrices; + using MeshElementType = typename TestFeType::MeshElementType; + + static const unsigned dim = TestFeType::dim; + static const unsigned e_nnodes = TestFeType::e_nnodes; + static const unsigned n_sample_pt_order2 = TestFeType::n_sample_pt_order2; + static const unsigned n_sample_pt_order3 = TestFeType::n_sample_pt_order3; + + using IntegrationMethod = typename NumLib::GaussIntegrationPolicy< + MeshElementType>::IntegrationMethod; public: - NumLibFemIsoTest() : - D(dim, dim), - expectedM(e_nnodes,e_nnodes), - expectedK(e_nnodes,e_nnodes), - integration_method(2) - { - // create a mesh element used for testing - mesh_element = this->createMeshElement(); - - // set a conductivity tensor - setIdentityMatrix(dim, D); - D *= conductivity; - MeshLib::ElementCoordinatesMappingLocal ele_local_coord( - *mesh_element, MeshLib::CoordinateSystem(*mesh_element).getDimension()); - auto R = ele_local_coord.getRotationMatrixToGlobal().topLeftCorner( - TestFeType::dim, TestFeType::global_dim); - globalD.noalias() = R.transpose() * (D * R); - - // set expected matrices - this->setExpectedMassMatrix(expectedM); - this->setExpectedLaplaceMatrix(conductivity, expectedK); - - // for destructor - vec_eles.push_back(mesh_element); - for (auto e : vec_eles) - for (unsigned i=0; i<e->getNumberOfNodes(); i++) - vec_nodes.push_back(e->getNode(i)); + NumLibFemIsoTest() + : D(dim, dim), + expectedM(e_nnodes, e_nnodes), + expectedK(e_nnodes, e_nnodes), + integration_method(2) + { + // create a mesh element used for testing + mesh_element = this->createMeshElement(); + + // set a conductivity tensor + setIdentityMatrix(dim, D); + D *= conductivity; + MeshLib::ElementCoordinatesMappingLocal ele_local_coord( + *mesh_element, + MeshLib::CoordinateSystem(*mesh_element).getDimension()); + auto R = ele_local_coord.getRotationMatrixToGlobal().topLeftCorner( + TestFeType::dim, TestFeType::global_dim); + globalD.noalias() = R.transpose() * (D * R); + + // set expected matrices + this->setExpectedMassMatrix(expectedM); + this->setExpectedLaplaceMatrix(conductivity, expectedK); + + // for destructor + vec_eles.push_back(mesh_element); + for (auto e : vec_eles) + for (unsigned i = 0; i < e->getNumberOfNodes(); i++) + vec_nodes.push_back(e->getNode(i)); } - virtual ~NumLibFemIsoTest() + ~NumLibFemIsoTest() override { - for (auto itr = vec_nodes.begin(); itr!=vec_nodes.end(); ++itr ) + for (auto itr = vec_nodes.begin(); itr != vec_nodes.end(); ++itr) delete *itr; - for (auto itr = vec_eles.begin(); itr!=vec_eles.end(); ++itr ) + for (auto itr = vec_eles.begin(); itr != vec_eles.end(); ++itr) delete *itr; } @@ -183,9 +183,9 @@ TYPED_TEST_CASE(NumLibFemIsoTest, TestTypes); TYPED_TEST(NumLibFemIsoTest, CheckMassMatrix) { // Refer to typedefs in the fixture - typedef typename TestFixture::FeType FeType; - typedef typename TestFixture::NodalMatrix NodalMatrix; - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; + using FeType = typename TestFixture::FeType; + using NodalMatrix = typename TestFixture::NodalMatrix; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; // create a finite element object FeType fe(*this->mesh_element); @@ -208,9 +208,9 @@ TYPED_TEST(NumLibFemIsoTest, CheckMassMatrix) TYPED_TEST(NumLibFemIsoTest, CheckLaplaceMatrix) { // Refer to typedefs in the fixture - typedef typename TestFixture::FeType FeType; - typedef typename TestFixture::NodalMatrix NodalMatrix; - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; + using FeType = typename TestFixture::FeType; + using NodalMatrix = typename TestFixture::NodalMatrix; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; // create a finite element object FeType fe(*this->mesh_element); @@ -233,9 +233,9 @@ TYPED_TEST(NumLibFemIsoTest, CheckLaplaceMatrix) TYPED_TEST(NumLibFemIsoTest, CheckMassLaplaceMatrices) { // Refer to typedefs in the fixture - typedef typename TestFixture::FeType FeType; - typedef typename TestFixture::NodalMatrix NodalMatrix; - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; + using FeType = typename TestFixture::FeType; + using NodalMatrix = typename TestFixture::NodalMatrix; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; // create a finite element object FeType fe(*this->mesh_element); @@ -262,9 +262,9 @@ TYPED_TEST(NumLibFemIsoTest, CheckMassLaplaceMatrices) TYPED_TEST(NumLibFemIsoTest, CheckGaussIntegrationLevel) { // Refer to typedefs in the fixture - typedef typename TestFixture::FeType FeType; - typedef typename TestFixture::NodalMatrix NodalMatrix; - typedef typename TestFixture::ShapeMatricesType ShapeMatricesType; + using FeType = typename TestFixture::FeType; + using NodalMatrix = typename TestFixture::NodalMatrix; + using ShapeMatricesType = typename TestFixture::ShapeMatricesType; // create a finite element object with gauss quadrature level 2 FeType fe(*this->mesh_element); diff --git a/Tests/NumLib/TestMeshComponentMap.cpp b/Tests/NumLib/TestMeshComponentMap.cpp index 213cc41a5103c2fc9ed0ad50ce2264a837fcf626..469a8229fb704f10c577e46451df05ca1fa09455 100644 --- a/Tests/NumLib/TestMeshComponentMap.cpp +++ b/Tests/NumLib/TestMeshComponentMap.cpp @@ -22,9 +22,9 @@ class NumLibMeshComponentMapTest : public ::testing::Test { public: - typedef MeshLib::MeshItemType MeshItemType; - typedef MeshLib::Location Location; - typedef NumLib::MeshComponentMap MeshComponentMap; + using MeshItemType = MeshLib::MeshItemType; + using Location = MeshLib::Location; + using MeshComponentMap = NumLib::MeshComponentMap; public: NumLibMeshComponentMapTest() @@ -38,7 +38,7 @@ class NumLibMeshComponentMapTest : public ::testing::Test components.emplace_back(new MeshLib::MeshSubsets{nodesSubset}); } - ~NumLibMeshComponentMapTest() + ~NumLibMeshComponentMapTest() override { delete cmap; delete nodesSubset; diff --git a/Tests/NumLib/TestODEInt.cpp b/Tests/NumLib/TestODEInt.cpp index c38f8b66e478de90a0541cee5740e1fd86b73e1e..38497469315b388217a1995568ad833359b4a7a2 100644 --- a/Tests/NumLib/TestODEInt.cpp +++ b/Tests/NumLib/TestODEInt.cpp @@ -223,7 +223,7 @@ TESTCASESLIST TestCase<ODE, NumLib::TIMEDISC> #define TCLSEP , -typedef ::testing::Types<TESTCASESLIST> TestCases; +using TestCases = ::testing::Types<TESTCASESLIST>; #undef TESTCASESLIST #undef TCLSEP diff --git a/Tests/NumLib/TestSerialExecutor.cpp b/Tests/NumLib/TestSerialExecutor.cpp index b0569b13933857fc980164a8b38278fc080f5ec0..9f5d11d14b3e30edfa1e8006458fe9fe24f2f6b0 100644 --- a/Tests/NumLib/TestSerialExecutor.cpp +++ b/Tests/NumLib/TestSerialExecutor.cpp @@ -67,7 +67,7 @@ public: static std::size_t const size = 100; }; -typedef ::testing::Types<int> TestCases; +using TestCases = ::testing::Types<int>; TYPED_TEST_CASE(NumLibSerialExecutor, TestCases); diff --git a/Tests/NumLib/TestShapeMatrices.cpp b/Tests/NumLib/TestShapeMatrices.cpp index 88eb72df7177acc228da4b1fb63631ba1c2a860b..5f90e15451e126c2cd8b9c6f1955c71abd944259 100644 --- a/Tests/NumLib/TestShapeMatrices.cpp +++ b/Tests/NumLib/TestShapeMatrices.cpp @@ -26,12 +26,14 @@ TEST(NumLib, FemShapeMatricesWithEigen) const static unsigned e_nnodes = 4; // Eigen matrix types - typedef Eigen::Matrix<double, e_nnodes, 1> NodalVector; - typedef Eigen::Matrix<double, dim, e_nnodes, Eigen::RowMajor> DimNodalMatrix; - typedef Eigen::Matrix<double, dim, dim, Eigen::RowMajor> DimMatrix; + using NodalVector = Eigen::Matrix<double, e_nnodes, 1>; + using DimNodalMatrix = + Eigen::Matrix<double, dim, e_nnodes, Eigen::RowMajor>; + using DimMatrix = Eigen::Matrix<double, dim, dim, Eigen::RowMajor>; // Shape data type - typedef ShapeMatrices<NodalVector,DimNodalMatrix,DimMatrix,DimNodalMatrix> ShapeMatricesType; + using ShapeMatricesType = + ShapeMatrices<NodalVector, DimNodalMatrix, DimMatrix, DimNodalMatrix>; auto setShapeDataToOnes = [](ShapeMatricesType &shape) { diff --git a/Tests/NumLib/TestTimeSteppingIterationNumber.cpp b/Tests/NumLib/TestTimeSteppingIterationNumber.cpp index 08e7a054edeb753b892baf03e5de3c8d8cab0e5a..baf12ca923216bb2022bfc3c8720c6cf22bf1363 100644 --- a/Tests/NumLib/TestTimeSteppingIterationNumber.cpp +++ b/Tests/NumLib/TestTimeSteppingIterationNumber.cpp @@ -11,6 +11,7 @@ #include <gtest/gtest.h> +#include <utility> #include <vector> #include <logog/include/logog.hpp> @@ -100,8 +101,11 @@ TEST(NumLib, TimeSteppingIterationNumberBased2) struct IterationNumberUpdate { - IterationNumberUpdate(const std::vector<std::size_t> &vec, std::size_t& counter) - : _nr_iterations(vec), i(counter) {} + IterationNumberUpdate(std::vector<std::size_t> vec, + std::size_t& counter) + : _nr_iterations(std::move(vec)), i(counter) + { + } std::vector<std::size_t> _nr_iterations; std::size_t& i; diff --git a/Tests/ProcessLib/TestJacobianAssembler.cpp b/Tests/ProcessLib/TestJacobianAssembler.cpp index 576982caba71b64a6916d090287308cb7f6b0ee6..b33da55d1dd78fa50a7b501a082151fe3d21da49 100644 --- a/Tests/ProcessLib/TestJacobianAssembler.cpp +++ b/Tests/ProcessLib/TestJacobianAssembler.cpp @@ -548,7 +548,7 @@ private: } }; -typedef ::testing::Types< +using TestCases = ::testing::Types< // DiagX LocalAssemblerM<MatVecDiagX>, LocalAssemblerK<MatVecDiagX>, LocalAssemblerB<MatVecDiagX>, @@ -566,8 +566,7 @@ typedef ::testing::Types< LocalAssemblerK<MatVecXSquaredShifted>, LocalAssemblerB<MatVecXSquaredShifted>, LocalAssemblerMKb<MatVecXSquaredShifted, MatVecXSquaredShifted, - MatVecXSquaredShifted>> - TestCases; + MatVecXSquaredShifted>>; TYPED_TEST_CASE(ProcessLibCentralDifferencesJacobianAssembler, TestCases); diff --git a/Tests/ProcessLib/TestLIE.cpp b/Tests/ProcessLib/TestLIE.cpp index 20c00c4243544d8bfb5c1a781920af9dfb5c007b..d9fb7f36dcc9197b8b1504efc658cb08deea7157 100644 --- a/Tests/ProcessLib/TestLIE.cpp +++ b/Tests/ProcessLib/TestLIE.cpp @@ -26,28 +26,26 @@ namespace std::unique_ptr<MeshLib::Mesh> createTriangle( std::array<std::array<double, 3>, 3> const& points) { - MeshLib::Node** nodes = new MeshLib::Node*[3]; + auto** nodes = new MeshLib::Node*[3]; for (int i = 0; i < points.size(); ++i) nodes[i] = new MeshLib::Node(points[i]); MeshLib::Element* e = new MeshLib::Tri(nodes); return std::unique_ptr<MeshLib::Mesh>(new MeshLib::Mesh( - "", - std::vector<MeshLib::Node*>{nodes[0], nodes[1], nodes[2]}, + "", std::vector<MeshLib::Node*>{nodes[0], nodes[1], nodes[2]}, std::vector<MeshLib::Element*>{e})); } std::unique_ptr<MeshLib::Mesh> createLine( std::array<std::array<double, 3>, 2> const& points) { - MeshLib::Node** nodes = new MeshLib::Node*[2]; + auto** nodes = new MeshLib::Node*[2]; for (int i = 0; i < points.size(); ++i) nodes[i] = new MeshLib::Node(points[i]); MeshLib::Element* e = new MeshLib::Line(nodes); return std::unique_ptr<MeshLib::Mesh>( - new MeshLib::Mesh("", - std::vector<MeshLib::Node*>{nodes[0], nodes[1]}, + new MeshLib::Mesh("", std::vector<MeshLib::Node*>{nodes[0], nodes[1]}, std::vector<MeshLib::Element*>{e})); }