本文整理汇总了Python中vtk.vtkStripper函数的典型用法代码示例。如果您正苦于以下问题:Python vtkStripper函数的具体用法?Python vtkStripper怎么用?Python vtkStripper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkStripper函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_isosurface
def get_isosurface(self, iso_value=500):
if not self.flag_read:
sys.stderr.write('No Image Loaded!\n')
return
contour = vtk.vtkContourFilter()
normals = vtk.vtkPolyDataNormals()
stripper = vtk.vtkStripper()
mapper = vtk.vtkPolyDataMapper()
contour.SetInputData(self.reader)
contour.SetValue(0, iso_value)
normals.SetInputConnection(contour.GetOutputPort())
normals.SetFeatureAngle(60.0)
normals.ReleaseDataFlagOn()
stripper.SetInputConnection(normals.GetOutputPort())
stripper.ReleaseDataFlagOn()
mapper.SetInputConnection(stripper.GetOutputPort())
mapper.SetScalarVisibility(False)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# Default colour, should be changed.
actor.GetProperty().SetDiffuseColor(
[247.0 / 255.0, 150.0 / 255.0, 155.0 / 255.0]) # Look like red
actor.GetProperty().SetSpecular(0.3)
actor.GetProperty().SetSpecularPower(20)
return actor
开发者ID:quentan,项目名称:Work_Test_4,代码行数:34,代码来源:medical_object.py
示例2: 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)
开发者ID:fvpolpeta,项目名称:devide,代码行数:60,代码来源:sliceDirection.py
示例3: Test3
def Test3(datadir):
reader = vtk.vtkDataSetReader()
reader.SetFileName(datadir + "/Data/blow.vtk")
reader.UpdateInformation();
reader.ReadAllScalarsOn()
reader.ReadAllVectorsOn()
dssf = vtk.vtkDataSetSurfaceFilter()
dssf.SetInputConnection(reader.GetOutputPort())
stripper = vtk.vtkStripper()
stripper.SetInputConnection(dssf.GetOutputPort())
f = vtk.vtkIntegrateAttributes()
f.SetInputConnection(stripper.GetOutputPort())
f.Update()
result = f.GetOutputDataObject(0)
val = result.GetPointData().GetArray("displacement1").GetValue(0)
assert (val > 463.64 and val < 463.642)
val = result.GetPointData().GetArray("thickness3").GetValue(0)
assert (val > 874.61 and val < 874.618)
val = result.GetCellData().GetArray("Area").GetValue(0)
assert (val > 1145.405 and val < 1145.415)
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:26,代码来源:TestIntegrateAttributes.py
示例4: get_actor
def get_actor(vtk_source, color=color_diffuse, opacity=1.0,
has_scalar_visibility=False, has_decimator=False):
"""
Set `scalar_visibility` be `True` makes `color` unavailable.
:return: a vtkActor
"""
if has_decimator:
# Reduce the number of triangles
decimator = vtk.vtkDecimatePro()
decimator.SetInputConnection(vtk_source.GetOutputPort())
# decimator.SetInputData(vtk_source)
decimator.SetFeatureAngle(60)
decimator.MaximumIterations = 1
decimator.PreserveTopologyOn()
decimator.SetMaximumError(0.0002)
decimator.SetTargetReduction(1)
decimator.SetErrorIsAbsolute(1)
decimator.SetAbsoluteError(0.0002)
decimator.ReleaseDataFlagOn()
# Generate Normals
normals = vtk.vtkPolyDataNormals()
if has_decimator:
normals.SetInputConnection(decimator.GetOutputPort())
else:
normals.SetInputConnection(vtk_source.GetOutputPort())
normals.SetFeatureAngle(60.0)
normals.ReleaseDataFlagOn()
stripper = vtk.vtkStripper()
stripper.SetInputConnection(normals.GetOutputPort())
stripper.ReleaseDataFlagOn()
mapper = vtk.vtkPolyDataMapper()
# mapper.SetInputConnection(vtk_source.GetOutputPort())
mapper.SetInputConnection(stripper.GetOutputPort())
mapper.SetScalarVisibility(has_scalar_visibility)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetDiffuseColor(color)
actor.GetProperty().SetSpecular(0.3)
actor.GetProperty().SetSpecularPower(20)
actor.GetProperty().SetInterpolation(2)
# actor.GetProperty().SetRepresentation(2)
# actor.GetProperty().SetEdgeVisibility(True)
# actor.GetProperty().SetOpacity(opacity)
if opacity < 1.0:
if is_depth_peeling_supported(render_window, renderer, True):
setup_evn_for_depth_peeling(render_window, renderer, max_peels, occlusion)
actor.GetProperty().SetOpacity(opacity)
else:
print "Depth Peeling is not supported."
return actor
开发者ID:quentan,项目名称:Algorithms,代码行数:56,代码来源:ImplicitFitting.py
示例5: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self,
module_manager,
vtk.vtkStripper(),
"Processing.",
("vtkPolyData",),
("vtkPolyData",),
replaceDoc=True,
inputFunctions=None,
outputFunctions=None,
)
开发者ID:sanguinariojoe,项目名称:devide,代码行数:12,代码来源:vtkStripper.py
示例6: __init__
def __init__(self, parent = None):
super(VTKFrame, self).__init__(parent)
self.vtkWidget = QVTKRenderWindowInteractor(self)
vl = QtGui.QVBoxLayout(self)
vl.addWidget(self.vtkWidget)
vl.setContentsMargins(0, 0, 0, 0)
self.ren = vtk.vtkRenderer()
self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
#Create a sphere
sphere = vtk.vtkSphereSource()
sphere.SetRadius(50)
sphere.SetThetaResolution(100)
sphere.SetPhiResolution(100)
plane = vtk.vtkPlane()
plane.SetOrigin(20, 0, 0)
plane.SetNormal(1, 0, 0)
#create cutter
cutter = vtk.vtkCutter()
cutter.SetCutFunction(plane)
cutter.SetInputConnection(sphere.GetOutputPort())
cutter.Update()
cutStrips = vtk.vtkStripper()
cutStrips.SetInputConnection(cutter.GetOutputPort())
cutStrips.Update()
cutPoly = vtk.vtkPolyData()
cutPoly.SetPoints((cutStrips.GetOutput()).GetPoints())
cutPoly.SetPolys((cutStrips.GetOutput()).GetLines())
cutMapper = vtk.vtkPolyDataMapper()
cutMapper.SetInput(cutPoly)
#cutMapper.SetInputConnection(cutter.GetOutputPort())
cutActor = vtk.vtkActor()
cutActor.GetProperty().SetColor(1, 1, 0)
cutActor.GetProperty().SetEdgeColor(0, 1, 0)
cutActor.GetProperty().SetLineWidth(2)
cutActor.GetProperty().EdgeVisibilityOn()
cutActor.SetMapper(cutMapper)
#create renderers and add actors of plane and cube
self.ren.AddActor(cutActor)
self.ren.ResetCamera()
self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:52,代码来源:filledpolygon.py
示例7: marchingCubes
def marchingCubes(self, image, ijkToRasMatrix, threshold):
transformIJKtoRAS = vtk.vtkTransform()
transformIJKtoRAS.SetMatrix(ijkToRasMatrix)
marchingCubes = vtk.vtkMarchingCubes()
marchingCubes.SetInputData(image)
marchingCubes.SetValue(0, threshold)
marchingCubes.ComputeScalarsOn()
marchingCubes.ComputeGradientsOn()
marchingCubes.ComputeNormalsOn()
marchingCubes.ReleaseDataFlagOn()
marchingCubes.Update()
if transformIJKtoRAS.GetMatrix().Determinant() < 0:
reverser = vtk.vtkReverseSense()
reverser.SetInputData(marchingCubes.GetOutput())
reverser.ReverseNormalsOn()
reverser.ReleaseDataFlagOn()
reverser.Update()
correctedOutput = reverser.GetOutput()
else:
correctedOutput = marchingCubes.GetOutput()
transformer = vtk.vtkTransformPolyDataFilter()
transformer.SetInputData(correctedOutput)
transformer.SetTransform(transformIJKtoRAS)
transformer.ReleaseDataFlagOn()
transformer.Update()
normals = vtk.vtkPolyDataNormals()
normals.ComputePointNormalsOn()
normals.SetInputData(transformer.GetOutput())
normals.SetFeatureAngle(60)
normals.SetSplitting(1)
normals.ReleaseDataFlagOn()
normals.Update()
stripper = vtk.vtkStripper()
stripper.SetInputData(normals.GetOutput())
stripper.ReleaseDataFlagOff()
stripper.Update()
stripper.GetOutput()
result = vtk.vtkPolyData()
result.DeepCopy(stripper.GetOutput())
return result
开发者ID:vmtk,项目名称:SlicerExtension-VMTK,代码行数:50,代码来源:LevelSetSegmentation.py
示例8: OnLoadSurfaceDict
def OnLoadSurfaceDict(self, pubsub_evt):
surface_dict = pubsub_evt.data
for key in surface_dict:
surface = surface_dict[key]
# Map polygonal data (vtkPolyData) to graphics primitives.
normals = vtk.vtkPolyDataNormals()
normals.SetInput(surface.polydata)
normals.SetFeatureAngle(80)
normals.AutoOrientNormalsOn()
normals.GetOutput().ReleaseDataFlagOn()
# Improve performance
stripper = vtk.vtkStripper()
stripper.SetInput(normals.GetOutput())
stripper.PassThroughCellIdsOn()
stripper.PassThroughPointIdsOn()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(stripper.GetOutput())
mapper.ScalarVisibilityOff()
mapper.ImmediateModeRenderingOn() # improve performance
# Represent an object (geometry & properties) in the rendered scene
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# Set actor colour and transparency
actor.GetProperty().SetColor(surface.colour)
actor.GetProperty().SetOpacity(1-surface.transparency)
self.actors_dict[surface.index] = actor
# Send actor by pubsub to viewer's render
ps.Publisher().sendMessage('Load surface actor into viewer', (actor))
ps.Publisher().sendMessage('Update status text in GUI',
_("Ready"))
# The following lines have to be here, otherwise all volumes disappear
ps.Publisher().sendMessage('Update surface info in GUI',
(surface.index, surface.name,
surface.colour, surface.volume,
surface.transparency))
if not surface.is_shown:
self.ShowActor(key, False)
开发者ID:151706061,项目名称:invesalius,代码行数:47,代码来源:surface.py
示例9: patch
def patch(mesh):
"""
This function...
:param mesh:
:return:
"""
edges = vtk.vtkFeatureEdges()
edges.SetInputData(mesh)
edges.FeatureEdgesOff()
edges.NonManifoldEdgesOn()
edges.ManifoldEdgesOff()
edges.BoundaryEdgesOn()
edges.Update()
print(
"{0} cells and {1} points".format(
edges.GetOutput().GetNumberOfCells(), edges.GetOutput().GetNumberOfPoints()
)
)
if edges.GetOutput().GetNumberOfPoints() == 0:
print("No defects")
return mesh
patchSkel = vtk.vtkStripper()
patchSkel.SetInputData(edges.GetOutput())
patchSkel.Update()
patchPoly = vtk.vtkPolyData()
patchPoly.Initialize()
patchPoly.SetPoints(patchSkel.GetOutput().GetPoints())
patchPoly.SetPolys(patchSkel.GetOutput().GetLines())
patchTri = vtk.vtkTriangleFilter()
patchTri.SetInputData(patchPoly)
patchTri.Update()
meshAppend = vtk.vtkAppendPolyData()
meshAppend.AddInputData(patchTri.GetOutput())
meshAppend.AddInputData(mesh)
meshAppend.Update()
poly = vtk.vtkCleanPolyData()
poly.SetInputData(meshAppend.GetOutput())
poly.Update()
return poly.GetOutput()
开发者ID:BRAINSia,项目名称:BRAINSTools,代码行数:46,代码来源:mesh2mask.py
示例10: __init__
def __init__(self, marker, planeWidget,
transform=None, lineWidth=1):
self.lineWidth=lineWidth
self.marker = marker
self.markerSource = marker.get_source()
self.planeWidget = planeWidget
self.transform = transform
self.implicitPlane = vtk.vtkPlane()
self.ringEdges = vtk.vtkCutter()
self.ringStrips = vtk.vtkStripper()
self.ringPoly = vtk.vtkPolyData()
self.ringMapper = vtk.vtkPolyDataMapper()
self.ringEdges.SetInput(self.markerSource.GetOutput())
self.implicitPlane.SetNormal(self.planeWidget.GetNormal())
self.implicitPlane.SetOrigin(self.planeWidget.GetOrigin())
#print 'implicit plane', self.implicitPlane
self.ringEdges.SetCutFunction(self.implicitPlane)
self.ringEdges.GenerateCutScalarsOff()
self.ringEdges.SetValue(0, 0.0)
self.ringStrips.SetInput(self.ringEdges.GetOutput())
self.ringStrips.Update()
self.ringPoly.SetPoints(self.ringStrips.GetOutput().GetPoints())
self.ringPoly.SetPolys(self.ringStrips.GetOutput().GetLines())
self.ringMapper.SetInput(self.ringPoly)
self.SetMapper(self.ringMapper)
self.lineProperty = self.GetProperty()
self.lineProperty.SetRepresentationToWireframe()
self.lineProperty.SetAmbient(1.0)
self.lineProperty.SetColor(self.marker.get_color())
self.lineProperty.SetLineWidth(lineWidth)
self.SetProperty(self.lineProperty)
self.VisibilityOff()
if transform is not None:
self.filter = vtk.vtkTransformPolyDataFilter()
self.filter.SetTransform(transform)
else:
self.filter = None
self.update()
开发者ID:neurodebian,项目名称:PyLocator,代码行数:45,代码来源:markers.py
示例11: slicevtkcontour
def slicevtkcontour(vtkmesh, h, init=0, end=0):
# Get limits
xmin, xmax, ymin, ymax, zmin, zmax = vtkmesh.GetBounds()
zmin += init
zmax -= end
# Plane to cut
plane = vtk.vtkPlane()
plane.SetOrigin(0, 0, zmin + h / 2.0)
plane.SetNormal(0, 0, 1)
# Cut function
cutter = vtk.vtkCutter()
cutter.SetInput(vtkmesh)
cutter.SetCutFunction(plane)
cutter.GenerateCutScalarsOn()
cutter.SetValue(0, 0)
# Catch the points
cutStrips = vtk.vtkStripper()
cutStrips.SetInputConnection(cutter.GetOutputPort())
cutStrips.Update()
# Slice and create polygons
layers = list()
# zreal = h/2.0
z = zmin + h / 2.0 # because set an reliable zero can broke the tip
zs = list()
polygons = list() # one for layer
while z < zmax:
zs.append(z)
plane.SetOrigin(0, 0, z)
cutStrips.Update()
coords = tuple()
for j in range(
cutStrips.GetOutput().GetCell(0).GetPoints().GetNumberOfPoints()
): # retrieve all points from the line
vec = Vec(cutStrips.GetOutput().GetCell(0).GetPoints().GetPoint(j))
coords += ((vec.x, vec.y),)
polygon = Polygon(coords)
polygons.append(polygon)
z += h
return polygons, zs
开发者ID:GVallicrosa,项目名称:FabQtV2,代码行数:43,代码来源:planner.py
示例12: ComputeAreas
def ComputeAreas(self):
stripper = vtk.vtkStripper()
stripper.SetInput(self.Contour)
stripper.SetMaximumLength(100000)
stripper.Update()
contour = stripper.GetOutput()
if contour.GetNumberOfCells() != 2:
self.InnerArea = 0.0
self.OuterArea = 0.0
return
areas = [0.0,0.0]
for n in range(2):
points = contour.GetCell(n).GetPoints()
numberOfPoints = points.GetNumberOfPoints()
for i in range(numberOfPoints):
point0 = points.GetPoint(i)
point1 = points.GetPoint((i+1)%numberOfPoints)
areas[n] += vtk.vtkTriangle.TriangleArea(self.Center,point0,point1)
self.InnerArea = min(areas)
self.OuterArea = max(areas)
开发者ID:151706061,项目名称:FEMRI,代码行数:20,代码来源:femrithicknessmeasurement.py
示例13: get_vtk_plane
def get_vtk_plane(self, side_len=25):
# cube = vtk.vtkCubeSource()
# cube.SetXLength(side_len)
# cube.SetYLength(side_len)
# cube.SetZLength(side_len)
# cube.SetCenter(*self.pos)
cube = vtk.vtkSphereSource()
cube.SetThetaResolution(100)
cube.SetPhiResolution(100)
cube.SetRadius(side_len)
cube.SetCenter(*self.xyz)
cubeMapper = vtk.vtkPolyDataMapper()
cubeMapper.SetInputConnection(cube.GetOutputPort())
plane = vtk.vtkPlane()
plane.SetOrigin(*self.xyz)
plane.SetNormal(*self.norm)
#create cutter
cutter = vtk.vtkCutter()
cutter.SetCutFunction(plane)
cutter.SetInputConnection(cube.GetOutputPort())
cutter.Update()
cutStrips = vtk.vtkStripper()
cutStrips.SetInputConnection(cutter.GetOutputPort())
cutStrips.Update()
cutPoly = vtk.vtkPolyData()
cutPoly.SetPoints((cutStrips.GetOutput()).GetPoints())
cutPoly.SetPolys((cutStrips.GetOutput()).GetLines())
cutMapper = vtk.vtkPolyDataMapper()
cutMapper.SetInput(cutPoly)
cutActor = vtk.vtkActor()
cutActor.GetProperty().SetColor(1, 1, 1)
cutActor.SetMapper(cutMapper)
return cutActor
开发者ID:sameeptandon,项目名称:handwash,代码行数:41,代码来源:VtkRenderer.py
示例14: update
def update(self):
surface_extractor = vtk.vtkContourFilter()
surface_extractor.SetInputConnection(self._image.GetOutputPort())
surface_extractor.SetValue(0, self.__surface_value)
surface_normals = vtk.vtkPolyDataNormals()
surface_normals.SetInputConnection(surface_extractor.GetOutputPort())
surface_normals.SetFeatureAngle(60.0)
surface_stripper = vtk.vtkStripper()
surface_stripper.SetInputConnection(surface_normals.GetOutputPort())
surface_mapper = vtk.vtkPolyDataMapper()
surface_mapper.SetInputConnection(surface_stripper.GetOutputPort())
surface_mapper.ScalarVisibilityOff()
surface_actor = vtk.vtkActor()
surface_actor.SetMapper(surface_mapper)
camera = vtk.vtkCamera()
camera.SetViewUp(0.0, 0.0, -1.0)
camera.SetPosition(0.0, 1.0, 0.0)
camera.SetFocalPoint(0.0, 0.0, 0.0)
camera.ComputeViewPlaneNormal()
camera.Dolly(1.5)
renderer = vtk.vtkRenderer()
renderer.AddActor(surface_actor)
renderer.SetActiveCamera(camera)
renderer.ResetCamera()
renderer.SetBackground(0.0,0.0,0.0)
renderer.ResetCameraClippingRange()
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
render_window_interactor = vtk.vtkRenderWindowInteractor()
render_window_interactor.SetRenderWindow(render_window)
render_window_interactor.Initialize()
render_window.Render()
render_window_interactor.Start()
开发者ID:simonlzn,项目名称:PythonMultiProcess,代码行数:41,代码来源:rendering_3D.py
示例15: __create_and_set_mapper
def __create_and_set_mapper(self):
self.implicitPlane = vtk.vtkPlane()
self.edges = vtk.vtkCutter()
self.strips = vtk.vtkStripper()
self.poly = vtk.vtkPolyData()
self.mapper = vtk.vtkPolyDataMapper()
self.edges.SetInputConnection(self.roiPipe.GetOutputPort())
self.implicitPlane.SetNormal(self.planeWidget.GetNormal())
self.implicitPlane.SetOrigin(self.planeWidget.GetOrigin())
self.edges.SetCutFunction(self.implicitPlane)
self.edges.GenerateCutScalarsOff()
self.edges.SetValue(0, 0.0)
self.strips.SetInputConnection(self.edges.GetOutputPort())
self.strips.Update()
self.poly.SetPoints(self.strips.GetOutput().GetPoints())
self.poly.SetPolys(self.strips.GetOutput().GetLines())
self.mapper.SetInput(self.poly)
self.mapper.ScalarVisibilityOff()
self.SetMapper(self.mapper)
开发者ID:neurodebian,项目名称:PyLocator,代码行数:21,代码来源:rois.py
示例16: _Execute
def _Execute(self, *args):
input = self.GetPolyDataInput()
# Gets any edges of the mesh
edger = vtkFeatureEdges()
edger.BoundaryEdgesOn()
edger.FeatureEdgesOff()
edger.NonManifoldEdgesOff()
edger.ManifoldEdgesOff()
edger.SetInputData(input)
# Converts the edges to a polyline
stripper = vtkStripper()
stripper.SetInputConnection(edger.GetOutputPort())
stripper.Update()
# Change the polylines into polygons
boundaryPoly = vtkPolyData()
boundaryPoly.SetPoints(stripper.GetOutput().GetPoints())
boundaryPoly.SetPolys(stripper.GetOutput().GetLines())
# Triangulate
tri = vtkTriangleFilter()
tri.SetInputData(boundaryPoly)
tri.Update()
# Join to the input
merger = vtkAppendPolyData()
merger.AddInputData(input)
merger.AddInputData(tri.GetOutput())
# Clean up by merging duplicate points
cleaner = vtkCleanPolyData()
cleaner.SetInputConnection(merger.GetOutputPort())
cleaner.Update()
# Set output
output = self.GetPolyDataOutput()
output.ShallowCopy(cleaner.GetOutput())
return
开发者ID:UCL,项目名称:hemelb,代码行数:40,代码来源:OutputGeneration.py
示例17: get_actor
def get_actor(vtk_source, color=[1, 1, 0]):
normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(vtk_source.GetOutputPort())
normals.SetFeatureAngle(60.0)
normals.ReleaseDataFlagOn()
stripper = vtk.vtkStripper()
stripper.SetInputConnection(normals.GetOutputPort())
stripper.ReleaseDataFlagOn()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(stripper.GetOutputPort())
mapper.SetScalarVisibility(0)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetDiffuseColor(color)
actor.GetProperty().SetSpecular(0.3)
actor.GetProperty().SetSpecularPower(20)
return actor
开发者ID:quentan,项目名称:Test_ImageData,代码行数:22,代码来源:TestImageData.py
示例18: addSurface
def addSurface(self, name, value, r, g, b):
if self.surfaces.has_key(name):
return
surface = {}
boneExtractor = vtk.vtkMarchingCubes()
boneExtractor.SetInput(self.vtkImageData)
boneExtractor.SetValue(0, value)
surface["boneExtractor"] = boneExtractor
boneNormals = vtk.vtkPolyDataNormals()
boneNormals.SetInputConnection(boneExtractor.GetOutputPort())
boneNormals.SetFeatureAngle(60.0)
surface["boneNormals"] = boneNormals
boneStripper = vtk.vtkStripper()
boneStripper.SetInputConnection(boneNormals.GetOutputPort())
surface["boneStripper"] = boneStripper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(boneStripper.GetOutputPort())
mapper.ScalarVisibilityOff()
mapper.Update()
surface["mapper"] = mapper
boneProperty = vtk.vtkProperty()
boneProperty.SetColor(r, g, b)
volume = vtk.vtkActor()
volume.SetMapper(mapper)
volume.SetProperty(boneProperty)
surface["volume"] = volume
self.addVolume(volume)
self.surfaces[name] = surface
self.updateMapperClipPlanes(mapper)
self.window.Render()
开发者ID:aevum,项目名称:moonstone,代码行数:38,代码来源:imagevolume.py
示例19: _capCutPolyData
def _capCutPolyData(self, clipPolyData):
# set a vtkCutter up exactly like the vtkClipPolyData
cutter = vtk.vtkCutter()
cutter.SetCutFunction(clipPolyData.GetClipFunction())
cutter.SetInput(clipPolyData.GetInput())
cutter.SetValue(0, clipPolyData.GetValue())
cutter.SetGenerateCutScalars(clipPolyData.GetGenerateClipScalars())
cutStripper = vtk.vtkStripper()
cutStripper.SetInput(cutter.GetOutput())
cutStripper.Update()
cutPolyData = vtk.vtkPolyData()
cutPolyData.SetPoints(cutStripper.GetOutput().GetPoints())
cutPolyData.SetPolys(cutStripper.GetOutput().GetLines())
cpd = vtk.vtkCleanPolyData()
cpd.SetInput(cutPolyData)
tf = vtk.vtkTriangleFilter()
tf.SetInput(cpd.GetOutput())
tf.Update()
return tf.GetOutput()
开发者ID:fvpolpeta,项目名称:devide,代码行数:23,代码来源:glenoidMouldDesign.py
示例20: Execute
def Execute(self):
normal = [math.cos(self.RotationAngle) * math.sin(self.TiltingAngle),
math.sin(self.RotationAngle) * math.sin(self.TiltingAngle),
math.cos(self.TiltingAngle)]
plane = vtk.vtkPlane()
plane.SetOrigin(self.Center)
plane.SetNormal(normal)
cutter = vtk.vtkCutter()
cutter.SetInput(self.Contour)
cutter.SetCutFunction(plane)
cutter.SetValue(0,0.0)
cutter.Update()
cleaner = vtk.vtkCleanPolyData()
cleaner.SetInput(cutter.GetOutput())
cleaner.Update()
stripper = vtk.vtkStripper()
stripper.SetInput(cleaner.GetOutput())
stripper.Update()
cutLine = stripper.GetOutput()
self.Locations = [0.0, 0.0]
self.Thickness = 2.0 * self.ComputeMeanRadius(cutLine)
self.Thickness3D = self.Thickness
开发者ID:151706061,项目名称:FEMRI,代码行数:24,代码来源:femrithicknessmeasurement.py
注:本文中的vtk.vtkStripper函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论