sgridisosurf.h

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 #ifndef VTKWRAP_SGRIDISOSURF_H
00022 #define VTKWRAP_SGRIDISOSURF_H
00023 
00024 #include "vtkStructuredGrid.h"
00025 #include "vtkMarchingContourFilter.h"
00026 #include "vtkPolyDataMapper.h"
00027 #include "vtkActor.h"
00028 #include "vtkProperty.h"
00029 #include "vtkLookupTable.h"
00030 
00031 class SGridIsoSurf
00032 {
00033     friend std::ostream & operator<< (std::ostream & os, SGridIsoSurf const & sgiso);
00034 public:
00035     SGridIsoSurf(vtkStructuredGrid * SGrid, double f, vtkLookupTable * lt=NULL) // F==level value
00036     {
00037         _isosurf        = vtkMarchingContourFilter ::New();
00038         _isosurf_mapper = vtkPolyDataMapper        ::New();
00039         _isosurf_actor  = vtkActor                 ::New();
00040         _isosurf        -> SetInput                (SGrid);
00041         _isosurf        -> SetValue                (0,f);
00042         _isosurf_mapper -> SetInputConnection      (_isosurf->GetOutputPort()); if (lt!=NULL)
00043         _isosurf_mapper -> SetLookupTable          (lt);
00044         _isosurf_actor  -> SetMapper               (_isosurf_mapper);
00045 
00046     }
00047     SGridIsoSurf(vtkStructuredGrid * SGrid, int nSurfs, double fMin, double fMax, vtkLookupTable * lt=NULL) // nSurfs between fMin and fMax
00048     {
00049         _isosurf        = vtkMarchingContourFilter ::New();
00050         _isosurf_mapper = vtkPolyDataMapper        ::New();
00051         _isosurf_actor  = vtkActor                 ::New();
00052         _isosurf        -> SetInput                (SGrid);
00053         _isosurf        -> GenerateValues          (nSurfs,fMin,fMax);
00054         _isosurf_mapper -> SetInputConnection      (_isosurf->GetOutputPort()); if (lt!=NULL)
00055         _isosurf_mapper -> SetLookupTable          (lt);
00056         _isosurf_actor  -> SetMapper               (_isosurf_mapper);
00057     }
00058     ~SGridIsoSurf()
00059     {
00060         _isosurf        -> Delete();
00061         _isosurf_mapper -> Delete();
00062         _isosurf_actor  -> Delete();
00063     }
00064     vtkActor * GetActor() { return _isosurf_actor; }
00065     vtkMarchingContourFilter * GetIsoSurf() { return _isosurf; }
00066 private:
00067     vtkMarchingContourFilter * _isosurf;
00068     vtkPolyDataMapper        * _isosurf_mapper;
00069     vtkActor                 * _isosurf_actor;
00070 }; // class SGridIsoSurf
00071 
00072 std::ostream & operator<< (std::ostream & os, SGridIsoSurf const & sgiso)
00073 {
00074     sgiso._isosurf->Print(os);
00075     return os;
00076 }
00077 
00078 #endif // VTKWRAP_SGRIDISOSURF_H
00079 
00080 // vim:fdm=marker

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