MCPcopy Create free account
hub / github.com/Kitware/VTK / RequestData

Method RequestData

Infovis/Layout/vtkTreeMapToPolyData.cxx:36–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36int vtkTreeMapToPolyData::RequestData(vtkInformation* vtkNotUsed(request),
37 vtkInformationVector** inputVector, vtkInformationVector* outputVector)
38{
39 // get the info objects
40 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
41 vtkInformation* outInfo = outputVector->GetInformationObject(0);
42
43 // get the input and output
44 vtkTree* inputTree = vtkTree::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
45 vtkPolyData* outputPoly = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
46
47 // For each input vertex create 4 points and 1 cell (quad)
48 vtkPoints* outputPoints = vtkPoints::New();
49 outputPoints->SetNumberOfPoints(inputTree->GetNumberOfVertices() * 4);
50 vtkCellArray* outputCells = vtkCellArray::New();
51
52 // Create an array for the point normals
53 vtkFloatArray* normals = vtkFloatArray::New();
54 normals->SetNumberOfComponents(3);
55 normals->SetNumberOfTuples(inputTree->GetNumberOfVertices() * 4);
56 normals->SetName("normals");
57
58 vtkDataArray* coordArray = this->GetInputArrayToProcess(0, inputTree);
59 if (!coordArray)
60 {
61 vtkErrorMacro("Area array not found.");
62 return 0;
63 }
64 vtkDataArray* levelArray = this->GetInputArrayToProcess(1, inputTree);
65
66 // Now set the point coordinates, normals, and insert the cell
67 for (int i = 0; i < inputTree->GetNumberOfVertices(); i++)
68 {
69 // Grab coords from the input
70 double coords[4];
71 coordArray->GetTuple(i, coords);
72
73 double z = 0;
74 if (levelArray)
75 {
76 z = this->LevelDeltaZ * levelArray->GetTuple1(i);
77 }
78 else
79 {
80 z = this->LevelDeltaZ * inputTree->GetLevel(i);
81 }
82
83 int index = i * 4;
84 outputPoints->SetPoint(index, coords[0], coords[2], z);
85 outputPoints->SetPoint(index + 1, coords[1], coords[2], z);
86 outputPoints->SetPoint(index + 2, coords[1], coords[3], z);
87 outputPoints->SetPoint(index + 3, coords[0], coords[3], z);
88
89 // Create an asymmetric gradient on the cells
90 // this gradient helps differentiate same colored
91 // cells from their neighbors. The asymmetric
92 // nature of the gradient is required.
93 normals->SetComponent(index, 0, 0);

Callers

nothing calls this directly

Calls 15

GetInformationObjectMethod · 0.80
GetNumberOfVerticesMethod · 0.80
GetTuple1Method · 0.80
GetVertexDataMethod · 0.80
SetPolysMethod · 0.80
SetActiveNormalsMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetMethod · 0.45
SetNumberOfPointsMethod · 0.45
SetNumberOfComponentsMethod · 0.45

Tested by

no test coverage detected