Python vtk.vtkXMLPolyDataWriter() Examples
The following are 6
code examples of vtk.vtkXMLPolyDataWriter().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
vtk
, or try the search function
.
Example #1
Source File: mesh.py From OpenWARP with Apache License 2.0 | 6 votes |
def _write_vtp(self): '''Internal function to write VTK PolyData mesh files ''' if self.VTK_installed is False: raise VTK_Exception('VTK must be installed write VTP/VTK meshes, please select a different output mesh_format') writer = vtk.vtkXMLPolyDataWriter() writer.SetFileName(self.files['vtp']) if vtk.VTK_MAJOR_VERSION >= 6: writer.SetInputData(self.vtp_mesh) else: writer.SetInput(self.vtp_mesh) writer.SetDataModeToAscii() writer.Write() print 'Wrote VTK PolyData mesh to: ' + str(self.files['vtp'])
Example #2
Source File: mesh.py From OpenWARP with Apache License 2.0 | 6 votes |
def _write_vtp(self): '''Internal function to write VTK PolyData mesh files ''' if self.VTK_installed is False: raise VTK_Exception('VTK must be installed write VTP/VTK meshes, please select a different output mesh_format') writer = vtk.vtkXMLPolyDataWriter() writer.SetFileName(self.files['vtp']) if vtk.VTK_MAJOR_VERSION >= 6: writer.SetInputData(self.vtp_mesh) else: writer.SetInput(self.vtp_mesh) writer.SetDataModeToAscii() writer.Write() print 'Wrote VTK PolyData mesh to: ' + str(self.files['vtp'])
Example #3
Source File: mesh.py From OpenWARP with Apache License 2.0 | 6 votes |
def _write_vtp(self): '''Internal function to write VTK PolyData mesh files ''' if self.VTK_installed is False: raise VTK_Exception('VTK must be installed write VTP/VTK meshes, please select a different output mesh_format') writer = vtk.vtkXMLPolyDataWriter() writer.SetFileName(self.files['vtp']) if vtk.VTK_MAJOR_VERSION >= 6: writer.SetInputData(self.vtp_mesh) else: writer.SetInput(self.vtp_mesh) writer.SetDataModeToAscii() writer.Write() print 'Wrote VTK PolyData mesh to: ' + str(self.files['vtp'])
Example #4
Source File: mesh.py From OpenWARP with Apache License 2.0 | 6 votes |
def _write_vtp(self): '''Internal function to write VTK PolyData mesh files ''' if self.VTK_installed is False: raise VTK_Exception('VTK must be installed write VTP/VTK meshes, please select a different output mesh_format') writer = vtk.vtkXMLPolyDataWriter() writer.SetFileName(self.files['vtp']) if vtk.VTK_MAJOR_VERSION >= 6: writer.SetInputData(self.vtp_mesh) else: writer.SetInput(self.vtp_mesh) writer.SetDataModeToAscii() writer.Write() print 'Wrote VTK PolyData mesh to: ' + str(self.files['vtp'])
Example #5
Source File: tract_io.py From geomloss with MIT License | 5 votes |
def save_vtk(filename, tracts, lines_indices=None, scalars = None): lengths = [len(p) for p in tracts] line_starts = ns.numpy.r_[0, ns.numpy.cumsum(lengths)] if lines_indices is None: lines_indices = [ns.numpy.arange(length) + line_start for length, line_start in izip(lengths, line_starts)] ids = ns.numpy.hstack([ns.numpy.r_[c[0], c[1]] for c in izip(lengths, lines_indices)]) vtk_ids = ns.numpy_to_vtkIdTypeArray(ids, deep=True) cell_array = vtk.vtkCellArray() cell_array.SetCells(len(tracts), vtk_ids) points = ns.numpy.vstack(tracts).astype(ns.get_vtk_to_numpy_typemap()[vtk.VTK_DOUBLE]) points_array = ns.numpy_to_vtk(points, deep=True) poly_data = vtk.vtkPolyData() vtk_points = vtk.vtkPoints() vtk_points.SetData(points_array) poly_data.SetPoints(vtk_points) poly_data.SetLines(cell_array) poly_data.BuildCells() if filename.endswith('.xml') or filename.endswith('.vtp'): writer = vtk.vtkXMLPolyDataWriter() writer.SetDataModeToBinary() else: writer = vtk.vtkPolyDataWriter() writer.SetFileTypeToBinary() writer.SetFileName(filename) if hasattr(vtk, 'VTK_MAJOR_VERSION') and vtk.VTK_MAJOR_VERSION > 5: writer.SetInputData(poly_data) else: writer.SetInput(poly_data) writer.Write()
Example #6
Source File: tract_io.py From geomloss with MIT License | 5 votes |
def save_vtk_labels(filename, tracts, scalars, lines_indices=None): lengths = [len(p) for p in tracts] line_starts = ns.numpy.r_[0, ns.numpy.cumsum(lengths)] if lines_indices is None: lines_indices = [ns.numpy.arange(length) + line_start for length, line_start in izip(lengths, line_starts)] ids = ns.numpy.hstack([ns.numpy.r_[c[0], c[1]] for c in izip(lengths, lines_indices)]) vtk_ids = ns.numpy_to_vtkIdTypeArray(ids, deep=True) cell_array = vtk.vtkCellArray() cell_array.SetCells(len(tracts), vtk_ids) points = ns.numpy.vstack(tracts).astype(ns.get_vtk_to_numpy_typemap()[vtk.VTK_DOUBLE]) points_array = ns.numpy_to_vtk(points, deep=True) poly_data = vtk.vtkPolyData() vtk_points = vtk.vtkPoints() vtk_points.SetData(points_array) poly_data.SetPoints(vtk_points) poly_data.SetLines(cell_array) poly_data.GetPointData().SetScalars(ns.numpy_to_vtk(scalars)) poly_data.BuildCells() # poly_data.SetScalars(scalars) if filename.endswith('.xml') or filename.endswith('.vtp'): writer = vtk.vtkXMLPolyDataWriter() writer.SetDataModeToBinary() else: writer = vtk.vtkPolyDataWriter() writer.SetFileTypeToBinary() writer.SetFileName(filename) if hasattr(vtk, 'VTK_MAJOR_VERSION') and vtk.VTK_MAJOR_VERSION > 5: writer.SetInputData(poly_data) else: writer.SetInput(poly_data) writer.Write()