@@ -58,6 +58,8 @@ public: // io
58
58
59
59
virtual vtkSmartPointer<vtkUnstructuredGrid> to_vtu () const = 0;
60
60
virtual void from_vtu (vtkSmartPointer<vtkUnstructuredGrid> grid) = 0;
61
+
62
+ static int check_simplicial_mesh_dims (vtkSmartPointer<vtkUnstructuredGrid> grid); // 0: nonsimplicial, 2 or 3: 2D or 3D
61
63
#endif
62
64
};
63
65
@@ -177,6 +179,37 @@ vtkSmartPointer<vtkUnstructuredGrid> simplicial_unstructured_mesh<I, F>::vector_
177
179
178
180
return grid;
179
181
}
182
+
183
+ template <typename I, typename F>
184
+ int simplicial_unstructured_mesh<I, F>::check_simplicial_mesh_dims(vtkSmartPointer<vtkUnstructuredGrid> grid)
185
+ {
186
+ int nd = 0 ;
187
+ #if (VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 2, 0))
188
+ vtkSmartPointer<vtkUnsignedCharArray> types = grid->GetDistinctCellTypesArray ();
189
+ const int ntypes = types->GetNumberOfValues ();
190
+
191
+ if (ntypes == 1 ) {
192
+ unsigned char type = types->GetValue (0 );
193
+ if (type == VTK_TRIANGLE) nd = 2 ;
194
+ else if (type == VTK_TETRA) nd = 3 ;
195
+ else nd = 0 ; // nonsimplicial
196
+ } else
197
+ nd = 0 ; // nonsimplicial
198
+ #else
199
+ vtkSmartPointer<vtkCellTypes> types = vtkSmartPointer<vtkCellTypes>::New ();
200
+ grid->GetCellTypes (types);
201
+ const int ntypes = types->GetNumberOfTypes ();
202
+
203
+ if (ntypes == 1 ) {
204
+ unsigned char type = types->GetCellType (0 );
205
+ if (type == VTK_TRIANGLE) nd = 2 ;
206
+ else if (type == VTK_TETRA) nd = 3 ;
207
+ else nd = 0 ; // nonsimplicial
208
+ } else
209
+ nd = 0 ; // nonsimplicial
210
+ #endif
211
+ return nd;
212
+ }
180
213
#endif
181
214
182
215
} // namespace ftk
0 commit comments