2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------
28 #include "creaVtkStreamLine.h"
30 #include "vtkPointData.h"
31 #include "vtkRenderWindow.h"
32 #include "vtkProperty.h"
33 #include "vtkPolyDataWriter.h"
36 creaVtkStreamLine::creaVtkStreamLine()
38 // _source = vtkPointSource::New();
39 // _vPointWidget = vtkPointWidget::New();
40 _streamMapper2 = vtkPolyDataMapper::New();
41 _tubefilter = vtkTubeFilter::New();
42 _ribbonfilter = vtkRibbonFilter::New();
46 //---------------------------------------------
47 creaVtkStreamLine::~creaVtkStreamLine()
52 //---------------------------------------------
53 void creaVtkStreamLine::SetPolyData( vtkPolyData* polydata)
58 //---------------------------------------------
59 void creaVtkStreamLine::Process()
67 //---------------------------Stream Lines-----------------------
68 _vPointWidget->SetInput( (vtkDataSet*) GetDataObject() );
72 _vPointWidget->AllOff();
73 _vPointWidget->PlaceWidget();
74 _vPointWidget->SetInteractor( GetRenderer()->GetRenderWindow()->GetInteractor() );
75 _source->SetNumberOfPoints(1000);
76 _source->SetRadius(5.0);
78 //EED1 _vPointWidget->On();
81 _vPointWidget->GetPosition(c);
82 _source->SetCenter( c );
85 _streamer->SetInput( GetDataObject() );
86 //EED1 _streamer->SetSource( _source->GetOutput() );
87 _streamer->SetSource( _sourcePoints );
88 _streamer->SetIntegratorTypeToRungeKutta45();
89 //EED _streamer->SetMaximumPropagation(500000);
90 _streamer->SetMaximumPropagation(500);
91 //EED _streamer->SetMaximumPropagationUnitToTimeUnit();
92 _streamer->SetInitialIntegrationStep (0.001);
93 //EED _streamer->SetInitialIntegrationStepUnitToCellLengthUnit();
94 _streamer->SetIntegrationDirectionToBoth();
95 //EED streamer->ComputeVorticityOn ();
97 // _streamer->Print(std::cout);
98 // _streamer->GetOutput()->Print(std::cout);
102 _tubefilter->SetInput( _streamer->GetOutput() );
103 _ribbonfilter->SetInput(_streamer->GetOutput());
106 _polydata->Modified();
109 if (GetTypeForm()==0)
111 //EED 2017-01-01 Migration VTK7
112 #if VTK_MAJOR_VERSION <= 5
113 _tubefilter->SetInput( _polydata );
115 _tubefilter->SetInputData( _polydata );
117 _tubefilter->SetRadius( GetScaleFactor() );
118 _tubefilter->SetNumberOfSides(12);
119 _tubefilter->SetVaryRadiusToVaryRadiusOff();
120 _tubefilter->Modified();
121 _tubefilter->Update();
122 //EED 2017-01-01 Migration VTK7
123 #if VTK_MAJOR_VERSION <= 5
124 _streamMapper2->SetInput( _tubefilter->GetOutput() );
126 _streamMapper2->SetInputData( _tubefilter->GetOutput() );
129 if (GetTypeForm()==1)
131 //EED 2017-01-01 Migration VTK7
132 #if VTK_MAJOR_VERSION <= 5
133 _ribbonfilter->SetInput( _polydata );
135 _ribbonfilter->SetInputData( _polydata );
137 _ribbonfilter->SetWidth( GetScaleFactor() );
138 _ribbonfilter->SetWidthFactor( GetScaleFactor()*10 );
139 _ribbonfilter->GlobalWarningDisplayOff (); //EED this is to avoid the "BEVEL WARNING"
140 _ribbonfilter->Modified();
141 _ribbonfilter->Update();
143 //EED 2017-01-01 Migration VTK7
144 #if VTK_MAJOR_VERSION <= 5
145 _streamMapper2->SetInput( _ribbonfilter->GetOutput() );
147 _streamMapper2->SetInputData( _ribbonfilter->GetOutput() );
150 if (GetTypeForm()==2)
152 //EED 2017-01-01 Migration VTK7
153 #if VTK_MAJOR_VERSION <= 5
154 _streamMapper2->SetInput( _polydata );
156 _streamMapper2->SetInputData( _polydata );
159 //EED _streamMapper2->SetLookupTable(vGreenToRedLut);
162 vtkDoubleArray* _velocity = vtkDoubleArray::New();
163 _velocity->SetName("velocity"); // ... fill the colors array
164 for (int ivelocity=0; ivelocity<=4000; ivelocity++ )
166 _velocity->InsertTuple3 (ivelocity, 1, 0, 0);
168 _polydata->GetPointData()->AddArray(_velocity);
172 // vtkFieldData *data = _polydata->GetFieldData();
173 // vtkDataArray *da = pointdata->GetArray("Normals");
175 // vtkPointData *data = _polydata->GetPointData();
176 // int i,sizeDa = data->GetNumberOfArrays();
177 // printf("EED creaVtkStreamLine::Process sizeDa %d \n", sizeDa );
178 // for (i=0;i<sizeDa;i++)
180 // printf("EED creaVtkStreamLine::Process-name %d, %s \n", i, data->GetArrayName(i) );
181 // data->GetArray(i)->Print(std::cout);
188 vtkPolyDataWriter *writer3 = vtkPolyDataWriter::New();
189 writer3->SetFileName( "/home/davila/Borrame/streamline-eed-c.vtk" );
190 writer3->SetInput( _polydata );
195 // vtkDataArray *nda = vtkDoubleArray::New();
196 // nda->DeepCopy(da);
197 // pointdata->AddArray( nda );
198 // bbGetInputIn()->GetPointData()->AddArray( nda );
204 // _streamMapper2->ScalarVisibilityOff();
208 // _streamMapper2->ScalarVisibilityOn();
209 // _streamMapper2->SetScalarModeToUsePointFieldData();
210 // _streamMapper2->SetLookupTable( _LutEED );
211 // _streamMapper2->SelectColorArray( "Normals" );
215 //Config 2 Orientation vectors
216 _streamMapper2->ScalarVisibilityOn();
217 _streamMapper2->SetScalarModeToUsePointFieldData();
218 _streamMapper2->SetLookupTable( _LutEED );
222 _LutEED->SetVectorModeToRGBColors();
223 _streamMapper2->SelectColorArray( "creaColorDirection" );
227 // _LutEED->SetVectorModeToMagnitude();
228 vtkLookupTable *lookuptable = vtkLookupTable::New();
229 _streamMapper2->SetLookupTable( lookuptable );
230 _streamMapper2->SelectColorArray( "creaMagnitud" );
235 _streamMapper2->SelectColorArray( "xx" );
236 _actor->GetProperty()->SetColor(_colorR,_colorG,_colorB);
240 _vtkglyph->SetInput( GetDataObject() );
241 _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
242 _vtkglyph->SetScaleModeToScaleByVector();
243 _vtkglyph->SetColorModeToColorByVector();
244 _vtkglyph->SetScaleFactor( GetScaleFactor() );
246 _pdm->SetInput( _vtkglyph->GetOutput());
247 _pdm->SetScalarModeToUsePointFieldData();
248 _pdm->SetLookupTable( _LutEED );
249 _pdm->SelectColorArray( "GlyphVector" );
260 _actor->SetMapper( _streamMapper2 );
261 _actor->GetProperty()->SetOpacity( GetOpacity() );