Changeset 8032 for trunk/anuga_core/source/anuga/geometry
- Timestamp:
- Oct 10, 2010, 5:14:24 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/geometry/test_polygon.py
r7866 r8032 12 12 read_polygon, point_on_line, point_in_polygon, \ 13 13 plot_polygons, outside_polygon, is_outside_polygon, \ 14 intersection, is_complex, is_inside_triangle, \ 15 interpolate_polyline, inside_polygon, in_and_outside_polygon 14 intersection, is_complex, polygon_overlap, not_polygon_overlap,\ 15 is_inside_triangle, interpolate_polyline, inside_polygon, \ 16 in_and_outside_polygon 16 17 17 18 from polygon_function import Polygon_function … … 415 416 416 417 418 def test_polygon_overlap(self): 419 #rectangular polygon, 2 triangles overlap 420 polygon = [[3.,3.],[3.,4.],[5.,4.],[5.,3.]] 421 triangles = [[7.,10.],#does not overlap 422 [8.,12.], 423 [9.,10.], 424 [3., 2.],#intersect 425 [4., 5.], 426 [5., 3.], 427 [3., 2.],#intersect 428 [4., 5.], 429 [5., 2.], 430 [0., 1.],#polygon inside triangle 431 [5., 50.], 432 [10., 1.], 433 [3.5, 3.25],#triangle inside polygon 434 [4., 3.75], 435 [4.5, 3.25]] 436 437 indices = polygon_overlap(triangles, polygon) 438 assert num.allclose([1, 2, 3, 4], indices) 439 440 #5 sided polygon, 2 triangles overlap 441 polygon = [[3.,3.],[3.,4.],[5.,4.],[5.5, 3.5],[5.,3.]] 442 triangles = [[7.,10.],#does not overlap 443 [8.,12.], 444 [9.,10.], 445 [3., 2.],#intersect 446 [4., 5.], 447 [5., 3.], 448 [3., 2.],#intersect 449 [4., 5.], 450 [5., 2.], 451 [0., 1.],#polygon inside triangle 452 [5., 50.], 453 [10., 1.], 454 [3.5, 3.25],#triangle inside polygon 455 [4., 3.75], 456 [4.5, 3.25]] 457 458 indices = polygon_overlap(triangles, polygon) 459 assert num.allclose([1, 2, 3, 4], indices) 460 461 def test_not_polygon_overlap(self): 462 #rectangular polygon, 2 triangles overlap 463 polygon = [[3.,3.],[3.,4.],[5.,4.],[5.,3.]] 464 triangles = [[7.,10.],#does not overlap 465 [8.,12.], 466 [9.,10.], 467 [3., 2.],#intersect 468 [4., 5.], 469 [5., 3.], 470 [3., 2.],#intersect 471 [4., 5.], 472 [5., 2.], 473 [0., 1.],#polygon inside triangle 474 [5., 50.], 475 [10., 1.], 476 [3.5, 3.25],#triangle inside polygon 477 [4., 3.75], 478 [4.5, 3.25]] 479 480 indices = not_polygon_overlap(triangles, polygon) 481 assert num.allclose([0], indices) 482 483 #5 sided polygon, 2 triangles overlap 484 polygon = [[3.,3.],[3.,4.],[5.,4.],[5.5, 3.5],[5.,3.]] 485 triangles = [[7.,10.],#does not overlap 486 [8.,12.], 487 [9.,10.], 488 [3., 2.],#intersect 489 [4., 5.], 490 [5., 3.], 491 [3., 2.],#intersect 492 [4., 5.], 493 [5., 2.], 494 [0., 1.],#polygon inside triangle 495 [5., 50.], 496 [10., 1.], 497 [3.5, 3.25],#triangle inside polygon 498 [4., 3.75], 499 [4.5, 3.25]] 500 501 indices = not_polygon_overlap(triangles, polygon) 502 assert num.allclose([0], indices) 503 417 504 def test_is_inside_triangle(self): 418 505 # Simplest case:
Note: See TracChangeset
for help on using the changeset viewer.