Beispiel #1
0
 def _GetLimits(self):
     """ Tell the axes how big this object is.
     """
     # Get limits
     x1, x2 = minmax(self._verts[:, 0])
     y1, y2 = minmax(self._verts[:, 1])
     z1, z2 = minmax(self._verts[:, 2])
     return vv.Wobject._GetLimits(self, x1, x2, y1, y2, z1, z2)
Beispiel #2
0
 def _GetLimits(self):
     """ Tell the axes how big this object is.
     """ 
     # Get limits
     x1, x2 = minmax(self._verts[:,0])
     y1, y2 = minmax(self._verts[:,1])
     z1, z2 = minmax(self._verts[:,2])
     return vv.Wobject._GetLimits(self, x1, x2, y1, y2, z1, z2)
Beispiel #3
0
 def __init__(self, parent, fVals, verts, faces, verticesPerFace, doDrawMesh, clim=None):
     vv.Wobject.__init__(self, parent)
     self._fVals = fVals # N-by-1 array?            values of N faces (not elements if 3D)
     self._verts = verts # M-by-3 array             coordinates of M vertices  
     self._faces = faces # N-by-3 or N-by-4 array   verts that make up N faces
     self.verticesPerFace = verticesPerFace #3 or 4. Either we have triangle faces or quads.
     self.doDrawMesh = doDrawMesh
     self._valMin = np.amin(fVals)
     self._valMax = np.amax(fVals)
     Colormapable.__init__(self)
     self._texture = None
     self.clim = minmax(self._fVals) if clim is None else clim
     self.colormap = vv.colormaps['jet']
Beispiel #4
0
 def __init__(self, parent, fVals, verts, faces, verticesPerFace, doDrawMesh, clim=None):
     vv.Wobject.__init__(self, parent)
     self._fVals = fVals # N-by-1 array?            values of N faces (not elements if 3D)
     self._verts = verts # M-by-3 array             coordinates of M vertices  
     self._faces = faces # N-by-3 or N-by-4 array   verts that make up N faces
     self.verticesPerFace = verticesPerFace #3 or 4. Either we have triangle faces or quads.
     self.doDrawMesh = doDrawMesh
     self._valMin = np.amin(fVals)
     self._valMax = np.amax(fVals)
     Colormapable.__init__(self)
     self._texture = None
     self.clim = minmax(self._fVals) if clim is None else clim
     self.colormap = vv.colormaps['jet']
Beispiel #5
0
 def SetValues(self, values, setClim=False):
     """ SetValues(values, setClim=False)
     
     Set the value data for each vertex. This can be given as:
       * Nx1 array, representing the indices in a colormap
       * Nx2 array, representing the texture coordinates in a texture
       * Nx3 array, representing the RGB values at each vertex
       * Nx4 array, representing the RGBA values at each vertex
     
     Use None as an argument to remove the values data.
     
     """
     # _values is the original supplied array (but as float32 or float64)
     # _values2 is the one used for visualization, corrected by clim
     
     if values is None:
         self._values = None # User explicitly wants to disable values
         self._values2 = None
         return
     
     # Make numpy array
     try:
         values = checkDimsOfArray(values, 0, 1, 2, 3, 4)
     except ValueError:
         raise ValueError("Values should be Nx1, Nx2, Nx3 or Nx4.")
     
     if values.shape[1] == 1:
         # Colormap indices: test data type
         if values.dtype == np.float32:
             pass
         else:
             values = values.astype(np.float32)
     
     elif values.shape[1] == 2:
         # Texture coordinates: test data type
         if values.dtype == np.float32:
             pass
         else:
             values = values.astype(np.float32)
     
     elif values.shape[1] in [3,4]:
         # Color: scale color range between 0 and 1
         if values.dtype in [np.float32, np.float64] and values.max()<1.1:
             pass
         elif values.dtype == np.uint8:
             values = values.astype(np.float32) / 256.0
         else:
             #mi, ma = minmax(values)
             #values = (values.astype(np.float32) - mi) / (ma-mi)
             # The clim makes sure the data is scaled
             values = values.astype(np.float32)
     
     # Store
     self._values = values
     
     # A bit of a hack... reset clim for Mesh class so that values2 is created
     if isinstance(self, Colormapable):
         if setClim:
             self.clim = minmax(values)
         else:
             self.clim = self.clim
 def SetValues(self, values, setClim=False):
     """ SetValues(values, setClim=False)
     
     Set the value data for each vertex. This can be given as:
       * Nx1 array, representing the indices in a colormap
       * Nx2 array, representing the texture coordinates in a texture
       * Nx3 array, representing the RGB values at each vertex
       * Nx4 array, representing the RGBA values at each vertex
     
     Use None as an argument to remove the values data.
     
     """
     # _values is the original supplied array (but as float32 or float64)
     # _values2 is the one used for visualization, corrected by clim
     
     if values is None:
         self._values = None # User explicitly wants to disable values
         self._values2 = None
         return
     
     # Make numpy array
     try:
         values = checkDimsOfArray(values, 0, 1, 2, 3, 4)
     except ValueError:
         raise ValueError("Values should be Nx1, Nx2, Nx3 or Nx4.")
     
     if values.shape[1] == 1:
         # Colormap indices: test data type
         if values.dtype == np.float32:
             pass
         else:
             values = values.astype(np.float32)
     
     elif values.shape[1] == 2:
         # Texture coordinates: test data type
         if values.dtype == np.float32:
             pass
         else:
             values = values.astype(np.float32)
     
     elif values.shape[1] in [3,4]:
         # Color: scale color range between 0 and 1
         if values.dtype in [np.float32, np.float64] and values.max()<1.1:
             pass
         elif values.dtype == np.uint8:
             values = values.astype(np.float32) / 256.0
         else:
             #mi, ma = minmax(values)
             #values = (values.astype(np.float32) - mi) / (ma-mi)
             # The clim makes sure the data is scaled
             values = values.astype(np.float32)
     
     # Store
     self._values = values
     
     # A bit of a hack... reset clim for Mesh class so that values2 is created
     if isinstance(self, Colormapable):
         if setClim:
             self.clim = minmax(values)
         else:
             self.clim = self.clim