Beispiel #1
0
 def setup(self):
     self.res = 32
     self.height = 0.0005
     self.sphere = self.addPart(ObjectBase(vtk.vtkTexturedSphereSource()))
     self.sphere._source.SetThetaResolution(self.res)
     self.sphere._source.SetPhiResolution(self.res)
     self.sphere._actor.GetProperty().SetColor(0.0, 0.0, 0.4)
     self.earth = self.addPart(ObjectBase(vtk.vtkEarthSource()))
     self.earth._source.SetRadius(0.5 + self.height)
     self.earth._source.SetOnRatio(0)
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self,
         module_manager,
         vtk.vtkEarthSource(),
         "Processing.",
         (),
         ("vtkPolyData",),
         replaceDoc=True,
         inputFunctions=None,
         outputFunctions=None,
     )
Beispiel #3
0
tss.SetPhiResolution(9)
earthMapper = vtk.vtkPolyDataMapper()
earthMapper.SetInputConnection(tss.GetOutputPort())
earthActor = vtk.vtkActor()
earthActor.SetMapper(earthMapper)
# load in the texture map
#
atext = vtk.vtkTexture()
pnmReader = vtk.vtkPNMReader()
pnmReader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/earth.ppm")
atext.SetInputConnection(pnmReader.GetOutputPort())
atext.InterpolateOn()
earthActor.SetTexture(atext)
# create a earth source and actor
#
es = vtk.vtkEarthSource()
es.SetRadius(0.501)
es.SetOnRatio(2)
earth2Mapper = vtk.vtkPolyDataMapper()
earth2Mapper.SetInputConnection(es.GetOutputPort())
earth2Actor = vtk.vtkActor()
earth2Actor.SetMapper(earth2Mapper)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(earthActor)
ren1.AddActor(earth2Actor)
ren1.SetBackground(0,0,0.1)
renWin.SetSize(300,300)
# render the image
#
ren1.ResetCamera()
Beispiel #4
0
tss.SetPhiResolution(9)
earthMapper = vtk.vtkPolyDataMapper()
earthMapper.SetInputConnection(tss.GetOutputPort())
earthActor = vtk.vtkActor()
earthActor.SetMapper(earthMapper)
# load in the texture map
#
atext = vtk.vtkTexture()
pnmReader = vtk.vtkPNMReader()
pnmReader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/earth.ppm")
atext.SetInputConnection(pnmReader.GetOutputPort())
atext.InterpolateOn()
earthActor.SetTexture(atext)
# create a earth source and actor
#
es = vtk.vtkEarthSource()
es.SetRadius(0.501)
es.SetOnRatio(2)
earth2Mapper = vtk.vtkPolyDataMapper()
earth2Mapper.SetInputConnection(es.GetOutputPort())
earth2Actor = vtk.vtkActor()
earth2Actor.SetMapper(earth2Mapper)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(earthActor)
ren1.AddActor(earth2Actor)
ren1.SetBackground(0, 0, 0.1)
renWin.SetSize(300, 300)
# render the image
#
ren1.ResetCamera()
Beispiel #5
0
	def makeEarthActors(self, earth_radius):
		"""
		generate the earth sphere, and the landmass outline

		Parameters
		----------
		earth_radius : int
			radius of the Earth in meters

		"""

		self.earthRadius = earth_radius

		# Create earth map
		# a point cloud that outlines all the earths landmass
		self.earthSource = vtk.vtkEarthSource()
		# draws as an outline of landmass, rather than fill it in
		self.earthSource.OutlineOn()

		# want this to be slightly larger than the sphere it sits on
		# so that it is not occluded by the sphere
		self.earthSource.SetRadius(self.earthRadius * 1.001)

		# controles the resolution of surface data (1 = full resolution)
		self.earthSource.SetOnRatio(1)

		# Create a mapper
		self.earthMapper = vtk.vtkPolyDataMapper()
		self.earthMapper.SetInputConnection(self.earthSource.GetOutputPort())

		# Create an actor
		self.earthActor = vtk.vtkActor()
		self.earthActor.SetMapper(self.earthMapper)

		# set color
		self.earthActor.GetProperty().SetColor(LANDMASS_OUTLINE_COLOR)
		self.earthActor.GetProperty().SetOpacity(EARTH_LAND_OPACITY)

		# make sphere data
		num_pts = EARTH_SPHERE_POINTS
		indices = np.arange(0, num_pts, dtype=float) + 0.5
		phi = np.arccos(1 - 2 * indices / num_pts)
		theta = np.pi * (1 + 5 ** 0.5) * indices
		x = np.cos(theta) * np.sin(phi) * self.earthRadius
		y = np.sin(theta) * np.sin(phi) * self.earthRadius
		z = np.cos(phi) * self.earthRadius

		# x,y,z is coordination of evenly distributed sphere
		# I will try to make poly data use this x,y,z
		points = vtk.vtkPoints()
		for i in range(len(x)):
			points.InsertNextPoint(x[i], y[i], z[i])

		poly = vtk.vtkPolyData()
		poly.SetPoints(points)

		# To create surface of a sphere we need to use Delaunay triangulation
		d3D = vtk.vtkDelaunay3D()
		d3D.SetInputData(poly)  # This generates a 3D mesh

		# We need to extract the surface from the 3D mesh
		dss = vtk.vtkDataSetSurfaceFilter()
		dss.SetInputConnection(d3D.GetOutputPort())
		dss.Update()

		# Now we have our final polydata
		spherePoly = dss.GetOutput()

		# Create a mapper
		sphereMapper = vtk.vtkPolyDataMapper()
		sphereMapper.SetInputData(spherePoly)

		# Create an actor
		self.sphereActor = vtk.vtkActor()
		self.sphereActor.SetMapper(sphereMapper)

		# set color
		self.sphereActor.GetProperty().SetColor(EARTH_BASE_COLOR)
		self.sphereActor.GetProperty().SetOpacity(EARTH_OPACITY)
Beispiel #6
0
nlines = 40

def spherePointsFromLatLons(lats, lons, radius=1.0):
	xyz = numpy.zeros((len(lats), 3), numpy.float64)
	xyz[:, 0] = radius * numpy.cos(lats * numpy.pi/180.) * numpy.cos(lons * numpy.pi/180.)
	xyz[:, 1] = radius * numpy.cos(lats * numpy.pi/180.) * numpy.sin(lons * numpy.pi/180.)
	xyz[:, 2] = radius * numpy.sin(lats * numpy.pi/180.)
	return xyz

# create nlines coordinate curves
pipeline = {'stuff': [],
            'actors': []}

# earth
earth = vtk.vtkEarthSource()
earth.SetRadius(0.99)
earth.OutlineOn()
tubes = vtk.vtkTubeFilter()
tubes.SetInputConnection(earth.GetOutputPort())
tubes.SetRadius(0.01)
tubes.SetNumberOfSides(5)
emapper = vtk.vtkPolyDataMapper()
emapper.SetInputConnection(tubes.GetOutputPort())
eactor = vtk.vtkActor()
eactor.GetProperty().SetColor(0.1, 0.1, 0.1)
eactor.SetMapper(emapper)

sphere = vtk.vtkSphereSource()
sphere.SetRadius(0.98)
sphere.SetThetaResolution(257)