]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuDrawAxe3D.cxx
6a369f3aa6c6e7404127f4ff9db4bd35231315cf
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuDrawAxe3D.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 #include "bbmaracasvisuDrawAxe3D.h"
27 #include "bbcreaMaracasVisuPackage.h"
28
29 #include "vtkImageData.h"
30 #include "vtkActor.h"
31 #include "vtkPoints.h"
32 #include "vtkCellArray.h"
33 #include "vtkProperty.h"
34
35 #include "vtkLinearTransform.h"
36 namespace bbcreaMaracasVisu
37 {
38
39 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxe3D)
40 BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxe3D,bbtk::AtomicBlackBox);
41 void DrawAxe3D::Process()
42 {
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();    
47
48 printf("EED DrawAxe3D::Process size vector %d %d %d\n",vectx.size(),vecty.size(),vectz.size() );
49
50 //      vtkImageData* img = bbGetInputImage();  
51         unsigned int i;
52         double spc[3];  
53 //      img->GetSpacing(spc);
54         spc[0]=1;
55         spc[1]=1;
56         spc[2]=1;
57
58         if(!vectx.empty()&&!vecty.empty()&&!vectz.empty())
59         {
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");
65
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");
72                 } // rof
73                 mallData->SetPoints( allPoints );
74                 mallData->SetLines( allTopology );
75 printf("EED DrawAxe3D::Process 4\n");
76                 allPoints->Delete();
77                 allTopology->Delete();  
78 printf("EED DrawAxe3D::Process 5\n");
79         }
80
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
86         ///Default Values
87         double opacity=bbGetInputOpacity();
88         mvtkactor->GetProperty()->SetOpacity( opacity );
89 printf("EED DrawAxe3D::Process 7\n");
90         if ( bbGetInputTransform()!=NULL )
91         {
92 printf("EED DrawAxe3D::Process 8\n");
93                 mvtkactor->SetUserTransform( bbGetInputTransform() );
94         }
95
96      // Interface Update
97      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
98      {
99 printf("EED DrawAxe3D::Process 9\n");
100                 firsttime=false;
101             bbGetInputRenderer()->AddActor( mvtkactor );
102      }
103 printf("EED DrawAxe3D::Process End\n");
104 }
105
106
107
108
109 void DrawAxe3D::bbUserSetDefaultValues()
110 {
111         firsttime        = true;
112         mallData         = NULL;
113         polydatamapper   = NULL;
114         mvtkactor        = NULL;
115
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);
124 }
125
126
127
128         //-----------------------------------------------------------------     
129         void DrawAxe3D::bbUserInitializeProcessing()
130         {
131                 mallData       = vtkPolyData::New( );
132                 polydatamapper = vtkPolyDataMapper::New();
133                 mvtkactor      = vtkActor::New();
134                 
135                 polydatamapper->SetInput(mallData);
136                 mvtkactor->SetMapper(polydatamapper);
137                 bbSetOutputOut(mvtkactor);
138         }
139
140         //-----------------------------------------------------------------     
141         void DrawAxe3D::bbUserFinalizeProcessing()
142         {
143                 if (mallData!=NULL)
144                 {
145                         mallData->Delete();
146                         mallData=NULL;
147                 }
148                 
149                 if (polydatamapper!=NULL)
150                 {
151                         polydatamapper->Delete();
152                         polydatamapper=NULL;
153                 }
154                 
155                 if (mvtkactor!=NULL)
156                 {
157                         mvtkactor->Delete();
158                         mvtkactor=NULL;
159                 }
160         }
161
162         //-----------------------------------------------------------------     
163 }
164
165 // EO namespace bbcreaMaracasVisu
166
167