Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VTK Examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VTK
VTK Examples
Commits
6299a795
Commit
6299a795
authored
7 years ago
by
Andrew Maclean
Browse files
Options
Downloads
Patches
Plain Diff
Reworking ParametricObjects.
Former-commit-id:
91e58aca
parent
090d6a53
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Cxx/GeometricObjects/ParametricObjects.cxx
+8
-7
8 additions, 7 deletions
src/Cxx/GeometricObjects/ParametricObjects.cxx
src/Python/GeometricObjects/ParametricObjects.py
+50
-57
50 additions, 57 deletions
src/Python/GeometricObjects/ParametricObjects.py
with
58 additions
and
64 deletions
src/Cxx/GeometricObjects/ParametricObjects.cxx
+
8
−
7
View file @
6299a795
...
...
@@ -3,12 +3,13 @@
#include
<vtkParametricFunctionSource.h>
#include
<vtkPolyDataMapper.h>
#include
<vtkProperty.h>
#include
<vtkRenderer.h>
#include
<vtkRenderWindow.h>
#include
<vtkRenderWindowInteractor.h>
#include
<vtkRenderer.h>
#include
<vtkSmartPointer.h>
// Select one of the following:
// Uncomment one of the following includes that correspond
// to the object that you have selected below:
// #include <vtkParametricBoy.h>
// #include <vtkParametricConicSpiral.h>
// #include <vtkParametricCrossCap.h>
...
...
@@ -30,9 +31,8 @@ int main(int, char* [])
vtkSmartPointer
<
vtkNamedColors
>
namedColors
=
vtkSmartPointer
<
vtkNamedColors
>::
New
();
// Select one of the following (matching the selection above)
vtkSmartPointer
<
vtkParametricTorus
>
parametricObject
=
vtkSmartPointer
<
vtkParametricTorus
>::
New
();
// Uncomment one of the following and
// ensure the matching include (above) is umcommented).
// vtkSmartPointer<vtkParametricBoy> parametricObject =
// vtkSmartPointer<vtkParametricBoy>::New();
// vtkSmartPointer<vtkParametricConicSpiral> parametricObject =
...
...
@@ -61,8 +61,8 @@ int main(int, char* [])
// vtkSmartPointer<vtkParametricSuperEllipsoid>::New();
// vtkSmartPointer<vtkParametricSuperToroid> parametricObject =
// vtkSmartPointer<vtkParametricSuperToroid>::New();
//
vtkSmartPointer<vtkParametricTorus> parametricObject =
//
vtkSmartPointer<vtkParametricTorus>::New();
vtkSmartPointer
<
vtkParametricTorus
>
parametricObject
=
vtkSmartPointer
<
vtkParametricTorus
>::
New
();
vtkSmartPointer
<
vtkParametricFunctionSource
>
parametricFunctionSource
=
vtkSmartPointer
<
vtkParametricFunctionSource
>::
New
();
...
...
@@ -82,6 +82,7 @@ int main(int, char* [])
vtkSmartPointer
<
vtkRenderer
>
renderer
=
vtkSmartPointer
<
vtkRenderer
>::
New
();
vtkSmartPointer
<
vtkRenderWindow
>
renderWindow
=
vtkSmartPointer
<
vtkRenderWindow
>::
New
();
renderWindow
->
SetWindowName
(
"Parametric Objects"
);
renderWindow
->
AddRenderer
(
renderer
);
vtkSmartPointer
<
vtkRenderWindowInteractor
>
interactor
=
vtkSmartPointer
<
vtkRenderWindowInteractor
>::
New
();
...
...
This diff is collapsed.
Click to expand it.
src/Python/GeometricObjects/ParametricObjects.py
+
50
−
57
View file @
6299a795
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
vtk
class
ParametricObjects
(
object
):
def
ParametricObjects
(
self
):
colors
=
vtk
.
vtkNamedColors
()
# Select one of the following functions.
# parametricObject = vtk.vtkParametricBoy()
# parametricObject = vtk.vtkParametricConicSpiral()
# parametricObject = vtk.vtkParametricCrossCap()
# parametricObject = vtk.vtkParametricDini()
# parametricObject = vtk.vtkParametricEllipsoid()
# parametricObject = vtk.vtkParametricEnneper()
# parametricObject = vtk.vtkParametricFigure8Klein()
# parametricObject = vtk.vtkParametricKlein()
# parametricObject = vtk.vtkParametricMobius()
# parametricObject = vtk.vtkParametricRandomHills()
# parametricObject = vtk.vtkParametricRoman()
# parametricObject = vtk.vtkParametricSpline()
# parametricObject = vtk.vtkParametricSuperEllipsoid()
# parametricObject = vtk.vtkParametricSuperToroid()
parametricObject
=
vtk
.
vtkParametricTorus
()
parametricSource
=
vtk
.
vtkParametricFunctionSource
()
parametricSource
.
SetParametricFunction
(
parametricObject
)
# mapper
mapper
=
vtk
.
vtkPolyDataMapper
()
mapper
.
SetInputConnection
(
parametricSource
.
GetOutputPort
())
# actor
actor
=
vtk
.
vtkActor
()
actor
.
SetMapper
(
mapper
)
actor
.
GetProperty
().
SetDiffuseColor
(
colors
.
GetColor3d
(
"
Burlywood
"
))
# ------------------------------------------------------------
# Create the RenderWindow, Renderer and Interactor
# ------------------------------------------------------------
ren
=
vtk
.
vtkRenderer
()
renWin
=
vtk
.
vtkRenderWindow
()
iren
=
vtk
.
vtkRenderWindowInteractor
()
renWin
.
AddRenderer
(
ren
)
iren
.
SetRenderWindow
(
renWin
)
# add actors
ren
.
AddViewProp
(
actor
)
ren
.
SetBackground
(
colors
.
GetColor3d
(
"
Beige
"
))
# enable user interface interactor
iren
.
Initialize
()
renWin
.
Render
()
iren
.
Start
()
if
__name__
==
"
__main__
"
:
po
=
ParametricObjects
()
po
.
ParametricObjects
()
def
main
():
namedColors
=
vtk
.
vtkNamedColors
()
# Uncomment one of the following.
# parametricObject = vtk.vtkParametricBoy()
# parametricObject = vtk.vtkParametricConicSpiral()
# parametricObject = vtk.vtkParametricCrossCap()
# parametricObject = vtk.vtkParametricDini()
# parametricObject = vtk.vtkParametricEllipsoid()
# parametricObject = vtk.vtkParametricEnneper()
# parametricObject = vtk.vtkParametricFigure8Klein()
# parametricObject = vtk.vtkParametricKlein()
# parametricObject = vtk.vtkParametricMobius()
# parametricObject = vtk.vtkParametricRandomHills()
# parametricObject = vtk.vtkParametricRoman()
# parametricObject = vtk.vtkParametricSpline()
# parametricObject = vtk.vtkParametricSuperEllipsoid()
# parametricObject = vtk.vtkParametricSuperToroid()
parametricObject
=
vtk
.
vtkParametricTorus
()
parametricFunctionSource
=
vtk
.
vtkParametricFunctionSource
()
parametricFunctionSource
.
SetParametricFunction
(
parametricObject
)
parametricFunctionSource
.
Update
()
# Visualize
mapper
=
vtk
.
vtkPolyDataMapper
()
mapper
.
SetInputConnection
(
parametricFunctionSource
.
GetOutputPort
())
# Create an actor for the contours
actor
=
vtk
.
vtkActor
()
actor
.
SetMapper
(
mapper
)
actor
.
GetProperty
().
SetDiffuseColor
(
namedColors
.
GetColor3d
(
"
Burlywood
"
))
renderer
=
vtk
.
vtkRenderer
()
renderWindow
=
vtk
.
vtkRenderWindow
()
renderWindow
.
SetWindowName
(
"
Parametric Objects
"
)
renderWindow
.
AddRenderer
(
renderer
)
interactor
=
vtk
.
vtkRenderWindowInteractor
()
interactor
.
SetRenderWindow
(
renderWindow
)
renderer
.
AddActor
(
actor
)
renderer
.
SetBackground
(
namedColors
.
GetColor3d
(
"
Beige
"
))
renderWindow
.
Render
()
interactor
.
Start
()
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment