Mathematical Principles for Scientific Computing and Visualization
http : // www.farinhansford.com/books/scv
by Gerald Farin and Dianne Hansford

This notebook illustrates the types of domains in volume visualization.

This notebook needs fixed up a bit. The conversion from Mathematic 5.2 to 6.0 required a lot of changes -- not all done.

Figures  15.1 was created with this notebook. 

See Chapter 15 : Volume Visualization for details.

Updated May 2008

(* Set the output folder *)
SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];

(* create data for the cell structures *)
lst={{0,0,0},{1,0,0},{2,0,0},{0,1,0},{1,1,0},{2,1,0},{0,2,0},{1,2,0},{2,2,0},{0,0,1},{1,0,1},{2,0,1},{0,1,1},{1,1,1},{2,1,1},{0,2,1},{1,2,1},{2,2,1},{0,0,2},{1,0,2},{2,0,2},{0,1,2},{1,1,2},{2,1,2},{0,2,2},{1,2,2},{2,2,2}};

(* Create a plot of the cells *)
pts=ListPointPlot3D[lst,PlotStyle->Directive[PointSize[0.05`], Black],Axes->False,Boxed->False];

(* Create data for vertices of another domain *)
lstv={{0.5`,0.5`,0.5`},{1.5`,0.5`,0.5`},{0.5`,1.5`,0.5`},{1.5`,1.5`,0.5`},{0.5`,0.5`,1.5`},{1.5`,0.5`,1.5`},{0.5`,1.5`,1.5`},{1.5`,1.5`,1.5`}};

(* Create a plot of the point set making up a cube *)
ptsv=ListPointPlot3D[lstv,PlotStyle->Directive[PointSize[0.05`],GrayLevel[0]], Axes->False,Boxed->False];

(* Create a cube centered at (1/2,1/2,1/2) *)
cubev=Graphics3D[{GrayLevel[0],Opacity[0.0],EdgeForm[Thick], Cuboid[{0.5`,0.5`,0.5`}]}];

(* Create data for an example illustrating scattered data *)
scatter={{0,0,1},{0,0,0},{1,0,0},{0,-1,0},{-1,0,0},{0,0,-1}};

(* Create a plot of the scattered data *)
ptsscatt=ListPointPlot3D[scatter,PlotStyle->Directive[PointSize[0.05`], Black],Axes->False,Boxed->False];



(* Create a plot of the lines connecting the scattered data *)
lines=Graphics3D[{GrayLevel[0],EdgeForm[Thick], Line[{{0,0,1},{0,0,0},{1,0,0},{0,-1,0},{-1,0,0},{0,0,-1},{0,0,0}}]}];

(* Create some special lines *)

l0=Graphics3D[{GrayLevel[0],EdgeForm[Thick],Line[{{0,0,1},{1,0,0}}]}];

l1=Graphics3D[{GrayLevel[0],EdgeForm[Thick],Line[{{0,0,1},{0,-1,0}}]}];

l2=Graphics3D[{GrayLevel[0],EdgeForm[Thick],Line[{{0,0,1},{-1,0,0}}]}];

l3=Graphics3D[{GrayLevel[0],EdgeForm[Thick],Line[{{0,0,0},{0,0,-1}}]}];

l4=Graphics3D[{GrayLevel[0],EdgeForm[Thick],Line[{{0,0,0},{0,-1,0}}]}];

l5=Graphics3D[{GrayLevel[0],EdgeForm[Thick],Line[{{0,0,0},{-1,0,0}}]}];

l6=Graphics3D[{GrayLevel[0],EdgeForm[Thick],Line[{{0,0,-1},{1,0,0}}]}];

l7=Graphics3D[{GrayLevel[0],EdgeForm[Thick],Line[{{0,0,-1},{0,-1,0}}]}];


(* Create a network of cubes -- each with a different color *)

cube000=Graphics3D[{GrayLevel[0.77`],Cuboid[{0,0,0}]}];

cube100=Graphics3D[{GrayLevel[0.69`],Cuboid[{1,0,0}]}];

cube010=Graphics3D[{GrayLevel[0.7`],Cuboid[{0,1,0}]}];

cube110=Graphics3D[{GrayLevel[0.75`],Cuboid[{1,1,0}]}];

cube001=Graphics3D[{GrayLevel[0.65`],Cuboid[{0,0,1}]}];

cube101=Graphics3D[{GrayLevel[0.6`],Cuboid[{1,0,1}]}];

cube011=Graphics3D[{GrayLevel[0.7`],Cuboid[{0,1,1}]}];

cube111=Graphics3D[{GrayLevel[0.55`],Cuboid[{1,1,1}]}];


(* Create another network of cubes *)
(* same as cubes above but in wireframe *)
bcube000=Graphics3D[{GrayLevel[0],Opacity[0.0],EdgeForm[Thick],Cuboid[{0,0,0}]}];
bcube100=Graphics3D[{GrayLevel[0],Opacity[0.0],EdgeForm[Thick],Cuboid[{1,0,0}]}];
bcube010=Graphics3D[{GrayLevel[0],Opacity[0.0],EdgeForm[Thick],Cuboid[{0,1,0}]}];
bcube110=Graphics3D[{GrayLevel[0],Opacity[0.0],EdgeForm[Thick],Cuboid[{1,1,0}]}];
bcube001=Graphics3D[{GrayLevel[0],Opacity[0.0],EdgeForm[Thick],Cuboid[{0,0,1}]}];
bcube101=Graphics3D[{GrayLevel[0],Opacity[0.0],EdgeForm[Thick],Cuboid[{1,0,1}]}];
bcube011=Graphics3D[{GrayLevel[0],Opacity[0.0],EdgeForm[Thick],Cuboid[{0,1,1}]}];
bcube111=Graphics3D[{GrayLevel[0],Opacity[0.0],EdgeForm[Thick],Cuboid[{1,1,1}]}];



(* ----- Create the four pictures --------------- *)
(* Put together the picture elements from above *)


(* Put together cubes  -- each cube is colored one color *)
pic1=Show[cube000,cube100,cube010,cube110,cube001,cube101,cube011,cube111,Boxed->False]

(* Put together the bcubes -- a wireframe structure *)
(* This is a rectilinear grid with values at the vertices *)
pic2=Show[bcube000,bcube100,bcube010,bcube110,bcube001,bcube101,bcube011,bcube111,pts,Boxed->False]

 (* display a cell defined from eight voxels *)
(* bottom left pic *)
pic3=Show[bcube000,bcube100,bcube010,bcube110,bcube001,bcube101,bcube011,bcube111,ptsv,cubev,Boxed->False,ViewPoint->{1.508`,-3.33`,0.927`}]


(* Scattered data example *)
pic4=Show[ptsscatt,lines,l0,l1,l2,l3,l4,l5,l6,l7,ViewPoint->{-0.888`,-4.`,2.047`}]

(* Create the combined picture *)
g=GraphicsGrid[{{pic1,pic2},{pic3,pic4}},Spacings->Scaled[0.25`]];

(* Display it *)
Show[g]

(* Output to a postscript file *)
Export["voldata.eps",%]

(* Here is a subset of the examples above *)
g2=GraphicsGrid[{{pic2,pic4}},Spacings->Scaled[0.25`]];
Show[g2]
Export["meshes3d.eps",%]