]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkIsoSurfaceExtractor.cxx
*** empty log message ***
[bbtk.git] / packages / vtk / src / bbvtkIsoSurfaceExtractor.cxx
1
2 /*=========================================================================
3                                                                                 
4   Program:   bbtk
5   Module:    $RCSfile: bbvtkIsoSurfaceExtractor.cxx,v $
6   Language:  C++
7   Date:      $Date: 2008/05/09 10:39:47 $
8   Version:   $Revision: 1.6 $
9                                                                                 
10   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
11   l'Image). All rights reserved. See Doc/License.txt or
12   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13                                                                                 
14      This software is distributed WITHOUT ANY WARRANTY; without even
15      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16      PURPOSE.  See the above copyright notices for more information.
17                                                                                 
18 =========================================================================*/
19 /**
20  *  \file 
21  *  \brief 
22  */
23
24
25 #ifdef _USE_VTK_
26
27 #include "vtkProperty.h"
28
29 #include "bbvtkIsoSurfaceExtractor.h"
30 #include "bbvtkPackage.h"
31
32 namespace bbvtk
33 {
34    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,IsoSurfaceExtractor)
35    BBTK_BLACK_BOX_IMPLEMENTATION(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
36
37    void IsoSurfaceExtractor::bbUserConstructor() 
38    { 
39      Init();
40      std::vector<double> colour;
41      colour.push_back(1.0);
42      colour.push_back(1.0);
43      colour.push_back(0.5);
44      bbSetInputColour(colour);
45
46    }
47    void IsoSurfaceExtractor::bbUserCopyConstructor() 
48    { 
49      Init();
50    }
51
52    void IsoSurfaceExtractor::bbUserDestructor() 
53    { 
54      marchingcubes->Delete();
55      polydatamapper->Delete();
56      vtkactor->Delete();
57   }
58
59    void IsoSurfaceExtractor::Init() 
60    { 
61      firsttime=true;
62
63      bbSetInputIn(NULL);
64      //     bbSetInputInVtkObject(NULL);
65      bbSetInputRenderer(NULL);
66      bbSetInputIsovalue(400);
67      bbSetInputOpacity(1);
68          
69      marchingcubes      = vtkMarchingCubes::New();
70      polydatamapper     = vtkPolyDataMapper::New();
71      vtkactor           = vtkActor::New();
72
73      polydatamapper->SetInput(marchingcubes->GetOutput());
74      vtkactor->SetMapper(polydatamapper);
75
76      polydatamapper->ScalarVisibilityOff();
77      polydatamapper->ImmediateModeRenderingOn();
78 }
79
80 //---------------------------------------------------------------------
81
82    void IsoSurfaceExtractor::DoProcess()
83    {
84      //   bbGetInputIn()->Print(std::cout);
85      // Visualisation - result volume
86      marchingcubes->SetInput( bbGetInputIn() );
87      marchingcubes->SetValue(0,  bbGetInputIsovalue() );
88      marchingcubes->Update();
89      
90      vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
91                                         bbGetInputColour()[1], 
92                                         bbGetInputColour()[2] );
93      
94      
95      vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
96      bbSetOutputOut( vtkactor );
97      
98      // Interface Update
99      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
100      {
101                 firsttime=false;
102             bbGetInputRenderer()->AddActor( vtkactor );
103      }
104    }
105 } // EO namespace bbtk
106
107 #endif //_USE_VTK_