]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuDrawAxe3D.cxx
Support #1768 CREATIS Licence insertion
[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         std::vector< double > vectx = bbGetInputlstPointX();
44         std::vector< double > vecty = bbGetInputlstPointY();
45         std::vector< double > vectz = bbGetInputlstPointZ();    
46
47 //      vtkImageData* img = bbGetInputImage();  
48         unsigned int i;
49         double spc[3];  
50 //      img->GetSpacing(spc);
51         spc[0]=1;
52         spc[1]=1;
53         spc[2]=1;
54
55         if(!vectx.empty()&&!vecty.empty()&&!vectz.empty()){
56                 vtkPoints* allPoints = vtkPoints::New( );
57                 vtkCellArray* allTopology = vtkCellArray::New( );
58                 allTopology->InsertNextCell( vectx.size() );
59
60                 for( i = 0; i < vectx.size( ); i++) {   
61                         //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
62                         //hay parametro dicom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata
63                         allPoints->InsertNextPoint( vectx[i]*spc[0],  vecty[i]*spc[1], vectz[i]*spc[2] );
64                         allTopology->InsertCellPoint( i );
65                 } // rof
66                 mallData->SetPoints( allPoints );
67                 mallData->SetLines( allTopology );
68                 allPoints->Delete();
69                 allTopology->Delete();  
70         }
71
72         mvtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
73                                 bbGetInputColour()[1], 
74                                 bbGetInputColour()[2] );
75
76         if ( bbGetInputTransform()!=NULL )
77         {
78                 mvtkactor->SetUserTransform( bbGetInputTransform() );
79         }
80
81      // Interface Update
82      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
83      {
84                 firsttime=false;
85             bbGetInputRenderer()->AddActor( mvtkactor );
86      }
87 }
88
89 void DrawAxe3D::bbUserSetDefaultValues()
90 {
91         firsttime        = true;
92         mallData         = NULL;
93         polydatamapper   = NULL;
94         mvtkactor        = NULL;
95
96     std::vector<double> colour;
97     colour.push_back(1.0);
98     colour.push_back(0.0);
99     colour.push_back(0.0);
100     bbSetInputColour(colour);
101 }
102
103
104
105         //-----------------------------------------------------------------     
106         void DrawAxe3D::bbUserInitializeProcessing()
107         {
108                 mallData       = vtkPolyData::New( );
109                 polydatamapper = vtkPolyDataMapper::New();
110                 mvtkactor      = vtkActor::New();
111                 
112                 polydatamapper->SetInput(mallData);
113                 mvtkactor->SetMapper(polydatamapper);
114                 bbSetOutputOut(mvtkactor);
115         }
116
117         //-----------------------------------------------------------------     
118         void DrawAxe3D::bbUserFinalizeProcessing()
119         {
120                 if (mallData!=NULL)
121                 {
122                         mallData->Delete();
123                         mallData=NULL;
124                 }
125                 
126                 if (polydatamapper!=NULL)
127                 {
128                         polydatamapper->Delete();
129                         polydatamapper=NULL;
130                 }
131                 
132                 if (mvtkactor!=NULL)
133                 {
134                         mvtkactor->Delete();
135                         mvtkactor=NULL;
136                 }
137         }
138
139         //-----------------------------------------------------------------     
140 }
141
142 // EO namespace bbcreaMaracasVisu
143
144