0024927: Getting rid of "Persistent" functionality -- Storable
[occt.git] / src / gp / gp_Ax2.cxx
CommitLineData
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
22#include <gp_Ax2.ixx>
23#include <gp.hxx>
24
25gp_Ax2::gp_Ax2 (const gp_Pnt& P, const gp_Dir& V) :
26axis(P,V)
27{
28 Standard_Real A = V.X();
29 Standard_Real B = V.Y();
30 Standard_Real C = V.Z();
31 Standard_Real Aabs = A;
32 if (Aabs < 0) Aabs = - Aabs;
33 Standard_Real Babs = B;
34 if (Babs < 0) Babs = - Babs;
35 Standard_Real Cabs = C;
36 if (Cabs < 0) Cabs = - Cabs;
37 gp_Dir D;
38
39 // pour determiner l axe X :
40 // on dit que le produit scalaire Vx.V = 0.
41 // et on recherche le max(A,B,C) pour faire la division.
42 // l'une des coordonnees du vecteur est nulle.
43
44 if ( Babs <= Aabs && Babs <= Cabs) {
45 if (Aabs > Cabs) D.SetCoord(-C,0., A);
46 else D.SetCoord( C,0.,-A);
47 }
48 else if ( Aabs <= Babs && Aabs <= Cabs) {
49 if (Babs > Cabs) D.SetCoord(0.,-C, B);
50 else D.SetCoord(0., C,-B);
51 }
52 else {
53 if (Aabs > Babs) D.SetCoord(-B, A,0.);
54 else D.SetCoord( B,-A,0.);
55 }
56 SetXDirection(D);
57}
58
59void gp_Ax2::Mirror (const gp_Pnt& P)
60{
61 gp_Pnt Temp = axis.Location();
62 Temp.Mirror (P);
63 axis.SetLocation (Temp);
64 vxdir.Reverse ();
65 vydir.Reverse ();
66}
67
68gp_Ax2 gp_Ax2::Mirrored(const gp_Pnt& P) const
69{
70 gp_Ax2 Temp = *this;
71 Temp.Mirror (P);
72 return Temp;
73}
74
75void gp_Ax2::Mirror (const gp_Ax1& A1)
76{
77 vydir.Mirror (A1);
78 vxdir.Mirror (A1);
79 gp_Pnt Temp = axis.Location();
80 Temp.Mirror (A1);
81 axis.SetLocation (Temp);
82 axis.SetDirection (vxdir.Crossed (vydir));
83}
84
85gp_Ax2 gp_Ax2::Mirrored(const gp_Ax1& A1) const
86{
87 gp_Ax2 Temp = *this;
88 Temp.Mirror (A1);
89 return Temp;
90}
91
92void gp_Ax2::Mirror (const gp_Ax2& A2)
93{
94 vydir.Mirror (A2);
95 vxdir.Mirror (A2);
96 gp_Pnt Temp = axis.Location();
97 Temp.Mirror (A2);
98 axis.SetLocation (Temp);
99 axis.SetDirection (vxdir.Crossed (vydir));
100}
101
102gp_Ax2 gp_Ax2::Mirrored(const gp_Ax2& A2) const
103{
104 gp_Ax2 Temp = *this;
105 Temp.Mirror (A2);
106 return Temp;
107}
108