[vtkusers] re: Try again - merging
Jared Cohen
Jared.Cohen at noaa.gov
Thu Aug 19 13:47:51 EDT 2004
>
>
>Jared,
>
> Your code seems easy to reproduce. Is it possible you send us a
>cxx/tcl/python code to reproduce this ?
>
>Thanks
>Mathieu
>
Sure thing, here you go (it's in Python)
import Numeric as N
import sys
from vtk import *
deg2rad = N.pi / 180.0
radius = 1.0
th_min, th_max = 0.0, 360.0 * deg2rad
ph_min, ph_max = 0.0, 180.0 * deg2rad
#create the plane
plane = vtkPlaneSource()
plane.SetOrigin(radius, ph_max, th_min)
plane.SetPoint1(radius, ph_max, th_max)
plane.SetPoint2(radius, ph_min, th_min)
plane.SetXResolution(36)
plane.SetYResolution(18)
plane.Update()
#warp it into a sphere
transform = vtkSphericalTransform()
transform.Update()
tpoly = vtkTransformPolyDataFilter()
tpoly.SetInput(plane.GetOutput())
tpoly.SetTransform(transform)
tpoly.Update()
#merge coincident points -- this is what causes
#the distortion
clean = vtkCleanPolyData()
clean.SetInput(tpoly.GetOutput())
clean.PointMergingOn()
clean.SetTolerance(0.000001)
#setup standard VTK pipeline
mapper = vtkPolyDataMapper()
mapper.SetInput(clean.GetOutput())
mapper.ImmediateModeRenderingOn()
mapper.Update()
actor = vtkActor()
actor.SetMapper(mapper)
actor.PickableOn()
actor.GetProperty().BackfaceCullingOn()
reader = vtkPNMReader()
reader.SetFileName("../../wrap/earth.ppm")
texture = vtkTexture()
texture.SetInput(reader.GetOutput())
texture.InterpolateOn()
actor.SetTexture(texture)
ren = vtkRenderer()
ren.AddActor(actor)
win = vtkRenderWindow()
win.AddRenderer(ren)
win.SetSize(500, 500)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(win)
style = vtkInteractorStyleTrackballCamera()
iren.SetInteractorStyle(style)
iren.Initialize()
win.Render()
iren.Start()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040819/674dec66/attachment.htm>
More information about the vtkusers
mailing list