Difference between revisions of "VTK/Examples/Python/TriangleCorners"

From KitwarePublic
< VTK‎ | Examples‎ | Python
Jump to navigationJump to search
m (Did not have example name.)
 
Line 3: Line 3:
 
import vtk
 
import vtk
 
from vtk import *
 
from vtk import *
import hybrid
 
from hybrid import *
 
  
 
Points = vtk.vtkPoints()
 
Points = vtk.vtkPoints()
Line 13: Line 11:
 
polydata = vtk.vtkPolyData()
 
polydata = vtk.vtkPolyData()
 
polydata.SetPoints(Points)
 
polydata.SetPoints(Points)
polydata.Update()
+
if vtk.VTK_MAJOR_VERSION <= 5:
 +
    polydata.Update()
  
 
writer = vtk.vtkXMLPolyDataWriter();
 
writer = vtk.vtkXMLPolyDataWriter();
 
writer.SetFileName("TrianglePoints.vtp");
 
writer.SetFileName("TrianglePoints.vtp");
writer.SetInput(polydata);
+
if vtk.VTK_MAJOR_VERSION <= 5:
writer.Write();
+
    writer.SetInput(polydata)
 +
else:
 +
    writer.SetInputData(polydata)
 +
writer.Write()
  
 
</source>
 
</source>

Latest revision as of 19:20, 28 May 2012

TriangleCorners.py

import vtk
from vtk import *

Points = vtk.vtkPoints()
Points.InsertNextPoint(1.0, 0.0, 0.0)
Points.InsertNextPoint(0.0, 0.0, 0.0)
Points.InsertNextPoint(0.0, 1.0, 0.0)

polydata = vtk.vtkPolyData()
polydata.SetPoints(Points)
if vtk.VTK_MAJOR_VERSION <= 5:
    polydata.Update()

writer = vtk.vtkXMLPolyDataWriter();
writer.SetFileName("TrianglePoints.vtp");
if vtk.VTK_MAJOR_VERSION <= 5:
    writer.SetInput(polydata)
else:
    writer.SetInputData(polydata)
writer.Write()