Parcourir la source

Fix discrete view

Eric Ramat il y a 2 ans
Parent
commit
dff7de1e9a

+ 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();
+        }
       }
     }
   }