00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <algorithm>
00023 #include <iostream>
00024
00025
00026 #include "vtkLightKit.h"
00027
00028
00029 #include "numerical/meshgrid.h"
00030 #include "vtkwrap/vtkwin.h"
00031 #include "vtkwrap/axes.h"
00032 #include "vtkwrap/arrow.h"
00033 #include "vtkwrap/cube.h"
00034 #include "vtkwrap/plane.h"
00035 #include "util/string.h"
00036 #include "util/util.h"
00037 #include "util/exception.h"
00038
00039 using Util::Sq3;
00040
00041 int main(int argc, char **argv) try
00042 {
00043
00044 int cam_key = 1;
00045 if (argc>=2) cam_key = atoi(argv[1]);
00046
00047
00048
00049 VTKWin win;
00050 switch (cam_key)
00051 {
00052 case 1: { win.GetCamera()->SetPosition(1,-0.25,0.25); break; }
00053 case 2: { win.GetCamera()->SetPosition(1,-1,0); break; }
00054 case 3: { win.SetViewPIplane(); break; }
00055 }
00056
00057
00058 double L = 10;
00059 double Lmax = 1.3*L;
00060
00061
00062 Axes ax(Lmax,1.5*Lmax,Lmax, "x","y","z", "peacock","black", 0.010,0.002, false);
00063 ax.AddActorsTo(win);
00064
00065
00066 double l = 0.3*L;
00067 double xa = 0.8*L;
00068 double ya = 0.8*L;
00069 Arrow::Geometry geom(0.010*Lmax, 0.020*Lmax, 4.0, 60);
00070 Arrow n (0 , 0 , -l , "blue" , L/2 , L/2 , L+l , &geom);
00071 Arrow a (0 , 0 , l , "red" , xa , ya , L , &geom);
00072 win.AddActor(n.GetActor());
00073 win.AddActor(a.GetActor());
00074
00075
00076 Cube cu1(0.5*L, 0.5*L, 0.5*L, L,L,L, "wheat" ,0.2);
00077 cu1.WireWidth(2).WireColor("black");
00078 win.AddActor(cu1.GetActor());
00079 win.AddActor(cu1.GetWireActor());
00080
00081
00082 char const color[] = "wheat";
00083 double opac = 0.7;
00084 double dx = L/10.0;
00085 Plane pl1(0,0, dx, 0,L, dx, L,0, dx, 0,0,1, color, opac);
00086 Plane pl2(0,0, 2*dx, 0,L, 2*dx, L,0, 2*dx, 0,0,1, color, opac);
00087 Plane pl3(0,0, 3*dx, 0,L, 3*dx, L,0, 3*dx, 0,0,1, color, opac);
00088 Plane pl4(0,0, 4*dx, 0,L, 4*dx, L,0, 4*dx, 0,0,1, color, opac);
00089 Plane pl5(0,0, 5*dx, 0,L, 5*dx, L,0, 5*dx, 0,0,1, color, opac);
00090 Plane pl6(0,0, 6*dx, 0,L, 6*dx, L,0, 6*dx, 0,0,1, color, opac);
00091 Plane pl7(0,0, 7*dx, 0,L, 7*dx, L,0, 7*dx, 0,0,1, color, opac);
00092 Plane pl8(0,0, 8*dx, 0,L, 8*dx, L,0, 8*dx, 0,0,1, color, opac);
00093 Plane pl9(0,0, 9*dx, 0,L, 9*dx, L,0, 9*dx, 0,0,1, color, opac);
00094 Plane pl10(0,0,10*dx, 0,L,10*dx, L,0,10*dx, 0,0,1, color, opac);
00095 win.AddActor( pl1.GetActor());
00096 win.AddActor( pl2.GetActor());
00097 win.AddActor( pl3.GetActor());
00098 win.AddActor( pl4.GetActor());
00099 win.AddActor( pl5.GetActor());
00100 win.AddActor( pl6.GetActor());
00101 win.AddActor( pl7.GetActor());
00102 win.AddActor( pl8.GetActor());
00103 win.AddActor( pl9.GetActor());
00104 win.AddActor(pl10.GetActor());
00105
00106
00107 vtkLightKit * lk = vtkLightKit::New();
00108 lk->SetKeyLightIntensity(1.0);
00109 lk->AddLightsToRenderer(win.GetRen());
00110
00111
00112 win.Show();
00113
00114
00115 win.WritePNG("bedding-planes.png");
00116
00117
00118 lk->Delete();
00119
00120 return 0;
00121 }
00122 catch (Exception * e)
00123 {
00124 e->Cout();
00125 if (e->IsFatal()) {delete e; exit(1);}
00126 delete e;
00127 }
00128 catch (char const * m)
00129 {
00130 std::cout << "Fatal: " << m << std::endl;
00131 exit (1);
00132 }
00133 catch (...)
00134 {
00135 std::cout << "Some exception (...) ocurred\n";
00136 }
00137
00138