------------------------------------------------------------------------------
| 77 | |
| 78 | //------------------------------------------------------------------------------ |
| 79 | void vtkPlotSurface::SetInputData(vtkTable* input) |
| 80 | { |
| 81 | this->InputTable = input; |
| 82 | this->NumberOfRows = input->GetNumberOfRows(); |
| 83 | this->NumberOfColumns = input->GetNumberOfColumns(); |
| 84 | this->NumberOfVertices = (this->NumberOfRows - 1) * (this->NumberOfColumns - 1) * 6; |
| 85 | |
| 86 | // initialize data ranges to row and column indices if they are not |
| 87 | // already set. |
| 88 | if (this->XMinimum == 0 && this->XMaximum == 0) |
| 89 | { |
| 90 | this->XMaximum = this->NumberOfColumns - 1; |
| 91 | } |
| 92 | if (this->YMinimum == 0 && this->YMaximum == 0) |
| 93 | { |
| 94 | this->YMaximum = this->NumberOfRows - 1; |
| 95 | } |
| 96 | |
| 97 | this->Points->SetNumberOfPoints(this->NumberOfRows * this->NumberOfColumns); |
| 98 | float* data = vtkArrayDownCast<vtkFloatArray>(this->Points->GetData())->GetPointer(0); |
| 99 | int pos = 0; |
| 100 | float surfaceMin = VTK_FLOAT_MAX; |
| 101 | float surfaceMax = VTK_FLOAT_MIN; |
| 102 | for (int i = 0; i < this->NumberOfRows; ++i) |
| 103 | { |
| 104 | for (int j = 0; j < this->NumberOfColumns; ++j) |
| 105 | { |
| 106 | // X (columns) |
| 107 | data[pos] = this->ColumnToX(j); |
| 108 | ++pos; |
| 109 | |
| 110 | // Y (rows) |
| 111 | data[pos] = this->RowToY(i); |
| 112 | ++pos; |
| 113 | |
| 114 | // Z (cell value) |
| 115 | float k = input->GetValue(i, j).ToFloat(); |
| 116 | data[pos] = k; |
| 117 | ++pos; |
| 118 | |
| 119 | surfaceMin = std::min(k, surfaceMin); |
| 120 | surfaceMax = std::max(k, surfaceMax); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | if (this->Chart) |
| 125 | { |
| 126 | this->Chart->RecalculateBounds(); |
| 127 | } |
| 128 | this->ComputeDataBounds(); |
| 129 | |
| 130 | // setup lookup table |
| 131 | this->LookupTable->SetNumberOfTableValues(256); |
| 132 | this->LookupTable->SetRange(surfaceMin, surfaceMax); |
| 133 | this->LookupTable->Build(); |
| 134 | this->ColorComponents = 3; |
| 135 | |
| 136 | // generate the surface that is used for rendering |
nothing calls this directly
no test coverage detected