浏览代码

Fix discrete view

Eric Ramat 3 年之前
父节点
当前提交
dff7de1e9a
共有 2 个文件被更改,包括 20 次插入18 次删除
  1. 1 1
      src/artis-star/common/observer/Observer.hpp
  2. 19 17
      src/artis-star/common/observer/View.hpp

+ 1 - 1
src/artis-star/common/observer/Observer.hpp

@@ -110,7 +110,7 @@ private:
   {
     for (typename Views::iterator it = _views.begin(); it != _views.end();
          ++it) {
-      it->second->observe(t);
+      it->second->observe(t, _step == 0);
     }
   }
 

+ 19 - 17
src/artis-star/common/observer/View.hpp

@@ -215,7 +215,7 @@ public:
     }
   }
 
-  virtual void observe(double time)
+  virtual void observe(double time, bool trim)
   {
     for (typename Selectors::const_iterator it = _selectors.begin();
          it != _selectors.end(); ++it) {
@@ -232,29 +232,31 @@ public:
       }
     }
 
-    bool ok = true;
-    auto it = _values.begin();
+    if (trim) {
+      bool ok = true;
+      auto it = _values.begin();
 
-    while (it != _values.end() and ok) {
-      const auto &v = it->second.begin()->second;
+      while (it != _values.end() and ok) {
+        const auto &v = it->second.begin()->second;
 
-      if (v.back().second.is_null()) {
-        ++it;
-      } else {
-        if (v.size() > 1) {
-          if (v.back().second == v[v.size() - 2].second) {
-            ++it;
+        if (v.back().second.is_null()) {
+          ++it;
+        } else {
+          if (v.size() > 1) {
+            if (v.back().second == v[v.size() - 2].second) {
+              ++it;
+            } else {
+              ok = false;
+            }
           } else {
             ok = false;
           }
-        } else {
-          ok = false;
         }
       }
-    }
-    if (ok) {
-      for (auto &v: _values) {
-        v.second.begin()->second.pop_back();
+      if (ok) {
+        for (auto &v: _values) {
+          v.second.begin()->second.pop_back();
+        }
       }
     }
   }