Пример #1
0
 def to_vtk(self, prefix):
     """
     export the result to vtk
     the mesh and its triangle data go to prefix_name_mesh.vtk,
     the potential/field/pseudopotential go to prefix_name.vtk
     all arrays are named
     """
     if self.configuration is not None:
         self.configuration.to_vtk(prefix)
     sp = tvtk.StructuredPoints(
             origin=self.grid.get_origin(),
             spacing=self.grid.step,
             dimensions=self.grid.shape)
     # spw = tvtk.StructuredPointsWriter(input=sp)
     spw = tvtk.StructuredPointsWriter()
     spw.set_input_data(sp)
     spw.file_name = "%s_%s.vtk" % (prefix, self.configuration.name)
     #xidr = tvtk.XMLImageDataWriter(input=sp)
     for data_name in "potential field pseudo_potential".split():
         data = getattr(self, data_name)
         if data is None:
             continue
         if len(data.shape) > 3:
             data = data.T.reshape(-1, data.shape[0])
         else:
             data = data.T.flatten()
         d = tvtk.DoubleArray(name=data_name)
         d.from_array(data)
         sp.point_data.add_array(d)
     spw.write()
     logging.info("wrote %s", spw.file_name)
Пример #2
0
 def test_parent_child_input(self):
     """Case where parent has GetInput and child SetInput."""
     vm = tvtk.SmartVolumeMapper()
     # In this case if the wrapping is not done right, the input
     # trait is made read-only which is a bug.  We set the input
     # below to test this.
     configure_input_data(vm, tvtk.ImageData())
     spw = tvtk.StructuredPointsWriter()
     spw.input_connection = None
Пример #3
0
    def test_parent_child_input(self):
        """Case where parent has GetInput and child SetInput."""
        vm = tvtk.VolumeTextureMapper2D()
        # In this case if the wrapping is not done right, the input
        # trait is made read-only which is a bug.  We set the input
        # below to test this.
        vm.input = tvtk.ImageData()

        spw = tvtk.StructuredPointsWriter()
        spw.input = None
Пример #4
0
 def test_parent_child_input(self):
     """Case where parent has GetInput and child SetInput."""
     if vtk_major_version == 6 and vtk_minor_version > 1:
         vm = tvtk.SmartVolumeMapper()
     else:
         vm = tvtk.VolumeTextureMapper2D()
     # In this case if the wrapping is not done right, the input
     # trait is made read-only which is a bug.  We set the input
     # below to test this.
     configure_input_data(vm, tvtk.ImageData())
     spw = tvtk.StructuredPointsWriter()
     if vtk_major_version < 6:
         spw.input = None
     else:
         spw.input_connection = None