Пример #1
0
	def test_utils_write_modified_box(self):
		params = pars.FFDParameters()
		params.read_parameters(filename='tests/test_datasets/parameters_test_ffd_sphere.prm')
		
		outfilename = 'tests/test_datasets/box_test_sphere.vtk'
		
		ut.write_bounding_box(params, outfilename)
		os.remove(outfilename)
Пример #2
0
	def test_utils_write_modified_box(self):
		params = pars.FFDParameters()
		params.read_parameters(filename='tests/test_datasets/parameters_test_ffd_sphere.prm')
		
		outfilename = 'tests/test_datasets/box_test_sphere.vtk'
		
		ut.write_bounding_box(params, outfilename)
		os.remove(outfilename)
Пример #3
0
	def test_utils_check_vtk_modified_box(self):
		params = pars.FFDParameters()
		params.read_parameters(filename='tests/test_datasets/parameters_test_ffd_sphere.prm')
		
		outfilename = 'tests/test_datasets/box_test_sphere.vtk'
		if vtk.VTK_MAJOR_VERSION <= 5:
			outfilename_expected = 'tests/test_datasets/box_modified_test_sphere_true_version5.vtk'
		else:
			outfilename_expected = 'tests/test_datasets/box_modified_test_sphere_true_version6.vtk'
		
		ut.write_bounding_box(params, outfilename)
		
		self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
		os.remove(outfilename)
Пример #4
0
	def test_utils_check_vtk_modified_box(self):
		params = pars.FFDParameters()
		params.read_parameters(filename='tests/test_datasets/parameters_test_ffd_sphere.prm')
		
		outfilename = 'tests/test_datasets/box_test_sphere.vtk'
		if vtk.VTK_MAJOR_VERSION <= 5:
			outfilename_expected = 'tests/test_datasets/box_modified_test_sphere_true_version5.vtk'
		else:
			outfilename_expected = 'tests/test_datasets/box_modified_test_sphere_true_version6.vtk'
		
		ut.write_bounding_box(params, outfilename)
		
		self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
		os.remove(outfilename)
Пример #5
0
# Create FFDParameters and move a point
params = pg.params.FFDParameters.null_morphing_box(
    n_control_points=[3, 2, 2],
    length_box=[xmax - xmin, ymax - ymin, zmax - zmin],
    origin_box=[xmin, ymin, zmin])

# Move point symmetrically, manual symmetry enforcement
# params.move_point(i=1, j=1, k=1, direction="Y", displacement=1)
# params.move_point(i=1, j=0, k=1, direction="Y", displacement=-1)

# Move point symmetrically, automatic symmetry enforcement
params.move_point(i=1, j=1, k=1, direction="Y", displacement=1, symmetry="XZ")

write_bounding_box(params,
                   './example_hull_stl_dtc/params.vtk',
                   write_deformed=False)
write_bounding_box(params,
                   './example_hull_stl_dtc/params_deformed.vtk',
                   write_deformed=True)

# Deform
free_form = pg.freeform.FFD(params, mesh_points)
free_form.perform()
new_mesh_points = free_form.modified_mesh_points
stl_handler.write(new_mesh_points, './example_hull_stl_dtc/DTC-scaled_mod.stl')

# Visualize deformation
# stl_handler.plot(plot_file='./example_hull_stl/SYSSER01_Z0WL_mod.stl')
stl_handler.show(show_file='./example_hull_stl_dtc/DTC-scaled_mod.stl')
Пример #6
0
#!/usr/bin/env python
# coding: utf-8
r"""Tutorial 1 STL example"""

import pygem as pg
from pygem.utils import write_bounding_box

# Parameters that DO modify the shape
params = pg.params.FFDParameters()
params.read_parameters(
    filename='./tutorial_1_stl/parameters_test_ffd_sphere.prm')

# Create VTK files to compare the undeformed and deformed lattice in Paraview
write_bounding_box(params, './tutorial_1_stl/params.vtk', write_deformed=False)
write_bounding_box(params,
                   './tutorial_1_stl/params_deformed.vtk',
                   write_deformed=True)

# The params print themselves nicely
print(params)

# Parameters that DO NOT modify the shape
params_null = pg.params.FFDParameters()
params_null.read_parameters(filename='./tutorial_1_stl/null.prm')

# Read the STL file
stl_handler = pg.stlhandler.StlHandler()
mesh_points = stl_handler.parse('./tutorial_1_stl/test_sphere.stl')

# Display the unmodified sphere in 2 possible ways
stl_handler.plot(plot_file='./tutorial_1_stl/test_sphere.stl')