From: eap Date: Wed, 24 Oct 2012 15:46:31 +0000 (+0000) Subject: 0021921: [CEA 690] GetVolume applied on many elements has performance issue X-Git-Tag: V6_6_0b1~39 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6d1ea10cad97c4dc9a9b7d009ec3ef641f914c23;p=modules%2Fsmesh.git 0021921: [CEA 690] GetVolume applied on many elements has performance issue Optimize _valueFromFunctor() --- diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index c57c6773d..87d32ec81 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -957,6 +957,7 @@ class Mesh: geom = 0 mesh = 0 editor = 0 + functors = [None] * SMESH.FT_Undefined._v ## Constructor # @@ -4056,9 +4057,16 @@ class Mesh: def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords): return self.editor.CreateHoleSkin( radius, theShape, groupName, theNodesCoords ) + def _getFunctor(self, funcType ): + fn = self.functors[ funcType._v ] + if not fn: + fn = self.smeshpyD.GetFunctor(funcType) + fn.SetMesh(self.mesh) + self.functors[ funcType._v ] = fn + return fn + def _valueFromFunctor(self, funcType, elemId): - fn = self.smeshpyD.GetFunctor(funcType) - fn.SetMesh(self.mesh) + fn = self._getFunctor( funcType ) if fn.GetElementType() == self.GetElementType(elemId, True): val = fn.GetValue(elemId) else: