本文整理汇总了Python中vtk.vtkLineSource函数的典型用法代码示例。如果您正苦于以下问题:Python vtkLineSource函数的具体用法?Python vtkLineSource怎么用?Python vtkLineSource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkLineSource函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _draw_line
def _draw_line(self):
line1 = vtk.vtkLineSource()
line1.SetPoint1(self.points[0])
line1.SetPoint2(self.points[1])
line2 = vtk.vtkLineSource()
line2.SetPoint1(self.points[1])
line2.SetPoint2(self.points[2])
arc = self.DrawArc()
line = vtk.vtkAppendPolyData()
line.AddInput(line1.GetOutput())
line.AddInput(line2.GetOutput())
line.AddInput(arc.GetOutput())
c = vtk.vtkCoordinate()
c.SetCoordinateSystemToWorld()
m = vtk.vtkPolyDataMapper2D()
m.SetInputConnection(line.GetOutputPort())
m.SetTransformCoordinate(c)
a = vtk.vtkActor2D()
a.SetMapper(m)
a.GetProperty().SetColor(self.colour)
self.line_actor = a
开发者ID:RuanAragao,项目名称:invesalius3,代码行数:27,代码来源:measures.py
示例2: __create_box
def __create_box(self):
xi = yi = 0.1
xf = yf = 200
line_i = vtk.vtkLineSource()
line_i.SetPoint1((xi, yi, 0))
line_i.SetPoint2((xf, yi, 0))
self.line_i = line_i
self.line_i_actor = self.__create_line_actor(line_i)
line_s = vtk.vtkLineSource()
line_s.SetPoint1((xi, yf, 0))
line_s.SetPoint2((xf, yf, 0))
self.line_s = line_s
self.line_s_actor = self.__create_line_actor(line_s)
line_l = vtk.vtkLineSource()
line_l.SetPoint1((xi, yi, 0))
line_l.SetPoint2((xi, yf, 0))
self.line_l = line_l
self.line_l_actor = self.__create_line_actor(line_l)
line_r = vtk.vtkLineSource()
line_r.SetPoint1((xf, yi, 0))
line_r.SetPoint2((xf, yf, 0))
self.line_r = line_r
self.line_r_actor = self.__create_line_actor(line_r)
box_actor = vtk.vtkPropAssembly()
box_actor.AddPart(self.line_i_actor)
box_actor.AddPart(self.line_s_actor)
box_actor.AddPart(self.line_l_actor)
box_actor.AddPart(self.line_r_actor)
self.box_actor = box_actor
开发者ID:ruppert,项目名称:invesalius3,代码行数:33,代码来源:slice_data.py
示例3: __init__
def __init__(self):
self._line1 = vtk.vtkLineSource()
self._line2 = vtk.vtkLineSource()
self.AddInput(self._line1.GetOutput())
self.AddInput(self._line2.GetOutput())
self._center = (0, 0, 0)
self._size = 10
开发者ID:parallaxinnovations,项目名称:vtkEVS,代码行数:8,代码来源:RectROIFactory.py
示例4: GetRepresentation
def GetRepresentation(self, x, y, z):
pc = self.camera.GetPosition() # camera position
pf = self.camera.GetFocalPoint() # focal position
pp = (x, y, z) # point where the user clicked
# Vector from camera position to user clicked point
vcp = [j-i for i,j in zip(pc, pp)]
# Vector from camera position to camera focal point
vcf = [j-i for i,j in zip(pc, pf)]
# the vector where the perpendicular vector will be given
n = [0,0,0]
# The cross, or vectorial product, give a vector perpendicular to vcp
# and vcf, in this case this vector will be in horizontal, this vector
# will be stored in the variable "n"
vtk.vtkMath.Cross(vcp, vcf, n)
# then normalize n to only indicate the direction of this vector
vtk.vtkMath.Normalize(n)
# then
p1 = [i*self.size + j for i,j in zip(n, pp)]
p2 = [i*-self.size + j for i,j in zip(n, pp)]
sh = vtk.vtkLineSource()
sh.SetPoint1(p1)
sh.SetPoint2(p2)
n = [0,0,0]
vcn = [j-i for i,j in zip(p1, pc)]
vtk.vtkMath.Cross(vcp, vcn, n)
vtk.vtkMath.Normalize(n)
p3 = [i*self.size + j for i,j in zip(n, pp)]
p4 = [i*-self.size +j for i,j in zip(n, pp)]
sv = vtk.vtkLineSource()
sv.SetPoint1(p3)
sv.SetPoint2(p4)
cruz = vtk.vtkAppendPolyData()
cruz.AddInput(sv.GetOutput())
cruz.AddInput(sh.GetOutput())
c = vtk.vtkCoordinate()
c.SetCoordinateSystemToWorld()
m = vtk.vtkPolyDataMapper2D()
m.SetInputConnection(cruz.GetOutputPort())
m.SetTransformCoordinate(c)
a = vtk.vtkActor2D()
a.SetMapper(m)
a.GetProperty().SetColor(self.colour)
return a
开发者ID:RuanAragao,项目名称:invesalius3,代码行数:51,代码来源:measures.py
示例5: drawLineBetween2Landmark
def drawLineBetween2Landmark(self, landmark1ID, landmark2ID, markupsDictionary):
markupsNode1 = slicer.mrmlScene.GetNodeByID(self.findMarkupsNodeFromLandmarkID(markupsDictionary, landmark1ID))
markupsNode2 = slicer.mrmlScene.GetNodeByID(self.findMarkupsNodeFromLandmarkID(markupsDictionary, landmark2ID))
landmark1Index = markupsNode1.GetMarkupIndexByID(landmark1ID)
landmark2Index = markupsNode2.GetMarkupIndexByID(landmark2ID)
coord1 = [-1, -1, -1]
coord2 = [-1, -1, -1]
markupsNode1.GetNthFiducialPosition(landmark1Index, coord1)
markupsNode2.GetNthFiducialPosition(landmark2Index, coord2)
line = vtk.vtkLineSource()
line.SetPoint1(coord1)
line.SetPoint2(coord2)
line.Update()
mapper = vtk.vtkPolyDataMapper()
actor = vtk.vtkActor()
mapper.SetInputData(line.GetOutput())
mapper.Update()
actor.SetMapper(mapper)
layoutManager = slicer.app.layoutManager()
threeDWidget = layoutManager.threeDWidget(0)
threeDView = threeDWidget.threeDView()
renderWindow = threeDView.renderWindow()
renderers = renderWindow.GetRenderers()
renderer = renderers.GetFirstRenderer()
renderWindow.AddRenderer(renderer)
renderer.AddActor(actor)
renderWindow.Render()
return renderer, actor
开发者ID:luciemac,项目名称:Q3DCExtension,代码行数:34,代码来源:Q3DC.py
示例6: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkLineSource(), 'Processing.',
(), ('vtkPolyData',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkLineSource.py
示例7: __init__
def __init__(self):
ActorFactory.__init__(self)
self._Property = vtk.vtkProperty()
self._Plane = None
self._Line = []
for i in range(4):
self._Line.append(vtk.vtkLineSource())
开发者ID:parallaxinnovations,项目名称:vtkAtamai,代码行数:7,代码来源:PlaneOutlineFactory.py
示例8: add_line_probe
def add_line_probe(self, name, p0, p1, n_point):
"""
Create the line probe - VTK object.
Parameters
----------
name : str
The probe name.
p0 : array_like
The coordinates of the start point.
p1 : array_like
The coordinates of the end point.
n_point : int
The number of probe points.
"""
line = vtk.vtkLineSource()
line.SetPoint1(p0)
line.SetPoint2(p1)
line.SetResolution(n_point)
line.Update()
pars = nm.arange(n_point + 1) / nm.float(n_point)
self.probes[name] = (line, pars)
self.probes_png[name] = False
开发者ID:logansorenson,项目名称:sfepy,代码行数:25,代码来源:probes_vtk.py
示例9: __draw_sample_as_line
def __draw_sample_as_line(self,sample,color,warning_color):
a = self.__line_actors.get(sample)
if a is not None:
a.SetVisibility(1)
return
p1 = sample.coil_center
p2 = sample.sphere_intersection
p1 = (p2+(p1-p2)/np.linalg.norm(p1-p2)*self.COIL_HEIGHT)
#p3 = p1+(p2-p1)*1.2 # an extra 20% to guarantee it goes into the sphere
p3 = p1+(p2-p1)*500
source = vtk.vtkLineSource()
source.SetPoint1(p1)
source.SetPoint2(p3)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
self.ren.AddActor(actor)
self.__line_actors[sample]=actor
prop = actor.GetProperty()
if sample.timing_error > 1:
if warning_color is None:
warning_color = self.SAMPLE_LINE_WARNING_COLOR
prop.SetColor(warning_color)
else:
if color is None:
color = self.SAMPLE_LINE_COLOR
prop.SetColor(color)
prop.SetAmbient(1.0)
开发者ID:deherinu,项目名称:TmsViewer,代码行数:34,代码来源:vtk_tms_widget.py
示例10: probeVolume
def probeVolume(self, volumeNode, rulerNode):
# get ruler ednpoints coordinates in RAS
p0ras = rulerNode.GetPolyData().GetPoint(0) + (1,)
p1ras = rulerNode.GetPolyData().GetPoint(1) + (1,)
# RAS --> IJK
ras2ijk = vtk.vtkMatrix4x4()
volumeNode.GetRASToIJKMatrix(ras2ijk)
p0ijk = [int(round(c)) for c in ras2ijk.MultiplyPoint(p0ras)[:3]]
p1ijk = [int(round(c)) for c in ras2ijk.MultiplyPoint(p1ras)[:3]]
# Create VTK line that will be used for sampling
line = vtk.vtkLineSource()
line.SetResolution(100)
line.SetPoint1(p0ijk)
line.SetPoint2(p1ijk)
# Create VTK probe filter and sample the image
probe = vtk.vtkProbeFilter()
probe .SetInputConnection(line.GetOutputPort())
probe.SetSourceData(volumeNode.GetImageData())
probe.Update()
# Return VTK array
return probe.GetOutput().GetPointData().GetArray('ImageScalars')
开发者ID:quentan,项目名称:SlicerScript,代码行数:26,代码来源:LineIntersityProfile.py
示例11: add_edge
def add_edge(self, start, end, colour=Colours.BASE0):
"""Appends an edge to the edges list."""
# Line
line = vtkLineSource()
line.SetPoint1(start)
line.SetPoint2(end)
# Line Mapper
line_mapper = vtkPolyDataMapper()
line_mapper.SetInputConnection(line.GetOutputPort())
self.edge_colours.append(colour)
self.line_mappers.append(line_mapper)
# Bar
bar = vtkTubeFilter()
bar.SetInputConnection(line.GetOutputPort())
bar.SetRadius(2.5)
self.bar_data.append(bar)
# Bar Mapper
# Tried this, but mapping the ribbon caused beaucoup errors,
# debugging would take a week.There must be some kind of way
# out of here.
# Said the joker to the thief
# There's too much confusion
# I can't get no relief
# No reason to get excited, the thief he kindly spoke
# But you and I have been through that
# And this is not our fate
# So let us not talk falsely now, the hour is getting late.
# (2011-08-12)
bar_mapper = vtkPolyDataMapper()
bar_mapper.SetInputConnection(bar.GetOutputPort())
self.bar_mappers.append(bar_mapper)
开发者ID:TomRegan,项目名称:synedoche,代码行数:31,代码来源:Graphics.py
示例12: draw_line
def draw_line(self, l):
"""
"""
if l in self.lines:
return
self.lines.append(l)
line = vtk.vtkLineSource()
line.SetPoint1(l.p1.x, l.p1.y, l.p1.z)
line.SetPoint2(l.p2.x, l.p2.y, l.p2.z)
# lineMapper = vtk.vtkPolyDataMapper()
# lineMapper.SetInputConnection(line.GetOutputPort())
# lineActor = vtk.vtkActor()
# lineActor.SetMapper(lineMapper)
tubeFilter = vtk.vtkTubeFilter()
tubeFilter.SetInputConnection(line.GetOutputPort())
tubeFilter.SetRadius(l.radius)
tubeFilter.SetNumberOfSides(10)
tubeFilter.Update()
tubeMapper = vtk.vtkPolyDataMapper()
tubeMapper.SetInputConnection(tubeFilter.GetOutputPort())
tubeActor = vtk.vtkActor()
tubeActor.SetMapper(tubeMapper)
tubeActor.GetProperty().SetColor(l.color[0], l.color[1], l.color[2])
self.rend.AddActor(tubeActor)
self.tubeActors.append(tubeActor)
开发者ID:hadim,项目名称:lsysdrawer,代码行数:32,代码来源:vviewer.py
示例13: add_line
def add_line(self, start, end, color=(0.5, 0.5, 0.5), width=1):
"""
Adds a line.
Args:
start:
Starting coordinates for line.
end:
Ending coordinates for line.
color:
Color for text as RGB. Defaults to grey.
width:
Width of line. Defaults to 1.
"""
source = vtk.vtkLineSource()
source.SetPoint1(start)
source.SetPoint2(end)
vertexIDs = vtk.vtkStringArray()
vertexIDs.SetNumberOfComponents(1)
vertexIDs.SetName("VertexIDs")
# Set the vertex labels
vertexIDs.InsertNextValue("a")
vertexIDs.InsertNextValue("b")
source.GetOutput().GetPointData().AddArray(vertexIDs)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(color)
actor.GetProperty().SetLineWidth(width)
self.ren.AddActor(actor)
开发者ID:akashneo,项目名称:pymatgen,代码行数:33,代码来源:structure_vtk.py
示例14: _createCylinder
def _createCylinder(self, endPt1, endPt2, res=20):
"""
Create a cylinder oriented to have the given end points.
:@type endPt1: Vec3f
:@param endPt1: The first end point to align the cylinder with.
:@type endPt2: Vec3f
:@param endPt2: The second end point to align the cylinder with.
:@type radius: float
:@param radius: The radius of the cylinder.
:@type res: int
:@param res: The circular resolution of the cylinder (number of sides).
Must be at least 3.
:@rtype: vtk.vtkActor
:@return: A renderable actor representing a cylinder.
"""
res = 3 if res < 3 else res
line = vtk.vtkLineSource()
line.SetPoint1(endPt1.x,endPt1.y,endPt1.z)
line.SetPoint2(endPt2.x,endPt2.y,endPt2.z)
# Create a tube filter to represent the line as a cylinder.
tube = vtk.vtkTubeFilter()
tube.SetInput(line.GetOutput())
tube.SetRadius(self.actor_radius)
tube.SetNumberOfSides(res)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(tube.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
return actor
开发者ID:smdabdoub,项目名称:ProkaryMetrics,代码行数:32,代码来源:bacteria.py
示例15: _create_geometry
def _create_geometry(self):
self._line_source = vtk.vtkLineSource()
m = vtk.vtkPolyDataMapper()
m.SetInputConnection(self._line_source.GetOutputPort())
a = vtk.vtkActor()
a.SetMapper(m)
a.GetProperty().SetColor(0.0, 0.0, 0.0)
self.props = [a]
开发者ID:sanguinariojoe,项目名称:devide,代码行数:8,代码来源:devide_canvas_object.py
示例16: starInterpolation
def starInterpolation(self, data, xy, h):
"""
Interpolate along a star stencil
@param data either self.refData or self.spcData
@param xy x and y coordinates at center of stencil
@param h excursion from the center
@return {'w': value, 'e': value, 'n': value, 's': value}
"""
lineX = vtk.vtkLineSource()
lineX.SetPoint1(xy[0] - h, xy[1], 0.0)
lineX.SetPoint2(xy[0] + h, xy[1], 0.0)
lineX.SetResolution(1)
lineY = vtk.vtkLineSource()
lineY.SetPoint1(xy[0], xy[1] - h, 0.0)
lineY.SetPoint2(xy[0], xy[1] + h, 0.0)
lineY.SetResolution(1)
probeX = vtk.vtkProbeFilter()
if vtk.VTK_MAJOR_VERSION >= 6:
probeX.SetSourceData(data['polydata'])
else:
probeX.SetSource(data['polydata'])
probeX.SetInputConnection(lineX.GetOutputPort())
probeX.Update()
probeY = vtk.vtkProbeFilter()
if vtk.VTK_MAJOR_VERSION >= 6:
probeY.SetSourceData(data['polydata'])
else:
probeY.SetSource(data['polydata'])
probeY.SetInputConnection(lineY.GetOutputPort())
probeY.Update()
res = {}
# west and east
res['w'] = probeX.GetOutput().GetPointData().GetArray(0).GetTuple(0)
res['e'] = probeX.GetOutput().GetPointData().GetArray(0).GetTuple(1)
# south and north
res['s'] = probeY.GetOutput().GetPointData().GetArray(0).GetTuple(0)
res['n'] = probeY.GetOutput().GetPointData().GetArray(0).GetTuple(1)
return res
开发者ID:pletzer,项目名称:compos,代码行数:46,代码来源:compos2d.py
示例17: createLine
def createLine(p1,p2,numPoints):
# Create the line along which you want to sample
line = vtk.vtkLineSource()
line.SetResolution(numPoints)
line.SetPoint1(p1)
line.SetPoint2(p2)
line.Update()
return line
开发者ID:blaisb,项目名称:cfdemUtilities,代码行数:8,代码来源:probePhaseAverage.py
示例18: __init__
def __init__(self,source):
self.line = vtk.vtkLineSource()
self.line.SetResolution(800)
self.line.SetPoint1(0,800,0)
self.line.SetPoint2(800,800,0)
self.SetInputConnection(self.line.GetOutputPort())
self.SetSource(source)
'''
开发者ID:rbulha,项目名称:scopevtk,代码行数:9,代码来源:Scope.py
示例19: get_line_actor
def get_line_actor(p0,p1):
source = vtk.vtkLineSource()
source.SetPoint1(p0)
source.SetPoint2(p1)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
return actor
开发者ID:deherinu,项目名称:TmsViewer,代码行数:9,代码来源:calibration_commands.py
示例20: __init__
def __init__(self,p1=(0,0,0) , p2=(1,1,1), color=(0,1,1) ):
""" line """
self.src = vtk.vtkLineSource()
self.src.SetPoint1(p1)
self.src.SetPoint2(p2)
self.mapper = vtk.vtkPolyDataMapper()
self.mapper.SetInput(self.src.GetOutput())
self.SetMapper(self.mapper)
self.SetColor(color)
开发者ID:aewallin,项目名称:randompolygon,代码行数:9,代码来源:ovdvtk.py
注:本文中的vtk.vtkLineSource函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论