PRO writegeometry,f,file,color=color,append=append,vrml=vrml,pointset=pointset ; This procedure writes a geometry file in Inventor 1.0 ASCII format. ; It is an improved version of the procedure by Aake Nordlund. ; Improvements: ; -) default color ; -) the possibility to append ; Bo Milvang-Jensen, 21-May-1996 ; -) the possibility to write VRML instead of Inventor ; Bo Milvang-Jensen, 30-May-1996 ; -) Writes "LineSet", instead of "IndexedLineSet" with trivial index 1,2,3,... ; -) /poinset added, gives "PointSet" instead of "LineSet" ; Bo Milvang-Jensen, 05-Jun-1996 ; An example of the use of this procedure: ; IDL> fff = fltarr(3,100) ; IDL> ggg = fltarr(3,250) ; IDL> ... give fff and ggg some suitable values ... ; IDL> writegeometry, fff, 'output.iv', color=[1.0, 0.0, 0.0] ; red ; IDL> writegeometry, ggg, 'output.iv', color=[0.0, 1.0, 0.0], /append ; green default, color, [1.0, 1.0, 1.0] ; Default color is white (RGB): default, append, 0 ; Default is not to append: default, vrml, 0 ; Default is to write Inventor, not VRML default, pointset, 0 ; Default is to write a "LineSet" openw,1,file,append=append ; Open file for writing, append if wanted: if (vrml ne 1) then begin header = [ $ '#Inventor V1.0 ascii', $ '' $ ] endif else begin header = [ $ '#VRML V1.0 ascii', $ '' $ ] endelse ; If we are not appending, print header: if (append ne 1) then printf,1,header,format='(a)' s1a = [ $ 'Separator {', $ ' MaterialBinding {', $ ' value OVERALL', $ ' }', $ ' Material {', $ ' ambientColor 0.2 0.2 0.2 ~' $ ] printf,1,s1a,format='(a)' printf,1,' diffuseColor ',string(color) s1b = [ $ ' specularColor 0.2 0.2 0.2 ~', $ ' shininess 0 ~', $ ' transparency 0 ~', $ ' }', $ ' Coordinate3 {', $ ' point [' $ ] printf,1,s1b,format='(a)' printf,1,f,form='(3f10.4,1h,)' s2= [ $ ' ]', $ ' }', $ ' LightModel {', $ ' model BASE_COLOR', $ ' }' $ ] printf,1,s2,format='(a)' If (pointset ne 1) then begin s2a= [ $ ' LineSet {' $ ] endif else begin s2a= [ $ ' PointSet {' $ ] endelse printf,1,s2a,format='(a)' s3= [ $ ' }', $ '}' $ ] printf,1,s3,format='(a)' close,1 END