00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <iostream>
00022 #include <cmath>
00023
00024 #include "numerical/meshgrid.h"
00025
00026 #include "vtkwrap/structgrid.h"
00027 #include "vtkwrap/hedgehog.h"
00028 #include "vtkwrap/vtkwin.h"
00029 #include "vtkwrap/sgridoutline.h"
00030 #include "vtkwrap/sgridisosurf.h"
00031 #include "vtkwrap/axes.h"
00032 #include "vtkwrap/colors.h"
00033
00034 using std::cout;
00035 using std::endl;
00036
00037 int main(int argc, char **argv)
00038 {
00039 if (argc!=4)
00040 {
00041 cout << "Usage:\n";
00042 cout << " " << argv[0] << " NP NQ NT\n";
00043 cout << endl;
00044 cout << "ex.: " << argv[0] << " 20 20 20\n";
00045 cout << endl;
00046 return 1;
00047 }
00048
00049 MeshGrid mg(0.0,1.0,atoi(argv[1]), 0.0,1.0,atoi(argv[2]), 0.0,1.0,atoi(argv[3]));
00050
00051
00052 double * F = new double [mg.Length()];
00053 double c[] = {0.5,0.5,0.5};
00054 double r = 0.25;
00055 for (int i=0; i<mg.Length(); ++i)
00056 F[i] = pow(mg.X(i)-c[0],2.0) + pow(mg.Y(i)-c[1],2.0) + pow(mg.Z(i)-c[2],2.0) - r*r;
00057
00058
00059 StructGrid::VectorTuple * V = new StructGrid::VectorTuple [mg.Length()];
00060 for (int i=0; i<mg.Length(); ++i)
00061 {
00062 V[i].vx = mg.X(i);
00063 V[i].vy = mg.Y(i);
00064 V[i].vz = mg.Z(i);
00065 }
00066
00067 StructGrid sg(mg.X(),mg.nX(), mg.Y(),mg.nY(), mg.Z(),mg.nZ(), F, V);
00068 cout << sg << endl;
00069 sg.WriteFile("tmp.structgrid.vtk");
00070
00071 HedgeHog hh(sg.GetGrid());
00072 cout << hh << endl;
00073
00074 SGridOutline sgo(sg.GetGrid());
00075 cout << sgo << endl;
00076
00077 vtkLookupTable * lt = vtkLookupTable::New();
00078 lt->SetNumberOfColors(1);
00079 lt->Build();
00080 lt->SetTableValue(0,CLR["blue"].C);
00081 SGridIsoSurf sgiso(sg.GetGrid(),0.0, lt);
00082
00083
00084
00085 sgiso.GetActor()->GetProperty()->SetOpacity(0.3);
00086 cout << sgiso << endl;
00087
00088 Axes ax(1.2, true);
00089 cout << ax << endl;
00090
00091 VTKWin win;
00092 win.AddActor(hh.GetActor());
00093 win.AddActor(sgo.GetActor());
00094 win.AddActor(sgiso.GetActor());
00095 win.AddActor(ax.GetActor());
00096 win.AddActor(ax.GetXLabelActor());
00097 win.AddActor(ax.GetYLabelActor());
00098 win.AddActor(ax.GetZLabelActor());
00099 win.Show();
00100
00101 delete [] F;
00102 delete [] V;
00103
00104 lt -> Delete();
00105
00106 return 0;
00107 }