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_MakeDir2d.hxx> |
7fd59977 |
19 | #include <gp.hxx> |
42cf5bc1 |
20 | #include <gp_Dir2d.hxx> |
21 | #include <gp_Pnt2d.hxx> |
22 | #include <gp_Vec2d.hxx> |
23 | #include <gp_XY.hxx> |
24 | #include <StdFail_NotDone.hxx> |
7fd59977 |
25 | |
26 | //========================================================================= |
27 | // Creation d une direction 2d (Dir2d) de gp a partir de 2 Pnt2d de gp. + |
28 | //========================================================================= |
7fd59977 |
29 | gce_MakeDir2d::gce_MakeDir2d(const gp_Pnt2d& P1, |
30 | const gp_Pnt2d& P2) |
31 | { |
32 | if (P1.Distance(P2) <= gp::Resolution()) { TheError = gce_ConfusedPoints; } |
33 | else { |
34 | TheDir2d = gp_Dir2d(P2.XY()-P1.XY()); |
35 | TheError = gce_Done; |
36 | } |
37 | } |
38 | |
39 | gce_MakeDir2d::gce_MakeDir2d(const gp_XY& Coord) |
40 | { |
41 | if (Coord.Modulus() <= gp::Resolution()) { TheError = gce_NullVector; } |
42 | else { |
43 | TheDir2d = gp_Dir2d(Coord); |
44 | TheError = gce_Done; |
45 | } |
46 | } |
47 | |
48 | gce_MakeDir2d::gce_MakeDir2d(const gp_Vec2d& V) |
49 | { |
50 | if (V.Magnitude() <= gp::Resolution()) { TheError = gce_NullVector; } |
51 | else { |
52 | TheDir2d = gp_Dir2d(V); |
53 | TheError = gce_Done; |
54 | } |
55 | } |
56 | |
57 | gce_MakeDir2d::gce_MakeDir2d(const Standard_Real Xv, |
58 | const Standard_Real Yv) |
59 | { |
60 | if (Xv*Xv+Yv*Yv <= gp::Resolution()) { TheError = gce_NullVector; } |
61 | else { |
62 | TheDir2d = gp_Dir2d(Xv,Yv); |
63 | TheError = gce_Done; |
64 | } |
65 | } |
66 | |
67 | const gp_Dir2d& gce_MakeDir2d::Value() const |
68 | { |
2d2b3d53 |
69 | StdFail_NotDone_Raise_if (TheError != gce_Done, |
70 | "gce_MakeDir2d::Value() - no result"); |
7fd59977 |
71 | return TheDir2d; |
72 | } |
73 | |
74 | const gp_Dir2d& gce_MakeDir2d::Operator() const |
75 | { |
76 | return Value(); |
77 | } |
78 | |
79 | gce_MakeDir2d::operator gp_Dir2d() const |
80 | { |
81 | return Value(); |
82 | } |
83 | |