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

Sphere->SphereSource, adding images and orientation markers

parent ce1606ab
No related branches found
No related tags found
1 merge request!395Adding some new vtk 9.4 examples
Showing
with 110 additions and 21 deletions
......@@ -218,19 +218,20 @@ If you are new to VTK then these [tutorials](#tutorial) will help to get you sta
| -------------- | ------------- | ------- |
[Arrow](/Cxx/GeometricObjects/Arrow) |
[Cone](/Cxx/GeometricObjects/Cone) | Display a cone
[ConeDemo](/Cxx/GeometricObjects/ConeDemo) | Disolay four different resolution cones.
[ConeDemo](/Cxx/GeometricObjects/ConeDemo) | Display four different resolution cones.
[Cylinder](/Cxx/GeometricObjects/Cylinder) |
[Disk](/Cxx/GeometricObjects/Disk) | A circle with a hole in it.
[EarthSource](/Cxx/GeometricObjects/EarthSource) | Create the Earth.
[Frustum](/Cxx/GeometricObjects/Frustum) |
[GoldenBallSource](/Cxx/GeometricObjects/GoldenBallSource) | Construct a solid, tetrahedralized ball.
[Line](/Cxx/GeometricObjects/Line) |
[OrientedArrow](/Cxx/GeometricObjects/OrientedArrow) | Orient an arrow along an arbitrary vector.
[OrientedCylinder](/Cxx/GeometricObjects/OrientedCylinder) | Orient a cylinder along an arbitrary vector.
[Plane](/Cxx/GeometricObjects/Plane) |
[Plane](/Cxx/GeometricObjects/Plane) | Construct a plane.
[PlatonicSolids](/Cxx/GeometricObjects/PlatonicSolids) |
[PolyLine1](/Cxx/GeometricObjects/PolyLine1) | This example demonstrates how to create a polygon through several ordered points.
[RegularPolygonSource](/Cxx/GeometricObjects/RegularPolygonSource) |
[Sphere](/Cxx/GeometricObjects/Sphere) |
[SphereSource](/Cxx/GeometricObjects/SphereSource) | Construct a sphere.
[TessellatedBoxSource](/Cxx/GeometricObjects/TessellatedBoxSource) | Generate a box with tessellated sides.
[TextActor](/Cxx/GeometricObjects/TextActor) | 2D "HUD-type" text
......
......@@ -13,6 +13,7 @@ if(NOT VTK_BINARY_DIR)
FiltersSources
IOParallel
InteractionStyle
InteractionWidgets
RenderingAnnotation
RenderingCore
RenderingFreeType
......
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCameraOrientationWidget.h>
#include <vtkInteractorStyleSwitch.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkParametricEnneper.h>
......@@ -43,6 +45,12 @@ int main(int, char*[])
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
auto is = vtkInteractorStyleSwitch::SafeDownCast(
renderWindowInteractor->GetInteractorStyle());
if (is)
{
is->SetCurrentStyleToTrackballCamera();
}
double* bounds;
bounds = fnSrc->GetOutput()->GetBounds();
......@@ -78,6 +86,11 @@ int main(int, char*[])
polarAxesActor->SetCamera(renderer->GetActiveCamera());
renderer->ResetCamera();
vtkNew<vtkCameraOrientationWidget> cow;
cow->SetParentRenderer(renderer);
// Enable the widget.
cow->On();
renderer->SetBackground(colors->GetColor3d("MidnightBlue").GetData());
// Render and interact.
......
#include <vtkActor.h>
#include <vtkCameraOrientationWidget.h>
#include <vtkDataSetMapper.h>
#include <vtkGoldenBallSource.h>
#include <vtkInteractorStyleSwitch.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkProperty.h>
......@@ -45,9 +47,20 @@ int main(int, char*[])
renderWindow->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
auto is = vtkInteractorStyleSwitch::SafeDownCast(
renderWindowInteractor->GetInteractorStyle());
if (is)
{
is->SetCurrentStyleToTrackballCamera();
}
renderer->AddActor(actor);
vtkNew<vtkCameraOrientationWidget> cow;
cow->SetParentRenderer(renderer);
// Enable the widget.
cow->On();
renderWindow->Render();
renderWindowInteractor->Start();
......
#include <vtkActor.h>
#include <vtkCameraOrientationWidget.h>
#include <vtkInteractorStyleSwitch.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPolyDataMapper.h>
......@@ -23,6 +25,7 @@ int main(int, char*[])
// Make the surface smooth.
sphereSource->SetPhiResolution(50);
sphereSource->SetThetaResolution(50);
sphereSource->LatLongTessellationOff();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(sphereSource->GetOutputPort());
......@@ -39,14 +42,25 @@ int main(int, char*[])
vtkNew<vtkRenderer> renderer;
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetSize(600, 600);
renderWindow->SetWindowName("Sphere");
renderWindow->SetWindowName("Sphere Source");
renderWindow->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
auto is = vtkInteractorStyleSwitch::SafeDownCast(
renderWindowInteractor->GetInteractorStyle());
if (is)
{
is->SetCurrentStyleToTrackballCamera();
}
renderer->AddActor(actor);
renderer->SetBackground(colors->GetColor3d("ParaViewBkg").GetData());
vtkNew<vtkCameraOrientationWidget> cow;
cow->SetParentRenderer(renderer);
// Enable the widget.
cow->On();
renderWindow->Render();
renderWindowInteractor->Start();
......
......@@ -149,9 +149,11 @@ This Python script, [SelectExamples](../PythonicAPI/Utilities/SelectExamples), w
| -------------- | ------------- | ------- |
[EarthSource](/PythonicAPI/GeometricObjects/EarthSource) | Create the Earth.
[Frustum](/PythonicAPI/GeometricObjects/Frustum) |
[GoldenBallSource](/PythonicAPI/GeometricObjects/GoldenBallSource) | Construct a solid, tetrahedralized ball.
[OrientedArrow](/PythonicAPI/GeometricObjects/OrientedArrow) | Orient an arrow along an arbitrary vector.
[OrientedCylinder](/PythonicAPI/GeometricObjects/OrientedCylinder) | Orient a cylinder along an arbitrary vector.
[PlatonicSolids](/PythonicAPI/GeometricObjects/PlatonicSolids) | All five platonic solids are displayed.
[SphereSource](/PythonicAPI/GeometricObjects/SphereSource) | Construct a sphere.
[TessellatedBoxSource](/PythonicAPI/GeometricObjects/TessellatedBoxSource) | Generate a box with tessellated sides.
### Non Linear
......
......@@ -9,6 +9,7 @@ import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkCommonComputationalGeometry import vtkParametricEnneper
from vtkmodules.vtkFiltersSources import vtkParametricFunctionSource
from vtkmodules.vtkInteractionWidgets import vtkCameraOrientationWidget
from vtkmodules.vtkRenderingAnnotation import vtkPolarAxesActor
from vtkmodules.vtkRenderingCore import (
vtkActor,
......@@ -39,6 +40,9 @@ def main():
render_window.AddRenderer(renderer)
render_window_interactor = vtkRenderWindowInteractor()
render_window_interactor.render_window = render_window
# Since we import vtkmodules.vtkInteractionStyle we can do this
# because vtkInteractorStyleSwitch is automatically imported:
render_window_interactor.interactor_style.SetCurrentStyleToTrackballCamera()
bounds = fn_src.update().output.bounds
radius = math.sqrt(abs(dot_product((bounds[0], bounds[2]), (bounds[1], bounds[3]))))
......@@ -66,6 +70,11 @@ def main():
polar_axes_actor.SetCamera(renderer.active_camera)
renderer.ResetCamera()
cow = vtkCameraOrientationWidget(parent_renderer=renderer,
interactor=render_window_interactor)
# Enable the widget.
cow.On()
# Render and interact.
render_window.Render()
render_window_interactor.Start()
......
......@@ -5,38 +5,50 @@ import vtkmodules.vtkInteractionStyle
# noinspection PyUnresolvedReferences
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkFiltersSources import vtkSphereSource, vtkGoldenBallSource
from vtkmodules.vtkFiltersSources import vtkGoldenBallSource
from vtkmodules.vtkInteractionWidgets import vtkCameraOrientationWidget
from vtkmodules.vtkRenderingCore import (
vtkActor,
vtkPolyDataMapper,
vtkRenderWindow,
vtkRenderWindowInteractor,
vtkRenderer, vtkMapper, vtkDataSetMapper, vtkProperty
vtkRenderer, vtkDataSetMapper, vtkProperty
)
def main():
colors = vtkNamedColors()
colors.SetColor("ParaViewBkg", [82, 87, 110, 255])
colors.SetColor("ParaViewBkg", 82, 87, 110, 255)
# Create a golden ball.
golden_ball_source = vtkGoldenBallSource(center=(0.0, 0.0, 0.0), radius=5.0, resolution=200, generate_normals=True, include_center_point=True)
golden_ball_source = vtkGoldenBallSource(center=(0.0, 0.0, 0.0),
radius=5.0, resolution=200,
generate_normals=True,
include_center_point=True)
mapper = vtkDataSetMapper()
golden_ball_source >> mapper
actor_prop = vtkProperty(color = colors.GetColor3d('Gold'), edge_color = colors.GetColor3d('DarkSlateBlue'), edge_visibility = True)
actor_prop = vtkProperty(color=colors.GetColor3d('Gold'), edge_color=colors.GetColor3d('DarkSlateBlue'),
edge_visibility=True)
actor = vtkActor(property=actor_prop, mapper=mapper)
renderer = vtkRenderer(background = colors.GetColor3d('ParaViewBkg'))
render_window = vtkRenderWindow(size=(600,600),window_name='Golden Ball Source')
renderer = vtkRenderer(background=colors.GetColor3d('ParaViewBkg'))
render_window = vtkRenderWindow(size=(600, 600), window_name='Golden Ball Source')
render_window.AddRenderer(renderer)
render_window_interactor = vtkRenderWindowInteractor()
render_window_interactor.SetRenderWindow(render_window)
# Since we import vtkmodules.vtkInteractionStyle we can do this
# because vtkInteractorStyleSwitch is automatically imported:
render_window_interactor.interactor_style.SetCurrentStyleToTrackballCamera()
renderer.AddActor(actor)
renderer.ResetCamera()
cow = vtkCameraOrientationWidget(parent_renderer=renderer,
interactor=render_window_interactor)
# Enable the widget.
cow.On()
render_window.Render()
render_window_interactor.Start()
......
......@@ -6,6 +6,7 @@ import vtkmodules.vtkInteractionStyle
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkFiltersSources import vtkSphereSource
from vtkmodules.vtkInteractionWidgets import vtkCameraOrientationWidget
from vtkmodules.vtkRenderingCore import (
vtkActor,
vtkPolyDataMapper,
......@@ -17,25 +18,36 @@ from vtkmodules.vtkRenderingCore import (
def main():
colors = vtkNamedColors()
colors.SetColor("ParaViewBkg", [82, 87, 110, 255])
colors.SetColor("ParaViewBkg", 82, 87, 110, 255)
# Create a sphere.
sphere_source = vtkSphereSource(center=(0.0, 0.0, 0.0), radius=5.0, phi_resolution=50, theta_resolution=50)
sphere_source = vtkSphereSource(center=(0.0, 0.0, 0.0), radius=5.0,
phi_resolution=50, theta_resolution=50,
lat_long_tessellation=False)
mapper = vtkPolyDataMapper()
sphere_source >> mapper
actor_prop = vtkProperty(color = colors.GetColor3d('Peru'), edge_color = colors.GetColor3d('DarkSlateBlue'), edge_visibility = True)
actor_prop = vtkProperty(color=colors.GetColor3d('Peru'), edge_color=colors.GetColor3d('DarkSlateBlue'),
edge_visibility=True)
actor = vtkActor(property=actor_prop, mapper=mapper)
renderer = vtkRenderer(background = colors.GetColor3d('ParaViewBkg'))
render_window = vtkRenderWindow(size=(600,600),window_name='Sphere')
renderer = vtkRenderer(background=colors.GetColor3d('ParaViewBkg'))
render_window = vtkRenderWindow(size=(600, 600), window_name='Sphere Source')
render_window.AddRenderer(renderer)
render_window_interactor = vtkRenderWindowInteractor()
render_window_interactor.SetRenderWindow(render_window)
# Since we import vtkmodules.vtkInteractionStyle we can do this
# because vtkInteractorStyleSwitch is automatically imported:
render_window_interactor.interactor_style.SetCurrentStyleToTrackballCamera()
renderer.AddActor(actor)
cow = vtkCameraOrientationWidget(parent_renderer=renderer,
interactor=render_window_interactor)
# Enable the widget.
cow.On()
render_window.Render()
render_window_interactor.Start()
......
src/Testing/Baseline/Cxx/Annotation/TestPolarAxesActor.png

130 B | W: | H:

src/Testing/Baseline/Cxx/Annotation/TestPolarAxesActor.png

130 B | W: | H:

src/Testing/Baseline/Cxx/Annotation/TestPolarAxesActor.png
src/Testing/Baseline/Cxx/Annotation/TestPolarAxesActor.png
src/Testing/Baseline/Cxx/Annotation/TestPolarAxesActor.png
src/Testing/Baseline/Cxx/Annotation/TestPolarAxesActor.png
  • 2-up
  • Swipe
  • Onion skin
src/Testing/Baseline/Cxx/GeometricObjects/TestSphereSource.png

131 B

src/Testing/Baseline/PythonicAPI/Annotation/TestPolarAxesActor.png

130 B | W: | H:

src/Testing/Baseline/PythonicAPI/Annotation/TestPolarAxesActor.png

130 B | W: | H:

src/Testing/Baseline/PythonicAPI/Annotation/TestPolarAxesActor.png
src/Testing/Baseline/PythonicAPI/Annotation/TestPolarAxesActor.png
src/Testing/Baseline/PythonicAPI/Annotation/TestPolarAxesActor.png
src/Testing/Baseline/PythonicAPI/Annotation/TestPolarAxesActor.png
  • 2-up
  • Swipe
  • Onion skin
src/Testing/Baseline/PythonicAPI/GeometricObjects/TestGoldenBallSource.png

131 B

src/Testing/Baseline/PythonicAPI/GeometricObjects/TestSphereSource.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