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 printf("EED DrawAxe3D::Process Start\n");
44 std::vector< double > vectx = bbGetInputlstPointX();
45 std::vector< double > vecty = bbGetInputlstPointY();
46 std::vector< double > vectz = bbGetInputlstPointZ();
48 printf("EED DrawAxe3D::Process size vector %d %d %d\n",vectx.size(),vecty.size(),vectz.size() );
50 // vtkImageData* img = bbGetInputImage();
53 // img->GetSpacing(spc);
58 if(!vectx.empty()&&!vecty.empty()&&!vectz.empty())
60 printf("EED DrawAxe3D::Process 1\n");
61 vtkPoints* allPoints = vtkPoints::New( );
62 vtkCellArray* allTopology = vtkCellArray::New( );
63 allTopology->InsertNextCell( vectx.size() );
64 printf("EED DrawAxe3D::Process 2\n");
66 for( i = 0; i < vectx.size( ); i++) {
67 //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
68 //hay parametro dicom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata
69 allPoints->InsertNextPoint( vectx[i]*spc[0], vecty[i]*spc[1], vectz[i]*spc[2] );
70 allTopology->InsertCellPoint( i );
71 printf("EED DrawAxe3D::Process 3\n");
73 mallData->SetPoints( allPoints );
74 mallData->SetLines( allTopology );
75 printf("EED DrawAxe3D::Process 4\n");
77 allTopology->Delete();
78 printf("EED DrawAxe3D::Process 5\n");
81 mvtkactor->GetProperty()->SetColor( bbGetInputColour()[0],
82 bbGetInputColour()[1],
83 bbGetInputColour()[2] );
84 printf("EED DrawAxe3D::Process 6\n");
85 //EC Axe Opacity property added
87 double opacity=bbGetInputOpacity();
88 mvtkactor->GetProperty()->SetOpacity( opacity );
89 printf("EED DrawAxe3D::Process 7\n");
90 if ( bbGetInputTransform()!=NULL )
92 printf("EED DrawAxe3D::Process 8\n");
93 mvtkactor->SetUserTransform( bbGetInputTransform() );
97 if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
99 printf("EED DrawAxe3D::Process 9\n");
101 bbGetInputRenderer()->AddActor( mvtkactor );
103 printf("EED DrawAxe3D::Process End\n");
109 void DrawAxe3D::bbUserSetDefaultValues()
113 polydatamapper = NULL;
116 std::vector<double> colour;
117 colour.push_back(1.0);
118 colour.push_back(0.0);
119 colour.push_back(0.0);
120 bbSetInputColour(colour);
121 bbSetInputOpacity(1.0);
122 bbSetInputRenderer(NULL);
123 bbSetInputTransform(NULL);
128 //-----------------------------------------------------------------
129 void DrawAxe3D::bbUserInitializeProcessing()
131 mallData = vtkPolyData::New( );
132 polydatamapper = vtkPolyDataMapper::New();
133 mvtkactor = vtkActor::New();
135 polydatamapper->SetInput(mallData);
136 mvtkactor->SetMapper(polydatamapper);
137 bbSetOutputOut(mvtkactor);
140 //-----------------------------------------------------------------
141 void DrawAxe3D::bbUserFinalizeProcessing()
149 if (polydatamapper!=NULL)
151 polydatamapper->Delete();
162 //-----------------------------------------------------------------
165 // EO namespace bbcreaMaracasVisu