]> Creatis software - creaMaracasVisu.git/commitdiff
#3109 creaMaracasVisu Bug New Normal - branch vtk7itk4 compilation with vtk7
authorEduardo DAVILA <davila@localhost.localdomain>
Thu, 3 Aug 2017 14:04:05 +0000 (16:04 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Thu, 3 Aug 2017 14:04:05 +0000 (16:04 +0200)
lib/Kernel/VTKObjects/SurfaceRenderer/surfacerenderingimagestencilexport.cxx
lib/Kernel/VTKObjects/SurfaceRenderer/surfacerenderingimagestencilexport.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.h

index 15d7bdb1cdbdda2840ffc356199232dcac428456..00424743978b101a25e85048f1b480c785268a42 100644 (file)
 
 #include "surfacerenderingimagestencilexport.h"
 
-#include "vtkObjectFactory.h"
 #include "vtkMetaImageWriter.h"
 
 #include "math.h"
 
+
 vtkStandardNewMacro(SurfaceRenderingImageStencilExport)
 
 SurfaceRenderingImageStencilExport::SurfaceRenderingImageStencilExport()
@@ -37,78 +37,143 @@ SurfaceRenderingImageStencilExport::SurfaceRenderingImageStencilExport()
     ImageOutput = 0;
 }
 
-SurfaceRenderingImageStencilExport::~SurfaceRenderingImageStencilExport(){
+SurfaceRenderingImageStencilExport::~SurfaceRenderingImageStencilExport()
+{
 
-    if(ImageOutput){
+    if(ImageOutput)
+       {
         ImageOutput->Delete();
     }
 }
 
-void SurfaceRenderingImageStencilExport::Update(){
-    this->Execute(0);
-}
 
-void SurfaceRenderingImageStencilExport::Execute(vtkImageData *data){
-
-    vtkSmartPointer<vtkPolyDataToImageStencil> polytostencil = vtkSmartPointer<vtkPolyDataToImageStencil>::New();
 
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
+
+       void SurfaceRenderingImageStencilExport::Update(){
+           this->Execute(0);
+       }
+
+
+       // This method is much too long, and has to be broken up!
+       // Furthermore we are loosing the normals !!!
+       void SurfaceRenderingImageStencilExport::Execute(vtkImageData *data){
+       {
+
+    vtkSmartPointer<vtkPolyDataToImageStencil> polytostencil = vtkSmartPointer<vtkPolyDataToImageStencil>::New();
+
     vtkPolyData* polydata = (vtkPolyData*)this->GetInput();
     polytostencil->SetInput(polydata);
-#else
-    vtkPolyData* polydata = (vtkPolyData*)this->GetInput();
-    polytostencil->SetInputData(polydata);
-#endif
     polytostencil->Update();
 
     double *bounds = polydata->GetBounds();
     vtkSmartPointer<vtkImageData> imagein = vtkSmartPointer<vtkImageData>::New();
 
     imagein->SetExtent(bounds[0] - 1, bounds[1] + 1, bounds[2] - 1, bounds[3] + 1, bounds[4] - 1, bounds[5] + 1);
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
     imagein->SetScalarTypeToUnsignedShort();    
     imagein->AllocateScalars();
-#else
-    imagein->AllocateScalars(VTK_UNSIGNED_SHORT,1);
-#endif
-
 
     int* extent = imagein->GetExtent();
 
-    for (int x = extent[0]; x <= extent[1]; x++){
-        for (int y = extent[2]; y <= extent[3]; y++){
-            for (int z  =extent[4]; z <= extent[5]; z++){
+       int x, y, z;
+    for (x = extent[0]; x <= extent[1]; x++){
+        for (y = extent[2]; y <= extent[3]; y++){
+            for (z  =extent[4]; z <= extent[5]; z++){
                 unsigned short* pixel = static_cast<unsigned short*>(imagein->GetScalarPointer(x,y,z));
                 *pixel = 0;
-            }
-        }
-    }
+            }  // for x
+        } // for y 
+    } // for z
 
     vtkSmartPointer<vtkImageStencil> stencil = vtkSmartPointer<vtkImageStencil>::New();
 
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
     stencil->SetInput(imagein);
     stencil->SetStencil(polytostencil->GetOutput());
+
+    stencil->ReverseStencilOn();
+    stencil->SetBackgroundValue(128);
+    stencil->Update();
+
+    if(ImageOutput)
+       {
+        ImageOutput->Delete();
+    }
+    ImageOutput = vtkImageData::New();
+    ImageOutput->DeepCopy(stencil->GetOutput());
+
+       }
+
 #else
+
+int SurfaceRenderingImageStencilExport::RequestData(  vtkInformation *vtkNotUsed(request),  vtkInformationVector **inputVector,  vtkInformationVector *outputVector)
+{
+
+       // get the info objects
+       vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
+       vtkInformation *outInfo = outputVector->GetInformationObject(0);
+
+       // get the input and output
+       vtkPolyData *input = vtkPolyData::SafeDownCast(    inInfo->Get(vtkDataObject::DATA_OBJECT()));
+       vtkPolyData *output = vtkPolyData::SafeDownCast(    outInfo->Get(vtkDataObject::DATA_OBJECT()));
+
+
+    vtkSmartPointer<vtkPolyDataToImageStencil> polytostencil = vtkSmartPointer<vtkPolyDataToImageStencil>::New();
+
+//    vtkPolyData* polydata = (vtkPolyData*)this->GetInput();
+    vtkPolyData* polydata = input;
+    polytostencil->SetInputData(polydata);
+    polytostencil->Update();
+
+    double *bounds = polydata->GetBounds();
+    vtkSmartPointer<vtkImageData> imagein = vtkSmartPointer<vtkImageData>::New();
+
+    imagein->SetExtent(bounds[0] - 1, bounds[1] + 1, bounds[2] - 1, bounds[3] + 1, bounds[4] - 1, bounds[5] + 1);
+    imagein->AllocateScalars(VTK_UNSIGNED_SHORT,1);
+
+
+    int* extent = imagein->GetExtent();
+
+       int x,y,z;
+    for (x = extent[0]; x <= extent[1]; x++){
+        for (y = extent[2]; y <= extent[3]; y++){
+            for (z  =extent[4]; z <= extent[5]; z++){
+                unsigned short* pixel = static_cast<unsigned short*>(imagein->GetScalarPointer(x,y,z));
+                *pixel = 0;
+            } // for z
+        }  // for y
+    }  // for z
+
+    vtkSmartPointer<vtkImageStencil> stencil = vtkSmartPointer<vtkImageStencil>::New();
+
     stencil->SetInputData(imagein);
     stencil->SetStencilData(polytostencil->GetOutput());
-#endif
 
     stencil->ReverseStencilOn();
     stencil->SetBackgroundValue(128);
     stencil->Update();
 
-    if(ImageOutput){
+    if(ImageOutput)
+       {
         ImageOutput->Delete();
     }
     ImageOutput = vtkImageData::New();
     ImageOutput->DeepCopy(stencil->GetOutput());
 
+       return 1;
 }
 
-vtkImageData* SurfaceRenderingImageStencilExport::GetOutput(){
+#endif
+
+
+
+
+
+
+
+//-------------------------------------------------------------------------------------------
+
+vtkImageData* SurfaceRenderingImageStencilExport::GetOutputData()
+{
     return ImageOutput;
 }
index 86d4f7d9347bd0e9125385948f8d371fb8c74548..5548f5263fbbc7e75530e0c1a0cf1fbad28d0d06 100644 (file)
 #ifndef SURFACERENDERINGIMAGESTENCILEXPORT_H
 #define SURFACERENDERINGIMAGESTENCILEXPORT_H
 
+#include "vtkObjectFactory.h"
 
-#include <vtkImageData.h>
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
   #include <vtkDataSetToImageFilter.h>
 #else
-  // ..
+  #include "vtkPolyDataAlgorithm.h"
+  #include "vtkDataObject.h"
+  #include "vtkInformation.h"
+  #include "vtkDemandDrivenPipeline.h"
+  #include "vtkInformationVector.h"
 #endif
 
 #include <vtkSmartPointer.h>
 #include <vtkPolyDataToImageStencil.h>
 #include <vtkImageStencil.h>
+#include <vtkImageData.h>
 #include <vtkPolyData.h>
 
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
 class SurfaceRenderingImageStencilExport : public vtkDataSetToImageFilter
+#else
+class SurfaceRenderingImageStencilExport : public vtkPolyDataAlgorithm
+#endif
 {
 public:
     static SurfaceRenderingImageStencilExport *New();
 
-    vtkTypeMacro(SurfaceRenderingImageStencilExport,vtkDataSetToImageFilter)
+    vtkTypeMacro(SurfaceRenderingImageStencilExport,vtkPolyDataAlgorithm)
 
+#if VTK_MAJOR_VERSION <= 5
     virtual void Update();
-    vtkImageData* GetOutput();
+#else
+       // ..
+#endif
+
+
+    virtual vtkImageData* GetOutputData();
 protected:
 
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+  // Usual data generation method
     virtual void Execute(vtkImageData *data);
+#else
+  virtual int RequestData(  vtkInformation *vtkNotUsed(request),  vtkInformationVector **inputVector,  vtkInformationVector *outputVector);    
+#endif
 
 private:
 
index 1ed82f0fca438d0aff166978bb4ba2ce1d85164e..bb2446879b5eb843d376177c9025c20f0508eefb 100644 (file)
@@ -197,9 +197,6 @@ int vtkClosePolyData::RequestData(  vtkInformation *vtkNotUsed(request),  vtkInf
        return 1;
 }
 
-
-
-
 #endif
 
 //----------------------------------------------------------------------------
index a11f8b858c5128310241ca584a1b45cedf43b7fa..37f8cde17c26cc5223262a826a6cebee59cb1d6b 100644 (file)
@@ -93,14 +93,7 @@ protected:
   // Usual data generation method
   void Execute();
 #else
-/*
-  int ProcessRequest(  vtkInformation *request, 
-                                               vtkInformationVector **inputVector, 
-                                               vtkInformationVector *outputVector);
-*/ 
-int RequestData(  vtkInformation *vtkNotUsed(request),  vtkInformationVector **inputVector,  vtkInformationVector *outputVector);
-
-       
+  int RequestData(  vtkInformation *vtkNotUsed(request),  vtkInformationVector **inputVector,  vtkInformationVector *outputVector);    
 #endif