0024893: CLang warnings -Wlogical-not-parentheses for gce_Done comparisons
[occt.git] / src / gce / gce_MakePln.cxx
1 // Created on: 1992-09-02
2 // Created by: Remi GILET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <gce_MakePln.ixx>
18 #include <StdFail_NotDone.hxx>
19 #include <gp.hxx>
20 #include <gp_Ax3.hxx>
21
22 gce_MakePln::gce_MakePln(const gp_Ax2& A2)
23 {
24   ThePln = gp_Pln(gp_Ax3(A2));
25   TheError = gce_Done;
26 }
27
28 gce_MakePln::gce_MakePln(const gp_Pnt& P,
29                          const gp_Dir& V)
30 {
31   ThePln = gp_Pln(P,V);
32   TheError = gce_Done;
33 }
34
35 gce_MakePln::gce_MakePln(const gp_Pnt& P1,
36                          const gp_Pnt& P2)
37 {
38   if (P1.Distance(P2) <= gp::Resolution()) { TheError = gce_ConfusedPoints; }
39   else {
40     gp_Dir dir(P2.XYZ()-P1.XYZ());
41     ThePln = gp_Pln(P1,dir);
42     TheError = gce_Done;
43   }
44 }
45
46 gce_MakePln::gce_MakePln(const Standard_Real A,
47                          const Standard_Real B,
48                          const Standard_Real C,
49                          const Standard_Real D)
50 {
51   if (A*A + B*B + C*C <= gp::Resolution()) {
52     TheError = gce_BadEquation;
53   }
54   else {
55     ThePln = gp_Pln(A,B,C,D);
56     TheError = gce_Done;
57   }
58 }
59
60 //=========================================================================
61 //   Creation d un gp_pln passant par trois points.                       +
62 //=========================================================================
63
64 gce_MakePln::gce_MakePln(const gp_Pnt& P1 ,
65                          const gp_Pnt& P2 ,
66                          const gp_Pnt& P3 ) 
67 {
68   gp_XYZ V1(P2.XYZ()-P1.XYZ());
69   gp_XYZ V2(P3.XYZ()-P1.XYZ());
70   gp_XYZ Norm(V1.Crossed(V2));
71   if (Norm.Modulus() < gp::Resolution()) { TheError = gce_ColinearPoints; }
72   else {
73     gp_Dir DNorm(Norm);
74     gp_Dir Dx(V1);
75     ThePln = gp_Pln(gp_Ax3(P1,DNorm,Dx));
76     TheError = gce_Done;
77   }
78 }
79
80 //=========================================================================
81 //   Creation d un gp_pln parallele a un autre pln a une distance donnee. +
82 //=========================================================================
83
84 gce_MakePln::gce_MakePln(const gp_Pln&       Pl   ,
85                          const Standard_Real Dist ) 
86 {
87   gp_Pnt Center(Pl.Location().XYZ()+Dist*gp_XYZ(Pl.Axis().Direction().XYZ()));
88   ThePln=gp_Pln(gp_Ax3(Center,Pl.Axis().Direction(),Pl.XAxis().Direction()));
89   TheError = gce_Done;
90 }
91
92 //=========================================================================
93 //   Creation d un gp_pln parallele a un autre pln passant par un point   +
94 //   <Point1>.                                                            +
95 //=========================================================================
96
97 gce_MakePln::gce_MakePln(const gp_Pln& Pl    ,
98                          const gp_Pnt& Point ) 
99 {
100   ThePln = gp_Pln(gp_Ax3(Point,Pl.Axis().Direction(),Pl.XAxis().Direction()));
101   TheError = gce_Done;
102 }
103
104 //=========================================================================
105 //  Creation d un gp_pln a partir d un Ax1 (Point + Normale).             +
106 //=========================================================================
107
108 gce_MakePln::gce_MakePln(const gp_Ax1& Axis ) 
109 {
110   ThePln = gp_Pln(Axis.Location(),Axis.Direction());
111   TheError = gce_Done;
112 }
113
114 //=========================================================================
115 //  Creation d un gp_pln par un tableau de points.                        +
116 //=========================================================================
117
118 /*gce_MakePln::gce_MakePln(const gp_Array1OfPnt& Pts     ,
119                                Standard_Real   ErrMax  ,
120                                Standard_Real   ErrMean ) 
121 {
122   TheError = gce_ConfusedPoints;
123 }
124 */
125 const gp_Pln& gce_MakePln::Value () const
126 {
127   StdFail_NotDone_Raise_if(TheError != gce_Done,"");
128   return ThePln;
129 }
130
131 const gp_Pln& gce_MakePln::Operator() const 
132 {
133   return Value();
134 }
135
136 gce_MakePln::operator gp_Pln() const
137 {
138   return Value();
139 }
140
141
142
143
144