]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkPolyDataToActor.cxx
#3008 BBTK Feature New Normal - Active option in box vtk::IsoSurfaceExtractor
[bbtk.git] / packages / vtk / src / bbvtkPolyDataToActor.cxx
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbvtkPolyDataToActor.cxx,v $
31   Language:  C++
32   Date:      $Date: 2009/05/28 08:55:44 $
33   Version:   $Revision: 1.15 $
34 =========================================================================*/
35
36 /**
37  *  \file 
38  *  \brief 
39  */
40
41
42 #ifdef _USE_VTK_
43
44 #include "vtkProperty.h"
45 #include "vtkLinearTransform.h"
46
47 #include "bbvtkPolyDataToActor.h"
48 #include "bbvtkPackage.h"
49
50 namespace bbvtk
51 {
52    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataToActor)
53    BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataToActor,bbtk::AtomicBlackBox);
54
55    void PolyDataToActor::bbUserSetDefaultValues() 
56    { 
57            actorAdded=false;
58            std::vector<double> colour;
59            colour.push_back(1.0);
60            colour.push_back(1.0);
61            colour.push_back(0.5);
62            bbSetInputColour(colour);
63
64            bbSetInputActive(true);
65            bbSetInputIn(NULL);
66            bbSetInputRenderer(NULL);
67            bbSetInputTransform(NULL);
68            bbSetInputOpacity(1);
69            bbSetInputRepresentation(2);
70            bbSetInputLineWidth(1);
71            bbSetInputScalarVisibility(false);
72
73            polydatamapper = NULL;
74            vtkactor       = NULL;
75    }
76
77
78         //---------------------------------------------------------------------
79    void PolyDataToActor::bbUserInitializeProcessing() 
80    {     
81      polydatamapper = vtkPolyDataMapper::New();
82      vtkactor       = vtkActor::New();
83
84 //     polydatamapper->SetInput(marchingcubes->GetOutput());
85      vtkactor->SetMapper(polydatamapper);
86
87      polydatamapper->ImmediateModeRenderingOn();
88    }
89
90         //---------------------------------------------------------------------
91         void PolyDataToActor::bbUserFinalizeProcessing() 
92         { 
93                 if (polydatamapper!=NULL)
94                 {
95                         polydatamapper->Delete();
96                         polydatamapper=NULL;
97                 }
98                 if (vtkactor!=NULL)
99                 {
100                         vtkactor->Delete();
101                         vtkactor=NULL;
102                 }               
103         }
104         
105         
106 //---------------------------------------------------------------------
107
108         void PolyDataToActor::DoProcess()
109         {
110
111                 if (bbGetInputActive()==true)
112                 {
113                          polydatamapper->SetInput( bbGetInputIn() );
114                          vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
115                          vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
116                            
117                          vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
118                                                         bbGetInputColour()[1], 
119                                                         bbGetInputColour()[2] );
120                                   
121                          vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
122                          
123                          if ( bbGetInputTransform()!=NULL )
124                          {
125                                 vtkactor->SetUserTransform( bbGetInputTransform() );
126                          }
127
128                          bbSetOutputOut( vtkactor );
129
130                          // Interface Update
131                          if ((actorAdded==false) && (bbGetInputRenderer()!=NULL ))
132                          {
133                            actorAdded=true;
134                            bbGetInputRenderer()->AddActor( vtkactor );
135                          }  // actorAdded
136
137                          if (bbGetInputScalarVisibility()==true )
138                          {
139                                  polydatamapper->ScalarVisibilityOn();
140                          } else {
141                                  polydatamapper->ScalarVisibilityOff();
142                          } // ScalarVisibility
143                 } else {
144                          // Interface Update
145                          if ((actorAdded==true) && (bbGetInputRenderer()!=NULL ))
146                          {
147                            actorAdded=false;
148                            bbGetInputRenderer()->RemoveActor( vtkactor );
149                          }  // actorAdded
150                 } // Active
151         }
152
153
154
155 } // EO namespace bbtk
156
157 #endif //_USE_VTK_
158