本文整理汇总了Python中vtk.vtkCollection函数的典型用法代码示例。如果您正苦于以下问题:Python vtkCollection函数的具体用法?Python vtkCollection怎么用?Python vtkCollection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkCollection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.vtkObjs = [vtk.vtkObject() for _ in range(30)]
self.collection = vtk.vtkCollection()
for obj in self.vtkObjs:
self.collection.AddItem(obj)
self.emptyCollection = vtk.vtkCollection()
示例2: examineForImport
def examineForImport(self,fileLists):
""" Returns a list of qSlicerDICOMLoadable
instances corresponding to ways of interpreting the
fileLists parameter.
"""
# Create loadables for each file list
loadables = []
for fileList in fileLists: # Each file list corresponds to one series, so do loadables
# Convert file list to VTK object to be able to pass it for examining
# (VTK class cannot have Qt object as argument, otherwise it is not python wrapped)
vtkFileList = vtk.vtkStringArray()
for file in fileList:
vtkFileList.InsertNextValue(slicer.util.toVTKString(file))
# Examine files
loadablesCollection = vtk.vtkCollection()
slicer.modules.dicomrtimportexport.logic().ExamineForLoad(vtkFileList, loadablesCollection)
for loadableIndex in xrange(0,loadablesCollection.GetNumberOfItems()):
vtkLoadable = loadablesCollection.GetItemAsObject(loadableIndex)
# Create Qt loadable if confidence is greater than 0
if vtkLoadable.GetConfidence() > 0:
# Convert to Qt loadable to pass it back
qtLoadable = slicer.qSlicerDICOMLoadable()
qtLoadable.copyFromVtkLoadable(vtkLoadable)
qtLoadable.tooltip = 'Valid RT object in selection'
qtLoadable.selected = True
loadables.append(qtLoadable)
return loadables
示例3: loadNode
def loadNode(self, uri, name, fileType = 'VolumeFile', fileProperties = {}):
self.logMessage('<b>Requesting load</b> <i>%s</i> from %s...\n' % (name, uri))
fileProperties['fileName'] = uri
fileProperties['name'] = name
firstLoadedNode = None
loadedNodes = vtk.vtkCollection()
success = slicer.app.coreIOManager().loadNodes(fileType, fileProperties, loadedNodes)
if not success or loadedNodes.GetNumberOfItems()<1:
self.logMessage('<b><font color="red">\tLoad failed!</font></b>\n')
return None
self.logMessage('<b>Load finished</b>\n')
# since nodes were read from a temp directory remove the storage nodes
for i in range(loadedNodes.GetNumberOfItems()):
loadedNode = loadedNodes.GetItemAsObject(i)
if not loadedNode.IsA("vtkMRMLStorableNode"):
continue
storageNode = loadedNode.GetStorageNode()
if not storageNode:
continue
slicer.mrmlScene.RemoveNode(storageNode)
loadedNode.SetAndObserveStorageNodeID(None)
return loadedNodes.GetItemAsObject(0)
示例4: addRuler
def addRuler(widget, color=None):
color = color if color else [0.25, 0.25, 0.75]
controller = widget.sliceController()
sliceView = widget.sliceView()
controller.setRulerType(2)
collection = vtk.vtkCollection()
sliceView.getDisplayableManagers(collection)
manager = None
for i in range(collection.GetNumberOfItems()):
if type(collection.GetItemAsObject(i)) is slicer.vtkMRMLRulerDisplayableManager:
manager = collection.GetItemAsObject(i)
break
renderers = manager.GetRenderer().GetRenderWindow().GetRenderers()
axisActor = None
textActor = None
for i in range(renderers.GetNumberOfItems()):
actors2D = renderers.GetItemAsObject(i).GetActors2D()
for j in range(actors2D.GetNumberOfItems()):
if type(actors2D.GetItemAsObject(j)) is vtk.vtkTextActor:
textActor = actors2D.GetItemAsObject(j)
elif type(actors2D.GetItemAsObject(j)) is vtk.vtkAxisActor2D:
axisActor = actors2D.GetItemAsObject(j)
if axisActor and textActor:
axisActor.GetProperty().SetColor(color)
textActor.GetProperty().SetColor(color)
sliceView.update()
break
示例5: getModel3DDisplayableManager
def getModel3DDisplayableManager(self):
threeDViewWidget = slicer.app.layoutManager().threeDWidget(0)
managers = vtk.vtkCollection()
threeDViewWidget.getDisplayableManagers(managers)
for i in range(managers.GetNumberOfItems()):
obj = managers.GetItemAsObject(i)
if obj.IsA('vtkMRMLLinearTransformsDisplayableManager3D'):
return obj
return None
示例6: export
def export(self, exportables):
exportablesCollection = vtk.vtkCollection()
for exportable in exportables:
vtkExportable = slicer.vtkSlicerDICOMExportable()
exportable.copyToVtkExportable(vtkExportable)
exportablesCollection.AddItem(vtkExportable)
self.exportAsDICOMSEG(exportablesCollection)
示例7: getFiducialSliceDisplayableManagerHelper
def getFiducialSliceDisplayableManagerHelper(self,sliceName='Red'):
sliceWidget = slicer.app.layoutManager().sliceWidget(sliceName)
sliceView = sliceWidget.sliceView()
collection = vtk.vtkCollection()
sliceView.getDisplayableManagers(collection)
for i in range(collection.GetNumberOfItems()):
m = collection.GetItemAsObject(i)
if m.GetClassName() == "vtkMRMLMarkupsFiducialDisplayableManager2D":
return m.GetHelper()
return None
示例8: export
def export(self,exportables):
# Convert Qt loadables to VTK ones for the RT export logic
exportablesCollection = vtk.vtkCollection()
for exportable in exportables:
vtkExportable = slicer.vtkSlicerDICOMExportable()
exportable.copyToVtkExportable(vtkExportable)
exportablesCollection.AddItem(vtkExportable)
# Export RT study
message = slicer.modules.dicomrtimportexport.logic().ExportDicomRTStudy(exportablesCollection)
return message
示例9: UpdateProxyNodeMetrics
def UpdateProxyNodeMetrics( taskMetrics, proxyNodes, time ):
if ( PythonMetricsCalculatorLogic.GetMRMLScene() == None or PythonMetricsCalculatorLogic.GetPerkEvaluatorLogic() == None ):
return
# Get all transforms in the scene
relevantTransformNodes = vtk.vtkCollection()
PythonMetricsCalculatorLogic.GetPerkEvaluatorLogic().GetProxyRelevantTransformNodes( proxyNodes, relevantTransformNodes )
# Update all metrics associated with children of the recorded transform
for j in range( relevantTransformNodes.GetNumberOfItems() ):
currentTransformNode = relevantTransformNodes.GetItemAsObject( j )
PythonMetricsCalculatorLogic.UpdateMetrics( taskMetrics, currentTransformNode, time )
示例10: loadNodeFromFile
def loadNodeFromFile(filename, filetype, properties={}, returnNode=False):
from slicer import app
from vtk import vtkCollection
properties['fileName'] = filename
if returnNode:
loadedNodes = vtkCollection()
success = app.coreIOManager().loadNodes(filetype, properties, loadedNodes)
return success, loadedNodes.GetItemAsObject(0)
else:
success = app.coreIOManager().loadNodes(filetype, properties)
return success
示例11: testSubclassGhost
def testSubclassGhost(self):
"""Make sure ghosting of the class works"""
o = vtkCustomObject()
c = vtk.vtkCollection()
c.AddItem(o)
i = id(o)
del o
o = vtk.vtkObject()
o = c.GetItemAsObject(0)
# make sure the id has changed, but class the same
self.assertEqual(o.__class__, vtkCustomObject)
self.assertNotEqual(i, id(o))
示例12: widgetVisible
def widgetVisible(self, fidNode, viewNodeID):
lm = slicer.app.layoutManager()
for v in range(lm.threeDViewCount):
td = lm.threeDWidget(v)
ms = vtk.vtkCollection()
td.getDisplayableManagers(ms)
for i in range(ms.GetNumberOfItems()):
m = ms.GetItemAsObject(i)
if m.GetClassName() == "vtkMRMLMarkupsFiducialDisplayableManager3D" and m.GetMRMLViewNode().GetID() == viewNodeID:
h = m.GetHelper()
seedWidget = h.GetWidget(fidNode)
return seedWidget.GetEnabled()
return 0
示例13: removeModelHierarchyAndChildModelNodesFromScene
def removeModelHierarchyAndChildModelNodesFromScene(modelHierarchyNode):
if modelHierarchyNode:
cmn = vtk.vtkCollection()
modelHierarchyNode.GetChildrenModelNodes(cmn)
for i in range(cmn.GetNumberOfItems()):
model = cmn.GetItemAsObject(i)
if model.IsA('vtkMRMLModelNode'):
slicer.mrmlScene.RemoveNode(model)
slicer.mrmlScene.RemoveNode(modelHierarchyNode)
示例14: makeModels
def makeModels(study, finding, colorTable):
if (study is None) | (finding is None) | (colorTable is None):
return
seg = finding.GetSegmentationMappedByStudyNodeID(study.GetID())
if seg:
labelVolume = seg.GetLabelVolumeNode()
#create a temporary model hierarchy for generating models
tempMH = slicer.vtkMRMLModelHierarchyNode()
slicer.mrmlScene.AddNode(tempMH)
if (labelVolume is not None) & (tempMH is not None):
parameters = {'InputVolume': labelVolume.GetID(), 'ColorTable': colorTable.GetID(),
'ModelSceneFile': tempMH.GetID(), 'GenerateAll': False, 'StartLabel': finding.GetColorID(),
'EndLabel': finding.GetColorID(), 'Name': labelVolume.GetName() + "_" + finding.GetName() + "_M"}
cliModelMaker = None
cliModelMaker = slicer.cli.run(slicer.modules.modelmaker, cliModelMaker, parameters, wait_for_completion = True)
genModelNodes = vtk.vtkCollection()
tempMH.GetChildrenModelNodes(genModelNodes)
if genModelNodes.GetNumberOfItems() > 0:
modelNode = genModelNodes.GetItemAsObject(0)
if modelNode:
if modelNode.IsA('vtkMRMLModelNode'):
hnode = slicer.vtkMRMLHierarchyNode.GetAssociatedHierarchyNode(modelNode.GetScene(), modelNode.GetID())
if hnode:
if seg.GetModelHierarchyNode():
SlicerLongitudinalPETCTModuleViewHelper.removeModelHierarchyAndChildModelNodesFromScene(seg.GetModelHierarchyNode())
hnode.SetName(seg.GetName()+"_Model")
seg.SetAndObserveModelHierarchyNodeID(hnode.GetID())
modelNode.SetName(labelVolume.GetName() + "_" + finding.GetName()+"_M")
if modelNode.GetDisplayNode():
modelNode.GetDisplayNode().SetName(labelVolume.GetName() + "_" + finding.GetName()+"_D")
modelNode.GetDisplayNode().AddViewNodeID(SlicerLongitudinalPETCTModuleViewHelper.getStandardViewNode().GetID())
hnode.SetName(labelVolume.GetName() + "_" + finding.GetName()+"_H")
modelNode.SetHideFromEditors(False)
else:
seg.SetAndObserveModelHierarchyNodeID("")
slicer.mrmlScene.RemoveNode(modelNode)
slicer.mrmlScene.RemoveNode(hnode)
slicer.mrmlScene.RemoveNode(tempMH.GetDisplayNode())
slicer.mrmlScene.RemoveNode(tempMH)
#return '#%02X%02X%02X' % (r,g,b)
示例15: widgetVisibleOnSlice
def widgetVisibleOnSlice(self, fidNode, sliceNodeID):
lm = slicer.app.layoutManager()
sliceNames = lm.sliceViewNames()
for sliceName in sliceNames:
sliceWidget = lm.sliceWidget(sliceName)
sliceView = sliceWidget.sliceView()
ms = vtk.vtkCollection()
sliceView.getDisplayableManagers(ms)
for i in range(ms.GetNumberOfItems()):
m = ms.GetItemAsObject(i)
if m.GetClassName() == 'vtkMRMLMarkupsFiducialDisplayableManager2D' and m.GetMRMLSliceNode().GetID() == sliceNodeID:
h = m.GetHelper()
seedWidget = h.GetWidget(fidNode)
return seedWidget.GetEnabled()
return 0