@@ -3,16 +3,17 @@ import * as vtkMath from 'vtk.js/Sources/Common/Core/Math';
33import vtkLine from 'vtk.js/Sources/Common/DataModel/Line' ;
44import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane' ;
55import vtkPriorityQueue from 'vtk.js/Sources/Common/Core/PriorityQueue' ;
6+ import { IntersectionState } from 'vtk.js/Sources/Common/DataModel/Line/Constants' ;
67import vtkBoundingBox from 'vtk.js/Sources/Common/DataModel/BoundingBox' ;
78import vtkCell from 'vtk.js/Sources/Common/DataModel/Cell' ;
89import vtkPoints from 'vtk.js/Sources/Common/Core/Points' ;
910import {
10- INTERSECTION ,
11- PolygonWithPointIntersectionState ,
11+ EPSILON ,
1212 FLOAT_EPSILON ,
13+ TOLERANCE ,
14+ PolygonWithPointIntersectionState ,
1315 VTK_DBL_EPSILON ,
14- POLYGON_TOLERANCE ,
15- EPSILON ,
16+ PolygonWithPolygonIntersectionState ,
1617} from 'vtk.js/Sources/Common/DataModel/Polygon/Constants' ;
1718
1819// ----------------------------------------------------------------------------
@@ -76,14 +77,14 @@ function pointInPolygon(point, vertices, bounds, normal) {
7677 p0 [ 1 ] = vertices [ i ++ ] ;
7778 p0 [ 2 ] = vertices [ i ++ ] ;
7879 if ( vtkMath . distance2BetweenPoints ( point , p0 ) <= tol2 ) {
79- return PolygonWithPointIntersectionState . INSIDE ;
80+ return PolygonWithPointIntersectionState . ON_LINE ;
8081 }
8182
8283 // Check coincidence to polygon edges
8384 // double* p1 = pts + 3 * ((i + 1) % numPts);
8485 const { distance, t } = vtkLine . distanceToLine ( point , p0 , p1 ) ;
8586 if ( distance <= tol2 && t > 0.0 && t < 1.0 ) {
86- return PolygonWithPointIntersectionState . INSIDE ;
87+ return PolygonWithPointIntersectionState . ON_LINE ;
8788 }
8889 }
8990
@@ -149,7 +150,9 @@ function pointInPolygon(point, vertices, bounds, normal) {
149150 } // Over all polygon edges
150151
151152 // 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 ;
153156}
154157
155158// ---------------------------------------------------
@@ -205,7 +208,7 @@ export function getNormal(poly, points, normal) {
205208 const v2 = [ ] ;
206209 for ( let j = 2 ; j < n ; j ++ ) {
207210 points . getPoint ( poly [ j ] , p2 ) ;
208- vtkMath . subtract ( p2 , p1 , v2 ) ;
211+ vtkMath . subtract ( p2 , p1 , v1 ) ;
209212 vtkMath . subtract ( p0 , p1 , v2 ) ;
210213
211214 nn [ 0 ] += v1 [ 1 ] * v2 [ 2 ] - v1 [ 2 ] * v2 [ 1 ] ;
@@ -533,8 +536,6 @@ function interpolateFunctionsUsingMVC(point, points) {
533536 // distance
534537 dist [ i ] = vtkMath . norm ( [ uVec [ 3 * i ] , uVec [ 3 * i + 1 ] , uVec [ 3 * i + 2 ] ] ) ;
535538
536- // eslint-disable-next-line no-debugger
537- debugger ;
538539 // handle special case when the point is really close to a vertex
539540 if ( dist [ i ] <= EPSILON ) {
540541 weights [ i ] = 1.0 ;
@@ -709,7 +710,7 @@ function intersectWithLine(p1, p2, points, normal) {
709710 t : Number . MAX_VALUE ,
710711 x : [ ] ,
711712 } ;
712- const tol2 = POLYGON_TOLERANCE * POLYGON_TOLERANCE ;
713+ const tol2 = TOLERANCE * TOLERANCE ;
713714
714715 // Intersect plane of the polygon with line
715716 //
@@ -742,7 +743,7 @@ function intersectConvex2DCells(polygon, points, normal) {
742743 const x1 = [ ] ;
743744 let lineIntersection ;
744745 const outObj = {
745- intersection : INTERSECTION . NO_INTERSECTION ,
746+ intersection : PolygonWithPolygonIntersectionState . NO_INTERSECTION ,
746747 x0 : [ ] ,
747748 x1 : [ ] ,
748749 } ;
@@ -768,7 +769,8 @@ function intersectConvex2DCells(polygon, points, normal) {
768769 t2 &&
769770 ! vtkMath . areEquals ( lineIntersection . x , outObj . x0 )
770771 ) {
771- outObj . intersection = INTERSECTION . LINE_INTERSECTION ;
772+ outObj . intersection =
773+ PolygonWithPolygonIntersectionState . LINE_INTERSECTION ;
772774 outObj . x1 = lineIntersection . x ;
773775 return outObj ;
774776 }
@@ -792,7 +794,8 @@ function intersectConvex2DCells(polygon, points, normal) {
792794 t2 &&
793795 ! vtkMath . areEquals ( lineIntersection . x , outObj . x0 )
794796 ) {
795- outObj . intersection = INTERSECTION . LINE_INTERSECTION ;
797+ outObj . intersection =
798+ PolygonWithPolygonIntersectionState . LINE_INTERSECTION ;
796799 outObj . x1 = lineIntersection . x ;
797800 return outObj ;
798801 }
@@ -801,10 +804,11 @@ function intersectConvex2DCells(polygon, points, normal) {
801804
802805 // Evaluate what we got
803806 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
805809 return outObj ;
806810 }
807- outObj . intersection = INTERSECTION . NO_INTERSECTION ;
811+ outObj . intersection = PolygonWithPolygonIntersectionState . NO_INTERSECTION ;
808812 return outObj ;
809813}
810814
@@ -963,12 +967,10 @@ function vtkPolygon(publicAPI, model) {
963967 if ( model . pointCount === vertexQueue . length ( ) ) {
964968 // convex
965969 const idPointToRemove = vertexQueue . pop ( ) ;
966- console . log ( idPointToRemove ) ;
967970 removePoint ( idPointToRemove , vertexQueue ) ;
968971 } else {
969972 // concave
970973 const idPointToRemove = vertexQueue . pop ( ) ;
971- console . log ( idPointToRemove ) ;
972974 if ( canRemoveVertex ( idPointToRemove ) ) {
973975 removePoint ( idPointToRemove , vertexQueue ) ;
974976 }
@@ -982,7 +984,6 @@ function vtkPolygon(publicAPI, model) {
982984 const ids = [ ] ;
983985 for ( let i = 0 ; i < model . pointCount ; i ++ ) ids . push ( i ) ;
984986 model . normal = [ ] ;
985- console . log ( ids ) ;
986987 return getNormal ( ids , model . points , model . normal ) ;
987988 } ;
988989
0 commit comments