@@ -3,6 +3,10 @@ import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray';
3
3
import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants' ;
4
4
import * as vtkMath from 'vtk.js/Sources/Common/Core/Math' ;
5
5
6
+ function compareFloat ( a , b ) {
7
+ return Math . abs ( a - b ) < Number . EPSILON ;
8
+ }
9
+
6
10
test ( 'Test vtkDataArray instance' , ( t ) => {
7
11
t . ok ( vtkDataArray , 'Make sure the class definition exists' ) ;
8
12
const instance = vtkDataArray . newInstance ( { size : 256 } ) ;
@@ -219,7 +223,6 @@ test('Test vtkDataArray getRange function with multi-channel data.', (t) => {
219
223
newArray [ i * 3 + 2 ] = i ;
220
224
}
221
225
222
- const compareFloat = ( a , b ) => Math . abs ( a - b ) < Number . EPSILON ;
223
226
const vecRange = da . getRange ( - 1 ) ;
224
227
t . ok (
225
228
compareFloat ( vecRange [ 0 ] . toFixed ( 2 ) , 0.0 ) ,
@@ -252,15 +255,23 @@ test('Test vtkDataArray getRanges function with multi-channel data.', (t) => {
252
255
const ranges = da . getRanges ( ) ;
253
256
254
257
t . ok (
255
- ranges . length === 3 ,
256
- 'getRanges should return an array of 3 vtkRange objects'
258
+ ranges . length === 4 ,
259
+ 'getRanges should return an array of 4 vtkRange objects'
257
260
) ;
258
261
t . ok ( ranges [ 0 ] . min === 0 , 'component:0 minimum value should be 0' ) ;
259
262
t . ok ( ranges [ 0 ] . max === 255 , 'component:0 maximum value should be 255' ) ;
260
263
t . ok ( ranges [ 1 ] . min === 0 , 'component:1 minimum value should be 0' ) ;
261
264
t . ok ( ranges [ 1 ] . max === 510 , 'component:1 maximum value should be 510' ) ;
262
265
t . ok ( ranges [ 2 ] . min === 0 , 'component:2 minimum value should be 0' ) ;
263
266
t . ok ( ranges [ 2 ] . max === 765 , 'component:2 maximum value should be 765' ) ;
267
+ t . ok (
268
+ ranges [ 2 ] . min === 0 ,
269
+ 'component:-1 vector magnitude minimum should be 0'
270
+ ) ;
271
+ t . ok (
272
+ compareFloat ( ranges [ 3 ] . max , 954.1226336273551 ) ,
273
+ 'component:-1 vector magnitude maximum should be 954.1226336273551'
274
+ ) ;
264
275
265
276
t . end ( ) ;
266
277
} ) ;
0 commit comments