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
4d61a689
Commit
4d61a689
authored
7 years ago
by
Andrew Maclean
Browse files
Options
Downloads
Patches
Plain Diff
Fixing Point.
Former-commit-id:
30f5b3ec
parent
3f8a8b10
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Cxx/GeometricObjects/Point.cxx
+12
-5
12 additions, 5 deletions
src/Cxx/GeometricObjects/Point.cxx
src/Python/GeometricObjects/Point.py
+37
-29
37 additions, 29 deletions
src/Python/GeometricObjects/Point.py
with
49 additions
and
34 deletions
src/Cxx/GeometricObjects/Point.cxx
+
12
−
5
View file @
4d61a689
#include
<vtkVersion.h>
#include
<vtkSmartPointer.h>
#include
<vtkPoints.h>
#include
<vtkActor.h>
#include
<vtkCellArray.h>
#include
<vtkNamedColors.h>
#include
<vtkPoints.h>
#include
<vtkPolyData.h>
#include
<vtkPolyDataMapper.h>
#include
<vtkActor.h>
#include
<vtkProperty.h>
#include
<vtkRenderWindow.h>
#include
<vtkRenderer.h>
#include
<vtkRenderWindow.h>
#include
<vtkRenderWindowInteractor.h>
#include
<vtkSmartPointer.h>
#include
<vtkVersion.h>
int
main
(
int
,
char
*
[])
{
vtkSmartPointer
<
vtkNamedColors
>
colors
=
vtkSmartPointer
<
vtkNamedColors
>::
New
();
// Create the geometry of a point (the coordinate)
vtkSmartPointer
<
vtkPoints
>
points
=
vtkSmartPointer
<
vtkPoints
>::
New
();
...
...
@@ -20,6 +24,7 @@ int main(int, char *[])
// Create the topology of the point (a vertex)
vtkSmartPointer
<
vtkCellArray
>
vertices
=
vtkSmartPointer
<
vtkCellArray
>::
New
();
// We need an an array of point id's for InsertNextCell.
vtkIdType
pid
[
1
];
pid
[
0
]
=
points
->
InsertNextPoint
(
p
);
vertices
->
InsertNextCell
(
1
,
pid
);
...
...
@@ -44,6 +49,7 @@ int main(int, char *[])
vtkSmartPointer
<
vtkActor
>
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
actor
->
SetMapper
(
mapper
);
actor
->
GetProperty
()
->
SetColor
(
colors
->
GetColor3d
(
"Tomato"
).
GetData
());
actor
->
GetProperty
()
->
SetPointSize
(
20
);
vtkSmartPointer
<
vtkRenderer
>
renderer
=
...
...
@@ -56,6 +62,7 @@ int main(int, char *[])
renderWindowInteractor
->
SetRenderWindow
(
renderWindow
);
renderer
->
AddActor
(
actor
);
renderer
->
SetBackground
(
colors
->
GetColor3d
(
"DarkOliveGreen"
).
GetData
());
renderWindow
->
Render
();
renderWindowInteractor
->
Start
();
...
...
This diff is collapsed.
Click to expand it.
src/Python/GeometricObjects/Point.py
+
37
−
29
View file @
4d61a689
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
vtk
# Create the geometry of a point (the coordinate)
points
=
vtk
.
vtkPoints
()
p
=
[
1.0
,
2.0
,
3.0
]
# Create the topology of the point (a vertex)
vertice
s
=
vtk
.
vtk
CellArray
()
def
main
():
color
s
=
vtk
.
vtk
NamedColors
()
id
=
points
.
InsertNextPoint
(
p
)
vertices
.
InsertNextCell
(
1
)
vertices
.
InsertCellPoint
(
id
)
# Create the geometry of a point (the coordinate
)
points
=
vtk
.
vtkPoints
(
)
p
=
[
1.0
,
2.0
,
3.0
]
# Create a polydata object
point
=
vtk
.
vtkPolyData
()
# Create the topology of the point (a vertex)
vertices
=
vtk
.
vtkCellArray
()
# We need an an array of point id's for InsertNextCell.
pid
=
[
0
]
pid
[
0
]
=
points
.
InsertNextPoint
(
p
)
vertices
.
InsertNextCell
(
1
,
pid
)
# Set the points and vertices we created as the geometry and topology of the polydata
point
.
SetPoints
(
points
)
point
.
SetVerts
(
vertices
)
# Create a polydata object
point
=
vtk
.
vtkPolyData
()
# Visualize
mapper
=
vtk
.
vtkPolyDataMapper
()
if
vtk
.
VTK_MAJOR_VERSION
<=
5
:
mapper
.
SetInput
(
point
)
else
:
# Set the points and vertices we created as the geometry and topology of the polydata
point
.
SetPoints
(
points
)
point
.
SetVerts
(
vertices
)
# Visualize
mapper
=
vtk
.
vtkPolyDataMapper
()
mapper
.
SetInputData
(
point
)
actor
=
vtk
.
vtkActor
()
actor
.
SetMapper
(
mapper
)
actor
.
GetProperty
().
SetPointSize
(
20
)
actor
=
vtk
.
vtkActor
()
actor
.
SetMapper
(
mapper
)
actor
.
GetProperty
().
SetColor
(
colors
.
GetColor3d
(
"
Tomato
"
))
actor
.
GetProperty
().
SetPointSize
(
20
)
renderer
=
vtk
.
vtkRenderer
()
renderWindow
=
vtk
.
vtkRenderWindow
()
renderWindow
.
AddRenderer
(
renderer
)
renderWindowInteractor
=
vtk
.
vtkRenderWindowInteractor
()
renderWindowInteractor
.
SetRenderWindow
(
renderWindow
)
renderer
.
AddActor
(
actor
)
renderer
.
SetBackground
(
colors
.
GetColor3d
(
"
DarkOliveGreen
"
))
renderer
=
vtk
.
vtkRenderer
()
renderWindow
=
vtk
.
vtkRenderWindow
()
renderWindow
.
AddRenderer
(
renderer
)
renderWindowInteractor
=
vtk
.
vtkRenderWindowInteractor
()
renderWindowInteractor
.
SetRenderWindow
(
renderWindow
)
renderWindow
.
Render
()
renderWindowInteractor
.
Start
()
renderer
.
AddActor
(
actor
)
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