예제 #1
0
 def testVariantExtract(self):
     """Use vtkVariantExtract"""
     l = [1, '2', cedilla, 4.0, vtk.vtkObject()]
     s = [vtk.vtkVariant(x) for x in l]
     m = [vtk.vtkVariantExtract(x) for x in s]
     self.assertEqual(l, m)
예제 #2
0
파일: TestVariant.py 프로젝트: ALouis38/VTK
 def testVariantExtract(self):
     """Use vtkVariantExtract"""
     l = [1, '2', cedilla, 4.0, vtk.vtkObject()]
     s = [vtk.vtkVariant(x) for x in l]
     m = [vtk.vtkVariantExtract(x) for x in s]
     self.assertEqual(l, m)
예제 #3
0
print("Index is %i" % d[vtk.vtkVariant(1.0)])

#
# Extra functionality from vtk.util.vtkVariant
#
# These are templated functions in C++, but in Python
# they take the template arg as a string instead,
# e.g. vtkVariantCreate<unsigned int>(1) becomes
#      vtkVariantCreate(1, 'unsigned int')

# Creation
v = vtk.vtkVariantCreate(1, 'unsigned int')

# Value extraction
v = vtk.vtkVariant(6.0)
f = vtk.vtkVariantExtract(v)

# Value extraction with type specified
f = vtk.vtkVariantExtract(v, 'double')

# Casting a variant
v = vtk.vtkVariant("10")
i = vtk.vtkVariantCast(v, 'int')
print("Valid cast result: %r" % i)

# A failed cast returns None
v = vtk.vtkVariant("hello")
i = vtk.vtkVariantCast(v, 'int')
print("Invalid cast result: %r" % i)

#
예제 #4
0
print("Index is %i" % d[vtk.vtkVariant(1.0)])

#
# Extra functionality from vtk.util.vtkVariant
#
# These are templated functions in C++, but in Python
# they take the template arg as a string instead,
# e.g. vtkVariantCreate<unsigned int>(1) becomes
#      vtkVariantCreate(1, 'unsigned int')

# Creation
v = vtk.vtkVariantCreate(1, 'unsigned int')

# Value extraction
v = vtk.vtkVariant(6.0)
f = vtk.vtkVariantExtract(v)

# Value extraction with type specified
f = vtk.vtkVariantExtract(v, 'double')

# Casting a variant
v = vtk.vtkVariant("10")
i = vtk.vtkVariantCast(v, 'int')
print("Valid cast result: %r" % i)

# A failed cast returns None
v = vtk.vtkVariant("hello")
i = vtk.vtkVariantCast(v, 'int')
print("Invalid cast result: %r" % i)

#