Mercurial > repos > greg > icqsol_compose_shapes
comparison icqsol_compose_shapes.py @ 1:e3350521105e draft
Uploaded
author | greg |
---|---|
date | Fri, 04 Dec 2015 09:22:33 -0500 |
parents | 36f5fa5bd6d9 |
children | 01ce1844eacb |
comparison
equal
deleted
inserted
replaced
0:36f5fa5bd6d9 | 1:e3350521105e |
---|---|
5 import icqsol_utils | 5 import icqsol_utils |
6 from icqsol.shapes.icqShapeManager import ShapeManager | 6 from icqsol.shapes.icqShapeManager import ShapeManager |
7 | 7 |
8 # Parse Command Line. | 8 # Parse Command Line. |
9 parser = argparse.ArgumentParser() | 9 parser = argparse.ArgumentParser() |
10 parser.add_argument( '--expression', dest='expression', help='Composition expression' ) | 10 parser.add_argument('--expression', dest='expression', help='Composition expression') |
11 parser.add_argument( '--shape_dataset', dest='shape_datasets', action='append', nargs=4, help='Shape datasets selected from history' ) | 11 parser.add_argument('--shape_dataset', dest='shape_datasets', action='append', nargs=4, help='Shape datasets selected from history') |
12 parser.add_argument( '--output', dest='output', help='Output dataset' ) | 12 parser.add_argument('--output', dest='output', help='Output dataset') |
13 parser.add_argument( '--output_vtk_type', dest='output_vtk_type', help='Output file format and type' ) | 13 parser.add_argument('--output_vtk_type', dest='output_vtk_type', help='Output file format and type') |
14 | 14 |
15 args = parser.parse_args() | 15 args = parser.parse_args() |
16 | 16 |
17 tmp_dir = icqsol_utils.get_temp_dir() | 17 tmp_dir = icqsol_utils.get_temp_dir() |
18 shape_tuples = [] | 18 shape_tuples = [] |
19 shape_mgr = ShapeManager() | 19 shape_mgr = ShapeManager() |
20 | 20 |
21 # Load the shapes. | 21 # Load the shapes. |
22 for ( expression_var, dataset_path, galaxy_ext, vtk_dataset_type ) in args.shape_datasets: | 22 for (expression_var, dataset_path, galaxy_ext, vtk_dataset_type) in args.shape_datasets: |
23 # Define the file format and type. | 23 # Define the file format and type. |
24 format, file_type = icqsol_utils.get_format_and_type( galaxy_ext ) | 24 format, file_type = icqsol_utils.get_format_and_type(galaxy_ext) |
25 if format == 'vtk': | 25 if format == 'vtk': |
26 shape_mgr.setReader( file_format=format, vtk_dataset_type=vtk_dataset_type ) | 26 shape_mgr.setReader(file_format=format, vtk_dataset_type=vtk_dataset_type) |
27 else: | 27 else: |
28 shape_mgr.setReader( file_format=format ) | 28 shape_mgr.setReader(file_format=format) |
29 icqsol_path = icqsol_utils.get_input_file_path( tmp_dir, dataset_path, format ) | 29 icqsol_path = icqsol_utils.get_input_file_path(tmp_dir, dataset_path, format) |
30 shape_tuple = ( expression_var, shape_mgr.loadAsShape( icqsol_path ) ) | 30 shape_tuple = (expression_var, shape_mgr.loadAsShape(icqsol_path)) |
31 shape_tuples.append( shape_tuple ) | 31 shape_tuples.append(shape_tuple) |
32 | 32 |
33 # Define the output file format and type. | 33 # Define the output file format and type. |
34 output_format, output_file_type = icqsol_utils.get_format_and_type( args.output_vtk_type ) | 34 output_format, output_file_type = icqsol_utils.get_format_and_type(args.output_vtk_type) |
35 tmp_output_path = icqsol_utils.get_temporary_file_path( tmp_dir, output_format ) | 35 tmp_output_path = icqsol_utils.get_temporary_file_path(tmp_dir, output_format) |
36 | 36 |
37 shape_mgr.setWriter( file_format=output_format, vtk_dataset_type=icqsol_utils.POLYDATA ) | 37 shape_mgr.setWriter(file_format=output_format, vtk_dataset_type=icqsol_utils.POLYDATA) |
38 | 38 |
39 # Compose the shapes. | 39 # Compose the shapes. |
40 composite_shape = shape_mgr.composeShapes( shape_tuples, args.expression ) | 40 composite_shape = shape_mgr.composeShapes(shape_tuples, args.expression) |
41 | 41 |
42 # Save the output. | 42 # Save the output. |
43 shape_mgr.saveShape( shape=composite_shape, file_name=tmp_output_path, file_type=output_file_type ) | 43 shape_mgr.saveShape(shape=composite_shape, file_name=tmp_output_path, file_type=output_file_type) |
44 shutil.move( tmp_output_path, args.output ) | 44 shutil.move(tmp_output_path, args.output) |