2 // 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)
4 #include "bbvtkMagnitud.h"
5 #include "bbvtkPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,Magnitud)
10 BBTK_BLACK_BOX_IMPLEMENTATION(Magnitud,bbtk::AtomicBlackBox);
12 // 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)
14 void Magnitud::Process()
17 // THE MAIN PROCESSING METHOD BODY
18 // Here we simply set the input 'In' value to the output 'Out'
19 // And print out the output value
20 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
21 // void bbSet{Input|Output}NAME(const TYPE&)
22 // const TYPE& bbGet{Input|Output}NAME() const
24 // * NAME is the name of the input/output
25 // (the one provided in the attribute 'name' of the tag 'input')
26 // * TYPE is the C++ type of the input/output
27 // (the one provided in the attribute 'type' of the tag 'input')
30 vGreenToRedLut->SetHueRange(0.6667,0.0);
31 vGreenToRedLut->Build();
34 vVecMagnitude->SetInput(bbGetInputIn());
35 vVecMagnitude->NormalizeOff();
36 vVecMagnitude->Update();
37 vVecMagnitude->GetOutput()->GetScalarRange( range1 );
38 vVecMagnitude->Update();
41 vMaskPoint->SetInput(bbGetInputIn());
42 vMaskPoint->SetOnRatio(100);
44 vMaskPoint->RandomModeOn();
46 vGlyph->SetInput(vMaskPoint->GetOutput());
47 vGlyph->SetSource(cone->GetOutput());
48 vGlyph->SetScaleModeToScaleByVector();
49 vGlyph->SetColorModeToColorByVector();
50 vGlyph->SetScaleFactor(0.20);
51 vGlyphMapper->SetInput( vGlyph->GetOutput() );
52 step = (range1[1]-range1[0])/10;
55 dRangeColorForMultipleContourVelocity[0]=0;
56 dRangeColorForMultipleContourVelocity[1]=1;
57 dRangeColorForGlyphVelocity[0]=0;
58 dRangeColorForGlyphVelocity[1]=1;
59 vMultipleContourVelocity->SetInput((vtkDataSet *) vVecMagnitude->GetOutput());
63 step = (range1[1]-range1[0])/10;
65 for( h=range1[0]; h<range1[1]; h+=step )
67 vMultipleContourVelocity->SetValue(index, h);
71 vMultipleContourMapper->SetInput( vMultipleContourVelocity->GetOutput() );
72 vMultipleContourMapper->SetScalarRange( range1 );
73 vMultipleContourMapper->SetLookupTable( vGreenToRedLut );
74 vMultipleContourMapper->Update();
75 vMultipleContourActor->SetMapper( vMultipleContourMapper );
76 vMultipleContourActor->GetProperty()->SetOpacity(0.4);
79 vGlyphMapper->SetLookupTable(vGreenToRedLut);
80 vGlyphMapper->SetScalarRange(range1);
81 vGlyphMapper->ImmediateModeRenderingOn();
84 vOutlineGrid->SetInput( bbGetInputIn() );
85 vOutlineMapper->SetInput(vOutlineGrid->GetOutput());
88 vOutlineActor->SetMapper(vOutlineMapper);
91 vGlyphActor->SetMapper( vGlyphMapper );
92 vGlyphActor->GetProperty()->SetOpacity(0);
94 //The Velocity Bar - Indicator (It's Actor is a vtkProper)
95 vScalarBarActor->SetLookupTable (vMultipleContourMapper->GetLookupTable());
96 vScalarBarActor->SetTitle ("Velocity");
97 vScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
98 vScalarBarActor->GetPositionCoordinate()->SetValue( 0.85, 0.25);
99 vScalarBarActor->SetOrientationToVertical();
100 vScalarBarActor->SetWidth (0.1);
101 vScalarBarActor->SetHeight (0.6);
102 vScalarBarActor->GetProperty()->SetOpacity(1); // 1 to Show - 0 to Hide
104 ///////////////////////////////////////////////////////////////////////////////////////////////////
105 //Start: Change values by the user
106 ///////////////////////////////////////////////////////////////////////////////////////////////////
108 vMaskPoint->SetOnRatio( bbGetInputMRatio());
109 vMaskPoint->Update();
112 vGlyphActor->GetProperty()->SetOpacity( bbGetInputOpactity()/100 );
113 vGlyph->SetScaleFactor(vGlyph->GetScaleFactor()-0.1);
115 vGlyph->SetScaleFactor(vGlyph->GetScaleFactor()+0.1);
117 if( (bbGetInputScale()/100)<0 )
119 if( (bbGetInputScale()/100)>1 )
122 //vGlyph->SetScaleFactor(dScale);
123 vGlyph->SetScaleFactor( bbGetInputScale()/100 );
126 //Set Glyph and Contour Colour Range
127 vVecMagnitude->GetOutput()->GetScalarRange( range1 );
128 dRangeColorForGlyphVelocity[0] = bbGetInputValInf()/100;
129 dRangeColorForGlyphVelocity[1] = bbGetInputValSup()/100;
130 dRangeColorForMultipleContourVelocity[0] = bbGetInputValInf()/100;
131 dRangeColorForMultipleContourVelocity[1] = bbGetInputValSup()/100;
132 double dTailleInterval=range1[1]-range1[0];
134 range1[1]=range1[0]+dTailleInterval*(bbGetInputValSup()/100);
135 range1[0]=range1[0]+dTailleInterval*(bbGetInputValInf()/100);
137 vGlyphMapper->SetScalarRange( range1 );
138 vMultipleContourMapper->SetScalarRange( range1 );
140 if( bbGetInputOpactity()/100<0 )
141 bbSetInputOpactity(0);
142 if( bbGetInputOpactity()/100>1 )
143 bbSetInputOpactity(1);
145 //Set Contour Opacity
146 vMultipleContourActor->GetProperty()->SetOpacity( bbGetInputOpactity()/100 );
147 vMultipleContourVelocity->SetNumberOfContours(vMultipleContourVelocity->GetNumberOfContours()+1);
148 vMultipleContourVelocity->Update();
149 vMultipleContourVelocity->SetNumberOfContours(vMultipleContourVelocity->GetNumberOfContours()-1);
150 vMultipleContourVelocity->Update();
152 //Set The Number of Contours
153 if( bbGetInputContour()<1)
154 bbSetInputContour(1);
156 step=(range1[1]-range1[0])/bbGetInputContour();
158 for( h=range1[0]; h<range1[1]; h+=step)
160 vMultipleContourVelocity->SetValue(index, h);
163 ///////////////////////////////////////////////////////////////////////////////////////////////////
164 //End: Change values by the user
165 ///////////////////////////////////////////////////////////////////////////////////////////////////
167 vPlaneWidget->SetInput(bbGetInputIn());
168 vPlaneWidget->NormalToXAxisOn();
169 vPlaneWidget->NormalToZAxisOn();
170 vPlaneWidget->SetResolution(1);
171 vPlaneWidget->SetRepresentationToOutline();
172 //vPlaneWidget->SetInteractor(vIren);
173 vPlaneWidget->SetPlaceFactor(1); //défini zoom initial
174 vPlaneWidget->PlaceWidget();
177 vPlaneWidget->GetOrigin(p0);
178 vPlaneWidget->GetCenter(c); //These is from Execute Method
179 vPlaneWidget->GetNormal(n);
180 vPlaneWidget->GetPoint1(p1);
181 vPlaneWidget->GetPoint2(p2);
183 c[0] = c[0]+ bbGetInputMoveX();
184 c[1] = c[1]+ bbGetInputMoveY();
185 c[2] = c[2]+ bbGetInputMoveZ();
187 vPlanSource->SetResolution( sizeIma-1, sizeIma-1);
188 vPlanSource->SetOrigin( p0 );
189 vPlanSource->SetPoint1( p1 );
190 vPlanSource->SetPoint2( p2 );
191 vPlanSource->Update( );
192 vPlanSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
193 vPlanSource->Update( );
194 vPlanSource->SetCenter( c );
195 vPlanSource->Update( );
197 vDiskSourceEED->SetInnerRadius (0);
198 vDiskSourceEED->SetOuterRadius (10);
199 vDiskSourceEED->SetRadialResolution (20);
200 vDiskSourceEED->SetCircumferentialResolution (20);
203 vPointWidget->SetInput( bbGetInputIn() );
204 vPointWidget->AllOff();
205 vPointWidget->PlaceWidget();
206 //vPointWidget->SetInteractor(vIren);
208 //vPointWidget->GetPolyData(point);
209 vPointWidget->GetPolyData(point);
210 source->SetNumberOfPoints(500);
212 tempc = bbGetInputPlaneCenterSL();
213 slCenter[0] = tempc[0];
214 slCenter[1] = tempc[1];
215 slCenter[2] = tempc[2];
216 source->SetCenter( slCenter );
218 source->SetCenter( c );
219 source->SetRadius(5.0);
221 streamer->SetInput( bbGetInputIn() );
222 streamer->SetSource(source->GetOutput());
223 streamer->SetIntegratorTypeToRungeKutta45();
224 streamer->SetMaximumPropagation(500000);
225 //EED streamer->SetMaximumPropagationUnitToTimeUnit ();
226 streamer->SetInitialIntegrationStep (0.001);
227 //EED streamer->SetInitialIntegrationStepUnitToCellLengthUnit();
228 streamer->SetIntegrationDirectionToBoth();
229 //EED streamer->ComputeVorticityOn ();
232 rf->SetInput(streamer->GetOutput());
234 rf->SetNumberOfSides(12);
235 rf->SetVaryRadiusToVaryRadiusOff();
237 streamer->GetOutput()->GetScalarRange( range );
238 streamMapper2->SetInput(rf->GetOutput());
239 streamMapper2->SetLookupTable(vGreenToRedLut);
240 //vStreamlineActor2->SetMapper( streamMapper2 );
242 //////////////////////////////////////////////////////////////////////////////////////
243 //Start: Part of the Execute Method
244 //////////////////////////////////////////////////////////////////////////////////////
248 alfa = atan2(ny,nx) * 180.0 / 3.1416;
249 beta = atan2( nz, sqrt( nx*nx + ny*ny ) ) * 180.0 / 3.1416;
250 transformEED->Identity();
251 transformEED->Translate(c);
252 transformEED->RotateWXYZ(alfa,0,0,1);
253 transformEED->RotateWXYZ(-beta,0,1,0);
254 transformEED->RotateWXYZ(90,0,1,0);
255 transformEED->Update();
256 //////////////////////////////////////////////////////////////////////////////////////
257 //End: Part of the Execute Method
258 //////////////////////////////////////////////////////////////////////////////////////
260 vtransformpolydatafilter->SetInput( vDiskSourceEED->GetOutput() );
261 vtransformpolydatafilter->SetTransform( transformEED );
262 vtransformpolydatafilter->Update();
264 vProbeslices->SetInput( ( vtkDataSet* )vtransformpolydatafilter->GetOutput());
265 vProbeslices->SetSource( bbGetInputIn() );
266 vProbeslices->Update( );
268 vGlyphFlowPlane->SetInput(vProbeslices->GetOutput());
269 vGlyphFlowPlane->SetSource(vArrowSource->GetOutput());
270 vGlyphFlowPlane->SetScaleModeToScaleByVector();
271 vGlyphFlowPlane->SetColorModeToColorByVector();
272 vGlyphFlowPlane->SetScaleFactor(0.2);
273 vGlyphFlowPlane->Update();
275 vProbeslicesFlowWidget->SetInput( ( vtkDataSet* )vPlanSource->GetOutput());
276 vProbeslicesFlowWidget->SetSource( vVecMagnitude->GetOutput() );
277 vProbeslicesFlowWidget->Update( );
279 vVecMagnitude->GetOutput()->GetScalarRange( range );
281 vAppendDataForFlowWidgetVisualisation->AddInput(vGlyphFlowPlane->GetOutput());
282 vAppendDataForFlowWidgetVisualisation->AddInput(vProbeslicesFlowWidget->GetPolyDataOutput());
284 vSliceMapper->SetInput( vAppendDataForFlowWidgetVisualisation->GetOutput());
285 vSliceMapper->SetScalarRange( range );
286 vSliceMapper->SetLookupTable( vGreenToRedLut );
288 vSliceActor->SetMapper( vSliceMapper );
290 if(bbGetInputShowPlane() == 1)
292 else if(bbGetInputShowPlane() == 0)
295 vSliceActor->GetProperty()->SetOpacity( bbGetInputShowPlane() );
297 exporter->SetInputConnection( vMultipleContourMapper->GetOutputPort() );
298 exporter->ImageLowerLeftOn();
300 bbSetOutputOut1( vSliceActor );
301 bbSetOutputOut2( vGlyphActor );
302 bbSetOutputOut3( vOutlineActor );
303 bbSetOutputOut4( vMultipleContourActor );
304 //bbSetOutputOut5( vScalarBarActor );
305 if(bbGetInputShowStream() == 1)
306 vStreamlineActor2->SetMapper( streamMapper2 );
308 vStreamlineActor2->SetMapper( NULL );
310 bbSetOutputOut5( vStreamlineActor2 );
311 //bbSetOutputOut5( vStreamlineActor2 );
312 //bbSetOutputOutExport( exporter );
313 //temp->GetData( (vtkInformation*) vMultipleContourVelocity->GetOutput() );
314 //temp->GetData( vMultipleContourMapper->GetOutput() );
315 //bbSetOutputOutTest( temp );
320 // 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)
322 void Magnitud::bbUserSetDefaultValues()
325 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
326 // Here we initialize the input 'In' to 0
334 bbSetInputMRatio(100);
335 bbSetInputOpactity(0.5);
336 bbSetInputScale(0.2);
337 bbSetInputContour(10);
338 bbSetInputShowPlane(1);
339 bbSetInputShowStream(0);
340 //bbSetInputPlaneCenterSL();
344 // 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)
346 void Magnitud::bbUserInitializeProcessing()
349 // THE INITIALIZATION METHOD BODY :
351 // but this is where you should allocate the internal/output pointers
355 cone = vtkArrowSource::New();
356 exporter = vtkImageExport::New();
357 point = vtkPolyData::New();
358 rf = vtkTubeFilter::New();
359 source = vtkPointSource::New();
360 streamer = vtkStreamTracer::New();
361 streamMapper2 = vtkPolyDataMapper::New();
363 transformEED = vtkTransform::New();
364 vAppendDataForFlowWidgetVisualisation = vtkAppendPolyData::New();
365 vArrowSource = vtkArrowSource::New();
366 vDiskSourceEED = vtkDiskSource::New();
367 vGlyph = vtkGlyph3D::New();
368 vGlyphActor = vtkActor::New();
369 vGlyphFlowPlane = vtkGlyph3D::New();
370 vGlyphMapper = vtkPolyDataMapper::New();
371 vGreenToRedLut = vtkLookupTable::New();
372 vIren = vtkRenderWindowInteractor::New();
373 vMaskPoint = vtkMaskPoints::New();
374 vMultipleContourActor = vtkActor::New();
375 vMultipleContourMapper = vtkPolyDataMapper::New();
376 vMultipleContourVelocity = vtkContourFilter::New();
377 vOutlineActor = vtkActor::New();
378 vOutlineGrid = vtkOutlineFilter::New();
379 vOutlineMapper = vtkPolyDataMapper::New();
380 vPlanSource = vtkPlaneSource::New();
381 vPlaneWidget = vtkPlaneWidget::New();
382 vPointWidget = vtkPointWidget::New();
383 vProbeslices = vtkProbeFilter::New();
384 vProbeslicesFlowWidget = vtkProbeFilter::New();
385 vScalarBarActor = vtkScalarBarActor::New();
386 vSliceMapper = vtkPolyDataMapper::New();
387 vSliceActor = vtkActor::New();
388 vStreamlineActor2 = vtkActor::New();
389 vtransformpolydatafilter = vtkTransformPolyDataFilter::New();
390 vVecMagnitude = vtkVectorNorm::New();
392 temp = vtkImageData::New();
394 sizeIma = SIZEPLANWIDGET;
398 // 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)
400 void Magnitud::bbUserFinalizeProcessing()
403 // THE FINALIZATION METHOD BODY :
405 // but this is where you should desallocate the internal/output pointers
408 /// \TODO delete everything no longer needed!
412 // EO namespace bbvtk