本文整理汇总了Python中vtk.vtkSphereSource方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkSphereSource方法的具体用法?Python vtk.vtkSphereSource怎么用?Python vtk.vtkSphereSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk
的用法示例。
在下文中一共展示了vtk.vtkSphereSource方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pipeline
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def test_pipeline():
# check defaults
s = vtk.vtkSphereSource()
f = vtk.vtkSmoothPolyDataFilter()
out = serial_connect(s, f)
assert isinstance(out, BSPolyData)
assert out.n_points > 0
# check update filter
s = vtk.vtkSphereSource()
f = vtk.vtkSmoothPolyDataFilter()
out = serial_connect(s, f, as_data=False)
assert isinstance(out, BSAlgorithm)
assert out.GetOutput().GetNumberOfPoints() > 0
# check filter no update
s = vtk.vtkSphereSource()
f = vtk.vtkSmoothPolyDataFilter()
out = serial_connect(s, f, as_data=False, update=False)
assert isinstance(out, BSAlgorithm)
assert out.GetOutput().GetNumberOfPoints() == 0
# check non-existing port
s = vtk.vtkSphereSource()
f = vtk.vtkSmoothPolyDataFilter()
out = serial_connect(s, f, port=1)
assert out is None
# check get all possible ports
s = vtk.vtkSphereSource()
f = vtk.vtkSmoothPolyDataFilter()
out = serial_connect(s, f, port=-1)
assert isinstance(out, list)
assert len(out) == f.GetNumberOfOutputPorts()
assert isinstance(out[0], BSPolyData)
assert out[0].n_points > 0
# check accept wrappers
s = wrap_vtk(vtk.vtkSphereSource)
f = wrap_vtk(vtk.vtkSmoothPolyDataFilter)
assert isinstance(serial_connect(s, f), BSPolyData)
示例2: _generate_sphere
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def _generate_sphere():
s = vtk.vtkSphereSource()
s.Update()
return wrap_vtk(s.GetOutput())
示例3: plotter_single_renderer
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def plotter_single_renderer():
s = to_data(vtk.vtkSphereSource())
p = Plotter(offscreen=True)
ren0 = p.AddRenderer(row=0, col=0)
ac0 = ren0.AddActor()
ac0.SetMapper(inputdata=s)
return p
示例4: test_build_plotter
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def test_build_plotter():
s1 = to_data(vtk.vtkSphereSource())
s2 = to_data(vtk.vtkSphereSource())
surfs = {'s1': s1, 's2': s2}
layout = np.array([['s1', 's2'], ['s2', 's2']])
p = build_plotter(surfs, layout, offscreen=True)
assert isinstance(p, Plotter)
示例5: test_plot_surf
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def test_plot_surf():
s1 = to_data(vtk.vtkSphereSource())
s2 = to_data(vtk.vtkSphereSource())
surfs = {'s1': s1, 's2': s2}
layout = np.array([['s1', 's2'], ['s2', 's2']])
plot_surf(surfs, layout, offscreen=True)
示例6: test_plot_hemispheres
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def test_plot_hemispheres():
s1 = to_data(vtk.vtkSphereSource())
s2 = to_data(vtk.vtkSphereSource())
plot_hemispheres(s1, s2, offscreen=True)
示例7: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def __init__(self, node, scale_factor, text_height=5, combo_name='Combo 1'):
# Calculate the node's deformed position
newX = node.X + scale_factor*(node.DX[combo_name])
newY = node.Y + scale_factor*(node.DY[combo_name])
newZ = node.Z + scale_factor*(node.DZ[combo_name])
# Generate a sphere for the node
sphere = vtk.vtkSphereSource()
sphere.SetCenter(newX, newY, newZ)
sphere.SetRadius(0.6*text_height)
# Set up a mapper for the node
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(sphere.GetOutputPort())
# Set up an actor for the node
self.actor = vtk.vtkActor()
self.actor.GetProperty().SetColor(255, 255, 0) # Yellow
self.actor.SetMapper(mapper)
# Create the text for the node label
label = vtk.vtkVectorText()
label.SetText(node.Name)
# Set up a mapper for the node label
lblMapper = vtk.vtkPolyDataMapper()
lblMapper.SetInputConnection(label.GetOutputPort())
# Set up an actor for the node label
self.lblActor = vtk.vtkFollower()
self.lblActor.SetMapper(lblMapper)
self.lblActor.SetScale(text_height, text_height, text_height)
self.lblActor.SetPosition(newX + 0.6*text_height, newY + 0.6*text_height, newZ)
self.lblActor.GetProperty().SetColor(255, 255, 0) # Yellow
#%%
# Converts a member object into a member in its deformed position for the viewer
示例8: check_depth_peeling
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def check_depth_peeling(number_of_peels=100, occlusion_ratio=0.0):
"""Check if depth peeling is available.
Attempts to use depth peeling to see if it is available for the current
environment. Returns ``True`` if depth peeling is available and has been
successfully leveraged, otherwise ``False``.
"""
# Try Depth Peeling with a basic scene
source = vtk.vtkSphereSource()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# requires opacity < 1
actor.GetProperty().SetOpacity(0.5)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindow.SetOffScreenRendering(True)
renderWindow.SetAlphaBitPlanes(True)
renderWindow.SetMultiSamples(0)
renderer.AddActor(actor)
renderer.SetUseDepthPeeling(True)
renderer.SetMaximumNumberOfPeels(number_of_peels)
renderer.SetOcclusionRatio(occlusion_ratio)
renderWindow.Render()
return renderer.GetLastRenderingUsedDepthPeeling() == 1
示例9: MakeSphere
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def MakeSphere():
"""
Make a sphere as the source.
:return: vtkPolyData with normal and scalar data.
"""
source = vtk.vtkSphereSource()
source.SetCenter(0.0, 0.0, 0.0)
source.SetRadius(10.0)
source.SetThetaResolution(32)
source.SetPhiResolution(32)
source.Update()
return MakeElevations(source.GetOutput())
示例10: CreateSphere
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def CreateSphere(self, origin, r):
"Create a sphere with given origin (x,y,z) and radius r"
sphere = vtk.vtkSphereSource()
sphere.SetCenter(origin)
sphere.SetRadius(r)
sphere.SetPhiResolution(25)
sphere.SetThetaResolution(25)
sphere.Update()
self.pd = vtk.vtkPolyData()
self.pd.DeepCopy(sphere.GetOutput())
self.scalars = None
self.SetupPipelineMesh()
示例11: test_cell_types
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def test_cell_types():
ss = vtk.vtkSphereSource()
ss.Update()
st = wrap_vtk(ss.GetOutput())
sl = mc.to_lines(st)
sv = mc.to_vertex(st)
assert checks.get_cell_types(st) == np.array([VTK_TRIANGLE])
assert checks.get_cell_types(st.VTKObject) == np.array([VTK_TRIANGLE])
assert checks.get_cell_types(sl) == np.array([VTK_LINE])
assert checks.get_cell_types(sv) == np.array([VTK_VERTEX])
assert checks.get_number_of_cell_types(st) == 1
assert checks.get_number_of_cell_types(st.VTKObject) == 1
assert checks.get_number_of_cell_types(sl) == 1
assert checks.get_number_of_cell_types(sv) == 1
assert checks.has_unique_cell_type(st)
assert checks.has_unique_cell_type(st.VTKObject)
assert checks.has_unique_cell_type(sl)
assert checks.has_unique_cell_type(sv)
assert checks.has_only_triangle(st)
assert checks.has_only_triangle(st.VTKObject)
assert checks.has_only_line(sl)
assert checks.has_only_vertex(sv)
ss2 = vtk.vtkSphereSource()
ss2.SetRadius(3)
ss2.Update()
s2 = ss2.GetOutput()
app = vtk.vtkAppendPolyData()
app.AddInputData(sl.VTKObject)
app.AddInputData(s2)
app.Update()
spl = wrap_vtk(app.GetOutput())
cell_types = np.sort([VTK_TRIANGLE, VTK_LINE])
assert np.all(checks.get_cell_types(spl) == cell_types)
assert checks.get_number_of_cell_types(spl) == cell_types.size
assert checks.has_unique_cell_type(spl) is False
assert checks.has_only_triangle(spl) is False
assert checks.has_only_line(spl) is False
assert checks.has_only_vertex(spl) is False
示例12: test_moran
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def test_moran():
# Sphere with points as locations to build spatial matrix
sphere = wrap_vtk(vtk.vtkSphereSource, radius=20, thetaResolution=10,
phiResolution=5)
sphere = to_data(sphere)
n_pts = sphere.n_points
# Features to randomize
rs = np.random.RandomState(0)
feats = rs.randn(n_pts, 2)
# build spatial weight matrix
a = me.get_immediate_distance(sphere)
a.data **= -1
# test default
v, w = compute_mem(a, tol=1e-7)
assert w.shape[0] <= (n_pts - 1)
assert v.shape == (n_pts, w.shape[0])
r1 = moran_randomization(feats[:, 0], v, n_rep=10, random_state=0)
assert r1.shape == (10, n_pts)
r2 = moran_randomization(feats, v, n_rep=10, random_state=0)
assert r2.shape == (10, n_pts, 2)
# test default dense
mem, ev = compute_mem(a.toarray(), tol=1e-7)
assert np.allclose(w, ev)
assert np.allclose(v, mem)
r1 = moran_randomization(feats[:, 0], mem, n_rep=10, random_state=0)
assert r1.shape == (10, n_pts)
r2 = moran_randomization(feats, mem, n_rep=10, random_state=0)
assert r2.shape == (10, n_pts, 2)
# test object api
msr = MoranRandomization(n_rep=10, random_state=0, tol=1e-7)
msr.fit(a)
assert np.allclose(msr.mev_, ev)
assert np.allclose(msr.mem_, mem)
assert np.allclose(r1, msr.randomize(feats[:, 0]))
assert np.allclose(r2, msr.randomize(feats))
# test object api with PolyData
msr = MoranRandomization(n_rep=10, random_state=0, tol=1e-7)
msr.fit(sphere)
assert np.allclose(msr.mev_, ev)
assert np.allclose(msr.mem_, mem)
assert np.allclose(r1, msr.randomize(feats[:, 0]))
assert np.allclose(r2, msr.randomize(feats))
示例13: Sphere
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSphereSource [as 别名]
def Sphere(radius=0.5, center=(0, 0, 0), direction=(0, 0, 1), theta_resolution=30,
phi_resolution=30, start_theta=0, end_theta=360, start_phi=0, end_phi=180):
"""Create a vtk Sphere.
Parameters
----------
radius : float, optional
Sphere radius
center : np.ndarray or list, optional
Center in [x, y, z]
direction : list or np.ndarray
Direction the top of the sphere points to in [x, y, z]
theta_resolution: int , optional
Set the number of points in the longitude direction (ranging from
start_theta to end theta).
phi_resolution : int, optional
Set the number of points in the latitude direction (ranging from
start_phi to end_phi).
start_theta : float, optional
Starting longitude angle.
end_theta : float, optional
Ending longitude angle.
start_phi : float, optional
Starting latitude angle.
end_phi : float, optional
Ending latitude angle.
Return
------
sphere : pyvista.PolyData
Sphere mesh.
"""
sphere = vtk.vtkSphereSource()
sphere.SetRadius(radius)
sphere.SetThetaResolution(theta_resolution)
sphere.SetPhiResolution(phi_resolution)
sphere.SetStartTheta(start_theta)
sphere.SetEndTheta(end_theta)
sphere.SetStartPhi(start_phi)
sphere.SetEndPhi(end_phi)
sphere.Update()
surf = pyvista.PolyData(sphere.GetOutput())
surf.rotate_y(-90)
translate(surf, center, direction)
return surf