]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkPolyDataToActor.cxx
no message
[bbtk.git] / packages / vtk / src / bbvtkPolyDataToActor.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbvtkPolyDataToActor.cxx,v $
4   Language:  C++
5   Date:      $Date: 2009/05/28 08:55:44 $
6   Version:   $Revision: 1.15 $
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 #include "vtkLinearTransform.h"
41
42 #include "bbvtkPolyDataToActor.h"
43 #include "bbvtkPackage.h"
44
45 namespace bbvtk
46 {
47    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataToActor)
48    BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataToActor,bbtk::AtomicBlackBox);
49
50    void PolyDataToActor::bbUserSetDefaultValues() 
51    { 
52            firsttime=true;
53            std::vector<double> colour;
54            colour.push_back(1.0);
55            colour.push_back(1.0);
56            colour.push_back(0.5);
57            bbSetInputColour(colour);
58
59            bbSetInputIn(NULL);
60            bbSetInputRenderer(NULL);
61            bbSetInputTransform(NULL);
62            bbSetInputOpacity(1);
63            bbSetInputRepresentation(2);
64            bbSetInputLineWidth(1);
65
66            polydatamapper = NULL;
67            vtkactor       = NULL;
68    }
69
70
71         //---------------------------------------------------------------------
72    void PolyDataToActor::bbUserInitializeProcessing() 
73    {     
74      polydatamapper = vtkPolyDataMapper::New();
75      vtkactor       = vtkActor::New();
76
77 //     polydatamapper->SetInput(marchingcubes->GetOutput());
78      vtkactor->SetMapper(polydatamapper);
79
80      polydatamapper->ScalarVisibilityOff();
81      polydatamapper->ImmediateModeRenderingOn();
82    }
83
84         //---------------------------------------------------------------------
85         void PolyDataToActor::bbUserFinalizeProcessing() 
86         { 
87                 if (polydatamapper!=NULL)
88                 {
89                         polydatamapper->Delete();
90                         polydatamapper=NULL;
91                 }
92                 if (vtkactor!=NULL)
93                 {
94                         vtkactor->Delete();
95                         vtkactor=NULL;
96                 }               
97         }
98         
99         
100 //---------------------------------------------------------------------
101
102    void PolyDataToActor::DoProcess()
103    {       
104      polydatamapper->SetInput( bbGetInputIn() );
105      
106          vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
107          vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
108            
109      vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
110                                         bbGetInputColour()[1], 
111                                         bbGetInputColour()[2] );
112           
113      vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
114      
115      if ( bbGetInputTransform()!=NULL )
116      {
117         vtkactor->SetUserTransform( bbGetInputTransform() );
118      }
119
120      bbSetOutputOut( vtkactor );
121
122      // Interface Update
123      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
124      {
125        firsttime=false;
126        bbGetInputRenderer()->AddActor( vtkactor );
127      } 
128    }
129 } // EO namespace bbtk
130
131 #endif //_USE_VTK_
132