Is it the Helix example you are referring to?
In that case I fail to find the equivalent methods for fixing/adding the cells.
The code that I manage to run so far is listed below. The cells are not working properly, changing Outline to Surface or Surface with Edges. Adding spherical glypsh gives the following output
I’m expecting one sphere in each corner, but there’s only two of those corners.
Each edge should have two spheres and each face should have have four spheres.
Is there a reason some points are missing? Is it related to the missing cell structure?
How can one fix the code so the cells gets properly defined?
import numpy as np
import vtk
from paraview.util.vtkAlgorithm import *
from vtkmodules.numpy_interface import dataset_adapter as dsa
from vtkmodules.vtkCommonDataModel import vtkExplicitStructuredGrid
@smproxy.source(name="ExplicitGrid_refactor",
label="TestExplicitGrid")
class PythonESGReader(VTKPythonAlgorithmBase):
def __init__(self):
VTKPythonAlgorithmBase.__init__(self, nInputPorts=0, nOutputPorts=1, outputType='vtkExplicitStructuredGrid')
self.__N = 3
def RequestInformation(self, request, inInfoVec, outInfoVec):
executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
outInfo.Set(executive.WHOLE_EXTENT(), 0, self.__N-1, 0, self.__N-1, 0, self.__N-1)
return 1
def RequestData(self, request, inInfoVec, outInfoVec):
extent = (0, self.__N-1, 0, self.__N-1, 0, self.__N-1)
nx = extent[1] - extent[0]
ny = extent[3] - extent[2]
nz = extent[5] - extent[4]
expected_cells = nx * ny * nz
output = dsa.WrapDataObject(
vtkExplicitStructuredGrid.GetData(outInfoVec, 0)
)
output.SetExtent(*extent)
newPoints = vtk.vtkPoints()
newPoints.Allocate(expected_cells * 8)
for k in range(nx):
for j in range(ny):
for i in range(nz):
# in each direction, shift the second cell
dx, dy, dz = 0.0, 0.0, 0.0
if i > 0:
dx = 0.2
if j > 0:
dy = 0.2
if k > 0:
dz = 0.2
# Add eight points
newPoints.InsertNextPoint(i-0.5+dx, j-0.5+dy, k-0.5+dz)
newPoints.InsertNextPoint(i+0.5+dx, j-0.5+dy, k-0.5+dz)
newPoints.InsertNextPoint(i-0.5+dx, j+0.5+dy, k-0.5+dz)
newPoints.InsertNextPoint(i+0.5+dx, j+0.5+dy, k-0.5+dz)
newPoints.InsertNextPoint(i-0.5+dx, j-0.5+dy, k+0.5+dz)
newPoints.InsertNextPoint(i+0.5+dx, j-0.5+dy, k+0.5+dz)
newPoints.InsertNextPoint(i-0.5+dx, j+0.5+dy, k+0.5+dz)
newPoints.InsertNextPoint(i+0.5+dx, j+0.5+dy, k+0.5+dz)
output.SetPoints(newPoints)
return 1