]> Creatis software - creaVtk.git/blob - lib/creaVtk/vtkVectorsVisu.cpp
#3223 creaVtk Feature New Normal - vtk8itk4wx3-mingw64
[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 <<<<<<< HEAD
42         _vtklinesource          = vtkLineSource::New();
43 =======
44 >>>>>>> master
45         _vtkglyph                       = vtkGlyph3D::New();
46         _vtklinesource          = vtkLineSource::New();
47
48         double point1[3];
49         double point2[3];
50         point1[0]=1;
51         point1[1]=0;
52         point1[2]=0;
53         point2[0]=-1;
54         point2[1]=0;
55         point2[2]=0;
56         _vtklinesource->SetPoint1( point1 );
57         _vtklinesource->SetPoint2( point2 );
58 }
59
60 //------------------------------------------------------------------------------
61 vtkVectorsVisu::~vtkVectorsVisu()
62 {
63 }
64
65
66 //------------------------------------------------------------------------------
67 void vtkVectorsVisu::Process()
68 {
69 <<<<<<< HEAD
70
71 =======
72 >>>>>>> master
73      if(_active==true)
74      {
75 #if VTK_MAJOR_VERSION <= 5
76          _vtkglyph->SetInput( GetDataObject() );  
77 <<<<<<< HEAD
78 #else
79          _vtkglyph->SetInputData( GetDataObject() );  
80 #endif
81
82 =======
83 >>>>>>> master
84                         if(GetTypeForm()==1)                                                            // source Arrow
85                         {
86 #if VTK_MAJOR_VERSION <= 5
87                         _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
88 #else
89                                 _vtkarrowsource->Update();
90                         _vtkglyph->SetSourceData( _vtkarrowsource->GetOutput() );
91 #endif
92                         } else {                                                                                                // source Line
93 #if VTK_MAJOR_VERSION <= 5
94                                 _vtkglyph->SetSource( _vtklinesource->GetOutput() );    
95 #else
96                                 _vtklinesource->Update();
97                                 _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );        
98 #endif
99                         }
100          _vtkglyph->SetScaleModeToScaleByVector();
101          _vtkglyph->SetColorModeToColorByVector();
102          _vtkglyph->SetScaleFactor( GetScaleFactor() );
103 <<<<<<< HEAD
104
105                 _vtkglyph->Update();
106
107 #if VTK_MAJOR_VERSION <= 5
108          _pdm->SetInput( _vtkglyph->GetOutput());
109 #else
110          _pdm->SetInputData( _vtkglyph->GetOutput());
111 #endif
112
113 =======
114          _vtkglyph->Update();
115          _pdm->SetInput( _vtkglyph->GetOutput());
116 >>>>>>> master
117 vtkPointData    *data   = _vtkglyph->GetOutput()->GetPointData();
118 //printf("EED -------------------------------------------\n");
119 //_vtkglyph->GetOutput()->Print(std::cout);
120 //printf("EED -------------------------------------------\n");
121 //data->Print(std::cout);
122 int i,sizeDa = data->GetNumberOfArrays();
123 for (i=0;i<sizeDa;i++)
124 {
125 <<<<<<< HEAD
126         printf("EED vtkVectorsVisu::Process-name %d, %s \n", i, data->GetArrayName(i) );
127 }
128
129 //EED         _pdm->SetScalarRange( range );
130 //EED         vtkPolyData       *pd                     = vGlyphFlowPlane->GetOutput();
131 //EED         vtkPointData      *pointdata              = pd->GetPointData();
132 //EED         vtkDataArray      *da                     = pointdata->GetVectors();
133 //EED         vtkDataArray *nda = vtkFloatArray::New();
134 //EED         nda->DeepCopy(da);
135 //       pointdata->RemoveArray( "GlyphVector" );
136 //       bbGetInputIn()->GetPointData()->RemoveArray( "GlyphVector" );
137 //EED         pointdata->AddArray( nda );
138 //EED         bbGetInputIn()->GetPointData()->AddArray( nda );
139 //EED2         _pdm->ScalarVisibilityOn();
140
141 =======
142         data->GetArray(i)->Print(std::cout);
143 }
144
145 >>>>>>> master
146         _pdm->ScalarVisibilityOn();
147         _pdm->SetColorModeToMapScalars();
148         //_pdm->SetColorModeToDefault();
149         // _pdm->SetColorModeToDirectScalars();  // NOT compile
150         _pdm->SetScalarModeToUsePointFieldData();
151         _pdm->ImmediateModeRenderingOn();
152
153         _LutEED->SetVectorModeToComponent();
154         //_LutEED->SetVectorModeToRGBColors();
155         //_LutEED->SetVectorModeToMagnitud();
156
157 //         _pdm->SetScalarModeToUsePointFieldData();
158          _pdm->SetLookupTable( _LutEED );
159          _pdm->SelectColorArray( "GlyphVector" );
160
161 //       vSliceMapperVec->SetLookupTable( vGreenToRedLut );
162 //       vSliceMapperVec->SetColorModeToMapScalars();
163
164 #if VTK_MAJOR_VERSION <= 5
165                 // ..
166 #else
167          _pdm->Update();
168 #endif
169          _actor->SetMapper( _pdm );
170          _actor->GetProperty()->SetOpacity( GetOpacity() );
171     }// if _active
172
173     VisibilityActor(); 
174 }
175