go to www.geomview.org home page
 
Home

Overview
FAQ
Documentation

Download

Mailing List

Geomview For Windows?

Support
Users
Development

Bug Reporting
Contributing
Contact Us

Sponsors

 

Site Search

 

Advanced
Search

 
About the software@geom archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Closed REQ 5868]: required software


  • To: software@geom.umn.edu
  • Subject: Re: [Closed REQ 5868]: required software
  • From: daemon
  • Date: Wed, 5 Jun 1996 10:49:17 -0500 (CDT)


> graphics objects but I am unable to do so  since neither me nor my 
> institution have the mathematica packages
> OOGL.M and GEOMVIEW.M 
> that you suggest in Ch. 9  of the manual. Is it possible to send me a 
> copy of both of them or inform where I could get them? 

These files are a part of the Geomview distribution; they were
supposed to come with the copy of Geomview that you have (in the
Geomview/mathematica directory).  In case they got lost, I've
included copies of them below, along with a third file that
they sometimes use, called BezierPlot.m.

Mark Phillips
Geometry Center



---  Geomview.m -------------------------------------------------
(*
 * Geomview.m selects Geomview graphics as the default for Show
 * of 3D graphics objects.  Others still use the default system.
 * To restore normality, load <<GL.m or <<X11.m or etc.
 *)

Needs["OOGL`"];

ClearAll[$DisplayFunction];

$DisplayFunction[g_Graphics3D] := Geomview[g];
$DisplayFunction[g_SurfaceGraphics] := Geomview[g];
$DisplayFunction[g_] := Display[$Display, g];

If[ !MemberQ[$CommandLine, "-noprompt"],
   ( Print[" -- Geomview graphics initialized -- "];
     If[(DisplayHost /. Options[Geomview]) != "",
	Print["Geomview.m: graphics will display remotely on ",
		DisplayHost /. Options[Geomview]];
	Print["To change this, see DisplayHost in Options[Geomview]."]
      ]
   )
  ];

---  end of Geomview.m ------------------------------------------

---  OOGL.m -----------------------------------------------------
(* $Header: /usrb/gcg/ngrap/src/bin/geomutil/math2oogl/RCS/OOGL.m,v 1.13 1994/11/17 22:39:29 mbp Exp $ *)

BeginPackage["OOGL`"]

(*

If you want to be able to use this package from a directory other
than the geomview distribution directory, or if you want to be able to
run it from a remote host, then
EITHER
   ensure that the programs
	"geomview", "math2oogl", "togeomview", and "oogl2rib"
   are in your search path (e.g. copy them to /usr/local/bin),

OR

  - Change the value of $GeomviewPath below to be the absolute pathname
	of the "geomview" shell script on your system and
  - Change the value of $GeomRoot below to be the absolute pathname
	of the geomview distribution directory on your system.

The first alternative is preferred when possible.
*)

(* $GeomviewPath = "/usr/local/bin/geomview"; *)
(* $GeomRoot = "/u/gcg/ngrap"; *)
$GeomviewPath = "geomview";
$GeomRoot = ".";

(* DO NOT CHANGE ANYTHING BELOW HERE *)


(*******************************************************************)

(* Copyright (c) 1993 The Geometry Center; University of Minnesota
   1300 South Second Street Suite 500;  Minneapolis, MN  55454, USA;
   
This is file OOGL.m.  OOGL.m is free software.  You can redistribute
it and/or modify it only under the terms given in the file COPYING,
which you should have received along with this file.  this and other
related software may be obtained via anonymous ftp from geom.umn.edu;
email: software@geom.umn.edu. *)


(* Authors: Nils McCarthy (nils at geom.umn.edu) 
	    Stuart Levy (slevy at geom.umn.edu)
	    Tamara Munzner (munzner at geom.umn.edu) 
	    Silvio Levy (levy at geom.umn.edu)
*)


(* To use this, you also need to install the math2oogl and oogl2rib C programs.
   They actually do the grunt work, as Mathematica is too slow
   to do it in any reasonable amount of time. *)

WriteOOGL::usage = "
WriteOOGL[filename,-Graphics3D or SurfaceGraphics-] writes the given
graphics object or list of graphics objects to filename.  Graphics3D
objects are converted to OOGL OFF format, SurfaceGraphics objects are
converted to OOGL MESH format. WriteOOGL understands only Polygon,
Line, and RGBColor Graphics3D directives.  If WriteOOGL encounters any
errors in the Graphics3D object, it silently tries to cope. Depends on
the C program math2oogl.";

Geomview::usage= "
Geomview [-Graphics3D or SurfaceGraphics-]\n 
Geomview [\"name\", -Graphics3D or SurfaceGraphics-] writes the given
graphics object or list of graphics objects to geomview, starting a
copy of geomview if necessary.  Graphics3D objects are converted to
OOGL OFF format, SurfaceGraphics objects are converted to OOGL MESH
format.  Polygons, Lines, Points, and RGBColor Graphics3D directives
are understood.  Geomview[\"name\", ...]  creates geomview object with
that name; default is \"Mathematica\".  Depends on the C program
math2oogl.";

WriteRIB::usage= "
WriteRIB [filename,-Graphics3D or SurfaceGraphics-]\n 
WriteRIB [filename,-Graphics3D or SurfaceGraphics-, \"options\"]]
writes the given graphics object or list of graphics objects as
RenderMan .rib files. It actually converts the Mathematica graphics
object to the OOGL data format, and then converts the OOGL files to
rib format.  Graphics3D objects become lists of Polygons, and
SurfaceGraphics objects become PatchMeshes. Polygons, Lines, Points,
and RGBColor Graphics3D directives are understood. Depends on the C
programs math2oogl and oogl2rib. WriteRIB[ ..., \"options\"] appends
the given text string to the invocation of oogl2rib.";

WriteChunk::usage= "

WriteChunk [filename,-Graphics3D or SurfaceGraphics-] is only for use
on machines that cannot start up a remote Unix shell on a machine that
has math2oogl, oogl2rib, and/or geomview installed (i.e. Macs, PCs).
It writes the Mathematica graphics object to a file in a format
accepted by shell scripts which should be run on a machine (Iris or
Next) that has the relevant programs installed. The shell scripts
\"writeoogl\",\"writegv\", and \"writerib\" correspond to WriteOOGL,
Geomview, and WriteRIB respectively: see their usage messages.";

DisplayHost::usage= "Option to Geomview[] specifying display hostname
for geomview.  Automatically set to REMOTEHOST or DISPLAY shell
variable if found.  Setting DisplayHost to \"local\" overrides this behavior.\n
To specify a different user name on the remote computer, use\n
    SetOptions[Geomview, DisplayHost -> \"user at host\" ];";

GeomviewCommand::usage =
"Option to Geomview[] specifying the command used to start geomview if\n
it is not already running.   May include geomview command-line options.";

MachType::usage= "Option to Geomview[] specifying machine type of
DisplayHost.  Should be either \"sgi\" or \"next\".  The default value
is set by Mathematica to be the same as the type of machine on which
Mathematica is running.";

(*Geomview /: Options[Geomview] := { DisplayHost -> "" };*)

MeshGraphics::usage = "\n
Head for mesh graphics object."

Options[Geomview] ^= {DisplayHost->"",
		      MachType->If [$System == "NeXT", "next",
			        If [$System == "SPARC", "sun4",
				   "sgi"] ],
		      XDisplay -> ":0",
		      GeomviewCommand -> $GeomviewPath};

Begin["`Private`"]

(* Use StringJoin not <> for backward compatibility *)

WriteChunk[filename_String, gobj_List] := (
  Map[ WriteChunk[filename,#] &, gobj]; 				   
);

WriteChunk[filename_String, gobj_Graphics3D] := (
  Write[filename, CForm[gobj[[0]]]];
  Write[filename, CForm[N[gobj[[1]]]]];
);

GoodHeadQ[gobj_] := (SameQ[gobj[[0]],SurfaceGraphics] ||
     SameQ[gobj[[0]],MeshGraphics] || SameQ[gobj[[0]],BezierPlot`BezierPatch]
	|| SameQ[gobj[[0]],BezierPatch])

WriteChunk[filename_String, gobj_?GoodHeadQ] := (
  Write[filename, CForm[gobj[[0]]]];
  WriteString[filename, "Dimensions\n"];
  Write[filename, Take[Dimensions[gobj[[1]]],2]];
  If[SameQ[gobj[[0]],SurfaceGraphics],
    WriteString[filename, "MeshRange\n"];
    Write[filename, MeshRange /. gobj[[-1]]]] ;
  (* write out the colors before the points, if they exist *)
  (* Backwards compatibility with v1.2: Dimensions[gobj] returns empty list *)
  If [$VersionNumber >= 2.0,
    If [Dimensions[gobj][[1]] > 2, Write[filename, CForm[gobj[[2]]]]],
    If [Dimensions[Dimensions[gobj[[2]]]][[1]] > 1, 
       Write[filename, CForm[gobj[[2]]]]]];
  Write[filename, CForm[N[gobj[[1]]]]];
);

If[$VersionNumber < 2.0, (
    StringTake[str_, take_] := Apply[StringJoin, Take[Characters[str], take]];
    StringPosition[str_, ch_] := Block[{chars = Characters[str]},
	Select[ Table[{i,i}, {i,1,StringLength[str]}], 
		(chars[[ #[[1]] ]] == ch)&] ];
    $Failed = Fail;
  )];

BinPrefix[mach_] := StringJoin[ $GeomRoot, "/bin/", mach ];
BinShPrefix[mach_] := StringJoin[ "PATH=$PATH:", BinPrefix[mach], " " ];

WriteOut[filename_String, gobj_, postpend_String:"", prepend_String:"",
         options___] :=(
  (* math2oogl expects '{}(), ' to be translated into newlines *)
  tr = "tr -s '{}(), ' '\\12\\12\\12\\12\\12\\12' | ";	
  (* Do the right thing if we've got a command instead of a file name. *)
  tmpfilename =
	If[StringMatchQ[filename, "!*"],
	    StringJoin[" | ",StringDrop[filename,1]],
	  If[filename != "",
	    StringJoin[" > ", filename],
	    filename]];
  newfilename =
    StringJoin["!",tr,prepend," ",
	       BinShPrefix[ MachType /. {options} /. Options[Geomview]],
	       "math2oogl ",postpend, tmpfilename];
  (* We might prepend 'rsh hostname' to the command, which must then be
   * quoted so that what comes after the pipes gets interpreted on
   * the remote not the local machine. The open quote is already in the
   * middle of the prepended string.
   * If we did prepend 'rsh hostname', also add a command to be executed in
   * case the rsh failed, to avoid e.g. mysterious "permission denied" errors.
   * StringMatchQ[prepend,"rsh*"] fails mysteriously in Math 1.2.
   *)
  If[StringLength[prepend]>3 && StringTake[prepend,3] == "rsh",
	newfilename = StringJoin[newfilename,
"'\\' || (echo Geomview graphics: Cannot rsh to machine ", rshhost, " as ",
		If[rshuser != "", StringJoin["user ", rshuser], "yourself"],
".; echo Check DisplayHost option, or your .rhosts file on ", rshhost, ".)"]];
  OpenWrite[newfilename];	
  WriteChunk[newfilename, gobj];
  Close[newfilename];	

);

WriteOOGL[filename_String,gobj_] :=(
   WriteOut[filename, gobj];
   gobj
);

WriteRIB[filename_String,gobj_, riboptions_String:"", options___] :=(
   WriteOut[filename,gobj, 
      StringJoin[" | oogl2rib -n mma.tiff ",riboptions]];
   gobj
);

(*
 * If the given filename is on the $PATH, returns the directory it's in,
 * else returns Null.  Used for load-time warning messages.
 *)
OnPathQ[filename_] :=
    Block[{pdir, i, posen, path = StringJoin[":",Environment["PATH"],":"] },
     (
	posen = StringPosition[path, ":"];
	Do[
	  (pdir = StringTake[path, {posen[[i]][[2]]+1, posen[[i+1]][[1]]-1}];
	   If[FileType[StringJoin[pdir,"/",filename]] === File,
	        Return[pdir]]),
	 {i, 1, Length[posen]-1}
	]
     )];
    


xhost[display_] := StringTake[display,
   StringPosition[StringJoin[display,":"], ":"] [[1]] [[1]]-1];

remotehost[host_String] := (
  newhost="";
  If[host != "",
    newhost = If[host == "local", "", host],
    (
      If[(rshhost = Environment["REMOTEHOST"]) =!= $Failed
	 || (rshhost = Environment["DISPLAY"]) =!= $Failed,
	  newhost = xhost[rshhost];
      ]
  )];
  If[newhost == $MachineName, newhost = ""];
  If[newhost != "" && Length[StringPosition[newhost, "@"]] == 0 &&
      ((ruser = Environment["REMOTEUSER"]) =!= $Failed
       || (ruser = Environment["USER"]) =!= $Failed
       || (ruser = Environment["LOGNAME"]) =!= $Failed),
    newhost = StringJoin[ruser, "@", newhost]];
  newhost
 );

toGV[host_, xdisplay_] :=(
  newhost = remotehost[host];

  {rshuser, rshhost} =
    If[Length[atposn = StringPosition[newhost, "@"]] > 0,
     {StringTake[newhost, {1,atposn[[1]][[1]]-1}],
	StringTake[newhost, {atposn[[1]][[2]]+1,StringLength[newhost]}]},
     {"", newhost}];

  (* Return our rsh command if any, else the empty string. *)
  If[newhost != "",
     StringJoin["rsh ", rshhost, 
		If[StringLength[rshuser] > 0, " -l ", ""], rshuser,
		" /bin/sh -c \\''DISPLAY=", xdisplay, "; export DISPLAY; "],
     ""
  ]
);

Geomview[ name_String, gobj_, options___] := (
   WriteOut["", gobj, StringJoin[" -togeomview ",name," ",
	GeomviewCommand /. {options} /. Options[Geomview]], 
         toGV[DisplayHost /. {options} /. Options[Geomview],
	      XDisplay /. {options} /. Options[Geomview]],
      options];
   gobj
);

Geomview[ gobj_, options___] := (
  Geomview[ "Mathematica", gobj, options ]; gobj
);

bpref = BinPrefix[MachType /. Options[Geomview]];

If[Not[StringQ[OnPathQ["math2oogl"]]],
  (Print["Warning: the program 'math2oogl' is not on your search path,\n",
	Environment["PATH"], "\n"];
   If[ FileType[StringJoin[bpref, "/math2oogl"]]===File,
      Print["using default path (in OOGL.m) of ", bpref, " instead."],
	Print[
"the Mathematica->geomview graphics package won't be able to work;\n
change the value of $Geomroot in OOGL.m, or ensure that the math2oogl programs\n
are installed somewhere on your search path."]
    ])
];

End[]
EndPackage[]

SetOptions[Geomview, DisplayHost -> OOGL`Private`remotehost[""] ];
---  end of OOGL.m ----------------------------------------------

---  BezierPlot.m -----------------------------------------------
(* Author: Silvio Levy *)

BeginPackage["BezierPlot`"]

BezierPatch::usage = "\n
  BezierPatch[ 4 by 4 array ] describes a bicubic Bezier patch\n
  to be plotted using OOGL.m, for example.  The elements of the\n
  array are usually 3D vectors, but the function doesn't care."

BezierPlot::usage = "\n
  BezierPlot[f,{t,tmin,tmax},{u,umin,umax}] \"plots\" the function f\n
  of two variables t and u, using Bezier patches.  (Usually f returns\n
  a 3D vector.)  BezierPlot returns an array of BezierPatch'es.\n
  Options:\n
    Epsilon is the increment used to compute derivatives (default: 10^-4)\n
    PlotPoints is a number or pair of numbers indicating the fineness\n
      of the subdivision (default: 5)";

BezierPlot::baditer = "bad iterator";

Options[BezierPlot] = {Epsilon -> .0001, PlotPoints->5}
  
Begin["`private`"]

BezierPlot[f_,{t_,tmin_,tmax_},{u_,umin_,umax_},options___]:=
Block[{it,iu,nt,nu,dt,du,loc,dfdt,dfdt0,dfdu,dfdu0,dboth,all,
      plotPoints=PlotPoints/.{options}/.Options[BezierPlot],
      eps=Epsilon/.{options}/.Options[BezierPlot]},
  If[Length[plotPoints]==2,{nt,nu}=plotPoints,nt=plotPoints;nu=plotPoints];
  If[nx<1 || ny<1,Message[BezierPlot::badpp];Return[{}]];
  dt=N[(tmax-tmin)/nt]; du=N[(umax-umin)/nu];
  If[!(NumberQ[dt]&&dt>0&&NumberQ[du]&&du>0),
    Message[BezierPlot::baditer];Return[{}]];
  loc=Table[f/.{t->tmin+dt it,u->umin+du iu},{iu,0,nu},{it,0,nt}];
  dfdt0=-loc+Table[f/.{t->tmin+dt(it+If[it<nt,1,-1]eps),u->umin+du iu},
                   {iu,0,nu},{it,0,nt}];
  dfdt=MapAt[-1#&,#,-1]& /@ dfdt0/(3 eps);
  dfdu0=-loc+Table[f/.{t->tmin+dt it,u->umin+du(iu+If[iu<nu,1,-1]eps)},
                   {iu,0,nu},{it,0,nt}];
  dfdu=MapAt[-1#&,#,-1]& @ dfdu0/(3 eps);
  dboth=MapAt[-1#&,#,-1]& /@ MapAt[-1#&,#,-1]& @ 
        (-loc-dfdt0-dfdu0+Table[f/.{t->tmin+dt(it+If[it<nt,1,-1]eps),
                                     u->umin+du(iu+If[iu<nu,1,-1]eps)}, 
                                {iu,0,nu},{it,0,nt}])/(9 eps^2);
  all=Transpose[{loc,dfdt,dfdu,dboth},{3,1,2}]//N;
  Map[
  BezierPatch[
  {{#[[1,1]],#[[1,1]]+#[[1,2]],#[[2,1]]-#[[2,2]],#[[2,1]]},
  {#[[1,1]]+#[[1,3]],#[[1,1]]+#[[1,2]]+#[[1,3]]+#[[1,4]],
    #[[2,1]]-#[[2,2]]+#[[2,3]]-#[[2,4]],#[[2,1]]+#[[2,3]]},
  {#[[3,1]]-#[[3,3]],#[[3,1]]+#[[3,2]]-#[[3,3]]-#[[3,4]],
   #[[4,1]]-#[[4,3]]-#[[4,2]]+#[[4,4]], #[[4,1]]-#[[4,3]]},
  {#[[3,1]],#[[3,1]]+#[[3,2]],#[[4,1]]-#[[4,2]],#[[4,1]]}}]&,
    Transpose[{Drop[#,-1]&/@ Drop[#,-1]& @ all, Rest/@Drop[#,-1]& @ all,
                    Drop[#,-1]&/@ Rest @ all, Rest/@Rest @ all}, {3,1,2}],{2}]
]

Format[x_BezierPatch]:="-BezierPatch-"

End[]
EndPackage[]
---  end of BezierPlot.m ----------------------------------------


 
Home | Overview | FAQ | Documentation | Support | Download | Mailing List
Windows? | Development | Bug Reporting | Contributing | Contact Us | Sponsors
 
site hosted by
SourceForge Logo