VTK  9.1.0
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 {
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 int nCellTypes = cellTypes->GetNumberOfTypes();
78 for (vtkIdType i = 0; i < nCellTypes; ++i)
79 {
80 unsigned char type = cellTypes->GetCellType(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.
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.
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:137
vtkIdType GetNumberOfTypes()
Return the number of types in the list.
Definition: vtkCellTypes.h:183
unsigned char GetCellType(vtkIdType cellId)
Return the type of cell.
Definition: vtkCellTypes.h:198
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
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:366
static vtkIdType NodeNumberingMappingFromVTK8To9(const int order[3], const vtkIdType node_id_vtk8)
Allocate and hold a VTK object.
Definition: vtkNew.h:165
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.
Update cells from v8 node layout to v9 node layout.
@ VTK_BEZIER_HEXAHEDRON
Definition: vtkCellType.h:162
@ VTK_LAGRANGE_HEXAHEDRON
Definition: vtkCellType.h:153
@ VTK_HIGHER_ORDER_HEXAHEDRON
Definition: vtkCellType.h:146
int vtkIdType
Definition: vtkType.h:332
bool vtkNeedsNewFileVersionV8toV9(vtkCellTypes *cellTypes)