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"
34 creaVtkStreamLine::creaVtkStreamLine()
36 _source = vtkPointSource::New();
37 _vPointWidget = vtkPointWidget::New();
38 _streamMapper2 = vtkPolyDataMapper::New();
39 _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::Process()
61 printf("creaVtkStreamLine::Process Start \n");
63 { //bbGetInputPlaneFieldShow
66 //---------------------------Stream Lines-----------------------
67 _vPointWidget->SetInput( (vtkDataSet*) GetDataObject() );
71 _vPointWidget->AllOff();
72 _vPointWidget->PlaceWidget();
73 _vPointWidget->SetInteractor( GetRenderer()->GetRenderWindow()->GetInteractor() );
74 _source->SetNumberOfPoints(1000);
75 _source->SetRadius(5.0);
77 //EED1 _vPointWidget->On();
81 _vPointWidget->GetPosition(c);
82 _source->SetCenter( c );
85 _streamer->SetInput( GetDataObject() );
87 //EED1 _streamer->SetSource( _source->GetOutput() );
88 _streamer->SetSource( _sourcePoints );
90 _streamer->SetIntegratorTypeToRungeKutta45();
92 //EED _streamer->SetMaximumPropagation(500000);
93 _streamer->SetMaximumPropagation(500);
94 //EED _streamer->SetMaximumPropagationUnitToTimeUnit();
96 _streamer->SetInitialIntegrationStep (0.001);
97 //EED _streamer->SetInitialIntegrationStepUnitToCellLengthUnit();
99 _streamer->SetIntegrationDirectionToBoth();
100 //EED streamer->ComputeVorticityOn ();
102 printf("EED creaVtkStreamLine::Process StreamLine PrintSelf\n");
103 _streamer->Print(std::cout);
106 _tubefilter->SetInput(_streamer->GetOutput());
107 _tubefilter->SetRadius( GetScaleFactor() );
108 _tubefilter->SetNumberOfSides(12);
109 _tubefilter->SetVaryRadiusToVaryRadiusOff();
111 _ribbonfilter->SetInput(_streamer->GetOutput());
112 _ribbonfilter->SetWidth( GetScaleFactor() );
113 _ribbonfilter->SetWidthFactor( GetScaleFactor()*10 );
114 _ribbonfilter->GlobalWarningDisplayOff (); //EED this is to avoid the "BEVEL WARNING"
116 //BORRAME _streamer->GetOutput()->GetScalarRange( range );
117 if (GetTypeForm()==0) {
118 _streamMapper2->SetInput( _tubefilter->GetOutput() );
120 _streamMapper2->SetInput( _ribbonfilter->GetOutput() );
122 //EED _streamMapper2->SetLookupTable(vGreenToRedLut);
125 vtkPolyData *pd = _streamer->GetOutput();
126 vtkPointData *pointdata = pd->GetPointData();
127 // vtkDataArray *da = pointdata->GetArray("Normals");
129 int i,sizeDa = pointdata->GetNumberOfArrays();
130 printf("EED creaVtkStreamLine::Process sizeDa %d \n", sizeDa );
131 for (i=0;i<sizeDa;i++)
133 printf("EED creaVtkStreamLine::Process-name %d, %s \n", i, pointdata->GetArrayName(i) );
136 // vtkDataArray *nda = vtkDoubleArray::New();
137 // nda->DeepCopy(da);
138 // pointdata->AddArray( nda );
139 // bbGetInputIn()->GetPointData()->AddArray( nda );
145 // _streamMapper2->ScalarVisibilityOff();
149 // _streamMapper2->ScalarVisibilityOn();
150 // _streamMapper2->SetScalarModeToUsePointFieldData();
151 // _streamMapper2->SetLookupTable( vLutEED );
152 // _streamMapper2->SelectColorArray( "Normals" );
155 //Config 2 Orientation vectors
156 _streamMapper2->ScalarVisibilityOn();
157 _streamMapper2->SetScalarModeToUsePointFieldData();
158 _streamMapper2->SetLookupTable( _LutEED );
159 _streamMapper2->SelectColorArray( "velocity" );
167 _actor->SetMapper( _streamMapper2 );
169 _actor->GetProperty()->SetOpacity( GetOpacity() );