1 """Abstract root classes of user-defined Python features producing a Body
2 Author: Daniel Brunier-Coulin
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
9 class Feature(ModelAPI_Feature):
10 """Base class of user-defined Python features."""
14 ModelAPI_Feature.__init__(self)
16 def addRealInput (self, inputid):
17 """Add double input"""
18 self.data().addAttribute(inputid, ModelAPI_AttributeDouble_typeId())
20 def getRealInput (self, inputid):
21 """Returns double input"""
22 return self.data().real(inputid).value()
24 def addResult (self, result):
26 shape = result.shape()
27 body = self.document().createBody( self.data() )
33 """Base class of hight level Python interfaces to features."""
35 def __init__(self, container, fid):
37 ### Create the feature
38 self.my = container.addFeature(fid)
40 def setRealInput (self, inputid, value):
42 self.my.data().real(inputid).setValue(value)
44 def areInputValid (self):
45 """Returns True if the input is valid"""
46 return ModelAPI_Session.get().validators().validate(self.my)
49 """Build the feature result"""