/** * \file * \author Karsten Rink * \date 2013-04-04 * \brief Definition of the MeshSurfaceExtraction class * * \copyright * Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org) * Distributed under a Modified BSD License. * See accompanying file LICENSE.txt or * http://www.opengeosys.org/project/license * */ #pragma once #include #include #include #include "MeshLib/Mesh.h" #include "MeshLib/Properties.h" namespace MeshLib { // forward declarations class Mesh; class Element; class Node; /** * \brief A set of tools concerned with extracting nodes and elements from a * mesh surface */ class MeshSurfaceExtraction { public: /// Returns a vector of the areas assigned to each node on a surface mesh. static std::vector getSurfaceAreaForNodes( const MeshLib::Mesh& mesh); /// Returns the surface nodes of a mesh. static std::vector getSurfaceNodes( const MeshLib::Mesh& mesh, Eigen::Vector3d const& dir, double angle); /** * Returns the 2d-element mesh representing the surface of the given mesh. * \param subsfc_mesh The original mesh * \param dir The direction in which face normals have to * point to be considered surface elements * \param angle The angle of the allowed deviation from the * given direction (0 <= angle <= 90 degrees) * \param subsfc_node_id_prop_name The name of the \c PropertyVector in * the surface mesh the subsurface mesh node ids are stored to. If the * string is empty, there won't be such a \c PropertyVector. * \param subsfc_element_id_prop_name The name of the PropertyVector in * the surface mesh that stores the subsurface element ids. If the string * is empty, there won't be such a \c PropertyVector. * \param face_id_prop_name The name of the \c PropertyVector in the surface * mesh that stores the face number of the subsurface element that belongs * to the boundary. If the string is empty, there won't be such a \c * PropertyVector. * \return A 2D mesh representing the surface in direction dir */ static MeshLib::Mesh* getMeshSurface( const MeshLib::Mesh& subsfc_mesh, Eigen::Vector3d const& dir, double angle, std::string_view subsfc_node_id_prop_name = "", std::string_view subsfc_element_id_prop_name = "", std::string_view face_id_prop_name = ""); private: /// Functionality needed for getSurfaceNodes() and getMeshSurface() static void get2DSurfaceElements( const std::vector& all_elements, std::vector& sfc_elements, std::vector& element_to_bulk_element_id_map, std::vector& element_to_bulk_face_id_map, Eigen::Vector3d const& dir, double angle, unsigned mesh_dimension); }; namespace BoundaryExtraction { std::unique_ptr getBoundaryElementsAsMesh( MeshLib::Mesh const& bulk_mesh, std::string_view subsfc_node_id_prop_name, std::string_view subsfc_element_id_prop_name, std::string_view face_id_prop_name); } void addBulkIDPropertiesToMesh( MeshLib::Mesh& surface_mesh, std::string_view node_to_bulk_node_id_map_name, std::vector const& node_to_bulk_node_id_map, std::string_view element_to_bulk_element_id_map_name, std::vector const& element_to_bulk_element_id_map, std::string_view element_to_bulk_face_id_map_name, std::vector const& element_to_bulk_face_id_map); } // namespace MeshLib