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

Function UpdateVTKAttributes

Examples/Catalyst/CFullExample2/FEAdaptor.cxx:46–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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