35 std::vector<GeoLib::Point*> points;
39 std::back_inserter(points),
41 { return new GeoLib::Point(*node_ptr, node_ptr->getID()); });
43 auto geoobject_name = mesh.
getName();
45 geo_objects.
addPointVec(std::move(points), geoobject_name, {}, eps);
46 return geoobject_name;
50 std::vector<std::size_t>
const& id_map,
56 id_map[getNodeIndex(e, 1)],
57 id_map[getNodeIndex(e, 2)]);
63 id_map[getNodeIndex(e, 1)],
64 id_map[getNodeIndex(e, 2)]);
66 id_map[getNodeIndex(e, 2)],
67 id_map[getNodeIndex(e, 3)]);
83 ERR(
"Mesh to geometry conversion is only working for 2D meshes.");
88 auto get_material_ids_and_bounds = [&]()
91 auto const materialIds = materialIDs(mesh);
94 return std::make_tuple(
nullptr, std::make_pair(0, 0));
102 "Could not get minimum/maximum ranges values for the "
103 "MaterialIDs property in the mesh '{:s}'.",
106 return std::make_tuple(materialIds, *bounds);
109 auto const [materialIds, bounds] = get_material_ids_and_bounds();
111 const unsigned nMatGroups(bounds.second - bounds.first + 1);
112 std::vector<GeoLib::Surface*> sfcs;
113 sfcs.reserve(nMatGroups);
114 std::string
const geoobject_name =
115 convertMeshNodesToGeoPoints(mesh, eps, geo_objects);
116 auto const& points = *geo_objects.
getPointVec(geoobject_name);
117 for (
unsigned i = 0; i < nMatGroups; ++i)
122 const std::vector<std::size_t>& id_map(
124 const std::vector<MeshLib::Element*>& elements = mesh.
getElements();
127 for (
unsigned i = 0; i < nElems; ++i)
129 auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first);
130 addElementToSurface(*elements[i], id_map, *sfcs[surfaceId]);
133 std::for_each(sfcs.begin(), sfcs.end(),
136 if (sfc->getNumberOfTriangles() == 0)
142 auto sfcs_end = std::remove(sfcs.begin(), sfcs.end(),
nullptr);
143 sfcs.erase(sfcs_end, sfcs.end());
145 geo_objects.addSurfaceVec(std::move(sfcs), geoobject_name,
151 const std::string& mesh_name,
155 std::vector<MeshLib::Node*> nodes;
156 std::vector<MeshLib::Element*> elements;
157 std::size_t nodeId = 0;
162 for (
unsigned j = 0; j < 3; j++)
168 for (
unsigned j = 0; j < 3; j++)
170 nodes.push_back(tri_nodes[j]);
174 mesh_name, nodes, elements,
true );
Definition of the GEOObjects class.
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the MeshRevision class.
Definition of the Mesh class.
Definition of the Quad class.
Definition of the Tri class.
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.
Definition of mesh to geometry conversion.
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)