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

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

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

revision 1042 by jongui, Fri Mar 16 05:15:37 2007 UTC revision 1043 by jongui, Mon Mar 19 06:46:34 2007 UTC
# Line 34  class DataCollector: Line 34  class DataCollector:
34              self.__vtk_xml_reader = vtk.vtkXMLUnstructuredGridReader()              self.__vtk_xml_reader = vtk.vtkXMLUnstructuredGridReader()
35              # Create a temporary .xml file and retrieves its path.              # Create a temporary .xml file and retrieves its path.
36              self.__tmp_file = tempfile.mkstemp(suffix=".xml")[1]              self.__tmp_file = tempfile.mkstemp(suffix=".xml")[1]
37              self.__vtk_xml_reader.SetFileName(self.__tmp_file)              #self.__vtk_xml_reader.SetFileName(self.__tmp_file)
38    
39      def __del__(self):      def __del__(self):
40          """          """
# Line 55  class DataCollector: Line 55  class DataCollector:
55          if(self.__source == Source.XML):          if(self.__source == Source.XML):
56              self.__vtk_xml_reader.SetFileName(file_name)              self.__vtk_xml_reader.SetFileName(file_name)
57    
58              # NOTE: Update must be called after SetFileName to make the reader              # Update must be called after SetFileName to make the reader
59              # up to date. Otherwise, some output values may be incorrect.              # up to date. Otherwise, some output values may be incorrect.
60              self.__vtk_xml_reader.Update()              self.__vtk_xml_reader.Update()
61              self.__output = self.__vtk_xml_reader.GetOutput()              self.__output = self.__vtk_xml_reader.GetOutput()
# Line 82  class DataCollector: Line 82  class DataCollector:
82    
83          if self.__source == Source.ESCRIPT:          if self.__source == Source.ESCRIPT:
84              esys.escript.saveVTK(self.__tmp_file,**args)              esys.escript.saveVTK(self.__tmp_file,**args)
85                self.__vtk_xml_reader.SetFileName(self.__tmp_file)
86                # Modified must be called for setData but NOT for
87                # setFileName. If Modified is not called, only the first file
88                # will always be displayed. The reason Modified is used is
89                # because the same temporary file name is always used
90                # (old file is overwritten). Modified MUST NOT be used in
91                # setFileName, it can cause incorrect output such as map.
92                self.__vtk_xml_reader.Modified()
93                # Update must be called after Modified. If Update is called before
94                # Modified, then the first/second image(s) may not be updated
95                # correctly.
96              self.__vtk_xml_reader.Update()              self.__vtk_xml_reader.Update()
97              self.__output = self.__vtk_xml_reader.GetOutput()              self.__output = self.__vtk_xml_reader.GetOutput()
98              self.__get_attribute_lists()              self.__get_attribute_lists()
# Line 104  class DataCollector: Line 115  class DataCollector:
115          # but is used only when a scalar attribute has been specified.          # but is used only when a scalar attribute has been specified.
116          if scalar in self.__point_attribute['scalars']:          if scalar in self.__point_attribute['scalars']:
117              self._getOutput().GetPointData().SetActiveScalars(scalar)              self._getOutput().GetPointData().SetActiveScalars(scalar)
118                print "SCALAR POINT DATA"
119          elif scalar in self.__cell_attribute['scalars']:          elif scalar in self.__cell_attribute['scalars']:
120              self._getOutput().GetCellData().SetActiveScalars(scalar)              self._getOutput().GetCellData().SetActiveScalars(scalar)
121                print "SCALAR CELL DATA"
122          else:          else:
123              print "\nERROR: No scalar called '%s' is available.\n" % scalar              print "\nERROR: No scalar called '%s' is available.\n" % scalar
124              sys.exit(1)              sys.exit(1)
# Line 125  class DataCollector: Line 138  class DataCollector:
138          # but is used only when a vector attribute has been specified.          # but is used only when a vector attribute has been specified.
139          if vector in self.__point_attribute['vectors']:          if vector in self.__point_attribute['vectors']:
140              self._getOutput().GetPointData().SetActiveVectors(vector)              self._getOutput().GetPointData().SetActiveVectors(vector)
141                print "VECTOR POINT DATA"
142          elif vector in self.__cell_attribute['vectors']:          elif vector in self.__cell_attribute['vectors']:
143              self._getOutput().GetCellData().SetActiveVectors(vector)              self._getOutput().GetCellData().SetActiveVectors(vector)
144                print "VECTOR CELL DATA"
145          else:          else:
146              print "\nERROR: No vector called '%s' is available.\n" % vector              print "\nERROR: No vector called '%s' is available.\n" % vector
147              sys.exit(1)              sys.exit(1)
# Line 152  class DataCollector: Line 167  class DataCollector:
167              print "\nERROR: No tensor called '%s' is available.\n" % tensor              print "\nERROR: No tensor called '%s' is available.\n" % tensor
168              sys.exit(0)              sys.exit(0)
169    
170        # 'object' is set to 'None' because some types of visualization have
171        # two different ranges that need to be updated while others only have one.
172      def _paramForUpdatingMultipleSources(self, viz_type, color_mode, mapper,      def _paramForUpdatingMultipleSources(self, viz_type, color_mode, mapper,
173              object = None):              object = None):
174          """          """
175          Parameters required to update the necessary range when two or more          Parameters required to update the necessary range when two or more
176          files are read.          files are read.
177    
178          @type viz_type: :          @type viz_type: : L{VizType <constant.VizType>} constant
179          @param viz_type:          @param viz_type: Type if visualization (i.e. Map, Velocity, etc)
180          @type color_mode:          @type color_mode: L{ColorMode <constant.ColorMode>} constant
181          @param color_mode:          @param color_mode: Type of color mode
182          @type mapper:          @type mapper: vtkDataSetMapper
183          @param mapper:          @param mapper: Mapped data
184          @type object:          @type object: vtkPolyDataAlgorith (i.e. vtkContourFilter, vtkGlyph3D, \
185          @param object:                  etc)
186            @param object: Poly data
187          """          """
188    
189          self.__viz_type = viz_type          self.__viz_type = viz_type
# Line 174  class DataCollector: Line 192  class DataCollector:
192          self.__object = object          self.__object = object
193    
194      def _updateRange(self, range):      def _updateRange(self, range):
195            """
196            Update the necessary range when two or more sources are read in.
197            """
198    
199          if self.__viz_type == VizType.MAP or \          if self.__viz_type == VizType.MAP or \
200                  self.__viz_type == VizType.ELLIPSOID or \                  self.__viz_type == VizType.ELLIPSOID or \
201                  self.__viz_type == VizType.CARPET:                  self.__viz_type == VizType.CARPET:

Legend:
Removed from v.1042  
changed lines
  Added in v.1043

  ViewVC Help
Powered by ViewVC 1.1.26