b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
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 mineur suite a la premiere revue de projet |
17 | // LPA, JCV 07/92 passage sur C1. |
18 | // JCV 07/92 Introduction de la method Dump |
19 | |
20 | #define No_Standard_OutOfRange |
21 | |
42cf5bc1 |
22 | |
7fd59977 |
23 | #include <gp.hxx> |
42cf5bc1 |
24 | #include <gp_Ax1.hxx> |
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> |
30 | #include <Standard_ConstructionError.hxx> |
bc73b006 |
31 | #include <Standard_Dump.hxx> |
7fd59977 |
32 | |
33 | gp_Ax2::gp_Ax2 (const gp_Pnt& P, const gp_Dir& V) : |
34 | axis(P,V) |
35 | { |
36 | Standard_Real A = V.X(); |
37 | Standard_Real B = V.Y(); |
38 | Standard_Real C = V.Z(); |
39 | Standard_Real Aabs = A; |
40 | if (Aabs < 0) Aabs = - Aabs; |
41 | Standard_Real Babs = B; |
42 | if (Babs < 0) Babs = - Babs; |
43 | Standard_Real Cabs = C; |
44 | if (Cabs < 0) Cabs = - Cabs; |
45 | gp_Dir D; |
46 | |
47 | // pour determiner l axe X : |
48 | // on dit que le produit scalaire Vx.V = 0. |
49 | // et on recherche le max(A,B,C) pour faire la division. |
50 | // l'une des coordonnees du vecteur est nulle. |
51 | |
52 | if ( Babs <= Aabs && Babs <= Cabs) { |
53 | if (Aabs > Cabs) D.SetCoord(-C,0., A); |
54 | else D.SetCoord( C,0.,-A); |
55 | } |
56 | else if ( Aabs <= Babs && Aabs <= Cabs) { |
57 | if (Babs > Cabs) D.SetCoord(0.,-C, B); |
58 | else D.SetCoord(0., C,-B); |
59 | } |
60 | else { |
61 | if (Aabs > Babs) D.SetCoord(-B, A,0.); |
62 | else D.SetCoord( B,-A,0.); |
63 | } |
64 | SetXDirection(D); |
65 | } |
66 | |
67 | void gp_Ax2::Mirror (const gp_Pnt& P) |
68 | { |
69 | gp_Pnt Temp = axis.Location(); |
70 | Temp.Mirror (P); |
71 | axis.SetLocation (Temp); |
72 | vxdir.Reverse (); |
73 | vydir.Reverse (); |
74 | } |
75 | |
76 | gp_Ax2 gp_Ax2::Mirrored(const gp_Pnt& P) const |
77 | { |
78 | gp_Ax2 Temp = *this; |
79 | Temp.Mirror (P); |
80 | return Temp; |
81 | } |
82 | |
83 | void gp_Ax2::Mirror (const gp_Ax1& A1) |
84 | { |
85 | vydir.Mirror (A1); |
86 | vxdir.Mirror (A1); |
87 | gp_Pnt Temp = axis.Location(); |
88 | Temp.Mirror (A1); |
89 | axis.SetLocation (Temp); |
90 | axis.SetDirection (vxdir.Crossed (vydir)); |
91 | } |
92 | |
93 | gp_Ax2 gp_Ax2::Mirrored(const gp_Ax1& A1) const |
94 | { |
95 | gp_Ax2 Temp = *this; |
96 | Temp.Mirror (A1); |
97 | return Temp; |
98 | } |
99 | |
100 | void gp_Ax2::Mirror (const gp_Ax2& A2) |
101 | { |
102 | vydir.Mirror (A2); |
103 | vxdir.Mirror (A2); |
104 | gp_Pnt Temp = axis.Location(); |
105 | Temp.Mirror (A2); |
106 | axis.SetLocation (Temp); |
107 | axis.SetDirection (vxdir.Crossed (vydir)); |
108 | } |
109 | |
110 | gp_Ax2 gp_Ax2::Mirrored(const gp_Ax2& A2) const |
111 | { |
112 | gp_Ax2 Temp = *this; |
113 | Temp.Mirror (A2); |
114 | return Temp; |
115 | } |
116 | |
bc73b006 |
117 | void gp_Ax2::DumpJson (Standard_OStream& theOStream, Standard_Integer) const |
118 | { |
119 | OCCT_DUMP_VECTOR_CLASS (theOStream, "Location", 3, axis.Location().X(), axis.Location().Y(), axis.Location().Z()) |
120 | OCCT_DUMP_VECTOR_CLASS (theOStream, "Direction", 3, axis.Direction().X(), axis.Direction().Y(), axis.Direction().Z()) |
121 | |
122 | OCCT_DUMP_VECTOR_CLASS (theOStream, "XDirection", 3, vxdir.X(), vxdir.Y(), vxdir.Z()) |
123 | OCCT_DUMP_VECTOR_CLASS (theOStream, "YDirection", 3, vydir.X(), vydir.Y(), vydir.Z()) |
124 | } |