]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkMagnitud.cxx
#3403 BBTK Feature New Normal - vtk8itk5wx3-macos
[bbtk.git] / packages / vtk / src / bbvtkMagnitud.cxx
index db2fdecf6c50d6ae5e944b7a4bfbd09030adf7ad..96e7726fca33dcabc07bbd2f88601770dec60df1 100644 (file)
@@ -2,7 +2,7 @@
  # ---------------------------------------------------------------------
  #
  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
- #                        pour la Santé)
+ #                        pour la Santé©
  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
@@ -41,6 +41,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(Magnitud,bbtk::AtomicBlackBox);
 void Magnitud::Process()
 {
 
+printf("EED Magnitud::Process Start\n");
+
 // THE MAIN PROCESSING METHOD BODY
 //   Here we simply set the input 'In' value to the output 'Out'
 //   And print out the output value
@@ -54,37 +56,76 @@ void Magnitud::Process()
 //      (the one provided in the attribute 'type' of the tag 'input')
 
 // ---------- 
- if (bbGetInputIn()!=NULL) {
-   vGreenToRedLut->SetHueRange(0.6667,0.0);
-   vGreenToRedLut->Build();
+       if (bbGetInputIn()!=NULL) 
+       {
+               vGreenToRedLut->SetHueRange(0.6667,0.0);
+               vGreenToRedLut->Build();
   
   //Input Data
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vVecMagnitude->SetInput(bbGetInputIn());
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vVecMagnitude->SetInputData(bbGetInputIn());
+#endif
+
    vVecMagnitude->NormalizeOff();
    vVecMagnitude->Update();
    vVecMagnitude->GetOutput()->GetScalarRange( range1 );
    vVecMagnitude->Update();
    
    //Glyph
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vMaskPoint->SetInput(bbGetInputIn());
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vMaskPoint->SetInputData(bbGetInputIn());
+#endif
+
    vMaskPoint->SetOnRatio(100);
    vMaskPoint->Update();
    vMaskPoint->RandomModeOn();
-   
-   vGlyph->SetInput(vMaskPoint->GetOutput());
-   vGlyph->SetSource(cone->GetOutput());
+
    vGlyph->SetScaleModeToScaleByVector();
    vGlyph->SetColorModeToColorByVector();
    vGlyph->SetScaleFactor(0.20);
+   
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
+   vGlyph->SetInput(vMaskPoint->GetOutput());
+   vGlyph->SetSource(cone->GetOutput());
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vGlyph->SetInputData(vMaskPoint->GetOutput());
+       cone->Update();
+   vGlyph->SetSourceData(cone->GetOutput());
+#endif
+
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vGlyphMapper->SetInput( vGlyph->GetOutput() );
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vGlyphMapper->SetInputData( vGlyph->GetOutput() );
+#endif
+
    step = (range1[1]-range1[0])/10;
       
    //Contour
-   dRangeColorForMultipleContourVelocity[0]=0;
-   dRangeColorForMultipleContourVelocity[1]=1;
-   dRangeColorForGlyphVelocity[0]=0;
-   dRangeColorForGlyphVelocity[1]=1;
+   dRangeColorForMultipleContourVelocity[0]    = 0;
+   dRangeColorForMultipleContourVelocity[1]    = 1;
+   dRangeColorForGlyphVelocity[0]                      = 0;
+   dRangeColorForGlyphVelocity[1]                      = 1;
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vMultipleContourVelocity->SetInput((vtkDataSet *) vVecMagnitude->GetOutput()); 
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vMultipleContourVelocity->SetInputData((vtkDataSet *) vVecMagnitude->GetOutput()); 
+#endif
    
    index = 0;
    double h;
@@ -96,7 +137,14 @@ void Magnitud::Process()
       index+=1;
    }
    
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vMultipleContourMapper->SetInput( vMultipleContourVelocity->GetOutput() );
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vMultipleContourMapper->SetInputData( vMultipleContourVelocity->GetOutput() );
+#endif
+
    vMultipleContourMapper->SetScalarRange( range1 );
    vMultipleContourMapper->SetLookupTable( vGreenToRedLut );
    vMultipleContourMapper->Update();
@@ -106,11 +154,21 @@ void Magnitud::Process()
    //Glyph Mapper
    vGlyphMapper->SetLookupTable(vGreenToRedLut);
    vGlyphMapper->SetScalarRange(range1);
-   vGlyphMapper->ImmediateModeRenderingOn();
+//EED 2020-04-21 vtk8 deprecated
+//   vGlyphMapper->ImmediateModeRenderingOn();
  
    //Outline Grid
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vOutlineGrid->SetInput( bbGetInputIn() );
    vOutlineMapper->SetInput(vOutlineGrid->GetOutput());
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vOutlineGrid->SetInputData( bbGetInputIn() );
+       vOutlineGrid->Update();
+   vOutlineMapper->SetInputData( vOutlineGrid->GetOutput() );
+#endif
+
    
    //Outline Grid Actor
    vOutlineActor->SetMapper(vOutlineMapper);
@@ -143,10 +201,14 @@ void Magnitud::Process()
    vGlyph->SetScaleFactor(vGlyph->GetScaleFactor()+0.1);
    vGlyph->Update();
    if( (bbGetInputScale()/100)<0 ) 
+       {
       bbSetInputScale(0);
+       }
    if( (bbGetInputScale()/100)>1 ) 
+       {
       bbSetInputScale(1);
-   
+   }
+
    //vGlyph->SetScaleFactor(dScale);
    vGlyph->SetScaleFactor( bbGetInputScale()/100 );
    vGlyph->Update();
@@ -166,9 +228,14 @@ void Magnitud::Process()
    vMultipleContourMapper->SetScalarRange( range1 );
 
    if( bbGetInputOpactity()/100<0 ) 
-      bbSetInputOpactity(0);
+       {
+       bbSetInputOpactity(0);
+       }
+
    if( bbGetInputOpactity()/100>1 ) 
-      bbSetInputOpactity(1);
+       {
+       bbSetInputOpactity(1);
+       }
 
    //Set Contour Opacity
    vMultipleContourActor->GetProperty()->SetOpacity( bbGetInputOpactity()/100 );
@@ -179,7 +246,9 @@ void Magnitud::Process()
 
    //Set The Number of Contours
    if( bbGetInputContour()<1) 
-      bbSetInputContour(1);
+       {
+               bbSetInputContour(1);
+       }
 
    step=(range1[1]-range1[0])/bbGetInputContour();
    index=0;
@@ -192,18 +261,24 @@ void Magnitud::Process()
    //End: Change values by the user
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    //The Plane Widget
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vPlaneWidget->SetInput(bbGetInputIn());
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vPlaneWidget->SetInputData(bbGetInputIn());
+#endif
    vPlaneWidget->NormalToXAxisOn();
    vPlaneWidget->NormalToZAxisOn();
    vPlaneWidget->SetResolution(1);
    vPlaneWidget->SetRepresentationToOutline();
    //vPlaneWidget->SetInteractor(vIren);
-   vPlaneWidget->SetPlaceFactor(1); //défini zoom initial
+   vPlaneWidget->SetPlaceFactor(1); //déæini zoom initial
    vPlaneWidget->PlaceWidget();
    vPlaneWidget->On();
 
    vPlaneWidget->GetOrigin(p0);
-   vPlaneWidget->GetCenter(c); //These is from Execute Method
+   vPlaneWidget->GetCenter(c); //These is fromvtkImageMathematics Execute Method
    vPlaneWidget->GetNormal(n);
    vPlaneWidget->GetPoint1(p1);
    vPlaneWidget->GetPoint2(p2);
@@ -228,7 +303,14 @@ void Magnitud::Process()
    vDiskSourceEED->SetCircumferentialResolution (20);
 
    //Stream Lines
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vPointWidget->SetInput( bbGetInputIn() );
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vPointWidget->SetInputData( bbGetInputIn() );
+#endif
+
    vPointWidget->AllOff();
    vPointWidget->PlaceWidget();
    //vPointWidget->SetInteractor(vIren);
@@ -246,8 +328,16 @@ void Magnitud::Process()
    source->SetCenter(  c );
    source->SetRadius(5.0);
    
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    streamer->SetInput( bbGetInputIn() );
    streamer->SetSource(source->GetOutput());
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   streamer->SetInputData( bbGetInputIn() );
+   streamer->SetSourceData( source->GetOutput() );
+#endif
+
    streamer->SetIntegratorTypeToRungeKutta45();
    streamer->SetMaximumPropagation(500000);
 //EED    streamer->SetMaximumPropagationUnitToTimeUnit ();
@@ -257,13 +347,28 @@ void Magnitud::Process()
 //EED   streamer->ComputeVorticityOn ();
    streamer->Update();
 
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    rf->SetInput(streamer->GetOutput());
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   rf->SetInputData(streamer->GetOutput());
+#endif
+
    rf->SetRadius(.5);
    rf->SetNumberOfSides(12);
    rf->SetVaryRadiusToVaryRadiusOff();
    
    streamer->GetOutput()->GetScalarRange( range );
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    streamMapper2->SetInput(rf->GetOutput());
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   streamMapper2->SetInputData(rf->GetOutput());
+#endif
+
    streamMapper2->SetLookupTable(vGreenToRedLut);
    //vStreamlineActor2->SetMapper( streamMapper2 );
    
@@ -285,40 +390,77 @@ void Magnitud::Process()
    //End: Part of the Execute Method
    //////////////////////////////////////////////////////////////////////////////////////
 
-   vtransformpolydatafilter->SetInput( vDiskSourceEED->GetOutput() );
    vtransformpolydatafilter->SetTransform( transformEED );
-   vtransformpolydatafilter->Update();
    
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
+   vtransformpolydatafilter->SetInput( vDiskSourceEED->GetOutput() );
    vProbeslices->SetInput( ( vtkDataSet* )vtransformpolydatafilter->GetOutput());
    vProbeslices->SetSource( bbGetInputIn() ); 
+   vGlyphFlowPlane->SetInput( vProbeslices->GetOutput() );
+   vGlyphFlowPlane->SetSource( vArrowSource->GetOutput() );
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vtransformpolydatafilter->SetInputData( vDiskSourceEED->GetOutput() );
+   vProbeslices->SetInputData( ( vtkDataSet* )vtransformpolydatafilter->GetOutput());
+   vProbeslices->SetSourceData( bbGetInputIn() ); 
+   vGlyphFlowPlane->SetInputData( vProbeslices->GetOutput() );
+       vArrowSource->Update();
+   vGlyphFlowPlane->SetSourceData( vArrowSource->GetOutput() );
+#endif
+
+   vtransformpolydatafilter->Update();
    vProbeslices->Update( );
 
-   vGlyphFlowPlane->SetInput(vProbeslices->GetOutput());
-   vGlyphFlowPlane->SetSource(vArrowSource->GetOutput());
+
    vGlyphFlowPlane->SetScaleModeToScaleByVector();
    vGlyphFlowPlane->SetColorModeToColorByVector();
    vGlyphFlowPlane->SetScaleFactor(0.2);
    vGlyphFlowPlane->Update();
 
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vProbeslicesFlowWidget->SetInput( ( vtkDataSet* )vPlanSource->GetOutput());
    vProbeslicesFlowWidget->SetSource( vVecMagnitude->GetOutput() ); 
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+   vProbeslicesFlowWidget->SetInputData( ( vtkDataSet* )vPlanSource->GetOutput());
+       vVecMagnitude->Update();
+   vProbeslicesFlowWidget->SetSourceData( vVecMagnitude->GetOutput() ); 
+#endif
+
    vProbeslicesFlowWidget->Update( );
       
    vVecMagnitude->GetOutput()->GetScalarRange( range );
 
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
    vAppendDataForFlowWidgetVisualisation->AddInput(vGlyphFlowPlane->GetOutput());
    vAppendDataForFlowWidgetVisualisation->AddInput(vProbeslicesFlowWidget->GetPolyDataOutput());
-
    vSliceMapper->SetInput( vAppendDataForFlowWidgetVisualisation->GetOutput());
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+       vGlyphFlowPlane->Update(); 
+       vProbeslicesFlowWidget->Update(); 
+   vAppendDataForFlowWidgetVisualisation->AddInputData( vGlyphFlowPlane->GetOutput() );
+   vAppendDataForFlowWidgetVisualisation->AddInputData( vProbeslicesFlowWidget->GetPolyDataOutput() );
+   vSliceMapper->SetInputData( vAppendDataForFlowWidgetVisualisation->GetOutput() );
+#endif
+
    vSliceMapper->SetScalarRange( range );
    vSliceMapper->SetLookupTable( vGreenToRedLut );
    
    vSliceActor->SetMapper( vSliceMapper );
 
    if(bbGetInputShowPlane() == 1)
+       {
       vPlaneWidget->On();
-   else if(bbGetInputShowPlane() == 0)
+       } else if(bbGetInputShowPlane() == 0) {
       vPlaneWidget->Off();
+       }
 
    vSliceActor->GetProperty()->SetOpacity( bbGetInputShowPlane() );
 
@@ -329,21 +471,25 @@ void Magnitud::Process()
    bbSetOutputOut2( vGlyphActor );
    bbSetOutputOut3( vOutlineActor );
    bbSetOutputOut4( vMultipleContourActor );
-   //bbSetOutputOut5( vScalarBarActor );
+
+//   bbSetOutputOut5( vScalarBarActor );
+
    if(bbGetInputShowStream() == 1)
+       {
       vStreamlineActor2->SetMapper( streamMapper2 );
-   else 
+       }   else {
       vStreamlineActor2->SetMapper( NULL );
-
+       }
    bbSetOutputOut5( vStreamlineActor2 );
    //bbSetOutputOut5( vStreamlineActor2 );
    //bbSetOutputOutExport( exporter );
    //temp->GetData( (vtkInformation*) vMultipleContourVelocity->GetOutput() );
    //temp->GetData( vMultipleContourMapper->GetOutput() );
    //bbSetOutputOutTest( temp );
+ } // if
 
+printf("EED Magnitud::Process End\n");
 
- } // if
 
 } // process
 
@@ -385,13 +531,13 @@ void Magnitud::bbUserInitializeProcessing()
 //    if any 
 
 // ---------- [
-   cone = vtkArrowSource::New();
-   exporter = vtkImageExport::New();
-   point = vtkPolyData::New();
-   rf = vtkTubeFilter::New();
-   source = vtkPointSource::New();
-   streamer = vtkStreamTracer::New();
-   streamMapper2 = vtkPolyDataMapper::New();
+   cone                                        = vtkArrowSource::New();
+   exporter                            = vtkImageExport::New();
+   point                                       = vtkPolyData::New();
+   rf                                          = vtkTubeFilter::New();
+   source                                      = vtkPointSource::New();
+   streamer                            = vtkStreamTracer::New();
+   streamMapper2                       = vtkPolyDataMapper::New();
    
    transformEED             = vtkTransform::New();
    vAppendDataForFlowWidgetVisualisation = vtkAppendPolyData::New();
@@ -402,7 +548,7 @@ void Magnitud::bbUserInitializeProcessing()
    vGlyphFlowPlane          = vtkGlyph3D::New();
    vGlyphMapper             = vtkPolyDataMapper::New();
    vGreenToRedLut           = vtkLookupTable::New();
-   vIren                    = vtkRenderWindowInteractor::New();
+//   vIren                    = vtkRenderWindowInteractor::New();
    vMaskPoint               = vtkMaskPoints::New();
    vMultipleContourActor    = vtkActor::New();
    vMultipleContourMapper   = vtkPolyDataMapper::New();