@kitware/vtk.js 25.9.2 → 25.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import vtkDataArray from './../../Common/Core/DataArray';
|
|
1
2
|
import { vtkObject } from './../../interfaces';
|
|
2
3
|
import { ColorSpace, Scale } from './ColorTransferFunction/Constants';
|
|
3
4
|
|
|
@@ -201,6 +202,25 @@ export interface vtkColorTransferFunction extends vtkObject {
|
|
|
201
202
|
withAlpha: boolean
|
|
202
203
|
): Float32Array;
|
|
203
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Construct a color transfer function from a vtkDataArray.
|
|
207
|
+
* The order of values depends on the number of components
|
|
208
|
+
* of the array.
|
|
209
|
+
* 3 -> RGB
|
|
210
|
+
* 4 -> XRGB
|
|
211
|
+
* 5 -> RGBMS
|
|
212
|
+
* 6 -> XRGBMS
|
|
213
|
+
*
|
|
214
|
+
* X represents the input value to a function
|
|
215
|
+
* RGB represents the red, green, and blue value output
|
|
216
|
+
* M represents the midpoint
|
|
217
|
+
* S represents sharpness
|
|
218
|
+
* @param {vtkDataArray} array
|
|
219
|
+
*/
|
|
220
|
+
buildFunctionFromArray(
|
|
221
|
+
array: vtkDataArray,
|
|
222
|
+
): void;
|
|
223
|
+
|
|
204
224
|
/**
|
|
205
225
|
* Construct a color transfer function from a table.
|
|
206
226
|
* @param {Number} xStart The index of the first point.
|
|
@@ -849,6 +849,69 @@ function vtkColorTransferFunction(publicAPI, model) {
|
|
|
849
849
|
|
|
850
850
|
model.buildTime.modified();
|
|
851
851
|
return model.table;
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
publicAPI.buildFunctionFromArray = function (array) {
|
|
855
|
+
publicAPI.removeAllPoints();
|
|
856
|
+
var numComponents = array.getNumberOfComponents();
|
|
857
|
+
|
|
858
|
+
for (var i = 0; i < array.getNumberOfTuples(); i++) {
|
|
859
|
+
switch (numComponents) {
|
|
860
|
+
case 3:
|
|
861
|
+
{
|
|
862
|
+
model.nodes.push({
|
|
863
|
+
x: i,
|
|
864
|
+
r: array.getComponent(i, 0),
|
|
865
|
+
g: array.getComponent(i, 1),
|
|
866
|
+
b: array.getComponent(i, 2),
|
|
867
|
+
midpoint: 0.5,
|
|
868
|
+
sharpness: 0.0
|
|
869
|
+
});
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
case 4:
|
|
874
|
+
{
|
|
875
|
+
model.nodes.push({
|
|
876
|
+
x: array.getComponent(i, 0),
|
|
877
|
+
r: array.getComponent(i, 1),
|
|
878
|
+
g: array.getComponent(i, 2),
|
|
879
|
+
b: array.getComponent(i, 3),
|
|
880
|
+
midpoint: 0.5,
|
|
881
|
+
sharpness: 0.0
|
|
882
|
+
});
|
|
883
|
+
break;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
case 5:
|
|
887
|
+
{
|
|
888
|
+
model.nodes.push({
|
|
889
|
+
x: i,
|
|
890
|
+
r: array.getComponent(i, 0),
|
|
891
|
+
g: array.getComponent(i, 1),
|
|
892
|
+
b: array.getComponent(i, 2),
|
|
893
|
+
midpoint: array.getComponent(i, 4),
|
|
894
|
+
sharpness: array.getComponent(i, 5)
|
|
895
|
+
});
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
case 6:
|
|
900
|
+
{
|
|
901
|
+
model.nodes.push({
|
|
902
|
+
x: array.getComponent(i, 0),
|
|
903
|
+
r: array.getComponent(i, 1),
|
|
904
|
+
g: array.getComponent(i, 2),
|
|
905
|
+
b: array.getComponent(i, 3),
|
|
906
|
+
midpoint: array.getComponent(i, 4),
|
|
907
|
+
sharpness: array.getComponent(i, 5)
|
|
908
|
+
});
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
publicAPI.sortAndUpdateRange();
|
|
852
915
|
}; //----------------------------------------------------------------------------
|
|
853
916
|
|
|
854
917
|
|