1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "bbmaracasvisuDrawAxe3D.h"
27 #include "bbcreaMaracasVisuPackage.h"
29 #include "vtkImageData.h"
31 #include "vtkPoints.h"
32 #include "vtkCellArray.h"
33 #include "vtkProperty.h"
35 #include "vtkLinearTransform.h"
36 namespace bbcreaMaracasVisu
39 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxe3D)
40 BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxe3D,bbtk::AtomicBlackBox);
41 void DrawAxe3D::Process()
43 std::vector< double > vectx = bbGetInputlstPointX();
44 std::vector< double > vecty = bbGetInputlstPointY();
45 std::vector< double > vectz = bbGetInputlstPointZ();
48 // vtkImageData* img = bbGetInputImage();
51 // img->GetSpacing(spc);
56 if(!vectx.empty()&&!vecty.empty()&&!vectz.empty())
58 vtkPoints* allPoints = vtkPoints::New( );
59 vtkCellArray* allTopology = vtkCellArray::New( );
60 allTopology->InsertNextCell( vectx.size() );
62 for( i = 0; i < vectx.size( ); i++) {
63 //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
64 //hay parametro dicom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata
65 allPoints->InsertNextPoint( vectx[i]*spc[0], vecty[i]*spc[1], vectz[i]*spc[2] );
66 allTopology->InsertCellPoint( i );
68 mallData->SetPoints( allPoints );
69 mallData->SetLines( allTopology );
71 allTopology->Delete();
74 mvtkactor->GetProperty()->SetColor( bbGetInputColour()[0],
75 bbGetInputColour()[1],
76 bbGetInputColour()[2] );
77 //EC Axe Opacity property added
79 double opacity=bbGetInputOpacity();
80 mvtkactor->GetProperty()->SetOpacity( opacity );
81 if ( bbGetInputTransform()!=NULL )
83 mvtkactor->SetUserTransform( bbGetInputTransform() );
87 if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
90 bbGetInputRenderer()->AddActor( mvtkactor );
97 void DrawAxe3D::bbUserSetDefaultValues()
101 polydatamapper = NULL;
104 std::vector<double> colour;
105 colour.push_back(1.0);
106 colour.push_back(0.0);
107 colour.push_back(0.0);
108 bbSetInputColour(colour);
109 bbSetInputOpacity(1.0);
110 bbSetInputRenderer(NULL);
111 bbSetInputTransform(NULL);
116 //-----------------------------------------------------------------
117 void DrawAxe3D::bbUserInitializeProcessing()
119 mallData = vtkPolyData::New( );
120 polydatamapper = vtkPolyDataMapper::New();
121 mvtkactor = vtkActor::New();
123 //EED 2017-01-01 Migration VTK7
124 #if VTK_MAJOR_VERSION <= 5
125 polydatamapper->SetInput(mallData);
127 polydatamapper->SetInputData(mallData);
130 mvtkactor->SetMapper(polydatamapper);
131 bbSetOutputOut(mvtkactor);
134 //-----------------------------------------------------------------
135 void DrawAxe3D::bbUserFinalizeProcessing()
143 if (polydatamapper!=NULL)
145 polydatamapper->Delete();
156 //-----------------------------------------------------------------
159 // EO namespace bbcreaMaracasVisu