vtkwrap_test07.cpp

00001 /***********************************************************************************
00002  * VTKwrap - Simple VTK wrappers                                                   *
00003  * Copyright (C) 2005 Dorival de Moraes Pedroso <dorival.pedroso at gmail.com>     *
00004  *                                                                                 *
00005  * This file is part of VTKwrap.                                                   *
00006  *                                                                                 *
00007  * VTKwrap is free software; you can redistribute it and/or modify it under        *
00008  * the  terms of the GNU General Public License as published by the Free Software  *
00009  * Foundation; either version 2 of the License, or (at your option) any later      *
00010  * version.                                                                        *
00011  *                                                                                 *
00012  * VTKwrap is distributed in the hope that it will be useful, but WITHOUT ANY      *
00013  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
00014  * PARTICULAR PURPOSE. See the GNU General Public License for more details.        *
00015  *                                                                                 *
00016  * You should have received a copy of the GNU General Public License along with    *
00017  * VTKwrap; if not, write to the Free Software Foundation, Inc., 51 Franklin       *
00018  * Street, Fifth Floor, Boston, MA 02110-1301, USA                                 *
00019  ***********************************************************************************/
00020 
00021 #include <iostream>
00022 #include <cmath>
00023 #include <vector>
00024 
00025 #include "numerical/meshgrid.h"
00026 
00027 #include "vtkwrap/vtkwin.h"
00028 #include "vtkwrap/sgridoutline.h"
00029 #include "vtkwrap/axes.h"
00030 #include "vtkwrap/colors.h"
00031 #include "vtkwrap/cutclip.h"
00032 #include "vtkwrap/sphere.h"
00033 #include "vtkwrap/cube.h"
00034 #include "vtkwrap/structgrid.h"
00035 #include "vtkwrap/sgridisosurf.h"
00036 
00037 int main(int argc, char **argv)
00038 {
00039     // Window
00040     VTKWin win;
00041 
00042     // Axes
00043     Axes ax(2, true);
00044     win.AddActor(ax.GetActor());
00045 
00046     // Generate grid
00047     const int n_pts = 20;
00048     MeshGrid mg(0,1,n_pts, 0,1,n_pts, 0,1,n_pts);
00049     int Size = mg.Length();
00050 
00051     // Calculate function values
00052     double * F = new double [Size];
00053     for (int i=0; i<Size; ++i)
00054         F[i] = pow(mg.X(i),2.0)+pow(mg.Y(i),2.0)+pow(mg.Z(i),2.0) - 1.0;
00055 
00056     // Create a VTK structured grid
00057     StructGrid sg(mg.X(),n_pts, mg.Y(),n_pts, mg.Z(),n_pts, F);
00058 
00059     // LookupTable of colors
00060     vtkLookupTable * lt = vtkLookupTable::New();
00061     lt->SetNumberOfColors(1);
00062     lt->Build();
00063     lt->SetTableValue(0,CLR["blue"].C);
00064 
00065     // Generate the Yield Surface
00066     SGridIsoSurf sgiso(sg.GetGrid(), /*F*/0.0, lt);
00067     win.AddActor(sgiso.GetActor());
00068 
00069     // Show
00070     win.Show();
00071 
00072     // Clean up
00073     delete [] F;
00074     lt->Delete();
00075 
00076     return 0;
00077 }

Generated on Wed Jan 24 15:56:28 2007 for MechSys by  doxygen 1.4.7