From efbb9df5bdfb61e1254131553d9b4ad5c029e79b Mon Sep 17 00:00:00 2001
From: joanvallve <jvallve@iri.upc.edu>
Date: Tue, 26 May 2020 10:51:13 +0200
Subject: [PATCH] moved setProblem from PM to PB and removed automatic
 setOrigin

---
 include/core/processor/processor_base.h   |  2 ++
 include/core/processor/processor_motion.h |  1 -
 src/processor/processor_base.cpp          | 17 +++++++++++++++++
 src/processor/processor_motion.cpp        | 18 ------------------
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h
index 00d569801..b12d92f10 100644
--- a/include/core/processor/processor_base.h
+++ b/include/core/processor/processor_base.h
@@ -326,6 +326,8 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce
 
         virtual bool permittedAuxFrame() final;
 
+        virtual void setProblem(ProblemPtr) override;
+
     public:
         /**\brief notify a new keyframe made by another processor
          *
diff --git a/include/core/processor/processor_motion.h b/include/core/processor/processor_motion.h
index 4568c6fb3..2eebf5410 100644
--- a/include/core/processor/processor_motion.h
+++ b/include/core/processor/processor_motion.h
@@ -147,7 +147,6 @@ class ProcessorMotion : public ProcessorBase, public IsMotion
     protected:
         ParamsProcessorMotionPtr params_motion_;
         ProcessingStep processing_step_;        ///< State machine controlling the processing step
-        virtual void setProblem(ProblemPtr) override;
 
     // This is the main public interface
     public:
diff --git a/src/processor/processor_base.cpp b/src/processor/processor_base.cpp
index 101bd5abb..6f28aef4d 100644
--- a/src/processor/processor_base.cpp
+++ b/src/processor/processor_base.cpp
@@ -104,6 +104,23 @@ void ProcessorBase::link(SensorBasePtr _sen_ptr)
         WOLF_WARN("Linking with a nullptr");
     }
 }
+
+void ProcessorBase::setProblem(ProblemPtr _problem)
+{
+    std::string str = "Processor works with " + std::to_string(dim_) + "D but problem is " + std::to_string(_problem->getDim()) + "D";
+    assert((dim_ == 0 or dim_ == _problem->getDim()) && str.c_str());
+
+    if (_problem == nullptr or _problem == this->getProblem())
+        return;
+
+    NodeBase::setProblem(_problem);
+
+    // adding processor is motion to the processor is motion vector
+    auto is_motion_ptr = std::dynamic_pointer_cast<IsMotion>(shared_from_this());
+    if (is_motion_ptr)
+        getProblem()->addProcessorIsMotion(is_motion_ptr);
+}
+
 /////////////////////////////////////////////////////////////////////////////////////////
 
 void BufferPackKeyFrame::add(const FrameBasePtr& _key_frame, const double& _time_tolerance)
diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp
index b08d88dc7..a6cddeff1 100644
--- a/src/processor/processor_motion.cpp
+++ b/src/processor/processor_motion.cpp
@@ -691,24 +691,6 @@ PackKeyFramePtr ProcessorMotion::computeProcessingStep()
     return nullptr;
 }
 
-void ProcessorMotion::setProblem(ProblemPtr _problem)
-{
-    std::string str = "Processor works with " + std::to_string(dim_) + "D but problem is " + std::to_string(_problem->getDim()) + "D";
-    assert((dim_ == 0 or dim_ == _problem->getDim()) && str.c_str());
-
-    if (_problem == nullptr or _problem == this->getProblem())
-        return;
-
-    NodeBase::setProblem(_problem);
-
-    // set the origin
-    if (origin_ptr_ == nullptr && this->getProblem()->getLastKeyFrame() != nullptr)
-        this->setOrigin(this->getProblem()->getLastKeyFrame());
-    
-    // adding processor is motion to the processor is motion vector
-    getProblem()->addProcessorIsMotion(std::dynamic_pointer_cast<IsMotion>(shared_from_this()));
-}
-
 bool ProcessorMotion::storeKeyFrame(FrameBasePtr _frame_ptr)
 {
   return true;
-- 
GitLab