help='Output VTK type') args = parser.parse_args() # Get the format of the input - either vtk or ply. input_format, input_file_type = icqsol_utils.get_format_and_type( args.input_file_format_and_type) tmp_dir = icqsol_utils.get_temp_dir() # Instantiate a ShapeManager for loading the input. shape_mgr = icqsol_utils.get_shape_manager(input_format, args.input_dataset_type) # Get the vtk polydata from the input dataset. vtk_poly_data = shape_mgr.loadAsVtkPolyData(args.input) # Translate (in place operation). displ = (args.displacement_x, args.displacement_y, args.displacement_z) shape_mgr.translateVtkPolyData(vtk_poly_data, displ=displ) # Save the output. output_format, output_file_type = icqsol_utils.get_format_and_type( args.output_vtk_type) tmp_dir = icqsol_utils.get_temp_dir() tmp_output_path = icqsol_utils.get_temporary_file_path(tmp_dir, icqsol_utils.VTK) shape_mgr.saveVtkPolyData(vtk_poly_data, file_name=tmp_output_path, file_type=output_file_type) shutil.move(tmp_output_path, args.output)
args = parser.parse_args() tmp_dir = icqsol_utils.get_temp_dir() input_format, input_file_type = icqsol_utils.get_format_and_type(args.input_file_format_and_type) # Instantiate a ShapeManager for loading the input. shape_mgr = icqsol_utils.get_shape_manager(icqsol_utils.VTK, args.input_dataset_type) # Get the vtkPolyData from the input dataset. vtk_poly_data = shape_mgr.loadAsVtkPolyData(args.input) # Add color to the data. colored_vtk_poly_data = shape_mgr.colorSurfaceField(vtk_poly_data=vtk_poly_data, color_map=args.color_map, field_name=args.field_name, field_component=args.field_component_index) # Write min/max field values. minVal, maxVal = shape_mgr.getFieldRange(vtk_poly_data, args.field_name, args.field_component_index) print 'component {2} min/max values of field {3}: {0}/{1}'.format(minVal, maxVal, args.field_component_index, args.field_name) # Define the output file format and type. output_format, output_file_type = icqsol_utils.get_format_and_type(args.output_vtk_type) tmp_output_path = icqsol_utils.get_temporary_file_path(tmp_dir, output_format) # Make sure the ShapeManager's writer is VTK POLYDATA. shape_mgr.setWriter(file_format=icqsol_utils.VTK, vtk_dataset_type=icqsol_utils.POLYDATA) # Save the output. shape_mgr.saveVtkPolyData(vtk_poly_data=colored_vtk_poly_data, file_name=tmp_output_path, file_type=output_file_type) shutil.move(tmp_output_path, args.output)
parser.add_argument('--rotation_axis_z', dest='rotation_axis_z', type=float, default=0.0, help='Z coordinate of rotation axis') parser.add_argument('--output', dest='output', help='Output file name') parser.add_argument('--output_vtk_type', dest='output_vtk_type', default='ascii', help='Output VTK type') args = parser.parse_args() # Get the format of the input - either vtk or ply. input_format, input_file_type = icqsol_utils.get_format_and_type(args.input_file_format_and_type) tmp_dir = icqsol_utils.get_temp_dir() # Instantiate a ShapeManager for loading the input. shape_mgr = icqsol_utils.get_shape_manager(input_format, args.input_dataset_type) # Get the vtk polydata from the input dataset. vtk_poly_data = shape_mgr.loadAsVtkPolyData(args.input) # Only rotate if the axis has some non-zero coordinates. # FIXME: this should be handled in a Galaxy tool validator. axis = (args.rotation_axis_x, args.rotation_axis_y, args.rotation_axis_z) if reduce(operator.mul, axis) != 0.0: # Rotate (in place operation). shape_mgr.rotateVtkPolyData(vtk_poly_data, angleDeg=args.rotation_degrees, axis=axis) output_format, output_file_type = icqsol_utils.get_format_and_type(args.output_vtk_type) # Save the output. tmp_dir = icqsol_utils.get_temp_dir() tmp_output_path = icqsol_utils.get_temporary_file_path(tmp_dir, icqsol_utils.VTK) shape_mgr.saveVtkPolyData(vtk_poly_data, file_name=tmp_output_path, file_type=output_file_type) shutil.move(tmp_output_path, args.output)