0024927: Getting rid of "Persistent" functionality -- Storable
[occt.git] / src / gp / gp_Pln.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 // JCV 30/08/90 Modif passage version C++ 2.0 sur Sun
16 // JCV 1/10/90 Changement de nom du package vgeom -> gp
17 // JCV 12/12/90 Modif suite a la premiere revue de projet
18 // LPA, JCV  07/92 passage sur C1.
19 // JCV 07/92 Introduction de la method Dump 
20 // LBO 08/93 Passage aux Ax3
21
22 #include <gp_Pln.ixx>
23 #include <gp.hxx>
24
25 gp_Pln::gp_Pln (const gp_Pnt& P,
26                 const gp_Dir& 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
38   //  pour determiner l'axe X :
39   //  on dit que le produit scalaire Vx.V = 0. 
40   //  et on recherche le max(A,B,C) pour faire la division.
41   //  l'une des coordonnees du vecteur est nulle. 
42
43   if( Babs <= Aabs && Babs <= Cabs) {
44     if (Aabs > Cabs)  pos = gp_Ax3 (P, V, gp_Dir (-C,0., A));
45     else              pos = gp_Ax3 (P, V, gp_Dir ( C,0.,-A));
46   }
47   else if( Aabs <= Babs && Aabs <= Cabs) {
48     if (Babs > Cabs)  pos = gp_Ax3 (P, V, gp_Dir (0.,-C, B));
49     else              pos = gp_Ax3 (P, V, gp_Dir (0., C,-B));
50   }
51   else {
52     if (Aabs > Babs)  pos = gp_Ax3 (P, V, gp_Dir (-B, A,0.));
53     else              pos = gp_Ax3 (P, V, gp_Dir ( B,-A,0.));
54   }
55 }
56
57 gp_Pln::gp_Pln (const Standard_Real A,
58                 const Standard_Real B,
59                 const Standard_Real C,
60                 const Standard_Real D)
61 {
62   Standard_Real Aabs = A;
63   if (Aabs < 0) Aabs = - Aabs;
64   Standard_Real Babs = B;
65   if (Babs < 0) Babs = - Babs;
66   Standard_Real Cabs = C;
67   if (Cabs < 0) Cabs = - Cabs;
68   if (Babs <= Aabs && Babs <= Cabs) {
69     if (Aabs > Cabs) pos = gp_Ax3(gp_Pnt(-D/A,  0.,  0.),
70                                   gp_Dir(A,B,C),
71                                   gp_Dir(-C,0., A));
72     else             pos = gp_Ax3(gp_Pnt(  0.,  0.,-D/C),
73                                   gp_Dir(A,B,C),
74                                   gp_Dir( C,0.,-A));
75   }
76   else if (Aabs <= Babs && Aabs <= Cabs) {
77     if (Babs > Cabs) pos = gp_Ax3(gp_Pnt(  0.,-D/B,  0.),
78                                   gp_Dir(A,B,C),
79                                   gp_Dir(0.,-C, B));
80     else             pos = gp_Ax3(gp_Pnt(  0.,  0.,-D/C),
81                                   gp_Dir(A,B,C),
82                                   gp_Dir(0., C,-B));
83   }
84   else {
85     if (Aabs > Babs) pos = gp_Ax3(gp_Pnt(-D/A,  0.,  0.),
86                                   gp_Dir(A,B,C),
87                                   gp_Dir(-B, A, 0.));
88     else             pos = gp_Ax3(gp_Pnt(  0.,-D/B,  0.),
89                                   gp_Dir(A,B,C),
90                                   gp_Dir( B,-A, 0.));
91   }
92
93
94 void gp_Pln::Mirror (const gp_Pnt& P)
95 { pos.Mirror(P);  }
96
97 gp_Pln gp_Pln::Mirrored (const gp_Pnt& P) const
98 {
99   gp_Pln Pl = *this;
100   Pl.pos.Mirror(P);
101   return Pl;
102 }
103
104 void gp_Pln::Mirror (const gp_Ax1& A1)
105 { pos.Mirror(A1); }
106
107 gp_Pln gp_Pln::Mirrored (const gp_Ax1& A1) const
108 {
109   gp_Pln Pl = *this;
110   Pl.pos.Mirror(A1);
111   return Pl;
112 }
113
114 void gp_Pln::Mirror (const gp_Ax2& A2)
115 { pos.Mirror(A2); }
116
117 gp_Pln gp_Pln::Mirrored (const gp_Ax2& A2) const
118 {
119   gp_Pln Pl = *this;
120   Pl.pos.Mirror(A2);
121   return Pl;
122 }
123