35 auto points = std::make_unique<std::vector<GeoLib::Point*>>();
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,
nullptr, eps);
46 return geoobject_name;
50 std::vector<std::size_t>
const& id_map,
83 ERR(
"Mesh to geometry conversion is only working for 2D meshes.");
88 auto get_material_ids_and_bounds = [&]()
94 return std::make_tuple(
nullptr, std::make_pair(0, 0));
101 "Could not get minimum/maximum ranges values for the "
102 "MaterialIDs property in the mesh '{:s}'.",
105 return std::make_tuple(materialIds, *bounds);
108 auto const [materialIds, bounds] = get_material_ids_and_bounds();
110 const unsigned nMatGroups(bounds.second - bounds.first + 1);
111 auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>();
112 sfcs->reserve(nMatGroups);
113 std::string
const geoobject_name =
115 auto const& points = *geo_objects.
getPointVec(geoobject_name);
116 for (
unsigned i = 0; i < nMatGroups; ++i)
121 const std::vector<std::size_t>& id_map(
123 const std::vector<MeshLib::Element*>& elements = mesh.
getElements();
126 for (
unsigned i = 0; i < nElems; ++i)
128 auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first);
132 std::for_each(sfcs->begin(), sfcs->end(),
135 if (sfc->getNumberOfTriangles() == 0)
141 auto sfcs_end = std::remove(sfcs->begin(), sfcs->end(),
nullptr);
142 sfcs->erase(sfcs_end, sfcs->end());
144 geo_objects.addSurfaceVec(std::move(sfcs), geoobject_name);
149 const std::string& mesh_name,
153 std::vector<MeshLib::Node*> nodes;
154 std::vector<MeshLib::Element*> elements;
155 std::size_t nodeId = 0;
160 for (
unsigned j = 0; j < 3; j++)
166 for (
unsigned j = 0; j < 3; j++)
168 nodes.push_back(tri_nodes[j]);
171 MeshLib::Mesh mesh_with_duplicated_nodes(mesh_name, nodes, elements);
Definition of the GEOObjects class.
void ERR(char const *fmt, Args const &... 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
const PointVec * getPointVecObj(const std::string &name) const
void addPointVec(std::unique_ptr< std::vector< Point * >> points, std::string &name, std::unique_ptr< std::map< std::string, std::size_t >> pnt_id_name_map=nullptr, double eps=std::sqrt(std::numeric_limits< double >::epsilon()))
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)
virtual MeshElemType getGeomType() const =0
MeshLib::Mesh * simplifyMesh(const std::string &new_mesh_name, double eps, unsigned min_elem_dim=1) const
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
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.
bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double const eps)
MeshLib::Mesh * convertSurfaceToMesh(const GeoLib::Surface &sfc, const std::string &mesh_name, double eps)
PropertyVector< int > const * materialIDs(Mesh const &mesh)
std::size_t getNodeIndex(Element const &element, unsigned const idx)
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)