Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/geom.git] / src / GEOM_PY / structelem / parts.py
index c4e2f8fe725dc7c4a561f58b74677d4e626fcbac..30420fc7d0ef12844d538b6b11ecc6d5469b6370 100644 (file)
@@ -1,22 +1,22 @@
 # -*- coding: utf-8 -*-
 #
-#  Copyright (C) 2007-2009      EDF R&D
-# 
-#    This file is part of PAL_SRC.
+# Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 #
-#    PAL_SRC is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
 #
-#    PAL_SRC is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
-#    along with PAL_SRC; if not, write to the Free Software
-#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 """
 This module defines the different structural element parts. It is used to
@@ -530,39 +530,45 @@ class RectangularBeam(Beam):
                             "%s - 2 * %s" % (self._getParamUserName("HZ2"),
                                              self._getParamUserName("EPZ2")))
 
-    def _makeRectangle(self, HY, HZ, planeSect):
+    def _makeRectangle(self, HY, HZ, lcs):
         """
         Create a rectangle in the specified plane.
         """
         halfHY = HY / 2.0
         halfHZ = HZ / 2.0
-        sketchStr = "Sketcher:F %g" % (-halfHZ) + " %g" % (-halfHY) + ":"
-        sketchStr += "TT %g" % (halfHZ) + " %g" % (-halfHY) + ":"
-        sketchStr += "TT %g" % (halfHZ) + " %g" % (halfHY) + ":" 
-        sketchStr += "TT %g" % (-halfHZ) + " %g" % (halfHY) + ":WW"
+        sketchStr = "Sketcher:F %g %g:" % (-halfHY, -halfHZ)
+        sketchStr += "TT %g %g:" % (halfHY, -halfHZ)
+        sketchStr += "TT %g %g:" % (halfHY, halfHZ)
+        sketchStr += "TT %g %g:WW" % (-halfHY, halfHZ)
         logger.debug('Drawing rectangle: "%s"' % sketchStr)
-        sketch = self.geom.MakeSketcherOnPlane(sketchStr, planeSect)
+        sketch = self.geom.MakeSketcherOnPlane(sketchStr, lcs)
         return sketch
 
-    def _makeSectionWires(self, fPoint, fNormal, lPoint, lNormal):
+    def _makeSectionRectangles(self, point, vecX, HY, HZ, EPY, EPZ):
         """
-        Create the rectangular sections used to build the pipe.
+        Create one side of the rectangular sections used to build the pipe.
         """
-        planeSect1 = self.geom.MakePlane(fPoint, fNormal, 1.0)
-        outerRect1 = self._makeRectangle(self.HY1, self.HZ1, planeSect1)
-        planeSect2 = self.geom.MakePlane(lPoint, lNormal, 1.0)
-        outerRect2 = self._makeRectangle(self.HY2, self.HZ2, planeSect2)
+        (vecY, vecZ) = self._orientation.getVecYZ(self.geom, point, vecX)
+        lcs = self.geom.MakeMarkerPntTwoVec(point, vecY, vecZ)
+        outerRect = self._makeRectangle(HY, HZ, lcs)
         if self.filling == HOLLOW:
-            innerRect1 = self._makeRectangle(self.HY1 - 2 * self.EPY1,
-                                             self.HZ1 - 2 * self.EPZ1,
-                                             planeSect1)
-            innerRect2 = self._makeRectangle(self.HY2 - 2 * self.EPY2,
-                                             self.HZ2 - 2 * self.EPZ2,
-                                             planeSect2)
+            innerRect = self._makeRectangle(HY - 2.0 * EPY,
+                                            HZ - 2.0 * EPZ,
+                                            lcs)
         else:
-            innerRect1 = None
-            innerRect2 = None
+            innerRect = None
+        return (outerRect, innerRect)
 
+    def _makeSectionWires(self, fPoint, fNormal, lPoint, lNormal):
+        """
+        Create the rectangular sections used to build the pipe.
+        """
+        (outerRect1, innerRect1) = \
+            self._makeSectionRectangles(fPoint, fNormal, self.HY1, self.HZ1,
+                                        self.EPY1, self.EPZ1)
+        (outerRect2, innerRect2) = \
+            self._makeSectionRectangles(lPoint, lNormal, self.HY2, self.HZ2,
+                                        self.EPY2, self.EPZ2)
         return (outerRect1, innerRect1, outerRect2, innerRect2)