OGS
VtkMappedMeshSource.h
Go to the documentation of this file.
1 
21 #pragma once
22 
23 #include <string>
24 
25 #include <vtkAOSDataArrayTemplate.h>
26 #include <vtkCellData.h>
27 #include <vtkFieldData.h>
28 #include <vtkNew.h>
29 #include <vtkPointData.h>
30 #include <vtkUnstructuredGrid.h>
31 #include <vtkUnstructuredGridAlgorithm.h>
32 
33 #include "MeshLib/Properties.h"
34 #include "MeshLib/PropertyVector.h"
35 
36 
37 
38 namespace MeshLib {
39 
40 class Mesh;
41 
44 class VtkMappedMeshSource final : public vtkUnstructuredGridAlgorithm
45 {
46 public:
48  vtkTypeMacro(VtkMappedMeshSource, vtkUnstructuredGridAlgorithm);
49  void PrintSelf(std::ostream& os, vtkIndent indent) override;
50 
52  void operator=(const VtkMappedMeshSource&) = delete;
53 
55  void SetMesh(const MeshLib::Mesh* mesh)
56  {
57  this->_mesh = mesh;
58  this->Modified();
59  }
60 
62  const MeshLib::Mesh* GetMesh() const { return _mesh; }
63 
64 protected:
66 
67  int ProcessRequest(vtkInformation* request,
68  vtkInformationVector** inputVector,
69  vtkInformationVector* outputVector) override;
70  int RequestData(vtkInformation* /*request*/,
71  vtkInformationVector** /*inputVector*/,
72  vtkInformationVector* /*outputVector*/) override;
73  int RequestInformation(vtkInformation* /*request*/,
74  vtkInformationVector** /*inputVector*/,
75  vtkInformationVector* /*outputVector*/) override;
76 
77 private:
79  template <typename T>
80  void addProperty(MeshLib::PropertyVector<T> const& property) const;
81 
82  const MeshLib::Mesh* _mesh{};
83 
85  int NumberOfNodes{0};
86 
87  vtkNew<vtkPoints> Points;
88  vtkNew<vtkPointData> PointData;
89  vtkNew<vtkCellData> CellData;
90  vtkNew<vtkFieldData> FieldData;
91 };
92 
93 } // Namespace MeshLib
Definition of the class Properties that implements a container of properties.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void addProperty(MeshLib::PropertyVector< T > const &property) const
Adds a zero-copy vtk array wrapper.
vtkTypeMacro(VtkMappedMeshSource, vtkUnstructuredGridAlgorithm)
vtkNew< vtkPointData > PointData
int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
void SetMesh(const MeshLib::Mesh *mesh)
Sets the mesh. Calling is mandatory.
static VtkMappedMeshSource * New()
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
vtkNew< vtkCellData > CellData
void PrintSelf(std::ostream &os, vtkIndent indent) override