/[escript]/trunk/pyvisi/py_src/carpet.py
ViewVC logotype

Diff of /trunk/pyvisi/py_src/carpet.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1208 by jongui, Mon Jul 2 04:46:10 2007 UTC revision 1209 by jongui, Mon Jul 2 05:46:49 2007 UTC
# Line 54  class Carpet(DataSetMapper, Actor3D, War Line 54  class Carpet(DataSetMapper, Actor3D, War
54          'True', otherwise 'False' (which is the default). On occasions, an          'True', otherwise 'False' (which is the default). On occasions, an
55          inaccurate object may be rendered from cell data even after conversion.          inaccurate object may be rendered from cell data even after conversion.
56    
57            @attention:  When 3D data is used, a cut will be performed on the
58            scalar field using a
59            plane before deformation occurs on the plane. However, if 2D data is
60            used a cut will NOT be performed and deformation will instead occur
61            immediately on the scalar field.  Pyvisi distinguishes 2D from 3D data
62            by retrieving the
63            length of the z-axis. A 2D data is assumed to have a z-axis length of
64            zero
65            while a 3D data is assumed to have a z-axis length of non-zero.
66            There are
67            exceptions to these rules where some 2D data may have a non-zero
68            z-axis length. However, such exceptions are not taken into account
69            at this stage.
70    
71          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
72          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
73          @type data_collector: L{DataCollector <datacollector.DataCollector>}          @type data_collector: L{DataCollector <datacollector.DataCollector>}
# Line 112  class Carpet(DataSetMapper, Actor3D, War Line 126  class Carpet(DataSetMapper, Actor3D, War
126          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
127          # will take place.          # will take place.
128          if(self.__lut == Lut.COLOR): # Colored lookup table.          if(self.__lut == Lut.COLOR): # Colored lookup table.
129              lookup_table = LookupTable()              self.__lookup_table = LookupTable()
130              lookup_table._setTableValue()              self.__lookup_table._setTableValue()
131          elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.          elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.
132              lookup_table = LookupTable()              self.__lookup_table = LookupTable()
133              lookup_table._setLookupTableToGreyScale()              self.__lookup_table._setLookupTableToGreyScale()
134    
135          self._setupPlane(self._getTransform())          self._setupPlane(self._getTransform())
 """  
         # Get the bounds of the object in the form of  
         # (xmin, xmax, ymin, ymax, zmin, zmax).  
         bounds = self.__data_collector._getDataCollectorOutput().GetBounds()  
         print "bounds: ", bounds  
         # Length of the z-axis (max - min). Assumption is made that if the  
         # length of the z-axis is equal to zero, the the data set is 2D.  
         # Otherwise, the data set is 3D. However, there are exceptions to this  
         # rule as some 2D data sets may have a z-axis length of non-zero, but  
         # such exceptions are not taken into account here.  
         z_axis_length = bounds[5] - bounds[4]  
   
         if(self.__cell_to_point == True): # Converts cell data to point data.  
             c2p = CellDataToPointData(\  
                     self.__data_collector._getDataCollectorOutput())  
             if(z_axis_length != 0): # A cutter is used for 3D data.  
                 self._setupCutter(c2p._getCellToPointOutput(), \  
                         self._getPlane())    
                 self._setupWarp(self._getCutterOutput())  
             elif(z_axis_length == 0): # A cutter is not used for 2D data.  
                 self._setupWarp(c2p._getCellToPointOutput())  
         elif(self.__cell_to_point == False): # No conversion happens.    
             if(z_axis_length != 0): # A cutter is used for 3D data.  
                 print "if"  
                 self._setupCutter(\  
                         self.__data_collector._getDataCollectorOutput(), \  
                         self._getPlane())    
                 self._setupWarp(self._getCutterOutput())  
             elif(z_axis_length == 0): # A cutter is not used for 2D data.  
                 print "else"  
                 self._setupWarp(  
                         self.__data_collector._getDataCollectorOutput())  
   
         self._setupDataSetMapper(self._getWarpOutput(),  
                 lookup_table._getLookupTable())  
136    
         self._setupActor3D(self._getDataSetMapper())  
         scene._addActor3D(self.__viewport, self._getActor3D())  
 """  
137      def _isModified(self):        def _isModified(self):  
138          """          """
139          Return whether the Carpet or DataCollector has been modified.          Return whether the Carpet or DataCollector has been modified.
# Line 176  class Carpet(DataSetMapper, Actor3D, War Line 152  class Carpet(DataSetMapper, Actor3D, War
152          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
153          """          """
154    
155            # This entire 'if' section had to be moved from the __init__ method
156            # due to the use of 'GetBounds()'. A source (i.e. xml file) must be
157            # supplied before 'GetBounds()' is able to return the correct value
158            # when executed. This is to accommodate for lazy evaluation.
159          if(self.__modified):          if(self.__modified):
160              # Get the bounds of the object in the form of              # Get the bounds of the object in the form of
161              # (xmin, xmax, ymin, ymax, zmin, zmax).              # (xmin, xmax, ymin, ymax, zmin, zmax).
162              bounds = self.__data_collector._getDataCollectorOutput().GetBounds()              bounds = self.__data_collector._getDataCollectorOutput().GetBounds()
             print "bounds: ", bounds  
163              # Length of the z-axis (max - min). Assumption is made that if the              # Length of the z-axis (max - min). Assumption is made that if the
164              # length of the z-axis is equal to zero, the the data set is 2D.              # length of the z-axis is equal to zero, the the data set is 2D.
165              # Otherwise, the data set is 3D. However, there are exceptions to this              # Otherwise, the data set is 3D. However, there are exceptions
166              # rule as some 2D data sets may have a z-axis length of non-zero, but              # to this rule as some 2D data sets may have a z-axis length
167              # such exceptions are not taken into account here.              # of non-zero, but such exceptions are not taken into account here.
168              z_axis_length = bounds[5] - bounds[4]              z_axis_length = bounds[5] - bounds[4]
169    
170              if(self.__cell_to_point == True): # Converts cell data to point data.              if(self.__cell_to_point == True): #Converts cell data to point data.
171                  c2p = CellDataToPointData(\                  c2p = CellDataToPointData(\
172                          self.__data_collector._getDataCollectorOutput())                          self.__data_collector._getDataCollectorOutput())
173                  if(z_axis_length != 0): # A cutter is used for 3D data.                  if(z_axis_length != 0): # A cutter is used for 3D data.
# Line 199  class Carpet(DataSetMapper, Actor3D, War Line 178  class Carpet(DataSetMapper, Actor3D, War
178                      self._setupWarp(c2p._getCellToPointOutput())                      self._setupWarp(c2p._getCellToPointOutput())
179              elif(self.__cell_to_point == False): # No conversion happens.                elif(self.__cell_to_point == False): # No conversion happens.  
180                  if(z_axis_length != 0): # A cutter is used for 3D data.                  if(z_axis_length != 0): # A cutter is used for 3D data.
                     print "if"  
181                      self._setupCutter(\                      self._setupCutter(\
182                              self.__data_collector._getDataCollectorOutput(), \                              self.__data_collector._getDataCollectorOutput(), \
183                              self._getPlane())                                self._getPlane())  
184                      self._setupWarp(self._getCutterOutput())                      self._setupWarp(self._getCutterOutput())
185                  elif(z_axis_length == 0): # A cutter is not used for 2D data.                  elif(z_axis_length == 0): # A cutter is not used for 2D data.
                     print "else"  
186                      self._setupWarp(                      self._setupWarp(
187                              self.__data_collector._getDataCollectorOutput())                              self.__data_collector._getDataCollectorOutput())
188    
189              self._setupDataSetMapper(self._getWarpOutput(),              self._setupDataSetMapper(self._getWarpOutput(),
190                      lookup_table._getLookupTable())                      self.__lookup_table._getLookupTable())
191    
192              self._setupActor3D(self._getDataSetMapper())              self._setupActor3D(self._getDataSetMapper())
193              scene._addActor3D(self.__viewport, self._getActor3D())              scene._addActor3D(self.__viewport, self._getActor3D())
194    
195    
   
   
   
   
   
   
196          if (self._isModified() == True):          if (self._isModified() == True):
197              if(self.__data_collector._isScalarSet() == True):              if(self.__data_collector._isScalarSet() == True):
198                  self.__data_collector._setActiveScalar()                  self.__data_collector._setActiveScalar()
# Line 233  class Carpet(DataSetMapper, Actor3D, War Line 204  class Carpet(DataSetMapper, Actor3D, War
204                  self._setScalarRange(self.__data_collector._getScalarRange())                  self._setScalarRange(self.__data_collector._getScalarRange())
205              self.__modified = False              self.__modified = False
206    
         bounds = self.__data_collector._getDataCollectorOutput().GetBounds()  
         print "bounds2: ", bounds  
207    
208    

Legend:
Removed from v.1208  
changed lines
  Added in v.1209

  ViewVC Help
Powered by ViewVC 1.1.26