diff --git a/Applications/DataExplorer/VtkVis/NetCdfConfigureDialog.cpp b/Applications/DataExplorer/VtkVis/NetCdfConfigureDialog.cpp index d42e89fe20045ee7830551ed60a4cbffc10a8eae..34af27d325e6fc74400f2a766048320580b6a777 100644 --- a/Applications/DataExplorer/VtkVis/NetCdfConfigureDialog.cpp +++ b/Applications/DataExplorer/VtkVis/NetCdfConfigureDialog.cpp @@ -79,9 +79,8 @@ void NetCdfConfigureDialog::on_comboBoxVariable_currentIndexChanged(int /*id*/) } //set up x-axis/lat -void NetCdfConfigureDialog::on_comboBoxDim1_currentIndexChanged(int id) +void NetCdfConfigureDialog::on_comboBoxDim1_currentIndexChanged(int /*id*/) { - if (id == -1) id = 0; double firstValue=0, lastValue=0; unsigned size = 0; getDimEdges(comboBoxDim1->currentText().toStdString(), size, firstValue, lastValue); diff --git a/Applications/DataExplorer/VtkVis/VtkRaster.cpp b/Applications/DataExplorer/VtkVis/VtkRaster.cpp index db80c188292ca0a16f1155a8400eb933dc8a2056..188af8f2139697da867d8b9f4a30f3d73f2ad4e2 100644 --- a/Applications/DataExplorer/VtkVis/VtkRaster.cpp +++ b/Applications/DataExplorer/VtkVis/VtkRaster.cpp @@ -388,13 +388,3 @@ bool VtkRaster::readWorldFile(std::string const& filename, image->SetDataOrigin(x0, vtk_y0, 0); return true; } - -void VtkRaster::uint32toRGBA(const unsigned int s, int* p) -{ - p[3] = s / (256 * 256 * 256); - int r = s % (256 * 256 * 256); - p[2] = r / (256 * 256); - r %= (256 * 256); - p[1] = r / 256; - p[0] = r % 256; -} diff --git a/Applications/DataExplorer/VtkVis/VtkRaster.h b/Applications/DataExplorer/VtkVis/VtkRaster.h index a8e70c8d4f3c8de1adcc81f79f948a1eb49eb4e1..65e87013562a66edc91909e1daed9a193f372b7d 100644 --- a/Applications/DataExplorer/VtkVis/VtkRaster.h +++ b/Applications/DataExplorer/VtkVis/VtkRaster.h @@ -72,7 +72,4 @@ private: * BMP/JPG/PNG-file and create a RasterHeader for the image. */ static bool readWorldFile(std::string const& filename, vtkImageReader2* image); - - /// Converts an uint32-number into a quadruple representing RGBA-colours for a pixel. - static void uint32toRGBA(const unsigned int s, int* p); }; diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp index 9d7aebde52ef73505c38dff8c1c3e35d4d137ae7..8b4f969f4cf5a4d3f2d55202705a004359ad7264 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp @@ -85,26 +85,25 @@ void VtkVisPipelineView::contextMenuEvent( QContextMenuEvent* event ) QMenu menu; QAction* addFilterAction = menu.addAction("Add filter..."); - 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 isSourceItem = false; - addMeshingAction = menu.addAction("Convert Image to Mesh..."); + QAction* addMeshingAction = + menu.addAction("Convert Image to Mesh..."); connect(addMeshingAction, SIGNAL(triggered()), this, SLOT(showImageToMeshConversionDialog())); } else { - addLUTAction = menu.addAction("Add color table..."); + QAction* addLUTAction = menu.addAction("Add color table..."); connect(addLUTAction, SIGNAL(triggered()), this, SLOT(addColorTable())); } - QAction* addConvertToMeshAction(nullptr); if (objectType == VTK_UNSTRUCTURED_GRID) { - addConvertToMeshAction = menu.addAction("Convert to Mesh..."); + QAction* addConvertToMeshAction = + menu.addAction("Convert to Mesh..."); connect(addConvertToMeshAction, SIGNAL(triggered()), this, SLOT(convertVTKToOGSMesh())); } @@ -113,11 +112,10 @@ void VtkVisPipelineView::contextMenuEvent( QContextMenuEvent* event ) #ifdef VTKFBXCONVERTER_FOUND QAction* exportFbxAction = menu.addAction("Export as Fbx"); #endif - QAction* removeAction = nullptr; if (!isSourceItem || vtkProps->IsRemovable()) { menu.addSeparator(); - removeAction = menu.addAction("Remove"); + QAction* removeAction = menu.addAction("Remove"); connect(removeAction, SIGNAL(triggered()), this, SLOT(removeSelectedPipelineItem())); } diff --git a/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp b/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp index 6cdb96a410b84d62fc3d75089a0126220fb1e0d3..ba7dffc2d8f2d6eb60ab847524eca893317a6ac1 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp @@ -326,16 +326,15 @@ void VtkVisTabWidget::buildProportiesDialog(VtkVisPipelineItem* item) QString key = i.key(); QList<QVariant> values = i.value(); - VtkAlgorithmPropertyVectorEdit* vectorEdit; if (!values.empty()) { QList<QString> valuesAsString; foreach (QVariant variant, values) valuesAsString.push_back(variant.toString()); - vectorEdit = new VtkAlgorithmPropertyVectorEdit(valuesAsString, key, - values.front().type(), - algProps); + VtkAlgorithmPropertyVectorEdit* vectorEdit = + new VtkAlgorithmPropertyVectorEdit( + valuesAsString, key, values.front().type(), algProps); connect(vectorEdit, SIGNAL(editingFinished()), this, SIGNAL(requestViewUpdate())); layout->addRow(key, vectorEdit); diff --git a/GeoLib/AnalyticalGeometry-impl.h b/GeoLib/AnalyticalGeometry-impl.h index a1f3dc7cae2c32316fc1df403ae02c67508b0a81..6ad53498b1970e563c9f03d3e8bf78b1f5b33ad2 100644 --- a/GeoLib/AnalyticalGeometry-impl.h +++ b/GeoLib/AnalyticalGeometry-impl.h @@ -27,7 +27,7 @@ void getNewellPlane (InputIterator pnts_begin, InputIterator pnts_end, plane_normal[2] += (pt_i[0] - pt_j[0]) * (pt_i[1] + pt_j[1]); // projection on xy - centroid += pt_j; + centroid += MathLib::Vector3(pt_j); } plane_normal.normalize(); @@ -48,7 +48,8 @@ void getNewellPlane (const std::vector<T_POINT*>& pnts, } template <class T_POINT> -std::pair<MathLib::Vector3, double> getNewellPlane (const std::vector<T_POINT>& pnts) +std::pair<MathLib::Vector3, double> getNewellPlane( + const std::vector<T_POINT>& pnts) { MathLib::Vector3 plane_normal; MathLib::Vector3 centroid; @@ -61,7 +62,7 @@ std::pair<MathLib::Vector3, double> getNewellPlane (const std::vector<T_POINT>& plane_normal[2] += (pnts[i][0] - pnts[j][0]) * (pnts[i][1] + pnts[j][1]); // projection on xy - centroid += pnts[j]; + centroid += MathLib::Vector3(pnts[j]); } plane_normal.normalize(); diff --git a/GeoLib/MinimalBoundingSphere.cpp b/GeoLib/MinimalBoundingSphere.cpp index 0fd40c5b188de171a4bbcd62e0c540a08a96393d..b29448a77d2513b564dad0a02a35bfeb20aad06d 100644 --- a/GeoLib/MinimalBoundingSphere.cpp +++ b/GeoLib/MinimalBoundingSphere.cpp @@ -72,7 +72,7 @@ MinimalBoundingSphere::MinimalBoundingSphere(MathLib::Point3d const& p, two_pnts_sphere = MinimalBoundingSphere(p, q); } _radius = two_pnts_sphere.getRadius(); - _center = two_pnts_sphere.getCenter(); + _center = MathLib::Vector3(two_pnts_sphere.getCenter()); } } @@ -103,21 +103,21 @@ MinimalBoundingSphere::MinimalBoundingSphere(MathLib::Point3d const& p, MinimalBoundingSphere const prs(p, r , s); MinimalBoundingSphere const qrs(q, r , s); _radius = pqr.getRadius(); - _center = pqr.getCenter(); + _center = MathLib::Vector3(pqr.getCenter()); if (_radius < pqs.getRadius()) { _radius = pqs.getRadius(); - _center = pqs.getCenter(); + _center = MathLib::Vector3(pqs.getCenter()); } if (_radius < prs.getRadius()) { _radius = prs.getRadius(); - _center = prs.getCenter(); + _center = MathLib::Vector3(prs.getCenter()); } if (_radius < qrs.getRadius()) { _radius = qrs.getRadius(); - _center = qrs.getCenter(); + _center = MathLib::Vector3(qrs.getCenter()); } } } @@ -128,7 +128,7 @@ MinimalBoundingSphere::MinimalBoundingSphere( { const std::vector<MathLib::Point3d*>& sphere_points(points); MinimalBoundingSphere const bounding_sphere = recurseCalculation(sphere_points, 0, sphere_points.size(), 0); - _center = bounding_sphere.getCenter(); + _center = MathLib::Vector3(bounding_sphere.getCenter()); _radius = bounding_sphere.getRadius(); } diff --git a/MathLib/Vector3.h b/MathLib/Vector3.h index 575ef025bb0900c64c16f99142064083f5845c0e..004304a8c3dbb4506ee4b716d24d59cb218592fa 100644 --- a/MathLib/Vector3.h +++ b/MathLib/Vector3.h @@ -52,7 +52,7 @@ public: /** * Construct Vector3 from TemplatePoint. */ - TemplateVector3(TemplatePoint<T,3> const& p) : + explicit TemplateVector3(TemplatePoint<T,3> const& p) : TemplatePoint<T>(p) {} diff --git a/MeshGeoToolsLib/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp index 57809f0367a0bcb59ab16f3fade7fb49c549635e..971eda9f1b30e055b4be06c104c75b6b00415aa8 100644 --- a/MeshGeoToolsLib/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -420,7 +420,7 @@ static void mapPointOnSurfaceElement(MeshLib::Element const& elem, MathLib::Point3d& q) { // create plane equation: n*p = d - MathLib::Vector3 const& p(*(elem.getNode(0))); + MathLib::Vector3 const p(*(elem.getNode(0))); MathLib::Vector3 const n(MeshLib::FaceRule::getSurfaceNormal(&elem)); if (n[2] == 0.0) { // vertical plane, z coordinate is arbitrary q[2] = p[2]; diff --git a/MeshLib/ElementCoordinatesMappingLocal.cpp b/MeshLib/ElementCoordinatesMappingLocal.cpp index b2a9a6763e8c6d0a7b42cf4f093e8cea28017706..f4ac3b9ba7b57fb68cf86ef78b7eda13b1ee11d8 100644 --- a/MeshLib/ElementCoordinatesMappingLocal.cpp +++ b/MeshLib/ElementCoordinatesMappingLocal.cpp @@ -26,10 +26,8 @@ namespace detail void rotateToLocal(const MeshLib::RotationMatrix& matR2local, std::vector<MathLib::Point3d>& points) { - for (auto& p : points) - { - p = matR2local * p; - } + std::transform(points.begin(), points.end(), points.begin(), + [&matR2local](auto const& pnt) { return matR2local * pnt; }); } /// get a rotation matrix to the global coordinates diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp index 444d39a49ef154ba3ad44ba7321f313c9c927b6d..48fac6dc43ca9fb15d95e8fa9b00f34b83a9e7e8 100644 --- a/MeshLib/Mesh.cpp +++ b/MeshLib/Mesh.cpp @@ -299,11 +299,9 @@ void scaleMeshPropertyVector(MeshLib::Mesh & mesh, WARN("Did not find PropertyVector '{:s}' for scaling.", property_name); return; } - for (auto& v : - *mesh.getProperties().getPropertyVector<double>(property_name)) - { - v *= factor; - } + auto & pv = *mesh.getProperties().getPropertyVector<double>(property_name); + std::transform(pv.begin(), pv.end(), pv.begin(), + [factor](auto const& v) { return v * factor; }); } PropertyVector<int> const* materialIDs(Mesh const& mesh) diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp index f50f5ae41830d8be509dc4a6e891a6f4472cc803..16431c3c5bae1099e793974bdf49c4248b01dc76 100644 --- a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp +++ b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp @@ -40,10 +40,11 @@ std::vector<MeshLib::Element*> copyElementVector( { std::vector<MeshLib::Element*> new_elements; new_elements.reserve(elements.size()); - for (auto element : elements) - { - new_elements.push_back(copyElement(element, new_nodes, node_id_map)); - } + std::transform(elements.begin(), elements.end(), + std::back_inserter(new_elements), + [&new_nodes, &node_id_map](auto const& element) { + return copyElement(element, new_nodes, node_id_map); + }); return new_elements; } diff --git a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp index c72c61fa6b48c8f297f1e98197f3417104cfa5b7..0801ac227756c268a5953d51c8ac279e37102d37 100644 --- a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp +++ b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp @@ -84,7 +84,8 @@ bool Mesh2MeshPropertyInterpolation::setPropertiesForMesh(Mesh& dest_mesh) const } void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh( - Mesh& dest_mesh, MeshLib::PropertyVector<double>& dest_properties) const + Mesh const& dest_mesh, + MeshLib::PropertyVector<double>& dest_properties) const { std::vector<double> interpolated_src_node_properties( _src_mesh.getNumberOfNodes()); diff --git a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h index becf37c8a013a643f9ddeefa8120aafa00f359f2..636f4ba6a4be06b82e4fc78955c9ed47d0319dd5 100644 --- a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h +++ b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h @@ -53,7 +53,7 @@ private: * @param dest_properties */ void interpolatePropertiesForMesh( - Mesh& dest_mesh, + Mesh const& dest_mesh, MeshLib::PropertyVector<double>& dest_properties) const; /** diff --git a/MeshLib/MeshEditing/MeshRevision.cpp b/MeshLib/MeshEditing/MeshRevision.cpp index 2570421137ae024ebff5e80d54d3c2129bb0bf89..7783ff84722b3dc0f6292139ab6ae9eb461e6b5b 100644 --- a/MeshLib/MeshEditing/MeshRevision.cpp +++ b/MeshLib/MeshEditing/MeshRevision.cpp @@ -16,6 +16,7 @@ #include <numeric> +#include "BaseLib/Algorithm.h" #include "BaseLib/Logging.h" #include "GeoLib/Grid.h" @@ -89,7 +90,7 @@ MeshLib::Mesh* MeshRevision::simplifyMesh(const std::string &new_mesh_name, { ERR("Element {:d} has unknown element type.", k); this->resetNodeIDs(); - this->cleanUp(new_nodes, new_elements); + BaseLib::cleanupVectorElements(new_nodes, new_elements); return nullptr; } if (material_vec) @@ -131,7 +132,7 @@ MeshLib::Mesh* MeshRevision::simplifyMesh(const std::string &new_mesh_name, new_properties); } - this->cleanUp(new_nodes, new_elements); + BaseLib::cleanupVectorElements(new_nodes, new_elements); return nullptr; } @@ -912,18 +913,4 @@ unsigned MeshRevision::lutPrismThirdNode(unsigned id1, unsigned id2) const } return std::numeric_limits<unsigned>::max(); } - -void MeshRevision::cleanUp(std::vector<MeshLib::Node*> &new_nodes, std::vector<MeshLib::Element*> &new_elements) const -{ - for (auto& new_element : new_elements) - { - delete new_element; - } - - for (auto& new_node : new_nodes) - { - delete new_node; - } -} - } // end namespace MeshLib diff --git a/MeshLib/MeshEditing/ProjectPointOnMesh.cpp b/MeshLib/MeshEditing/ProjectPointOnMesh.cpp index b1ab4f265b3aedc31719d2ecf7750f101b1e2703..0453a133d432bf5afb76984faf51614b2b03d29c 100644 --- a/MeshLib/MeshEditing/ProjectPointOnMesh.cpp +++ b/MeshLib/MeshEditing/ProjectPointOnMesh.cpp @@ -61,7 +61,8 @@ MeshLib::Element const* getProjectedElement( double getElevation(MeshLib::Element const& element, MeshLib::Node const& node) { - MathLib::Vector3 const v = node - *element.getNode(0); + MathLib::Vector3 const v = + MathLib::Vector3(node) - MathLib::Vector3(*element.getNode(0)); MathLib::Vector3 const n = MeshLib::FaceRule::getSurfaceNormal(&element).getNormalizedVector(); return node[2] - scalarProduct(n, v) * n[2]; diff --git a/MeshLib/MeshEnums.cpp b/MeshLib/MeshEnums.cpp index c96f5df9b47a5d7cab50a676522bbed62070fdbc..acdd2fbf169614188283f3c4a8f5b4c5ac78060c 100644 --- a/MeshLib/MeshEnums.cpp +++ b/MeshLib/MeshEnums.cpp @@ -145,10 +145,11 @@ std::vector<MeshElemType> getMeshElemTypes() std::vector<std::string> getMeshElemTypeStringsShort() { std::vector<std::string> vec; - for (MeshElemType eleType : getMeshElemTypes()) - { - vec.push_back(MeshElemType2StringShort(eleType)); - } + auto const& mesh_elem_types = getMeshElemTypes(); + std::transform(mesh_elem_types.begin(), mesh_elem_types.end(), + std::back_inserter(vec), [](auto const& element_type) { + return MeshElemType2StringShort(element_type); + }); return vec; } diff --git a/MeshLib/MeshGenerators/MeshGenerator.cpp b/MeshLib/MeshGenerators/MeshGenerator.cpp index f80fcc02b36210b84f2c5884212ef350d5d795a1..a3e730983c1c706624eba7431c4b8f32790729ec 100644 --- a/MeshLib/MeshGenerators/MeshGenerator.cpp +++ b/MeshLib/MeshGenerators/MeshGenerator.cpp @@ -30,19 +30,28 @@ std::vector<MeshLib::Node*> MeshGenerator::generateRegularNodes( const std::vector<const std::vector<double>*> &vec_xyz_coords, const MathLib::Point3d& origin) { + auto const shift_coordinates = [](auto const& in, auto& out, + auto const& shift) { + std::transform(in.begin(), in.end(), std::back_inserter(out), + [&shift](auto const& v) { return v + shift; }); + }; + std::array<std::vector<double>, 3> coords; + for (std::size_t i = 0; i < 3; ++i) + { + coords[i].reserve(vec_xyz_coords[i]->size()); + shift_coordinates(*vec_xyz_coords[i], coords[i], origin[i]); + } + std::vector<Node*> nodes; - nodes.reserve(vec_xyz_coords[0]->size()*vec_xyz_coords[1]->size()*vec_xyz_coords[2]->size()); + nodes.reserve(coords[0].size() * coords[1].size() * coords[2].size()); - for (std::size_t i = 0; i < vec_xyz_coords[2]->size(); i++) + for (auto const z : coords[2]) { - const double z ((*vec_xyz_coords[2])[i]+origin[2]); - for (std::size_t j = 0; j < vec_xyz_coords[1]->size(); j++) + for (auto const y : coords[1]) { - const double y ((*vec_xyz_coords[1])[j]+origin[1]); - for (double const x : *vec_xyz_coords[0]) - { - nodes.push_back (new Node(x+origin[0], y, z)); - } + std::transform( + coords[0].begin(), coords[0].end(), std::back_inserter(nodes), + [&y, &z](double const& x) { return new Node(x, y, z); }); } } return nodes; diff --git a/MeshLib/MeshGenerators/MeshLayerMapper.cpp b/MeshLib/MeshGenerators/MeshLayerMapper.cpp index 48188ab5eec43e56d22bf83ecc38bd52e42e2d02..c2ae402cfb3dd30d9cf6028957a430c30e31ab04 100644 --- a/MeshLib/MeshGenerators/MeshLayerMapper.cpp +++ b/MeshLib/MeshGenerators/MeshLayerMapper.cpp @@ -174,10 +174,8 @@ bool MeshLayerMapper::createRasterLayers( // add bottom layer std::vector<MeshLib::Node*> const& nodes = bottom->getNodes(); - for (MeshLib::Node* node : nodes) - { - _nodes.push_back(new MeshLib::Node(*node)); - } + std::transform(nodes.begin(), nodes.end(), std::back_inserter(_nodes), + [](auto const* node) { return new MeshLib::Node(*node); }); // add the other layers for (std::size_t i = 0; i < nLayers - 1; ++i) diff --git a/MeshLib/MeshSearch/MeshElementGrid.cpp b/MeshLib/MeshSearch/MeshElementGrid.cpp index fe0e69527661efba62d2854347223c5b4b50b4fa..dc44cb6f379e8200aaad13eb79f192a51fc6636d 100644 --- a/MeshLib/MeshSearch/MeshElementGrid.cpp +++ b/MeshLib/MeshSearch/MeshElementGrid.cpp @@ -134,7 +134,6 @@ bool MeshElementGrid::sortElementInGridCells(MeshLib::Element const& element) return false; } - std::vector<std::array<std::size_t,3>> coord_vecs(element.getNumberOfNodes()); for (std::size_t k(1); k<element.getNumberOfNodes(); ++k) { // compute coordinates of the grid for each node of the element c = getGridCellCoordinates(*(static_cast<MathLib::Point3d const*>(element.getNode(k)))); diff --git a/MeshLib/Node.h b/MeshLib/Node.h index ccd519139c3a58d89b3dda8b36d0ce2d3175707e..2ee62b82e039a256d3f7df836a636fa1423a6e09 100644 --- a/MeshLib/Node.h +++ b/MeshLib/Node.h @@ -91,7 +91,7 @@ protected: /// Resets the connected nodes of this node. The connected nodes are /// generated by Mesh::setNodesConnectedByElements(). - void setConnectedNodes(std::vector<Node*> &connected_nodes) + void setConnectedNodes(std::vector<Node*> const& connected_nodes) { _connected_nodes = connected_nodes; } diff --git a/MeshLib/Properties.cpp b/MeshLib/Properties.cpp index 2423ac01b8b397e0a4b0aa5340ca1eb08ae80c4f..68a77de2bac41036a7ff3044bca564a05a0d48a4 100644 --- a/MeshLib/Properties.cpp +++ b/MeshLib/Properties.cpp @@ -36,10 +36,9 @@ bool Properties::hasPropertyVector(std::string const& name) const std::vector<std::string> Properties::getPropertyVectorNames() const { std::vector<std::string> names; - for (auto p : _properties) - { - names.push_back(p.first); - } + std::transform(_properties.begin(), _properties.end(), + std::back_inserter(names), + [](auto const& pair) { return pair.first; }); return names; } diff --git a/MeshLib/convertMeshToGeo.cpp b/MeshLib/convertMeshToGeo.cpp index 10a6aa6aef239ba34a1e4ac86b10aa60d4832a13..6e9ee80d8bcfcd7af95cce06a83359295a542a82 100644 --- a/MeshLib/convertMeshToGeo.cpp +++ b/MeshLib/convertMeshToGeo.cpp @@ -133,12 +133,12 @@ bool convertMeshToGeo(const MeshLib::Mesh& mesh, addElementToSurface(*elements[i], id_map, *(*sfcs)[surfaceId]); } - std::for_each(sfcs->begin(), sfcs->end(), [](GeoLib::Surface* sfc) { + std::for_each(sfcs->begin(), sfcs->end(), [](GeoLib::Surface*& sfc) { if (sfc->getNumberOfTriangles() == 0) { delete sfc; + sfc = nullptr; } - sfc = nullptr; }); auto sfcs_end = std::remove(sfcs->begin(), sfcs->end(), nullptr); sfcs->erase(sfcs_end, sfcs->end()); diff --git a/ProcessLib/BoundaryCondition/NormalTractionBoundaryConditionLocalAssembler.h b/ProcessLib/BoundaryCondition/NormalTractionBoundaryConditionLocalAssembler.h index 76bec33b3d05eb2127e63772935160e95f747c28..8ed02b06f0136add80ca7754fc72319a1efd691f 100644 --- a/ProcessLib/BoundaryCondition/NormalTractionBoundaryConditionLocalAssembler.h +++ b/ProcessLib/BoundaryCondition/NormalTractionBoundaryConditionLocalAssembler.h @@ -86,7 +86,8 @@ public: // TODO Extend to rotated 2d meshes and line elements. if (e.getGeomType() == MeshLib::MeshElemType::LINE) { - auto v1 = (*e.getNode(1)) - (*e.getNode(0)); + auto v1 = MathLib::Vector3(*e.getNode(1)) - + MathLib::Vector3(*e.getNode(0)); element_normal[0] = -v1[1]; element_normal[1] = v1[0]; element_normal.normalize(); diff --git a/ProcessLib/LIE/Common/Utils.cpp b/ProcessLib/LIE/Common/Utils.cpp index 3866fb50c94981f6f408dbfb49bb62e238e86d3c..d6c52f604c17737b6f1ed29933118ff9fc7d6053 100644 --- a/ProcessLib/LIE/Common/Utils.cpp +++ b/ProcessLib/LIE/Common/Utils.cpp @@ -21,7 +21,8 @@ void computeNormalVector(MeshLib::Element const& e, unsigned const global_dim, if (global_dim == 2) { assert(e.getGeomType() == MeshLib::MeshElemType::LINE); - auto v1 = (*e.getNode(1)) - (*e.getNode(0)); + auto v1 = + MathLib::Vector3(*e.getNode(1)) - MathLib::Vector3(*e.getNode(0)); element_normal[0] = -v1[1]; element_normal[1] = v1[0]; element_normal[2] = 0; // not used in 2d but needed for normalization