VTK  9.2.6
vtkUpdateCellsV8toV9.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkUpdateCellsV8toV9.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
20 #ifndef vtkUpdateCellsV8toV9_h
21 #define vtkUpdateCellsV8toV9_h
22 
23 #include "vtkCellArray.h"
24 #include "vtkCellData.h"
25 #include "vtkCellType.h"
26 #include "vtkCellTypes.h"
28 #include "vtkIdList.h"
29 #include "vtkIdTypeArray.h"
30 #include "vtkNew.h"
31 #include "vtkUnstructuredGrid.h"
32 
34 {
35  vtkNew<vtkIdList> oldpts, newpts;
36 
37  for (vtkIdType i = 0; i < output->GetNumberOfCells(); ++i)
38  {
41  type == VTK_BEZIER_HEXAHEDRON)
42  {
43  output->GetCells()->GetCellAtId(i, oldpts);
44  newpts->DeepCopy(oldpts);
45 
46  int degs[3];
47  if (output->GetCellData()->SetActiveAttribute(
48  "HigherOrderDegrees", vtkDataSetAttributes::AttributeTypes::HIGHERORDERDEGREES) != -1)
49  {
51  double degs_double[3];
52  v->GetTuple(i, degs_double);
53  for (int ii = 0; ii < 3; ii++)
54  degs[ii] = static_cast<int>(degs_double[ii]);
55  }
56  else
57  {
58  int order =
59  static_cast<int>(round(std::cbrt(static_cast<int>(oldpts->GetNumberOfIds())))) - 1;
60  degs[0] = degs[1] = degs[2] = order;
61  }
62  for (int j = 0; j < oldpts->GetNumberOfIds(); j++)
63  {
65  if (j != newid)
66  {
67  newpts->SetId(j, oldpts->GetId(newid));
68  }
69  }
70  output->GetCells()->ReplaceCellAtId(i, newpts);
71  }
72  }
73 }
74 
75 inline bool vtkNeedsNewFileVersionV8toV9(vtkUnsignedCharArray* distinctCellTypes)
76 {
77  vtkIdType nCellTypes = distinctCellTypes->GetNumberOfValues();
78  for (vtkIdType i = 0; i < nCellTypes; ++i)
79  {
80  unsigned char type = distinctCellTypes->GetValue(i);
82  type == VTK_BEZIER_HEXAHEDRON)
83  {
84  return true;
85  }
86  }
87  return false;
88 }
89 
90 #endif // vtkUpdateCellsV8toV9_h
91 // VTK-HeaderTest-Exclude: vtkUpdateCellsV8toV9.h
void SetId(const vtkIdType i, const vtkIdType vtkid)
Set the id at location i.
Definition: vtkIdList.h:92
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:288
ValueType GetValue(vtkIdType valueIdx) const
Get the value at valueIdx.
int vtkIdType
Definition: vtkType.h:332
bool vtkNeedsNewFileVersionV8toV9(vtkUnsignedCharArray *distinctCellTypes)
vtkIdType GetNumberOfValues() const
Get the total number of values in the array.
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkIdType GetNumberOfIds() const noexcept
Return the number of id's in the list.
Definition: vtkIdList.h:60
vtkIdType GetNumberOfCells() override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
dynamic, self-adjusting array of unsigned char
ValueType GetTypedComponent(vtkIdType tupleIdx, int comp) const
Get component comp of the tuple at tupleIdx.
vtkUnsignedCharArray * GetCellTypesArray()
Get the array of all cell types in the grid.
vtkIdType GetId(const vtkIdType i)
Return the id at location i.
Definition: vtkIdList.h:65
void ReplaceCellAtId(vtkIdType cellId, vtkIdList *list)
Replaces the point ids for the specified cell with the supplied list.
void vtkUpdateCellsV8toV9(vtkUnstructuredGrid *output)
vtkDataArray * GetHigherOrderDegrees()
Set/Get the rational degrees data.
vtkCellArray * GetCells()
Return the unstructured grid connectivity array.
void GetCellAtId(vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints)
Return the point ids for the cell at cellId.
int SetActiveAttribute(const char *name, int attributeType)
Make the array with the given name the active attribute.
static vtkIdType NodeNumberingMappingFromVTK8To9(const int order[3], const vtkIdType node_id_vtk8)
void DeepCopy(vtkIdList *ids)
Copy an id list by explicitly copying the internal array.