Ejemplo n.º 1
0
                    type=float,
                    default=float('inf'),
                    help='Maximum edge length')
parser.add_argument('--output', dest='output', help='Output dataset')
parser.add_argument('--output_vtk_type',
                    dest='output_vtk_type',
                    help='Output VTK type')

args = parser.parse_args()

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)

# Apply the texture to the shape's surface.
vtk_poly_data = shape_mgr.addTextureToVtkPolyData(
    vtk_poly_data,
    texture_file=args.input_texture,
    max_edge_length=args.max_edge_length,
    texture_file_format=args.input_texture_file_format)

# Define the output file format and type (the output_format can only be 'vtk').
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)
Ejemplo n.º 2
0
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('--field_name', dest='field_name', help='Field name')
parser.add_argument('--field_component_index', dest='field_component_index', type=int, help='Index of field component')
parser.add_argument('--color_map', dest='color_map', help='Color map')
parser.add_argument('--output', dest='output', help='Output dataset')
parser.add_argument('--output_vtk_type', dest='output_vtk_type', help='Output VTK type')

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)
Ejemplo n.º 3
0
if args.origin_x is not None and args.origin_y is not None and args.origin_z is not None:
    origin = [args.origin_x, args.origin_y, args.origin_z]
if args.length_x is not None and args.length_y is not None and args.length_z is not None:
    lengths = [args.length_x, args.length_y, args.length_z]
if args.rotation_axis_x is not None and args.rotation_axis_y is not None and args.rotation_axis_z is not None:
    rotation_axis = [
        args.rotation_axis_x, args.rotation_axis_y, args.rotation_axis_z
    ]

# Define the output file format and type.
format, file_type = icqsol_utils.get_format_and_type(args.output_vtk_type)
tmp_dir = icqsol_utils.get_temp_dir()
cloning = True if args.create_process == 'clone' else False

# TODO: fix this to handle inputPLY files for cloning, but producing VTK POLYDATA.
shape_mgr = icqsol_utils.get_shape_manager(format, icqsol_utils.POLYDATA)

if cloning:
    # We're cloning an existing shape selected from the history.
    tmp_input_path = icqsol_utils.get_input_file_path(tmp_dir,
                                                      args.shape_input,
                                                      '.%s' % format)
    shape_to_clone = shape_mgr.loadAsShape(tmp_input_path)
    new_shape = shape_mgr.cloneShape(shape_to_clone)
    if icqsol_utils.asbool(args.rotate):
        shape_mgr.rotateShape(new_shape,
                              axis=rotation_axis,
                              angleDeg=args.rotation_degree)
    if icqsol_utils.asbool(args.translate):
        shape_mgr.translateShape(new_shape, disp=origin)
else:
Ejemplo n.º 4
0
# 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('--min_cell_area', dest='min_cell_area', type=float, help='Minimum cell area')
parser.add_argument('--output', dest='output', help='Output dataset')
parser.add_argument('--output_vtk_type', dest='output_vtk_type', help='Output VTK type')

args = parser.parse_args()

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)

# Coarsen the shape if requested.
vtk_poly_data = shape_mgr.coarsenVtkPolyData(vtk_poly_data, min_cell_area=args.min_cell_area)

# Define the output file format and type (the output_format can only be 'vtk').
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.
shape_mgr.setWriter(file_format=icqsol_utils.VTK, vtk_dataset_type=icqsol_utils.POLYDATA)

# Save the output.
Ejemplo n.º 5
0
args = parser.parse_args()

if args.origin_x is not None and args.origin_y is not None and args.origin_z is not None:
    origin = [args.origin_x, args.origin_y, args.origin_z]
if args.length_x is not None and args.length_y is not None and args.length_z is not None:
    lengths = [args.length_x, args.length_y, args.length_z]
if args.rotation_axis_x is not None and args.rotation_axis_y is not None and args.rotation_axis_z is not None:
    rotation_axis = [args.rotation_axis_x, args.rotation_axis_y, args.rotation_axis_z]

# Define the output file format and type.
format, file_type = icqsol_utils.get_format_and_type(args.output_vtk_type)
tmp_dir = icqsol_utils.get_temp_dir()
cloning = True if args.create_process == 'clone' else False

# TODO: fix this to handle inputPLY files for cloning, but producing VTK POLYDATA.
shape_mgr = icqsol_utils.get_shape_manager(format, icqsol_utils.POLYDATA)

if cloning:
    # We're cloning an existing shape selected from the history.
    tmp_input_path = icqsol_utils.get_input_file_path(tmp_dir, args.shape_input, '.%s' % format)
    shape_to_clone = shape_mgr.loadAsShape(tmp_input_path)
    new_shape = shape_mgr.cloneShape(shape_to_clone)
    if icqsol_utils.asbool(args.rotate):
        shape_mgr.rotateShape(new_shape, axis=rotation_axis, angleDeg=args.rotation_degree)
    if icqsol_utils.asbool(args.translate):
        shape_mgr.translateShape(new_shape, disp=origin)
else:
    # Create the primitive shape.
    if args.shape == 'box':
        new_shape = shape_mgr.createShape('box',
                                          origin=origin,
Ejemplo n.º 6
0
import shutil

import icqsol_utils

# Parse Command Line.
parser = argparse.ArgumentParser()
parser.add_argument('--expression', dest='expression', help='Composition expression')
parser.add_argument('--shape_dataset', dest='shape_datasets', action='append', nargs=4, help='Shape datasets selected from history')
parser.add_argument('--output', dest='output', help='Output dataset')
parser.add_argument('--output_vtk_type', dest='output_vtk_type', help='Output file format and type')

args = parser.parse_args()

tmp_dir = icqsol_utils.get_temp_dir()
shape_tuples = []
shape_mgr = icqsol_utils.get_shape_manager()

# Load the shapes.
for (expression_var, dataset_path, galaxy_ext, vtk_dataset_type) in args.shape_datasets:
    # Define the file format and type.
    format, file_type = icqsol_utils.get_format_and_type(galaxy_ext)
    if format == icqsol_utils.VTK:
        shape_mgr.setReader(file_format=format, vtk_dataset_type=vtk_dataset_type)
    else:
        shape_mgr.setReader(file_format=format)
    icqsol_path = icqsol_utils.get_input_file_path(tmp_dir, dataset_path, format)
    shape_tuple = (expression_var, shape_mgr.loadAsShape(icqsol_path))
    shape_tuples.append(shape_tuple)

# Define the output file format and type.
output_format, output_file_type = icqsol_utils.get_format_and_type(args.output_vtk_type)
Ejemplo n.º 7
0
                    help='Composition expression')
parser.add_argument('--shape_dataset',
                    dest='shape_datasets',
                    action='append',
                    nargs=4,
                    help='Shape datasets selected from history')
parser.add_argument('--output', dest='output', help='Output dataset')
parser.add_argument('--output_vtk_type',
                    dest='output_vtk_type',
                    help='Output file format and type')

args = parser.parse_args()

tmp_dir = icqsol_utils.get_temp_dir()
shape_tuples = []
shape_mgr = icqsol_utils.get_shape_manager()

# Load the shapes.
for (expression_var, dataset_path, galaxy_ext,
     vtk_dataset_type) in args.shape_datasets:
    # Define the file format and type.
    format, file_type = icqsol_utils.get_format_and_type(galaxy_ext)
    if format == icqsol_utils.VTK:
        shape_mgr.setReader(file_format=format,
                            vtk_dataset_type=vtk_dataset_type)
    else:
        shape_mgr.setReader(file_format=format)
    icqsol_path = icqsol_utils.get_input_file_path(tmp_dir, dataset_path,
                                                   format)
    shape_tuple = (expression_var, shape_mgr.loadAsShape(icqsol_path))
    shape_tuples.append(shape_tuple)