Changeset 8055
 Timestamp:
 Oct 29, 2010, 11:01:25 AM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/anuga_core/source/anuga/utilities/polygon_ext.c
r8046 r8055 440 440 441 441 442 int __triangle_ polyline_overlap(double* polyline,443 442 int __triangle_line_intersect(double* line, 443 double* triangle) 444 444 { 445 445 int j, jj, A, B; … … 450 450 double a, b; 451 451 452 p0_x = polyline[0];453 p0_y = polyline[1];454 p1_x = polyline[2];455 p1_y = polyline[3];452 p0_x = line[0]; 453 p0_y = line[1]; 454 p1_x = line[2]; 455 p1_y = line[3]; 456 456 457 457 pp_x = (p1_y  p0_y); … … 494 494 if (a >= 0.0f && a <= 1.0f && b >=0.0f && b <=1.0f) 495 495 { 496 return 1; // overlap496 return 1; //intersect 497 497 } 498 498 … … 514 514 if (A >= 1 && B >= 1) 515 515 { 516 return 1; // overlap516 return 1; //polygon sits completely inside a triangle 517 517 } 518 518 519 return 0; //no overlap519 return 0; //no intersection 520 520 } 521 521 522 522 523 int __ polyline_overlap(double* polyline,524 525 526 523 int __line_intersect(double* line, 524 double* triangles, 525 long* indices, 526 int M) //number of triangles 527 527 { 528 528 double* triangle; 529 529 int i, inside_index, outside_index; 530 530 531 inside_index = 0; // Keep track of triangles that overlap532 outside_index = M  1; // Keep track of triangles that don't overlap(starting from end)531 inside_index = 0; // Keep track of triangles that intersect 532 outside_index = M  1; // Keep track of triangles that don't intersect (starting from end) 533 533 534 534 for (i = 0; i < M; i++) … … 536 536 triangle = triangles + 6*i; 537 537 538 if (__triangle_ polyline_overlap(polyline,539 538 if (__triangle_line_intersect(line, 539 triangle)) 540 540 { 541 541 indices[inside_index] = i; … … 854 854 } 855 855 856 PyObject *_ polyline_overlap(PyObject *self, PyObject *args)856 PyObject *_line_intersect(PyObject *self, PyObject *args) 857 857 { 858 858 // … … 900 900 901 901 PyArrayObject 902 * polyline,902 *line, 903 903 *triangles, 904 904 *indices; … … 910 910 // Convert Python arguments to C 911 911 if (!PyArg_ParseTuple(args, "OOO", 912 & polyline,912 &line, 913 913 &triangles, 914 914 &indices)) { … … 920 920 921 921 // Call underlying routine 922 res = __ polyline_overlap((double*) polyline>data,923 (double*) triangles>data,924 (long*) indices>data,925 (int) triangles>dimensions[0]/3);922 res = __line_intersect((double*) line>data, 923 (double*) triangles>data, 924 (long*) indices>data, 925 (int) triangles>dimensions[0]/3); 926 926 927 927 … … 1103 1103 {"_polygon_overlap", _polygon_overlap, 1104 1104 METH_VARARGS, "Print out"}, 1105 {"_ polyline_overlap", _polyline_overlap,1105 {"_line_intersect", _line_intersect, 1106 1106 METH_VARARGS, "Print out"}, 1107 1107 {"_is_inside_triangle", _is_inside_triangle,
Note: See TracChangeset
for help on using the changeset viewer.