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.hxx>
23
24 #include <gp.hxx>
25 #include <gp_Ax1.hxx>
26 #include <gp_Ax2.hxx>
27 #include <gp_Ax3.hxx>
28 #include <gp_Dir.hxx>
29 #include <gp_Lin.hxx>
30 #include <gp_Pnt.hxx>
31 #include <gp_Trsf.hxx>
32 #include <gp_Vec.hxx>
33 #include <Standard_ConstructionError.hxx>
34 #include <Standard_Dump.hxx>
35
gp_Pln(const gp_Pnt & P,const gp_Dir & V)36 gp_Pln::gp_Pln (const gp_Pnt& P,
37 const gp_Dir& V)
38 {
39 Standard_Real A = V.X();
40 Standard_Real B = V.Y();
41 Standard_Real C = V.Z();
42 Standard_Real Aabs = A;
43 if (Aabs < 0) Aabs = - Aabs;
44 Standard_Real Babs = B;
45 if (Babs < 0) Babs = - Babs;
46 Standard_Real Cabs = C;
47 if (Cabs < 0) Cabs = - Cabs;
48
49 // pour determiner l'axe X :
50 // on dit que le produit scalaire Vx.V = 0.
51 // et on recherche le max(A,B,C) pour faire la division.
52 // l'une des coordonnees du vecteur est nulle.
53
54 if( Babs <= Aabs && Babs <= Cabs) {
55 if (Aabs > Cabs) pos = gp_Ax3 (P, V, gp_Dir (-C,0., A));
56 else pos = gp_Ax3 (P, V, gp_Dir ( C,0.,-A));
57 }
58 else if( Aabs <= Babs && Aabs <= Cabs) {
59 if (Babs > Cabs) pos = gp_Ax3 (P, V, gp_Dir (0.,-C, B));
60 else pos = gp_Ax3 (P, V, gp_Dir (0., C,-B));
61 }
62 else {
63 if (Aabs > Babs) pos = gp_Ax3 (P, V, gp_Dir (-B, A,0.));
64 else pos = gp_Ax3 (P, V, gp_Dir ( B,-A,0.));
65 }
66 }
67
gp_Pln(const Standard_Real A,const Standard_Real B,const Standard_Real C,const Standard_Real D)68 gp_Pln::gp_Pln (const Standard_Real A,
69 const Standard_Real B,
70 const Standard_Real C,
71 const Standard_Real D)
72 {
73 Standard_Real Aabs = A;
74 if (Aabs < 0) Aabs = - Aabs;
75 Standard_Real Babs = B;
76 if (Babs < 0) Babs = - Babs;
77 Standard_Real Cabs = C;
78 if (Cabs < 0) Cabs = - Cabs;
79 if (Babs <= Aabs && Babs <= Cabs) {
80 if (Aabs > Cabs) pos = gp_Ax3(gp_Pnt(-D/A, 0., 0.),
81 gp_Dir(A,B,C),
82 gp_Dir(-C,0., A));
83 else pos = gp_Ax3(gp_Pnt( 0., 0.,-D/C),
84 gp_Dir(A,B,C),
85 gp_Dir( C,0.,-A));
86 }
87 else if (Aabs <= Babs && Aabs <= Cabs) {
88 if (Babs > Cabs) pos = gp_Ax3(gp_Pnt( 0.,-D/B, 0.),
89 gp_Dir(A,B,C),
90 gp_Dir(0.,-C, B));
91 else pos = gp_Ax3(gp_Pnt( 0., 0.,-D/C),
92 gp_Dir(A,B,C),
93 gp_Dir(0., C,-B));
94 }
95 else {
96 if (Aabs > Babs) pos = gp_Ax3(gp_Pnt(-D/A, 0., 0.),
97 gp_Dir(A,B,C),
98 gp_Dir(-B, A, 0.));
99 else pos = gp_Ax3(gp_Pnt( 0.,-D/B, 0.),
100 gp_Dir(A,B,C),
101 gp_Dir( B,-A, 0.));
102 }
103 }
104
Mirror(const gp_Pnt & P)105 void gp_Pln::Mirror (const gp_Pnt& P)
106 { pos.Mirror(P); }
107
Mirrored(const gp_Pnt & P) const108 gp_Pln gp_Pln::Mirrored (const gp_Pnt& P) const
109 {
110 gp_Pln Pl = *this;
111 Pl.pos.Mirror(P);
112 return Pl;
113 }
114
Mirror(const gp_Ax1 & A1)115 void gp_Pln::Mirror (const gp_Ax1& A1)
116 { pos.Mirror(A1); }
117
Mirrored(const gp_Ax1 & A1) const118 gp_Pln gp_Pln::Mirrored (const gp_Ax1& A1) const
119 {
120 gp_Pln Pl = *this;
121 Pl.pos.Mirror(A1);
122 return Pl;
123 }
124
Mirror(const gp_Ax2 & A2)125 void gp_Pln::Mirror (const gp_Ax2& A2)
126 { pos.Mirror(A2); }
127
Mirrored(const gp_Ax2 & A2) const128 gp_Pln gp_Pln::Mirrored (const gp_Ax2& A2) const
129 {
130 gp_Pln Pl = *this;
131 Pl.pos.Mirror(A2);
132 return Pl;
133 }
134
DumpJson(Standard_OStream & theOStream,Standard_Integer theDepth) const135 void gp_Pln::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
136 {
137 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &pos)
138 }
139