Changeset 7701


Ignore:
Timestamp:
Apr 29, 2010, 3:14:45 PM (15 years ago)
Author:
James Hudson
Message:

Fixed crash bug if triangles not in numeric form.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/fit_interpolate/search_functions.py

    r7700 r7701  
    88import time
    99
     10from anuga.utilities.numerical_tools import get_machine_precision
     11from anuga.utilities.numerical_tools import ensure_numeric
     12from anuga.config import max_float
     13
    1014from anuga.utilities import compile
    1115if compile.can_use_C_extension('polygon_ext.c'):
    1216    # Underlying C implementations can be accessed
    13     from polygon_ext import _is_inside_triangle 
    14        
    15 #from anuga.utilities.polygon import is_inside_triangle
    16 from anuga.utilities.numerical_tools import get_machine_precision
    17 from anuga.config import max_float
     17    from polygon_ext import _is_inside_triangle       
     18else:
     19    msg = 'C implementations could not be accessed by %s.\n ' %__file__
     20    msg += 'Make sure compile_all.py has been run as described in '
     21    msg += 'the ANUGA installation guide.'
     22    raise Exception, msg
    1823
    1924import numpy as num
     
    97102    """
    98103    global last_triangle
     104
     105    x = ensure_numeric(x, num.float)   
    99106   
    100107    # These statments are needed if triangles is empty
     
    107114    for k, tri_verts_norms in triangles:
    108115        tri = tri_verts_norms[0]
     116        tri = ensure_numeric(tri)               
    109117        # k is the triangle index
    110118        # tri is a list of verts (x, y), representing a tringle
    111119        # Find triangle that contains x (if any) and interpolate
    112 
    113         # Input check disabled to speed things up.
    114         if _is_inside_triangle(x, tri,
    115                               int(True), 1.0e-12, 1.0e-12):
     120       
     121        # Input check disabled to speed things up.     
     122        if bool(_is_inside_triangle(x, tri, int(True), 1.0e-12, 1.0e-12)):
    116123           
    117124            n0, n1, n2 = tri_verts_norms[1]       
Note: See TracChangeset for help on using the changeset viewer.