59{
60 vtkSmartPointer<vtkInformation> outInfo =
61 outputVector->GetInformationObject(0);
62 vtkSmartPointer<vtkUnstructuredGrid> output =
63 vtkUnstructuredGrid::SafeDownCast(
64 outInfo->Get(vtkDataObject::DATA_OBJECT()));
65
66 if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) >
67 0)
68 {
69 return 1;
70 }
71
72
74
75 MeshNodalCoordinatesBackend backend(
_mesh->getNodes());
76
77 vtkNew<vtkImplicitArray<MeshNodalCoordinatesBackend>> nodeCoords;
78 nodeCoords->ConstructBackend(backend);
79 nodeCoords->SetNumberOfComponents(3);
80 nodeCoords->SetNumberOfTuples(
_mesh->getNumberOfNodes());
81 this->
Points->SetData(nodeCoords);
82 output->SetPoints(this->
Points.GetPointer());
83
84
85 auto elems =
_mesh->getElements();
86 output->Allocate(elems.size());
87 for (auto& cell : elems)
88 {
90
91 const MeshLib::Element* const elem = cell;
94 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New();
95 ptIds->SetNumberOfIds(numNodes);
96
97 for (unsigned i = 0; i < numNodes; ++i)
98 {
99 ptIds->SetId(i, nodes[i]->getID());
100 }
101
102 if (cellType == VTK_WEDGE)
103 {
104 for (unsigned i = 0; i < 3; ++i)
105 {
106 const auto prism_swap_id = ptIds->GetId(i);
107 ptIds->SetId(i, ptIds->GetId(i + 3));
108 ptIds->SetId(i + 3, prism_swap_id);
109 }
110 }
111
112 output->InsertNextCell(cellType, ptIds);
113 }
114
115
116 for (
auto [name, property] :
_mesh->getProperties())
117 {
118 if (!property->is_for_output)
119 {
120 continue;
121 }
122 if (auto const* p = dynamic_cast<PropertyVector<double>*>(property))
123 {
125 }
126 else if (auto const* p = dynamic_cast<PropertyVector<float>*>(property))
127 {
129 }
130 else if (auto const* p = dynamic_cast<PropertyVector<int>*>(property))
131 {
133 }
134 else if (auto const* p =
135 dynamic_cast<PropertyVector<unsigned>*>(property))
136 {
138 }
139 else if (auto const* p = dynamic_cast<PropertyVector<long>*>(property))
140 {
142 }
143 else if (auto const* p =
144 dynamic_cast<PropertyVector<long long>*>(property))
145 {
147 }
148 else if (auto const* p =
149 dynamic_cast<PropertyVector<unsigned long>*>(property))
150 {
152 }
153 else if (auto const* p =
154 dynamic_cast<PropertyVector<unsigned long long>*>(
155 property))
156 {
158 }
159 else if (auto const* p =
160 dynamic_cast<PropertyVector<std::size_t>*>(property))
161 {
163 }
164 else if (auto const* p = dynamic_cast<PropertyVector<char>*>(property))
165 {
167 }
168 else if (auto const* p =
169 dynamic_cast<PropertyVector<unsigned char>*>(property))
170 {
172 }
173 else if (auto const* p =
174 dynamic_cast<PropertyVector<uint8_t>*>(property))
175 {
177 }
178 else
179 {
181 "Mesh property '{:s}' of unhandled data type '{:s}'. Please "
182 "check the data type of the mesh properties. The available "
183 "data types are:"
184 "\n\t double,"
185 "\n\t float,"
186 "\n\t int,"
187 "\n\t unsigned,"
188 "\n\t long,"
189 "\n\t long long,"
190 "\n\t unsigned long long,"
191 "\n\t char,",
192 "\n\t unsigned char,",
193 "\n\t uint8_t.",
194 property->getPropertyName(),
196 }
197 }
198
199 output->GetPointData()->ShallowCopy(this->
PointData.GetPointer());
200 output->GetCellData()->ShallowCopy(this->
CellData.GetPointer());
201 output->GetFieldData()->ShallowCopy(this->
FieldData.GetPointer());
202 return 1;
203}
int OGSToVtkCellType(MeshLib::CellType ogs)
virtual unsigned getNumberOfNodes() const =0
void addProperty(MeshLib::PropertyVector< T > const &property) const
Adds a zero-copy vtk array wrapper.
vtkNew< vtkPoints > Points
std::string typeToString()