Changeset 4623


Ignore:
Timestamp:
Jul 12, 2007, 3:31:51 PM (17 years ago)
Author:
ole
Message:

Allowed create_mesh_from_regions to (optionally) allow interior polygons
to fall outside the bounding polygon. In such cases they can now be ignored
by setting the keyword argument fail_if_polygons_outside to False.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/pmesh/mesh_interface.py

    r4285 r4623  
    2929                             mesh_geo_reference=None,
    3030                             minimum_triangle_angle=28.0,
     31                             fail_if_polygons_outside=True,
    3132                             use_cache=False,
    3233                             verbose=True):
     
    6869    Note, interior regions should be fully nested, as overlaps may cause
    6970    unintended resolutions.
     71
     72    fail_if_polygons_outside: If True (the default) Exception in thrown
     73    where interior polygons fall outside bounding polygon. If False, these
     74    will be ignored and execution continued.
     75       
    7076   
    7177    """
     
    8288              'mesh_geo_reference': mesh_geo_reference,
    8389              'minimum_triangle_angle': minimum_triangle_angle,
     90              'fail_if_polygons_outside': fail_if_polygons_outside,
    8491              'verbose': verbose}   # FIXME (Ole): Should be bypassed one day
    8592                                    # What should be bypassed? Verbose?
     
    118125                              mesh_geo_reference=None,
    119126                              minimum_triangle_angle=28.0,
     127                              fail_if_polygons_outside=True,
    120128                              verbose=True):
    121129    """_create_mesh_from_regions - internal function.
     
    145153    if interior_regions is not None:       
    146154        # Test that all the interior polygons are inside the bounding_poly
     155        # and throw out those that aren't fully included.
     156
     157        polygons_inside_boundary = []
    147158        for interior_polygon, res in interior_regions:
    148159            indices = inside_polygon(interior_polygon, bounding_polygon,
     
    150161   
    151162            if len(indices) <> len(interior_polygon):
    152                 msg = 'Interior polygon %s is outside bounding polygon: %s'\
    153                       %(str(interior_polygon), str(bounding_polygon))
    154                 raise PolygonError, msg
     163                msg = 'Interior polygon %s is not fully inside'\
     164                      %(str(interior_polygon))
     165                msg += ' bounding polygon: %s.' %(str(bounding_polygon))
     166
     167                if fail_if_polygons_outside is True:
     168                    raise PolygonError, msg                   
     169                else:
     170                    msg += ' I will ignore it.'
     171                    print msg
     172
     173            else:
     174                polygons_inside_boundary.append([interior_polygon, res])
     175               
     176        # Record only those that were fully contained       
     177        interior_regions = polygons_inside_boundary
     178
     179           
    155180   
    156181# the following segment of code could be used to Test that all the
Note: See TracChangeset for help on using the changeset viewer.