From b63a157f91efd0d66d2bdeee03eaa616724b365e Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Thu, 12 Sep 2019 14:00:21 +0300
Subject: [PATCH] Add initial ILW files

---
 applications/reconstruct/CMakeLists.txt |  6 +---
 applications/reconstruct/src/ilw.cpp    | 37 ++++++++++++++++++++++++
 applications/reconstruct/src/ilw.cu     |  0
 applications/reconstruct/src/ilw.hpp    | 38 +++++++++++++++++++------
 4 files changed, 68 insertions(+), 13 deletions(-)
 create mode 100644 applications/reconstruct/src/ilw.cpp
 create mode 100644 applications/reconstruct/src/ilw.cu

diff --git a/applications/reconstruct/CMakeLists.txt b/applications/reconstruct/CMakeLists.txt
index 1e55c671c..57b0e38db 100644
--- a/applications/reconstruct/CMakeLists.txt
+++ b/applications/reconstruct/CMakeLists.txt
@@ -6,14 +6,9 @@ set(REPSRC
 	src/main.cpp
 	src/voxel_scene.cpp
 	src/scene_rep_hash_sdf.cu
-	src/compactors.cu
-	src/garbage.cu
-	src/integrators.cu
 	#src/ray_cast_sdf.cu
 	src/voxel_render.cu
 	src/camera_util.cu
-	src/voxel_hash.cu
-	src/voxel_hash.cpp
 	#src/ray_cast_sdf.cpp
 	src/registration.cpp
 	#src/virtual_source.cpp
@@ -22,6 +17,7 @@ set(REPSRC
 	src/mls.cu
 	src/depth_camera.cu
 	src/depth_camera.cpp
+	src/ilw.cpp
 )
 
 add_executable(ftl-reconstruct ${REPSRC})
diff --git a/applications/reconstruct/src/ilw.cpp b/applications/reconstruct/src/ilw.cpp
new file mode 100644
index 000000000..1ca6312af
--- /dev/null
+++ b/applications/reconstruct/src/ilw.cpp
@@ -0,0 +1,37 @@
+#include "ilw.hpp"
+
+using ftl::ILW;
+using ftl::detail::ILWData;
+
+ILW::ILW() {
+
+}
+
+ILW::~ILW() {
+
+}
+
+bool ILW::process(ftl::rgbd::FrameSet &fs) {
+    _phase0(fs);
+
+    for (int i=0; i<2; ++i) {
+        _phase1(fs);
+        for (int j=0; j<3; ++j) {
+            _phase2(fs);
+        }
+    }
+
+    return true;
+}
+
+bool ILW::_phase0(ftl::rgbd::FrameSet &fs) {
+    // Clear points channel...
+}
+
+bool ILW::_phase1(ftl::rgbd::FrameSet &fs) {
+    // Run correspondence kernel to find points
+}
+
+bool ILW::_phase2(ftl::rgbd::FrameSet &fs) {
+    // Run energies and motion kernel
+}
diff --git a/applications/reconstruct/src/ilw.cu b/applications/reconstruct/src/ilw.cu
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/reconstruct/src/ilw.hpp b/applications/reconstruct/src/ilw.hpp
index 200b47347..0914905e5 100644
--- a/applications/reconstruct/src/ilw.hpp
+++ b/applications/reconstruct/src/ilw.hpp
@@ -1,8 +1,21 @@
 #ifndef _FTL_RECONSTRUCT_ILW_HPP_
 #define _FTL_RECONSTRUCT_ILW_HPP_
 
+#include <ftl/cuda_common.hpp>
+#include <ftl/rgbd/frameset.hpp>
+#include <vector>
+
 namespace ftl {
 
+namespace detail {
+struct ILWData{
+    // x,y,z + confidence
+    ftl::cuda::TextureObject<float4> correspondence;
+
+    ftl::cuda::TextureObject<float4> points;
+};
+}
+
 /**
  * For a set of sources, perform Iterative Lattice Warping to correct the
  * location of points between the cameras. The algorithm finds possible
@@ -18,18 +31,27 @@ class ILW {
     ~ILW();
 
     /**
-     * Set a physical scene that is composed of a set of source cameras.
-     */
-    void setScene(ftl::CameraSetScene *);
-
-    /**
-     * Take a frameset and perform the iterative lattice warping to update
-     * a scene object.
+     * Take a frameset and perform the iterative lattice warping.
      */
     bool process(ftl::rgbd::FrameSet &fs);
 
     private:
-    ftl::CameraSetScene *scene_;
+    /*
+     * Initialise data.
+     */
+    bool _phase0(ftl::rgbd::FrameSet &fs);
+
+    /*
+     * Find possible correspondences and a confidence value.
+     */
+    bool _phase1(ftl::rgbd::FrameSet &fs);
+
+    /*
+     * Calculate energies and move the points.
+     */
+    bool _phase2(ftl::rgbd::FrameSet &fs);
+
+    std::vector<detail::ILWData> data_;
 };
 
 }
-- 
GitLab