Back to index

salome-geom  6.5.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
GEOM_PY.structelem.StructuralElement Class Reference

List of all members.

Public Member Functions

def __init__
def addPart
def addOrientation
def build
def display

Static Public Member Functions

def showElement

Private Member Functions

def _getSObject

Private Attributes

 _parts
 _shapeDict
 _id
 _studyEditor
 _SObject

Static Private Attributes

int _counter = 1
int _mainFolderTag = 14725

Detailed Description

This class represents a structural element, i.e. a set of geometrical
objects built along geometrical primitives. The parameter `studyId`
defines the ID of the study that will contain the structural element. If
it is :const:`None` or not specified, the constructor will use the ID of
the active study as defined by :func:`salome.kernel.studyedit.getActiveStudyId`
function. Structural elements are normally created by the class
:class:`StructuralElementManager`, so this class should not be
instantiated directly in the general case.

Definition at line 238 of file __init__.py.


Constructor & Destructor Documentation

def GEOM_PY.structelem.StructuralElement.__init__ (   self,
  studyId = None 
)

Definition at line 252 of file __init__.py.

00252 
00253     def __init__(self, studyId = None):
00254         # _parts is the dictionary mapping group name to structural element
00255         # part. _shapeDict is the dictionary mapping SubShapeID objects to
00256         # structural element parts. Both are used to avoid duplicate shapes
00257         # in structural elements.
00258         self._parts = {}
00259         self._shapeDict = {}
00260         self._id = StructuralElement._counter
00261         StructuralElement._counter += 1
00262         self._studyEditor = getStudyEditor(studyId)
00263         logger.debug("Creating structural element in study %s" %
00264                      self._studyEditor.studyId)
00265         self._SObject = None


Member Function Documentation

Find or create the study object corresponding to the structural
element. This object is named "SE_N" where N is a numerical ID. 

Definition at line 266 of file __init__.py.

00266 
00267     def _getSObject(self):
00268         """
00269         Find or create the study object corresponding to the structural
00270         element. This object is named "SE_N" where N is a numerical ID. 
00271         """
00272         if self._SObject is None:
00273             geomComponent = self._studyEditor.study.FindComponent("GEOM")
00274             mainFolder = self._studyEditor.setItemAtTag(geomComponent,
00275                                             StructuralElement._mainFolderTag,
00276                                             name = "Structural Elements")
00277             self._SObject = self._studyEditor.findOrCreateItem(mainFolder,
00278                                             name = "SE_" + str(self._id))
00279         return self._SObject

def GEOM_PY.structelem.StructuralElement.addOrientation (   self,
  meshGroup,
  orientParams 
)
Add orientation information to a part in the structural element. This
information will be used to build the corresponding markers.

:type  meshGroup: string
:param meshGroup: the name of a geometrical primitive. The orientation
          information will apply to the structural element
          part built along this primitive.

:type  orientParams: dictionary
:param orientParams: parameters defining the orientation of the
             structural element part. Those parameters are
             detailed in class
             :class:`~orientation.Orientation1D`.

Definition at line 317 of file __init__.py.

00317 
00318     def addOrientation(self, meshGroup, orientParams):
00319         """
00320         Add orientation information to a part in the structural element. This
00321         information will be used to build the corresponding markers.
00322 
00323         :type  meshGroup: string
00324         :param meshGroup: the name of a geometrical primitive. The orientation
00325                           information will apply to the structural element
00326                           part built along this primitive.
00327 
00328         :type  orientParams: dictionary
00329         :param orientParams: parameters defining the orientation of the
00330                              structural element part. Those parameters are
00331                              detailed in class
00332                              :class:`~orientation.Orientation1D`.
00333 
00334         """
00335         if self._parts.has_key(meshGroup):
00336             self._parts[meshGroup].addOrientation(orientParams)
00337         else:
00338             logger.warning('Mesh group "%s" not found in structural element, '
00339                            'cannot set orientation.' % meshGroup)

def GEOM_PY.structelem.StructuralElement.addPart (   self,
  newpart 
)
Add a part to the structural element.

:type  newpart: :class:`~parts.StructuralElementPart`
:param newpart: the part to add to the structural element.

Definition at line 280 of file __init__.py.

00280 
00281     def addPart(self, newpart):
00282         """
00283         Add a part to the structural element.
00284 
00285         :type  newpart: :class:`~parts.StructuralElementPart`
00286         :param newpart: the part to add to the structural element.
00287 
00288         """
00289         newshapes = newpart.baseShapesSet
00290 
00291         # Check duplicate groups
00292         if self._parts.has_key(newpart.groupName):
00293             logger.warning('Mesh group "%s" is used several times in the '
00294                            'structural element. Only the last definition '
00295                            'will be used.' % newpart.groupName)
00296         else:
00297             # Check duplicate shapes
00298             intersect = newshapes.intersection(self._shapeDict.keys())
00299             while len(intersect) > 0:
00300                 shape, = intersect
00301                 oldpartwithshape = self._shapeDict[shape]
00302                 oldpartshapes = oldpartwithshape.baseShapesSet
00303                 intersectwitholdpart = intersect.intersection(oldpartshapes)
00304                 logger.warning('Some shapes are common to groups "%s" and '
00305                                '"%s". For those, the parameters defined for '
00306                                '"%s" will be used.' %
00307                                (oldpartwithshape.groupName, newpart.groupName,
00308                                 newpart.groupName))
00309                 oldpartwithshape.baseShapesSet = \
00310                                 oldpartshapes.difference(intersectwitholdpart)
00311                 intersect = intersect.difference(intersectwitholdpart)
00312 
00313         # Finally add the new part in the structural element
00314         self._parts[newpart.groupName] = newpart
00315         for shape in newshapes:
00316             self._shapeDict[shape] = newpart

Build the geometric shapes and the markers corresponding to the
different parts of the structural element, and add them to the study.

Definition at line 340 of file __init__.py.

00340 
00341     def build(self):
00342         """
00343         Build the geometric shapes and the markers corresponding to the
00344         different parts of the structural element, and add them to the study.
00345         """
00346         gg = salome.ImportComponentGUI("GEOM")
00347         for part in self._parts.itervalues():
00348             # Build the structural element part
00349             logger.debug("Building %s" % part)
00350             try:
00351                 (shape, markers) = part.build()
00352                 if shape is None:
00353                     logger.error("Part %s has not been built" % part)
00354                     continue
00355             except:
00356                 logger.exception("Couldn't build part %s" % part)
00357                 continue
00358             
00359             # Add the new objects to the study
00360             IOR = self._studyEditor.study.ConvertObjectToIOR(shape)
00361             shapeSObjName = part.name + "_" + part.groupName
00362             icon = None
00363             if salome.hasDesktop():
00364                 icon = gg.getShapeTypeIcon(IOR)
00365             shapeSObj = self._studyEditor.createItem(self._getSObject(),
00366                                             name = shapeSObjName, IOR = IOR,
00367                                             icon = icon)
00368             if markers is not None and len(markers) > 0:
00369                 i = 1
00370                 for marker in markers:
00371                     markerIOR = \
00372                             self._studyEditor.study.ConvertObjectToIOR(marker)
00373                     markerSObjName = "Orient_" + shapeSObjName
00374                     if len(markers) > 1:
00375                         markerSObjName += "_%d" % i
00376                     markerSObj = self._studyEditor.createItem(
00377                                                 self._getSObject(),
00378                                                 name = markerSObjName,
00379                                                 IOR = markerIOR,
00380                                                 icon = "ICON_OBJBROWSER_LCS")
00381                     i += 1

Here is the call graph for this function:

Display the structural element in the geom view.

Definition at line 382 of file __init__.py.

00382 
00383     def display(self):
00384         """
00385         Display the structural element in the geom view.
00386         """
00387         StructuralElement.showElement(self._SObject)

def GEOM_PY.structelem.StructuralElement.showElement (   theSObject) [static]
Display the structural element corresponding to the study object
`theSObject`

Definition at line 389 of file __init__.py.

00389 
00390     def showElement(theSObject):
00391         """
00392         Display the structural element corresponding to the study object
00393         `theSObject`
00394         """
00395         if theSObject is not None:
00396             gg = salome.ImportComponentGUI("GEOM")
00397             aStudy = theSObject.GetStudy()
00398             editor = getStudyEditor(aStudy._get_StudyId())
00399             aIterator = aStudy.NewChildIterator(theSObject)
00400             aIterator.Init()
00401             while aIterator.More():
00402                 sobj = aIterator.Value()
00403                 icon = editor.getIcon(sobj)
00404                 if icon != "ICON_OBJBROWSER_LCS":
00405                     entry = aIterator.Value().GetID()
00406                     gg.createAndDisplayGO(entry)
00407                     gg.setDisplayMode(entry, 1)
00408                 aIterator.Next()
00409 


Member Data Documentation

Definition at line 249 of file __init__.py.

Definition at line 259 of file __init__.py.

Definition at line 250 of file __init__.py.

Definition at line 257 of file __init__.py.

Definition at line 258 of file __init__.py.

Definition at line 264 of file __init__.py.

Definition at line 261 of file __init__.py.


The documentation for this class was generated from the following file: