1
- import macro from 'vtk.js/Sources/macros' ;
1
+ import macro , { TYPED_ARRAYS } from 'vtk.js/Sources/macros' ;
2
2
import vtkCell from 'vtk.js/Sources/Common/DataModel/Cell' ;
3
3
import * as vtkMath from 'vtk.js/Sources/Common/Core/Math' ;
4
4
import vtkLine from 'vtk.js/Sources/Common/DataModel/Line' ;
@@ -614,24 +614,18 @@ function vtkTriangle(publicAPI, model) {
614
614
* @param {Number[] } derivs - The derivatives.
615
615
*/
616
616
publicAPI . derivatives = ( subId , pcoords , values , dim , derivs ) => {
617
- const x0 = [ ] ;
618
- const x1 = [ ] ;
619
- const x2 = [ ] ;
620
- model . points . getPoint ( 0 , x0 ) ;
621
- model . points . getPoint ( 1 , x1 ) ;
622
- model . points . getPoint ( 2 , x2 ) ;
617
+ const x0 = model . points . getPoint ( 0 ) ;
618
+ const x1 = model . points . getPoint ( 1 ) ;
619
+ const x2 = model . points . getPoint ( 2 ) ;
623
620
624
621
const n = [ ] ;
625
622
const v10 = [ ] ;
626
623
const v20 = [ ] ;
627
624
const v = [ ] ;
628
625
computeNormal ( x0 , x1 , x2 , n ) ;
629
626
630
- for ( let i = 0 ; i < 3 ; i ++ ) {
631
- v10 [ i ] = x1 [ i ] - x0 [ i ] ;
632
- v [ i ] = x2 [ i ] - x0 [ i ] ;
633
- }
634
-
627
+ vtkMath . subtract ( x1 , x0 , v10 ) ;
628
+ vtkMath . subtract ( x2 , x0 , v ) ;
635
629
vtkMath . cross ( n , v10 , v20 ) ;
636
630
637
631
const lenX = vtkMath . normalize ( v10 ) ; // check for degenerate triangle
@@ -658,7 +652,7 @@ function vtkTriangle(publicAPI, model) {
658
652
const J = [ v1 [ 0 ] - v0 [ 0 ] , v1 [ 1 ] - v0 [ 1 ] , v2 [ 0 ] - v0 [ 0 ] , v2 [ 1 ] - v0 [ 1 ] ] ;
659
653
660
654
// Compute inverse Jacobian (expects flat array)
661
- const JI = new Array ( 4 ) . fill ( 0.0 ) ;
655
+ const JI = macro . newTypedArray ( TYPED_ARRAYS . Float64Array , 4 ) ;
662
656
vtkMath . invertMatrix ( J , JI , 2 ) ; // returns flat array [JI00, JI01, JI10, JI11]
663
657
664
658
// Compute derivatives
0 commit comments