[cig-commits] r6386 - geodyn/3D/MAG/trunk/idl

wei at geodynamics.org wei at geodynamics.org
Fri Mar 23 17:51:34 PDT 2007


Author: wei
Date: 2007-03-23 17:51:33 -0700 (Fri, 23 Mar 2007)
New Revision: 6386

Added:
   geodyn/3D/MAG/trunk/idl/sphere.pro
   geodyn/3D/MAG/trunk/idl/tube.pro
Log:
Add two more idl procedures for volume redering with the field lines

Added: geodyn/3D/MAG/trunk/idl/sphere.pro
===================================================================
--- geodyn/3D/MAG/trunk/idl/sphere.pro	2007-03-24 00:02:43 UTC (rev 6385)
+++ geodyn/3D/MAG/trunk/idl/sphere.pro	2007-03-24 00:51:33 UTC (rev 6386)
@@ -0,0 +1,31 @@
+;PROCEDURE SPHERE
+;A procedure to render a sphere
+
+;set color parameters for iMac
+device,decomposed=0
+loadct,1 ;blue-white color table
+
+; Create an empty, 3D array:
+SPHERE = FLTARR(20, 20, 20)
+
+; Create the spherical dataset:
+FOR X=0,19 DO FOR Y=0,19 DO FOR Z=0,19 DO $
+   SPHERE(X, Y, Z) = SQRT((X-10)2 + (Y-10)2 + (Z-10)2)
+
+   ; Find the vertices and polygons for a density level of 8:
+   SHADE_VOLUME, SPHERE, 8, V, P
+
+   ; Set up an appropriate 3D transformation so we can see the
+   ; sphere. This step is very important:
+   SCALE3, XRANGE=[0,20], YRANGE=[0,20], ZRANGE=[0,20]
+
+   ; Render the image. Note that the T3D keyword has been set so that
+   ; the previously-established 3D transformation is used:
+   image = POLYSHADE(V, P, /T3D)
+
+   ; Display the image:
+   TV, image
+
+   ;end sphere.pro
+   end
+

Added: geodyn/3D/MAG/trunk/idl/tube.pro
===================================================================
--- geodyn/3D/MAG/trunk/idl/tube.pro	2007-03-24 00:02:43 UTC (rev 6385)
+++ geodyn/3D/MAG/trunk/idl/tube.pro	2007-03-24 00:51:33 UTC (rev 6386)
@@ -0,0 +1,62 @@
+
+;PROCEDURE TUBE
+;A procedure to render a tube along a trajectory
+;For a single tube, a monochromatic color table is
+;recommended, such as loadct=0(b&w) or 1(blue-white) 
+
+;set color parameters for iMac
+device,decomposed=0
+loadct,1
+
+
+;DEFINE COORDINATE AND VARIABLE ARRAYS
+x=fltarr(10,10,10)
+y=fltarr(10,10,10)
+z=fltarr(10,10,10)
+vx=fltarr(10,10,10)
+vy=fltarr(10,10,10)
+vz=fltarr(10,10,10)
+
+;SPECIFY COORDINATE GRID
+for k=0,9 do begin
+x(k,*,*)=k & y(*,k,*)=k & z(*,*,k)=k
+endfor
+
+;SPECIFY FIELD VARIABLE - INCOMPRESSIBLE!
+
+;case#1: spiral
+vz=replicate(0.1,10,10,10)
+vx=2.*sin(0.5*x)*cos(0.5*y)
+vy=-2.*cos(0.5*x)*sin(0.5*y)
+
+;LOAD FIELD VARIABLE INTO DATA ARRAYS
+data=fltarr(3,10,10,10)
+data(0,*,*,*)=vx
+data(1,*,*,*)=vy
+data(2,*,*,*)=vz
+
+;SPECIFY THE STARTING POINT FOR THE TRAJECTORY
+seeds=[1.,1.,0] 
+
+;create the trajectory
+particle_trace,data,seeds,verts,conn,normals, $
+	max_stepsize=0.25, max_iterations=500	
+print,'particle trace done'
+
+;define a circular tube around the trajectory
+tubrad=0.1
+pi=3.1416
+xp=fltarr(2,11)
+np=findgen(11)/5 & np(10)=0 
+xp(0,*)=tubrad*cos(np*pi) & xp(1,*)=tubrad*sin(np*pi)
+
+;create the tube
+streamline,verts,conn,normals,outverts,outconn,profile=xp
+print,'streamline done'
+
+;render the tube
+SCALE3,XRANGE=[0,9],YRANGE=[0,9],ZRANGE=[0,9],Ax=15
+set_shading,light=[0,0,1]
+tvscl,polyshade(outverts,outconn,/t3d)
+
+end



More information about the cig-commits mailing list