本文整理汇总了Python中vtk.vtkPlane函数的典型用法代码示例。如果您正苦于以下问题:Python vtkPlane函数的具体用法?Python vtkPlane怎么用?Python vtkPlane使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkPlane函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setClipPlanes
def setClipPlanes(mapper, xmin, xmax, ymin, ymax):
clipPlaneCollection = vtk.vtkPlaneCollection()
if xmin != xmax:
clipPlaneXMin = vtk.vtkPlane()
clipPlaneXMin.SetOrigin(xmin, 0.0, 0.0)
clipPlaneXMin.SetNormal(1.0, 0.0, 0.0)
clipPlaneXMax = vtk.vtkPlane()
clipPlaneXMax.SetOrigin(xmax, 0.0, 0.0)
clipPlaneXMax.SetNormal(-1.0, 0.0, 0.0)
clipPlaneCollection.AddItem(clipPlaneXMin)
clipPlaneCollection.AddItem(clipPlaneXMax)
if ymin != ymax:
clipPlaneYMin = vtk.vtkPlane()
clipPlaneYMin.SetOrigin(0.0, ymin, 0.0)
clipPlaneYMin.SetNormal(0.0, 1.0, 0.0)
clipPlaneYMax = vtk.vtkPlane()
clipPlaneYMax.SetOrigin(0.0, ymax, 0.0)
clipPlaneYMax.SetNormal(0.0, -1.0, 0.0)
clipPlaneCollection.AddItem(clipPlaneYMin)
clipPlaneCollection.AddItem(clipPlaneYMax)
if clipPlaneCollection.GetNumberOfItems() > 0:
mapper.SetClippingPlanes(clipPlaneCollection)
示例2: testPassByReference
def testPassByReference(self):
t = vtk.mutable(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]
vtk.vtkPlane.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)
vtk.vtkPlane().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 = vtk.vtkPlane()
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)
vtk.vtkPlane.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)
示例3: initialize
def initialize (self):
debug ("In CutPlane::initialize ()")
self.plane = vtk.vtkPlane ()
self.fil = vtk.vtkCutter ()
out = self.prev_fil.GetOutput()
self.fil.SetInput (out)
self.fil.SetCutFunction (self.plane)
self.center = out.GetCenter ()
self.plane.SetOrigin (self.center)
self.plane.SetNormal (0.0, 0.0, 1.0)
self.step_var = Tkinter.DoubleVar ()
self.n_step_var = Tkinter.IntVar ()
self.resoln_var = Tkinter.DoubleVar ()
self.resoln_var.set (1.0)
self.slider = []
self.set_def_step_size ()
self.step_var.set (self.step_size)
self.n_step_var.set (10)
self.slider_pos = 0
self._auto_sweep_init ()
self.sweep_step.set (1)
self.fil.Update ()
示例4: create_cut_acto_plane
def create_cut_acto_plane(self,xpos,ypos,zpos,plane_id):
#vtk plane
plane=vtk.vtkPlane()
plane.SetOrigin(xpos,ypos,zpos)
if plane_id==0:
plane.SetNormal(1,0,0)
if plane_id==1:
plane.SetNormal(0,1,0)
if plane_id==2:
plane.SetNormal(0.0,0.0,1)
#create cutter
cutter=vtk.vtkCutter()
cutter.SetCutFunction(plane)
cutter.SetInputConnection(self.dti_reader.GetOutputPort())
cutter.Update()
#probe filter for the cutting plane
probe_filter=vtk.vtkProbeFilter()
probe_filter.SetInputConnection(cutter.GetOutputPort())
probe_filter.SetSourceConnection(self.dti_reader.GetOutputPort())
self.plane1=plane
return probe_filter
示例5: cut
def cut(cube, normal):
plane=vtk.vtkPlane()
plane.SetOrigin(cube.GetCenter())
plane.SetNormal(*normal)
#create cutter
cutter=vtk.vtkCutter()
cutter.SetCutFunction(plane)
cutter.SetInputConnection(cube.GetOutputPort())
cutter.Update()
cutterMapper=vtk.vtkPolyDataMapper()
cutterMapper.SetInputConnection( cutter.GetOutputPort())
#create plane actor
planeActor=vtk.vtkActor()
planeActor.GetProperty().SetColor(1.0,1,0)
planeActor.GetProperty().SetLineWidth(2)
planeActor.SetMapper(cutterMapper)
#create renderers and add actors of plane and cube
ren.AddActor(planeActor)
ret = []
points = cutter.GetOutput().GetPoints()
for i in range(points.GetNumberOfPoints()):
point = points.GetPoint(i)
ret.append( point )
return ret
示例6: get
def get(self):
resultado = {}
imageData = reader.get("IMAGE", self.subj, format="VTK", name=self.get_argument("type", None), space="world")
plane=vtk.vtkPlane()
if (self.get_argument("plane", None) == "x"):
plane.SetNormal(1,0,0)
plane.SetOrigin(float(self.get_argument("pos", None)),0,0)
if (self.get_argument("plane", None) == "y"):
plane.SetNormal(0,1,0)
plane.SetOrigin(0,float(self.get_argument("pos", None)),0)
if (self.get_argument("plane", None) == "z"):
plane.SetNormal(0,0,1)
plane.SetOrigin(0,0,float(self.get_argument("pos", None)))
planeCut = vtk.vtkCutter()
planeCut.SetInputData(imageData)
planeCut.SetCutFunction(plane)
planeCut.Update()
resultado['subject'] = self.subj
resultado['type'] = 'image'
resultado['plane'] = self.get_argument("plane", None)
resultado['pos'] = self.get_argument("pos", None)
resultado['bounds'] = planeCut.GetOutput().GetBounds()
resultado['dimensions'] = imageData.GetDimensions()
resultado['scalars'] = numpy_support.vtk_to_numpy(planeCut.GetOutput().GetPointData().GetScalars()).tolist()
self.set_header("Content-Type","application/json")
self.write(json.dumps(resultado, separators=(',',':')))
示例7: _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()
示例8: addPlaneCutter
def addPlaneCutter(self, i):
#take record of the plane weight
planeWeightTextValue = self.planeWeightText[i].text()
self.planeWtInt[i] = planeWeightTextValue.toFloat()
self.ren.RemoveActor(self.planeActor)
plane=vtk.vtkPlane()
plane.SetOrigin(float(self.firstPlanePtValueRecord[i][0]),float(self.firstPlanePtValueRecord[i][1]), float(self.firstPlanePtValueRecord[i][2]) )
a = np.array([self.secondPlanePtValueRecord[i][0]-self.firstPlanePtValueRecord[i][0], self.secondPlanePtValueRecord[i][1]-self.firstPlanePtValueRecord[i][1], self.secondPlanePtValueRecord[i][2]-self.firstPlanePtValueRecord[i][2]])
b = np.array([self.thirdPlanePtValueRecord[i][0]-self.firstPlanePtValueRecord[i][0], self.thirdPlanePtValueRecord[i][1]-self.firstPlanePtValueRecord[i][1],self.thirdPlanePtValueRecord[i][2]-self.firstPlanePtValueRecord[i][2]])
self.planeOrigin[i] = self.firstPlanePtValueRecord[i]
self.planeNormal[i] = np.cross(a, b)
self.planeNormal[i] = self.planeNormal[i] / np.linalg.norm(self.planeNormal[i])
plane.SetNormal(self.planeNormal[i])
#create cutter
cutter=vtk.vtkCutter()
cutter.SetCutFunction(plane)
cutter.SetInputConnection(self.append.GetOutputPort())
cutter.Update()
cutterMapper=vtk.vtkPolyDataMapper()
cutterMapper.SetInputConnection(cutter.GetOutputPort())
self.planeActor.GetProperty().SetColor(1.0,1,0)
self.planeActor.GetProperty().SetLineWidth(2)
self.planeActor.SetMapper(cutterMapper)
self.ren.AddActor(self.planeActor)
示例9: Slice_VTK_data_to_VTK
def Slice_VTK_data_to_VTK(inputFileName,
outputFileName,
point, normal,
resolution
):
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(inputFileName)
reader.Update()
plane = vtk.vtkPlane()
plane.SetOrigin(point)
plane.SetNormal(normal)
cutter = vtk.vtkFiltersCorePython.vtkCutter()
cutter.SetCutFunction(plane)
cutter.SetInputConnection(reader.GetOutputPort())
cutter.Update()
#Convert tht polydata structure générated by cutter into unstructured grid by triangulation
triFilter = vtk.vtkDataSetTriangleFilter()
triFilter.SetInputConnection(cutter.GetOutputPort())
triFilter.Update()
writer = vtk.vtkXMLUnstructuredGridWriter()
writer.SetInputData(triFilter.GetOutput())
writer.SetFileName(outputFileName)
writer.Write()
示例10: _fbzCutPlane
def _fbzCutPlane(self, fbz, giaN, giaGlenoid):
"""Calculate cut-plane corresponding to fbz.
fbz is a list containing the two points defining a single FBZ
(forbidden zone). giaN is the glenoid-insertion axis normal.
giaGlenoid is the user-selected gia point on the glenoid.
This method will return a cut-plane to enforce the given fbz such
that giaGlenoid is on the inside of the implicit plane.
"""
fbzV = map(operator.sub, fbz[0], fbz[1])
fbzPN = [0,0,0]
vtk.vtkMath.Cross(fbzV, giaN, fbzPN)
vtk.vtkMath.Normalize(fbzPN)
fbzPlane = vtk.vtkPlane()
fbzPlane.SetOrigin(fbz[0])
fbzPlane.SetNormal(fbzPN)
insideVal = fbzPlane.EvaluateFunction(giaGlenoid)
if insideVal < 0:
# eeep, it's outside, so flip the planeNormal
fbzPN = [-1.0 * i for i in fbzPN]
fbzPlane.SetNormal(fbzPN)
return fbzPlane
示例11: 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
示例12: clip
def clip(inp, origin, normal, inside_out=False, take_cell=False):
"""
VTK operation: clip. A vtkGeometryFilter is used to convert the
resulted vtkUnstructuredMesh object into a vtkPolyData object.
@param inp: input VTK object.
@type inp: vtk.vtkobject
@param origin: a 3-tuple for cut origin.
@type origin: tuple
@param normal: a 3-tuple for cut normal.
@type normal: tuple
@keyword inside_out: make inside out. Default False.
@type inside_out: bool
@keyword take_cell: treat the input VTK object with values on cells.
Default False.
@type: take_cell: bool
@return: output VTK object.
@rtype: vtk.vtkobject
"""
import vtk
pne = vtk.vtkPlane()
pne.SetOrigin(origin)
pne.SetNormal(normal)
clip = vtk.vtkClipDataSet()
if take_cell:
clip.SetInput(inp)
else:
clip.SetInputConnection(inp.GetOutputPort())
clip.SetClipFunction(pne)
if inside_out:
clip.InsideOutOn()
parison = vtk.vtkGeometryFilter()
parison.SetInputConnection(clip.GetOutputPort())
return parison
示例13: addContourObject
def addContourObject(self, contourObject, prop3D):
"""Activate contouring for the contourObject. The contourObject
is usually a tdObject and specifically a vtkPolyData. We also
need the prop3D that represents this polydata in the 3d scene.
"""
if self._contourObjectsDict.has_key(contourObject):
# we already have this, thanks
return
try:
contourable = contourObject.IsA('vtkPolyData')
except:
contourable = False
if contourable:
# we need a cutter to calculate the contours and then a stripper
# to string them all together
cutter = vtk.vtkCutter()
plane = vtk.vtkPlane()
cutter.SetCutFunction(plane)
trfm = vtk.vtkTransform()
trfm.SetMatrix(prop3D.GetMatrix())
trfmFilter = vtk.vtkTransformPolyDataFilter()
trfmFilter.SetTransform(trfm)
trfmFilter.SetInput(contourObject)
cutter.SetInput(trfmFilter.GetOutput())
stripper = vtk.vtkStripper()
stripper.SetInput(cutter.GetOutput())
#
#tubef = vtk.vtkTubeFilter()
#tubef.SetNumberOfSides(12)
#tubef.SetRadius(0.5)
#tubef.SetInput(stripper.GetOutput())
# and create the overlay at least for the 3d renderer
mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(stripper.GetOutput())
mapper.ScalarVisibilityOff()
actor = vtk.vtkActor()
actor.SetMapper(mapper)
c = self.sliceDirections.slice3dVWR._tdObjects.getObjectColour(
contourObject)
actor.GetProperty().SetColor(c)
actor.GetProperty().SetInterpolationToFlat()
# add it to the renderer
self.sliceDirections.slice3dVWR._threedRenderer.AddActor(actor)
# add all necessary metadata to our dict
contourDict = {'contourObject' : contourObject,
'contourObjectProp' : prop3D,
'trfmFilter' : trfmFilter,
'cutter' : cutter,
'tdActor' : actor}
self._contourObjectsDict[contourObject] = contourDict
# now sync the bugger
self.syncContourToObject(contourObject)
示例14: 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)
示例15: InitVTKMethods
def InitVTKMethods(self):
"""Initializes the VTK methods to be used."""
self.colortable=ColorTableSource()
self._plane=vtkPlane()
self._cutter=vtkCutter()
self._mapper=vtkDataSetMapper()
self.actor=vtkLODActor()