Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:14:20

0001 // Created on: 1992-08-26
0002 // Created by: Remi GILET
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _gce_MakeDir2d_HeaderFile
0018 #define _gce_MakeDir2d_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <gp_Dir2d.hxx>
0025 #include <gce_Root.hxx>
0026 class gp_Vec2d;
0027 class gp_XY;
0028 class gp_Pnt2d;
0029 
0030 //! This class implements construction algorithms for `gp_Dir2d`.
0031 //! Supported constructions include:
0032 //! - direction from vector or coordinate components;
0033 //! - direction from two points.
0034 class gce_MakeDir2d : public gce_Root
0035 {
0036 public:
0037   DEFINE_STANDARD_ALLOC
0038 
0039   //! Normalizes the vector V and creates a direction.
0040   //! @note Construction fails with `gce_NullVector` if
0041   //!       `V.Magnitude() <= gp::Resolution()`.
0042   //! @param[in] V direction vector
0043   Standard_EXPORT gce_MakeDir2d(const gp_Vec2d& V);
0044 
0045   //! Creates a direction from a coordinate vector.
0046   //! @note Construction fails with `gce_NullVector` if
0047   //!       `Coord.Modulus() <= gp::Resolution()`.
0048   //! @param[in] Coord coordinate vector
0049   Standard_EXPORT gce_MakeDir2d(const gp_XY& Coord);
0050 
0051   //! Creates a direction with its two cartesian coordinates.
0052   //! @note Construction fails with `gce_NullVector` if
0053   //!       `Xv*Xv + Yv*Yv <= gp::Resolution()`.
0054   //! @param[in] Xv X coordinate value
0055   //! @param[in] Yv Y coordinate value
0056   Standard_EXPORT gce_MakeDir2d(const double Xv, const double Yv);
0057 
0058   //! Creates a direction from two points.
0059   //! @note Construction fails with `gce_ConfusedPoints` if points are coincident.
0060   //! @param[in] P1 first point
0061   //! @param[in] P2 second point
0062   Standard_EXPORT gce_MakeDir2d(const gp_Pnt2d& P1, const gp_Pnt2d& P2);
0063 
0064   //! Returns the constructed unit vector.
0065   //! Exceptions StdFail_NotDone if no unit vector is constructed.
0066   //! @return resulting direction
0067   Standard_EXPORT const gp_Dir2d& Value() const;
0068 
0069   //! Alias for Value() returning a copy.
0070   //! @return resulting object
0071   gp_Dir2d Operator() const { return Value(); }
0072 
0073   //! Conversion operator returning the constructed object.
0074   //! @return resulting object
0075   operator gp_Dir2d() const { return Operator(); }
0076 
0077 private:
0078   gp_Dir2d TheDir2d;
0079 };
0080 
0081 #endif // _gce_MakeDir2d_HeaderFile