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