@@ -4,7 +4,6 @@ import * as vtkMath from 'vtk.js/Sources/Common/Core/Math';
4
4
5
5
const { vtkErrorMacro } = macro ;
6
6
const { DefaultDataType } = Constants ;
7
- const TUPLE_HOLDER = [ ] ;
8
7
9
8
// ----------------------------------------------------------------------------
10
9
// Global methods
@@ -103,8 +102,10 @@ function getDataType(typedArray) {
103
102
function getMaxNorm ( normArray ) {
104
103
const numComps = normArray . getNumberOfComponents ( ) ;
105
104
let maxNorm = 0.0 ;
105
+ const tuple = new Array ( numComps ) ;
106
106
for ( let i = 0 ; i < normArray . getNumberOfTuples ( ) ; ++ i ) {
107
- const norm = vtkMath . norm ( normArray . getTuple ( i ) , numComps ) ;
107
+ normArray . getTuple ( i , tuple ) ;
108
+ const norm = vtkMath . norm ( tuple , numComps ) ;
108
109
if ( norm > maxNorm ) {
109
110
maxNorm = norm ;
110
111
}
@@ -299,11 +300,8 @@ function vtkDataArray(publicAPI, model) {
299
300
return publicAPI . insertTuples ( idx , tuples ) ;
300
301
} ;
301
302
302
- publicAPI . getTuple = ( idx , tupleToFill = TUPLE_HOLDER ) => {
303
+ publicAPI . getTuple = ( idx , tupleToFill = [ ] ) => {
303
304
const numberOfComponents = model . numberOfComponents || 1 ;
304
- if ( tupleToFill . length !== numberOfComponents ) {
305
- tupleToFill . length = numberOfComponents ;
306
- }
307
305
const offset = idx * numberOfComponents ;
308
306
// Check most common component sizes first
309
307
// to avoid doing a for loop if possible
@@ -321,7 +319,7 @@ function vtkDataArray(publicAPI, model) {
321
319
tupleToFill [ 0 ] = model . values [ offset ] ;
322
320
break ;
323
321
default :
324
- for ( let i = 0 ; i < numberOfComponents ; i ++ ) {
322
+ for ( let i = numberOfComponents - 1 ; i >= 0 ; -- i ) {
325
323
tupleToFill [ i ] = model . values [ offset + i ] ;
326
324
}
327
325
}
@@ -427,14 +425,11 @@ function vtkDataArray(publicAPI, model) {
427
425
vtkErrorMacro ( 'numberOfComponents must match' ) ;
428
426
}
429
427
430
- const tuple1 = [ ] ;
431
- const tuple2 = [ ] ;
428
+ const tuple1 = source1 . getTuple ( source1Idx ) ;
429
+ const tuple2 = source2 . getTuple ( source2Idx ) ;
432
430
const out = [ ] ;
433
431
out . length = numberOfComponents ;
434
432
435
- source1 . getTuple ( source1Idx , tuple1 ) ;
436
- source2 . getTuple ( source2Idx , tuple2 ) ;
437
-
438
433
// Check most common component sizes first
439
434
// to avoid doing a for loop if possible
440
435
switch ( numberOfComponents ) {
0 commit comments