b311480e |
1 | // Created on: 1992-09-02 |
2 | // Created by: Remi GILET |
3 | // Copyright (c) 1992-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <gce_MakeDir.hxx> |
7fd59977 |
19 | #include <gp.hxx> |
42cf5bc1 |
20 | #include <gp_Dir.hxx> |
21 | #include <gp_Pnt.hxx> |
22 | #include <gp_Vec.hxx> |
23 | #include <gp_XYZ.hxx> |
24 | #include <StdFail_NotDone.hxx> |
7fd59977 |
25 | |
26 | //========================================================================= |
27 | // Creation d une direction 3d (Dir) de gp a partir de 2 Pnt de gp. + |
28 | //========================================================================= |
7fd59977 |
29 | gce_MakeDir::gce_MakeDir(const gp_Pnt& P1, |
30 | const gp_Pnt& P2) |
31 | { |
32 | if (P1.Distance(P2) <= gp::Resolution()) { TheError = gce_ConfusedPoints; } |
33 | else { |
34 | TheDir = gp_Dir(P2.XYZ()-P1.XYZ()); |
35 | TheError = gce_Done; |
36 | } |
37 | } |
38 | |
39 | gce_MakeDir::gce_MakeDir(const gp_XYZ& Coord) |
40 | { |
41 | if (Coord.Modulus() <= gp::Resolution()) { TheError = gce_NullVector; } |
42 | else { |
43 | TheDir = gp_Dir(Coord); |
44 | TheError = gce_Done; |
45 | } |
46 | } |
47 | |
48 | gce_MakeDir::gce_MakeDir(const gp_Vec& V) |
49 | { |
50 | if (V.Magnitude() <= gp::Resolution()) { TheError = gce_NullVector; } |
51 | else { |
52 | TheDir = gp_Dir(V); |
53 | TheError = gce_Done; |
54 | } |
55 | } |
56 | |
57 | gce_MakeDir::gce_MakeDir(const Standard_Real Xv, |
58 | const Standard_Real Yv, |
59 | const Standard_Real Zv) |
60 | { |
61 | if (Xv*Xv+Yv*Yv+Zv*Zv <= gp::Resolution()) { TheError = gce_NullVector; } |
62 | else { |
63 | TheDir = gp_Dir(Xv,Yv,Zv); |
64 | TheError = gce_Done; |
65 | } |
66 | } |
67 | |
68 | const gp_Dir& gce_MakeDir::Value() const |
69 | { |
2d2b3d53 |
70 | StdFail_NotDone_Raise_if (TheError != gce_Done, |
71 | "gce_MakeDir::Value() - no result"); |
7fd59977 |
72 | return TheDir; |
73 | } |
74 | |
75 | const gp_Dir& gce_MakeDir::Operator() const |
76 | { |
77 | return Value(); |
78 | } |
79 | |
80 | gce_MakeDir::operator gp_Dir() const |
81 | { |
82 | return Value(); |
83 | } |
84 | |