[vtkusers] Stereograpic sphere

Meehan, Bernard MEEHANBT at nv.doe.gov
Tue Jan 13 18:15:12 EST 2015


If you just wanted to display the Wulff net, this code would do it:


#!/usr/bin/env python

# This example creates a simple stereographic projection of a portion of a

# sphere. I have taken a lot of the code from the "ExpCos.py" demo program on

# the GitHub site:

# https://github.com/Kitware/VTK/blob/master/Examples/Modelling/Python/expCos.py


import sys, vtk

from math import *


#------------------------------------------------------------------------------#

#                set up a plane in the center of the view area                 #

#------------------------------------------------------------------------------#

plane = vtk.vtkPlaneSource()

plane.SetXResolution(20)

plane.SetYResolution(20)

plane.SetCenter(0., -0.5, 0.)


transform = vtk.vtkTransform()

transform.Scale(pi, pi, 1)


scale_transform = vtk.vtkTransformPolyDataFilter()

scale_transform.SetInputConnection(plane.GetOutputPort())

scale_transform.SetTransform(transform)

scale_transform.Update()


# Perform the stereographic projection directly on the points in the plane

# above. This assumes that the x coordinate is the azimuthal angle, and is in

# the range (-pi, pi), and that the y coordinate is the altitude angle, in the

# range (-pi/2, pi/2).

input_pd  = scale_transform.GetOutputDataObject(0)

stereo_pd = vtk.vtkPolyData()

stereo_pd.CopyStructure(input_pd)


new_points = vtk.vtkPoints()

for i in range(input_pd.GetNumberOfPoints()):

  location   = input_pd.GetPoint(i)

  phi, theta = location[:2]


  x = sin(phi)*sin(theta)/(1 - cos(phi)*sin(theta))

  y = cos(theta)/(1 - cos(phi)*sin(theta))

  new_points.InsertPoint(i, x, y, 0.)


stereo_pd.SetPoints(new_points)


stereo_edges = vtk.vtkExtractEdges()

stereo_edges.SetInputData(stereo_pd)


stereo_edge_mapper = vtk.vtkPolyDataMapper()

stereo_edge_mapper.SetInputConnection(stereo_edges.GetOutputPort())


stereo_map_mapper = vtk.vtkPolyDataMapper()

stereo_map_mapper.SetInputData(stereo_pd)


stereo_map_actor = vtk.vtkActor()

stereo_map_actor.SetMapper(stereo_map_mapper)

stereo_map_actor.GetProperty().SetColor(0.9020, 0.6627, 1.0000)

stereo_map_actor.GetProperty().SetOpacity(0.4)


stereo_edge_actor = vtk.vtkActor()

stereo_edge_actor.SetMapper(stereo_edge_mapper)

stereo_edge_actor.GetProperty().SetColor(0.1882, 0.1294, 1.0000)


#------------------------------------------------------------------------------#

#                               rendering stuff                                #

#------------------------------------------------------------------------------#

ren = vtk.vtkRenderer()

ren.AddActor(stereo_map_actor)

ren.AddActor(stereo_edge_actor)


renWin = vtk.vtkRenderWindow()

renWin.AddRenderer(ren)

renWin.SetSize(500, 500)


iren = vtk.vtkRenderWindowInteractor()

iren.SetRenderWindow(renWin)


ren.ResetCamera()

iren.Initialize()

renWin.Render()

iren.Start()

From: Luis Vieira <luis.vieira at vektore.com<mailto:luis.vieira at vektore.com>>
Date: Tuesday, January 13, 2015 at 8:12 AM
To: "vtkusers at vtk.org<mailto:vtkusers at vtk.org>" <vtkusers at vtk.org<mailto:vtkusers at vtk.org>>
Subject: [vtkusers] Stereograpic sphere

Dear VTKers,

 I am beginner in VTK and I am struggling to plot a Stereonet graph. I have been trying vtkPolydata , vtkPoints, vtkParametricSpline and vtkParametricFunctionSource. I have tried vtkCharXY. However I have no success. Any ideas to suggest where I could start and which vtk classes will help me to develop a semi-sphere?

Thank you so much.

[cid:part1.00090300.03070201 at vektore.com][cid:part2.01000209.04080907 at vektore.com]
[cid:part3.00060700.04090401 at vektore.com][cid:part4.00080402.03030802 at vektore.com]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150113/1b7fcc0c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ATT00001.png
Type: image/png
Size: 10036 bytes
Desc: ATT00001.png
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150113/1b7fcc0c/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ATT00002.png
Type: image/png
Size: 10252 bytes
Desc: ATT00002.png
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150113/1b7fcc0c/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hfggjfca.png
Type: image/png
Size: 14514 bytes
Desc: hfggjfca.png
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150113/1b7fcc0c/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: idfdibda.png
Type: image/png
Size: 97134 bytes
Desc: idfdibda.png
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150113/1b7fcc0c/attachment-0003.png>


More information about the vtkusers mailing list