Esempio n. 1
0
 def testFloatReference(self):
     m = svtk.reference(3.0)
     n = svtk.reference(4.0)
     m *= 2
     self.assertEqual(m, 6.0)
     self.assertEqual(str(m), str(m.get()))
     o = n + m
     self.assertEqual(o, 10.0)
Esempio n. 2
0
 def testPassTupleByReference(self):
     n = svtk.reference(0)
     t = svtk.reference((0, ))
     ca = svtk.svtkCellArray()
     ca.InsertNextCell(3, (1, 3, 0))
     ca.GetCell(0, n, t)
     self.assertEqual(n, 3)
     self.assertEqual(tuple(t), (1, 3, 0))
Esempio n. 3
0
 def testPassByReferenceerence(self):
     t = svtk.reference(0.0)
     p0 = (0.5, 0.0, 0.0)
     n = (1.0, 0.0, 0.0)
     p1 = (0.0, 0.0, 0.0)
     p2 = (1.0, 1.0, 1.0)
     x = [0.0, 0.0, 0.0]
     svtk.svtkPlane.IntersectWithLine(p1, p2, n, p0, t, x)
     self.assertEqual(round(t, 6), 0.5)
     self.assertEqual(round(x[0], 6), 0.5)
     self.assertEqual(round(x[1], 6), 0.5)
     self.assertEqual(round(x[2], 6), 0.5)
     svtk.svtkPlane().IntersectWithLine(p1, p2, n, p0, t, x)
     self.assertEqual(round(t, 6), 0.5)
     self.assertEqual(round(x[0], 6), 0.5)
     self.assertEqual(round(x[1], 6), 0.5)
     self.assertEqual(round(x[2], 6), 0.5)
     t.set(0)
     p = svtk.svtkPlane()
     p.SetOrigin(0.5, 0.0, 0.0)
     p.SetNormal(1.0, 0.0, 0.0)
     p.IntersectWithLine(p1, p2, t, x)
     self.assertEqual(round(t, 6), 0.5)
     self.assertEqual(round(x[0], 6), 0.5)
     self.assertEqual(round(x[1], 6), 0.5)
     self.assertEqual(round(x[2], 6), 0.5)
     svtk.svtkPlane.IntersectWithLine(p, p1, p2, t, x)
     self.assertEqual(round(t, 6), 0.5)
     self.assertEqual(round(x[0], 6), 0.5)
     self.assertEqual(round(x[1], 6), 0.5)
     self.assertEqual(round(x[2], 6), 0.5)
Esempio n. 4
0
 def testMethods(self):
     """Test overloaded methods"""
     # single-argument method svtkTransform::SetMatrix()
     t = svtk.svtkTransform()
     m = svtk.svtkMatrix4x4()
     m.SetElement(0, 0, 2)
     t.SetMatrix(m)
     self.assertEqual(t.GetMatrix().GetElement(0, 0), 2)
     t.SetMatrix([0, 1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1])
     self.assertEqual(t.GetMatrix().GetElement(0, 0), 0)
     # mixed number of arguments
     fd = svtk.svtkFieldData()
     fa = svtk.svtkFloatArray()
     fa.SetName("Real")
     ia = svtk.svtkIntArray()
     ia.SetName("Integer")
     fd.AddArray(fa)
     fd.AddArray(ia)
     a = fd.GetArray("Real")
     self.assertEqual(id(a), id(fa))
     i = svtk.reference(0)
     a = fd.GetArray("Integer", i)
     self.assertEqual(id(a), id(ia))
     self.assertEqual(i, 1)
Esempio n. 5
0
 def testTupleReference(self):
     m = svtk.reference((0, ))
     self.assertEqual(m, (0, ))
     self.assertEqual(len(m), 1)
     self.assertEqual(m[0], 0)
Esempio n. 6
0
 def testStringReference(self):
     m = svtk.reference("%s %s!")
     m %= ("hello", "world")
     self.assertEqual(m, "hello world!")
Esempio n. 7
0
 def testIntReference(self):
     m = svtk.reference(3)
     n = svtk.reference(4)
     m |= n
     self.assertEqual(m, 7.0)
     self.assertEqual(str(m), str(m.get()))
Esempio n. 8
0
        i, staticLocator.FindClosestPoint(probePoints.GetPoint(i)))
staticTimer.StopTimer()
staticOpTime = staticTimer.GetElapsedTime()
print("    Static Closest point probing: {0}".format(staticOpTime))
print("    Divisions: {0}".format(staticLocator.GetDivisions()))

# Poke other methods before deleting static locator class
staticClosestN = svtk.svtkIdList()
staticLocator.FindClosestNPoints(10, probePoints.GetPoint(0), staticClosestN)

# Intersect with line
# Out of plane line intersecction
a0 = [0.5, 0.5, 1]
a1 = [0.5, 0.5, -1]
tol = 0.001
t = svtk.reference(0.0)
lineX = [0.0, 0.0, 0.0]
ptX = [0.0, 0.0, 0.0]
ptId = svtk.reference(-100)
staticLocator.IntersectWithLine(a0, a1, tol, t, lineX, ptX, ptId)
print("    Out of plane line intersection: PtId {0}".format(ptId))

# In plane line intersection
a0 = [-1.5, 0.5, 0]
a1 = [1.5, 0.5, 0]
tol = 0.001
t = svtk.reference(0.0)
lineX = [0.0, 0.0, 0.0]
ptX = [0.0, 0.0, 0.0]
ptId = svtk.reference(-100)
staticLocator.IntersectWithLine(a0, a1, tol, t, lineX, ptX, ptId)