diff --git a/src/PythonicAPI.md b/src/PythonicAPI.md index 03764a74fc436a084772552414a0809517418b8a..94625790c34f061e91a88db847d3aa347a2ac1a0 100644 --- a/src/PythonicAPI.md +++ b/src/PythonicAPI.md @@ -72,6 +72,7 @@ This Python script, [SelectExamples](../PythonicAPI/Utilities/SelectExamples), w | Example Name | Description | Image | | -------------- | ------------- | ------- | [WritePLY](/PythonicAPI/IO/WritePLY) | +[WriteSTL](/PythonicAPI/IO/WriteSTL) | #### VTK Formats @@ -147,6 +148,7 @@ This Python script, [SelectExamples](../PythonicAPI/Utilities/SelectExamples), w [ImplicitQuadric](/PythonicAPI/ImplicitFunctions/ImplicitQuadric) | Create an ellipsoid using an implicit quadric [ImplicitSphere](/PythonicAPI/ImplicitFunctions/ImplicitSphere) | Demonstrate sampling of a sphere implicit function [ImplicitSphere1](/PythonicAPI/ImplicitFunctions/ImplicitSphere1) | Demonstrate sampling of a sphere implicit function +[Lorenz](/PythonicAPI/Visualization/Lorenz) | Visualizing a Lorenz strange attractor by integrating the Lorenz equations in a volume. [SampleFunction](/PythonicAPI/ImplicitFunctions/SampleFunction) | Sample and visualize an implicit function. [SmoothDiscreteFlyingEdges3D](/PythonicAPI/Modelling/SmoothDiscreteFlyingEdges3D) | Generate smooth surfaces from labeled data. @@ -317,6 +319,7 @@ This section includes ?vtkUnstructuredGrid?. | -------------- | ------------- | ------- | [ColoredSphere](/PythonicAPI/Rendering/ColoredSphere) | A simple sphere. [GradientBackground](/PythonicAPI/Rendering/GradientBackground) | Demonstrates the background shading options. +[MotionBlur](/PythonicAPI/Rendering/MotionBlur) | Example of motion blur. [OutlineGlowPass](/PythonicAPI/Rendering/OutlineGlowPass) | Demonstrates how to render a object in a scene with a glowing outline. [PBR_Skybox](/PythonicAPI/Rendering/PBR_Skybox) | Demonstrates physically based rendering, a skybox and image based lighting. [PBR_Skybox_Texturing](/PythonicAPI/Rendering/PBR_Skybox_Texturing) | Demonstrates physically based rendering, a skybox, image based lighting and texturing. @@ -422,6 +425,8 @@ See [this tutorial](http://www.vtk.org/Wiki/VTK/Tutorials/3DDataTypes) for a bri [CompassWidget](/PythonicAPI/Widgets/CompassWidget) | Draws an interactive compass. [ContourWidget](/PythonicAPI/Widgets/ContourWidget) | Draw a contour (line) which can be deformed by the user. [ImplicitPlaneWidget2](/PythonicAPI/Widgets/ImplicitPlaneWidget2) | Clip polydata with an implicit plane. +[SphereWidget](/PythonicAPI/Widgets/SphereWidget) | This 3D widget defines a sphere that can be interactively placed in a scene. +[SplineWidget](/PythonicAPI/Widgets/SplineWidget) | This example shows how to use vtkSplineWidget with a callback being used to get the length of the spline widget. ## Plotting diff --git a/src/PythonicAPI/IO/ReadSLC.py b/src/PythonicAPI/IO/ReadSLC.py index 7cfba5a138d72bc1a2160991d22f5c4994380c09..606bb82558aa3a27a4323d57007f3616570e5dd7 100755 --- a/src/PythonicAPI/IO/ReadSLC.py +++ b/src/PythonicAPI/IO/ReadSLC.py @@ -29,7 +29,7 @@ def main(): mapper = vtkPolyDataMapper() reader >> mapper - # Implementing Marching Cubes Algorithm to create the surface using vtkContourFilter object. + # Create the surface using a vtkContourFilter object. contour_filter = vtkContourFilter() # Change the range(2nd and 3rd Parameter) based on your # requirement. The recommended value for 1st parameter is greater than 1 @@ -63,7 +63,6 @@ def main(): # Assign actor to the renderer. renderer.AddActor(actor) renderer.AddActor(outline_actor) - # renderer.SetBackground(colors.GetColor3d('SlateGray')) # Pick a good view cam1 = renderer.GetActiveCamera() diff --git a/src/PythonicAPI/IO/WriteSTL.md b/src/PythonicAPI/IO/WriteSTL.md new file mode 100644 index 0000000000000000000000000000000000000000..bd058a1285f3c4d85624551c0e2e64faa47ba227 --- /dev/null +++ b/src/PythonicAPI/IO/WriteSTL.md @@ -0,0 +1,3 @@ +### Description + +An [STL file](https://en.wikipedia.org/wiki/STL_(file_format)) describes a triangulated three-dimensional surface by the unit normal and vertices (ordered by the right-hand rule) of the triangles. This example saves 3D geometric data stored in a vtkPolyData object to an STL file using vtkSTLWriter. diff --git a/src/PythonicAPI/IO/WriteSTL.py b/src/PythonicAPI/IO/WriteSTL.py new file mode 100755 index 0000000000000000000000000000000000000000..25a82a603f05e46983642a555121b3fa39a79af3 --- /dev/null +++ b/src/PythonicAPI/IO/WriteSTL.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 + +# noinspection PyUnresolvedReferences +import vtkmodules.vtkInteractionStyle +# noinspection PyUnresolvedReferences +import vtkmodules.vtkRenderingOpenGL2 +from vtkmodules.vtkCommonColor import vtkNamedColors +from vtkmodules.vtkFiltersSources import vtkSphereSource +from vtkmodules.vtkIOGeometry import ( + vtkSTLReader, + vtkSTLWriter +) +from vtkmodules.vtkRenderingCore import ( + vtkActor, + vtkPolyDataMapper, + vtkRenderWindow, + vtkRenderWindowInteractor, + vtkRenderer +) + + +def get_program_parameters(): + import argparse + description = 'Generate image data, then write a .stl file.' + epilogue = ''' + ''' + parser = argparse.ArgumentParser(description=description, epilog=epilogue) + parser.add_argument('filename', help='A required stl filename.', nargs='?', + const='TestWriteSTL.ply', + type=str, default='TestWriteSTL.ply') + args = parser.parse_args() + return args.filename + + +def main(): + colors = vtkNamedColors() + + filename = get_program_parameters() + + sphere_source = vtkSphereSource() + + # Write the stl file to disk. + stl_writer = vtkSTLWriter(file_name=filename) + sphere_source >> stl_writer + stl_writer.Write() + + # Read and display for verification. + reader = vtkSTLReader(file_name=filename) + + mapper = vtkPolyDataMapper() + reader >> mapper + + actor = vtkActor(mapper=mapper) + actor.property.color = colors.GetColor3d('MistyRose') + + # Create a renderer, rendering window and interactor. + ren = vtkRenderer(background=colors.GetColor3d('cobalt_green')) + ren_win = vtkRenderWindow(window_name='WriteSTL') + ren_win.AddRenderer(ren) + iren = vtkRenderWindowInteractor() + iren.render_window = ren_win + + # Assign actor to the renderer. + ren.AddActor(actor) + + # Enable user interface interactor. + iren.Initialize() + ren_win.Render() + iren.Start() + + +if __name__ == '__main__': + main() diff --git a/src/PythonicAPI/Rendering/MotionBlur.md b/src/PythonicAPI/Rendering/MotionBlur.md new file mode 100644 index 0000000000000000000000000000000000000000..5c246117e910005c532bf61127c650f467e1da90 --- /dev/null +++ b/src/PythonicAPI/Rendering/MotionBlur.md @@ -0,0 +1,6 @@ +### Description + +Example of motion blur. + +!!! info + See [Figure 7-36](../../../VTKBook/07Chapter7/#Figure%207-36) in [Chapter 7](../../../VTKBook/07Chapter7) in the [VTK Textbook](../../../VTKBook/01Chapter1/). diff --git a/src/PythonicAPI/Rendering/MotionBlur.py b/src/PythonicAPI/Rendering/MotionBlur.py new file mode 100755 index 0000000000000000000000000000000000000000..1314970cf534f07c1863c54aa91479470dc03730 --- /dev/null +++ b/src/PythonicAPI/Rendering/MotionBlur.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python3 + +# noinspection PyUnresolvedReferences +import vtkmodules.vtkInteractionStyle +# noinspection PyUnresolvedReferences +import vtkmodules.vtkRenderingOpenGL2 +from vtkmodules.vtkCommonColor import vtkNamedColors +from vtkmodules.vtkIOPLY import vtkPLYReader +from vtkmodules.vtkRenderingCore import ( + vtkActor, + vtkPolyDataMapper, + vtkRenderWindow, + vtkRenderWindowInteractor, + vtkRenderer +) +from vtkmodules.vtkRenderingOpenGL2 import ( + vtkRenderStepsPass, + vtkSimpleMotionBlurPass +) + + +def main(): + file_name = get_program_parameters() + + colors = vtkNamedColors() + + colors.SetColor('A1Diff', 255, 204, 77, 255) + colors.SetColor('A2Amb', 51, 51, 255, 255) + colors.SetColor('A2Diff', 51, 255, 204, 255) + colors.SetColor('A3Amb', 128, 166, 255, 255) + colors.SetColor('Bkg', 77, 102, 153, 255) + + renderer = vtkRenderer(background=colors.GetColor3d('Bkg')) + render_window = vtkRenderWindow(size=(500, 500), window_name='MotionBlur') + render_window.AddRenderer(renderer) + iren = vtkRenderWindowInteractor() + iren.render_window = render_window + + reader = vtkPLYReader(file_name=file_name) + + mapper = vtkPolyDataMapper() + reader >> mapper + + # Create three models using the same mapper. + + actor = vtkActor(mapper=mapper) + actor.property.ambient_color = colors.GetColor3d('Red') + actor.property.diffuse_color = colors.GetColor3d('A1Diff') + actor.property.specular = 0.0 + actor.property.diffuse = 0.5 + actor.property.ambient = 0.3 + actor.position = (-0.1, 0.0, -0.1) + renderer.AddActor(actor) + + actor = vtkActor(mapper=mapper) + actor.property.ambient_color = colors.GetColor3d('A2Amb') + actor.property.diffuse_color = colors.GetColor3d('A2Diff') + actor.property.specular_color = colors.GetColor3d('Black') + actor.property.specular = 0.2 + actor.property.diffuse = 0.9 + actor.property.ambient = 0.1 + actor.property.specular_power = 10.0 + renderer.AddActor(actor) + + actor = vtkActor(mapper=mapper) + actor.property.diffuse_color = colors.GetColor3d('A3Amb') + actor.property.specular_color = colors.GetColor3d('White') + actor.property.specular = 0.7 + actor.property.diffuse = 0.4 + actor.property.specular_power = 60.0 + actor.position = (0.1, 0.0, 0.1) + renderer.AddActor(actor) + + render_window.SetMultiSamples(0) + + # Create the basic VTK render steps. + basic_passes = vtkRenderStepsPass() + + motion = vtkSimpleMotionBlurPass() + motion.SetDelegatePass(basic_passes) + + # Tell the renderer to use our render pass pipeline. + renderer.SetPass(motion) + + num_renders = 30 + + renderer.active_camera.position = (0, 0, -1) + renderer.active_camera.focal_point = (0, 0, 0) + renderer.active_camera.view_up = (0, 1, 0) + renderer.ResetCamera() + renderer.active_camera.Azimuth(15.0) + renderer.active_camera.Zoom(1.2) + + render_window.Render() + + for i in range(0, num_renders): + renderer.active_camera.Azimuth(10.0 / num_renders) + renderer.active_camera.Elevation(10.0 / num_renders) + render_window.Render() + + iren.Start() + + +def get_program_parameters(): + import argparse + description = 'Example of motion blur.' + epilogue = ''' + ''' + parser = argparse.ArgumentParser(description=description, epilog=epilogue, + formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument('filename', help='Armadillo.ply.') + args = parser.parse_args() + return args.filename + + +if __name__ == '__main__': + main() diff --git a/src/PythonicAPI/Snippets/VTKDataClasses.md b/src/PythonicAPI/Snippets/VTKDataClasses.md index 7aef23a6744c10542ba1562f166ea845974a97c0..249f706bb9f0df5b8af5c55caa0628c38c7cd581 100644 --- a/src/PythonicAPI/Snippets/VTKDataClasses.md +++ b/src/PythonicAPI/Snippets/VTKDataClasses.md @@ -482,6 +482,20 @@ class RuledSurfaceFilter: VTK_RULED_MODE_POINT_WALK: int = 1 ``` + +### SphereWidget + +``` Python +@dataclass(frozen=True) +class SphereWidget: + @dataclass(frozen=True) + class Representation: + VTK_SPHERE_OFF: int = 0 + VTK_SPHERE_WIREFRAME: int = 1 + VTK_SPHERE_SURFACE: int = 2 + +``` + ### SpiderPlotActor ``` Python diff --git a/src/PythonicAPI/Visualization/FroggieView.py b/src/PythonicAPI/Visualization/FroggieView.py index 87e3f3c422e4e0124754cce0e7d5b9a984a7397b..878f93c2a492b9db30ba18df78cddd99611951a3 100755 --- a/src/PythonicAPI/Visualization/FroggieView.py +++ b/src/PythonicAPI/Visualization/FroggieView.py @@ -134,9 +134,9 @@ def main(fn, select_figure, no_sliders, chosen_tissues): ren_win = vtkRenderWindow(window_name='FroggieView') ren_win.AddRenderer(ren) iren = vtkRenderWindowInteractor() - iren.SetRenderWindow(ren_win) + iren.render_window = ren_win style = vtkInteractorStyleTrackballCamera() - iren.SetInteractorStyle(style) + iren.interactor_style = style sliders = dict() left_step_size = 1.0 / 9 diff --git a/src/PythonicAPI/Visualization/Lorenz.py b/src/PythonicAPI/Visualization/Lorenz.py new file mode 100755 index 0000000000000000000000000000000000000000..f2d46ba28f3ba11c1559709c6b031d6c952ceeaa --- /dev/null +++ b/src/PythonicAPI/Visualization/Lorenz.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python3 + +""" +Create an iso-surface of the Lorenz attractor. + +Here we visualize a Lorenz strange attractor by integrating the Lorenz equations in a volume. +The number of visits in each voxel is recorded as a scalar function. +The surface is extracted via a contour filter using a visit value of 50. +The number of integration steps is 10 million, in a volume of dimensions 200 x 200 x 200. +The surface roughness is caused by the discrete nature of the evaluation function. + +""" +# noinspection PyUnresolvedReferences +import vtkmodules.vtkInteractionStyle +# noinspection PyUnresolvedReferences +import vtkmodules.vtkRenderingOpenGL2 +from vtkmodules.vtkCommonColor import vtkNamedColors +from vtkmodules.vtkCommonCore import ( + vtkMinimalStandardRandomSequence, + vtkShortArray +) +from vtkmodules.vtkCommonDataModel import vtkStructuredPoints +from vtkmodules.vtkFiltersCore import vtkContourFilter +from vtkmodules.vtkRenderingCore import ( + vtkActor, + vtkPolyDataMapper, + vtkRenderWindow, + vtkRenderWindowInteractor, + vtkRenderer +) + + +def main(): + colors = vtkNamedColors() + + Pr = 10.0 # The Lorenz parameters + b = 2.667 + r = 28.0 + # x = 0.0 + # y = 0.0 + # z = 0.0 # starting (and current) x, y, z + h = 0.01 # integration step size + resolution = 200 # slice resolution + iterations = 10000000 # number of iterations + xmin = -30.0 # x, y, z range for voxels + xmax = 30.0 + ymin = -30.0 + ymax = 30.0 + zmin = -10.0 + zmax = 60.0 + + # Take a stab at an integration step size. + dx = resolution / (xmax - xmin) + dy = resolution / (ymax - ymin) + dz = resolution / (zmax - zmin) + + s = 'The Lorenz Attractor\n' + s += f' Pr = {Pr}\n b = {b}\n r = {r}\n' + s += f' integration step size = {h:4.2f}\n' + s += f' slice resolution = {resolution}\n' + s += f' number of iterations = {iterations}\n' + s += f' specified range (x, y, z):\n' + s += f' minimum: ({xmin:6.2f}, {ymin:6.2f}, {zmin:6.2f})\n' + s += f' maximum: ({xmax:6.2f}, {ymax:6.2f}, {zmax:6.2f})\n' + print(s) + + random_sequence = vtkMinimalStandardRandomSequence(seed=8775070) + x = random_sequence.GetRangeValue(xmin, xmax) + random_sequence.Next() + y = random_sequence.GetRangeValue(ymin, ymax) + random_sequence.Next() + z = random_sequence.GetRangeValue(zmin, zmax) + random_sequence.Next() + + s += f' starting at: ({x:6.2f}, {y:6.2f}, {z:6.2f})' + print(s) + + print(' generating the volume ...') + + # Allocate memory for the slices. + slice_size = resolution * resolution + num_pts = slice_size * resolution + scalars = vtkShortArray() + for i in range(0, num_pts): + scalars.InsertTuple1(i, 0) + for j in range(0, iterations): + # Integrate to the next time step. + xx = x + h * Pr * (y - x) + yy = y + h * (x * (r - z) - y) + zz = z + h * (x * y - (b * z)) + + x = xx + y = yy + z = zz + + # Calculate the voxel index. + if xmax > x > xmin and ymax > y > ymin and zmax > z > zmin: + xxx = int(float(xx - xmin) * dx) + yyy = int(float(yy - ymin) * dy) + zzz = int(float(zz - zmin) * dz) + index = xxx + yyy * resolution + zzz * slice_size + scalars.SetTuple1(index, scalars.GetTuple1(index) + 1) + + origin = (xmin, ymin, zmin) + spacing = ((xmax - xmin) / resolution, (ymax - ymin) / resolution, (zmax - zmin) / resolution) + volume = vtkStructuredPoints(dimensions=(resolution, resolution, resolution), + origin=origin, spacing=spacing) + volume.point_data.SetScalars(scalars) + + print(' contouring ...') + + # Create the iso-surface. + contour = vtkContourFilter(input_data=volume) + contour.SetValue(0, 50) + + # Create mapper. + mapper = vtkPolyDataMapper(scalar_visibility=False) + contour >> mapper + + # Create actor. + actor = vtkActor(mapper=mapper) + actor.property.color = colors.GetColor3d('DodgerBlue') + + # Do the graphics dance. + renderer = vtkRenderer(background=colors.GetColor3d('PaleGoldenrod')) + ren_win = vtkRenderWindow(size=(640, 480), window_name='Lorenz') + ren_win.AddRenderer(renderer) + iren = vtkRenderWindowInteractor() + iren.render_window = ren_win + + renderer.AddActor(actor) + + # Interact with the data. + ren_win.Render() + ren_win.SetWindowName('Lorenz') + + camera = renderer.GetActiveCamera() + camera.position = (-67.645167, -25.714343, 63.483516) + camera.focal_point = (3.224902, -4.398594, 29.552112) + camera.view_up = (-0.232264, 0.965078, 0.121151) + camera.distance = 81.414176 + camera.clipping_range = (18.428905, 160.896031) + + iren.Start() + + +if __name__ == '__main__': + main() diff --git a/src/PythonicAPI/Widgets/SphereWidget.md b/src/PythonicAPI/Widgets/SphereWidget.md new file mode 100644 index 0000000000000000000000000000000000000000..87c31fb13519d44dac0e1e5b45033120540e5c64 --- /dev/null +++ b/src/PythonicAPI/Widgets/SphereWidget.md @@ -0,0 +1,3 @@ +### Description + +This example shows how to use the SphereWidget. diff --git a/src/PythonicAPI/Widgets/SphereWidget.py b/src/PythonicAPI/Widgets/SphereWidget.py new file mode 100755 index 0000000000000000000000000000000000000000..d6b679853db8864198c20cc6b0c1005954b686cf --- /dev/null +++ b/src/PythonicAPI/Widgets/SphereWidget.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 + +from dataclasses import dataclass + +# noinspection PyUnresolvedReferences +import vtkmodules.vtkInteractionStyle +# noinspection PyUnresolvedReferences +import vtkmodules.vtkRenderingOpenGL2 +from vtkmodules.vtkCommonColor import vtkNamedColors +from vtkmodules.vtkInteractionWidgets import vtkSphereWidget +from vtkmodules.vtkRenderingCore import ( + vtkRenderWindow, + vtkRenderWindowInteractor, + vtkRenderer +) + + +def sphere_callback(obj, event): + """ + The callback function. + :param obj: The sphere widget. + :param event: + :return: + """ + center = obj.center + print(f'Center: {center[0]:6.3f}, {center[1]:6.3f}, {center[2]:6.3f}') + + +def main(): + colors = vtkNamedColors() + + # colors.SetColor('bkg', 0.1, 0.2, 0.4, 1.0) + + # A renderer, render window and interactor. + renderer = vtkRenderer(background=colors.GetColor3d('MidnightBlue')) + ren_win = vtkRenderWindow(window_name='SphereWidget') + ren_win.AddRenderer(renderer) + interactor = vtkRenderWindowInteractor() + interactor.render_window = ren_win + + # A Sphere widget + sphere_widget = vtkSphereWidget(interactor=interactor, + representation=SphereWidget.Representation.VTK_SPHERE_SURFACE) + sphere_widget.sphere_property.color = colors.GetColor3d('BurlyWood') + + # Connect the event to a function. + sphere_widget.AddObserver('InteractionEvent', sphere_callback) + + # Start + interactor.Initialize() + ren_win.Render() + sphere_widget.On() + interactor.Start() + + +@dataclass(frozen=True) +class SphereWidget: + @dataclass(frozen=True) + class Representation: + VTK_SPHERE_OFF: int = 0 + VTK_SPHERE_WIREFRAME: int = 1 + VTK_SPHERE_SURFACE: int = 2 + + +if __name__ == '__main__': + main() diff --git a/src/PythonicAPI/Widgets/SplineWidget.md b/src/PythonicAPI/Widgets/SplineWidget.md new file mode 100644 index 0000000000000000000000000000000000000000..67bd58309038dcea2967ceb5976e1fcedbafd107 --- /dev/null +++ b/src/PythonicAPI/Widgets/SplineWidget.md @@ -0,0 +1,3 @@ +### Description + +This example shows how to use vtkSplineWidget with a callback being used to get the length of the spline widget. diff --git a/src/PythonicAPI/Widgets/SplineWidget.py b/src/PythonicAPI/Widgets/SplineWidget.py new file mode 100755 index 0000000000000000000000000000000000000000..570f06b50e93e3b7ed5471604e0105a4a0782a63 --- /dev/null +++ b/src/PythonicAPI/Widgets/SplineWidget.py @@ -0,0 +1,90 @@ +#!/usr/bin/python3 + +# noinspection PyUnresolvedReferences +import vtkmodules.vtkInteractionStyle +# noinspection PyUnresolvedReferences +import vtkmodules.vtkRenderingOpenGL2 + +from vtkmodules.vtkCommonColor import vtkNamedColors +from vtkmodules.vtkCommonCore import ( + vtkCommand +) +from vtkmodules.vtkFiltersSources import vtkCylinderSource +from vtkmodules.vtkInteractionStyle import vtkInteractorStyleTrackballCamera +from vtkmodules.vtkInteractionWidgets import ( + vtkCameraOrientationWidget, + vtkSplineWidget +) +from vtkmodules.vtkRenderingCore import ( + vtkActor, + vtkPolyDataMapper, + vtkRenderWindow, + vtkRenderWindowInteractor, + vtkRenderer +) + + +def main(argv): + colors = vtkNamedColors() + colors.SetColor('ParaViewBkg', 82, 87, 110, 255) + + window_width = 1024 + window_height = 1024 + + ren_win = vtkRenderWindow(size=(window_width, window_height), window_name='SplineWidget') + ren_win.SetSize(window_width, window_height) + # Important: The interactor must be set prior to enabling the widgets. + iren = vtkRenderWindowInteractor() + iren.render_window = ren_win + style = vtkInteractorStyleTrackballCamera() + iren.interactor_style = style + + renderer = vtkRenderer(background=colors.GetColor3d('ParaViewBkg')) + + # Create a cylinder. + cylinder = vtkCylinderSource() + cylinder.SetCenter(0.0, 0.0, 0.0) + cylinder.SetRadius(3.0) + cylinder.SetHeight(5.0) + cylinder.SetResolution(100) + + # Create a mapper and actor + mapper = vtkPolyDataMapper() + mapper.SetInputConnection(cylinder.GetOutputPort()) + actor = vtkActor() + actor.GetProperty().SetColor(colors.GetColor3d('Cornsilk')) + actor.SetMapper(mapper) + # Add the actor to the scene + renderer.AddActor(actor) + + ren_win.AddRenderer(renderer) + + # A spline widget + spline_widget = vtkSplineWidget(interactor=iren) + spline_widget.SetProp3D(actor) + spline_widget.PlaceWidget(-2.5, 2.5, 3.5, 3.5, 0, 0, ) + spline_widget.On() + + spline_widget.AddObserver(vtkCommand.EndInteractionEvent, SplineCallback(spline_widget)) + + cow = vtkCameraOrientationWidget(parent_renderer=renderer) + cow.On() + + ren_win.Render() + iren.Start() + + +class SplineCallback: + def __init__(self, spline_widget): + self.spline = spline_widget + + def __call__(self, caller, ev): + spline_widget = caller + length = spline_widget.summed_length + print(f'Length: {length:6.2f}') + + +if __name__ == '__main__': + import sys + + main(sys.argv) diff --git a/src/Testing/Baseline/PythonicAPI/IO/TestWriteSTL.png b/src/Testing/Baseline/PythonicAPI/IO/TestWriteSTL.png new file mode 100644 index 0000000000000000000000000000000000000000..8f56d7799edca53999aa09f7b6fb5f719b2ae073 --- /dev/null +++ b/src/Testing/Baseline/PythonicAPI/IO/TestWriteSTL.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75f0f77f49ba1a570f065f2a2d58cbd1545e20becd9b8283d90a60c735d3c123 +size 4979 diff --git a/src/Testing/Baseline/PythonicAPI/Rendering/TestMotionBlur.png b/src/Testing/Baseline/PythonicAPI/Rendering/TestMotionBlur.png new file mode 100644 index 0000000000000000000000000000000000000000..6e8785002855558cb073d27fc0ac52239032ffa6 --- /dev/null +++ b/src/Testing/Baseline/PythonicAPI/Rendering/TestMotionBlur.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b21ffc3f322aa6563e161f1ce4358d404bb218dcb83a7fc0c20bcfbbebd38673 +size 106895 diff --git a/src/Testing/Baseline/PythonicAPI/Visualization/TestLorenz.png b/src/Testing/Baseline/PythonicAPI/Visualization/TestLorenz.png new file mode 100644 index 0000000000000000000000000000000000000000..d0fdc0851a57b162b3957437aec3492953fea623 --- /dev/null +++ b/src/Testing/Baseline/PythonicAPI/Visualization/TestLorenz.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:699c56e92bdee661c60cbbf660b89d8fbb6a39702a3685af05f9e55492328d6c +size 314417 diff --git a/src/Testing/Baseline/PythonicAPI/Widgets/TestSphereWidget.png b/src/Testing/Baseline/PythonicAPI/Widgets/TestSphereWidget.png new file mode 100644 index 0000000000000000000000000000000000000000..f85687fea3513e03fdffe40636be0d652d719b7b --- /dev/null +++ b/src/Testing/Baseline/PythonicAPI/Widgets/TestSphereWidget.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5f19cbe947496566b9581d31105734ce93f394d35be57994051d7a264a6bfbd +size 35845 diff --git a/src/Testing/Baseline/PythonicAPI/Widgets/TestSplineWidget.png b/src/Testing/Baseline/PythonicAPI/Widgets/TestSplineWidget.png new file mode 100644 index 0000000000000000000000000000000000000000..f451daec5ffea23bd18e857fe23818c2833450dd --- /dev/null +++ b/src/Testing/Baseline/PythonicAPI/Widgets/TestSplineWidget.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4db6c669e52a333acf0851711ccdab09b38f1058674d4654bbf6be5f1a7f77d2 +size 15126