Skip to content
Snippets Groups Projects
Commit 5524c632 authored by Dmitri Naumov's avatar Dmitri Naumov Committed by Dmitri Naumov
Browse files

[MGTL] Construct meshes from geometries.

parent d0c0266c
No related branches found
No related tags found
No related merge requests found
/**
* \file
* \copyright
* Copyright (c) 2012-2018, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*/
#include "ConstructMeshesFromGeometries.h"
#include <logog/include/logog.hpp>
#include "MeshLib/Elements/Element.h"
#include "MeshLib/MeshEditing/DuplicateMeshComponents.h"
#include "MeshLib/Node.h"
#include "BoundaryElementsSearcher.h"
#include "MeshNodeSearcher.h"
namespace MeshGeoToolsLib
{
template <typename GeometryVec>
std::vector<std::unique_ptr<MeshLib::Mesh>>
constructAdditionalMeshesFromGeometries(
std::vector<GeometryVec*> const& geometries,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher)
{
std::vector<std::unique_ptr<MeshLib::Mesh>> additional_meshes;
for (GeometryVec* const geometry_vec : geometries)
{
// Each geometry_vec has a name, this is the first part of the full
// name.
auto const& vec_name = geometry_vec->getName();
auto const& vec_data = *geometry_vec->getVector();
auto const vec_size = geometry_vec->size();
for (std::size_t i = 0; i < vec_size; ++i)
{
// Each geometry has a name, this is the second part of the full
// name.
std::string geometry_name;
bool const is_geometry_named =
geometry_vec->getNameOfElementByID(i, geometry_name);
if (!is_geometry_named)
{
continue;
}
auto const& geometry = *vec_data[i];
DBUG("Creating mesh from geometry %s %s.", vec_name.c_str(),
geometry_name.c_str());
additional_meshes.emplace_back(createMeshFromElementSelection(
vec_name + "_" + geometry_name,
MeshLib::cloneElements(
boundary_element_searcher.getBoundaryElements(geometry))));
}
}
return additional_meshes;
}
std::vector<std::unique_ptr<MeshLib::Mesh>>
constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const& geo_objects,
MeshLib::Mesh const& mesh)
{
std::vector<std::unique_ptr<MeshLib::Mesh>> additional_meshes;
// TODO (naumov) add config for search length algorithms.
auto search_length_algorithm =
std::make_unique<MeshGeoToolsLib::SearchLength>();
auto const& mesh_node_searcher =
MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeSearcher(
mesh, std::move(search_length_algorithm));
MeshGeoToolsLib::BoundaryElementsSearcher boundary_element_searcher(
mesh, mesh_node_searcher);
//
// Points
//
{
auto point_meshes = constructAdditionalMeshesFromGeometries(
geo_objects.getPoints(), boundary_element_searcher);
std::move(begin(point_meshes), end(point_meshes),
std::back_inserter(additional_meshes));
}
//
// Polylines
//
{
auto polyline_meshes = constructAdditionalMeshesFromGeometries(
geo_objects.getPolylines(), boundary_element_searcher);
std::move(begin(polyline_meshes), end(polyline_meshes),
std::back_inserter(additional_meshes));
}
// Surfaces
{
auto surface_meshes = constructAdditionalMeshesFromGeometries(
geo_objects.getSurfaces(), boundary_element_searcher);
std::move(begin(surface_meshes), end(surface_meshes),
std::back_inserter(additional_meshes));
}
return additional_meshes;
}
} // namespace MeshGeoToolsLib
/**
* \file
* \copyright
* Copyright (c) 2012-2018, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*/
#include <memory>
#include <vector>
#include "MeshLib/Mesh.h"
namespace GeoLib
{
class GEOObjects;
}
namespace MeshGeoToolsLib
{
/// For each named geometry in the give geo_objects (defined on the given \c
/// mesh) constructs a mesh corresponding to the geometry with mappings to the
/// bulk mesh elements and nodes.
std::vector<std::unique_ptr<MeshLib::Mesh>>
constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const& geo_objects,
MeshLib::Mesh const& mesh);
} // namespace MeshGeoToolsLib
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment