# HG changeset patch # User iuc # Date 1471979148 14400 # Node ID 88af59c4a2e50777406d6f7a2d70f7fe32d0f925 Uploaded diff -r 000000000000 -r 88af59c4a2e5 icqsol_macros.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/icqsol_macros.xml Tue Aug 23 15:05:48 2016 -0400 @@ -0,0 +1,116 @@ + + + 1.0 + + + icqsol + + + + + + + + + + + + + + + + + + + + + + + + + + + --origin_x $create_process_cond.shape_cond.origin_x + --origin_y $create_process_cond.shape_cond.origin_y + --origin_z $create_process_cond.shape_cond.origin_z + + + + + + + + --length_x $create_process_cond.shape_cond.length_x + --length_y $create_process_cond.shape_cond.length_y + --length_z $create_process_cond.shape_cond.length_z + + + + + + + + + + + + + + + + + + + + + + + + + + --radius $create_process_cond.shape_cond.radius + + + + + + + + --n_theta $create_process_cond.shape_cond.n_theta + + + + + + + + --n_phi $create_process_cond.shape_cond.n_phi + + + + + + + + + + @unpublished{None, + author = {None}, + title = {None}, + year = {None}, + eprint = {None}, + url = {https://github.com/gregvonkuster/galaxy-csg} + } + + @misc(Schroeder-Martin-Lorensen2006, + author = "Will Schroeder and + Ken Martin and + Bill Lorensen", + year = "2006", + title = "The Visualization Toolkit (4th ed.)", + publisher = "Kitware", + url = "https://en.wikipedia.org/wiki/Special:BookSources/978-1-930934-19-1") + + + + diff -r 000000000000 -r 88af59c4a2e5 icqsol_translate_shape.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/icqsol_translate_shape.py Tue Aug 23 15:05:48 2016 -0400 @@ -0,0 +1,39 @@ +#!/usr/bin/env python +import argparse +import shutil + +import icqsol_utils + +# Parse Command Line. +parser = argparse.ArgumentParser() +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('--displacement_x', dest='displacement_x', type=float, default=1.0, help='X coordinate of displacement') +parser.add_argument('--displacement_y', dest='displacement_y', type=float, default=0.0, help='Y coordinate of displacement') +parser.add_argument('--displacement_z', dest='displacement_z', type=float, default=0.0, help='Z coordinate of displacement') +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) + +# 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) diff -r 000000000000 -r 88af59c4a2e5 icqsol_translate_shape.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/icqsol_translate_shape.xml Tue Aug 23 15:05:48 2016 -0400 @@ -0,0 +1,62 @@ + + + + + icqsol_macros.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +**What it does** + +Applies translation operations to a shape by adding a displacement to each coordinate. + +* **Shape** - Shape to be translated. +* **Displacement X,Y,Z** - Coordinates of the displacement. + + + + diff -r 000000000000 -r 88af59c4a2e5 icqsol_utils.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/icqsol_utils.py Tue Aug 23 15:05:48 2016 -0400 @@ -0,0 +1,86 @@ +import os +import sys +import tempfile + +from icqsol.shapes.icqShapeManager import ShapeManager +from icqsol.bem.icqLaplaceSolver import LaplaceSolver + +PLY = 'ply' +POLYDATA = 'POLYDATA' +VTK = 'vtk' + + +def asbool(val): + return str(val).lower() in ['yes', 'true'] + + +def get_format_and_type(galaxy_ext): + # Define the output file format and type. + format = None + datatype = None + if galaxy_ext in ['vtkascii', 'vtkbinary']: + format = VTK + elif galaxy_ext in ['plyascii', 'plybinary']: + format = PLY + if galaxy_ext in ['vtkascii', 'plyascii']: + datatype = 'ascii' + elif galaxy_ext in ['vtkbinary', 'plybinary']: + datatype = 'binary' + return format, datatype + + +def get_input_file_path(tmp_dir, input_file, format): + """ + iCqSol uses file extensions (e.g., .ply, .vtk) when reading and + writing files, so the Galaxy dataset naming convention of + setting all file extensions as .dat must be handled. + """ + file_path = get_temporary_file_path(tmp_dir, format) + # Remove the file so we can create a symlink. + os.remove(file_path) + os.symlink(input_file, file_path) + return file_path + + +def get_laplace_solver(shape_data, max_edge_length=float('inf')): + return LaplaceSolver(shape_data, max_edge_length=max_edge_length) + + +def get_shape_manager(format=None, dataset_type=None): + # Instantiate a ShapeManager. + return ShapeManager(file_format=format, vtk_dataset_type=dataset_type) + + +def get_temp_dir(prefix='tmp-vtk-', dir=None): + """ + Return a temporary directory. + """ + return tempfile.mkdtemp(prefix=prefix, dir=dir) + + +def get_tempfilename(dir=None, suffix=None): + """ + Return a temporary file name. + """ + if suffix is None: + s = None + elif suffix.startswith('.'): + s = suffix + else: + s = '.%s' % suffix + fd, name = tempfile.mkstemp(suffix=s, dir=dir) + os.close(fd) + return name + + +def get_temporary_file_path(tmp_dir, file_extension): + """ + Return the path to a temporary file with a valid VTK format + file extension. + """ + return get_tempfilename(tmp_dir, file_extension) + + +def stop_err(msg): + sys.stderr.write("%s\n" % msg) + sys.exit() diff -r 000000000000 -r 88af59c4a2e5 test-data/cylinder_with_field.vtkascii --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/cylinder_with_field.vtkascii Tue Aug 23 15:05:48 2016 -0400 @@ -0,0 +1,129 @@ +# vtk DataFile Version 3.0 +vtk output +ASCII +DATASET POLYDATA +POINTS 66 float +0.5 0.2 0.3 0.5 0.2 -0.2 0.5 0.00865828 -0.16194 +0.85 0.2 -0.2 0.85 0.00865828 -0.16194 0.85 0.2 0.3 +0.5 -0.153553 -0.0535534 0.85 -0.153553 -0.0535534 0.5 -0.26194 0.108658 +0.85 -0.26194 0.108658 0.5 -0.3 0.3 0.85 -0.3 0.3 +0.5 -0.26194 0.491342 0.85 -0.26194 0.491342 0.5 -0.153553 0.653553 +0.85 -0.153553 0.653553 0.5 0.00865828 0.76194 0.85 0.00865828 0.76194 +0.5 0.2 0.8 0.85 0.2 0.8 0.5 0.391342 0.76194 +0.85 0.391342 0.76194 0.5 0.553553 0.653553 0.85 0.553553 0.653553 +0.5 0.66194 0.491342 0.85 0.66194 0.491342 0.5 0.7 0.3 +0.85 0.7 0.3 0.5 0.66194 0.108658 0.85 0.66194 0.108658 +0.5 0.553553 -0.0535534 0.85 0.553553 -0.0535534 0.5 0.391342 -0.16194 +0.85 0.391342 -0.16194 0.5 0.2 -0.2 0.5 0.00865828 -0.16194 +0.85 0.2 -0.2 0.85 0.00865828 -0.16194 0.5 -0.153553 -0.0535534 +0.85 -0.153553 -0.0535534 0.5 -0.26194 0.108658 0.85 -0.26194 0.108658 +0.5 -0.3 0.3 0.85 -0.3 0.3 0.5 -0.26194 0.491342 +0.85 -0.26194 0.491342 0.5 -0.153553 0.653553 0.85 -0.153553 0.653553 +0.5 0.00865828 0.76194 0.85 0.00865828 0.76194 0.5 0.2 0.8 +0.85 0.2 0.8 0.5 0.391342 0.76194 0.85 0.391342 0.76194 +0.5 0.553553 0.653553 0.85 0.553553 0.653553 0.5 0.66194 0.491342 +0.85 0.66194 0.491342 0.5 0.7 0.3 0.85 0.7 0.3 +0.5 0.66194 0.108658 0.85 0.66194 0.108658 0.5 0.553553 -0.0535534 +0.85 0.553553 -0.0535534 0.5 0.391342 -0.16194 0.85 0.391342 -0.16194 + +POLYGONS 64 256 +3 0 1 2 +3 4 35 34 +3 34 3 4 +3 5 37 36 +3 0 2 6 +3 7 38 35 +3 35 4 7 +3 5 39 37 +3 0 6 8 +3 9 40 38 +3 38 7 9 +3 5 41 39 +3 0 8 10 +3 11 42 40 +3 40 9 11 +3 5 43 41 +3 0 10 12 +3 13 44 42 +3 42 11 13 +3 5 45 43 +3 0 12 14 +3 15 46 44 +3 44 13 15 +3 5 47 45 +3 0 14 16 +3 17 48 46 +3 46 15 17 +3 5 49 47 +3 0 16 18 +3 19 50 48 +3 48 17 19 +3 5 51 49 +3 0 18 20 +3 21 52 50 +3 50 19 21 +3 5 53 51 +3 0 20 22 +3 23 54 52 +3 52 21 23 +3 5 55 53 +3 0 22 24 +3 25 56 54 +3 54 23 25 +3 5 57 55 +3 0 24 26 +3 27 58 56 +3 56 25 27 +3 5 59 57 +3 0 26 28 +3 29 60 58 +3 58 27 29 +3 5 61 59 +3 0 28 30 +3 31 62 60 +3 60 29 31 +3 5 63 61 +3 0 30 32 +3 33 64 62 +3 62 31 33 +3 5 65 63 +3 0 32 1 +3 3 34 64 +3 64 33 3 +3 5 36 65 + +POINT_DATA 66 +NORMALS Normals float +-1 0 0 -1 0 0 -1 0 0 +0 0.0661589 -0.997809 0 -0.320722 -0.947173 1 0 0 +-1 0 0 0 -0.658776 -0.752339 -1 0 0 +0 -0.896537 -0.442968 -1 0 0 0 -0.997809 -0.0661589 +-1 0 0 0 -0.947173 0.320722 -1 0 0 +0 -0.752339 0.658776 -1 0 0 0 -0.442968 0.896537 +-1 0 0 0 -0.0661589 0.997809 -1 0 0 +0 0.320722 0.947173 -1 0 0 0 0.658776 0.752339 +-1 0 0 0 0.896538 0.442968 -1 0 0 +0 0.997809 0.0661589 -1 0 0 0 0.947173 -0.320722 +-1 0 0 0 0.752339 -0.658776 -1 0 0 +0 0.442968 -0.896537 0 -0.0661588 -0.997809 0 -0.442968 -0.896537 +1 0 0 1 0 0 0 -0.752339 -0.658776 +1 0 0 0 -0.947173 -0.320722 1 0 0 +0 -0.997809 0.0661589 1 0 0 0 -0.896537 0.442968 +1 0 0 0 -0.658776 0.752339 1 0 0 +0 -0.320722 0.947173 1 0 0 0 0.0661589 0.997809 +1 0 0 0 0.442968 0.896537 1 0 0 +0 0.752339 0.658776 1 0 0 0 0.947173 0.320722 +1 0 0 0 0.997809 -0.0661589 1 0 0 +0 0.896538 -0.442968 1 0 0 0 0.658776 -0.752339 +1 0 0 0 0.320722 -0.947173 1 0 0 + +FIELD FieldData 1 +my_field 1 66 double +1.19292 1.19292 1.20573 1.3179 1.62563 1.3179 1.21993 1.45051 1.15534 +1.16035 1.13279 1.0751 1.15534 1.16035 1.21993 1.45051 1.20573 1.62563 +1.19292 1.3179 1.0824 0.902456 1.00774 0.681662 0.967386 0.577466 0.954762 +0.547018 0.967386 0.577466 1.00774 0.681662 1.0824 0.902456 1.19292 1.20573 +1.3179 1.62563 1.21993 1.45051 1.15534 1.16035 1.13279 1.0751 1.15534 +1.16035 1.21993 1.45051 1.20573 1.62563 1.19292 1.3179 1.0824 0.902456 +1.00774 0.681662 0.967386 0.577466 0.954762 0.547018 0.967386 0.577466 1.00774 +0.681662 1.0824 0.902456 diff -r 000000000000 -r 88af59c4a2e5 test-data/translated_cylinder_with_field.vtkascii --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/translated_cylinder_with_field.vtkascii Tue Aug 23 15:05:48 2016 -0400 @@ -0,0 +1,129 @@ +# vtk DataFile Version 4.0 +vtk output +ASCII +DATASET POLYDATA +POINTS 66 float +0.5 1.2 -0.2 0.5 1.2 -0.7 0.5 1.00866 -0.66194 +0.85 1.2 -0.7 0.85 1.00866 -0.66194 0.85 1.2 -0.2 +0.5 0.846447 -0.553553 0.85 0.846447 -0.553553 0.5 0.73806 -0.391342 +0.85 0.73806 -0.391342 0.5 0.7 -0.2 0.85 0.7 -0.2 +0.5 0.73806 -0.00865799 0.85 0.73806 -0.00865799 0.5 0.846447 0.153553 +0.85 0.846447 0.153553 0.5 1.00866 0.26194 0.85 1.00866 0.26194 +0.5 1.2 0.3 0.85 1.2 0.3 0.5 1.39134 0.26194 +0.85 1.39134 0.26194 0.5 1.55355 0.153553 0.85 1.55355 0.153553 +0.5 1.66194 -0.00865799 0.85 1.66194 -0.00865799 0.5 1.7 -0.2 +0.85 1.7 -0.2 0.5 1.66194 -0.391342 0.85 1.66194 -0.391342 +0.5 1.55355 -0.553553 0.85 1.55355 -0.553553 0.5 1.39134 -0.66194 +0.85 1.39134 -0.66194 0.5 1.2 -0.7 0.5 1.00866 -0.66194 +0.85 1.2 -0.7 0.85 1.00866 -0.66194 0.5 0.846447 -0.553553 +0.85 0.846447 -0.553553 0.5 0.73806 -0.391342 0.85 0.73806 -0.391342 +0.5 0.7 -0.2 0.85 0.7 -0.2 0.5 0.73806 -0.00865799 +0.85 0.73806 -0.00865799 0.5 0.846447 0.153553 0.85 0.846447 0.153553 +0.5 1.00866 0.26194 0.85 1.00866 0.26194 0.5 1.2 0.3 +0.85 1.2 0.3 0.5 1.39134 0.26194 0.85 1.39134 0.26194 +0.5 1.55355 0.153553 0.85 1.55355 0.153553 0.5 1.66194 -0.00865799 +0.85 1.66194 -0.00865799 0.5 1.7 -0.2 0.85 1.7 -0.2 +0.5 1.66194 -0.391342 0.85 1.66194 -0.391342 0.5 1.55355 -0.553553 +0.85 1.55355 -0.553553 0.5 1.39134 -0.66194 0.85 1.39134 -0.66194 + +POLYGONS 64 256 +3 0 1 2 +3 4 35 34 +3 34 3 4 +3 5 37 36 +3 0 2 6 +3 7 38 35 +3 35 4 7 +3 5 39 37 +3 0 6 8 +3 9 40 38 +3 38 7 9 +3 5 41 39 +3 0 8 10 +3 11 42 40 +3 40 9 11 +3 5 43 41 +3 0 10 12 +3 13 44 42 +3 42 11 13 +3 5 45 43 +3 0 12 14 +3 15 46 44 +3 44 13 15 +3 5 47 45 +3 0 14 16 +3 17 48 46 +3 46 15 17 +3 5 49 47 +3 0 16 18 +3 19 50 48 +3 48 17 19 +3 5 51 49 +3 0 18 20 +3 21 52 50 +3 50 19 21 +3 5 53 51 +3 0 20 22 +3 23 54 52 +3 52 21 23 +3 5 55 53 +3 0 22 24 +3 25 56 54 +3 54 23 25 +3 5 57 55 +3 0 24 26 +3 27 58 56 +3 56 25 27 +3 5 59 57 +3 0 26 28 +3 29 60 58 +3 58 27 29 +3 5 61 59 +3 0 28 30 +3 31 62 60 +3 60 29 31 +3 5 63 61 +3 0 30 32 +3 33 64 62 +3 62 31 33 +3 5 65 63 +3 0 32 1 +3 3 34 64 +3 64 33 3 +3 5 36 65 + +POINT_DATA 66 +NORMALS Normals float +-1 0 0 -1 0 0 -1 0 0 +0 0.0661583 -0.997809 0 -0.320722 -0.947173 1 0 0 +-1 0 0 0 -0.658776 -0.752339 -1 0 0 +0 -0.896537 -0.442969 -1 0 0 0 -0.997809 -0.0661584 +-1 0 0 0 -0.947173 0.320723 -1 0 0 +0 -0.752338 0.658778 -1 0 0 0 -0.44297 0.896537 +-1 0 0 0 -0.0661585 0.997809 -1 0 0 +0 0.320723 0.947173 -1 0 0 0 0.658777 0.752338 +-1 0 0 0 0.896536 0.44297 -1 0 0 +0 0.997809 0.0661585 -1 0 0 0 0.947173 -0.320723 +-1 0 0 0 0.752338 -0.658777 -1 0 0 +0 0.442969 -0.896537 0 -0.0661585 -0.997809 0 -0.442969 -0.896537 +1 0 0 1 0 0 0 -0.752338 -0.658777 +1 0 0 0 -0.947173 -0.320722 1 0 0 +0 -0.997809 0.0661584 1 0 0 0 -0.896536 0.44297 +1 0 0 0 -0.658777 0.752338 1 0 0 +0 -0.320723 0.947173 1 0 0 0 0.0661583 0.997809 +1 0 0 0 0.44297 0.896536 1 0 0 +0 0.752338 0.658777 1 0 0 0 0.947173 0.320723 +1 0 0 0 0.997809 -0.0661585 1 0 0 +0 0.896537 -0.44297 1 0 0 0 0.658777 -0.752338 +1 0 0 0 0.320722 -0.947173 1 0 0 + +FIELD FieldData 1 +my_field 1 66 double +1.19292 1.19292 1.20573 1.3179 1.62563 1.3179 1.21993 1.45051 1.15534 +1.16035 1.13279 1.0751 1.15534 1.16035 1.21993 1.45051 1.20573 1.62563 +1.19292 1.3179 1.0824 0.902456 1.00774 0.681662 0.967386 0.577466 0.954762 +0.547018 0.967386 0.577466 1.00774 0.681662 1.0824 0.902456 1.19292 1.20573 +1.3179 1.62563 1.21993 1.45051 1.15534 1.16035 1.13279 1.0751 1.15534 +1.16035 1.21993 1.45051 1.20573 1.62563 1.19292 1.3179 1.0824 0.902456 +1.00774 0.681662 0.967386 0.577466 0.954762 0.547018 0.967386 0.577466 1.00774 +0.681662 1.0824 0.902456