Skip to content
Snippets Groups Projects
Commit 484db898 authored by Andrew Maclean's avatar Andrew Maclean
Browse files

Adding SpatioTemporalHarmonicsSource.py and documentation plus tweaks

parent 7c5f8d80
No related branches found
No related tags found
1 merge request!396Add spatio temporal harmonics source
Pipeline #428728 passed
......@@ -402,6 +402,7 @@ These examples demonstrate how to create an display one of the many vtkParametri
[SelectionSource](/Cxx/Filtering/SelectionSource) | Specify a selection.
[ShrinkPolyData](/Cxx/PolyData/ShrinkPolyData) | Move all items in a PolyData towards their centroid.
[Silhouette](/Cxx/PolyData/Silhouette) |
[SpatioTemporalHarmonicsSource](/Cxx/Filtering/SpatioTemporalHarmonicsSource) | Generate image data containing spatio-temporal harmonic data.
[Spring](/Cxx/Modelling/Spring) | Rotation in combination with linear displacement and radius variation.
[Stripper](/Cxx/PolyData/Stripper) | Convert triangles to triangle strips.
[ThinPlateSplineTransform](/Cxx/PolyData/ThinPlateSplineTransform) |
......
......@@ -3,6 +3,7 @@
#include <vtkCameraOrientationWidget.h>
#include <vtkDataSetMapper.h>
#include <vtkInteractorStyleSwitch.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
......@@ -11,10 +12,14 @@
int main(int, char*[])
{
// Create source
vtkNew<vtkNamedColors> colors;
// Create the source.
const int MAX_EXTENT = 10;
vtkNew<vtkSpatioTemporalHarmonicsSource> source;
source->SetWholeExtent(-MAX_EXTENT, MAX_EXTENT, -MAX_EXTENT, MAX_EXTENT,
source->SetWholeExtent(-MAX_EXTENT, MAX_EXTENT,
-MAX_EXTENT, MAX_EXTENT,
-MAX_EXTENT, MAX_EXTENT);
source->ClearHarmonics();
......@@ -27,9 +32,7 @@ int main(int, char*[])
source->AddTimeStepValue(1.0);
source->AddTimeStepValue(2.0);
// source->Update();
// Create mapper and actor.
// Create the mapper and actor.
vtkNew<vtkDataSetMapper> mapper;
mapper->SetInputConnection(source->GetOutputPort());
mapper->SetScalarRange(-6.0, 6.0);
......@@ -39,7 +42,7 @@ int main(int, char*[])
// Create a renderer, render window, and interactor.
vtkNew<vtkRenderer> ren;
ren->SetBackground(0.5, 0.5, 0.5);
ren->SetBackground(colors->GetColor3d("Gray").GetData());
vtkNew<vtkRenderWindow> renWin;
renWin->SetWindowName("SpatioTemporalHarmonicsSource");
renWin->SetSize(600, 600);
......
### Description
Generate image data containing spatio-temporal harmonic data.
This source allows you to specify the uniform grid extent. It also lets you choose the harmonics you want.
The source has an embedded filter allowing you to add mutiple harmonics defined by their amplitude, temporal frequency, wave vector, and phase. The sum of these will be computed using the sine function for each point. Note that there is no cosine in this function. If no harmonic is specified, values will be null.
The source can also generate time steps by specifying time values.
### Description
A vtkGoldenBallSource algorithm has been added to provide a method to construct a solid, tetrahedralized ball. It uses a Fibonacci spiral (generated using the “Golden Angle” of π(sqrt(5) - 1)) which is then projected out of the plane onto a sphere and Delaunay-tetrahedralized into a ball. It includes a “normal” vector field by default which is zero-length at the center of the ball.
A vtkGoldenBallSource algorithm has been added to provide a method to construct a solid, tetrahedralized ball. It uses a Fibonacci spiral (generated using the “Golden Angle” of 180(√5 - 3)°) which is then projected out of the plane onto a sphere and Delaunay-tetrahedralized into a ball. It includes a “normal” vector field by default which is zero-length at the center of the ball.
Besides the spiral construction this algorithm is also distinct from the existing sphere source because it produces a solid rather than a bounding surface.
......@@ -233,6 +233,7 @@ This Python script, [SelectExamples](../PythonicAPI/Utilities/SelectExamples), w
[RuledSurfaceFilter](/PythonicAPI/PolyData/RuledSurfaceFilter) |
[Silhouette](/PythonicAPI/PolyData/Silhouette) |
[SmoothMeshGrid](/PythonicAPI/PolyData/SmoothMeshGrid) | Create a terrain with regularly spaced points and smooth it with ?vtkLoopSubdivisionFilter? and ?vtkButterflySubdivisionFilter?.
[SpatioTemporalHarmonicsSource](/Cxx/PythonicAPI/SpatioTemporalHarmonicsSource) | Generate image data containing spatio-temporal harmonic data.
[Spring](/PythonicAPI/Modelling/Spring) | Rotation in combination with linear displacement and radius variation.
[ThinPlateSplineTransform](/PythonicAPI/PolyData/ThinPlateSplineTransform) |
[VertexConnectivity](/PythonicAPI/PolyData/VertexConnectivity) | Get a list of vertices attached (through an edge) to a vertex.
......
### Description
Generate image data containing spatio-temporal harmonic data.
This source allows you to specify the uniform grid extent. It also lets you choose the harmonics you want.
The source has an embedded filter allowing you to add mutiple harmonics defined by their amplitude, temporal frequency, wave vector, and phase. The sum of these will be computed using the sine function for each point. Note that there is no cosine in this function. If no harmonic is specified, values will be null.
The source can also generate time steps by specifying time values.
#!/usr/bin/env python3
# noinspection PyUnresolvedReferences
import vtkmodules.vtkInteractionStyle
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingOpenGL2
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingUI
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkFiltersSources import vtkSpatioTemporalHarmonicsSource
from vtkmodules.vtkInteractionWidgets import (
vtkCameraOrientationWidget
)
from vtkmodules.vtkRenderingCore import (
vtkActor,
vtkDataSetMapper,
vtkRenderer,
vtkRenderWindow,
vtkRenderWindowInteractor
)
def main():
colors = vtkNamedColors()
# Create the source
MAX_EXTENT = 10
extent = (-MAX_EXTENT, MAX_EXTENT) * 3
source = vtkSpatioTemporalHarmonicsSource(whole_extent=extent)
source.ClearHarmonics()
source.AddHarmonic(1.0, 1.0, 1.0, 0.0, 0.0, 0.0)
source.AddHarmonic(2.0, 1.0, 0.0, 1.0, 0.0, 0.0)
source.AddHarmonic(4.0, 1.0, 0.0, 0.0, 1.0, 0.0)
source.ClearTimeStepValues()
source.AddTimeStepValue(0.0)
source.AddTimeStepValue(1.0)
source.AddTimeStepValue(2.0)
# Create the mapper and actor.
mapper = vtkDataSetMapper(scalar_range=(-6.0, 6.0))
source >> mapper
actor = vtkActor(mapper=mapper)
# Create a renderer, render window, and interactor.
ren = vtkRenderer(background=colors.GetColor3d('Gray'))
renWin = vtkRenderWindow(size=(600, 600), window_name='SpatioTemporalHarmonicsSource')
renWin.AddRenderer(ren)
iRen = vtkRenderWindowInteractor()
iRen.render_window = renWin
# Since we import vtkmodules.vtkInteractionStyle we can do this
# because vtkInteractorStyleSwitch is automatically imported:
iRen.interactor_style.SetCurrentStyleToTrackballCamera()
ren.ResetCamera()
ren.active_camera.position = (50.0, 40.0, 30.0)
ren.active_camera.focal_point = (0.0, 0.0, 0.0)
ren.ResetCameraClippingRange()
# Add the actor, render and interact.
ren.AddActor(actor)
renWin.Render()
cow = vtkCameraOrientationWidget()
cow.SetParentRenderer(ren)
# Enable the widget.
cow.On()
iRen.Start()
if __name__ == '__main__':
main()
### Description
A vtkGoldenBallSource algorithm has been added to provide a method to construct a solid, tetrahedralized ball. It uses a Fibonacci spiral (generated using the “Golden Angle” of π(sqrt(5) - 1)) which is then projected out of the plane onto a sphere and Delaunay-tetrahedralized into a ball. It includes a “normal” vector field by default which is zero-length at the center of the ball.
A vtkGoldenBallSource algorithm has been added to provide a method to construct a solid, tetrahedralized ball. It uses a Fibonacci spiral (generated using the “Golden Angle” of 180(√5 - 3)°) which is then projected out of the plane onto a sphere and Delaunay-tetrahedralized into a ball. It includes a “normal” vector field by default which is zero-length at the center of the ball.
Besides the spiral construction this algorithm is also distinct from the existing sphere source because it produces a solid rather than a bounding surface.
src/Testing/Baseline/Cxx/Filtering/TestSpatioTemporalHarmonicsSource.png

131 B

src/Testing/Baseline/PythonicAPI/Filtering/TestSpatioTemporalHarmonicsSource.png

131 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment