]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkPolyDataToActor.cxx
#3403 BBTK Feature New Normal - vtk8itk5wx3-macos
[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
51 namespace bbvtk
52 {
53    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataToActor)
54    BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataToActor,bbtk::AtomicBlackBox);
55
56    void PolyDataToActor::bbUserSetDefaultValues() 
57    { 
58            actorAdded=false;
59            std::vector<double> colour;
60            colour.push_back(1.0);
61            colour.push_back(1.0);
62            colour.push_back(0.5);
63            bbSetInputColour(colour);
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            polydatamapper = NULL;
73            vtkactor       = NULL;
74    }
75
76
77         //---------------------------------------------------------------------
78    void PolyDataToActor::bbUserInitializeProcessing() 
79    {     
80      polydatamapper = vtkPolyDataMapper::New();
81      vtkactor       = vtkActor::New();
82 //     polydatamapper->SetInput(marchingcubes->GetOutput());
83      vtkactor->SetMapper(polydatamapper);
84 //EED 2020-04-21 vtk8 deprecated
85 //     polydatamapper->ImmediateModeRenderingOn();
86    }
87
88         //---------------------------------------------------------------------
89         void PolyDataToActor::bbUserFinalizeProcessing() 
90         { 
91                 if (polydatamapper!=NULL)
92                 {
93                         polydatamapper->Delete();
94                         polydatamapper=NULL;
95                 }
96                 if (vtkactor!=NULL)
97                 {
98                         vtkactor->Delete();
99                         vtkactor=NULL;
100                 }               
101         }
102         
103         
104 //---------------------------------------------------------------------
105
106         void PolyDataToActor::DoProcess()
107         {
108
109                 if (bbGetInputActive()==true)
110                 {
111 //EED 2017-01-01 Migration VTK7
112 #if VTK_MAJOR_VERSION <= 5
113                          polydatamapper->SetInput( bbGetInputIn() );
114 #else
115                          polydatamapper->SetInputData( bbGetInputIn() );
116 #endif
117
118                          vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
119
120                         if (bbGetInputRepresentation()==1)
121                         {
122                                  vtkactor->GetProperty()->SetAmbient(1);
123                                  vtkactor->GetProperty()->SetDiffuse(1);
124                                  vtkactor->GetProperty()->SetSpecular(0);
125                         } else {
126 printf("EED WARNNING!  PolyDataToActor::DoProcess  which is the default values of Ambient, Diffuse, Specular ? \n");
127                         }
128
129                          vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
130                            
131                          vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
132                                                         bbGetInputColour()[1], 
133                                                         bbGetInputColour()[2] );
134                                   
135                          vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
136
137                          
138                          if ( bbGetInputTransform()!=NULL )
139                          {
140                                 vtkactor->SetUserTransform( bbGetInputTransform() );
141                          }
142
143                          bbSetOutputOut( vtkactor );
144
145                          // Interface Update
146                          if ((actorAdded==false) && (bbGetInputRenderer()!=NULL ))
147                          {
148                            actorAdded=true;
149                            bbGetInputRenderer()->AddActor( vtkactor );
150                          }  // actorAdded
151
152                          if (bbGetInputScalarVisibility()==true )
153                          {
154                                  polydatamapper->ScalarVisibilityOn();
155                          } else {
156                                  polydatamapper->ScalarVisibilityOff();
157                          } // ScalarVisibility
158                 } else {
159                          // Interface Update
160                          if ((actorAdded==true) && (bbGetInputRenderer()!=NULL ))
161                          {
162                            actorAdded=false;
163                            bbGetInputRenderer()->RemoveActor( vtkactor );
164                          }  // actorAdded
165                 } // Active
166         }
167
168
169
170 } // EO namespace bbtk
171
172 #endif //_USE_VTK_
173