Ignore:
Timestamp:
Jul 22, 2005, 5:59:19 PM (20 years ago)
Author:
ole
Message:

Interpolation work and some refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/general_mesh.py

    r1587 r1632  
    173173
    174174
    175     def get_vertex_coordinates(self):
     175    def get_vertex_coordinates(self, obj = False):
    176176        """Return all vertex coordinates.
    177177        Return all vertex coordinates for all triangles as an Nx6 array
    178178        (ordered as x0, y0, x1, y1, x2, y2 for each triangle)
    179         """
    180         return self.vertex_coordinates
     179
     180        if obj is True, the x/y pairs are returned in a 3*N x 2 array.
     181        FIXME, we might make that the default.
     182
     183       
     184        """
     185
     186        if obj is True:
     187            from Numeric import concatenate, reshape
     188            V = self.vertex_coordinates
     189            #return concatenate( (V[:,0:2], V[:,2:4], V[:,4:6]), axis=0)
     190
     191            N = V.shape[0]
     192            return reshape(V, (3*N, 2))
     193        else:   
     194            return self.vertex_coordinates
    181195
    182196
     
    193207        """
    194208
    195         #FIXME: Perhaps they should be ordered as in obj files??
     209        #FIXME (Ole): Perhaps they should be ordered as in obj files??
    196210        #See quantity.get_vertex_values
     211        #FIXME (Ole) - oh yes they should
    197212
    198213        from Numeric import zeros, Float
     
    210225        return vertex_coordinates
    211226
    212     def get_vertices(self,  indexes=None):
     227    def get_vertices(self, indexes=None):
    213228        """Get connectivity
    214229        indexes is the set of element ids of interest
     
    221236
    222237        return  take(self.triangles, indexes)
     238
     239    #FIXME - merge these two
     240    def get_triangles(self, obj = False):
     241        """Get connetivity
     242        Return triangles (triplets of indices into point coordinates)
     243       
     244        """
     245
     246        if obj is True:
     247            from Numeric import array, reshape, Int       
     248            m = len(self)  #Number of triangles
     249            M = 3*m        #Total number of unique vertices
     250            T = reshape(array(range(M)).astype(Int), (m,3))
     251        else:
     252            T = self.triangles
     253
     254        return T     
     255
     256   
    223257
    224258    def get_unique_vertices(self,  indexes=None):
Note: See TracChangeset for help on using the changeset viewer.