]> Creatis software - cpPlugins.git/blobdiff - plugins/GenericPlugins/JoinBoundingBoxes.cxx
yet another refactoring
[cpPlugins.git] / plugins / GenericPlugins / JoinBoundingBoxes.cxx
diff --git a/plugins/GenericPlugins/JoinBoundingBoxes.cxx b/plugins/GenericPlugins/JoinBoundingBoxes.cxx
new file mode 100644 (file)
index 0000000..d3bdfb5
--- /dev/null
@@ -0,0 +1,44 @@
+#include <GenericPlugins/JoinBoundingBoxes.h>
+#include <cpPlugins/Pipeline/DataObject.h>
+#include <cpInstances/DataObjects/BoundingBox.h>
+
+// -------------------------------------------------------------------------
+cpPlugins_GenericPlugins::JoinBoundingBoxes::
+JoinBoundingBoxes( )
+  : Superclass( )
+{
+  this->_ConfigureInput( "Inputs", true, true );
+  this->_ConfigureOutput< cpInstances::DataObjects::BoundingBox >( "Output" );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins_GenericPlugins::JoinBoundingBoxes::
+~JoinBoundingBoxes( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins_GenericPlugins::JoinBoundingBoxes::
+_GenerateData( )
+{
+  typedef cpPlugins::Pipeline::DataObject _TDO;
+  typedef cpInstances::DataObjects::BoundingBox _TBB;
+
+  auto out = dynamic_cast< _TBB* >( this->GetOutput( "Output" ) );
+  unsigned int nInputs = this->GetInputSize( "Inputs" );
+  for( unsigned int i = 0; i < nInputs; ++i )
+  {
+    auto in = dynamic_cast< _TDO* >( this->GetInput( "Inputs", i ) );
+    if( i > 0 )
+    {
+      _TBB::Pointer bb = _TBB::New( );
+      bb->SetDataObject( in );
+      out->Blend( bb );
+    }
+    else
+      out->SetDataObject( in );
+
+  } // rof
+}
+
+// eof - $RCSfile$