]> Creatis software - bbtk.git/commitdiff
Feature #1894 Black box to clip a polydata with a plane.
authorRicardo A Corredor <Ricardo.Corredor@creatis.insa-lyon.fr>
Mon, 21 Jan 2013 16:24:08 +0000 (17:24 +0100)
committerRicardo A Corredor <Ricardo.Corredor@creatis.insa-lyon.fr>
Mon, 21 Jan 2013 16:24:08 +0000 (17:24 +0100)
NewBoxes in vtk package:
PlaneClipPolyData

Look into vtk/bbs/appli/examplePlaneClipPolyData.bbs for an example

packages/vtk/bbs/appli/examplePlaneClipPolyData.bbg [new file with mode: 0644]
packages/vtk/bbs/appli/examplePlaneClipPolyData.bbs [new file with mode: 0644]
packages/vtk/src/bbvtkPlaneClipPolyData.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkPlaneClipPolyData.h [new file with mode: 0644]

diff --git a/packages/vtk/bbs/appli/examplePlaneClipPolyData.bbg b/packages/vtk/bbs/appli/examplePlaneClipPolyData.bbg
new file mode 100644 (file)
index 0000000..1bb0f12
--- /dev/null
@@ -0,0 +1,51 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBG BlackBox Diagram file
+# - /home/corredor/Software/CreaTools/All_Dec2012/creatools_source/bbtk/packages/vtk/bbs/appli/examplePlaneClipPolyData.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+DESCRIPTION:Description ??
+AUTHOR:Author ??
+COMPLEXBOX:FALSE
+COMPLEXINPUTS:0
+BOXES:4
+BOX
+vtk:SphereSource:Box00
+ISEXEC:FALSE
+-100.995049:79.554760:-900.000000
+-55.420049:69.554760:-900.000000
+FIN_BOX
+BOX
+vtk:PlaneClipPolyData:Box01
+ISEXEC:FALSE
+-100.543675:49.764041:-900.000000
+-54.968675:39.764041:-900.000000
+PORT
+PlaneNormal:"0 1 0"
+PORT
+PlaneOrigin:"0 0 0 "
+FIN_BOX
+BOX
+vtk:PolyDataToActor:Box02
+ISEXEC:FALSE
+-97.835428:23.810006:-900.000000
+-52.260428:13.810006:-900.000000
+FIN_BOX
+BOX
+wxvtk:Viewer3D:Box03
+ISEXEC:TRUE
+-96.029930:-5.755025:-900.000000
+-35.389930:-15.755025:-900.000000
+FIN_BOX
+CONNECTIONS:3
+CONNECTION
+Box00:Out:Box01:PolyData
+NumberOfControlPoints:0
+CONNECTION
+Box01:ClippedPolyData:Box02:In
+NumberOfControlPoints:0
+CONNECTION
+Box02:Out:Box03:In1
+NumberOfControlPoints:0
+APP_END
diff --git a/packages/vtk/bbs/appli/examplePlaneClipPolyData.bbs b/packages/vtk/bbs/appli/examplePlaneClipPolyData.bbs
new file mode 100644 (file)
index 0000000..a5bba25
--- /dev/null
@@ -0,0 +1,38 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBS BlackBox Script
+# - /home/corredor/Software/CreaTools/All_Dec2012/creatools_source/bbtk/packages/vtk/bbs/appli/examplePlaneClipPolyData.bbs
+# ----------------------------------
+
+# BBTK GEditor Script
+# ----------------------
+
+include std
+include itkvtk
+include vtk
+include wxvtk
+
+author "Author ??"
+description "Description ??"
+category "<VOID>"
+
+new SphereSource Box00
+
+new PlaneClipPolyData Box01
+  set Box01.PlaneNormal "0 1 0"
+  set Box01.PlaneOrigin "0 0 0 "
+
+new PolyDataToActor Box02
+
+new Viewer3D Box03
+
+
+connect Box00.Out Box01.PolyData
+
+connect Box01.ClippedPolyData Box02.In
+
+connect Box02.Out Box03.In1
+
+
+
+# Complex input ports
+exec Box03
diff --git a/packages/vtk/src/bbvtkPlaneClipPolyData.cxx b/packages/vtk/src/bbvtkPlaneClipPolyData.cxx
new file mode 100644 (file)
index 0000000..e3432ee
--- /dev/null
@@ -0,0 +1,65 @@
+//===== 
+// 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)
+//===== 
+#include "bbvtkPlaneClipPolyData.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PlaneClipPolyData)
+BBTK_BLACK_BOX_IMPLEMENTATION(PlaneClipPolyData,bbtk::AtomicBlackBox);
+//===== 
+// 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)
+//===== 
+void PlaneClipPolyData::Process()
+{
+
+       //std::cout << "RaC PlaneClipPolyData::Process START"<< std::endl;
+
+       std::vector<double> origin = bbGetInputPlaneOrigin();
+       std::vector<double> normal = bbGetInputPlaneNormal();
+
+       vtkPolyData* inPolyData = bbGetInputPolyData();
+
+       vtkPlane* plane = vtkPlane::New();
+       plane->SetOrigin(origin[0],origin[1],origin[2]);
+       plane->SetNormal(normal[0],normal[1],normal[2]);
+
+       vtkClipPolyData* clipper = vtkClipPolyData::New();
+       clipper->SetInputConnection(inPolyData->GetProducerPort());
+       clipper->SetClipFunction(plane);
+       clipper->Update();
+
+       vtkPolyData* outPolydata = clipper->GetOutput();
+    bbSetOutputClippedPolyData(outPolydata);
+
+   // std::cout << "RaC PlaneClipPolyData::Process END "<<polydataCopy<< std::endl;
+  
+}
+//===== 
+// 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)
+//===== 
+void PlaneClipPolyData::bbUserSetDefaultValues()
+{
+
+  
+}
+//===== 
+// 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)
+//===== 
+void PlaneClipPolyData::bbUserInitializeProcessing()
+{
+
+  
+}
+//===== 
+// 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)
+//===== 
+void PlaneClipPolyData::bbUserFinalizeProcessing()
+{
+  
+}
+}
+// EO namespace bbvtk
+
+
diff --git a/packages/vtk/src/bbvtkPlaneClipPolyData.h b/packages/vtk/src/bbvtkPlaneClipPolyData.h
new file mode 100644 (file)
index 0000000..f68ea0e
--- /dev/null
@@ -0,0 +1,68 @@
+//===== 
+// 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)
+//===== 
+#ifndef __bbvtkPlaneClipPolyData_h_INCLUDED__
+#define __bbvtkPlaneClipPolyData_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include <vtkSmartPointer.h>
+#include <vtkPolyData.h>
+#include <vtkClipPolyData.h>
+#include <vtkPlane.h>
+
+#include <vtkDataSetMapper.h>
+#include <vtkActor.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+
+#include <vtkCamera.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkActor.h>
+#include <vtkProperty.h>
+#include <vtkSphereSource.h>
+
+namespace bbvtk
+{
+
+class bbvtk_EXPORT PlaneClipPolyData
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(PlaneClipPolyData,bbtk::AtomicBlackBox);
+//===== 
+// 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)
+//===== 
+  BBTK_DECLARE_INPUT(PlaneOrigin,std::vector<double>);
+  BBTK_DECLARE_INPUT(PlaneNormal,std::vector<double>);
+  BBTK_DECLARE_INPUT(PolyData,vtkPolyData*);
+  BBTK_DECLARE_OUTPUT(ClippedPolyData,vtkPolyData*);
+  BBTK_PROCESS(Process);
+  void Process();
+
+
+//===== 
+// 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)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(PlaneClipPolyData,bbtk::AtomicBlackBox);
+BBTK_NAME("PlaneClipPolyData");
+BBTK_AUTHOR("Ricardo A Corredor");
+BBTK_DESCRIPTION("Clips a polydata with a plane determined by the origin and normal given");
+BBTK_CATEGORY("");
+BBTK_INPUT(PlaneClipPolyData,PlaneOrigin,"Cutting plane origin",std::vector<double>,"");
+BBTK_INPUT(PlaneClipPolyData,PlaneNormal,"Cutting plane normal",std::vector<double>,"");
+BBTK_INPUT(PlaneClipPolyData,PolyData,"PolyData to be clipped",vtkPolyData*,"");
+BBTK_OUTPUT(PlaneClipPolyData,ClippedPolyData,"New PolyData clipped",vtkPolyData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(PlaneClipPolyData);
+//===== 
+// 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)
+//===== 
+}
+// EO namespace bbvtk
+
+#endif // __bbvtkPlaneClipPolyData_h_INCLUDED__
+