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 # ------------------------------------------------------------------------ */
29 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
31 #include "bbvtkMagnitud.h"
32 #include "bbvtkPackage.h"
36 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,Magnitud)
37 BBTK_BLACK_BOX_IMPLEMENTATION(Magnitud,bbtk::AtomicBlackBox);
39 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
41 void Magnitud::Process()
44 printf("EED Magnitud::Process Start\n");
46 // THE MAIN PROCESSING METHOD BODY
47 // Here we simply set the input 'In' value to the output 'Out'
48 // And print out the output value
49 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
50 // void bbSet{Input|Output}NAME(const TYPE&)
51 // const TYPE& bbGet{Input|Output}NAME() const
53 // * NAME is the name of the input/output
54 // (the one provided in the attribute 'name' of the tag 'input')
55 // * TYPE is the C++ type of the input/output
56 // (the one provided in the attribute 'type' of the tag 'input')
59 if (bbGetInputIn()!=NULL)
61 vGreenToRedLut->SetHueRange(0.6667,0.0);
62 vGreenToRedLut->Build();
65 //EED 2017-01-01 Migration VTK7
66 #if (VTK_MAJOR_VERSION <= 5)
67 vVecMagnitude->SetInput(bbGetInputIn());
69 #if (VTK_MAJOR_VERSION >= 6)
70 vVecMagnitude->SetInputData(bbGetInputIn());
73 vVecMagnitude->NormalizeOff();
74 vVecMagnitude->Update();
75 vVecMagnitude->GetOutput()->GetScalarRange( range1 );
76 vVecMagnitude->Update();
79 //EED 2017-01-01 Migration VTK7
80 #if (VTK_MAJOR_VERSION <= 5)
81 vMaskPoint->SetInput(bbGetInputIn());
83 #if (VTK_MAJOR_VERSION >= 6)
84 vMaskPoint->SetInputData(bbGetInputIn());
87 vMaskPoint->SetOnRatio(100);
89 vMaskPoint->RandomModeOn();
91 vGlyph->SetScaleModeToScaleByVector();
92 vGlyph->SetColorModeToColorByVector();
93 vGlyph->SetScaleFactor(0.20);
95 //EED 2017-01-01 Migration VTK7
96 #if (VTK_MAJOR_VERSION <= 5)
97 vGlyph->SetInput(vMaskPoint->GetOutput());
98 vGlyph->SetSource(cone->GetOutput());
100 #if (VTK_MAJOR_VERSION >= 6)
101 vGlyph->SetInputData(vMaskPoint->GetOutput());
103 vGlyph->SetSourceData(cone->GetOutput());
107 //EED 2017-01-01 Migration VTK7
108 #if (VTK_MAJOR_VERSION <= 5)
109 vGlyphMapper->SetInput( vGlyph->GetOutput() );
111 #if (VTK_MAJOR_VERSION >= 6)
112 vGlyphMapper->SetInputData( vGlyph->GetOutput() );
115 step = (range1[1]-range1[0])/10;
118 dRangeColorForMultipleContourVelocity[0] = 0;
119 dRangeColorForMultipleContourVelocity[1] = 1;
120 dRangeColorForGlyphVelocity[0] = 0;
121 dRangeColorForGlyphVelocity[1] = 1;
122 //EED 2017-01-01 Migration VTK7
123 #if (VTK_MAJOR_VERSION <= 5)
124 vMultipleContourVelocity->SetInput((vtkDataSet *) vVecMagnitude->GetOutput());
126 #if (VTK_MAJOR_VERSION >= 6)
127 vMultipleContourVelocity->SetInputData((vtkDataSet *) vVecMagnitude->GetOutput());
132 step = (range1[1]-range1[0])/10;
134 for( h=range1[0]; h<range1[1]; h+=step )
136 vMultipleContourVelocity->SetValue(index, h);
140 //EED 2017-01-01 Migration VTK7
141 #if (VTK_MAJOR_VERSION <= 5)
142 vMultipleContourMapper->SetInput( vMultipleContourVelocity->GetOutput() );
144 #if (VTK_MAJOR_VERSION >= 6)
145 vMultipleContourMapper->SetInputData( vMultipleContourVelocity->GetOutput() );
148 vMultipleContourMapper->SetScalarRange( range1 );
149 vMultipleContourMapper->SetLookupTable( vGreenToRedLut );
150 vMultipleContourMapper->Update();
151 vMultipleContourActor->SetMapper( vMultipleContourMapper );
152 vMultipleContourActor->GetProperty()->SetOpacity(0.4);
155 vGlyphMapper->SetLookupTable(vGreenToRedLut);
156 vGlyphMapper->SetScalarRange(range1);
157 vGlyphMapper->ImmediateModeRenderingOn();
160 //EED 2017-01-01 Migration VTK7
161 #if (VTK_MAJOR_VERSION <= 5)
162 vOutlineGrid->SetInput( bbGetInputIn() );
163 vOutlineMapper->SetInput(vOutlineGrid->GetOutput());
165 #if (VTK_MAJOR_VERSION >= 6)
166 vOutlineGrid->SetInputData( bbGetInputIn() );
167 vOutlineGrid->Update();
168 vOutlineMapper->SetInputData( vOutlineGrid->GetOutput() );
173 vOutlineActor->SetMapper(vOutlineMapper);
176 vGlyphActor->SetMapper( vGlyphMapper );
177 vGlyphActor->GetProperty()->SetOpacity(0);
179 //The Velocity Bar - Indicator (It's Actor is a vtkProper)
180 vScalarBarActor->SetLookupTable (vMultipleContourMapper->GetLookupTable());
181 vScalarBarActor->SetTitle ("Velocity");
182 vScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
183 vScalarBarActor->GetPositionCoordinate()->SetValue( 0.85, 0.25);
184 vScalarBarActor->SetOrientationToVertical();
185 vScalarBarActor->SetWidth (0.1);
186 vScalarBarActor->SetHeight (0.6);
187 vScalarBarActor->GetProperty()->SetOpacity(1); // 1 to Show - 0 to Hide
189 ///////////////////////////////////////////////////////////////////////////////////////////////////
190 //Start: Change values by the user
191 ///////////////////////////////////////////////////////////////////////////////////////////////////
193 vMaskPoint->SetOnRatio( bbGetInputMRatio());
194 vMaskPoint->Update();
197 vGlyphActor->GetProperty()->SetOpacity( bbGetInputOpactity()/100 );
198 vGlyph->SetScaleFactor(vGlyph->GetScaleFactor()-0.1);
200 vGlyph->SetScaleFactor(vGlyph->GetScaleFactor()+0.1);
202 if( (bbGetInputScale()/100)<0 )
206 if( (bbGetInputScale()/100)>1 )
211 //vGlyph->SetScaleFactor(dScale);
212 vGlyph->SetScaleFactor( bbGetInputScale()/100 );
215 //Set Glyph and Contour Colour Range
216 vVecMagnitude->GetOutput()->GetScalarRange( range1 );
217 dRangeColorForGlyphVelocity[0] = bbGetInputValInf()/100;
218 dRangeColorForGlyphVelocity[1] = bbGetInputValSup()/100;
219 dRangeColorForMultipleContourVelocity[0] = bbGetInputValInf()/100;
220 dRangeColorForMultipleContourVelocity[1] = bbGetInputValSup()/100;
221 double dTailleInterval=range1[1]-range1[0];
223 range1[1]=range1[0]+dTailleInterval*(bbGetInputValSup()/100);
224 range1[0]=range1[0]+dTailleInterval*(bbGetInputValInf()/100);
226 vGlyphMapper->SetScalarRange( range1 );
227 vMultipleContourMapper->SetScalarRange( range1 );
229 if( bbGetInputOpactity()/100<0 )
231 bbSetInputOpactity(0);
234 if( bbGetInputOpactity()/100>1 )
236 bbSetInputOpactity(1);
239 //Set Contour Opacity
240 vMultipleContourActor->GetProperty()->SetOpacity( bbGetInputOpactity()/100 );
241 vMultipleContourVelocity->SetNumberOfContours(vMultipleContourVelocity->GetNumberOfContours()+1);
242 vMultipleContourVelocity->Update();
243 vMultipleContourVelocity->SetNumberOfContours(vMultipleContourVelocity->GetNumberOfContours()-1);
244 vMultipleContourVelocity->Update();
246 //Set The Number of Contours
247 if( bbGetInputContour()<1)
249 bbSetInputContour(1);
252 step=(range1[1]-range1[0])/bbGetInputContour();
254 for( h=range1[0]; h<range1[1]; h+=step)
256 vMultipleContourVelocity->SetValue(index, h);
259 ///////////////////////////////////////////////////////////////////////////////////////////////////
260 //End: Change values by the user
261 ///////////////////////////////////////////////////////////////////////////////////////////////////
263 //EED 2017-01-01 Migration VTK7
264 #if (VTK_MAJOR_VERSION <= 5)
265 vPlaneWidget->SetInput(bbGetInputIn());
267 #if (VTK_MAJOR_VERSION >= 6)
268 vPlaneWidget->SetInputData(bbGetInputIn());
270 vPlaneWidget->NormalToXAxisOn();
271 vPlaneWidget->NormalToZAxisOn();
272 vPlaneWidget->SetResolution(1);
273 vPlaneWidget->SetRepresentationToOutline();
274 //vPlaneWidget->SetInteractor(vIren);
275 vPlaneWidget->SetPlaceFactor(1); //défini zoom initial
276 vPlaneWidget->PlaceWidget();
279 vPlaneWidget->GetOrigin(p0);
280 vPlaneWidget->GetCenter(c); //These is fromvtkImageMathematics Execute Method
281 vPlaneWidget->GetNormal(n);
282 vPlaneWidget->GetPoint1(p1);
283 vPlaneWidget->GetPoint2(p2);
285 c[0] = c[0]+ bbGetInputMoveX();
286 c[1] = c[1]+ bbGetInputMoveY();
287 c[2] = c[2]+ bbGetInputMoveZ();
289 vPlanSource->SetResolution( sizeIma-1, sizeIma-1);
290 vPlanSource->SetOrigin( p0 );
291 vPlanSource->SetPoint1( p1 );
292 vPlanSource->SetPoint2( p2 );
293 vPlanSource->Update( );
294 vPlanSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
295 vPlanSource->Update( );
296 vPlanSource->SetCenter( c );
297 vPlanSource->Update( );
299 vDiskSourceEED->SetInnerRadius (0);
300 vDiskSourceEED->SetOuterRadius (10);
301 vDiskSourceEED->SetRadialResolution (20);
302 vDiskSourceEED->SetCircumferentialResolution (20);
305 //EED 2017-01-01 Migration VTK7
306 #if (VTK_MAJOR_VERSION <= 5)
307 vPointWidget->SetInput( bbGetInputIn() );
309 #if (VTK_MAJOR_VERSION >= 6)
310 vPointWidget->SetInputData( bbGetInputIn() );
313 vPointWidget->AllOff();
314 vPointWidget->PlaceWidget();
315 //vPointWidget->SetInteractor(vIren);
317 //vPointWidget->GetPolyData(point);
318 vPointWidget->GetPolyData(point);
319 source->SetNumberOfPoints(500);
321 tempc = bbGetInputPlaneCenterSL();
322 slCenter[0] = tempc[0];
323 slCenter[1] = tempc[1];
324 slCenter[2] = tempc[2];
325 source->SetCenter( slCenter );
327 source->SetCenter( c );
328 source->SetRadius(5.0);
330 //EED 2017-01-01 Migration VTK7
331 #if (VTK_MAJOR_VERSION <= 5)
332 streamer->SetInput( bbGetInputIn() );
333 streamer->SetSource(source->GetOutput());
335 #if (VTK_MAJOR_VERSION >= 6)
336 streamer->SetInputData( bbGetInputIn() );
337 streamer->SetSourceData( source->GetOutput() );
340 streamer->SetIntegratorTypeToRungeKutta45();
341 streamer->SetMaximumPropagation(500000);
342 //EED streamer->SetMaximumPropagationUnitToTimeUnit ();
343 streamer->SetInitialIntegrationStep (0.001);
344 //EED streamer->SetInitialIntegrationStepUnitToCellLengthUnit();
345 streamer->SetIntegrationDirectionToBoth();
346 //EED streamer->ComputeVorticityOn ();
349 //EED 2017-01-01 Migration VTK7
350 #if (VTK_MAJOR_VERSION <= 5)
351 rf->SetInput(streamer->GetOutput());
353 #if (VTK_MAJOR_VERSION >= 6)
354 rf->SetInputData(streamer->GetOutput());
358 rf->SetNumberOfSides(12);
359 rf->SetVaryRadiusToVaryRadiusOff();
361 streamer->GetOutput()->GetScalarRange( range );
363 //EED 2017-01-01 Migration VTK7
364 #if (VTK_MAJOR_VERSION <= 5)
365 streamMapper2->SetInput(rf->GetOutput());
367 #if (VTK_MAJOR_VERSION >= 6)
368 streamMapper2->SetInputData(rf->GetOutput());
371 streamMapper2->SetLookupTable(vGreenToRedLut);
372 //vStreamlineActor2->SetMapper( streamMapper2 );
374 //////////////////////////////////////////////////////////////////////////////////////
375 //Start: Part of the Execute Method
376 //////////////////////////////////////////////////////////////////////////////////////
380 alfa = atan2(ny,nx) * 180.0 / 3.1416;
381 beta = atan2( nz, sqrt( nx*nx + ny*ny ) ) * 180.0 / 3.1416;
382 transformEED->Identity();
383 transformEED->Translate(c);
384 transformEED->RotateWXYZ(alfa,0,0,1);
385 transformEED->RotateWXYZ(-beta,0,1,0);
386 transformEED->RotateWXYZ(90,0,1,0);
387 transformEED->Update();
388 //////////////////////////////////////////////////////////////////////////////////////
389 //End: Part of the Execute Method
390 //////////////////////////////////////////////////////////////////////////////////////
392 vtransformpolydatafilter->SetTransform( transformEED );
395 //EED 2017-01-01 Migration VTK7
396 #if (VTK_MAJOR_VERSION <= 5)
397 vtransformpolydatafilter->SetInput( vDiskSourceEED->GetOutput() );
398 vProbeslices->SetInput( ( vtkDataSet* )vtransformpolydatafilter->GetOutput());
399 vProbeslices->SetSource( bbGetInputIn() );
400 vGlyphFlowPlane->SetInput( vProbeslices->GetOutput() );
401 vGlyphFlowPlane->SetSource( vArrowSource->GetOutput() );
403 #if (VTK_MAJOR_VERSION >= 6)
404 vtransformpolydatafilter->SetInputData( vDiskSourceEED->GetOutput() );
405 vProbeslices->SetInputData( ( vtkDataSet* )vtransformpolydatafilter->GetOutput());
406 vProbeslices->SetSourceData( bbGetInputIn() );
407 vGlyphFlowPlane->SetInputData( vProbeslices->GetOutput() );
408 vArrowSource->Update();
409 vGlyphFlowPlane->SetSourceData( vArrowSource->GetOutput() );
412 vtransformpolydatafilter->Update();
413 vProbeslices->Update( );
416 vGlyphFlowPlane->SetScaleModeToScaleByVector();
417 vGlyphFlowPlane->SetColorModeToColorByVector();
418 vGlyphFlowPlane->SetScaleFactor(0.2);
419 vGlyphFlowPlane->Update();
422 //EED 2017-01-01 Migration VTK7
423 #if (VTK_MAJOR_VERSION <= 5)
424 vProbeslicesFlowWidget->SetInput( ( vtkDataSet* )vPlanSource->GetOutput());
425 vProbeslicesFlowWidget->SetSource( vVecMagnitude->GetOutput() );
427 #if (VTK_MAJOR_VERSION >= 6)
428 vProbeslicesFlowWidget->SetInputData( ( vtkDataSet* )vPlanSource->GetOutput());
429 vVecMagnitude->Update();
430 vProbeslicesFlowWidget->SetSourceData( vVecMagnitude->GetOutput() );
433 vProbeslicesFlowWidget->Update( );
435 vVecMagnitude->GetOutput()->GetScalarRange( range );
438 //EED 2017-01-01 Migration VTK7
439 #if (VTK_MAJOR_VERSION <= 5)
440 vAppendDataForFlowWidgetVisualisation->AddInput(vGlyphFlowPlane->GetOutput());
441 vAppendDataForFlowWidgetVisualisation->AddInput(vProbeslicesFlowWidget->GetPolyDataOutput());
442 vSliceMapper->SetInput( vAppendDataForFlowWidgetVisualisation->GetOutput());
444 #if (VTK_MAJOR_VERSION >= 6)
445 vGlyphFlowPlane->Update();
446 vProbeslicesFlowWidget->Update();
447 vAppendDataForFlowWidgetVisualisation->AddInputData( vGlyphFlowPlane->GetOutput() );
448 vAppendDataForFlowWidgetVisualisation->AddInputData( vProbeslicesFlowWidget->GetPolyDataOutput() );
449 vSliceMapper->SetInputData( vAppendDataForFlowWidgetVisualisation->GetOutput() );
452 vSliceMapper->SetScalarRange( range );
453 vSliceMapper->SetLookupTable( vGreenToRedLut );
455 vSliceActor->SetMapper( vSliceMapper );
457 if(bbGetInputShowPlane() == 1)
460 } else if(bbGetInputShowPlane() == 0) {
464 vSliceActor->GetProperty()->SetOpacity( bbGetInputShowPlane() );
466 exporter->SetInputConnection( vMultipleContourMapper->GetOutputPort() );
467 exporter->ImageLowerLeftOn();
469 bbSetOutputOut1( vSliceActor );
470 bbSetOutputOut2( vGlyphActor );
471 bbSetOutputOut3( vOutlineActor );
472 bbSetOutputOut4( vMultipleContourActor );
474 // bbSetOutputOut5( vScalarBarActor );
476 if(bbGetInputShowStream() == 1)
478 vStreamlineActor2->SetMapper( streamMapper2 );
480 vStreamlineActor2->SetMapper( NULL );
482 bbSetOutputOut5( vStreamlineActor2 );
483 //bbSetOutputOut5( vStreamlineActor2 );
484 //bbSetOutputOutExport( exporter );
485 //temp->GetData( (vtkInformation*) vMultipleContourVelocity->GetOutput() );
486 //temp->GetData( vMultipleContourMapper->GetOutput() );
487 //bbSetOutputOutTest( temp );
490 printf("EED Magnitud::Process End\n");
498 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
500 void Magnitud::bbUserSetDefaultValues()
503 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
504 // Here we initialize the input 'In' to 0
512 bbSetInputMRatio(100);
513 bbSetInputOpactity(0.5);
514 bbSetInputScale(0.2);
515 bbSetInputContour(10);
516 bbSetInputShowPlane(1);
517 bbSetInputShowStream(0);
518 //bbSetInputPlaneCenterSL();
522 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
524 void Magnitud::bbUserInitializeProcessing()
527 // THE INITIALIZATION METHOD BODY :
529 // but this is where you should allocate the internal/output pointers
533 cone = vtkArrowSource::New();
534 exporter = vtkImageExport::New();
535 point = vtkPolyData::New();
536 rf = vtkTubeFilter::New();
537 source = vtkPointSource::New();
538 streamer = vtkStreamTracer::New();
539 streamMapper2 = vtkPolyDataMapper::New();
541 transformEED = vtkTransform::New();
542 vAppendDataForFlowWidgetVisualisation = vtkAppendPolyData::New();
543 vArrowSource = vtkArrowSource::New();
544 vDiskSourceEED = vtkDiskSource::New();
545 vGlyph = vtkGlyph3D::New();
546 vGlyphActor = vtkActor::New();
547 vGlyphFlowPlane = vtkGlyph3D::New();
548 vGlyphMapper = vtkPolyDataMapper::New();
549 vGreenToRedLut = vtkLookupTable::New();
550 // vIren = vtkRenderWindowInteractor::New();
551 vMaskPoint = vtkMaskPoints::New();
552 vMultipleContourActor = vtkActor::New();
553 vMultipleContourMapper = vtkPolyDataMapper::New();
554 vMultipleContourVelocity = vtkContourFilter::New();
555 vOutlineActor = vtkActor::New();
556 vOutlineGrid = vtkOutlineFilter::New();
557 vOutlineMapper = vtkPolyDataMapper::New();
558 vPlanSource = vtkPlaneSource::New();
559 vPlaneWidget = vtkPlaneWidget::New();
560 vPointWidget = vtkPointWidget::New();
561 vProbeslices = vtkProbeFilter::New();
562 vProbeslicesFlowWidget = vtkProbeFilter::New();
563 vScalarBarActor = vtkScalarBarActor::New();
564 vSliceMapper = vtkPolyDataMapper::New();
565 vSliceActor = vtkActor::New();
566 vStreamlineActor2 = vtkActor::New();
567 vtransformpolydatafilter = vtkTransformPolyDataFilter::New();
568 vVecMagnitude = vtkVectorNorm::New();
570 temp = vtkImageData::New();
572 sizeIma = SIZEPLANWIDGET;
576 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
578 void Magnitud::bbUserFinalizeProcessing()
581 // THE FINALIZATION METHOD BODY :
583 // but this is where you should desallocate the internal/output pointers
586 /// \TODO delete everything no longer needed!
590 // EO namespace bbvtk