Ignore:
Timestamp:
Feb 10, 2009, 11:11:04 AM (16 years ago)
Author:
rwilson
Message:

Initial commit of numpy changes. Still a long way to go.

Location:
branches/numpy
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/pmesh/mesh.py

    r6156 r6304  
    2222import types
    2323import exceptions
     24
     25import numpy as num
    2426
    2527
     
    3739except ImportError: 
    3840    # Hand-built mockup of the things we need from the kinds package, since it
    39     # was recently removed from the standard Numeric distro.  Some users may 
     41    # was recently removed from the standard numeric distro.  Some users may 
    4042    # not have it by default. 
    4143    class _bunch: 
     
    117119
    118120class Vertex(Point):
    119     """
    120     A point on the mesh.
     121    """A point on the mesh.
    121122    Object attributes based on the Triangle program
    122123    """
    123     def __init__(self,X,Y, attributes = None):
     124
     125    VERTEXSQUARESIDELENGTH = 6
     126
     127    def __init__(self, X, Y, attributes=None):
    124128        __slots__ = ['x','y','attributes']
    125        
    126         assert (type(X) == types.FloatType or type(X) == types.IntType)
    127         assert (type(Y) == types.FloatType or type(Y) == types.IntType)
    128         self.x=X
    129         self.y=Y       
    130         self.attributes=[]
    131        
    132         if attributes is None:
    133             self.attributes=[]
    134         else:
     129
     130        # we don't care what we get, as long as we can get float *value*
     131        self.x = float(X)
     132        self.y = float(Y)
     133
     134        self.attributes = []
     135        if not attributes is None:
    135136            self.attributes=attributes
    136137   
    137 
    138138    def setAttributes(self,attributes):
    139         """
    140         attributes is a list.
    141         """
     139        """attributes is a list. """
     140
    142141        self.attributes = attributes
    143142       
    144     VERTEXSQUARESIDELENGTH = 6
    145143    def draw(self, canvas, tags, colour = 'black',scale = 1, xoffset = 0,
    146144             yoffset =0, ):
     
    176174    def __repr__(self):
    177175        return "[(%f,%f),%r]" % (self.x,self.y,self.attributes)
    178    
     176
     177
    179178class Hole(Point):
    180     """
    181     A region of the mesh were no triangles are generated.
     179    """A region of the mesh were no triangles are generated.
    182180    Defined by a point in the hole enclosed by segments.
    183181    """
     
    201199   
    202200class Region(Point):
    203     """
    204     A region of the mesh, defined by a point in the region
    205     enclosed by segments. Used to tag areas.
     201    """A region of the mesh.
     202    Defined by a point in the region enclosed by segments. Used to tag areas.
    206203    """
     204
    207205    CROSSLENGTH = 6
    208206    TAG = 0
    209207    MAXAREA = 1
    210208   
    211     def __init__(self,X,Y, tag = None, maxArea = None):
    212         """Precondition: tag is a string and maxArea is a real
    213         """
    214         # This didn't work. 
    215         #super(Region,self)._init_(self,X,Y)
     209    def __init__(self, X, Y, tag=None, maxArea=None):
     210        """Precondition: tag is a string and maxArea is a real"""
     211
    216212        self.x=X
    217213        self.y=Y   
    218         self.attributes =[] # index 0 is the tag string
    219                             #optoinal index 1 is the max triangle area
    220                             #NOTE the size of this attribute is assumed
    221                             # to be 1 or 2 in regionstrings2int
     214        self.attributes = [] # index 0 is the tag string
     215                             # optional index 1 is the max triangle area
     216                             # NOTE the size of this attribute is assumed
     217                             # to be 1 or 2 in regionstrings2int
    222218        if tag is None:
    223219            self.attributes.append("")
Note: See TracChangeset for help on using the changeset viewer.