def nonOrientedCursor( htg, waited ):
    nb = 0
    cursor = vtk.vtkHyperTreeGridNonOrientedCursor()
    for treeId in range(htg.GetMaxNumberOfTrees()):
        htg.InitializeNonOrientedCursor( cursor, treeId )
        if not cursor.IsMasked():
            nb += recursive( cursor )
    print('nb: ', nb)
    if waited and nb != waited:
        print('ERROR Not corresponding waited value')
    return nb
def nonOrientedCursor(htg, waited):
    nb = 0
    cursor = vtk.vtkHyperTreeGridNonOrientedCursor()
    for treeId in range(htg.GetMaxNumberOfTrees()):
        htg.InitializeNonOrientedCursor(cursor, treeId)
        if not cursor.IsMasked():
            nb += recursive(cursor)
    print('nb: ', nb)
    if waited and nb != waited:
        print('ERROR Not corresponding waited value')
    return nb
示例#3
0
    def RequestData(self, vtkself, request, inInfo, outInfo):
        inp = self.GetInputData(inInfo, 0, 0)
        out = self.GetOutputData(outInfo, 0)
        out.ShallowCopy(inp)

        scalar = inp.GetPointData().GetArray('scalar')
        assert (scalar)

        outMask = vtk.vtkBitArray()
        outMask.SetNumberOfTuples(out.GetNumberOfVertices())

        cursor = vtk.vtkHyperTreeGridNonOrientedCursor()
        for treeId in range(inp.GetMaxNumberOfTrees()):
            inp.InitializeNonOrientedCursor(cursor, treeId)
            self.RecursiveProcess(cursor, scalar, outMask)

        out.SetMask(outMask)
        return 1
yValues.SetNumberOfValues(3)
yValues.SetValue(0, -1)
yValues.SetValue(1, 0)
yValues.SetValue(2, 1)
htg.SetYCoordinates(yValues);

zValues = vtk.vtkDoubleArray()
zValues.SetNumberOfValues(4)
zValues.SetValue(0, -1)
zValues.SetValue(1, 0)
zValues.SetValue(2, 1)
zValues.SetValue(3, 2)
htg.SetZCoordinates(zValues);

# Let's split the various trees
cursor = vtk.vtkHyperTreeGridNonOrientedCursor()
offsetIndex = 0

# ROOT CELL 0-5
for iHT in range(6):
  htg.InitializeNonOrientedCursor(cursor, iHT, True)
  cursor.SetGlobalIndexStart(offsetIndex)
  idx = cursor.GetGlobalNodeIndex()
  scalarArray.InsertTuple1(idx, iHT+1)
  offsetIndex += cursor.GetTree().GetNumberOfVertices()

# ROOT CELL 6
htg.InitializeNonOrientedCursor(cursor, 6, True)
cursor.SetGlobalIndexStart(offsetIndex)
idx = cursor.GetGlobalNodeIndex()
scalarArray.InsertTuple1(idx, 7)
yValues.SetNumberOfValues(3)
yValues.SetValue(0, -1)
yValues.SetValue(1, 0)
yValues.SetValue(2, 1)
htg.SetYCoordinates(yValues)

zValues = vtk.vtkDoubleArray()
zValues.SetNumberOfValues(4)
zValues.SetValue(0, -1)
zValues.SetValue(1, 0)
zValues.SetValue(2, 1)
zValues.SetValue(3, 2)
htg.SetZCoordinates(zValues)

# Let's split the various trees
cursor = vtk.vtkHyperTreeGridNonOrientedCursor()
offsetIndex = 0

# ROOT CELL 0-5
for iHT in range(6):
    htg.InitializeNonOrientedCursor(cursor, iHT, True)
    cursor.SetGlobalIndexStart(offsetIndex)
    idx = cursor.GetGlobalNodeIndex()
    scalarArray.InsertTuple1(idx, iHT + 1)
    offsetIndex += cursor.GetTree().GetNumberOfVertices()

# ROOT CELL 6
htg.InitializeNonOrientedCursor(cursor, 6, True)
cursor.SetGlobalIndexStart(offsetIndex)
idx = cursor.GetGlobalNodeIndex()
scalarArray.InsertTuple1(idx, 7)