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')
31 if (bbGetInputIn()!=NULL) {
32 vGreenToRedLut->SetHueRange(0.6667,0.0);
33 vGreenToRedLut->Build();
36 vVecMagnitude->SetInput(bbGetInputIn());
37 vVecMagnitude->NormalizeOff();
38 vVecMagnitude->Update();
39 vVecMagnitude->GetOutput()->GetScalarRange( range1 );
40 vVecMagnitude->Update();
43 vMaskPoint->SetInput(bbGetInputIn());
44 vMaskPoint->SetOnRatio(100);
46 vMaskPoint->RandomModeOn();
48 vGlyph->SetInput(vMaskPoint->GetOutput());
49 vGlyph->SetSource(cone->GetOutput());
50 vGlyph->SetScaleModeToScaleByVector();
51 vGlyph->SetColorModeToColorByVector();
52 vGlyph->SetScaleFactor(0.20);
53 vGlyphMapper->SetInput( vGlyph->GetOutput() );
54 step = (range1[1]-range1[0])/10;
57 dRangeColorForMultipleContourVelocity[0]=0;
58 dRangeColorForMultipleContourVelocity[1]=1;
59 dRangeColorForGlyphVelocity[0]=0;
60 dRangeColorForGlyphVelocity[1]=1;
61 vMultipleContourVelocity->SetInput((vtkDataSet *) vVecMagnitude->GetOutput());
65 step = (range1[1]-range1[0])/10;
67 for( h=range1[0]; h<range1[1]; h+=step )
69 vMultipleContourVelocity->SetValue(index, h);
73 vMultipleContourMapper->SetInput( vMultipleContourVelocity->GetOutput() );
74 vMultipleContourMapper->SetScalarRange( range1 );
75 vMultipleContourMapper->SetLookupTable( vGreenToRedLut );
76 vMultipleContourMapper->Update();
77 vMultipleContourActor->SetMapper( vMultipleContourMapper );
78 vMultipleContourActor->GetProperty()->SetOpacity(0.4);
81 vGlyphMapper->SetLookupTable(vGreenToRedLut);
82 vGlyphMapper->SetScalarRange(range1);
83 vGlyphMapper->ImmediateModeRenderingOn();
86 vOutlineGrid->SetInput( bbGetInputIn() );
87 vOutlineMapper->SetInput(vOutlineGrid->GetOutput());
90 vOutlineActor->SetMapper(vOutlineMapper);
93 vGlyphActor->SetMapper( vGlyphMapper );
94 vGlyphActor->GetProperty()->SetOpacity(0);
96 //The Velocity Bar - Indicator (It's Actor is a vtkProper)
97 vScalarBarActor->SetLookupTable (vMultipleContourMapper->GetLookupTable());
98 vScalarBarActor->SetTitle ("Velocity");
99 vScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
100 vScalarBarActor->GetPositionCoordinate()->SetValue( 0.85, 0.25);
101 vScalarBarActor->SetOrientationToVertical();
102 vScalarBarActor->SetWidth (0.1);
103 vScalarBarActor->SetHeight (0.6);
104 vScalarBarActor->GetProperty()->SetOpacity(1); // 1 to Show - 0 to Hide
106 ///////////////////////////////////////////////////////////////////////////////////////////////////
107 //Start: Change values by the user
108 ///////////////////////////////////////////////////////////////////////////////////////////////////
110 vMaskPoint->SetOnRatio( bbGetInputMRatio());
111 vMaskPoint->Update();
114 vGlyphActor->GetProperty()->SetOpacity( bbGetInputOpactity()/100 );
115 vGlyph->SetScaleFactor(vGlyph->GetScaleFactor()-0.1);
117 vGlyph->SetScaleFactor(vGlyph->GetScaleFactor()+0.1);
119 if( (bbGetInputScale()/100)<0 )
121 if( (bbGetInputScale()/100)>1 )
124 //vGlyph->SetScaleFactor(dScale);
125 vGlyph->SetScaleFactor( bbGetInputScale()/100 );
128 //Set Glyph and Contour Colour Range
129 vVecMagnitude->GetOutput()->GetScalarRange( range1 );
130 dRangeColorForGlyphVelocity[0] = bbGetInputValInf()/100;
131 dRangeColorForGlyphVelocity[1] = bbGetInputValSup()/100;
132 dRangeColorForMultipleContourVelocity[0] = bbGetInputValInf()/100;
133 dRangeColorForMultipleContourVelocity[1] = bbGetInputValSup()/100;
134 double dTailleInterval=range1[1]-range1[0];
136 range1[1]=range1[0]+dTailleInterval*(bbGetInputValSup()/100);
137 range1[0]=range1[0]+dTailleInterval*(bbGetInputValInf()/100);
139 vGlyphMapper->SetScalarRange( range1 );
140 vMultipleContourMapper->SetScalarRange( range1 );
142 if( bbGetInputOpactity()/100<0 )
143 bbSetInputOpactity(0);
144 if( bbGetInputOpactity()/100>1 )
145 bbSetInputOpactity(1);
147 //Set Contour Opacity
148 vMultipleContourActor->GetProperty()->SetOpacity( bbGetInputOpactity()/100 );
149 vMultipleContourVelocity->SetNumberOfContours(vMultipleContourVelocity->GetNumberOfContours()+1);
150 vMultipleContourVelocity->Update();
151 vMultipleContourVelocity->SetNumberOfContours(vMultipleContourVelocity->GetNumberOfContours()-1);
152 vMultipleContourVelocity->Update();
154 //Set The Number of Contours
155 if( bbGetInputContour()<1)
156 bbSetInputContour(1);
158 step=(range1[1]-range1[0])/bbGetInputContour();
160 for( h=range1[0]; h<range1[1]; h+=step)
162 vMultipleContourVelocity->SetValue(index, h);
165 ///////////////////////////////////////////////////////////////////////////////////////////////////
166 //End: Change values by the user
167 ///////////////////////////////////////////////////////////////////////////////////////////////////
169 vPlaneWidget->SetInput(bbGetInputIn());
170 vPlaneWidget->NormalToXAxisOn();
171 vPlaneWidget->NormalToZAxisOn();
172 vPlaneWidget->SetResolution(1);
173 vPlaneWidget->SetRepresentationToOutline();
174 //vPlaneWidget->SetInteractor(vIren);
175 vPlaneWidget->SetPlaceFactor(1); //défini zoom initial
176 vPlaneWidget->PlaceWidget();
179 vPlaneWidget->GetOrigin(p0);
180 vPlaneWidget->GetCenter(c); //These is from Execute Method
181 vPlaneWidget->GetNormal(n);
182 vPlaneWidget->GetPoint1(p1);
183 vPlaneWidget->GetPoint2(p2);
185 c[0] = c[0]+ bbGetInputMoveX();
186 c[1] = c[1]+ bbGetInputMoveY();
187 c[2] = c[2]+ bbGetInputMoveZ();
189 vPlanSource->SetResolution( sizeIma-1, sizeIma-1);
190 vPlanSource->SetOrigin( p0 );
191 vPlanSource->SetPoint1( p1 );
192 vPlanSource->SetPoint2( p2 );
193 vPlanSource->Update( );
194 vPlanSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
195 vPlanSource->Update( );
196 vPlanSource->SetCenter( c );
197 vPlanSource->Update( );
199 vDiskSourceEED->SetInnerRadius (0);
200 vDiskSourceEED->SetOuterRadius (10);
201 vDiskSourceEED->SetRadialResolution (20);
202 vDiskSourceEED->SetCircumferentialResolution (20);
205 vPointWidget->SetInput( bbGetInputIn() );
206 vPointWidget->AllOff();
207 vPointWidget->PlaceWidget();
208 //vPointWidget->SetInteractor(vIren);
210 //vPointWidget->GetPolyData(point);
211 vPointWidget->GetPolyData(point);
212 source->SetNumberOfPoints(500);
214 tempc = bbGetInputPlaneCenterSL();
215 slCenter[0] = tempc[0];
216 slCenter[1] = tempc[1];
217 slCenter[2] = tempc[2];
218 source->SetCenter( slCenter );
220 source->SetCenter( c );
221 source->SetRadius(5.0);
223 streamer->SetInput( bbGetInputIn() );
224 streamer->SetSource(source->GetOutput());
225 streamer->SetIntegratorTypeToRungeKutta45();
226 streamer->SetMaximumPropagation(500000);
227 //EED streamer->SetMaximumPropagationUnitToTimeUnit ();
228 streamer->SetInitialIntegrationStep (0.001);
229 //EED streamer->SetInitialIntegrationStepUnitToCellLengthUnit();
230 streamer->SetIntegrationDirectionToBoth();
231 //EED streamer->ComputeVorticityOn ();
234 rf->SetInput(streamer->GetOutput());
236 rf->SetNumberOfSides(12);
237 rf->SetVaryRadiusToVaryRadiusOff();
239 streamer->GetOutput()->GetScalarRange( range );
240 streamMapper2->SetInput(rf->GetOutput());
241 streamMapper2->SetLookupTable(vGreenToRedLut);
242 //vStreamlineActor2->SetMapper( streamMapper2 );
244 //////////////////////////////////////////////////////////////////////////////////////
245 //Start: Part of the Execute Method
246 //////////////////////////////////////////////////////////////////////////////////////
250 alfa = atan2(ny,nx) * 180.0 / 3.1416;
251 beta = atan2( nz, sqrt( nx*nx + ny*ny ) ) * 180.0 / 3.1416;
252 transformEED->Identity();
253 transformEED->Translate(c);
254 transformEED->RotateWXYZ(alfa,0,0,1);
255 transformEED->RotateWXYZ(-beta,0,1,0);
256 transformEED->RotateWXYZ(90,0,1,0);
257 transformEED->Update();
258 //////////////////////////////////////////////////////////////////////////////////////
259 //End: Part of the Execute Method
260 //////////////////////////////////////////////////////////////////////////////////////
262 vtransformpolydatafilter->SetInput( vDiskSourceEED->GetOutput() );
263 vtransformpolydatafilter->SetTransform( transformEED );
264 vtransformpolydatafilter->Update();
266 vProbeslices->SetInput( ( vtkDataSet* )vtransformpolydatafilter->GetOutput());
267 vProbeslices->SetSource( bbGetInputIn() );
268 vProbeslices->Update( );
270 vGlyphFlowPlane->SetInput(vProbeslices->GetOutput());
271 vGlyphFlowPlane->SetSource(vArrowSource->GetOutput());
272 vGlyphFlowPlane->SetScaleModeToScaleByVector();
273 vGlyphFlowPlane->SetColorModeToColorByVector();
274 vGlyphFlowPlane->SetScaleFactor(0.2);
275 vGlyphFlowPlane->Update();
277 vProbeslicesFlowWidget->SetInput( ( vtkDataSet* )vPlanSource->GetOutput());
278 vProbeslicesFlowWidget->SetSource( vVecMagnitude->GetOutput() );
279 vProbeslicesFlowWidget->Update( );
281 vVecMagnitude->GetOutput()->GetScalarRange( range );
283 vAppendDataForFlowWidgetVisualisation->AddInput(vGlyphFlowPlane->GetOutput());
284 vAppendDataForFlowWidgetVisualisation->AddInput(vProbeslicesFlowWidget->GetPolyDataOutput());
286 vSliceMapper->SetInput( vAppendDataForFlowWidgetVisualisation->GetOutput());
287 vSliceMapper->SetScalarRange( range );
288 vSliceMapper->SetLookupTable( vGreenToRedLut );
290 vSliceActor->SetMapper( vSliceMapper );
292 if(bbGetInputShowPlane() == 1)
294 else if(bbGetInputShowPlane() == 0)
297 vSliceActor->GetProperty()->SetOpacity( bbGetInputShowPlane() );
299 exporter->SetInputConnection( vMultipleContourMapper->GetOutputPort() );
300 exporter->ImageLowerLeftOn();
302 bbSetOutputOut1( vSliceActor );
303 bbSetOutputOut2( vGlyphActor );
304 bbSetOutputOut3( vOutlineActor );
305 bbSetOutputOut4( vMultipleContourActor );
306 //bbSetOutputOut5( vScalarBarActor );
307 if(bbGetInputShowStream() == 1)
308 vStreamlineActor2->SetMapper( streamMapper2 );
310 vStreamlineActor2->SetMapper( NULL );
312 bbSetOutputOut5( vStreamlineActor2 );
313 //bbSetOutputOut5( vStreamlineActor2 );
314 //bbSetOutputOutExport( exporter );
315 //temp->GetData( (vtkInformation*) vMultipleContourVelocity->GetOutput() );
316 //temp->GetData( vMultipleContourMapper->GetOutput() );
317 //bbSetOutputOutTest( temp );
327 // 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)
329 void Magnitud::bbUserSetDefaultValues()
332 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
333 // Here we initialize the input 'In' to 0
341 bbSetInputMRatio(100);
342 bbSetInputOpactity(0.5);
343 bbSetInputScale(0.2);
344 bbSetInputContour(10);
345 bbSetInputShowPlane(1);
346 bbSetInputShowStream(0);
347 //bbSetInputPlaneCenterSL();
351 // 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)
353 void Magnitud::bbUserInitializeProcessing()
356 // THE INITIALIZATION METHOD BODY :
358 // but this is where you should allocate the internal/output pointers
362 cone = vtkArrowSource::New();
363 exporter = vtkImageExport::New();
364 point = vtkPolyData::New();
365 rf = vtkTubeFilter::New();
366 source = vtkPointSource::New();
367 streamer = vtkStreamTracer::New();
368 streamMapper2 = vtkPolyDataMapper::New();
370 transformEED = vtkTransform::New();
371 vAppendDataForFlowWidgetVisualisation = vtkAppendPolyData::New();
372 vArrowSource = vtkArrowSource::New();
373 vDiskSourceEED = vtkDiskSource::New();
374 vGlyph = vtkGlyph3D::New();
375 vGlyphActor = vtkActor::New();
376 vGlyphFlowPlane = vtkGlyph3D::New();
377 vGlyphMapper = vtkPolyDataMapper::New();
378 vGreenToRedLut = vtkLookupTable::New();
379 vIren = vtkRenderWindowInteractor::New();
380 vMaskPoint = vtkMaskPoints::New();
381 vMultipleContourActor = vtkActor::New();
382 vMultipleContourMapper = vtkPolyDataMapper::New();
383 vMultipleContourVelocity = vtkContourFilter::New();
384 vOutlineActor = vtkActor::New();
385 vOutlineGrid = vtkOutlineFilter::New();
386 vOutlineMapper = vtkPolyDataMapper::New();
387 vPlanSource = vtkPlaneSource::New();
388 vPlaneWidget = vtkPlaneWidget::New();
389 vPointWidget = vtkPointWidget::New();
390 vProbeslices = vtkProbeFilter::New();
391 vProbeslicesFlowWidget = vtkProbeFilter::New();
392 vScalarBarActor = vtkScalarBarActor::New();
393 vSliceMapper = vtkPolyDataMapper::New();
394 vSliceActor = vtkActor::New();
395 vStreamlineActor2 = vtkActor::New();
396 vtransformpolydatafilter = vtkTransformPolyDataFilter::New();
397 vVecMagnitude = vtkVectorNorm::New();
399 temp = vtkImageData::New();
401 sizeIma = SIZEPLANWIDGET;
405 // 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)
407 void Magnitud::bbUserFinalizeProcessing()
410 // THE FINALIZATION METHOD BODY :
412 // but this is where you should desallocate the internal/output pointers
415 /// \TODO delete everything no longer needed!
419 // EO namespace bbvtk