]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuDrawAxe3D.cxx
fa7a0cfe5c7ebf9fed64923660ecd44af0e51a30
[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
48 //      vtkImageData* img = bbGetInputImage();  
49         unsigned int i;
50         double spc[3];  
51 //      img->GetSpacing(spc);
52         spc[0]=1;
53         spc[1]=1;
54         spc[2]=1;
55
56         if(!vectx.empty()&&!vecty.empty()&&!vectz.empty())
57         {
58                 vtkPoints* allPoints = vtkPoints::New( );
59                 vtkCellArray* allTopology = vtkCellArray::New( );
60                 allTopology->InsertNextCell( vectx.size() );
61
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 );
67                 } // rof
68                 mallData->SetPoints( allPoints );
69                 mallData->SetLines( allTopology );
70                 allPoints->Delete();
71                 allTopology->Delete();  
72         }
73
74         mvtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
75                                 bbGetInputColour()[1], 
76                                 bbGetInputColour()[2] );
77         //EC Axe Opacity property added
78         ///Default Values
79         double opacity=bbGetInputOpacity();
80         mvtkactor->GetProperty()->SetOpacity( opacity );
81         if ( bbGetInputTransform()!=NULL )
82         {
83                 mvtkactor->SetUserTransform( bbGetInputTransform() );
84         }
85
86      // Interface Update
87      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
88      {
89                 firsttime=false;
90             bbGetInputRenderer()->AddActor( mvtkactor );
91      }
92 }
93
94
95
96
97 void DrawAxe3D::bbUserSetDefaultValues()
98 {
99         firsttime        = true;
100         mallData         = NULL;
101         polydatamapper   = NULL;
102         mvtkactor        = NULL;
103
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);
112 }
113
114
115
116         //-----------------------------------------------------------------     
117         void DrawAxe3D::bbUserInitializeProcessing()
118         {
119                 mallData       = vtkPolyData::New( );
120                 polydatamapper = vtkPolyDataMapper::New();
121                 mvtkactor      = vtkActor::New();
122                 
123                 polydatamapper->SetInput(mallData);
124                 mvtkactor->SetMapper(polydatamapper);
125                 bbSetOutputOut(mvtkactor);
126         }
127
128         //-----------------------------------------------------------------     
129         void DrawAxe3D::bbUserFinalizeProcessing()
130         {
131                 if (mallData!=NULL)
132                 {
133                         mallData->Delete();
134                         mallData=NULL;
135                 }
136                 
137                 if (polydatamapper!=NULL)
138                 {
139                         polydatamapper->Delete();
140                         polydatamapper=NULL;
141                 }
142                 
143                 if (mvtkactor!=NULL)
144                 {
145                         mvtkactor->Delete();
146                         mvtkactor=NULL;
147                 }
148         }
149
150         //-----------------------------------------------------------------     
151 }
152
153 // EO namespace bbcreaMaracasVisu
154
155