]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkIsoSurfaceExtractor.cxx
*** empty log message ***
[bbtk.git] / packages / vtk / src / bbvtkIsoSurfaceExtractor.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbvtkIsoSurfaceExtractor.cxx,v $
4   Language:  C++
5   Date:      $Date: 2008/11/20 17:41:48 $
6   Version:   $Revision: 1.8 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32  *  \file 
33  *  \brief 
34  */
35
36
37 #ifdef _USE_VTK_
38
39 #include "vtkProperty.h"
40
41 #include "bbvtkIsoSurfaceExtractor.h"
42 #include "bbvtkPackage.h"
43
44 namespace bbvtk
45 {
46    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,IsoSurfaceExtractor)
47    BBTK_BLACK_BOX_IMPLEMENTATION(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
48
49    void IsoSurfaceExtractor::bbUserConstructor() 
50    { 
51      Init();
52      std::vector<double> colour;
53      colour.push_back(1.0);
54      colour.push_back(1.0);
55      colour.push_back(0.5);
56      bbSetInputColour(colour);
57          bbSetInputTransform(NULL);
58    }
59    void IsoSurfaceExtractor::bbUserCopyConstructor() 
60    { 
61      Init();
62    }
63
64    void IsoSurfaceExtractor::bbUserDestructor() 
65    { 
66      marchingcubes->Delete();
67      polydatamapper->Delete();
68      vtkactor->Delete();
69   }
70
71    void IsoSurfaceExtractor::Init() 
72    { 
73      firsttime=true;
74
75      bbSetInputIn(NULL);
76      //     bbSetInputInVtkObject(NULL);
77      bbSetInputRenderer(NULL);
78      bbSetInputIsovalue(400);
79      bbSetInputOpacity(1);
80          
81      marchingcubes      = vtkMarchingCubes::New();
82      polydatamapper     = vtkPolyDataMapper::New();
83      vtkactor           = vtkActor::New();
84
85      polydatamapper->SetInput(marchingcubes->GetOutput());
86      vtkactor->SetMapper(polydatamapper);
87
88      polydatamapper->ScalarVisibilityOff();
89      polydatamapper->ImmediateModeRenderingOn();
90 }
91
92 //---------------------------------------------------------------------
93
94    void IsoSurfaceExtractor::DoProcess()
95    {
96      //   bbGetInputIn()->Print(std::cout);
97      // Visualisation - result volume
98      marchingcubes->SetInput( bbGetInputIn() );
99      marchingcubes->SetValue(0,  bbGetInputIsovalue() );
100      marchingcubes->Update();
101      
102      vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
103                                         bbGetInputColour()[1], 
104                                         bbGetInputColour()[2] );
105      
106      
107      vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
108         
109          if ( bbGetInputTransform()!=NULL )
110          {
111                  vtkactor->SetUserTransform( bbGetInputTransform() );
112          }
113
114      bbSetOutputOut( vtkactor );
115      
116      // Interface Update
117      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
118      {
119                 firsttime=false;
120             bbGetInputRenderer()->AddActor( vtkactor );
121      }
122    }
123 } // EO namespace bbtk
124
125 #endif //_USE_VTK_