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

Fixing Point.

Former-commit-id: 30f5b3ec
parent 3f8a8b10
No related branches found
No related tags found
No related merge requests found
#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();
......
#!/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)
vertices = vtk.vtkCellArray()
def main():
colors = vtk.vtkNamedColors()
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()
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