Mercurial > repos > greg > icqsol_rotate_shape
changeset 2:9767d2d8505e draft
Uploaded
author | greg |
---|---|
date | Sat, 05 Dec 2015 10:30:11 -0500 |
parents | 41bc84dbe8ae |
children | c1ee5eab4fc8 |
files | icqsol_rotate_shape.py |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/icqsol_rotate_shape.py Sat Dec 05 10:29:57 2015 -0500 +++ b/icqsol_rotate_shape.py Sat Dec 05 10:30:11 2015 -0500 @@ -11,7 +11,7 @@ parser.add_argument('--input', dest='input', help='Shape dataset selected from history') parser.add_argument('--input_file_format_and_type', dest='input_file_format_and_type', help='Input file format and type') parser.add_argument('--input_dataset_type', dest='input_dataset_type', help='Input dataset_type') -parser.add_argument('--rotation_angle_degrees', dest='rotation_angle_degrees', type=float, default=0.0, help='Rotation angle in degrees') +parser.add_argument('--rotation_degrees', dest='rotation_degrees', type=float, default=0.0, help='Rotation angle in degrees') parser.add_argument('--rotation_axis_x', dest='rotation_axis_x', type=float, default=1.0, help='X coordinate of rotation axis') parser.add_argument('--rotation_axis_y', dest='rotation_axis_y', type=float, default=0.0, help='Y coordinate of rotation axis') parser.add_argument('--rotation_axis_z', dest='rotation_axis_z', type=float, default=0.0, help='Z coordinate of rotation axis') @@ -25,7 +25,7 @@ tmp_dir = icqsol_utils.get_temp_dir() # Instantiate a ShapeManager for loading the input. -if input_format == 'vtk': +if input_format == icqsol_utils.VTK: shape_mgr = ShapeManager(file_format=input_format, vtk_dataset_type=args.input_dataset_type) else: shape_mgr = ShapeManager(file_format=input_format) @@ -34,14 +34,16 @@ 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_angle_degrees, axis=axis) + 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, 'vtk') +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)