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
6c7baa7a
Commit
6c7baa7a
authored
7 years ago
by
Andrew Maclean
Browse files
Options
Downloads
Patches
Plain Diff
Making Tetrahedron look better.
parent
c12eae69
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/Tetrahedron.cxx
+16
-8
16 additions, 8 deletions
src/Cxx/GeometricObjects/Tetrahedron.cxx
src/Python/GeometricObjects/Tetrahedron.py
+86
-75
86 additions, 75 deletions
src/Python/GeometricObjects/Tetrahedron.py
with
102 additions
and
83 deletions
src/Cxx/GeometricObjects/Tetrahedron.cxx
+
16
−
8
View file @
6c7baa7a
#include
<vtkVersion.h>
#include
<vtkSmartPointer.h>
#include
<vtkActor.h>
#include
<vtkCellArray.h>
#include
<vtkTetra.h>
#include
<vtkUnstructuredGrid.h>
#include
<vtkPoints.h>
#include
<vtkCellType.h>
#include
<vtkDataSetMapper.h>
#include
<vtkActor.h>
#include
<vtkRenderWindow.h>
#include
<vtkNamedColors.h>
#include
<vtkPoints.h>
#include
<vtkProperty.h>
#include
<vtkRenderer.h>
#include
<vtkRenderWindow.h>
#include
<vtkRenderWindowInteractor.h>
#include
<vtkSmartPointer.h>
#include
<vtkTetra.h>
#include
<vtkUnstructuredGrid.h>
#include
<vtkVersion.h>
int
main
(
int
,
char
*
[])
{
vtkSmartPointer
<
vtkNamedColors
>
colors
=
vtkSmartPointer
<
vtkNamedColors
>::
New
();
vtkSmartPointer
<
vtkPoints
>
points
=
vtkSmartPointer
<
vtkPoints
>
::
New
();
points
->
InsertNextPoint
(
0
,
0
,
0
);
...
...
@@ -62,6 +67,7 @@ int main(int, char*[])
vtkSmartPointer
<
vtkActor
>
actor1
=
vtkSmartPointer
<
vtkActor
>::
New
();
actor1
->
SetMapper
(
mapper1
);
actor1
->
GetProperty
()
->
SetColor
(
colors
->
GetColor3d
(
"Cyan"
).
GetData
());
// Create a mapper and actor
vtkSmartPointer
<
vtkDataSetMapper
>
mapper2
=
...
...
@@ -75,12 +81,14 @@ int main(int, char*[])
vtkSmartPointer
<
vtkActor
>
actor2
=
vtkSmartPointer
<
vtkActor
>::
New
();
actor2
->
SetMapper
(
mapper2
);
actor2
->
GetProperty
()
->
SetColor
(
colors
->
GetColor3d
(
"Yellow"
).
GetData
());
// Create a renderer, render window, and interactor
vtkSmartPointer
<
vtkRenderer
>
renderer
=
vtkSmartPointer
<
vtkRenderer
>::
New
();
vtkSmartPointer
<
vtkRenderWindow
>
renderWindow
=
vtkSmartPointer
<
vtkRenderWindow
>::
New
();
renderWindow
->
SetWindowName
(
"Tetrahedron"
);
renderWindow
->
AddRenderer
(
renderer
);
vtkSmartPointer
<
vtkRenderWindowInteractor
>
renderWindowInteractor
=
vtkSmartPointer
<
vtkRenderWindowInteractor
>::
New
();
...
...
@@ -89,7 +97,7 @@ int main(int, char*[])
// Add the actor to the scene
renderer
->
AddActor
(
actor1
);
renderer
->
AddActor
(
actor2
);
renderer
->
SetBackground
(
.3
,
.6
,
.3
);
// Background color green
renderer
->
SetBackground
(
colors
->
GetColor3d
(
"DarkGreen"
).
GetData
());
// Render and interact
renderWindow
->
Render
();
...
...
This diff is collapsed.
Click to expand it.
src/Python/GeometricObjects/Tetrahedron.py
+
86
−
75
View file @
6c7baa7a
...
...
@@ -2,78 +2,89 @@
import
vtk
points
=
vtk
.
vtkPoints
()
points
.
InsertNextPoint
(
0
,
0
,
0
)
points
.
InsertNextPoint
(
1
,
0
,
0
)
points
.
InsertNextPoint
(
1
,
1
,
0
)
points
.
InsertNextPoint
(
0
,
1
,
1
)
points
.
InsertNextPoint
(
5
,
5
,
5
)
points
.
InsertNextPoint
(
6
,
5
,
5
)
points
.
InsertNextPoint
(
6
,
6
,
5
)
points
.
InsertNextPoint
(
5
,
6
,
6
)
# The first tetrahedron
unstructuredGrid1
=
vtk
.
vtkUnstructuredGrid
()
unstructuredGrid1
.
SetPoints
(
points
)
tetra
=
vtk
.
vtkTetra
()
tetra
.
GetPointIds
().
SetId
(
0
,
0
)
tetra
.
GetPointIds
().
SetId
(
1
,
1
)
tetra
.
GetPointIds
().
SetId
(
2
,
2
)
tetra
.
GetPointIds
().
SetId
(
3
,
3
)
cellArray
=
vtk
.
vtkCellArray
()
cellArray
.
InsertNextCell
(
tetra
)
unstructuredGrid1
.
SetCells
(
vtk
.
VTK_TETRA
,
cellArray
)
# The second tetrahedron
unstructuredGrid2
=
vtk
.
vtkUnstructuredGrid
()
unstructuredGrid2
.
SetPoints
(
points
)
tetra
=
vtk
.
vtkTetra
()
tetra
.
GetPointIds
().
SetId
(
0
,
4
)
tetra
.
GetPointIds
().
SetId
(
1
,
5
)
tetra
.
GetPointIds
().
SetId
(
2
,
6
)
tetra
.
GetPointIds
().
SetId
(
3
,
7
)
cellArray
=
vtk
.
vtkCellArray
()
cellArray
.
InsertNextCell
(
tetra
)
unstructuredGrid2
.
SetCells
(
vtk
.
VTK_TETRA
,
cellArray
)
# Create a mapper and actor
mapper1
=
vtk
.
vtkDataSetMapper
()
if
vtk
.
VTK_MAJOR_VERSION
<=
5
:
mapper1
.
SetInputConnection
(
unstructuredGrid1
.
GetProducerPort
())
else
:
mapper1
.
SetInputData
(
unstructuredGrid1
)
actor1
=
vtk
.
vtkActor
()
actor1
.
SetMapper
(
mapper1
)
# Create a mapper and actor
mapper2
=
vtk
.
vtkDataSetMapper
()
if
vtk
.
VTK_MAJOR_VERSION
<=
5
:
mapper2
.
SetInputConnection
(
unstructuredGrid2
.
GetProducerPort
())
else
:
mapper2
.
SetInputData
(
unstructuredGrid2
)
actor2
=
vtk
.
vtkActor
()
actor2
.
SetMapper
(
mapper2
)
# Create a renderer, render window, and interactor
renderer
=
vtk
.
vtkRenderer
()
renderWindow
=
vtk
.
vtkRenderWindow
()
renderWindow
.
AddRenderer
(
renderer
)
renderWindowInteractor
=
vtk
.
vtkRenderWindowInteractor
()
renderWindowInteractor
.
SetRenderWindow
(
renderWindow
)
# Add the actor to the scene
renderer
.
AddActor
(
actor1
)
renderer
.
AddActor
(
actor2
)
renderer
.
SetBackground
(.
3
,
.
6
,
.
3
)
# Background color green
# Render and interact
renderWindow
.
Render
()
renderWindowInteractor
.
Start
()
def
main
():
colors
=
vtk
.
vtkNamedColors
()
points
=
vtk
.
vtkPoints
()
points
.
InsertNextPoint
(
0
,
0
,
0
)
points
.
InsertNextPoint
(
1
,
0
,
0
)
points
.
InsertNextPoint
(
1
,
1
,
0
)
points
.
InsertNextPoint
(
0
,
1
,
1
)
points
.
InsertNextPoint
(
5
,
5
,
5
)
points
.
InsertNextPoint
(
6
,
5
,
5
)
points
.
InsertNextPoint
(
6
,
6
,
5
)
points
.
InsertNextPoint
(
5
,
6
,
6
)
# The first tetrahedron
unstructuredGrid1
=
vtk
.
vtkUnstructuredGrid
()
unstructuredGrid1
.
SetPoints
(
points
)
tetra
=
vtk
.
vtkTetra
()
tetra
.
GetPointIds
().
SetId
(
0
,
0
)
tetra
.
GetPointIds
().
SetId
(
1
,
1
)
tetra
.
GetPointIds
().
SetId
(
2
,
2
)
tetra
.
GetPointIds
().
SetId
(
3
,
3
)
cellArray
=
vtk
.
vtkCellArray
()
cellArray
.
InsertNextCell
(
tetra
)
unstructuredGrid1
.
SetCells
(
vtk
.
VTK_TETRA
,
cellArray
)
# The second tetrahedron
unstructuredGrid2
=
vtk
.
vtkUnstructuredGrid
()
unstructuredGrid2
.
SetPoints
(
points
)
tetra
=
vtk
.
vtkTetra
()
tetra
.
GetPointIds
().
SetId
(
0
,
4
)
tetra
.
GetPointIds
().
SetId
(
1
,
5
)
tetra
.
GetPointIds
().
SetId
(
2
,
6
)
tetra
.
GetPointIds
().
SetId
(
3
,
7
)
cellArray
=
vtk
.
vtkCellArray
()
cellArray
.
InsertNextCell
(
tetra
)
unstructuredGrid2
.
SetCells
(
vtk
.
VTK_TETRA
,
cellArray
)
# Create a mapper and actor
mapper1
=
vtk
.
vtkDataSetMapper
()
if
vtk
.
VTK_MAJOR_VERSION
<=
5
:
mapper1
.
SetInputConnection
(
unstructuredGrid1
.
GetProducerPort
())
else
:
mapper1
.
SetInputData
(
unstructuredGrid1
)
actor1
=
vtk
.
vtkActor
()
actor1
.
SetMapper
(
mapper1
)
actor1
.
GetProperty
().
SetColor
(
colors
.
GetColor3d
(
"
Cyan
"
))
# Create a mapper and actor
mapper2
=
vtk
.
vtkDataSetMapper
()
if
vtk
.
VTK_MAJOR_VERSION
<=
5
:
mapper2
.
SetInputConnection
(
unstructuredGrid2
.
GetProducerPort
())
else
:
mapper2
.
SetInputData
(
unstructuredGrid2
)
actor2
=
vtk
.
vtkActor
()
actor2
.
SetMapper
(
mapper2
)
actor2
.
GetProperty
().
SetColor
(
colors
.
GetColor3d
(
"
Yellow
"
))
# Create a renderer, render window, and interactor
renderer
=
vtk
.
vtkRenderer
()
renderWindow
=
vtk
.
vtkRenderWindow
()
renderWindow
.
SetWindowName
(
"
Tetrahedron
"
)
renderWindow
.
AddRenderer
(
renderer
)
renderWindowInteractor
=
vtk
.
vtkRenderWindowInteractor
()
renderWindowInteractor
.
SetRenderWindow
(
renderWindow
)
# Add the actor to the scene
renderer
.
AddActor
(
actor1
)
renderer
.
AddActor
(
actor2
)
renderer
.
SetBackground
(
colors
.
GetColor3d
(
"
DarkGreen
"
))
# Render and interact
renderWindow
.
Render
()
renderWindowInteractor
.
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