Forráskód Böngészése

Set node values into threshold function only if needed

It can be expensive to set the same node values. vtkPiecewiseFunction
would fire a ModifiedEvent event even if the node is the same which can
be computationally expensive.
Julien Finet 13 éve
szülő
commit
395a6866ca
1 módosított fájl, 11 hozzáadás és 1 törlés
  1. 11 1
      Libs/Visualization/VTK/Widgets/ctkVTKThresholdWidget.cpp

+ 11 - 1
Libs/Visualization/VTK/Widgets/ctkVTKThresholdWidget.cpp

@@ -306,7 +306,17 @@ void ctkVTKThresholdWidgetPrivate::setNodeValue(int index, double* nodeValues)
     }
   else
     {
-    this->PiecewiseFunction->SetNodeValue(index, nodeValues);
+    double values[4];
+    this->PiecewiseFunction->GetNodeValue(index, values);
+    // Updating the node will fire a modified event which can be costly
+    // We change the node values only if there is a change.
+    if (values[0] != nodeValues[0] ||
+        values[1] != nodeValues[1] ||
+        values[2] != nodeValues[2] ||
+        values[3] != nodeValues[3])
+      {
+      this->PiecewiseFunction->SetNodeValue(index, nodeValues);
+      }
     }
 }