42cf5bc1 |
1 | // Created on: 1993-03-24 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Geom2d_Direction_HeaderFile |
18 | #define _Geom2d_Direction_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <Geom2d_Vector.hxx> |
24 | #include <Standard_Real.hxx> |
25 | class Standard_ConstructionError; |
26 | class gp_Dir2d; |
27 | class Geom2d_Vector; |
28 | class gp_Trsf2d; |
29 | class Geom2d_Geometry; |
30 | |
31 | |
32 | class Geom2d_Direction; |
33 | DEFINE_STANDARD_HANDLE(Geom2d_Direction, Geom2d_Vector) |
34 | |
35 | |
36 | //! The class Direction specifies a vector that is never null. |
37 | //! It is a unit vector. |
38 | class Geom2d_Direction : public Geom2d_Vector |
39 | { |
40 | |
41 | public: |
42 | |
43 | |
44 | //! Creates a unit vector with it 2 cartesian coordinates. |
45 | //! |
46 | //! Raised if Sqrt( X*X + Y*Y) <= Resolution from gp. |
47 | Standard_EXPORT Geom2d_Direction(const Standard_Real X, const Standard_Real Y); |
48 | |
49 | //! Creates a persistent copy of <me>. |
50 | Standard_EXPORT Geom2d_Direction(const gp_Dir2d& V); |
51 | |
52 | //! Assigns the coordinates X and Y to this unit vector, |
53 | //! then normalizes it. |
54 | //! Exceptions |
55 | //! Standard_ConstructionError if Sqrt(X*X + |
56 | //! Y*Y) is less than or equal to gp::Resolution(). |
57 | Standard_EXPORT void SetCoord (const Standard_Real X, const Standard_Real Y); |
58 | |
59 | //! Converts the gp_Dir2d unit vector V into this unit vector. |
60 | Standard_EXPORT void SetDir2d (const gp_Dir2d& V); |
61 | |
62 | |
63 | //! Assigns a value to the X coordinate of this unit vector, then normalizes it. |
64 | //! Exceptions |
65 | //! Standard_ConstructionError if the value assigned |
66 | //! causes the magnitude of the vector to become less |
67 | //! than or equal to gp::Resolution(). |
68 | Standard_EXPORT void SetX (const Standard_Real X); |
69 | |
70 | //! Assigns a value to the Y coordinate of this unit vector, then normalizes it. |
71 | //! Exceptions |
72 | //! Standard_ConstructionError if the value assigned |
73 | //! causes the magnitude of the vector to become less |
74 | //! than or equal to gp::Resolution(). |
75 | Standard_EXPORT void SetY (const Standard_Real Y); |
76 | |
77 | //! Converts this unit vector into a gp_Dir2d unit vector. |
78 | Standard_EXPORT gp_Dir2d Dir2d() const; |
79 | |
80 | //! returns 1.0 |
81 | Standard_EXPORT Standard_Real Magnitude() const; |
82 | |
83 | //! returns 1.0 |
84 | Standard_EXPORT Standard_Real SquareMagnitude() const; |
85 | |
86 | //! Computes the cross product between <me> and <Other>. |
87 | Standard_EXPORT Standard_Real Crossed (const Handle(Geom2d_Vector)& Other) const; |
88 | Standard_Real operator ^ (const Handle(Geom2d_Vector)& Other) const |
89 | { |
90 | return Crossed(Other); |
91 | } |
92 | |
93 | //! Applies the transformation T to this unit vector, then normalizes it. |
94 | Standard_EXPORT void Transform (const gp_Trsf2d& T); |
95 | |
96 | //! Creates a new object which is a copy of this unit vector. |
97 | Standard_EXPORT Handle(Geom2d_Geometry) Copy() const; |
98 | |
99 | |
100 | |
101 | |
102 | DEFINE_STANDARD_RTTI(Geom2d_Direction,Geom2d_Vector) |
103 | |
104 | protected: |
105 | |
106 | |
107 | |
108 | |
109 | private: |
110 | |
111 | |
112 | |
113 | |
114 | }; |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | |
122 | #endif // _Geom2d_Direction_HeaderFile |