42cf5bc1 |
1 | // Created by: NW,JPB,CAL |
2 | // Copyright (c) 1991-1999 Matra Datavision |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _Graphic3d_Vector_HeaderFile |
17 | #define _Graphic3d_Vector_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_DefineAlloc.hxx> |
21 | #include <Standard_Handle.hxx> |
22 | |
23 | #include <Standard_ShortReal.hxx> |
24 | #include <Standard_Real.hxx> |
25 | #include <Graphic3d_Vertex.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | class Graphic3d_VectorError; |
28 | |
29 | |
30 | //! This class allows the creation and update |
31 | //! of a 3D vector. |
32 | class Graphic3d_Vector |
33 | { |
34 | public: |
35 | |
36 | DEFINE_STANDARD_ALLOC |
37 | |
38 | |
39 | //! Creates a vector with 1.0, 0.0, 0.0 coordinates. |
40 | Standard_EXPORT Graphic3d_Vector(); |
41 | |
42 | //! Creates a vector with <AX>, <AY>, <AZ> coordinates. |
43 | Standard_EXPORT Graphic3d_Vector(const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ); |
44 | |
45 | //! Creates a vector from 2 points <APoint1> and <APoint2>. |
46 | Standard_EXPORT Graphic3d_Vector(const Graphic3d_Vertex& APoint1, const Graphic3d_Vertex& APoint2); |
47 | |
48 | //! Normalises <me>. |
49 | //! Category: Methods to modify the class definition |
50 | //! Warning: Raises VectorError if <me> is null. |
51 | Standard_EXPORT void Normalize(); |
52 | |
53 | //! Modifies the coordinates of the vector <me>. |
54 | Standard_EXPORT void SetCoord (const Standard_Real Xnew, const Standard_Real Ynew, const Standard_Real Znew); |
55 | |
56 | //! Modifies the X coordinate of the vector <me>. |
57 | Standard_EXPORT void SetXCoord (const Standard_Real Xnew); |
58 | |
59 | //! Modifies the Y coordinate of the vector <me>. |
60 | Standard_EXPORT void SetYCoord (const Standard_Real Ynew); |
61 | |
62 | //! Modifies the Z coordinate of the vector <me>. |
63 | Standard_EXPORT void SetZCoord (const Standard_Real Znew); |
64 | |
65 | //! Returns the coordinates of the vector <me>. |
66 | Standard_EXPORT void Coord (Standard_Real& AX, Standard_Real& AY, Standard_Real& AZ) const; |
67 | |
68 | //! Returns Standard_True if <me> has length 1. |
69 | Standard_EXPORT Standard_Boolean IsNormalized() const; |
70 | |
71 | //! Returns Standard_True if <me> has length zero. |
72 | Standard_EXPORT Standard_Boolean LengthZero() const; |
73 | |
74 | //! Returns the X coordinates of the vector <me>. |
75 | Standard_EXPORT Standard_Real X() const; |
76 | |
77 | //! Returns the Y coordinate of the vector <me>. |
78 | Standard_EXPORT Standard_Real Y() const; |
79 | |
80 | //! Returns the Z coordinate of the vector <me>. |
81 | Standard_EXPORT Standard_Real Z() const; |
82 | |
83 | //! Returns Standard_True if the vector <AV1> and |
84 | //! <AV2> are parallel. |
85 | Standard_EXPORT static Standard_Boolean IsParallel (const Graphic3d_Vector& AV1, const Graphic3d_Vector& AV2); |
86 | |
87 | //! Returns the norm of the vector <AX>, <AY>, <AZ>. |
88 | Standard_EXPORT static Standard_Real NormeOf (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ); |
89 | |
90 | //! Returns the norm of the vector <AVector>. |
91 | Standard_EXPORT static Standard_Real NormeOf (const Graphic3d_Vector& AVector); |
92 | |
93 | |
94 | |
95 | |
96 | protected: |
97 | |
98 | |
99 | |
100 | |
101 | |
102 | private: |
103 | |
104 | |
105 | |
106 | Standard_ShortReal MyX; |
107 | Standard_ShortReal MyY; |
108 | Standard_ShortReal MyZ; |
109 | Standard_ShortReal MyNorme; |
110 | |
111 | |
112 | }; |
113 | |
114 | |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | #endif // _Graphic3d_Vector_HeaderFile |