diff python/moving.py @ 880:000555430b28

adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 14 Mar 2017 17:10:35 -0400
parents d1ff6917d082
children 8ba82b371eea
line wrap: on
line diff
--- a/python/moving.py	Tue Mar 14 14:22:14 2017 -0400
+++ b/python/moving.py	Tue Mar 14 17:10:35 2017 -0400
@@ -1242,8 +1242,14 @@
     def setUserType(self, userType):
         self.userType = userType
 
-    def setFeatures(self, features):
-        self.features = [features[i] for i in self.featureNumbers]
+    def setFeatures(self, features, featuresOrdered = False):
+        '''Sets the features in the features field based on featureNumbers
+        if not all features are loaded from 0, one needs to renumber in a dict'''
+        if featuresOrdered:
+            tmp = features
+        else:
+            tmp = {f.getNum():f for f in features}
+        self.features = [tmp[i] for i in self.featureNumbers]
 
     def getFeatures(self):
         return self.features