X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_PY%2Fstructelem%2Fparts.py;h=be2c1a9663bb3df68b64a36dc54f6f5fe7f0af45;hb=c1d63ef1f803d255b61ee99fb618bf471add07f4;hp=d697210f92871cd0aa73baab3c8c0045ff77e69b;hpb=3cd92817cb4c5ee5911d6f40fe977b5e57b980e1;p=modules%2Fgeom.git diff --git a/src/GEOM_PY/structelem/parts.py b/src/GEOM_PY/structelem/parts.py old mode 100755 new mode 100644 index d697210f9..be2c1a966 --- a/src/GEOM_PY/structelem/parts.py +++ b/src/GEOM_PY/structelem/parts.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -45,7 +45,7 @@ from salome.kernel import termcolor logger = Logger("salome.geom.structelem.parts", color = termcolor.RED) from salome.geom.geomtools import getGeompy -import orientation +from . import orientation # Filling for the beams FULL = "FULL" @@ -119,7 +119,6 @@ class SubShapeID: ## This class is the base class for all structural element parts. It should # not be instantiated directly (consider it as an "abstract" class). -# \param studyId (integer) the ID of the study in which the part is created. # \param groupName (string) the name of the underlying geometrical primitive # in the study. # \param groupGeomObj (GEOM object) the underlying geometrical primitive. @@ -132,9 +131,6 @@ class StructuralElementPart: This class is the base class for all structural element parts. It should not be instantiated directly (consider it as an "abstract" class). - :type studyId: integer - :param studyId: the ID of the study in which the part is created. - :type groupName: string :param groupName: the name of the underlying geometrical primitive in the study. @@ -153,7 +149,7 @@ class StructuralElementPart: DEFAULT_NAME = "StructElemPart" - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = DEFAULT_NAME, color = None): self._parameters = parameters self.groupName = groupName @@ -161,7 +157,7 @@ class StructuralElementPart: self._orientation = None self._paramUserName = {} self.name = name - self.geom = getGeompy(studyId) + self.geom = getGeompy() self.baseShapesSet = set() self.isMainShape = (groupGeomObj.GetType() != 37) # See geompyDC.ShapeIdToType for type codes if not self.isMainShape: @@ -186,7 +182,7 @@ class StructuralElementPart: if len(nameList) > 0: paramName = nameList[0] for name in nameList: - if self._parameters.has_key(name): + if name in self._parameters: self._paramUserName[paramName] = name return self._parameters[name] return default @@ -196,7 +192,7 @@ class StructuralElementPart: """ This method finds the user name for a parameter. """ - if self._paramUserName.has_key(paramName): + if paramName in self._paramUserName: return self._paramUserName[paramName] else: return paramName @@ -236,11 +232,11 @@ class StructuralElementPart: mindim, value) ## Build the geometric shapes and the markers corresponding to the - # structural element part in the study \em studyId. + # structural element part in the study. def build(self): """ Build the geometric shapes and the markers corresponding to the - structural element part in the study `studyId`. + structural element part in the study. """ shape = self._buildPart() markers = self._buildMarkers() @@ -308,9 +304,9 @@ class Beam(StructuralElementPart): DEFAULT_NAME = "Beam" - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = DEFAULT_NAME, color = None): - StructuralElementPart.__init__(self, studyId, groupName, groupGeomObj, + StructuralElementPart.__init__(self, groupName, groupGeomObj, parameters, name, color) self._orientation = orientation.Orientation1D() @@ -361,7 +357,8 @@ class Beam(StructuralElementPart): face2 = self.geom.MakeFace(wire2, True) shell = self.geom.MakePipeWithDifferentSections([wire1, wire2], [point1, point2], - path, False, False) + path, False, False, + False) closedShell = self.geom.MakeShell([face1, face2, shell]) solid = self.geom.MakeSolid([closedShell]) return solid @@ -453,15 +450,15 @@ class CircularBeam(Beam): """ - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = Beam.DEFAULT_NAME, color = None): if color is None: - if parameters.has_key("R1"): # variable section + if "R1" in parameters: # variable section color = LIGHT_RED else: # constant section color = RED - Beam.__init__(self, studyId, groupName, groupGeomObj, parameters, + Beam.__init__(self, groupName, groupGeomObj, parameters, name, color) self.R1 = self._getParameter(["R1", "R"]) @@ -565,15 +562,15 @@ class RectangularBeam(Beam): """ - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = Beam.DEFAULT_NAME, color = None): if color is None: - if parameters.has_key("HY1") or parameters.has_key("H1"): + if "HY1" in parameters or "H1" in parameters: color = LIGHT_BLUE # variable section else: # constant section color = BLUE - Beam.__init__(self, studyId, groupName, groupGeomObj, parameters, + Beam.__init__(self, groupName, groupGeomObj, parameters, name, color) self.HY1 = self._getParameter(["HY1", "HY", "H1", "H"]) @@ -686,7 +683,7 @@ def getParameterInDict(nameList, parametersDict, default = None): several different names. """ for name in nameList: - if parametersDict.has_key(name): + if name in parametersDict: return parametersDict[name] return default @@ -713,7 +710,7 @@ class GeneralBeam(RectangularBeam): parameters. """ - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = Beam.DEFAULT_NAME, color = None): self.IY1 = getParameterInDict(["IY1", "IY"], parameters) self.IZ1 = getParameterInDict(["IZ1", "IZ"], parameters) @@ -727,12 +724,12 @@ class GeneralBeam(RectangularBeam): parameters["HZ2"] = math.sqrt(12 * self.IY2 / self.A2) if color is None: - if parameters.has_key("IY1"): # variable section + if "IY1" in parameters: # variable section color = LIGHT_GREEN else: # constant section color = GREEN - RectangularBeam.__init__(self, studyId, groupName, groupGeomObj, parameters, + RectangularBeam.__init__(self, groupName, groupGeomObj, parameters, name, color) ## This class is an "abstract" class for all 2D structural element parts. It @@ -748,9 +745,9 @@ class StructuralElementPart2D(StructuralElementPart): DEFAULT_NAME = "StructuralElementPart2D" - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = DEFAULT_NAME): - StructuralElementPart.__init__(self, studyId, groupName, groupGeomObj, + StructuralElementPart.__init__(self, groupName, groupGeomObj, parameters, name) self._orientation = orientation.Orientation2D( self._getParameter(["angleAlpha"]), @@ -790,13 +787,10 @@ class StructuralElementPart2D(StructuralElementPart): self.geom.ShapeType["FACE"]) for face in faces: offsetFace = self._makeFaceOffset(face, offset) - # get tangent plane on surface by parameters + # get the center of the face and the normal at the center center = self.geom.MakeVertexOnSurface(offsetFace, uParam, vParam) - tangPlane = self.geom.MakeTangentPlaneOnFace(offsetFace, - uParam, vParam, - 1.0) - normal = self.geom.GetNormal(tangPlane) + normal = self.geom.GetNormal(offsetFace, center) marker = self._orientation.buildMarker(self.geom, center, normal) listMarkers.append(marker) @@ -836,9 +830,9 @@ class ThickShell(StructuralElementPart2D): DEFAULT_NAME = "ThickShell" - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = DEFAULT_NAME): - StructuralElementPart2D.__init__(self, studyId, groupName, + StructuralElementPart2D.__init__(self, groupName, groupGeomObj, parameters, name) self.thickness = self._getParameter(["Epais"]) logger.debug(repr(self)) @@ -980,9 +974,9 @@ class Grid(StructuralElementPart2D): DEFAULT_NAME = "Grid" - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = DEFAULT_NAME): - StructuralElementPart2D.__init__(self, studyId, groupName, + StructuralElementPart2D.__init__(self, groupName, groupGeomObj, parameters, name) self.xr = self._getParameter(["origAxeX"]) self.yr = self._getParameter(["origAxeY"]) @@ -1108,82 +1102,82 @@ class Grid(StructuralElementPart2D): ## Alias for class GeneralBeam. # \ingroup parts -def VisuPoutreGenerale(studyId, groupName, groupGeomObj, parameters, +def VisuPoutreGenerale(groupName, groupGeomObj, parameters, name = "POUTRE"): """ Alias for class :class:`GeneralBeam`. """ - return GeneralBeam(studyId, groupName, groupGeomObj, parameters, name) + return GeneralBeam(groupName, groupGeomObj, parameters, name) ## Alias for class CircularBeam. # \ingroup parts -def VisuPoutreCercle(studyId, groupName, groupGeomObj, parameters, +def VisuPoutreCercle(groupName, groupGeomObj, parameters, name = "POUTRE"): """ Alias for class :class:`CircularBeam`. """ - return CircularBeam(studyId, groupName, groupGeomObj, parameters, name) + return CircularBeam(groupName, groupGeomObj, parameters, name) ## Alias for class RectangularBeam. # \ingroup parts -def VisuPoutreRectangle(studyId, groupName, groupGeomObj, parameters, +def VisuPoutreRectangle(groupName, groupGeomObj, parameters, name = "POUTRE"): """ Alias for class :class:`RectangularBeam`. """ - return RectangularBeam(studyId, groupName, groupGeomObj, parameters, name) + return RectangularBeam(groupName, groupGeomObj, parameters, name) ## Alias for class GeneralBeam. # \ingroup parts -def VisuBarreGenerale(studyId, groupName, groupGeomObj, parameters, +def VisuBarreGenerale(groupName, groupGeomObj, parameters, name = "BARRE"): """ Alias for class :class:`GeneralBeam`. """ - return GeneralBeam(studyId, groupName, groupGeomObj, parameters, name, + return GeneralBeam(groupName, groupGeomObj, parameters, name, color = ORANGE) ## Alias for class RectangularBeam. # \ingroup parts -def VisuBarreRectangle(studyId, groupName, groupGeomObj, parameters, +def VisuBarreRectangle(groupName, groupGeomObj, parameters, name = "BARRE"): """ Alias for class :class:`RectangularBeam`. """ - return RectangularBeam(studyId, groupName, groupGeomObj, parameters, name, + return RectangularBeam(groupName, groupGeomObj, parameters, name, color = ORANGE) ## Alias for class CircularBeam. # \ingroup parts -def VisuBarreCercle(studyId, groupName, groupGeomObj, parameters, +def VisuBarreCercle(groupName, groupGeomObj, parameters, name = "BARRE"): """ Alias for class :class:`CircularBeam`. """ - return CircularBeam(studyId, groupName, groupGeomObj, parameters, name, + return CircularBeam(groupName, groupGeomObj, parameters, name, color = ORANGE) ## Alias for class CircularBeam. # \ingroup parts -def VisuCable(studyId, groupName, groupGeomObj, parameters, name = "CABLE"): +def VisuCable(groupName, groupGeomObj, parameters, name = "CABLE"): """ Alias for class :class:`CircularBeam`. """ - return CircularBeam(studyId, groupName, groupGeomObj, parameters, name, + return CircularBeam(groupName, groupGeomObj, parameters, name, color = PURPLE) ## Alias for class ThickShell. # \ingroup parts -def VisuCoque(studyId, groupName, groupGeomObj, parameters, name = "COQUE"): +def VisuCoque(groupName, groupGeomObj, parameters, name = "COQUE"): """ Alias for class :class:`ThickShell`. """ - return ThickShell(studyId, groupName, groupGeomObj, parameters, name) + return ThickShell(groupName, groupGeomObj, parameters, name) ## Alias for class Grid. # \ingroup parts -def VisuGrille(studyId, groupName, groupGeomObj, parameters, name = "GRILLE"): +def VisuGrille(groupName, groupGeomObj, parameters, name = "GRILLE"): """ Alias for class :class:`Grid`. """ - return Grid(studyId, groupName, groupGeomObj, parameters, name) + return Grid(groupName, groupGeomObj, parameters, name)