]> Creatis software - creaVtk.git/blob - lib/creaVtk/vtkVectorsVisu.cpp
#3110 creaVtk Bug New Normal - branch vtk7itk4 compilation with vtk7
[creaVtk.git] / lib / creaVtk / vtkVectorsVisu.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 #                        pour la Sante)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and
11 #  abiding by the rules of distribution of free software. You can  use,
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B
13 #  license as circulated by CEA, CNRS and INRIA at the following URL
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability.
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
26 */
27
28 #include "vtkVectorsVisu.h"
29
30 #include "vtkProperty.h"
31
32 //Borrame
33 #include "vtkPointData.h"
34
35
36 //------------------------------------------------------------------------------
37 vtkVectorsVisu::vtkVectorsVisu()
38   :vtkVectorsTensorsVisuBase()
39 {
40         _vtkarrowsource         = vtkArrowSource::New();
41         _vtklinesource          = vtkLineSource::New();
42         _vtkglyph                       = vtkGlyph3D::New();
43 }
44
45
46 //------------------------------------------------------------------------------
47 vtkVectorsVisu::~vtkVectorsVisu()
48 {
49 }
50
51 //------------------------------------------------------------------------------
52 void vtkVectorsVisu::Process()
53 {
54 printf("EED vtkVectorsVisu::Process  Start\n");
55
56      if(_active==true)
57      {
58 #if VTK_MAJOR_VERSION <= 5
59          _vtkglyph->SetInput( GetDataObject() );  
60 #else
61          _vtkglyph->SetInputData( GetDataObject() );  
62 #endif
63
64                         if(GetTypeForm()==1)                                                            // source Arrow
65                         {
66 #if VTK_MAJOR_VERSION <= 5
67                  _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
68 #else
69                  _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
70 #endif
71                         } else {                                                                                                // source Line
72 #if VTK_MAJOR_VERSION <= 5
73                                 _vtkglyph->SetSource( _vtklinesource->GetOutput() );    
74 #else
75                                 _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );        
76 #endif
77                         }
78
79          _vtkglyph->SetScaleModeToScaleByVector();
80          _vtkglyph->SetColorModeToColorByVector();
81          _vtkglyph->SetScaleFactor( GetScaleFactor() );
82 printf("EED vtkVectorsVisu::Process  A\n"  );
83
84
85                 _vtkglyph->Update();
86
87 #if VTK_MAJOR_VERSION <= 5
88          _pdm->SetInput( _vtkglyph->GetOutput());
89 #else
90          _pdm->SetInputData( _vtkglyph->GetOutput());
91 #endif
92
93 vtkPointData    *data   = _vtkglyph->GetOutput()->GetPointData();
94 //printf("EED -------------------------------------------\n");
95 //_vtkglyph->GetOutput()->Print(std::cout);
96 //printf("EED -------------------------------------------\n");
97 //data->Print(std::cout);
98 printf("EED -------------------------------------------\n");                    
99 int i,sizeDa = data->GetNumberOfArrays();
100 printf("EED vtkVectorsVisu::Process  sizeDa %d \n", sizeDa );
101 for (i=0;i<sizeDa;i++)
102 {
103         printf("EED vtkVectorsVisu::Process-name %d, %s \n", i, data->GetArrayName(i) );
104         data->GetArray(i)->Print(std::cout);
105         printf("EED -------------------------------------------\n");
106 }
107
108 //EED         _pdm->SetScalarRange( range );
109 //EED         vtkPolyData       *pd                     = vGlyphFlowPlane->GetOutput();
110 //EED         vtkPointData      *pointdata              = pd->GetPointData();
111 //EED         vtkDataArray      *da                     = pointdata->GetVectors();
112 //EED         vtkDataArray *nda = vtkFloatArray::New();
113 //EED         nda->DeepCopy(da);
114 //       pointdata->RemoveArray( "GlyphVector" );
115 //       bbGetInputIn()->GetPointData()->RemoveArray( "GlyphVector" );
116 //EED         pointdata->AddArray( nda );
117 //EED         bbGetInputIn()->GetPointData()->AddArray( nda );
118 //EED2         _pdm->ScalarVisibilityOn();
119
120
121
122
123
124         _pdm->ScalarVisibilityOn();
125         _pdm->SetColorModeToMapScalars();
126         //_pdm->SetColorModeToDefault();
127         // _pdm->SetColorModeToDirectScalars();  // NOT compile
128         _pdm->SetScalarModeToUsePointFieldData();
129         _pdm->ImmediateModeRenderingOn();
130
131         _LutEED->SetVectorModeToComponent();
132         //_LutEED->SetVectorModeToRGBColors();
133         //_LutEED->SetVectorModeToMagnitud();
134
135
136
137 //         _pdm->SetScalarModeToUsePointFieldData();
138          _pdm->SetLookupTable( _LutEED );
139          _pdm->SelectColorArray( "GlyphVector" );
140
141 //       vSliceMapperVec->SetLookupTable( vGreenToRedLut );
142 //       vSliceMapperVec->SetColorModeToMapScalars();
143
144 #if VTK_MAJOR_VERSION <= 5
145                 // ..
146 #else
147          _pdm->Update();
148 #endif
149          _actor->SetMapper( _pdm );
150          _actor->GetProperty()->SetOpacity( GetOpacity() );
151     }// if _active
152
153     VisibilityActor(); 
154 printf("EED vtkVectorsVisu::Process  END\n");
155 }
156         
157
158
159
160
161