]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkPolyDataToActor.cxx
#3352 BBTK Feature New Normal - box TemporaryPicker in 3D
[bbtk.git] / packages / vtk / src / bbvtkPolyDataToActor.cxx
index 62dca0c7ac58888e682a189ad50c74948f758ed1..2aad2ec130eb57e7ee73ab1be1e5634a342df18a 100644 (file)
 
 #include "vtkProperty.h"
 #include "vtkLinearTransform.h"
+#include "vtkCleanPolyData.h"
 
 #include "bbvtkPolyDataToActor.h"
 #include "bbvtkPackage.h"
 
+#include "vtkRenderWindow.h"
+
 namespace bbvtk
 {
    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataToActor)
@@ -54,20 +57,20 @@ namespace bbvtk
 
    void PolyDataToActor::bbUserSetDefaultValues() 
    { 
-          firsttime=true;
+          actorAdded=false;
           std::vector<double> colour;
           colour.push_back(1.0);
           colour.push_back(1.0);
           colour.push_back(0.5);
           bbSetInputColour(colour);
-
+          bbSetInputActive(true);
           bbSetInputIn(NULL);
           bbSetInputRenderer(NULL);
           bbSetInputTransform(NULL);
           bbSetInputOpacity(1);
           bbSetInputRepresentation(2);
           bbSetInputLineWidth(1);
-
+          bbSetInputScalarVisibility(false);
           polydatamapper = NULL;
           vtkactor       = NULL;
    }
@@ -82,9 +85,7 @@ namespace bbvtk
 //     polydatamapper->SetInput(marchingcubes->GetOutput());
      vtkactor->SetMapper(polydatamapper);
 
-//   polydatamapper->ScalarVisibilityOff();
-     polydatamapper->ScalarVisibilityOn();
-     polydatamapper->ImmediateModeRenderingOn();
+//     polydatamapper->ImmediateModeRenderingOn();
    }
 
        //---------------------------------------------------------------------
@@ -105,33 +106,103 @@ namespace bbvtk
        
 //---------------------------------------------------------------------
 
-   void PolyDataToActor::DoProcess()
-   {      
-     polydatamapper->SetInput( bbGetInputIn() );
-     
-        vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
-        vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
-          
-     vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
-                                       bbGetInputColour()[1], 
-                                       bbGetInputColour()[2] );
-          
-     vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
-     
-     if ( bbGetInputTransform()!=NULL )
-     {
-        vtkactor->SetUserTransform( bbGetInputTransform() );
-     }
-
-     bbSetOutputOut( vtkactor );
-
-     // Interface Update
-     if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
-     {
-       firsttime=false;
-       bbGetInputRenderer()->AddActor( vtkactor );
-     } 
-   }
+void PolyDataToActor::DoProcess()
+{
+printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
+printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
+printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
+printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
+printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
+printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
+printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
+printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
+//https://stackoverflow.com/questions/47528086/problems-with-rendering-transparent-objects-in-vtk
+//https://itk.org/Wiki/VTK/Depth_Peeling
+bbGetInputRenderer()->SetUseDepthPeeling(1);
+bbGetInputRenderer()->SetOcclusionRatio(0.1);
+bbGetInputRenderer()->SetMaximumNumberOfPeels(100);
+bbGetInputRenderer()->GetRenderWindow()->SetMultiSamples(0);
+bbGetInputRenderer()->GetRenderWindow()->SetAlphaBitPlanes(1);
+
+
+               if (bbGetInputRenderer()==NULL)
+               {
+                       printf("EED Warnning! PolyDataToActor::DoProcess  missing Renderer.\n");
+               }
+
+
+               if (bbGetInputActive()==true)
+               {
+
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+                        polydatamapper->SetInput( bbGetInputIn() );
+#else
+                        polydatamapper->SetInputData( bbGetInputIn() );  
+#endif
+
+                        vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
+
+                       if (bbGetInputRepresentation()==0)
+                       {
+                                vtkactor->GetProperty()->SetAmbient(1);
+                                vtkactor->GetProperty()->SetDiffuse(1);
+                                vtkactor->GetProperty()->SetSpecular(0);
+printf("EED WARNNING!  PolyDataToActor::DoProcess  which is the default values of Ambient, Diffuse, Specular for points option? \n");
+                       } else if (bbGetInputRepresentation()==1)
+                       {
+                                vtkactor->GetProperty()->SetAmbient(1);
+                                vtkactor->GetProperty()->SetDiffuse(1);
+                                vtkactor->GetProperty()->SetSpecular(0);
+                       } else if (bbGetInputRepresentation()==2)
+                       {
+                                vtkactor->GetProperty()->SetAmbient(0);
+                                vtkactor->GetProperty()->SetDiffuse(1);
+                                vtkactor->GetProperty()->SetSpecular(0);
+                       }
+
+                        vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
+                          
+                        vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
+                                                       bbGetInputColour()[1], 
+                                                       bbGetInputColour()[2] );
+                                 
+                        vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
+
+                        
+                        if ( bbGetInputTransform()!=NULL )
+                        {
+                               vtkactor->SetUserTransform( bbGetInputTransform() );
+                        }
+
+                        bbSetOutputOut( vtkactor );
+
+                        // Interface Update
+                        if ((actorAdded==false) && (bbGetInputRenderer()!=NULL ))
+                        {
+                          actorAdded=true;
+                          bbGetInputRenderer()->AddActor( vtkactor );
+                        }  // actorAdded
+
+                        if (bbGetInputScalarVisibility()==true )
+                        {
+                                polydatamapper->ScalarVisibilityOn();
+                        } else {
+                                polydatamapper->ScalarVisibilityOff();
+                        } // ScalarVisibility
+               } else {
+                        // Interface Update
+                        if ((actorAdded==true) && (bbGetInputRenderer()!=NULL ))
+                        {
+                          actorAdded=false;
+                          bbGetInputRenderer()->RemoveActor( vtkactor );
+                        }  // actorAdded
+               } // Active
+}
+
+
+
 } // EO namespace bbtk
 
 #endif //_USE_VTK_