예제 #1
0
 def testArray(self):
     """Test values, tuples, components of arrays
     """
     array = svtk.svtkDoubleArray()
     array.SetNumberOfComponents(2)
     t = (2.0, 10.0)
     array.InsertNextTuple(t)
     array.InsertNextTuple(t)
     array.InsertNextTuple(t)
     self.assertEqual(array.GetTuple(0), t)
     self.assertEqual(array.GetTuple(2), t)
     with self.assertRaises(ValueError):
         array.GetTuple(-1)
     with self.assertRaises(ValueError):
         array.GetTuple(3)
     with self.assertRaises(ValueError):
         array.SetTuple(-1, t)
     with self.assertRaises(ValueError):
         array.SetTuple(3, t)
     self.assertEqual(array.GetValue(0), 2.0)
     self.assertEqual(array.GetValue(5), 10.0)
     with self.assertRaises(ValueError):
         array.GetValue(-1)
     with self.assertRaises(ValueError):
         array.GetValue(6)
     with self.assertRaises(ValueError):
         array.SetValue(-1, 2.0)
     with self.assertRaises(ValueError):
         array.SetValue(6, 10.0)
     self.assertEqual(array.GetComponent(0, 1), 10.0)
     with self.assertRaises(ValueError):
         array.GetComponent(0, -1)
     with self.assertRaises(ValueError):
         array.GetComponent(0, 2)
     with self.assertRaises(ValueError):
         array.GetComponent(-1, 0)
     with self.assertRaises(ValueError):
         array.GetComponent(3, 1)
     with self.assertRaises(ValueError):
         array.SetComponent(0, -1, 0.0)
     with self.assertRaises(ValueError):
         array.SetComponent(0, 2, 0.0)
     with self.assertRaises(ValueError):
         array.SetComponent(-1, 0, 0.0)
     with self.assertRaises(ValueError):
         array.SetComponent(3, 1, 0.0)
예제 #2
0
#!/usr/bin/env python
import svtk

htg = svtk.svtkHyperTreeGrid()
htg.Initialize()

scalarArray = svtk.svtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')

htg.SetDimensions([4, 3, 1])
htg.SetBranchFactor(2)

# Rectilinear grid coordinates
xValues = svtk.svtkDoubleArray()
xValues.SetNumberOfValues(4)
xValues.SetValue(0, -1)
xValues.SetValue(1, 0)
xValues.SetValue(2, 1)
xValues.SetValue(3, 2)
htg.SetXCoordinates(xValues);

yValues = svtk.svtkDoubleArray()
yValues.SetNumberOfValues(3)
yValues.SetValue(0, -1)
yValues.SetValue(1, 0)
yValues.SetValue(2, 1)
htg.SetYCoordinates(yValues);
예제 #3
0
htg.Initialize()

scalarArray = svtk.svtkUnsignedCharArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(26)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')

for i in range(26):
    scalarArray.InsertTuple1(i, i + 1)

htg.SetDimensions([4, 3, 1])
htg.SetBranchFactor(2)

# rectilinear grid coordinates
xValues = svtk.svtkDoubleArray()
xValues.SetNumberOfValues(4)
xValues.SetValue(0, -1)
xValues.SetValue(1, 0)
xValues.SetValue(2, 1)
xValues.SetValue(3, 2)
htg.SetXCoordinates(xValues)

yValues = svtk.svtkDoubleArray()
yValues.SetNumberOfValues(3)
yValues.SetValue(0, -1)
yValues.SetValue(1, 0)
yValues.SetValue(2, 1)
htg.SetYCoordinates(yValues)

zValues = svtk.svtkDoubleArray()
#!/usr/bin/env python
"""
Create a HTG
without mask
during HTG build we build scalar, used Global Index implicit with SetGlobalIndexStart
SetGlobalIndexStart, one call by HT
"""
import svtk

htg = svtk.svtkUniformHyperTreeGrid()
htg.Initialize()

scalarArray = svtk.svtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')

htg.SetDimensions([4, 3, 1])
htg.SetBranchFactor(2)
htg.SetOrigin([-1., -1., -2])
htg.SetGridScale([1., 1., 1.])

# Let's split the various trees
cursor = svtk.svtkHyperTreeGridNonOrientedCursor()
offsetIndex = 0

# ROOT CELL 0
htg.InitializeNonOrientedCursor(cursor, 0, True)
cursor.SetGlobalIndexStart(offsetIndex)