14#include <vtkCellData.h>
15#include <vtkDataArray.h>
16#include <vtkImageData.h>
17#include <vtkPointData.h>
18#include <vtkSmartPointer.h>
35 std::string
const& array_name)
45 double const*
const img,
49 std::string
const& array_name)
56 ERR(
"Invalid Mesh Element Type.");
64 ERR(
"Triangle or Quad elements cannot be used to construct meshes from "
73 ERR(
"Elevation mapping can only be performed for 2D meshes.");
77 std::unique_ptr<MeshLib::Mesh> mesh;
117 std::unique_ptr<MeshLib::Mesh> new_mesh;
118 std::vector<std::size_t> elements_to_remove;
121 std::vector<MeshLib::Node*>
const& nodes(mesh->getNodes());
122 std::vector<MeshLib::Element*>
const& elems(mesh->getElements());
123 std::size_t
const n_nodes(elems[0]->getNumberOfNodes());
124 bool const double_idx =
127 std::size_t
const m = (double_idx) ? 2 : 1;
128 for (std::size_t k = 0; k < header.
n_depth; k++)
130 std::size_t
const layer_idx = (k * header.
n_rows * header.
n_cols);
131 for (std::size_t i = 0; i < header.
n_cols; i++)
133 std::size_t
const idx(i * header.
n_rows + layer_idx);
134 for (std::size_t j = 0; j < header.
n_rows; j++)
136 double const val(img[idx + j]);
139 elements_to_remove.push_back(m * (idx + j));
142 elements_to_remove.push_back(m * (idx + j) + 1);
146 for (std::size_t n = 0; n < n_nodes; ++n)
148 (*(nodes[getNodeIndex(*elems[m * (idx + j)], n)]))[2] =
152 (*(nodes[getNodeIndex(*elems[m * (idx + j) + 1],
164 if (array_name ==
"MaterialIDs")
168 fillPropertyVector<int>(*prop_vec, img, header, elem_type);
170 static_cast<int>(header.
no_data));
176 fillPropertyVector<double>(*prop_vec, img, header, elem_type);
181 if (!elements_to_remove.empty())
184 *mesh, elements_to_remove, mesh->getName()));
188 new_mesh = std::move(mesh);
193 new_mesh->getProperties().removePropertyVector(array_name);
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
Definition of the Node class.
Class Raster is used for managing raster data.
double const * data() const
RasterHeader const & getHeader() const
Returns the complete header information.
const std::vector< std::size_t > & getSearchedElementIDs() const
return marked elements
std::size_t searchByPropertyValue(std::string const &property_name, PROPERTY_TYPE const property_value)
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
PropertyVector< T > * createNewPropertyVector(std::string_view name, MeshItemType mesh_item_type, std::size_t n_components=1)
UseIntensityAs
Selection of possible interpretations for intensities.
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.