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=========================================================================*/
19
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 {
39 vtkIdType type = output->GetCellTypesArray()->GetTypedComponent(i, 0);
42 {
43 output->GetCells()->GetCellAtId(i, oldpts);
44 newpts->DeepCopy(oldpts);
45
46 int degs[3];
47 if (output->GetCellData()->SetActiveAttribute(
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
76{
77 vtkIdType nCellTypes = distinctCellTypes->GetNumberOfValues();
78 for (vtkIdType i = 0; i < nCellTypes; ++i)
79 {
80 unsigned char type = distinctCellTypes->GetValue(i);
83 {
84 return true;
85 }
86 }
87 return false;
88}
89
90#endif // vtkUpdateCellsV8toV9_h
91// VTK-HeaderTest-Exclude: vtkUpdateCellsV8toV9.h
ValueType GetTypedComponent(vtkIdType tupleIdx, int comp) const
Get component comp of the tuple at tupleIdx.
ValueType GetValue(vtkIdType valueIdx) const
Get the value at valueIdx.
vtkIdType GetNumberOfValues() const
Get the total number of values in the array.
void GetCellAtId(vtkIdType cellId, vtkIdType &cellSize, vtkIdType const *&cellPoints)
Return the point ids for the cell at cellId.
void ReplaceCellAtId(vtkIdType cellId, vtkIdList *list)
Replaces the point ids for the specified cell with the supplied list.
virtual double * GetTuple(vtkIdType tupleIdx)=0
Get the data tuple at tupleIdx.
int SetActiveAttribute(const char *name, int attributeType)
Make the array with the given name the active attribute.
vtkDataArray * GetHigherOrderDegrees()
Set/Get the rational degrees data.
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition vtkDataSet.h:282
static vtkIdType NodeNumberingMappingFromVTK8To9(const int order[3], const vtkIdType node_id_vtk8)
Allocate and hold a VTK object.
Definition vtkNew.h:56
dynamic, self-adjusting array of unsigned char
dataset represents arbitrary combinations of all possible cell types
vtkCellArray * GetCells()
Return the unstructured grid connectivity array.
vtkIdType GetNumberOfCells() override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
vtkUnsignedCharArray * GetCellTypesArray()
Get the array of all cell types in the grid.
@ VTK_BEZIER_HEXAHEDRON
@ VTK_LAGRANGE_HEXAHEDRON
@ VTK_HIGHER_ORDER_HEXAHEDRON
#define vtkDataArray
int vtkIdType
Definition vtkType.h:332
void vtkUpdateCellsV8toV9(vtkUnstructuredGrid *output)
bool vtkNeedsNewFileVersionV8toV9(vtkUnsignedCharArray *distinctCellTypes)