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()
61 printf("EED creaVtkStreamLine::Process Start \n");
68 //---------------------------Stream Lines-----------------------
69 _vPointWidget->SetInput( (vtkDataSet*) GetDataObject() );
73 _vPointWidget->AllOff();
74 _vPointWidget->PlaceWidget();
75 _vPointWidget->SetInteractor( GetRenderer()->GetRenderWindow()->GetInteractor() );
76 _source->SetNumberOfPoints(1000);
77 _source->SetRadius(5.0);
79 //EED1 _vPointWidget->On();
82 _vPointWidget->GetPosition(c);
83 _source->SetCenter( c );
86 _streamer->SetInput( GetDataObject() );
87 //EED1 _streamer->SetSource( _source->GetOutput() );
88 _streamer->SetSource( _sourcePoints );
89 _streamer->SetIntegratorTypeToRungeKutta45();
90 //EED _streamer->SetMaximumPropagation(500000);
91 _streamer->SetMaximumPropagation(500);
92 //EED _streamer->SetMaximumPropagationUnitToTimeUnit();
93 _streamer->SetInitialIntegrationStep (0.001);
94 //EED _streamer->SetInitialIntegrationStepUnitToCellLengthUnit();
95 _streamer->SetIntegrationDirectionToBoth();
96 //EED streamer->ComputeVorticityOn ();
98 // _streamer->Print(std::cout);
99 // _streamer->GetOutput()->Print(std::cout);
103 _tubefilter->SetInput( _streamer->GetOutput() );
104 _ribbonfilter->SetInput(_streamer->GetOutput());
107 _polydata->Modified();
109 printf("EED creaVtkStreamLine::Process 0 %p \n", _polydata);
111 if (GetTypeForm()==0)
113 printf("EED creaVtkStreamLine::Process 1 \n");
114 _tubefilter->SetInput( _polydata );
115 _tubefilter->SetRadius( GetScaleFactor() );
116 _tubefilter->SetNumberOfSides(12);
117 _tubefilter->SetVaryRadiusToVaryRadiusOff();
118 _tubefilter->Modified();
119 _tubefilter->Update();
120 _streamMapper2->SetInput( _tubefilter->GetOutput() );
122 if (GetTypeForm()==1)
124 printf("EED creaVtkStreamLine::Process 2 \n");
125 _ribbonfilter->SetInput( _polydata );
126 _ribbonfilter->SetWidth( GetScaleFactor() );
127 _ribbonfilter->SetWidthFactor( GetScaleFactor()*10 );
128 _ribbonfilter->GlobalWarningDisplayOff (); //EED this is to avoid the "BEVEL WARNING"
129 _ribbonfilter->Modified();
130 _ribbonfilter->Update();
131 _streamMapper2->SetInput( _ribbonfilter->GetOutput() );
133 if (GetTypeForm()==2)
135 printf("EED creaVtkStreamLine::Process 3 \n");
136 _streamMapper2->SetInput( _polydata );
138 printf("EED creaVtkStreamLine::Process 4 \n");
139 //EED _streamMapper2->SetLookupTable(vGreenToRedLut);
142 vtkDoubleArray* _velocity = vtkDoubleArray::New();
143 _velocity->SetName("velocity"); // ... fill the colors array
144 for (int ivelocity=0; ivelocity<=4000; ivelocity++ )
146 _velocity->InsertTuple3 (ivelocity, 1, 0, 0);
148 _polydata->GetPointData()->AddArray(_velocity);
150 printf("EED creaVtkStreamLine::Process A \n" );
152 vtkPointData *data = _polydata->GetPointData();
154 printf("EED -------------------------------------------\n");
155 _polydata->Print(std::cout);
156 printf("EED -------------------------------------------\n");
157 data->Print(std::cout);
158 printf("EED -------------------------------------------\n");
160 // vtkFieldData *data = _polydata->GetFieldData();
161 // vtkDataArray *da = pointdata->GetArray("Normals");
163 int i,sizeDa = data->GetNumberOfArrays();
164 printf("EED creaVtkStreamLine::Process sizeDa %d \n", sizeDa );
165 for (i=0;i<sizeDa;i++)
167 printf("EED creaVtkStreamLine::Process-name %d, %s \n", i, data->GetArrayName(i) );
168 data->GetArray(i)->Print(std::cout);
169 printf("EED -------------------------------------------\n");
176 vtkPolyDataWriter *writer3 = vtkPolyDataWriter::New();
177 writer3->SetFileName( "/home/davila/Borrame/streamline-eed-c.vtk" );
178 writer3->SetInput( _polydata );
183 // vtkDataArray *nda = vtkDoubleArray::New();
184 // nda->DeepCopy(da);
185 // pointdata->AddArray( nda );
186 // bbGetInputIn()->GetPointData()->AddArray( nda );
192 // _streamMapper2->ScalarVisibilityOff();
196 // _streamMapper2->ScalarVisibilityOn();
197 // _streamMapper2->SetScalarModeToUsePointFieldData();
198 // _streamMapper2->SetLookupTable( _LutEED );
199 // _streamMapper2->SelectColorArray( "Normals" );
203 //Config 2 Orientation vectors
204 _streamMapper2->ScalarVisibilityOn();
205 _streamMapper2->SetScalarModeToUsePointFieldData();
206 _streamMapper2->SetLookupTable( _LutEED );
210 _LutEED->SetVectorModeToRGBColors();
211 _streamMapper2->SelectColorArray( "creaColorDirection" );
215 // _LutEED->SetVectorModeToMagnitude();
216 vtkLookupTable *lookuptable = vtkLookupTable::New();
217 _streamMapper2->SetLookupTable( lookuptable );
218 _streamMapper2->SelectColorArray( "creaMagnitud" );
223 _streamMapper2->SelectColorArray( "xx" );
224 _actor->GetProperty()->SetColor(_colorR,_colorG,_colorB);
228 _vtkglyph->SetInput( GetDataObject() );
229 _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
230 _vtkglyph->SetScaleModeToScaleByVector();
231 _vtkglyph->SetColorModeToColorByVector();
232 _vtkglyph->SetScaleFactor( GetScaleFactor() );
234 _pdm->SetInput( _vtkglyph->GetOutput());
235 _pdm->SetScalarModeToUsePointFieldData();
236 _pdm->SetLookupTable( _LutEED );
237 _pdm->SelectColorArray( "GlyphVector" );
248 _actor->SetMapper( _streamMapper2 );
249 _actor->GetProperty()->SetOpacity( GetOpacity() );
255 printf("EED creaVtkStreamLine::Process End \n");