------------------------------------------------------------------------------
| 187 | |
| 188 | //------------------------------------------------------------------------------ |
| 189 | void vtkDiscretizableColorTransferFunction::Build() |
| 190 | { |
| 191 | this->Superclass::Build(); |
| 192 | |
| 193 | if (this->LookupTableUpdateTime > this->GetMTime()) |
| 194 | { |
| 195 | // no need to rebuild anything. |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | this->LookupTable->SetVectorMode(this->VectorMode); |
| 200 | this->LookupTable->SetVectorComponent(this->VectorComponent); |
| 201 | this->LookupTable->SetIndexedLookup(this->IndexedLookup); |
| 202 | this->LookupTable->SetUseBelowRangeColor(this->UseBelowRangeColor); |
| 203 | this->LookupTable->SetUseAboveRangeColor(this->UseAboveRangeColor); |
| 204 | |
| 205 | double rgba[4]; |
| 206 | this->GetBelowRangeColor(rgba); |
| 207 | rgba[3] = 1.0; |
| 208 | this->LookupTable->SetBelowRangeColor(rgba); |
| 209 | |
| 210 | this->GetAboveRangeColor(rgba); |
| 211 | rgba[3] = 1.0; |
| 212 | this->LookupTable->SetAboveRangeColor(rgba); |
| 213 | |
| 214 | // this is essential since other the LookupTable doesn't update the |
| 215 | // annotations map. That's a bug in the implementation of |
| 216 | // vtkScalarsToColors::SetAnnotations(..,..); |
| 217 | this->LookupTable->SetAnnotations(nullptr, nullptr); |
| 218 | this->LookupTable->SetAnnotations(this->AnnotatedValues, this->Annotations); |
| 219 | |
| 220 | if (this->IndexedLookup) |
| 221 | { |
| 222 | if (this->GetNumberOfIndexedColors() > 0) |
| 223 | { |
| 224 | // Use the specified indexed-colors. |
| 225 | vtkIdType count = this->GetNumberOfAnnotatedValues(); |
| 226 | this->LookupTable->SetNumberOfTableValues(count); |
| 227 | for (size_t cc = 0; |
| 228 | cc < this->Internals->IndexedColors.size() && cc < static_cast<size_t>(count); cc++) |
| 229 | { |
| 230 | rgba[0] = this->Internals->IndexedColors[cc].GetData()[0]; |
| 231 | rgba[1] = this->Internals->IndexedColors[cc].GetData()[1]; |
| 232 | rgba[2] = this->Internals->IndexedColors[cc].GetData()[2]; |
| 233 | rgba[3] = this->Internals->IndexedColors[cc].GetData()[3]; |
| 234 | this->LookupTable->SetTableValue(static_cast<int>(cc), rgba); |
| 235 | } |
| 236 | } |
| 237 | else |
| 238 | { |
| 239 | // old logic for backwards compatibility. |
| 240 | int nv = this->GetSize(); |
| 241 | this->LookupTable->SetNumberOfTableValues(nv); |
| 242 | double nodeVal[6]; |
| 243 | for (int i = 0; i < nv; ++i) |
| 244 | { |
| 245 | this->GetNodeValue(i, nodeVal); |
| 246 | nodeVal[4] = 1.; |