]> Creatis software - creaVtk.git/blob - lib/creaVtk/vtkVectorsVisu.cpp
92c3df40293c4ceac6970204482ccad1dbd404da
[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      if(_active==true)
55      {
56 #if VTK_MAJOR_VERSION <= 5
57          _vtkglyph->SetInput( GetDataObject() );  
58 #else
59          _vtkglyph->SetInputData( GetDataObject() );  
60 #endif
61
62                         if(GetTypeForm()==1)                                                            // source Arrow
63                         {
64 #if VTK_MAJOR_VERSION <= 5
65                  _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
66 #else
67                  _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
68 #endif
69                         } else {                                                                                                // source Line
70 #if VTK_MAJOR_VERSION <= 5
71                                 _vtkglyph->SetSource( _vtklinesource->GetOutput() );    
72 #else
73                                 _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );        
74 #endif
75                         }
76
77          _vtkglyph->SetScaleModeToScaleByVector();
78          _vtkglyph->SetColorModeToColorByVector();
79          _vtkglyph->SetScaleFactor( GetScaleFactor() );
80          _vtkglyph->Update();
81
82 #if VTK_MAJOR_VERSION <= 5
83          _pdm->SetInput( _vtkglyph->GetOutput());
84 #else
85          _pdm->SetInputData( _vtkglyph->GetOutput());
86 #endif
87
88 vtkPointData    *data   = _vtkglyph->GetOutput()->GetPointData();
89 //printf("EED -------------------------------------------\n");
90 //_vtkglyph->GetOutput()->Print(std::cout);
91 //printf("EED -------------------------------------------\n");
92 //data->Print(std::cout);
93 printf("EED -------------------------------------------\n");                    
94 int i,sizeDa = data->GetNumberOfArrays();
95 printf("EED vtkVectorsVisu::Process  sizeDa %d \n", sizeDa );
96 for (i=0;i<sizeDa;i++)
97 {
98         printf("EED vtkVectorsVisu::Process-name %d, %s \n", i, data->GetArrayName(i) );
99         data->GetArray(i)->Print(std::cout);
100         printf("EED -------------------------------------------\n");
101 }
102
103 //EED         _pdm->SetScalarRange( range );
104 //EED         vtkPolyData       *pd                     = vGlyphFlowPlane->GetOutput();
105 //EED         vtkPointData      *pointdata              = pd->GetPointData();
106 //EED         vtkDataArray      *da                     = pointdata->GetVectors();
107 //EED         vtkDataArray *nda = vtkFloatArray::New();
108 //EED         nda->DeepCopy(da);
109 //       pointdata->RemoveArray( "GlyphVector" );
110 //       bbGetInputIn()->GetPointData()->RemoveArray( "GlyphVector" );
111 //EED         pointdata->AddArray( nda );
112 //EED         bbGetInputIn()->GetPointData()->AddArray( nda );
113 //EED2         _pdm->ScalarVisibilityOn();
114
115
116
117
118
119         _pdm->ScalarVisibilityOn();
120         _pdm->SetColorModeToMapScalars();
121         //_pdm->SetColorModeToDefault();
122         // _pdm->SetColorModeToDirectScalars();  // NOT compile
123         _pdm->SetScalarModeToUsePointFieldData();
124         _pdm->ImmediateModeRenderingOn();
125
126         _LutEED->SetVectorModeToComponent();
127         //_LutEED->SetVectorModeToRGBColors();
128         //_LutEED->SetVectorModeToMagnitud();
129
130
131
132 //         _pdm->SetScalarModeToUsePointFieldData();
133          _pdm->SetLookupTable( _LutEED );
134          _pdm->SelectColorArray( "GlyphVector" );
135
136 //       vSliceMapperVec->SetLookupTable( vGreenToRedLut );
137 //       vSliceMapperVec->SetColorModeToMapScalars();
138
139          _actor->SetMapper( _pdm );
140          _actor->GetProperty()->SetOpacity( GetOpacity() );
141     }// if _active
142
143     VisibilityActor(); 
144 }
145         
146
147
148
149
150