24 std::vector<GeoLib::Point*> points;
28 std::back_inserter(points),
30 { return new GeoLib::Point(*node_ptr, node_ptr->getID()); });
32 auto geoobject_name = mesh.
getName();
34 geo_objects.
addPointVec(std::move(points), geoobject_name, {}, eps);
35 return geoobject_name;
39 std::vector<std::size_t>
const& id_map,
45 id_map[getNodeIndex(e, 1)],
46 id_map[getNodeIndex(e, 2)]);
52 id_map[getNodeIndex(e, 1)],
53 id_map[getNodeIndex(e, 2)]);
55 id_map[getNodeIndex(e, 2)],
56 id_map[getNodeIndex(e, 3)]);
72 ERR(
"Mesh to geometry conversion is only working for 2D meshes.");
77 auto get_material_ids_and_bounds = [&]()
80 auto const materialIds = materialIDs(mesh);
83 return std::make_tuple(
nullptr, std::make_pair(0, 0));
91 "Could not get minimum/maximum ranges values for the "
92 "MaterialIDs property in the mesh '{:s}'.",
95 return std::make_tuple(materialIds, *bounds);
98 auto const [materialIds, bounds] = get_material_ids_and_bounds();
100 const unsigned nMatGroups(bounds.second - bounds.first + 1);
101 std::vector<GeoLib::Surface*> sfcs;
102 sfcs.reserve(nMatGroups);
103 std::string
const geoobject_name =
104 convertMeshNodesToGeoPoints(mesh, eps, geo_objects);
105 auto const& points = *geo_objects.
getPointVec(geoobject_name);
106 for (
unsigned i = 0; i < nMatGroups; ++i)
111 const std::vector<std::size_t>& id_map(
113 const std::vector<MeshLib::Element*>& elements = mesh.
getElements();
116 for (
unsigned i = 0; i < nElems; ++i)
118 auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first);
119 addElementToSurface(*elements[i], id_map, *sfcs[surfaceId]);
122 std::for_each(sfcs.begin(), sfcs.end(),
125 if (sfc->getNumberOfTriangles() == 0)
131 auto sfcs_end = std::remove(sfcs.begin(), sfcs.end(),
nullptr);
132 sfcs.erase(sfcs_end, sfcs.end());
134 geo_objects.addSurfaceVec(std::move(sfcs), geoobject_name,
140 const std::string& mesh_name,
144 std::vector<MeshLib::Node*> nodes;
145 std::vector<MeshLib::Element*> elements;
146 std::size_t nodeId = 0;
151 for (
unsigned j = 0; j < 3; j++)
157 for (
unsigned j = 0; j < 3; j++)
159 nodes.push_back(tri_nodes[j]);
163 mesh_name, nodes, elements,
true );
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Container class for geometric objects.
const std::vector< Point * > * getPointVec(const std::string &name) const
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
const PointVec * getPointVecObj(const std::string &name) const
const std::vector< std::size_t > & getIDMap() const
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
std::size_t getNumberOfTriangles() const
void addTriangle(std::size_t pnt_a, std::size_t pnt_b, std::size_t pnt_c)
std::map< std::string, std::size_t > NameIdMap
virtual MeshElemType getGeomType() const =0
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
const std::string getName() const
Get name of the mesh.
std::size_t getNumberOfNodes() const
Get the number of nodes.
std::size_t getNumberOfElements() const
Get the number of elements.
TemplateElement< MeshLib::TriRule3 > Tri
void addElementToSurface(MeshLib::Element const &e, std::vector< std::size_t > const &id_map, GeoLib::Surface &surface)
std::string convertMeshNodesToGeoPoints(MeshLib::Mesh const &mesh, double const eps, GeoLib::GEOObjects &geo_objects)