pro Fl_Mesh, Flines_Str, Vertex_List, Polygon_List, Radius=Radius, Nvert=Nvert ;+ ; Name: Fl_Mesh ; Purpose: ; Generates a polygon mesh (vertex list and polygon list) ; that represent a set of field lines ; Calling Sequence: ; Fl_Mesh, Flines_Str, Vertex_List, Polygon_List ; Inputs: ; Flines_Str Field line structure varibale with the following tags ; ; Nlines : # of field lines in the set ; Pos : an index array with (Nlines+1) elements ; Data : a 2-D array of 3 x pos(nlines) elements ; the 1st field line : from pos(0) to pos(1)-1 ; the 2nd filed line : from pos(1) to pos(2)-1 ; and so on. ; Outputs: ; ; Vertex_LIst Mesh vertices ; Polygon_List Mesh indices ; ; Keywards: ; ; Radius Minor radius of field lines ; (default = 0.01 times length-scale) ; Example: ; Create a set of two field lines for example. ; ; t=(findgen(200)) ; Data = fltarr(3, 400) ; Data(0,*) = [0.05*cos(2*!pi*t/50.),0.15*sin(2*!pi*t/50.) ] ; Data(1,*) = [0.05*sin(2*!pi*t/50.), 0.15*cos(2*!pi*t/50.)] ; Data(2,*) = [t/200.,t/200.] ; Flines_Str = {nlines:2, pos:[0, 200, 400], Data: Data} ; ; Determine the meshes for the field lines ; ; Fl_Mesh, Flines_Str, Vertex_List, Polygon_List ; ; Display after rotations and translation ; ; t3d, /reset ; t3d, rotate=[0, 20.0, 0.] ; t3d, rotate=[0, 0, 60] ; t3d, translate=[0.25, 0.25, 0.25] ; Vertex_List = vert_t3d(Vertex_List) ; window, 0, xsize=512, ysize=512 ; create_view, winx=512, winy=512 ; set_shading, light=[-0.5, -0.5, 1.0], reject=0 ; a=polyshade(Vertex_List, Polygon_List, /data) ; tvscl, a ; ;- Nlines = Flines_Str.Nlines Pos = Flines_Str.POs Data = Flines_Str.Data if n_elements(nvert) eq 0 then nvert =11 if n_elements(radius) eq 0 then radius = $ 0.01*((max(Data(0,*), min=m)-m)>(max(Data(1,*), min=m)-m) $ > (max(Data(2, *),min=m)-m)) for line=0, Nlines-1 do begin i0 = Pos(line) i1 = Pos(line+1)-1 fline0 = Data(*, i0:i1) npoint=n_elements(fline0(0, *)) fl_geometry, fline0, arc_length, curvature, tangent, normal fline = fline0(*, 1:npoint-2) t = tangent(*, 1:npoint-2) n = normal(*, 1:npoint-2) b = t*0 b(0, *) = t(1,*)*n(2,*)-t(2,*)*n(1,*) b(1,*) = t(2,*)*n(0,*)-t(0,*)*n(2,*) b(2,*) = t(0,*)*n(1,*)-t(1,*)*n(0,*) npoint=npoint-2 vert_num = nvert*npoint vertex = fltarr(3, vert_num, /nozero) vertex(2, *) = 0. vertex(1, *) = radius vertex(0, *) = findgen(nvert)*2*!pi/(float(nvert-1))#replicate(1, npoint) tmp = cv_coord(from_cylin=vertex, /to_rect) for k=0, 2 do $ vertex(k, *) = $ tmp(0,*)*(replicate(1, nvert)#n(k, *)) $ +tmp(1, *)*(replicate(1, nvert)#b(k, *)) $ +tmp(2,*)*(replicate(1, nvert)#t(k, *)) $ +(replicate(1, nvert)#fline(k,*)) indx_num = (nvert-1L)*(npoint-1L) poly_num = 5L*indx_num polygon = lonarr(poly_num, /nozero) y_inc = replicate(1L, (nvert-1L))#lindgen(npoint-1L) p_ind = 5L*lindgen(indx_num) polygon[p_ind]=4L polygon[p_ind+1L]=lindgen(indx_num)+y_inc[*] y_inc=0 polygon[p_ind+2L]=polygon[p_ind+1L]+1L polygon[p_ind+3L]=polygon[p_ind+2L]+nvert polygon[p_ind+4L]=polygon[p_ind+3L]-1L p_ind=0 if line eq 0 then begin Vertex_List = vertex Polygon_List = polygon endif else begin polygon = polygon + n_elements(Vertex_List(0,*)) ss = indgen(n_elements(polygon)/5)*5 polygon(ss)=4 Polygon_List = [Polygon_List, polygon] Vertex_List = [[Vertex_List], [vertex]] endelse endfor end