Back to index

salome-geom  6.5.0
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
GEOM_PY.structelem.orientation.Orientation2D Class Reference

List of all members.

Public Member Functions

def __init__
def __repr__
def buildMarker

Public Attributes

 geom

Private Member Functions

def _buildDefaultMarker
def _buildMarkerRefVecX

Private Attributes

 _alpha
 _beta
 _vect

Detailed Description

This class is used to compute the orientation of 2D elements and to build
the corresponding markers. Angles `alpha` and `beta` are used to determine
the local coordinate system for the 2D element. If `vect` is not
:const:`None`, it is used instead of `alpha` and `beta`.

Definition at line 153 of file orientation.py.


Constructor & Destructor Documentation

def GEOM_PY.structelem.orientation.Orientation2D.__init__ (   self,
  alpha,
  beta,
  vect 
)

Definition at line 161 of file orientation.py.

00161 
00162     def __init__(self, alpha, beta, vect):
00163         self.geom = None
00164         self._alpha = alpha
00165         self._beta = beta
00166         self._vect = vect


Member Function Documentation

Definition at line 167 of file orientation.py.

00167 
00168     def __repr__(self):
00169         reprdict = self.__dict__.copy()
00170         del reprdict["geom"]
00171         return '%s(%s)' % (self.__class__.__name__, reprdict)

def GEOM_PY.structelem.orientation.Orientation2D._buildDefaultMarker (   self,
  center,
  normal,
  warnings = True 
) [private]
Create the default marker, that use the normal vector of the 2D object
as the local Z axis and the global X axis to determine the local X
axis. `warnings` can be used to enable or disable the logging of
warning messages.

Definition at line 172 of file orientation.py.

00172 
00173     def _buildDefaultMarker(self, center, normal, warnings = True):
00174         """
00175         Create the default marker, that use the normal vector of the 2D object
00176         as the local Z axis and the global X axis to determine the local X
00177         axis. `warnings` can be used to enable or disable the logging of
00178         warning messages.
00179         """
00180         marker = None
00181         globalVecX = self.geom.MakeVectorDXDYDZ(1.0, 0.0, 0.0)
00182         angle = self.geom.GetAngleRadians(normal, globalVecX)
00183         if abs(angle) < 1e-7 or abs(angle - math.pi) < 1e-7:
00184             if warnings:
00185                 logger.warning("Face normal is colinear to absolute X axis. "
00186                                "Absolute Y axis will be used to determine "
00187                                "local X axis.")
00188             globalVecY = self.geom.MakeVectorDXDYDZ(0.0, 1.0, 0.0)
00189             marker = self._buildMarkerRefVecX(center, normal, globalVecY)
00190         else:
00191             marker = self._buildMarkerRefVecX(center, normal, globalVecX)
00192         return marker

Here is the call graph for this function:

Here is the caller graph for this function:

def GEOM_PY.structelem.orientation.Orientation2D._buildMarkerRefVecX (   self,
  center,
  normal,
  refVecX 
) [private]
Create a marker using `normal` as Z axis and `refVecX` to determine
the X axis.

Definition at line 193 of file orientation.py.

00193 
00194     def _buildMarkerRefVecX(self, center, normal, refVecX):
00195         """
00196         Create a marker using `normal` as Z axis and `refVecX` to determine
00197         the X axis.
00198         """
00199         xPoint = self.geom.MakeTranslationVector(center, refVecX)
00200         zPoint = self.geom.MakeTranslationVector(center, normal)
00201         locPlaneZX = self.geom.MakePlaneThreePnt(center, zPoint, xPoint, 1.0)
00202         locY = self.geom.GetNormal(locPlaneZX)
00203         yPoint = self.geom.MakeTranslationVector(center, locY)
00204         locPlaneYZ = self.geom.MakePlaneThreePnt(center, yPoint, zPoint, 1.0)
00205         locX = self.geom.GetNormal(locPlaneYZ)
00206         marker = self.geom.MakeMarkerPntTwoVec(center, locX, locY)
00207         return marker

Here is the caller graph for this function:

def GEOM_PY.structelem.orientation.Orientation2D.buildMarker (   self,
  geom,
  center,
  normal,
  warnings = True 
)
Create a marker with origin `center` and `normal` as Z axis. The other
axes are computed using the parameters alpha and beta of the
Orientation2D instance. `geom` is the pseudo-geompy object used to
build the geometric shapes. `warnings` can be used to enable or
disable the logging of warning messages.

Definition at line 208 of file orientation.py.

00208 
00209     def buildMarker(self, geom, center, normal, warnings = True):
00210         """
00211         Create a marker with origin `center` and `normal` as Z axis. The other
00212         axes are computed using the parameters alpha and beta of the
00213         Orientation2D instance. `geom` is the pseudo-geompy object used to
00214         build the geometric shapes. `warnings` can be used to enable or
00215         disable the logging of warning messages.
00216         """
00217         self.geom = geom
00218         marker = None
00219         refVecX = None
00220         if self._vect is not None:
00221             # Using vector parameter
00222             if abs(self._vect[0]) <= 1e-7 and abs(self._vect[1]) <= 1e-7 and \
00223                                               abs(self._vect[2]) <= 1e-7:
00224                 if warnings:
00225                     logger.warning("Vector too small: %s, using default LCS" %
00226                                    self._vect)
00227             else:
00228                 refVecX = self.geom.MakeVectorDXDYDZ(self._vect[0],
00229                                                      self._vect[1],
00230                                                      self._vect[2])
00231         elif self._alpha is not None and self._beta is not None:
00232             # Using alpha and beta angles
00233             alphaRad = math.radians(self._alpha)
00234             betaRad = math.radians(self._beta)
00235             if abs(alphaRad) <= 1e-7 and abs(betaRad) <= 1e-7:
00236                 if warnings:
00237                     logger.warning("Angles too small: (%g, %g), using "
00238                                    "default LCS" % (self._alpha, self._beta))
00239             else:
00240                 # rotate global CS with angles alpha and beta
00241                 refVecX = self.geom.MakeVectorDXDYDZ(1.0, 0.0, 0.0)
00242                 refVecY = self.geom.MakeVectorDXDYDZ(0.0, 1.0, 0.0)
00243                 globalVecZ = self.geom.MakeVectorDXDYDZ(0.0, 0.0, 1.0)
00244                 if abs(alphaRad) > 1e-7:
00245                     refVecX = self.geom.Rotate(refVecX, globalVecZ, alphaRad)
00246                     refVecY = self.geom.Rotate(refVecY, globalVecZ, alphaRad)
00247                 if abs(betaRad) > 1e-7:
00248                     refVecX = self.geom.Rotate(refVecX, refVecY, betaRad)
00249     
00250         if refVecX is not None:
00251             # build local coordinate system
00252             angle = self.geom.GetAngleRadians(normal, refVecX)
00253             if abs(angle) < 1e-7 or abs(angle - math.pi) < 1e-7:
00254                 if warnings:
00255                     logger.warning("Face normal is colinear to the reference "
00256                                    "X axis, using default LCS.")
00257             else:
00258                 marker = self._buildMarkerRefVecX(center, normal, refVecX)
00259 
00260         if marker is None:
00261             marker = self._buildDefaultMarker(center, normal, warnings)
00262 
00263         return marker

Here is the call graph for this function:


Member Data Documentation

Definition at line 163 of file orientation.py.

Definition at line 164 of file orientation.py.

Definition at line 165 of file orientation.py.

Definition at line 162 of file orientation.py.


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