@@ -3,16 +3,17 @@ import * as vtkMath from 'vtk.js/Sources/Common/Core/Math';
3
3
import vtkLine from 'vtk.js/Sources/Common/DataModel/Line' ;
4
4
import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane' ;
5
5
import vtkPriorityQueue from 'vtk.js/Sources/Common/Core/PriorityQueue' ;
6
+ import { IntersectionState } from 'vtk.js/Sources/Common/DataModel/Line/Constants' ;
6
7
import vtkBoundingBox from 'vtk.js/Sources/Common/DataModel/BoundingBox' ;
7
8
import vtkCell from 'vtk.js/Sources/Common/DataModel/Cell' ;
8
9
import vtkPoints from 'vtk.js/Sources/Common/Core/Points' ;
9
10
import {
10
- INTERSECTION ,
11
- PolygonWithPointIntersectionState ,
11
+ EPSILON ,
12
12
FLOAT_EPSILON ,
13
+ TOLERANCE ,
14
+ PolygonWithPointIntersectionState ,
13
15
VTK_DBL_EPSILON ,
14
- POLYGON_TOLERANCE ,
15
- EPSILON ,
16
+ PolygonWithPolygonIntersectionState ,
16
17
} from 'vtk.js/Sources/Common/DataModel/Polygon/Constants' ;
17
18
18
19
// ----------------------------------------------------------------------------
@@ -76,14 +77,14 @@ function pointInPolygon(point, vertices, bounds, normal) {
76
77
p0 [ 1 ] = vertices [ i ++ ] ;
77
78
p0 [ 2 ] = vertices [ i ++ ] ;
78
79
if ( vtkMath . distance2BetweenPoints ( point , p0 ) <= tol2 ) {
79
- return PolygonWithPointIntersectionState . INSIDE ;
80
+ return PolygonWithPointIntersectionState . ON_LINE ;
80
81
}
81
82
82
83
// Check coincidence to polygon edges
83
84
// double* p1 = pts + 3 * ((i + 1) % numPts);
84
85
const { distance, t } = vtkLine . distanceToLine ( point , p0 , p1 ) ;
85
86
if ( distance <= tol2 && t > 0.0 && t < 1.0 ) {
86
- return PolygonWithPointIntersectionState . INSIDE ;
87
+ return PolygonWithPointIntersectionState . ON_LINE ;
87
88
}
88
89
}
89
90
@@ -149,7 +150,9 @@ function pointInPolygon(point, vertices, bounds, normal) {
149
150
} // Over all polygon edges
150
151
151
152
// A winding number == 0 is outside the polygon
152
- return wn === 0 ? PolygonWithPointIntersectionState . OUTSIDE : PolygonWithPointIntersectionState . INSIDE ;
153
+ return wn === 0
154
+ ? PolygonWithPointIntersectionState . OUTSIDE
155
+ : PolygonWithPointIntersectionState . INSIDE ;
153
156
}
154
157
155
158
// ---------------------------------------------------
@@ -205,7 +208,7 @@ export function getNormal(poly, points, normal) {
205
208
const v2 = [ ] ;
206
209
for ( let j = 2 ; j < n ; j ++ ) {
207
210
points . getPoint ( poly [ j ] , p2 ) ;
208
- vtkMath . subtract ( p2 , p1 , v2 ) ;
211
+ vtkMath . subtract ( p2 , p1 , v1 ) ;
209
212
vtkMath . subtract ( p0 , p1 , v2 ) ;
210
213
211
214
nn [ 0 ] += v1 [ 1 ] * v2 [ 2 ] - v1 [ 2 ] * v2 [ 1 ] ;
@@ -533,8 +536,6 @@ function interpolateFunctionsUsingMVC(point, points) {
533
536
// distance
534
537
dist [ i ] = vtkMath . norm ( [ uVec [ 3 * i ] , uVec [ 3 * i + 1 ] , uVec [ 3 * i + 2 ] ] ) ;
535
538
536
- // eslint-disable-next-line no-debugger
537
- debugger ;
538
539
// handle special case when the point is really close to a vertex
539
540
if ( dist [ i ] <= EPSILON ) {
540
541
weights [ i ] = 1.0 ;
@@ -709,7 +710,7 @@ function intersectWithLine(p1, p2, points, normal) {
709
710
t : Number . MAX_VALUE ,
710
711
x : [ ] ,
711
712
} ;
712
- const tol2 = POLYGON_TOLERANCE * POLYGON_TOLERANCE ;
713
+ const tol2 = TOLERANCE * TOLERANCE ;
713
714
714
715
// Intersect plane of the polygon with line
715
716
//
@@ -742,7 +743,7 @@ function intersectConvex2DCells(polygon, points, normal) {
742
743
const x1 = [ ] ;
743
744
let lineIntersection ;
744
745
const outObj = {
745
- intersection : INTERSECTION . NO_INTERSECTION ,
746
+ intersection : PolygonWithPolygonIntersectionState . NO_INTERSECTION ,
746
747
x0 : [ ] ,
747
748
x1 : [ ] ,
748
749
} ;
@@ -768,7 +769,8 @@ function intersectConvex2DCells(polygon, points, normal) {
768
769
t2 &&
769
770
! vtkMath . areEquals ( lineIntersection . x , outObj . x0 )
770
771
) {
771
- outObj . intersection = INTERSECTION . LINE_INTERSECTION ;
772
+ outObj . intersection =
773
+ PolygonWithPolygonIntersectionState . LINE_INTERSECTION ;
772
774
outObj . x1 = lineIntersection . x ;
773
775
return outObj ;
774
776
}
@@ -792,7 +794,8 @@ function intersectConvex2DCells(polygon, points, normal) {
792
794
t2 &&
793
795
! vtkMath . areEquals ( lineIntersection . x , outObj . x0 )
794
796
) {
795
- outObj . intersection = INTERSECTION . LINE_INTERSECTION ;
797
+ outObj . intersection =
798
+ PolygonWithPolygonIntersectionState . LINE_INTERSECTION ;
796
799
outObj . x1 = lineIntersection . x ;
797
800
return outObj ;
798
801
}
@@ -801,10 +804,11 @@ function intersectConvex2DCells(polygon, points, normal) {
801
804
802
805
// Evaluate what we got
803
806
if ( idx === 1 ) {
804
- outObj . intersection = INTERSECTION . POINT_INTERSECTION ; // everything intersecting at single point
807
+ outObj . intersection =
808
+ PolygonWithPolygonIntersectionState . POINT_INTERSECTION ; // everything intersecting at single point
805
809
return outObj ;
806
810
}
807
- outObj . intersection = INTERSECTION . NO_INTERSECTION ;
811
+ outObj . intersection = PolygonWithPolygonIntersectionState . NO_INTERSECTION ;
808
812
return outObj ;
809
813
}
810
814
@@ -963,12 +967,10 @@ function vtkPolygon(publicAPI, model) {
963
967
if ( model . pointCount === vertexQueue . length ( ) ) {
964
968
// convex
965
969
const idPointToRemove = vertexQueue . pop ( ) ;
966
- console . log ( idPointToRemove ) ;
967
970
removePoint ( idPointToRemove , vertexQueue ) ;
968
971
} else {
969
972
// concave
970
973
const idPointToRemove = vertexQueue . pop ( ) ;
971
- console . log ( idPointToRemove ) ;
972
974
if ( canRemoveVertex ( idPointToRemove ) ) {
973
975
removePoint ( idPointToRemove , vertexQueue ) ;
974
976
}
@@ -982,7 +984,6 @@ function vtkPolygon(publicAPI, model) {
982
984
const ids = [ ] ;
983
985
for ( let i = 0 ; i < model . pointCount ; i ++ ) ids . push ( i ) ;
984
986
model . normal = [ ] ;
985
- console . log ( ids ) ;
986
987
return getNormal ( ids , model . points , model . normal ) ;
987
988
} ;
988
989
0 commit comments