From ae80889baf0d1e95b0389ae7cf79e443785ec310 Mon Sep 17 00:00:00 2001 From: Julian Heinze Date: Wed, 19 Jul 2023 16:17:39 +0200 Subject: [PATCH] included non_const version of materialIDs in mesh and used new version for mat_ids --- MeshLib/Mesh.cpp | 6 ++++++ MeshLib/Mesh.h | 1 + MeshToolsLib/MeshGenerators/AddFaultToVoxelGrid.cpp | 3 +-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp index ca7165fd070..3e644ed03ac 100644 --- a/MeshLib/Mesh.cpp +++ b/MeshLib/Mesh.cpp @@ -273,6 +273,12 @@ PropertyVector const* materialIDs(Mesh const& mesh) return nullptr; } +PropertyVector* materialIDs(Mesh& mesh) +{ + return const_cast*>( + MeshLib::materialIDs(std::as_const(mesh))); +} + PropertyVector const* bulkNodeIDs(Mesh const& mesh) { auto const& properties = mesh.getProperties(); diff --git a/MeshLib/Mesh.h b/MeshLib/Mesh.h index 1bc1e382240..871a036f060 100644 --- a/MeshLib/Mesh.h +++ b/MeshLib/Mesh.h @@ -182,6 +182,7 @@ inline bool operator!=(Mesh const& a, Mesh const& b) /// If the property does not exists (or is of different type), a nullptr is /// returned. PropertyVector const* materialIDs(Mesh const& mesh); +PropertyVector* materialIDs(Mesh& mesh); PropertyVector const* bulkNodeIDs(Mesh const& mesh); PropertyVector const* bulkElementIDs(Mesh const& mesh); diff --git a/MeshToolsLib/MeshGenerators/AddFaultToVoxelGrid.cpp b/MeshToolsLib/MeshGenerators/AddFaultToVoxelGrid.cpp index 6305482b7d5..a0d1089629d 100644 --- a/MeshToolsLib/MeshGenerators/AddFaultToVoxelGrid.cpp +++ b/MeshToolsLib/MeshGenerators/AddFaultToVoxelGrid.cpp @@ -29,7 +29,6 @@ namespace { -static std::string mat_name = "MaterialIDs"; // tests if a plane and an AABB are intersecting // (based on Christer Ericson "Real Time Collision Detection" 5.2.3) bool testAABBIntersectingPlane(Eigen::Vector3d const& aabb_centre, @@ -99,7 +98,7 @@ void markFaults(MeshLib::Mesh& mesh, MeshLib::Mesh const& fault, { auto const& elems = mesh.getElements(); std::size_t const n_elems = mesh.getNumberOfElements(); - auto mat_ids = mesh.getProperties().getPropertyVector("MaterialIDs"); + auto mat_ids = MeshLib::materialIDs(mesh); auto const& fnodes = fault.getNodes(); auto const& felems = fault.getElements(); GeoLib::AABB const fault_aabb(fnodes.cbegin(), fnodes.cend());