]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkMeshCutByAxis.cxx
Clean code
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkMeshCutByAxis.cxx
index 111efb526a8a5b24e53b26dea94f5363cc59ee82..7af703c93e6c65824714e9aa40c458ab01f7046a 100644 (file)
@@ -7,7 +7,7 @@
 #include <vtkBox.h>
 #include <vtkPlane.h>
 #include <vtkClipPolyData.h>
-
+#include <vtkPolyDataNormals.h>
 namespace bbcreaVtk
 {
 
@@ -39,9 +39,18 @@ void MeshCutByAxis::Process()
                vtkPlane                *clipPlane      = vtkPlane::New();      
                vtkBox                  *clipBox        = vtkBox::New();        
                vtkClipPolyData *clipper        = vtkClipPolyData::New();
+//             clipper->GenerateClipScalarsOn();
+//             clipper->GenerateClippedOutputOff();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
            clipper             -> SetInput( bbGetInputIn() );
+#else
+//             vtkPolyDataNormals *nn = vtkPolyDataNormals::New();
+//             nn->SetInputData( bbGetInputIn() );
+//         clipper             -> SetInputData( nn->GetOutput() );
+           clipper             -> SetInputData( bbGetInputIn() );
+#endif
                clipper->SetInsideOut( bbGetInputInsideVol() );
-
                int a;  // correction border 
                if (bbGetInputInsideVol()==false)
                {
@@ -49,15 +58,12 @@ void MeshCutByAxis::Process()
                } else {
                        a=0;
                }
-
                int px=bbGetInputPoint()[0];
                int py=bbGetInputPoint()[1];
                int pz=bbGetInputPoint()[2];
-
                if ( bbGetInputType()=="x"              ) { clipPlane->SetNormal(1, 0, 0);                                                                              ok=1;   } else  
                if ( bbGetInputType()=="y"              ) { clipPlane->SetNormal(0, 1, 0);                                                                              ok=1;   } else
                if ( bbGetInputType()=="z"              ) { clipPlane->SetNormal(0, 0, 1);                                                                              ok=1;   } else
-
                if ( bbGetInputType()=="x+y+"   ) { clipBox->SetBounds(px       ,px+sb  ,py             ,py+sb  ,pz-sb  ,pz+sb  );      ok=2;   } else
                if ( bbGetInputType()=="x-y+"   ) { clipBox->SetBounds(px-sb,px+a       ,py             ,py+sb  ,pz-sb  ,pz+sb  );      ok=2;   } else
                if ( bbGetInputType()=="x+y-"   ) { clipBox->SetBounds(px       ,px+sb  ,py-sb  ,py+a   ,pz-sb  ,pz+sb  );      ok=2;   } else
@@ -73,7 +79,6 @@ void MeshCutByAxis::Process()
                if ( bbGetInputType()=="x+z-"   ) { clipBox->SetBounds(px       ,px+sb  ,py-sb  ,py+sb  ,pz-sb  ,pz+a   );      ok=2;   } else
                if ( bbGetInputType()=="x-z-"   ) { clipBox->SetBounds(px-sb,px+a       ,py-sb  ,py+sb  ,pz-sb  ,pz+a   );      ok=2;   } else
 
-
                if ( bbGetInputType()=="x+y+z+" ) { clipBox->SetBounds(px       ,px+sb  ,py             ,py+sb  ,pz     ,pz+sb  );      ok=2;   } else
                if ( bbGetInputType()=="x-y+z+" ) { clipBox->SetBounds(px-sb,px+a       ,py             ,py+sb  ,pz     ,pz+sb  );      ok=2;   } else
                if ( bbGetInputType()=="x+y-z+" ) { clipBox->SetBounds(px       ,px+sb  ,py-sb  ,py+a   ,pz     ,pz+sb  );      ok=2;   } else
@@ -85,11 +90,14 @@ void MeshCutByAxis::Process()
 
                if (ok==1) {
                        clipPlane       -> SetOrigin(px,py,pz); 
+                       clipPlane       -> Modified();
                        clipper         -> SetClipFunction(clipPlane);  
+                       clipper         -> Update();
                        bbSetOutputOut( clipper->GetOutput() ); 
-               } else          if (ok==2) {
-                       
-                       clipper         -> SetClipFunction(clipBox);  
+               } else          if (ok==2) {                    
+                       clipBox -> Modified();
+                       clipper -> SetClipFunction(clipBox); 
+                       clipper -> Update();
                        bbSetOutputOut( clipper->GetOutput() ); 
                } else {
                        bbSetOutputOut( bbGetInputIn() );