本文整理汇总了Python中vtk.vtkClipPolyData函数的典型用法代码示例。如果您正苦于以下问题:Python vtkClipPolyData函数的具体用法?Python vtkClipPolyData怎么用?Python vtkClipPolyData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkClipPolyData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clipSurfacesForCutLVMesh
def clipSurfacesForCutLVMesh(
endo,
epi,
height,
verbose=1):
myVTK.myPrint(verbose, "*** clipSurfacesForCutLVMesh ***")
plane = vtk.vtkPlane()
plane.SetNormal(0,0,-1)
plane.SetOrigin(0,0,height)
clip = vtk.vtkClipPolyData()
clip.SetClipFunction(plane)
clip.SetInputData(endo)
clip.Update()
clipped_endo = clip.GetOutput(0)
clip = vtk.vtkClipPolyData()
clip.SetClipFunction(plane)
clip.SetInputData(epi)
clip.Update()
clipped_epi = clip.GetOutput(0)
return (clipped_endo,
clipped_epi)
示例2: clipSurfacesForFullLVMesh
def clipSurfacesForFullLVMesh(endo, epi, verbose=1):
myVTK.myPrint(verbose, "*** clipSurfacesForFullLVMesh ***")
endo_implicit_distance = vtk.vtkImplicitPolyDataDistance()
endo_implicit_distance.SetInput(endo)
epi_implicit_distance = vtk.vtkImplicitPolyDataDistance()
epi_implicit_distance.SetInput(epi)
epi_clip = vtk.vtkClipPolyData()
epi_clip.SetInputData(epi)
epi_clip.SetClipFunction(endo_implicit_distance)
epi_clip.GenerateClippedOutputOn()
epi_clip.Update()
clipped_epi = epi_clip.GetOutput(0)
clipped_valve = epi_clip.GetOutput(1)
endo_clip = vtk.vtkClipPolyData()
endo_clip.SetInputData(endo)
endo_clip.SetClipFunction(epi_implicit_distance)
endo_clip.InsideOutOn()
endo_clip.Update()
clipped_endo = endo_clip.GetOutput(0)
return (clipped_endo, clipped_epi, clipped_valve)
示例3: clipSurfacesForFullBiVMesh
def clipSurfacesForFullBiVMesh(
pdata_endLV,
pdata_endRV,
pdata_epi,
verbose=1):
myVTK.myPrint(verbose, "*** clipSurfacesForFullBiVMesh ***")
pdata_endLV_implicit_distance = vtk.vtkImplicitPolyDataDistance()
pdata_endLV_implicit_distance.SetInput(pdata_endLV)
pdata_endRV_implicit_distance = vtk.vtkImplicitPolyDataDistance()
pdata_endRV_implicit_distance.SetInput(pdata_endRV)
pdata_epi_implicit_distance = vtk.vtkImplicitPolyDataDistance()
pdata_epi_implicit_distance.SetInput(pdata_epi)
pdata_endLV_clip = vtk.vtkClipPolyData()
pdata_endLV_clip.SetInputData(pdata_endLV)
pdata_endLV_clip.SetClipFunction(pdata_epi_implicit_distance)
pdata_endLV_clip.InsideOutOn()
pdata_endLV_clip.Update()
clipped_pdata_endLV = pdata_endLV_clip.GetOutput(0)
pdata_endRV_clip = vtk.vtkClipPolyData()
pdata_endRV_clip.SetInputData(pdata_endRV)
pdata_endRV_clip.SetClipFunction(pdata_epi_implicit_distance)
pdata_endRV_clip.InsideOutOn()
pdata_endRV_clip.Update()
clipped_pdata_endRV = pdata_endRV_clip.GetOutput(0)
pdata_epi_clip = vtk.vtkClipPolyData()
pdata_epi_clip.SetInputData(pdata_epi)
pdata_epi_clip.SetClipFunction(pdata_endLV_implicit_distance)
pdata_epi_clip.GenerateClippedOutputOn()
pdata_epi_clip.Update()
clipped_pdata_epi = pdata_epi_clip.GetOutput(0)
clipped_valM = pdata_epi_clip.GetOutput(1)
pdata_epi_clip = vtk.vtkClipPolyData()
pdata_epi_clip.SetInputData(clipped_pdata_epi)
pdata_epi_clip.SetClipFunction(pdata_endRV_implicit_distance)
pdata_epi_clip.GenerateClippedOutputOn()
pdata_epi_clip.Update()
clipped_pdata_epi = pdata_epi_clip.GetOutput(0)
clipped_valP = pdata_epi_clip.GetOutput(1)
return (clipped_pdata_endLV,
clipped_pdata_endRV,
clipped_pdata_epi,
clipped_valM,
clipped_valP)
示例4: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkClipPolyData(), 'Processing.',
('vtkPolyData',), ('vtkPolyData', 'vtkPolyData'),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
示例5: openSurfaceAtPoint
def openSurfaceAtPoint(self, polyData, seed):
'''
Returns a new surface with an opening at the given seed.
'''
someradius = 1.0
pointLocator = vtk.vtkPointLocator()
pointLocator.SetDataSet(polyData)
pointLocator.BuildLocator()
# find the closest point next to the seed on the surface
# id = pointLocator.FindClosestPoint(int(seed[0]),int(seed[1]),int(seed[2]))
id = pointLocator.FindClosestPoint(seed)
# the seed is now guaranteed on the surface
seed = polyData.GetPoint(id)
sphere = vtk.vtkSphere()
sphere.SetCenter(seed[0], seed[1], seed[2])
sphere.SetRadius(someradius)
clip = vtk.vtkClipPolyData()
clip.SetInputData(polyData)
clip.SetClipFunction(sphere)
clip.Update()
outPolyData = vtk.vtkPolyData()
outPolyData.DeepCopy(clip.GetOutput())
return outPolyData
示例6: _Clip
def _Clip(self, pd):
# The plane implicit function will be >0 for all the points in the positive side
# of the plane (i.e. x s.t. n.(x-o)>0, where n is the plane normal and o is the
# plane origin).
plane = vtkPlane()
plane.SetOrigin(self.Iolet.Centre.x, self.Iolet.Centre.y, self.Iolet.Centre.z)
plane.SetNormal(self.Iolet.Normal.x, self.Iolet.Normal.y, self.Iolet.Normal.z)
# The sphere implicit function will be >0 for all the points outside the sphere.
sphere = vtkSphere()
sphere.SetCenter(self.Iolet.Centre.x, self.Iolet.Centre.y, self.Iolet.Centre.z)
sphere.SetRadius(self.Iolet.Radius)
# The VTK_INTERSECTION operator takes the maximum value of all the registered
# implicit functions. This will result in the function evaluating to >0 for all
# the points outside the sphere plus those inside the sphere in the positive
# side of the plane.
clippingFunction = vtkImplicitBoolean()
clippingFunction.AddFunction(plane)
clippingFunction.AddFunction(sphere)
clippingFunction.SetOperationTypeToIntersection()
clipper = vtkClipPolyData()
clipper.SetInput(pd)
clipper.SetClipFunction(clippingFunction)
# Filter to get part closest to seed point
connectedRegionGetter = vtkPolyDataConnectivityFilter()
connectedRegionGetter.SetExtractionModeToClosestPointRegion()
connectedRegionGetter.SetClosestPoint(*self.SeedPoint)
connectedRegionGetter.SetInputConnection(clipper.GetOutputPort())
connectedRegionGetter.Update()
return connectedRegionGetter.GetOutput()
示例7: SphereDrill
def SphereDrill(self, m_holelist, m_holeRadius, m_quiet=False):
"""
Drill sphere at locations specified by m_holelist.
:param m_holelist: [list] A list of coordinates where holes are to be drilled
:param m_holeRadius: [float] The radius of the hole to drill
:param m_quiet: [bool]
:return:
"""
m_totalNumOfHoles = len(m_holelist)
if not m_quiet:
t = time.time()
print "Drilling"
for i in xrange(m_totalNumOfHoles):
m_sphere = vtk.vtkSphere()
m_sphere.SetCenter(m_holelist[i])
m_sphere.SetRadius(m_holeRadius)
clipper = vtk.vtkClipPolyData()
clipper.SetInputData(self._data)
clipper.SetClipFunction(m_sphere)
clipper.Update()
clipped = clipper.GetOutput()
self._data.DeepCopy(clipped)
if not m_quiet:
print "\t%s/%s -- %.2f %%" % (i + 1, m_totalNumOfHoles, (i + 1) * 100 / float(m_totalNumOfHoles))
if not m_quiet:
print "Finished: Totaltime used = %.2f s" % (time.time() - t)
pass
示例8: cut_brain_hemi
def cut_brain_hemi(hemi_elec_data, hemi_poly_data):
depth_elec_data = hemi_elec_data[(hemi_elec_data.eType == 'D') | (hemi_elec_data.eType == 'd')]
print depth_elec_data
print
x_coords = np.array([avg_surf.x_snap for avg_surf in depth_elec_data.avgSurf], dtype=np.float)
y_coords = np.array([avg_surf.y_snap for avg_surf in depth_elec_data.avgSurf], dtype=np.float)
z_coords = np.array([avg_surf.z_snap for avg_surf in depth_elec_data.avgSurf], dtype=np.float)
x_min, x_max = np.min(x_coords), np.max(x_coords)
y_min, y_max = np.min(y_coords), np.max(y_coords)
z_min, z_max = np.min(z_coords), np.max(z_coords)
clipPlane = vtk.vtkPlane()
clipPlane.SetNormal(0.0, 0.0, 1.0)
# clipPlane.SetOrigin(0, 0, np.max(z_coords))
# clipPlane.SetOrigin(np.max(x_coords), np.max(y_coords), np.max(z_coords))
clipPlane.SetOrigin(0, 0, -500)
clipper = vtk.vtkClipPolyData()
clipper.SetInputData(hemi_poly_data)
clipper.SetClipFunction(clipPlane)
return clipper
示例9: Execute
def Execute(self):
if self.Surface == None:
self.PrintError('Error: no Surface.')
if self.WidgetType == "box":
self.ClipFunction = vtk.vtkPlanes()
elif self.WidgetType == "sphere":
self.ClipFunction = vtk.vtkSphere()
self.Clipper = vtk.vtkClipPolyData()
self.Clipper.SetInput(self.Surface)
self.Clipper.SetClipFunction(self.ClipFunction)
self.Clipper.GenerateClippedOutputOn()
self.Clipper.InsideOutOn()
if not self.vmtkRenderer:
self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
self.vmtkRenderer.Initialize()
self.OwnRenderer = 1
mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(self.Surface)
mapper.ScalarVisibilityOff()
self.Actor = vtk.vtkActor()
self.Actor.SetMapper(mapper)
self.vmtkRenderer.Renderer.AddActor(self.Actor)
if self.WidgetType == "box":
self.ClipWidget = vtk.vtkBoxWidget()
self.ClipWidget.GetFaceProperty().SetColor(0.6,0.6,0.2)
self.ClipWidget.GetFaceProperty().SetOpacity(0.25)
elif self.WidgetType == "sphere":
self.ClipWidget = vtk.vtkSphereWidget()
self.ClipWidget.GetSphereProperty().SetColor(0.6,0.6,0.2)
self.ClipWidget.GetSphereProperty().SetOpacity(0.25)
self.ClipWidget.GetSelectedSphereProperty().SetColor(0.6,0.0,0.0)
self.ClipWidget.GetSelectedSphereProperty().SetOpacity(0.75)
self.ClipWidget.SetRepresentationToSurface()
self.ClipWidget.SetPhiResolution(20)
self.ClipWidget.SetThetaResolution(20)
self.ClipWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
self.Display()
self.Transform = vtk.vtkTransform()
self.ClipWidget.GetTransform(self.Transform)
if self.OwnRenderer:
self.vmtkRenderer.Deallocate()
if self.CleanOutput == 1:
cleaner = vtk.vtkCleanPolyData()
cleaner.SetInput(self.Surface)
cleaner.Update()
self.Surface = cleaner.GetOutput()
if self.Surface.GetSource():
self.Surface.GetSource().UnRegisterAllOutputs()
示例10: Clipper
def Clipper(src, dx, dy, dz):
'''
Clip a vtkPolyData source.
A cube is made whose size corresponds the the bounds of the source.
Then each side is shrunk by the appropriate dx, dy or dz. After
this operation the source is clipped by the cube.
:param: src - the vtkPolyData source
:param: dx - the amount to clip in the x-direction
:param: dy - the amount to clip in the y-direction
:param: dz - the amount to clip in the z-direction
:return: vtkPolyData.
'''
bounds = [0,0,0,0,0,0]
src.GetBounds(bounds)
plane1 = vtk.vtkPlane()
plane1.SetOrigin(bounds[0] + dx, 0, 0)
plane1.SetNormal(1, 0, 0)
plane2 = vtk.vtkPlane()
plane2.SetOrigin(bounds[1] - dx, 0, 0)
plane2.SetNormal(-1, 0, 0)
plane3 = vtk.vtkPlane()
plane3.SetOrigin(0, bounds[2] + dy, 0)
plane3.SetNormal(0, 1, 0)
plane4 = vtk.vtkPlane()
plane4.SetOrigin(0, bounds[3] - dy, 0)
plane4.SetNormal(0, -1, 0)
plane5 = vtk.vtkPlane()
plane5.SetOrigin(0, 0, bounds[4] + dz)
plane5.SetNormal(0, 0, 1)
plane6 = vtk.vtkPlane()
plane6.SetOrigin(0, 0, bounds[5] - dz)
plane6.SetNormal(0, 0, -1)
clipFunction = vtk.vtkImplicitBoolean()
clipFunction.SetOperationTypeToUnion()
clipFunction.AddFunction(plane1)
clipFunction.AddFunction(plane2)
clipFunction.AddFunction(plane3)
clipFunction.AddFunction(plane4)
clipFunction.AddFunction(plane5)
clipFunction.AddFunction(plane6)
# Clip it.
clipper =vtk.vtkClipPolyData()
clipper.SetClipFunction(clipFunction)
clipper.SetInputData(src)
clipper.GenerateClipScalarsOff()
clipper.GenerateClippedOutputOff()
#clipper.GenerateClippedOutputOn()
clipper.Update()
return clipper.GetOutput()
示例11: __init__
def __init__(self, parent=None, id=-1,
pos=wx.DefaultPosition,
title="3D Density"):
VizFrame.__init__(self, parent, id, pos, title)
self.widget = wxVTKRenderWindowInteractor(self,-1)
style = vtk.vtkInteractorStyleTrackballCamera()
self.widget.SetInteractorStyle(style)
self.ren = vtk.vtkRenderer()
self.ren.SetBackground(0.1, 0.1, 0.7)
self.widget.GetRenderWindow().AddRenderer(self.ren)
self.data = None
self.colors = None
# layout the frame
self.box = wx.BoxSizer(wx.HORIZONTAL)
self.leftPanel = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self.box)
self.box.Add(self.leftPanel,0, wx.EXPAND)
self.box.Add(self.widget,1,wx.EXPAND)
self.Layout()
self.MenuBar = wx.MenuBar()
self.FileMenu = wx.Menu()
self.GateMenu = wx.Menu()
self.MenuBar.Append(self.FileMenu, "File")
self.MenuBar.Append(self.GateMenu, "Gating")
self.SetMenuBar(self.MenuBar)
export = self.FileMenu.Append(-1, "Export graphics")
self.Bind(wx.EVT_MENU, self.OnExport, export)
self.colorGate = self.GateMenu.Append(-1, "Gate on visible colors only")
self.Bind(wx.EVT_MENU, self.GateByColor, self.colorGate)
self.colorGate.Enable(False)
gate = self.GateMenu.Append(-1, "Capture gated events")
self.boxAddMenuItem = self.GateMenu.Append(-1, "Add box gate")
self.GateMenu.AppendSeparator()
self.boxes = []
self.Bind(wx.EVT_MENU, self.OnBox, self.boxAddMenuItem)
self.Bind(wx.EVT_MENU, self.Gate, gate)
self.selectActor = vtk.vtkLODActor()
self.planes = {} #vtk.vtkPlanes()
self.clipper = vtk.vtkClipPolyData()
self.boxCount = 1
self.boxIds = {}
self.Show()
self.SendSizeEvent()
示例12: planeclip
def planeclip(polydata, point, normal, insideout=True):
"""Clip polydata with a plane defined by point and normal. Change clipping
direction with 'insideout' argument."""
clipplane = vtk.vtkPlane()
clipplane.SetOrigin(point)
clipplane.SetNormal(normal)
clipper = vtk.vtkClipPolyData()
clipper.SetInput(polydata)
clipper.SetClipFunction(clipplane)
if insideout:
clipper.InsideOutOn()
clipper.Update()
return clipper.GetOutput()
示例13: _createTube
def _createTube(self):
logging.debug("In MultiSliceContour::createTube()")
points = vtk.vtkPoints()
for point in self._originalPoints:
points.InsertNextPoint(point)
self._parametricSpline = vtk.vtkParametricSpline()
self._parametricSpline.SetPoints(points)
self._parametricFuntionSource = vtk.vtkParametricFunctionSource()
self._parametricFuntionSource.SetParametricFunction(self._parametricSpline)
self._parametricFuntionSource.SetUResolution(100)
self._tubeFilter = vtk.vtkTubeFilter()
self._tubeFilter.SetNumberOfSides(10)
self._tubeFilter.SetRadius(self._radius)
self._tubeFilter.SetInputConnection(self._parametricFuntionSource.GetOutputPort())
self._tubeActor = []
self._cubes = []
i = 0
for cutter in self._cutters:
cutter.SetInputConnection(self._tubeFilter.GetOutputPort())
cutter.Update()
cube = vtk.vtkBox()
#TODO change imagebounds to planesourceRange
cube.SetBounds(self._scene.slice[i].getBounds())
clip = vtk.vtkClipPolyData()
clip.SetClipFunction(cube)
clip.SetInputConnection(cutter.GetOutputPort())
clip.InsideOutOn()
clip.Update()
self._cubes.append(cube)
tubeMapper=vtk.vtkPolyDataMapper()
tubeMapper.ScalarVisibilityOff()
tubeMapper.SetInputConnection(clip.GetOutputPort())
tubeMapper.GlobalImmediateModeRenderingOn()
tubeActor = vtk.vtkActor()
tubeActor.SetMapper(tubeMapper)
tubeActor.GetProperty().LightingOff()
tubeActor.GetProperty().SetColor(self.lineColor)
tubeActor.SetUserTransform(self._scene.slice[i].resliceTransform.GetInverse())
self._tubeActor.append(tubeActor)
self._scene.renderer.AddActor(tubeActor)
i = i+1
示例14: planeclip
def planeclip(surface, point, normal, insideout=1):
clipplane = vtk.vtkPlane()
clipplane.SetOrigin(point)
clipplane.SetNormal(normal)
clipper = vtk.vtkClipPolyData()
clipper.SetInputData(surface)
clipper.SetClipFunction(clipplane)
if insideout == 1:
clipper.InsideOutOn()
else:
clipper.InsideOutOff()
clipper.Update()
return clipper.GetOutput()
示例15: doClip1
def doClip1(data,value,normal,axis=0):
# We have the actor, do clipping
clpf = vtk.vtkPlane()
if axis == 0:
clpf.SetOrigin(value,0,0)
clpf.SetNormal(normal,0,0)
else:
clpf.SetOrigin(0,value,0)
clpf.SetNormal(0,normal,0)
clp = vtk.vtkClipPolyData()
clp.SetClipFunction(clpf)
clp.SetInputData(data)
clp.Update()
return clp.GetOutput()