Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/gp_Ax1.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (c) 1991-1999 Matra Datavision
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _gp_Ax1_HeaderFile
0016 #define _gp_Ax1_HeaderFile
0017 
0018 #include <gp_Pnt.hxx>
0019 #include <gp_Dir.hxx>
0020 
0021 class gp_Ax2;
0022 class gp_Trsf;
0023 class gp_Vec;
0024 
0025 //! Describes an axis in 3D space.
0026 //! An axis is defined by:
0027 //! -   its origin (also referred to as its "Location point"), and
0028 //! -   its unit vector (referred to as its "Direction" or "main   Direction").
0029 //! An axis is used:
0030 //! -   to describe 3D geometric entities (for example, the
0031 //! axis of a revolution entity). It serves the same purpose
0032 //! as the STEP function "axis placement one axis", or
0033 //! -   to define geometric transformations (axis of
0034 //! symmetry, axis of rotation, and so on).
0035 //! For example, this entity can be used to locate a geometric entity
0036 //! or to define a symmetry axis.
0037 class gp_Ax1 
0038 {
0039 public:
0040 
0041   DEFINE_STANDARD_ALLOC
0042 
0043   //! Creates an axis object representing Z axis of
0044   //! the reference coordinate system.
0045   gp_Ax1()
0046   : loc(0.,0.,0.), vdir(0.,0.,1.)
0047   {}
0048 
0049   //! P is the location point and V is the direction of <me>.
0050   gp_Ax1 (const gp_Pnt& theP, const gp_Dir& theV)
0051   : loc(theP), vdir (theV)
0052   {}
0053 
0054   //! Assigns V as the "Direction"  of this axis.
0055   void SetDirection (const gp_Dir& theV) { vdir = theV; }
0056 
0057   //! Assigns  P as the origin of this axis.
0058   void SetLocation (const gp_Pnt& theP) { loc = theP; }
0059 
0060   //! Returns the direction of <me>.
0061   const gp_Dir& Direction() const { return vdir; }
0062 
0063   //! Returns the location point of <me>.
0064   const gp_Pnt& Location() const { return loc; }
0065 
0066   //! Returns True if  :
0067   //! . the angle between <me> and <Other> is lower or equal
0068   //! to <AngularTolerance> and
0069   //! . the distance between <me>.Location() and <Other> is lower
0070   //! or equal to <LinearTolerance> and
0071   //! . the distance between <Other>.Location() and <me> is lower
0072   //! or equal to LinearTolerance.
0073   Standard_EXPORT Standard_Boolean IsCoaxial (const gp_Ax1& Other, const Standard_Real AngularTolerance, const Standard_Real LinearTolerance) const;
0074 
0075   //! Returns True if the direction of this and another axis are normal to each other.
0076   //! That is, if the angle between the two axes is equal to Pi/2.
0077   //! Note: the tolerance criterion is given by theAngularTolerance.
0078   Standard_Boolean IsNormal (const gp_Ax1& theOther, const Standard_Real theAngularTolerance) const
0079   {
0080     return vdir.IsNormal (theOther.vdir, theAngularTolerance);
0081   }
0082 
0083   //! Returns True if the direction of this and another axis are parallel with opposite orientation.
0084   //! That is, if the angle between the two axes is equal to Pi.
0085   //! Note: the tolerance criterion is given by theAngularTolerance.
0086   Standard_Boolean IsOpposite (const gp_Ax1& theOther, const Standard_Real theAngularTolerance) const
0087   {
0088     return vdir.IsOpposite (theOther.vdir, theAngularTolerance);
0089   }
0090 
0091   //! Returns True if the direction of this and another axis are parallel with same orientation or opposite orientation.
0092   //! That is, if the angle between the two axes is equal to 0 or Pi.
0093   //! Note: the tolerance criterion is given by theAngularTolerance.
0094   Standard_Boolean IsParallel (const gp_Ax1& theOther, const Standard_Real theAngularTolerance) const
0095   {
0096     return vdir.IsParallel(theOther.vdir, theAngularTolerance);
0097   }
0098 
0099   //! Computes the angular value, in radians, between this.Direction() and theOther.Direction().
0100   //! Returns the angle between 0 and 2*PI radians.
0101   Standard_Real Angle (const gp_Ax1& theOther) const { return vdir.Angle (theOther.vdir); }
0102 
0103   //! Reverses the unit vector of this axis and assigns the result to this axis.
0104   void Reverse() { vdir.Reverse(); }
0105 
0106   //! Reverses the unit vector of this axis and creates a new one.
0107   Standard_NODISCARD gp_Ax1 Reversed() const
0108   {
0109     gp_Dir D = vdir.Reversed();
0110     return gp_Ax1 (loc, D);
0111   }
0112 
0113   //! Performs the symmetrical transformation of an axis
0114   //! placement with respect to the point P which is the
0115   //! center of the symmetry and assigns the result to this axis.
0116   Standard_EXPORT void Mirror (const gp_Pnt& P);
0117 
0118   //! Performs the symmetrical transformation of an axis
0119   //! placement with respect to the point P which is the
0120   //! center of the symmetry and creates a new axis.
0121   Standard_NODISCARD Standard_EXPORT gp_Ax1 Mirrored (const gp_Pnt& P) const;
0122 
0123   //! Performs the symmetrical transformation of an axis
0124   //! placement with respect to an axis placement which
0125   //! is the axis of the symmetry and assigns the result to this axis.
0126   Standard_EXPORT void Mirror (const gp_Ax1& A1);
0127 
0128   //! Performs the symmetrical transformation of an axis
0129   //! placement with respect to an axis placement which
0130   //! is the axis of the symmetry and creates a new axis.
0131   Standard_NODISCARD Standard_EXPORT gp_Ax1 Mirrored (const gp_Ax1& A1) const;
0132 
0133   //! Performs the symmetrical transformation of an axis
0134   //! placement with respect to a plane. The axis placement
0135   //! <A2> locates the plane of the symmetry :
0136   //! (Location, XDirection, YDirection) and assigns the result to this axis.
0137   Standard_EXPORT void Mirror (const gp_Ax2& A2);
0138 
0139   //! Performs the symmetrical transformation of an axis
0140   //! placement with respect to a plane. The axis placement
0141   //! <A2> locates the plane of the symmetry :
0142   //! (Location, XDirection, YDirection) and creates a new axis.
0143   Standard_NODISCARD Standard_EXPORT gp_Ax1 Mirrored (const gp_Ax2& A2) const;
0144 
0145   //! Rotates this axis at an angle theAngRad (in radians) about the axis theA1
0146   //! and assigns the result to this axis.
0147   void Rotate (const gp_Ax1& theA1, const Standard_Real theAngRad)
0148   {
0149     loc .Rotate (theA1, theAngRad);
0150     vdir.Rotate (theA1, theAngRad);
0151   }
0152 
0153   //! Rotates this axis at an angle theAngRad (in radians) about the axis theA1
0154   //! and creates a new one.
0155   Standard_NODISCARD gp_Ax1 Rotated (const gp_Ax1& theA1, const Standard_Real theAngRad) const
0156   {
0157     gp_Ax1 A = *this;
0158     A.Rotate (theA1, theAngRad);
0159     return A;
0160   }
0161 
0162   //! Applies a scaling transformation to this axis with:
0163   //! - scale factor theS, and
0164   //! - center theP and assigns the result to this axis.
0165   void Scale (const gp_Pnt& theP, const Standard_Real theS)
0166   {
0167     loc.Scale (theP, theS);
0168     if (theS < 0.0) { vdir.Reverse(); }
0169   }
0170 
0171   //! Applies a scaling transformation to this axis with:
0172   //! - scale factor theS, and
0173   //! - center theP and creates a new axis.
0174   Standard_NODISCARD gp_Ax1 Scaled (const gp_Pnt& theP, const Standard_Real theS) const
0175   {
0176     gp_Ax1 A1 = *this;
0177     A1.Scale (theP, theS);
0178     return A1;
0179   }
0180 
0181   //! Applies the transformation theT to this axis and assigns the result to this axis.
0182   void Transform (const gp_Trsf& theT)
0183   {
0184     loc .Transform (theT);
0185     vdir.Transform (theT);
0186   }
0187 
0188   //! Applies the transformation theT to this axis and creates a new one.
0189   //!
0190   //! Translates an axis plaxement in the direction of the vector <V>.
0191   //! The magnitude of the translation is the vector's magnitude.
0192   Standard_NODISCARD gp_Ax1 Transformed (const gp_Trsf& theT) const
0193   {
0194     gp_Ax1 A1 = *this;
0195     A1.Transform (theT);
0196     return A1;
0197   }
0198 
0199   //! Translates this axis by the vector theV, and assigns the result to this axis.
0200   void Translate (const gp_Vec& theV) { loc.Translate (theV); }
0201 
0202   //! Translates this axis by the vector theV,
0203   //! and creates a new one.
0204   Standard_NODISCARD gp_Ax1 Translated (const gp_Vec& theV) const
0205   {
0206     gp_Ax1 A1 = *this;
0207     (A1.loc).Translate (theV); 
0208     return A1;
0209   }
0210 
0211   //! Translates this axis by:
0212   //! the vector (theP1, theP2) defined from point theP1 to point theP2.
0213   //! and assigns the result to this axis.
0214   void Translate (const gp_Pnt& theP1, const gp_Pnt& theP2) { loc.Translate (theP1, theP2); }
0215 
0216   //! Translates this axis by:
0217   //! the vector (theP1, theP2) defined from point theP1 to point theP2.
0218   //! and creates a new one.
0219   Standard_NODISCARD gp_Ax1 Translated (const gp_Pnt& theP1, const gp_Pnt& theP2) const
0220   {
0221     gp_Ax1 A1 = *this;
0222     (A1.loc).Translate (theP1, theP2);
0223     return A1;
0224   }
0225 
0226   //! Dumps the content of me into the stream
0227   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0228 
0229   //! Inits the content of me from the stream
0230   Standard_EXPORT Standard_Boolean InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
0231 
0232 private:
0233 
0234   gp_Pnt loc;
0235   gp_Dir vdir;
0236 
0237 };
0238 
0239 #endif // _gp_Ax1_HeaderFile