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 _tubefilter->SetInput( _polydata );
112 _tubefilter->SetRadius( GetScaleFactor() );
113 _tubefilter->SetNumberOfSides(12);
114 _tubefilter->SetVaryRadiusToVaryRadiusOff();
115 _tubefilter->Modified();
116 _tubefilter->Update();
117 _streamMapper2->SetInput( _tubefilter->GetOutput() );
119 if (GetTypeForm()==1)
121 _ribbonfilter->SetInput( _polydata );
122 _ribbonfilter->SetWidth( GetScaleFactor() );
123 _ribbonfilter->SetWidthFactor( GetScaleFactor()*10 );
124 _ribbonfilter->GlobalWarningDisplayOff (); //EED this is to avoid the "BEVEL WARNING"
125 _ribbonfilter->Modified();
126 _ribbonfilter->Update();
127 _streamMapper2->SetInput( _ribbonfilter->GetOutput() );
129 if (GetTypeForm()==2)
131 _streamMapper2->SetInput( _polydata );
133 //EED _streamMapper2->SetLookupTable(vGreenToRedLut);
136 vtkDoubleArray* _velocity = vtkDoubleArray::New();
137 _velocity->SetName("velocity"); // ... fill the colors array
138 for (int ivelocity=0; ivelocity<=4000; ivelocity++ )
140 _velocity->InsertTuple3 (ivelocity, 1, 0, 0);
142 _polydata->GetPointData()->AddArray(_velocity);
146 // vtkFieldData *data = _polydata->GetFieldData();
147 // vtkDataArray *da = pointdata->GetArray("Normals");
149 // vtkPointData *data = _polydata->GetPointData();
150 // int i,sizeDa = data->GetNumberOfArrays();
151 // printf("EED creaVtkStreamLine::Process sizeDa %d \n", sizeDa );
152 // for (i=0;i<sizeDa;i++)
154 // printf("EED creaVtkStreamLine::Process-name %d, %s \n", i, data->GetArrayName(i) );
155 // data->GetArray(i)->Print(std::cout);
162 vtkPolyDataWriter *writer3 = vtkPolyDataWriter::New();
163 writer3->SetFileName( "/home/davila/Borrame/streamline-eed-c.vtk" );
164 writer3->SetInput( _polydata );
169 // vtkDataArray *nda = vtkDoubleArray::New();
170 // nda->DeepCopy(da);
171 // pointdata->AddArray( nda );
172 // bbGetInputIn()->GetPointData()->AddArray( nda );
178 // _streamMapper2->ScalarVisibilityOff();
182 // _streamMapper2->ScalarVisibilityOn();
183 // _streamMapper2->SetScalarModeToUsePointFieldData();
184 // _streamMapper2->SetLookupTable( _LutEED );
185 // _streamMapper2->SelectColorArray( "Normals" );
189 //Config 2 Orientation vectors
190 _streamMapper2->ScalarVisibilityOn();
191 _streamMapper2->SetScalarModeToUsePointFieldData();
192 _streamMapper2->SetLookupTable( _LutEED );
196 _LutEED->SetVectorModeToRGBColors();
197 _streamMapper2->SelectColorArray( "creaColorDirection" );
201 // _LutEED->SetVectorModeToMagnitude();
202 vtkLookupTable *lookuptable = vtkLookupTable::New();
203 _streamMapper2->SetLookupTable( lookuptable );
204 _streamMapper2->SelectColorArray( "creaMagnitud" );
209 _streamMapper2->SelectColorArray( "xx" );
210 _actor->GetProperty()->SetColor(_colorR,_colorG,_colorB);
214 _vtkglyph->SetInput( GetDataObject() );
215 _vtkglyph->SetSource( _vtkarrowsource->GetOutput() );
216 _vtkglyph->SetScaleModeToScaleByVector();
217 _vtkglyph->SetColorModeToColorByVector();
218 _vtkglyph->SetScaleFactor( GetScaleFactor() );
220 _pdm->SetInput( _vtkglyph->GetOutput());
221 _pdm->SetScalarModeToUsePointFieldData();
222 _pdm->SetLookupTable( _LutEED );
223 _pdm->SelectColorArray( "GlyphVector" );
234 _actor->SetMapper( _streamMapper2 );
235 _actor->GetProperty()->SetOpacity( GetOpacity() );