MCPcopy Create free account
hub / github.com/Kitware/ParaView / UpdateVTKAttributes

Function UpdateVTKAttributes

Examples/Catalyst/CFullExample/FEAdaptor.cxx:47–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void UpdateVTKAttributes(vtkCPInputDataDescription* idd, unsigned int numberOfPoints,
48 double* velocityData, unsigned int numberOfCells, float* pressureData)
49{
50 if (idd->IsFieldNeeded("velocity", vtkDataObject::POINT) == true)
51 {
52 if (VTKGrid->GetPointData()->GetNumberOfArrays() == 0)
53 {
54 // velocity array
55 vtkNew<vtkDoubleArray> velocity;
56 velocity->SetName("velocity");
57 velocity->SetNumberOfComponents(3);
58 velocity->SetNumberOfTuples(static_cast<vtkIdType>(numberOfPoints));
59 VTKGrid->GetPointData()->AddArray(velocity);
60 }
61 vtkDoubleArray* velocity =
62 vtkDoubleArray::SafeDownCast(VTKGrid->GetPointData()->GetArray("velocity"));
63 // The velocity array is ordered as vx0,vx1,vx2,..,vy0,vy1,vy2,..,vz0,vz1,vz2,..
64 // so we need to create a full copy of it with VTK's ordering of
65 // vx0,vy0,vz0,vx1,vy1,vz1,..
66 for (unsigned int i = 0; i < numberOfPoints; i++)
67 {
68 double values[3] = { velocityData[i], velocityData[i + numberOfPoints],
69 velocityData[i + 2 * numberOfPoints] };
70 velocity->SetTypedTuple(i, values);
71 }
72 }
73 if (idd->IsFieldNeeded("pressure", vtkDataObject::CELL) == true)
74 {
75 if (VTKGrid->GetCellData()->GetNumberOfArrays() == 0)
76 {
77 // pressure array
78 vtkNew<vtkFloatArray> pressure;
79 pressure->SetName("pressure");
80 pressure->SetNumberOfComponents(1);
81 VTKGrid->GetCellData()->AddArray(pressure);
82 }
83 vtkFloatArray* pressure =
84 vtkFloatArray::SafeDownCast(VTKGrid->GetCellData()->GetArray("pressure"));
85 // The pressure array is a scalar array so we can reuse
86 // memory as long as we ordered the points properly.
87 pressure->SetArray(pressureData, static_cast<vtkIdType>(numberOfCells), 1);
88 }
89}
90
91void BuildVTKDataStructures(vtkCPInputDataDescription* idd, unsigned int numberOfPoints,
92 double* points, double* velocity, unsigned int numberOfCells, unsigned int* cells,

Callers 1

BuildVTKDataStructuresFunction · 0.70

Calls 6

IsFieldNeededMethod · 0.80
AddArrayMethod · 0.80
GetNumberOfArraysMethod · 0.45
SetNameMethod · 0.45
SetNumberOfComponentsMethod · 0.45
GetArrayMethod · 0.45

Tested by

no test coverage detected