2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbvtkPolyDataToActor.cxx,v $
32 Date: $Date: 2009/05/28 08:55:44 $
33 Version: $Revision: 1.15 $
34 =========================================================================*/
44 #include "vtkProperty.h"
45 #include "vtkLinearTransform.h"
46 #include "vtkCleanPolyData.h"
48 #include "bbvtkPolyDataToActor.h"
49 #include "bbvtkPackage.h"
51 #include "vtkRenderWindow.h"
55 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataToActor)
56 BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataToActor,bbtk::AtomicBlackBox);
58 void PolyDataToActor::bbUserSetDefaultValues()
61 std::vector<double> colour;
62 colour.push_back(1.0);
63 colour.push_back(1.0);
64 colour.push_back(0.5);
65 bbSetInputColour(colour);
66 bbSetInputActive(true);
68 bbSetInputRenderer(NULL);
69 bbSetInputTransform(NULL);
71 bbSetInputRepresentation(2);
72 bbSetInputLineWidth(1);
73 bbSetInputScalarVisibility(false);
74 polydatamapper = NULL;
79 //---------------------------------------------------------------------
80 void PolyDataToActor::bbUserInitializeProcessing()
82 polydatamapper = vtkPolyDataMapper::New();
83 vtkactor = vtkActor::New();
85 // polydatamapper->SetInput(marchingcubes->GetOutput());
86 vtkactor->SetMapper(polydatamapper);
88 // polydatamapper->ImmediateModeRenderingOn();
91 //---------------------------------------------------------------------
92 void PolyDataToActor::bbUserFinalizeProcessing()
94 if (polydatamapper!=NULL)
96 polydatamapper->Delete();
107 //---------------------------------------------------------------------
109 void PolyDataToActor::DoProcess()
111 if (bbGetInputRenderer()==NULL)
113 printf("EED Warnning! PolyDataToActor::DoProcess missing Renderer.\n");
117 if (bbGetInputActive()==true)
121 //EED 2017-01-01 Migration VTK7
122 #if VTK_MAJOR_VERSION <= 5
123 polydatamapper->SetInput( bbGetInputIn() );
125 polydatamapper->SetInputData( bbGetInputIn() );
128 vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
130 if (bbGetInputRepresentation()==0)
132 vtkactor->GetProperty()->SetAmbient(1);
133 vtkactor->GetProperty()->SetDiffuse(1);
134 vtkactor->GetProperty()->SetSpecular(0);
135 printf("EED WARNNING! PolyDataToActor::DoProcess which is the default values of Ambient, Diffuse, Specular for points option? \n");
136 } else if (bbGetInputRepresentation()==1)
138 vtkactor->GetProperty()->SetAmbient(1);
139 vtkactor->GetProperty()->SetDiffuse(1);
140 vtkactor->GetProperty()->SetSpecular(0);
141 } else if (bbGetInputRepresentation()==2)
143 vtkactor->GetProperty()->SetAmbient(0);
144 vtkactor->GetProperty()->SetDiffuse(1);
145 vtkactor->GetProperty()->SetSpecular(0);
148 vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
150 vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],
151 bbGetInputColour()[1],
152 bbGetInputColour()[2] );
154 vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
157 if ( bbGetInputTransform()!=NULL )
159 vtkactor->SetUserTransform( bbGetInputTransform() );
162 bbSetOutputOut( vtkactor );
165 if ((actorAdded==false) && (bbGetInputRenderer()!=NULL ))
168 bbGetInputRenderer()->AddActor( vtkactor );
171 if (bbGetInputScalarVisibility()==true )
173 polydatamapper->ScalarVisibilityOn();
175 polydatamapper->ScalarVisibilityOff();
176 } // ScalarVisibility
179 if ((actorAdded==true) && (bbGetInputRenderer()!=NULL ))
182 bbGetInputRenderer()->RemoveActor( vtkactor );
189 } // EO namespace bbtk