0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / gce / gce_MakeDir.cxx
1 // Created on: 1992-09-02
2 // Created by: Remi GILET
3 // Copyright (c) 1992-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
18 #include <gce_MakeDir.hxx>
19 #include <gp.hxx>
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>
25
26 //=========================================================================
27 //   Creation d une direction 3d (Dir) de gp a partir de 2 Pnt de gp.     +
28 //=========================================================================
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
70   StdFail_NotDone_Raise_if (TheError != gce_Done,
71                             "gce_MakeDir::Value() - no result");
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