[vtkusers] Programmable source not visualized

Olivier Rodenberg orodenberg at gmail.com
Mon Feb 22 08:42:33 EST 2016


Hi, 

I am trying to visualize an hexahedron in Paraview using a programmable source. The points and cells are created, however the hexahedron is not visualized. Bellow is the code of the hexahedron. Does anyone know the what is missing in the code?

>From paraview import vtk

numberOfVertices = 8
 
# Create the points
points = vtk.vtkPoints()
points.InsertNextPoint(0.0, 0.0, 0.0)
points.InsertNextPoint(1.0, 0.0, 0.0)
points.InsertNextPoint(1.0, 1.0, 0.0)
points.InsertNextPoint(0.0, 1.0, 0.0)
points.InsertNextPoint(0.0, 0.0, 1.0)
points.InsertNextPoint(1.0, 0.0, 1.0)
points.InsertNextPoint(1.0, 1.0, 1.0)
points.InsertNextPoint(0.0, 1.0, 1.0)

# Create a hexahedron from the points
hex_ = vtk.vtkHexahedron()
for i in range(0, numberOfVertices):
    hex_.GetPointIds().SetId(i, i)

#Create scalars
scalars = vtk.vtkDoubleArray()
scalars.SetName('First Property')
scalars.InsertNextValue(100.0)
scalars.InsertNextValue(100.2)
scalars.InsertNextValue(100.0)
scalars.InsertNextValue(100.2)
scalars.InsertNextValue(100.0)
scalars.InsertNextValue(100.2)
scalars.InsertNextValue(100.0)
scalars.InsertNextValue(100.2)

# Add the points and hexahedron to an unstructured grid
uGrid = vtk.vtkUnstructuredGrid()
uGrid.Allocate(1,1)
uGrid.InsertNextCell(hex_.GetCellType(), hex_.GetPointIds())
uGrid.SetPoints(points)
uGrid.GetPointData().SetScalars(scalars)    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160222/627df03f/attachment.html>


More information about the vtkusers mailing list