OGS
VtkMappedMeshSource.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <vtkAOSDataArrayTemplate.h>
7#include <vtkCellData.h>
8#include <vtkFieldData.h>
9#include <vtkNew.h>
10#include <vtkPointData.h>
11#include <vtkUnstructuredGrid.h>
12#include <vtkUnstructuredGridAlgorithm.h>
13
14#include <set>
15#include <string>
16
17#include "MeshLib/Properties.h"
19
20namespace MeshLib
21{
22
23class Mesh;
24
34class VtkMappedMeshSource final : public vtkUnstructuredGridAlgorithm
35{
36public:
38 vtkTypeMacro(VtkMappedMeshSource, vtkUnstructuredGridAlgorithm);
39 void PrintSelf(std::ostream& os, vtkIndent indent) override;
40
42 void operator=(const VtkMappedMeshSource&) = delete;
43
45 void SetMesh(const MeshLib::Mesh* mesh)
46 {
47 this->_mesh = mesh;
48 this->Modified();
49 }
50
51 void setOutputVariableNames(std::set<std::string> const& output_variables);
52
54 const MeshLib::Mesh* GetMesh() const { return _mesh; }
55
56protected:
58
59 int ProcessRequest(vtkInformation* request,
60 vtkInformationVector** inputVector,
61 vtkInformationVector* outputVector) override;
62 int RequestData(vtkInformation* /*request*/,
63 vtkInformationVector** /*inputVector*/,
64 vtkInformationVector* /*outputVector*/) override;
65 int RequestInformation(vtkInformation* /*request*/,
66 vtkInformationVector** /*inputVector*/,
67 vtkInformationVector* /*outputVector*/) override;
68
69private:
71 template <typename T>
72 void addProperty(MeshLib::PropertyVector<T> const& property) const;
73
75 std::set<std::string> _output_variable_names;
76
79
80 vtkNew<vtkPoints> Points;
81 vtkNew<vtkPointData> PointData;
82 vtkNew<vtkCellData> CellData;
83 vtkNew<vtkFieldData> FieldData;
84};
85
86} // Namespace MeshLib
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void setOutputVariableNames(std::set< std::string > const &output_variables)
std::set< std::string > _output_variable_names
void addProperty(MeshLib::PropertyVector< T > const &property) const
Adds a zero-copy vtk array wrapper.
vtkTypeMacro(VtkMappedMeshSource, vtkUnstructuredGridAlgorithm)
vtkNew< vtkPointData > PointData
static VtkMappedMeshSource * New()
int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
void SetMesh(const MeshLib::Mesh *mesh)
Sets the mesh. Calling is mandatory.
vtkNew< vtkFieldData > FieldData
void operator=(const VtkMappedMeshSource &)=delete
const MeshLib::Mesh * GetMesh() const
Returns the mesh.
VtkMappedMeshSource(const VtkMappedMeshSource &)=delete
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void PrintSelf(std::ostream &os, vtkIndent indent) override