From: barate Date: Thu, 7 Apr 2011 13:50:50 +0000 (+0000) Subject: Fixed structural elements with rectangular section (bug PAL 1826) X-Git-Tag: V6_3_0a1~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=346dbd8b2f45543d160b3400cab14b806c946f17;p=modules%2Fgeom.git Fixed structural elements with rectangular section (bug PAL 1826) --- diff --git a/doc/docutils/images/salome-geom-structuralelements.png b/doc/docutils/images/salome-geom-structuralelements.png index 6ed41b12f..9c05f7ecd 100644 Binary files a/doc/docutils/images/salome-geom-structuralelements.png and b/doc/docutils/images/salome-geom-structuralelements.png differ diff --git a/src/GEOM_PY/structelem/orientation.py b/src/GEOM_PY/structelem/orientation.py index 1bf111791..a47b76937 100644 --- a/src/GEOM_PY/structelem/orientation.py +++ b/src/GEOM_PY/structelem/orientation.py @@ -80,11 +80,11 @@ class Orientation1D: logger.warning("Invalid orientation parameter(s) (ignored): %s" % str(mydict)) - def _buildDefaultMarker(self, center, vecX): + def _getDefaultVecYZ(self, center, vecX): """ - Create the default marker, that use the main direction of the 1D - object as the local X axis and the global Z axis to determine the - local Z axis. + Get the vectors Y and Z for the default LCS, that use the main + direction of the 1D object as the local X axis and the global Z axis + to determine the local Z axis. """ xPoint = self.geom.MakeTranslationVector(center, vecX) givenVecZ = self.geom.MakeVectorDXDYDZ(0.0, 0.0, 1.0) @@ -97,18 +97,31 @@ class Orientation1D: zPoint = self.geom.MakeTranslationVector(center, givenVecZ) locPlaneZX = self.geom.MakePlaneThreePnt(center, zPoint, xPoint, 1.0) locY = self.geom.GetNormal(locPlaneZX) - marker = self.geom.MakeMarkerPntTwoVec(center,vecX,locY) - return marker + yPoint = self.geom.MakeTranslationVector(center, locY) + locPlaneXY = self.geom.MakePlaneThreePnt(center, xPoint, yPoint, 1.0) + locZ = self.geom.GetNormal(locPlaneXY) + return (locY, locZ) def buildMarker(self, geom, center, vecX): """ Create a marker with origin `center` and X axis `vecX`. `geom` is the pseudo-geompy object used to build the geometric shapes. """ + (locY, locZ) = self.getVecYZ(geom, center, vecX) + marker = geom.MakeMarkerPntTwoVec(center, vecX, locY) + return marker + + def getVecYZ(self, geom, center, vecX): + """ + Get the vectors Y and Z for the LCS with origin `center` and X axis + `vecX`. `geom` is the pseudo-geompy object used to build the geometric + shapes. + """ self.geom = geom - marker = None + locY = None + locZ = None if self._vectorYCoords is None: - marker = self._buildDefaultMarker(center, vecX) + (locY, locZ) = self._getDefaultVecYZ(center, vecX) else: xPoint = self.geom.MakeTranslationVector(center, vecX) givenLocY = self.geom.MakeVectorDXDYDZ(self._vectorYCoords[0], @@ -118,7 +131,7 @@ class Orientation1D: if abs(angle) < 1e-7 or abs(angle - math.pi) < 1e-7: logger.warning("Vector Y is colinear to the beam X axis, " "using default LCS.") - marker = self._buildDefaultMarker(center, vecX) + (locY, locZ) = self._getDefaultVecYZ(center, vecX) else: yPoint = self.geom.MakeTranslationVector(center, givenLocY) locPlaneXY = self.geom.MakePlaneThreePnt(center, xPoint, @@ -128,13 +141,13 @@ class Orientation1D: locPlaneZX = self.geom.MakePlaneThreePnt(center, zPoint, xPoint, 1.0) locY = self.geom.GetNormal(locPlaneZX) - marker = self.geom.MakeMarkerPntTwoVec(center,vecX,locY) if self._angle != 0.0: angleRad = math.radians(self._angle) - marker = self.geom.Rotate(marker, vecX, angleRad) + locY = self.geom.Rotate(locY, vecX, angleRad) + locZ = self.geom.Rotate(locZ, vecX, angleRad) - return marker + return (locY, locZ) class Orientation2D: diff --git a/src/GEOM_PY/structelem/parts.py b/src/GEOM_PY/structelem/parts.py index c4e2f8fe7..5c18c33bb 100644 --- a/src/GEOM_PY/structelem/parts.py +++ b/src/GEOM_PY/structelem/parts.py @@ -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)