vtkwrap_test09.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 
00023 // VTK
00024 #include "vtkPoints.h"
00025 #include "vtkHexahedron.h"
00026 #include "vtkUnstructuredGrid.h"
00027 #include "vtkDataSetMapper.h"
00028 #include "vtkActor.h"
00029 #include "vtkProperty.h"
00030 
00031 // MechSys
00032 #include "vtkwrap/vtkwin.h"
00033 #include "vtkwrap/ugridlabels.h"
00034 #include "vtkwrap/ugridclipper.h"
00035 
00036 using std::cout;
00037 using std::endl;
00038 
00039 int main(int argc, char **argv)
00040 {
00041     // Window
00042     VTKWin win;
00043 
00044     // Points
00045     vtkPoints * pts = vtkPoints::New();
00046     pts -> SetNumberOfPoints (8);
00047     pts -> InsertPoint       (0, 0, 0, 0);
00048     pts -> InsertPoint       (1, 1, 0, 0);
00049     pts -> InsertPoint       (2, 1, 1, 0);
00050     pts -> InsertPoint       (3, 0, 1, 0);
00051     pts -> InsertPoint       (4, 0, 0, 1);
00052     pts -> InsertPoint       (5, 1, 0, 1);
00053     pts -> InsertPoint       (6, 1, 1, 1);
00054     pts -> InsertPoint       (7, 0, 1, 1);
00055 
00056     // A Hexahedron
00057     vtkHexahedron * hex = vtkHexahedron::New();
00058     hex -> GetPointIds() -> SetId(0, 0);
00059     hex -> GetPointIds() -> SetId(1, 1);
00060     hex -> GetPointIds() -> SetId(2, 2);
00061     hex -> GetPointIds() -> SetId(3, 3);
00062     hex -> GetPointIds() -> SetId(4, 4);
00063     hex -> GetPointIds() -> SetId(5, 5);
00064     hex -> GetPointIds() -> SetId(6, 6);
00065     hex -> GetPointIds() -> SetId(7, 7);
00066 
00067     // Unstructured grid
00068     vtkUnstructuredGrid * ugrid  = vtkUnstructuredGrid ::New();
00069     vtkDataSetMapper    * mapper = vtkDataSetMapper    ::New();
00070     vtkActor            * actor  = vtkActor            ::New();
00071     ugrid  -> Allocate       (1, 1);
00072     ugrid  -> InsertNextCell (hex->GetCellType(), hex->GetPointIds());
00073     ugrid  -> SetPoints      (pts);
00074     mapper -> SetInput       (ugrid);
00075     actor  -> SetMapper      (mapper);
00076     actor  -> GetProperty()->SetDiffuseColor(1, 1, 0);
00077 
00078     // UGridClipper
00079     UGridClipper cli(win, ugrid, NULL, 0.5,0.5,0.5, 1,1,1);
00080     cli.AddActorsTo(win);
00081 
00082     // Show
00083     //win.AddActor(actor);
00084     win.Show();
00085 
00086     return 0;
00087 }

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