b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
7fd59977 |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
7fd59977 |
15 | // JCV 1/10/90 Changement de nom du package vgeom -> gp |
16 | // JCV 12/12/90 modif introduction des classes XYZ et Mat dans le package |
17 | // LPA, JCV 07/92 passage sur C1. |
18 | // JCV 07/92 Introduction de la method Dump |
19 | |
20 | #define No_Standard_OutOfRange |
21 | |
d5477f8c |
22 | #include <gp_Ax1.hxx> |
42cf5bc1 |
23 | |
7fd59977 |
24 | #include <gp.hxx> |
42cf5bc1 |
25 | #include <gp_Ax2.hxx> |
26 | #include <gp_Dir.hxx> |
27 | #include <gp_Pnt.hxx> |
28 | #include <gp_Trsf.hxx> |
29 | #include <gp_Vec.hxx> |
bc73b006 |
30 | #include <Standard_Dump.hxx> |
7fd59977 |
31 | |
32 | Standard_Boolean gp_Ax1::IsCoaxial |
33 | (const gp_Ax1& Other, |
34 | const Standard_Real AngularTolerance, |
35 | const Standard_Real LinearTolerance) const |
36 | { |
37 | gp_XYZ XYZ1 = loc.XYZ(); |
38 | XYZ1.Subtract (Other.loc.XYZ()); |
39 | XYZ1.Cross (Other.vdir.XYZ()); |
40 | Standard_Real D1 = XYZ1.Modulus(); |
41 | gp_XYZ XYZ2 = Other.loc.XYZ(); |
42 | XYZ2.Subtract (loc.XYZ()); |
43 | XYZ2.Cross (vdir.XYZ()); |
44 | Standard_Real D2 = XYZ2.Modulus(); |
45 | return (vdir.IsEqual (Other.vdir, AngularTolerance) && |
46 | D1 <= LinearTolerance && D2 <= LinearTolerance); |
47 | } |
48 | |
49 | void gp_Ax1::Mirror (const gp_Pnt& P) |
50 | { |
51 | loc.Mirror(P); |
52 | vdir.Reverse(); |
53 | } |
54 | |
55 | gp_Ax1 gp_Ax1::Mirrored (const gp_Pnt& P) const |
56 | { |
57 | gp_Ax1 A1 = *this; |
58 | A1.Mirror (P); |
59 | return A1; |
60 | } |
61 | |
62 | void gp_Ax1::Mirror (const gp_Ax1& A1) |
63 | { |
64 | loc.Mirror(A1); |
65 | vdir.Mirror(A1.vdir); |
66 | } |
67 | |
68 | gp_Ax1 gp_Ax1::Mirrored (const gp_Ax1& A1) const |
69 | { |
70 | gp_Ax1 A = *this; |
71 | A.Mirror (A1); |
72 | return A; |
73 | } |
74 | |
75 | void gp_Ax1::Mirror (const gp_Ax2& A2) |
76 | { |
77 | loc.Mirror (A2); |
78 | vdir.Mirror (A2); |
79 | } |
80 | |
81 | gp_Ax1 gp_Ax1::Mirrored (const gp_Ax2& A2) const |
82 | { |
83 | gp_Ax1 A1 = *this; |
84 | A1.Mirror (A2); |
85 | return A1; |
86 | } |
87 | |
bc73b006 |
88 | void gp_Ax1::DumpJson (Standard_OStream& theOStream, Standard_Integer) const |
89 | { |
90 | OCCT_DUMP_VECTOR_CLASS (theOStream, "Location", 3, loc.X(), loc.Y(), loc.Z()) |
91 | OCCT_DUMP_VECTOR_CLASS (theOStream, "Direction", 3, vdir.X(), vdir.Y(), vdir.Z()) |
92 | } |
6b63dc83 |
93 | |
94 | Standard_Boolean gp_Ax1::InitFromJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) |
95 | { |
96 | Standard_Integer aPos = theStreamPos; |
97 | TCollection_AsciiString aStreamStr = Standard_Dump::Text (theSStream); |
98 | |
99 | gp_XYZ& anXYZLoc = loc.ChangeCoord(); |
100 | OCCT_INIT_VECTOR_CLASS (aStreamStr, "Location", aPos, 3, |
101 | &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3)) |
102 | gp_XYZ aDir; |
103 | OCCT_INIT_VECTOR_CLASS (aStreamStr, "Direction", aPos, 3, |
104 | &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3)) |
105 | SetDirection (aDir); |
106 | |
107 | theStreamPos = aPos; |
108 | return Standard_True; |
109 | } |