11import test from 'tape-catch' ;
22import vtkQuad from 'vtk.js/Sources/Common/DataModel/Quad' ;
33import vtkPoints from 'vtk.js/Sources/Common/Core/Points' ;
4+ import { QuadWithLineIntersectionState } from 'vtk.js/Sources/Common/DataModel/Quad/Constants' ;
45
56test ( 'Test vtkQuad instance' , ( t ) => {
67 t . ok ( vtkQuad , 'Make sure the class definition exists' ) ;
@@ -10,9 +11,6 @@ test('Test vtkQuad instance', (t) => {
1011} ) ;
1112
1213test ( 'Test vtkQuad intersectWithLine flat' , ( t ) => {
13- const yesIntersection = 1 ;
14- const noIntersection = 0 ;
15-
1614 const points = vtkPoints . newInstance ( ) ;
1715 points . setNumberOfPoints ( 4 ) ;
1816 points . setData ( Float32Array . from ( [ 0 , 0 , 0 , 1 , 0 , 0 , 1 , 1 , 0 , 0 , 1 , 0 ] ) ) ;
@@ -28,13 +26,19 @@ test('Test vtkQuad intersectWithLine flat', (t) => {
2826 const pcoords = [ ] ;
2927 let intersection ;
3028 intersection = quad . intersectWithLine ( p1 , p2 , tol , x , pcoords ) ;
31- t . equal ( intersection . intersect , noIntersection ) ;
29+ t . equal (
30+ intersection . intersect ,
31+ QuadWithLineIntersectionState . NO_INTERSECTION
32+ ) ;
3233
3334 // Intersect on v1
3435 p1 = [ 0 , 0 , 0 ] ;
3536 p2 = [ 0 , 0 , 1 ] ;
3637 intersection = quad . intersectWithLine ( p1 , p2 , tol , x , pcoords ) ;
37- t . equal ( intersection . intersect , yesIntersection ) ;
38+ t . equal (
39+ intersection . intersect ,
40+ QuadWithLineIntersectionState . YES_INTERSECTION
41+ ) ;
3842 t . equal ( intersection . t , 0 ) ;
3943 t . deepEqual ( x , p1 ) ;
4044 t . deepEqual ( pcoords , [ 0 , 0 , 0 ] ) ;
@@ -43,29 +47,39 @@ test('Test vtkQuad intersectWithLine flat', (t) => {
4347 p1 = [ 1 , 1 , 1 ] ;
4448 p2 = [ 1 , 1 , 0 ] ;
4549 intersection = quad . intersectWithLine ( p1 , p2 , tol , x , pcoords ) ;
46- t . equal ( intersection . intersect , yesIntersection ) ;
50+ t . equal (
51+ intersection . intersect ,
52+ QuadWithLineIntersectionState . YES_INTERSECTION
53+ ) ;
4754 t . equal ( intersection . t , 1 ) ;
4855 t . deepEqual ( x , p2 ) ;
49- t . deepEqual ( pcoords , [ 0 , 1 , 0 ] ) ;
56+ t . deepEqual ( pcoords , [ 1 , 1 , 0 ] ) ;
5057
5158 // No intersection if finite line
5259 p1 = [ - 2 , 0 , 0 ] ;
5360 p2 = [ - 1 , 0 , 0 ] ;
5461 intersection = quad . intersectWithLine ( p1 , p2 , tol , x , pcoords ) ;
55- t . equal ( intersection . intersect , noIntersection ) ;
62+ t . equal (
63+ intersection . intersect ,
64+ QuadWithLineIntersectionState . NO_INTERSECTION
65+ ) ;
5666
5767 // Parallel to v2,v3
5868 p1 = [ 2 , 0 , 0 ] ;
5969 p2 = [ 2 , 1 , 0 ] ;
6070 intersection = quad . intersectWithLine ( p1 , p2 , tol , x , pcoords ) ;
61- t . equal ( intersection . intersect , noIntersection ) ;
71+ t . equal (
72+ intersection . intersect ,
73+ QuadWithLineIntersectionState . NO_INTERSECTION
74+ ) ;
6275
6376 // Line coplanar to quad
6477 p1 = [ 0.5 , - 1 , 0 ] ;
6578 p2 = [ 0.5 , 1 , 0 ] ;
6679 intersection = quad . intersectWithLine ( p1 , p2 , tol , x , pcoords ) ;
67- t . equal ( intersection . intersect , noIntersection ) ;
68- t . equal ( intersection . t , Number . MAX_VALUE ) ;
69- t . deepEqual ( pcoords , [ 0 , 0 , 0 ] ) ;
80+ t . equal (
81+ intersection . intersect ,
82+ QuadWithLineIntersectionState . NO_INTERSECTION
83+ ) ;
7084 t . end ( ) ;
7185} ) ;
0 commit comments