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 if (bbGetInputIn()!=NULL) {
31 vGreenToRedLut->SetHueRange(0.6667,0.0);
32 vGreenToRedLut->Build();
35 vVecMagnitude->SetInput(bbGetInputIn());
36 vVecMagnitude->NormalizeOff();
37 vVecMagnitude->Update();
38 vVecMagnitude->GetOutput()->GetScalarRange( range1 );
39 vVecMagnitude->Update();
42 vMaskPoint->SetInput(bbGetInputIn());
43 vMaskPoint->SetOnRatio(100);
45 vMaskPoint->RandomModeOn();
47 vGlyph->SetInput(vMaskPoint->GetOutput());
48 vGlyph->SetSource(cone->GetOutput());
49 vGlyph->SetScaleModeToScaleByVector();
50 vGlyph->SetColorModeToColorByVector();
51 vGlyph->SetScaleFactor(0.20);
52 vGlyphMapper->SetInput( vGlyph->GetOutput() );
53 step = (range1[1]-range1[0])/10;
56 dRangeColorForMultipleContourVelocity[0]=0;
57 dRangeColorForMultipleContourVelocity[1]=1;
58 dRangeColorForGlyphVelocity[0]=0;
59 dRangeColorForGlyphVelocity[1]=1;
60 vMultipleContourVelocity->SetInput((vtkDataSet *) vVecMagnitude->GetOutput());
64 step = (range1[1]-range1[0])/10;
66 for( h=range1[0]; h<range1[1]; h+=step )
68 vMultipleContourVelocity->SetValue(index, h);
72 vMultipleContourMapper->SetInput( vMultipleContourVelocity->GetOutput() );
73 vMultipleContourMapper->SetScalarRange( range1 );
74 vMultipleContourMapper->SetLookupTable( vGreenToRedLut );
75 vMultipleContourMapper->Update();
76 vMultipleContourActor->SetMapper( vMultipleContourMapper );
77 vMultipleContourActor->GetProperty()->SetOpacity(0.4);
80 vGlyphMapper->SetLookupTable(vGreenToRedLut);
81 vGlyphMapper->SetScalarRange(range1);
82 vGlyphMapper->ImmediateModeRenderingOn();
85 vOutlineGrid->SetInput( bbGetInputIn() );
86 vOutlineMapper->SetInput(vOutlineGrid->GetOutput());
89 vOutlineActor->SetMapper(vOutlineMapper);
92 vGlyphActor->SetMapper( vGlyphMapper );
93 vGlyphActor->GetProperty()->SetOpacity(0);
95 //The Velocity Bar - Indicator (It's Actor is a vtkProper)
96 vScalarBarActor->SetLookupTable (vMultipleContourMapper->GetLookupTable());
97 vScalarBarActor->SetTitle ("Velocity");
98 vScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
99 vScalarBarActor->GetPositionCoordinate()->SetValue( 0.85, 0.25);
100 vScalarBarActor->SetOrientationToVertical();
101 vScalarBarActor->SetWidth (0.1);
102 vScalarBarActor->SetHeight (0.6);
103 vScalarBarActor->GetProperty()->SetOpacity(1); // 1 to Show - 0 to Hide
105 ///////////////////////////////////////////////////////////////////////////////////////////////////
106 //Start: Change values by the user
107 ///////////////////////////////////////////////////////////////////////////////////////////////////
109 vMaskPoint->SetOnRatio( bbGetInputMRatio());
110 vMaskPoint->Update();
113 vGlyphActor->GetProperty()->SetOpacity( bbGetInputOpactity()/100 );
114 vGlyph->SetScaleFactor(vGlyph->GetScaleFactor()-0.1);
116 vGlyph->SetScaleFactor(vGlyph->GetScaleFactor()+0.1);
118 if( (bbGetInputScale()/100)<0 )
120 if( (bbGetInputScale()/100)>1 )
123 //vGlyph->SetScaleFactor(dScale);
124 vGlyph->SetScaleFactor( bbGetInputScale()/100 );
127 //Set Glyph and Contour Colour Range
128 vVecMagnitude->GetOutput()->GetScalarRange( range1 );
129 dRangeColorForGlyphVelocity[0] = bbGetInputValInf()/100;
130 dRangeColorForGlyphVelocity[1] = bbGetInputValSup()/100;
131 dRangeColorForMultipleContourVelocity[0] = bbGetInputValInf()/100;
132 dRangeColorForMultipleContourVelocity[1] = bbGetInputValSup()/100;
133 double dTailleInterval=range1[1]-range1[0];
135 range1[1]=range1[0]+dTailleInterval*(bbGetInputValSup()/100);
136 range1[0]=range1[0]+dTailleInterval*(bbGetInputValInf()/100);
138 vGlyphMapper->SetScalarRange( range1 );
139 vMultipleContourMapper->SetScalarRange( range1 );
141 if( bbGetInputOpactity()/100<0 )
142 bbSetInputOpactity(0);
143 if( bbGetInputOpactity()/100>1 )
144 bbSetInputOpactity(1);
146 //Set Contour Opacity
147 vMultipleContourActor->GetProperty()->SetOpacity( bbGetInputOpactity()/100 );
148 vMultipleContourVelocity->SetNumberOfContours(vMultipleContourVelocity->GetNumberOfContours()+1);
149 vMultipleContourVelocity->Update();
150 vMultipleContourVelocity->SetNumberOfContours(vMultipleContourVelocity->GetNumberOfContours()-1);
151 vMultipleContourVelocity->Update();
153 //Set The Number of Contours
154 if( bbGetInputContour()<1)
155 bbSetInputContour(1);
157 step=(range1[1]-range1[0])/bbGetInputContour();
159 for( h=range1[0]; h<range1[1]; h+=step)
161 vMultipleContourVelocity->SetValue(index, h);
164 ///////////////////////////////////////////////////////////////////////////////////////////////////
165 //End: Change values by the user
166 ///////////////////////////////////////////////////////////////////////////////////////////////////
168 vPlaneWidget->SetInput(bbGetInputIn());
169 vPlaneWidget->NormalToXAxisOn();
170 vPlaneWidget->NormalToZAxisOn();
171 vPlaneWidget->SetResolution(1);
172 vPlaneWidget->SetRepresentationToOutline();
173 //vPlaneWidget->SetInteractor(vIren);
174 vPlaneWidget->SetPlaceFactor(1); //défini zoom initial
175 vPlaneWidget->PlaceWidget();
178 vPlaneWidget->GetOrigin(p0);
179 vPlaneWidget->GetCenter(c); //These is from Execute Method
180 vPlaneWidget->GetNormal(n);
181 vPlaneWidget->GetPoint1(p1);
182 vPlaneWidget->GetPoint2(p2);
184 c[0] = c[0]+ bbGetInputMoveX();
185 c[1] = c[1]+ bbGetInputMoveY();
186 c[2] = c[2]+ bbGetInputMoveZ();
188 vPlanSource->SetResolution( sizeIma-1, sizeIma-1);
189 vPlanSource->SetOrigin( p0 );
190 vPlanSource->SetPoint1( p1 );
191 vPlanSource->SetPoint2( p2 );
192 vPlanSource->Update( );
193 vPlanSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
194 vPlanSource->Update( );
195 vPlanSource->SetCenter( c );
196 vPlanSource->Update( );
198 vDiskSourceEED->SetInnerRadius (0);
199 vDiskSourceEED->SetOuterRadius (10);
200 vDiskSourceEED->SetRadialResolution (20);
201 vDiskSourceEED->SetCircumferentialResolution (20);
204 vPointWidget->SetInput( bbGetInputIn() );
205 vPointWidget->AllOff();
206 vPointWidget->PlaceWidget();
207 //vPointWidget->SetInteractor(vIren);
209 //vPointWidget->GetPolyData(point);
210 vPointWidget->GetPolyData(point);
211 source->SetNumberOfPoints(500);
213 tempc = bbGetInputPlaneCenterSL();
214 slCenter[0] = tempc[0];
215 slCenter[1] = tempc[1];
216 slCenter[2] = tempc[2];
217 source->SetCenter( slCenter );
219 source->SetCenter( c );
220 source->SetRadius(5.0);
222 streamer->SetInput( bbGetInputIn() );
223 streamer->SetSource(source->GetOutput());
224 streamer->SetIntegratorTypeToRungeKutta45();
225 streamer->SetMaximumPropagation(500000);
226 //EED streamer->SetMaximumPropagationUnitToTimeUnit ();
227 streamer->SetInitialIntegrationStep (0.001);
228 //EED streamer->SetInitialIntegrationStepUnitToCellLengthUnit();
229 streamer->SetIntegrationDirectionToBoth();
230 //EED streamer->ComputeVorticityOn ();
233 rf->SetInput(streamer->GetOutput());
235 rf->SetNumberOfSides(12);
236 rf->SetVaryRadiusToVaryRadiusOff();
238 streamer->GetOutput()->GetScalarRange( range );
239 streamMapper2->SetInput(rf->GetOutput());
240 streamMapper2->SetLookupTable(vGreenToRedLut);
241 //vStreamlineActor2->SetMapper( streamMapper2 );
243 //////////////////////////////////////////////////////////////////////////////////////
244 //Start: Part of the Execute Method
245 //////////////////////////////////////////////////////////////////////////////////////
249 alfa = atan2(ny,nx) * 180.0 / 3.1416;
250 beta = atan2( nz, sqrt( nx*nx + ny*ny ) ) * 180.0 / 3.1416;
251 transformEED->Identity();
252 transformEED->Translate(c);
253 transformEED->RotateWXYZ(alfa,0,0,1);
254 transformEED->RotateWXYZ(-beta,0,1,0);
255 transformEED->RotateWXYZ(90,0,1,0);
256 transformEED->Update();
257 //////////////////////////////////////////////////////////////////////////////////////
258 //End: Part of the Execute Method
259 //////////////////////////////////////////////////////////////////////////////////////
261 vtransformpolydatafilter->SetInput( vDiskSourceEED->GetOutput() );
262 vtransformpolydatafilter->SetTransform( transformEED );
263 vtransformpolydatafilter->Update();
265 vProbeslices->SetInput( ( vtkDataSet* )vtransformpolydatafilter->GetOutput());
266 vProbeslices->SetSource( bbGetInputIn() );
267 vProbeslices->Update( );
269 vGlyphFlowPlane->SetInput(vProbeslices->GetOutput());
270 vGlyphFlowPlane->SetSource(vArrowSource->GetOutput());
271 vGlyphFlowPlane->SetScaleModeToScaleByVector();
272 vGlyphFlowPlane->SetColorModeToColorByVector();
273 vGlyphFlowPlane->SetScaleFactor(0.2);
274 vGlyphFlowPlane->Update();
276 vProbeslicesFlowWidget->SetInput( ( vtkDataSet* )vPlanSource->GetOutput());
277 vProbeslicesFlowWidget->SetSource( vVecMagnitude->GetOutput() );
278 vProbeslicesFlowWidget->Update( );
280 vVecMagnitude->GetOutput()->GetScalarRange( range );
282 vAppendDataForFlowWidgetVisualisation->AddInput(vGlyphFlowPlane->GetOutput());
283 vAppendDataForFlowWidgetVisualisation->AddInput(vProbeslicesFlowWidget->GetPolyDataOutput());
285 vSliceMapper->SetInput( vAppendDataForFlowWidgetVisualisation->GetOutput());
286 vSliceMapper->SetScalarRange( range );
287 vSliceMapper->SetLookupTable( vGreenToRedLut );
289 vSliceActor->SetMapper( vSliceMapper );
291 if(bbGetInputShowPlane() == 1)
293 else if(bbGetInputShowPlane() == 0)
296 vSliceActor->GetProperty()->SetOpacity( bbGetInputShowPlane() );
298 exporter->SetInputConnection( vMultipleContourMapper->GetOutputPort() );
299 exporter->ImageLowerLeftOn();
301 bbSetOutputOut1( vSliceActor );
302 bbSetOutputOut2( vGlyphActor );
303 bbSetOutputOut3( vOutlineActor );
304 bbSetOutputOut4( vMultipleContourActor );
305 //bbSetOutputOut5( vScalarBarActor );
306 if(bbGetInputShowStream() == 1)
307 vStreamlineActor2->SetMapper( streamMapper2 );
309 vStreamlineActor2->SetMapper( NULL );
311 bbSetOutputOut5( vStreamlineActor2 );
312 //bbSetOutputOut5( vStreamlineActor2 );
313 //bbSetOutputOutExport( exporter );
314 //temp->GetData( (vtkInformation*) vMultipleContourVelocity->GetOutput() );
315 //temp->GetData( vMultipleContourMapper->GetOutput() );
316 //bbSetOutputOutTest( temp );
326 // 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)
328 void Magnitud::bbUserSetDefaultValues()
331 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
332 // Here we initialize the input 'In' to 0
340 bbSetInputMRatio(100);
341 bbSetInputOpactity(0.5);
342 bbSetInputScale(0.2);
343 bbSetInputContour(10);
344 bbSetInputShowPlane(1);
345 bbSetInputShowStream(0);
346 //bbSetInputPlaneCenterSL();
350 // 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)
352 void Magnitud::bbUserInitializeProcessing()
355 // THE INITIALIZATION METHOD BODY :
357 // but this is where you should allocate the internal/output pointers
361 cone = vtkArrowSource::New();
362 exporter = vtkImageExport::New();
363 point = vtkPolyData::New();
364 rf = vtkTubeFilter::New();
365 source = vtkPointSource::New();
366 streamer = vtkStreamTracer::New();
367 streamMapper2 = vtkPolyDataMapper::New();
369 transformEED = vtkTransform::New();
370 vAppendDataForFlowWidgetVisualisation = vtkAppendPolyData::New();
371 vArrowSource = vtkArrowSource::New();
372 vDiskSourceEED = vtkDiskSource::New();
373 vGlyph = vtkGlyph3D::New();
374 vGlyphActor = vtkActor::New();
375 vGlyphFlowPlane = vtkGlyph3D::New();
376 vGlyphMapper = vtkPolyDataMapper::New();
377 vGreenToRedLut = vtkLookupTable::New();
378 vIren = vtkRenderWindowInteractor::New();
379 vMaskPoint = vtkMaskPoints::New();
380 vMultipleContourActor = vtkActor::New();
381 vMultipleContourMapper = vtkPolyDataMapper::New();
382 vMultipleContourVelocity = vtkContourFilter::New();
383 vOutlineActor = vtkActor::New();
384 vOutlineGrid = vtkOutlineFilter::New();
385 vOutlineMapper = vtkPolyDataMapper::New();
386 vPlanSource = vtkPlaneSource::New();
387 vPlaneWidget = vtkPlaneWidget::New();
388 vPointWidget = vtkPointWidget::New();
389 vProbeslices = vtkProbeFilter::New();
390 vProbeslicesFlowWidget = vtkProbeFilter::New();
391 vScalarBarActor = vtkScalarBarActor::New();
392 vSliceMapper = vtkPolyDataMapper::New();
393 vSliceActor = vtkActor::New();
394 vStreamlineActor2 = vtkActor::New();
395 vtransformpolydatafilter = vtkTransformPolyDataFilter::New();
396 vVecMagnitude = vtkVectorNorm::New();
398 temp = vtkImageData::New();
400 sizeIma = SIZEPLANWIDGET;
404 // 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)
406 void Magnitud::bbUserFinalizeProcessing()
409 // THE FINALIZATION METHOD BODY :
411 // but this is where you should desallocate the internal/output pointers
414 /// \TODO delete everything no longer needed!
418 // EO namespace bbvtk