]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkIsoSurfaceExtractor.cxx
=== MAJOR RELEASE ====
[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/18 12:59:52 $
8   Version:   $Revision: 1.4 $
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 //---------------------------------------------------------------------
76
77    void IsoSurfaceExtractor::DoProcess()
78    {
79      //   bbGetInputIn()->Print(std::cout);
80      // Visualisation - result volume
81      marchingcubes->SetInput( bbGetInputIn() );
82      marchingcubes->SetValue(0,  bbGetInputIsovalue() );
83      marchingcubes->Update();
84      
85      // if (_2_isoActorMC6!=NULL)
86      //  {
87      //   bbGetInputRenderer()->RemoveActor(vtkactor);
88      //  }
89      
90      vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  bbGetInputColour()[1], bbGetInputColour()[2] );
91      
92      
93      vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
94      bbSetOutputOut( vtkactor );
95      
96      // Interface Update
97      /* 
98      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
99        {
100          firsttime=false;
101          bbGetInputRenderer()->AddActor( vtkactor );
102        }
103      */
104    }
105 } // EO namespace bbtk
106
107 #endif //_USE_VTK_