6#include <vtkDataArray.h>
16class vtkUnstructuredGrid;
33 vtkUnstructuredGrid* grid,
34 bool const compute_element_neighbors =
false,
35 std::string
const& mesh_name =
"vtkUnstructuredGrid");
42 std::vector<double>
const& elevation,
43 std::vector<int>& node_idx_map,
49 std::vector<double>
const& pix_val,
50 std::vector<bool>
const& pix_vis,
51 std::vector<MeshLib::Node*>
const& nodes,
52 std::vector<int>
const& node_idx_map,
53 std::size_t
const imgHeight,
54 std::size_t
const imgWidth,
60 std::vector<double>
const& pix_val,
61 std::vector<bool>
const& pix_vis,
62 const std::size_t& imgHeight,
63 const std::size_t& imgWidth,
66 for (std::size_t i = 0; i < imgHeight; i++)
68 for (std::size_t j = 0; j < imgWidth; j++)
70 if (!pix_vis[i * imgWidth + j])
74 T val(
static_cast<T
>(pix_val[i * (imgWidth + 1) + j]));
105 if (
sizeof(T) != array.GetDataTypeSize())
108 "Trying to convert a vtk array '{:s}' with data type '{:s}' of "
109 "size {:d} to a different sized type '{:s}' of size {:d}.",
110 array.GetName(), array.GetDataTypeAsString(),
114 vtkIdType
const nTuples(array.GetNumberOfTuples());
115 int const nComponents(array.GetNumberOfComponents());
116 char const*
const array_name(array.GetName());
119 array_name, type, nTuples, nComponents);
122 WARN(
"Array {:s} could not be converted to PropertyVector.",
126 auto* data_array =
static_cast<T*
>(array.GetVoidPointer(0));
127 vec->
assign(std::span<T>(data_array, nTuples * nComponents));
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
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)
constexpr void assign(R &&r)
constexpr void push_back(const PROP_VAL_TYPE &value)
Converter for VtkUnstructured Grids to OGS meshes.
static std::vector< MeshLib::Element * > createElementVector(std::vector< double > const &pix_val, std::vector< bool > const &pix_vis, std::vector< MeshLib::Node * > const &nodes, std::vector< int > const &node_idx_map, std::size_t const imgHeight, std::size_t const imgWidth, MeshElemType elem_type)
Creates a mesh element vector based on image data.
static void fillPropertyVector(MeshLib::PropertyVector< T > &prop_vec, std::vector< double > const &pix_val, std::vector< bool > const &pix_vis, const std::size_t &imgHeight, const std::size_t &imgWidth, MeshElemType elem_type)
Creates a scalar array/mesh property based on pixel values.
static void convertTypedArray(vtkDataArray &array, MeshLib::Properties &properties, MeshLib::MeshItemType type)
static void convertScalarArrays(vtkUnstructuredGrid &grid, MeshLib::Mesh &mesh)
static MeshLib::Mesh * convertUnstructuredGrid(vtkUnstructuredGrid *grid, bool const compute_element_neighbors=false, std::string const &mesh_name="vtkUnstructuredGrid")
Converts a vtkUnstructuredGrid object to a Mesh.
static void convertArray(vtkDataArray &array, MeshLib::Properties &properties, MeshLib::MeshItemType type)
static std::vector< MeshLib::Node * > createNodeVector(std::vector< double > const &elevation, std::vector< int > &node_idx_map, GeoLib::RasterHeader const &header, bool use_elevation)
std::string typeToString()
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.