本文整理汇总了Python中vtk.vtkTransformFilter函数的典型用法代码示例。如果您正苦于以下问题:Python vtkTransformFilter函数的具体用法?Python vtkTransformFilter怎么用?Python vtkTransformFilter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkTransformFilter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_cylinder
def get_cylinder(upper, height, radius,
direction,
resolution=10):
src = vtk.vtkCylinderSource()
src.SetCenter((0, height/2, 0))
src.SetHeight(height + radius/2.0)
src.SetRadius(radius)
src.SetResolution(resolution)
rot1 = vtk.vtkTransform()
fi = nm.arccos(direction[1])
rot1.RotateWXYZ(-nm.rad2deg(fi), 0.0, 0.0, 1.0)
u = nm.abs(nm.sin(fi))
rot2 = vtk.vtkTransform()
if u > 1.0e-6:
# sometimes d[0]/u little bit is over 1
d0_over_u = direction[0] / u
if d0_over_u > 1:
psi = 0
elif d0_over_u < -1:
psi = 2 * nm.pi
else:
psi = nm.arccos(direction[0] / u)
logger.debug('d0 '+str(direction[0])+' u '+str(u)+' psi '+str(psi))
if direction[2] < 0:
psi = 2 * nm.pi - psi
rot2.RotateWXYZ(-nm.rad2deg(psi), 0.0, 1.0, 0.0)
tl = vtk.vtkTransform()
tl.Translate(upper)
tr1a = vtk.vtkTransformFilter()
tr1a.SetInput(src.GetOutput())
tr1a.SetTransform(rot1)
tr1b = vtk.vtkTransformFilter()
tr1b.SetInput(tr1a.GetOutput())
tr1b.SetTransform(rot2)
tr2 = vtk.vtkTransformFilter()
tr2.SetInput(tr1b.GetOutput())
tr2.SetTransform(tl)
tr2.Update()
return tr2.GetOutput()
开发者ID:Trineon,项目名称:lisa,代码行数:51,代码来源:gen_vtk_tree.py
示例2: wrapOpImp
def wrapOpImp(self):
transformFilter = vtk.vtkTransformFilter();
transformFilter.SetTransform(self.getTransform());
transformFilter.SetInputData(self.data);
transformFilter.Update();
result = transformFilter.GetOutput();
return result;
开发者ID:avontd2868,项目名称:OU_Final_Year,代码行数:7,代码来源:vtkOperations.py
示例3: attach_stl
def attach_stl(self, fname, scale=None):
"""Load a given STL file into a vtkPolyData object"""
reader = vtk.vtkSTLReader()
reader.SetFileName(fname)
reader.Update() # polydata
if scale is not None:
trans = vtk.vtkTransform()
trans.Scale(scale)
filt = vtk.vtkTransformFilter()
if vtk.VTK_MAJOR_VERSION <= 5:
filt.SetInputConnection(reader.GetOutputPort)
else:
filt.SetInputConnection(reader.GetOutputPort())
filt.SetTransform(trans)
mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
mapper.SetInput(filt.GetOutput())
else:
mapper.SetInputConnection(filt.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
self._ren.AddActor(actor)
开发者ID:Andrew-AbiMansour,项目名称:PyDEM,代码行数:31,代码来源:visualize.py
示例4: __init__
def __init__(self, profile):
"""Clip the STL and set attributes on the SWIG-proxied C++
GeometryGenerator object.
"""
self.profile = profile
self.generator = Generation.PolyDataGenerator()
self._SetCommonGeneratorProperties()
self.generator.SetSeedPointWorking(profile.SeedPoint.x / profile.VoxelSize,
profile.SeedPoint.y / profile.VoxelSize,
profile.SeedPoint.z / profile.VoxelSize)
# This will create the pipeline for the clipped surface
clipper = Clipper(profile)
# Scale by the voxel size
trans = vtkTransform()
scale = 1. / profile.VoxelSize
trans.Scale(scale, scale, scale)
transformer = vtkTransformFilter()
transformer.SetTransform(trans)
transformer.SetInputConnection(clipper.ClippedSurfaceSource.GetOutputPort())
# Uncomment this an insert the output path to debug pipeline construction
# write = StageWriter('/path/to/stage/output/directory').WriteOutput
# for alg in getpipeline(transformer):
# write(alg)
transformer.Update()
self.ClippedSurface = transformer.GetOutput()
self.generator.SetClippedSurface(self.ClippedSurface)
return
开发者ID:jenshnielsen,项目名称:hemelb,代码行数:34,代码来源:OutputGeneration.py
示例5: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkTransformFilter(), 'Processing.',
('vtkPointSet',), ('vtkPointSet',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkTransformFilter.py
示例6: get_slice
def get_slice(self, image, rotation):
"""Generate a polydata object of the provided image rotated by the
provided rotation."""
rotation_degrees = rotation.copy()
rotation_degrees[0] = 2.*numpy.arccos(rotation[0])*180./numpy.pi
transformation = vtk.vtkTransform()
transformation.RotateWXYZ(rotation_degrees[0], rotation_degrees[1],
rotation_degrees[2], rotation_degrees[3])
transform_filter = vtk.vtkTransformFilter()
input_poly_data = vtk.vtkPolyData()
input_poly_data.DeepCopy(self._template_poly_data)
# This deep copy stuff is needed since transform returns a
# pointer to the same object but transformed (i think) but
# it should be checked really.
#input_poly_data = self._template_poly_data.
#transform_filter.SetInputData(self._template_poly_data)
transform_filter.SetInputData(input_poly_data)
transform_filter.SetTransform(transformation)
transform_filter.Update()
this_poly_data = transform_filter.GetOutput()
scalars = this_poly_data.GetPointData().GetScalars()
for i in range(self._side):
for j in range(self._side):
# point_coord = this_poly_data.GetPoint(self._side*i + j)
#if point_coord[0] > 0.:
scalars.SetTuple1(i*self._side+j, image[i, j])
#scalars.SetTuple1(i*self._side+j, image[j, i])
# else:
# #polys.GetData().SetTuple4(i*self._side+j, 0., 0., 0., 0.)
# scalars.SetTuple1(i*self._side+j, nan)
this_poly_data.Modified()
return this_poly_data
开发者ID:FilipeMaia,项目名称:emc,代码行数:34,代码来源:slice_module.py
示例7: Execute
def Execute(self):
if (self.Mesh == None):
self.PrintError('Error: no Mesh.')
if not self.Matrix4x4:
self.Matrix4x4 = vtk.vtkMatrix4x4()
if self.MatrixCoefficients != []:
self.PrintLog('Setting up transform matrix using specified coefficients')
self.Matrix4x4.DeepCopy(self.MatrixCoefficients)
elif self.Translation != [0.0,0.0,0.0] or self.Rotation != [0.0,0.0,0.0] or self.Scaling != [1.0,1.0,1.0]:
self.PrintLog('Setting up transform matrix using specified translation, rotation and/or scaling')
transform = vtk.vtkTransform()
transform.RotateX(self.Rotation[0])
transform.RotateY(self.Rotation[1])
transform.RotateZ(self.Rotation[2])
transform.Translate(self.Translation[0], self.Translation[1], self.Translation[2])
transform.Scale(self.Scaling[0], self.Scaling[1], self.Scaling[2])
self.Matrix4x4.DeepCopy(transform.GetMatrix())
if self.InvertMatrix:
self.Matrix4x4.Invert()
transform = vtk.vtkMatrixToLinearTransform()
transform.SetInput(self.Matrix4x4)
transformFilter = vtk.vtkTransformFilter()
transformFilter.SetInputData(self.Mesh)
transformFilter.SetTransform(transform)
transformFilter.Update()
self.Mesh = transformFilter.GetOutput()
开发者ID:samsmu,项目名称:vmtk,代码行数:32,代码来源:vmtkmeshtransform.py
示例8: CreateTorus
def CreateTorus(point1, point2, axe):
"""
Creates a torus that has point1 as center point2 defines
a point on the torus.
"""
direction = map(lambda x, y: x - y, point2, point1)
length = math.sqrt(sum(map(lambda x: x ** 2, direction)))
torus = vtkParametricTorus()
torus.SetRingRadius(length / 1.5)
torus.SetCrossSectionRadius(length / 30.0)
torusSource = vtkParametricFunctionSource()
torusSource.SetParametricFunction(torus)
torusSource.SetScalarModeToPhase()
torusSource.Update()
transform = vtkTransform()
if axe == 0:
transform.RotateY(90)
elif axe == 1:
transform.RotateX(90)
transformFilter = vtkTransformFilter()
transformFilter.SetInputConnection(torusSource.GetOutputPort())
transformFilter.SetTransform(transform)
transformFilter.Update()
torusMapper = vtkPolyDataMapper()
torusMapper.SetInputConnection(transformFilter.GetOutputPort())
torusActor = vtkActor()
torusActor.SetMapper(torusMapper)
return torusActor, transformFilter.GetOutput()
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:35,代码来源:vtkDrawing.py
示例9: WriteVTSXMLVolumeFile
def WriteVTSXMLVolumeFile(self):
if (self.OutputFileName == ''):
self.PrintError('Error: no OutputFileName.')
self.PrintLog('Writing VTS XML grid file.')
if self.ApplyTransform == 0:
origin = self.Image.GetOrigin()
spacing = self.Image.GetSpacing()
matrix = vtk.vtkMatrix4x4()
matrix.DeepCopy((1/spacing[0], 0, 0, - origin[0]/spacing[0],
0, 1/spacing[1], 0, - origin[1]/spacing[1],
0, 0, 1/spacing[2], - origin[2]/spacing[2],
0, 0, 0, 1)) #LPI convention with correct origin and spacing
else:
if self.RasToIjkMatrixCoefficients == None:
self.PrintError('Error: no RasToIjkMatrixCoefficients.')
matrix = vtk.vtkMatrix4x4()
matrix.DeepCopy(self.RasToIjkMatrixCoefficients)
trans = vtk.vtkTransform()
trans.SetMatrix(matrix)
trans_filt = vtk.vtkTransformFilter()
trans_filt.SetTransform(trans)
trans_filt.SetInputData(self.Image)
trans_filt.Update()
writer = vtk.vtkXMLStructuredGridWriter()
writer.SetInputConnection(trans_filt.GetOutputPort())
writer.SetFileName(self.OutputFileName)
writer.Write()
开发者ID:vmtk,项目名称:vmtk,代码行数:27,代码来源:vmtkimagewriter.py
示例10: __init__
def __init__ (self, mod_m):
debug ("In VelocityVector::__init__ ()")
Common.state.busy ()
Base.Objects.Module.__init__ (self, mod_m)
self.glyph2d_src = vtk.vtkGlyphSource2D ()
self.cone = vtk.vtkConeSource ()
self.arrow = vtk.vtkArrowSource ()
self.glyph_src = self.cone
self.glyph3d = vtk.vtkGlyph3D ()
self.mapper = self.map = vtk.vtkPolyDataMapper ()
self.actor = self.act = vtk.vtkActor ()
# used to orient the cone properly
self.glph_trfm = vtk.vtkTransformFilter ()
self.glph_trfm.SetTransform (vtk.vtkTransform ())
self.data_out = self.mod_m.GetOutput ()
# Point of glyph that is attached -- -1 is tail, 0 is center,
# 1 is head.
self.glyph_pos = -1
self.scale = 1.0
self.color_mode = 2 #2 is vector, 1 is scalar, -1 none
self._initialize ()
self._gui_init ()
self.renwin.Render ()
Common.state.idle ()
开发者ID:sldion,项目名称:DNACC,代码行数:25,代码来源:VelocityVector.py
示例11: TransformFilter
def TransformFilter(self, currentElement):
transFilter = vtk.vtkTransformFilter()
# Datatype(s) I need for input: Algorithm, LinearTransform
AlgorithmElement = ''
TransformElement = ''
for childElement in currentElement.getchildren():
if childElement.tag in vtkTypes['Algorithm']:
AlgorithmElement = childElement
if childElement.tag in vtkTypes['LinearTransform']:
TransformElement = childElement
if AlgorithmElement != '':
dataset = self.namesToFunctions[AlgorithmElement.tag](AlgorithmElement)
try:
transFilter.SetInputConnection(dataset.GetOutputPort())
except:
self.logger.error(' .. <TransformFilter> failed to SetInputConnection')
else:
self.logger.error(' .. <TransformFilter> needs an Algorithm-type childElement')
if TransformElement != '':
transform = self.namesToFunctions[TransformElement.tag](TransformElement)
try:
transFilter.SetTransform(transform)
except:
self.logger.error(' .. <TransformFilter> failed to SetTransform')
else:
self.logger.error('<TransformFilter> needs an Transform-type childElement')
return transFilter
开发者ID:mfassler,项目名称:jaivis,代码行数:27,代码来源:xmlReader.py
示例12: surfacescaling
def surfacescaling(polydata, scalefactor=1.0):
"""Scale a vtkPolyData object."""
transform = vtk.vtkTransform()
transform.Scale(scalefactor, scalefactor, scalefactor)
transformFilter = vtk.vtkTransformFilter()
transformFilter.SetInput(polydata)
transformFilter.SetTransform(transform)
transformFilter.Update()
return transformFilter.GetOutput()
开发者ID:ajgeers,项目名称:utils,代码行数:9,代码来源:vtklib.py
示例13: surfacetranslation
def surfacetranslation(polydata, translation=[0.0, 0.0, 0.0]):
"""Translate a vtkPolyData object."""
transform = vtk.vtkTransform()
transform.Translate(translation)
transformFilter = vtk.vtkTransformFilter()
transformFilter.SetInput(polydata)
transformFilter.SetTransform(transform)
transformFilter.Update()
return transformFilter.GetOutput()
开发者ID:ajgeers,项目名称:utils,代码行数:9,代码来源:vtklib.py
示例14: Execute
def Execute(self):
if (self.Mesh == None):
self.PrintError('Error: no Mesh.')
transform = vtk.vtkTransform()
transform.Scale(self.ScaleFactor,self.ScaleFactor,self.ScaleFactor)
transformFilter = vtk.vtkTransformFilter()
transformFilter.SetInputData(self.Mesh)
transformFilter.SetTransform(transform)
transformFilter.Update()
self.Mesh = transformFilter.GetOutput()
开发者ID:vmtk,项目名称:vmtk,代码行数:14,代码来源:vmtkmeshscaling.py
示例15: addToScene
def addToScene(self, msource, **kwargs):
import vtk
vsource = msource
if 'translate' in kwargs:
tf = vtk.vtkTransformFilter()
tf.SetTransform(vtk.vtkTransform())
delta = kwargs['translate']
tf.GetTransform().Translate(delta[0], delta[1], delta[2])
tf.SetInputConnection(msource.GetOutputPort())
vsource = tf
ac = vtk.vtkActor()
mp = vtk.vtkCompositePolyDataMapper()
ac.SetMapper(mp)
mp.SetInputConnection(vsource.GetOutputPort())
self.renderer.AddActor(ac)
开发者ID:zenotech,项目名称:SMTK,代码行数:15,代码来源:testing.py
示例16: Execute
def Execute(self):
if (self.Mesh == None):
self.PrintError('Error: no Mesh.')
transform = vtk.vtkTransform()
transform.Scale(self.ScaleFactor,self.ScaleFactor,self.ScaleFactor)
transformFilter = vtk.vtkTransformFilter()
transformFilter.SetInput(self.Mesh)
transformFilter.SetTransform(transform)
transformFilter.Update()
self.Mesh = transformFilter.GetOutput()
if self.Mesh.GetSource():
self.Mesh.GetSource().UnRegisterAllOutputs()
开发者ID:ChaliZhg,项目名称:vmtk,代码行数:17,代码来源:vmtkmeshscaling.py
示例17: __init__
def __init__( self, desiredPointSize=0.5, maxNumPoints=1e6 ):
self.maxNumPoints = maxNumPoints
self.vtkPolyData = vtk.vtkPolyData()
self.vtkTransformFilter = vtk.vtkTransformFilter()
self.vtkTransform = vtk.vtkTransform()
self.vtkTransformFilter.SetTransform( self.vtkTransform )
self.vtkTransformFilter.SetInput( self.vtkPolyData )
self.clearPoints()
mapper = vtk.vtkPolyDataMapper()
mapper. SetInput( self.vtkTransformFilter.GetOutput() )
mapper.SetColorModeToDefault()
mapper.SetScalarRange( 0.0, 1.0 )
mapper.SetScalarVisibility(1)
self.vtkActor = vtk.vtkActor()
self.vtkActor.SetMapper(mapper)
property = self.vtkActor.GetProperty()
property.SetPointSize(desiredPointSize)
开发者ID:imclab,项目名称:vistrails,代码行数:17,代码来源:VoxelizerModule.py
示例18: __init__
def __init__(self, profile):
"""Clip the STL and set attributes on the SWIG-proxied C++
GeometryGenerator object.
"""
GeometryGenerator.__init__(self)
self._profile = profile
self.generator = Generation.PolyDataGenerator()
self._SetCommonGeneratorProperties()
self.generator.SetSeedPointWorking(
profile.SeedPoint.x / profile.VoxelSize,
profile.SeedPoint.y / profile.VoxelSize,
profile.SeedPoint.z / profile.VoxelSize)
# This will create the pipeline for the clipped surface
clipper = Clipper(profile)
# Scale by the voxel size
trans = vtkTransform()
scale = 1. / profile.VoxelSize
trans.Scale(scale, scale, scale)
transformer = vtkTransformFilter()
transformer.SetTransform(trans)
transformer.SetInputConnection(
clipper.ClippedSurfaceSource.GetOutputPort())
# Uncomment this an insert the output path to debug pipeline construction
# write = StageWriter('/Users/rupert/working/compare/aneurysm').WriteOutput
# i = 0
# for alg in getpipeline(transformer):
# print i
# i += 1
# print alg
# write(alg)
transformer.Update()
self.ClippedSurface = transformer.GetOutput()
self.generator.SetClippedSurface(self.ClippedSurface)
originWorking, nSites = self._ComputeOriginWorking()
self.generator.SetOriginWorking(*(float(x) for x in originWorking))
self.generator.SetSiteCounts(*(int(x) for x in nSites))
self.OriginMetres = Vector(originWorking * self.VoxelSizeMetres)
return
开发者ID:UCL,项目名称:hemelb,代码行数:44,代码来源:OutputGeneration.py
示例19: initialize
def initialize (self, valid_coord):
""" Initializes the seed given an array of valid co-ordinate
directions. [x-axis, y-axis, z_axis] is the format. For
instance if x-axis == 0 then the data is along the YZ plane.
This method is responsible for actually creating the seed. """
debug ("In SeedManager::initialize ()")
assert len (valid_coord) == 3
self.dim = reduce (lambda x, y: x+y, valid_coord)
if self.dim == 3:
self.seed = vtk.vtkPointSource ()
else:
self.seed = vtk.vtkDiskSource ()
self.seed.SetRadialResolution (1)
self.seed.SetInnerRadius (0.0)
self.transform = vtk.vtkTransformFilter ()
self.transform.SetTransform (vtk.vtkTransform ())
self.transform.SetInput (self.seed.GetOutput ())
self.orient_2d (valid_coord)
开发者ID:sldion,项目名称:DNACC,代码行数:19,代码来源:Streamlines.py
示例20: __init__
def __init__(self, body_fixed=True):
self.body_fixed = body_fixed
# vtk objects for creating 3D scene
self.vtkrenderer = vtk.vtkRenderer()
self.vtkrenderer.SetBackground(1, 1, 1)
self.vtkrender_window = vtk.vtkRenderWindow()
self.vtkrender_window.AddRenderer(self.vtkrenderer)
self.vtkrender_window.SetSize(self.window_size)
self.vtkrender_window_interactor = vtk.vtkRenderWindowInteractor()
self.vtkrender_window_interactor.SetRenderWindow(self.vtkrender_window)
self.camera = vtk.vtkCamera()
self.camera.SetPosition([p*self.scale_factor for p in self.camera_pos]);
self.camera.SetFocalPoint(0, 0, 0);
self.camera.SetViewUp(self.camera_up);
self.vtkrenderer.SetActiveCamera(self.camera);
self.vtkvrml_exporter = vtk.vtkVRMLExporter()
# vtk objects for reading, and rendering object parts
self.vtkreader = {}
self.vtkpolydata = {}
self.vtkmapper = {}
self.vtktransform = {}
self.vtkfilter = {}
# read each part from its stl file
for part in self.parts:
self.vtkreader[part] = vtk.vtkSTLReader()
self.vtkreader[part].SetFileName(self.models_folder + part + '.stl')
self.vtktransform[part] = vtk.vtkTransform()
self.vtktransform[part].Scale(self.scale_factor, self.scale_factor, self.scale_factor)
self.vtkfilter[part] = vtk.vtkTransformFilter()
self.vtkfilter[part].SetInput(self.vtkreader[part].GetOutput())
self.vtkfilter[part].SetTransform(self.vtktransform[part])
self.vtkpolydata[part] = self.vtkfilter[part].GetOutput()
self.vtkmapper[part] = vtk.vtkPolyDataMapper()
self.vtkmapper[part].SetInput(self.vtkpolydata[part])
if self.body_fixed:
# actor for body part (every object has a part named body at origin)
self.vtkbodyactor = vtk.vtkActor()
self.vtkbodyactor.SetMapper(self.vtkmapper['Body'])
self.vtkbodyactor.SetPosition(0, 0, 0)
self.graspit_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.graspit_socket.connect((self.graspit_tcp_ip, self.graspit_tcp_port))
开发者ID:gokererdogan,项目名称:ShapeGrammar,代码行数:43,代码来源:haptics_forward_model.py
注:本文中的vtk.vtkTransformFilter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论