# -*- 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 is used to compute the orientation of the different parts in a
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)
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],
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,
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: