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"
35 creaVtkStreamLine::creaVtkStreamLine()
37 _source = vtkPointSource::New();
38 _vPointWidget = vtkPointWidget::New();
39 _streamMapper2 = vtkPolyDataMapper::New();
40 _streamer = vtkStreamTracer::New();
41 _tubefilter = vtkTubeFilter::New();
42 _ribbonfilter = vtkRibbonFilter::New();
46 //---------------------------------------------
47 creaVtkStreamLine::~creaVtkStreamLine()
51 //---------------------------------------------
52 void creaVtkStreamLine::SetSourcePoints( vtkDataSet* sourcepoints)
54 _sourcePoints = sourcepoints;
57 //---------------------------------------------
58 void creaVtkStreamLine::SetPolyData( vtkPolyData* polydata)
63 //---------------------------------------------
64 void creaVtkStreamLine::Process()
66 printf("EED creaVtkStreamLine::Process Start \n");
71 { //bbGetInputPlaneFieldShow
76 //---------------------------Stream Lines-----------------------
77 _vPointWidget->SetInput( (vtkDataSet*) GetDataObject() );
81 _vPointWidget->AllOff();
82 _vPointWidget->PlaceWidget();
83 _vPointWidget->SetInteractor( GetRenderer()->GetRenderWindow()->GetInteractor() );
84 _source->SetNumberOfPoints(1000);
85 _source->SetRadius(5.0);
87 //EED1 _vPointWidget->On();
90 _vPointWidget->GetPosition(c);
91 _source->SetCenter( c );
94 _streamer->SetInput( GetDataObject() );
95 //EED1 _streamer->SetSource( _source->GetOutput() );
96 _streamer->SetSource( _sourcePoints );
97 _streamer->SetIntegratorTypeToRungeKutta45();
98 //EED _streamer->SetMaximumPropagation(500000);
99 _streamer->SetMaximumPropagation(500);
100 //EED _streamer->SetMaximumPropagationUnitToTimeUnit();
101 _streamer->SetInitialIntegrationStep (0.001);
102 //EED _streamer->SetInitialIntegrationStepUnitToCellLengthUnit();
103 _streamer->SetIntegrationDirectionToBoth();
104 //EED streamer->ComputeVorticityOn ();
106 // _streamer->Print(std::cout);
107 // _streamer->GetOutput()->Print(std::cout);
110 //vtkPolyDataWriter *writer3 = vtkPolyDataWriter::New();
111 //writer3->SetFileName( "/home/davila/Borrame/streamline-eed.vtk" );
112 //writer3->SetInput( _streamer->GetOutput() );
116 _tubefilter->SetInput( _streamer->GetOutput() );
117 _ribbonfilter->SetInput(_streamer->GetOutput());
120 _tubefilter->SetInput( _polydata );
121 _ribbonfilter->SetInput( _polydata );
124 _tubefilter->SetRadius( GetScaleFactor() );
125 _tubefilter->SetNumberOfSides(12);
126 _tubefilter->SetVaryRadiusToVaryRadiusOff();
128 _ribbonfilter->SetWidth( GetScaleFactor() );
129 _ribbonfilter->SetWidthFactor( GetScaleFactor()*10 );
130 _ribbonfilter->GlobalWarningDisplayOff (); //EED this is to avoid the "BEVEL WARNING"
132 _polydata->Modified();
133 //BORRAME _streamer->GetOutput()->GetScalarRange( range );
134 if (GetTypeForm()==0)
136 _streamMapper2->SetInput( _tubefilter->GetOutput() );
138 if (GetTypeForm()==1)
140 _streamMapper2->SetInput( _ribbonfilter->GetOutput() );
142 if (GetTypeForm()==2)
144 _streamMapper2->SetInput( _polydata );
146 //EED _streamMapper2->SetLookupTable(vGreenToRedLut);
150 vtkPolyData *pd = _streamer->GetOutput();
151 vtkPointData *pointdata = pd->GetPointData();
152 // vtkDataArray *da = pointdata->GetArray("Normals");
154 int i,sizeDa = pointdata->GetNumberOfArrays();
155 printf("EED creaVtkStreamLine::Process sizeDa %d \n", sizeDa );
156 for (i=0;i<sizeDa;i++)
158 printf("EED creaVtkStreamLine::Process-name %d, %s \n", i, pointdata->GetArrayName(i) );
163 // vtkDataArray *nda = vtkDoubleArray::New();
164 // nda->DeepCopy(da);
165 // pointdata->AddArray( nda );
166 // bbGetInputIn()->GetPointData()->AddArray( nda );
172 // _streamMapper2->ScalarVisibilityOff();
176 // _streamMapper2->ScalarVisibilityOn();
177 // _streamMapper2->SetScalarModeToUsePointFieldData();
178 // _streamMapper2->SetLookupTable( vLutEED );
179 // _streamMapper2->SelectColorArray( "Normals" );
182 //Config 2 Orientation vectors
183 _streamMapper2->ScalarVisibilityOn();
184 _streamMapper2->SetScalarModeToUsePointFieldData();
185 _streamMapper2->SetLookupTable( _LutEED );
186 _streamMapper2->SelectColorArray( "velocity" );
191 _actor->SetMapper( _streamMapper2 );
192 _actor->GetProperty()->SetOpacity( GetOpacity() );