]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkIsoSurfaceExtractor.cxx
7b23c9af0738fd9b22e19b9339a14a3e872d8455
[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/04/24 12:56:41 $
8   Version:   $Revision: 1.5 $
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::Init() 
53    { 
54      firsttime=true;
55
56           bbSetInputIn(NULL);
57           //     bbSetInputInVtkObject(NULL);
58          bbSetInputRenderer(NULL);
59      bbSetInputIsovalue(400);
60      bbSetInputOpacity(1);
61          
62          marchingcubes  = vtkMarchingCubes::New();
63      polydatamapper     = vtkPolyDataMapper::New();
64      vtkactor        = vtkActor::New();
65
66      polydatamapper->SetInput(marchingcubes->GetOutput());
67      vtkactor->SetMapper(polydatamapper);
68
69      polydatamapper->ScalarVisibilityOff();
70      polydatamapper->ImmediateModeRenderingOn();
71 }
72
73 //---------------------------------------------------------------------
74
75    void IsoSurfaceExtractor::DoProcess()
76    {
77      //   bbGetInputIn()->Print(std::cout);
78      // Visualisation - result volume
79      marchingcubes->SetInput( bbGetInputIn() );
80      marchingcubes->SetValue(0,  bbGetInputIsovalue() );
81      marchingcubes->Update();
82      
83      vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  bbGetInputColour()[1], bbGetInputColour()[2] );
84      
85      
86      vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
87      bbSetOutputOut( vtkactor );
88      
89      // Interface Update
90      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
91      {
92                 firsttime=false;
93             bbGetInputRenderer()->AddActor( vtkactor );
94      }
95    }
96 } // EO namespace bbtk
97
98 #endif //_USE_VTK_