[vtkusers] Triangle Geometry and Vertices

Paulo Henrique Junqueira Amorim paulojamorim at gmail.com
Sat Dec 11 21:41:02 EST 2010


Hi,

I'm trying to write this example (
http://www.vtk.org/Wiki/VTK/Tutorials/TriangleGeometryVertices ) in python
language.

When you open the VTK rendering window occurs Segmentation fault.

I tried to open the file (.vtp) in the Paraview, when click on Apply, the
Paraview closes.

Regards,
Paulo


*The code:
*
from vtk import *

X = [1.0, 0.0, 0.0]
Y = [0.0, 0.0, 1.0]
Z = [0.0, 0.0, 0.0]

points = vtkPoints()
vertices = vtkCellArray()

ids = vtkIdList()
ids.SetNumberOfIds(3)

for i in xrange(3):
    ids.SetId(i, i)
    points.InsertNextPoint(X[i],Y[i],Z[i])
    vertices.InsertNextCell(ids)

writer = vtkXMLPolyDataWriter()
writer.SetFileName ( ".//TriangleVerts.vtp")
writer.SetInput(polydata)
writer.Write()

polydata = vtkPolyData()
polydata.SetPoints(points)
polydata.SetVerts(vertices)
polydata.Update()

mapper = vtkPolyDataMapper()
mapper.SetInput(polydata)

actor = vtkActor()
actor.SetMapper(mapper)

ren = vtkRenderer()
ren.AddActor(actor)

renWin = vtkRenderWindow()
renWin.AddRenderer( ren )

iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

renWin.Render()


*VTP File Content:*


<?xml version="1.0"?>
<VTKFile type="PolyData" version="0.1" byte_order="LittleEndian"
compressor="vtkZLibDataCompressor">
  <PolyData>
    <Piece NumberOfPoints="3"
NumberOfVerts="3"                    NumberOfLines="0"
NumberOfStrips="0"                    NumberOfPolys="0"                   >
      <PointData>
      </PointData>
      <CellData>
      </CellData>
      <Points>
        <DataArray type="Float32" Name="Points" NumberOfComponents="3"
format="appended" RangeMin="0"
RangeMax="1"                    offset="0"                   />
      </Points>
      <Verts>
        <DataArray type="Int64" Name="connectivity" format="appended"
RangeMin=""                     RangeMax=""
offset="48"                  />
        <DataArray type="Int64" Name="offsets" format="appended"
RangeMin=""                     RangeMax=""
offset="108"                 />
      </Verts>
      <Lines>
        <DataArray type="Int64" Name="connectivity" format="appended"
RangeMin=""                     RangeMax=""
offset="156"                 />
        <DataArray type="Int64" Name="offsets" format="appended"
RangeMin=""                     RangeMax=""
offset="172"                 />
      </Lines>
      <Strips>
        <DataArray type="Int64" Name="connectivity" format="appended"
RangeMin=""                     RangeMax=""
offset="188"                 />
        <DataArray type="Int64" Name="offsets" format="appended"
RangeMin=""                     RangeMax=""
offset="204"                 />
      </Strips>
      <Polys>
        <DataArray type="Int64" Name="connectivity" format="appended"
RangeMin=""                     RangeMax=""
offset="220"                 />
        <DataArray type="Int64" Name="offsets" format="appended"
RangeMin=""                     RangeMax=""
offset="236"                 />
      </Polys>
    </Piece>
  </PolyData>
  <AppendedData encoding="base64">

_AQAAAACAAAAkAAAAEAAAAA==eJxjYGiwZ8AJIHIAHX4Bfw==AQAAAACAAAAwAAAAGQAAAA==eJxjYICAFXqXL8XXM8ABIwMqgPEBffcDXA==AQAAAACAAAAYAAAAEAAAAA==eJxjYoAAFijNBqUBALgADQ==AAAAAACAAAAAAAAAAAAAAACAAAAAAAAAAAAAAACAAAAAAAAAAAAAAACAAAAAAAAAAAAAAACAAAAAAAAAAAAAAACAAAAAAAAA
  </AppendedData>
</VTKFile>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101212/2ed020f7/attachment.htm>


More information about the vtkusers mailing list