예제 #1
0
print("  Number of subdivisions: {0:d}".format(num_subdiv))
print("  Subdivision method: {0:s}".format(subdiv_method))

# Get control points.
control_points = path.get_control_points()
print("Number of control points: {0:d}".format(len(control_points)))

# Get path curve.
curve_polydata = path.get_curve_polydata()
print("Curve polydata: ")
print("  Number of points: {0:d}".format(curve_polydata.GetNumberOfPoints()))

# Get path curve frame.
curve_frame = path.get_curve_frame(1)
print("Curve frame: ")
print("  Position: {0:s}".format(str(curve_frame.position)))
print("  Normal: {0:s}".format(str(curve_frame.normal)))
print("  Tangent: {0:s}".format(str(curve_frame.tangent)))

# Create graphics window.
win_width = 500
win_height = 500
renderer, renderer_window = gr.init_graphics(win_width, win_height)

# Show path.
gr.create_path_geometry(renderer, path)
#gr.add_geometry(renderer, curve_polydata)

# Display window.
gr.display(renderer_window)
print("Path at time 0:")
aorta_path = paths.get_path(0)
control_points = aorta_path.get_control_points()
print("  Number of control points: {0:d}".format(len(control_points)))
curve_points = aorta_path.get_curve_points()
print("  Number of curve points: {0:d}".format(len(curve_points)))
#
point = aorta_path.get_curve_point(20)
print("  Point 20: {0:s}".format(str(point)))
tangent = aorta_path.get_curve_tangent(20)
print("  Tangent 20: {0:s}".format(str(tangent)))
normal = aorta_path.get_curve_normal(20)
print("  Normal 20: {0:s}".format(str(normal)))
#
num_subdiv = aorta_path.get_num_subdivisions()
print("  Number of subdivisions: {0:d}".format(num_subdiv))
subdiv_method = aorta_path.get_subdivision_method()
print("  Subdivision method: {0:s}".format(subdiv_method))

## Create renderer and graphics window.
win_width = 500
win_height = 500
renderer, renderer_window = gr.init_graphics(win_width, win_height)

# Create path geometry.
gr.create_path_geometry(renderer, aorta_path)
#gr.create_path_geometry(renderer, aorta_path, show_points=True)

# Display window.
gr.display(renderer_window)
#
print("Path:")
num_subdiv = path.get_num_subdivisions()
subdiv_method = path.get_subdivision_method()
print("  Number of subdivisions: {0:d}".format(num_subdiv))
print("  Subdivision method: {0:s}".format(subdiv_method))

## Get control points.
control_points = path.get_control_points()
print("  Number of control points: {0:d}".format(len(control_points)))

## Get path curve points.
curve_points = path.get_curve_points()
print("  Number of curve points: {0:d}".format(len(curve_points)))
# Show path.
gr.create_path_geometry(renderer, path)

## Set subdivision method.
#
# SubdivisionMethod: SPACING, SUBDIVISION or TOTAL.
#
# Default is TOTAL.
#
print("\nPath: set new subdivision method: ")
#
#path.set_subdivision_method(method=sv.path.SubdivisionMethod.SPACING, spacing=0.5)
#path.set_subdivision_method(method=sv.path.SubdivisionMethod.SUBDIVISION, num_div=10)
path.set_subdivision_method(method=sv.pathplanning.SubdivisionMethod.TOTAL,
                            num_total=20)
#
num_subdiv = path.get_num_subdivisions()
예제 #4
0
curve_points = aorta_path.get_curve_points()
print("  Number of curve points: {0:d}".format(len(curve_points)))

## Smooth the path.
print("Smoothed the aorta path:")
sample_rate = 20
num_modes = 40
smooth_control_pts = True
smooth_control_pts = False
print("  sample_rate: " + str(sample_rate))
print("  num_modes: " + str(num_modes))
smoothed_path = aorta_path.smooth(sample_rate=sample_rate, num_modes=num_modes, smooth_control_pts=smooth_control_pts)
control_points = smoothed_path.get_control_points()
curve_points = smoothed_path.get_curve_points()
print("  Number of control points: {0:d}".format(len(control_points)))
print("  Number of curve points: {0:d}".format(len(curve_points)))

## Create renderer and graphics window.
win_width = 500
win_height = 500
renderer, renderer_window = gr.init_graphics(win_width, win_height)

# Create path geometry.
gr.create_path_geometry(renderer, aorta_path)
gr.create_path_geometry(renderer, smoothed_path, line_color=[0.6,0.0,0.0], marker_color=[0.0,0.6,0.0])

# Display window.
gr.display(renderer_window)