VTK  9.7.1
vtkUpdateCellsV8toV9.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
8 #ifndef vtkUpdateCellsV8toV9_h
9 #define vtkUpdateCellsV8toV9_h
10 
11 #include "vtkCellArray.h"
12 #include "vtkCellData.h"
13 #include "vtkCellType.h"
15 #include "vtkIdList.h"
16 #include "vtkNew.h"
17 #include "vtkUnstructuredGrid.h"
18 
19 VTK_ABI_NAMESPACE_BEGIN
21 {
22  vtkNew<vtkIdList> oldpts, newpts;
23 
24  for (vtkIdType i = 0; i < output->GetNumberOfCells(); ++i)
25  {
26  int type = output->GetCellType(i);
28  type == VTK_BEZIER_HEXAHEDRON)
29  {
30  output->GetCells()->GetCellAtId(i, oldpts);
31  newpts->DeepCopy(oldpts);
32 
33  int degs[3];
34  if (output->GetCellData()->SetActiveAttribute(
35  "HigherOrderDegrees", vtkDataSetAttributes::AttributeTypes::HIGHERORDERDEGREES) != -1)
36  {
38  double degs_double[3];
39  v->GetTuple(i, degs_double);
40  for (int ii = 0; ii < 3; ii++)
41  degs[ii] = static_cast<int>(degs_double[ii]);
42  }
43  else
44  {
45  int order =
46  static_cast<int>(round(std::cbrt(static_cast<int>(oldpts->GetNumberOfIds())))) - 1;
47  degs[0] = degs[1] = degs[2] = order;
48  }
49  for (int j = 0; j < oldpts->GetNumberOfIds(); j++)
50  {
52  if (j != newid)
53  {
54  newpts->SetId(j, oldpts->GetId(newid));
55  }
56  }
57  output->GetCells()->ReplaceCellAtId(i, newpts);
58  }
59  }
60 }
61 
62 inline bool vtkNeedsNewFileVersionV8toV9(vtkUnsignedCharArray* distinctCellTypes)
63 {
64  vtkIdType nCellTypes = distinctCellTypes->GetNumberOfValues();
65  for (vtkIdType i = 0; i < nCellTypes; ++i)
66  {
67  unsigned char type = distinctCellTypes->GetValue(i);
69  type == VTK_BEZIER_HEXAHEDRON)
70  {
71  return true;
72  }
73  }
74  return false;
75 }
76 
77 VTK_ABI_NAMESPACE_END
78 #endif // vtkUpdateCellsV8toV9_h
79 // VTK-HeaderTest-Exclude: vtkUpdateCellsV8toV9.h
void GetCellAtId(vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints, vtkIdList *ptIds) override
Return the point ids for the cell at cellId.
virtual double * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition: vtkDataSet.h:304
ValueType GetValue(vtkIdType valueIdx) const
Get the value at valueIdx.
int vtkIdType
Definition: vtkType.h:363
bool vtkNeedsNewFileVersionV8toV9(vtkUnsignedCharArray *distinctCellTypes)
vtkIdType GetNumberOfValues() const
Get the total number of values in the array.
vtkIdType GetId(vtkIdType i)
Return the id at location i.
Definition: vtkIdList.h:81
void SetId(vtkIdType i, vtkIdType id)
Set the id at location i.
Definition: vtkIdList.h:113
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition: vtkIdList.h:76
vtkIdType GetNumberOfCells() override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
dynamic, self-adjusting array of unsigned char
void ReplaceCellAtId(vtkIdType cellId, vtkIdList *list)
Replaces the point ids for the specified cell with the supplied list.
int GetCellType(vtkIdType cellId) override
Get the type of the cell with the given cellId.
void vtkUpdateCellsV8toV9(vtkUnstructuredGrid *output)
vtkDataArray * GetHigherOrderDegrees()
Set/Get the rational degrees data.
vtkCellArray * GetCells()
Return the unstructured grid connectivity array.
int SetActiveAttribute(const char *name, int attributeType)
Make the array with the given name the active attribute.
static vtkIdType NodeNumberingMappingFromVTK8To9(const int order[3], vtkIdType node_id_vtk8)
void DeepCopy(vtkIdList *ids)
Copy an id list by explicitly copying the internal array.