b311480e |
1 | // Created on: 1992-09-02 |
2 | // Created by: Remi GILET |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #include <gce_MakePln.ixx> |
23 | #include <StdFail_NotDone.hxx> |
24 | #include <gp.hxx> |
25 | #include <gp_Ax3.hxx> |
26 | |
27 | gce_MakePln::gce_MakePln(const gp_Ax2& A2) |
28 | { |
29 | ThePln = gp_Pln(gp_Ax3(A2)); |
30 | TheError = gce_Done; |
31 | } |
32 | |
33 | gce_MakePln::gce_MakePln(const gp_Pnt& P, |
34 | const gp_Dir& V) |
35 | { |
36 | ThePln = gp_Pln(P,V); |
37 | TheError = gce_Done; |
38 | } |
39 | |
40 | gce_MakePln::gce_MakePln(const gp_Pnt& P1, |
41 | const gp_Pnt& P2) |
42 | { |
43 | if (P1.Distance(P2) <= gp::Resolution()) { TheError = gce_ConfusedPoints; } |
44 | else { |
45 | gp_Dir dir(P2.XYZ()-P1.XYZ()); |
46 | ThePln = gp_Pln(P1,dir); |
47 | TheError = gce_Done; |
48 | } |
49 | } |
50 | |
51 | gce_MakePln::gce_MakePln(const Standard_Real A, |
52 | const Standard_Real B, |
53 | const Standard_Real C, |
54 | const Standard_Real D) |
55 | { |
56 | if (A*A + B*B + C*C <= gp::Resolution()) { |
57 | TheError = gce_BadEquation; |
58 | } |
59 | else { |
60 | ThePln = gp_Pln(A,B,C,D); |
61 | TheError = gce_Done; |
62 | } |
63 | } |
64 | |
65 | //========================================================================= |
66 | // Creation d un gp_pln passant par trois points. + |
67 | //========================================================================= |
68 | |
69 | gce_MakePln::gce_MakePln(const gp_Pnt& P1 , |
70 | const gp_Pnt& P2 , |
71 | const gp_Pnt& P3 ) |
72 | { |
73 | gp_XYZ V1(P2.XYZ()-P1.XYZ()); |
74 | gp_XYZ V2(P3.XYZ()-P1.XYZ()); |
75 | gp_XYZ Norm(V1.Crossed(V2)); |
76 | if (Norm.Modulus() < gp::Resolution()) { TheError = gce_ColinearPoints; } |
77 | else { |
78 | gp_Dir DNorm(Norm); |
79 | gp_Dir Dx(V1); |
80 | ThePln = gp_Pln(gp_Ax3(P1,DNorm,Dx)); |
81 | TheError = gce_Done; |
82 | } |
83 | } |
84 | |
85 | //========================================================================= |
86 | // Creation d un gp_pln parallele a un autre pln a une distance donnee. + |
87 | //========================================================================= |
88 | |
89 | gce_MakePln::gce_MakePln(const gp_Pln& Pl , |
90 | const Standard_Real Dist ) |
91 | { |
92 | gp_Pnt Center(Pl.Location().XYZ()+Dist*gp_XYZ(Pl.Axis().Direction().XYZ())); |
93 | ThePln=gp_Pln(gp_Ax3(Center,Pl.Axis().Direction(),Pl.XAxis().Direction())); |
94 | TheError = gce_Done; |
95 | } |
96 | |
97 | //========================================================================= |
98 | // Creation d un gp_pln parallele a un autre pln passant par un point + |
99 | // <Point1>. + |
100 | //========================================================================= |
101 | |
102 | gce_MakePln::gce_MakePln(const gp_Pln& Pl , |
103 | const gp_Pnt& Point ) |
104 | { |
105 | ThePln = gp_Pln(gp_Ax3(Point,Pl.Axis().Direction(),Pl.XAxis().Direction())); |
106 | TheError = gce_Done; |
107 | } |
108 | |
109 | //========================================================================= |
110 | // Creation d un gp_pln a partir d un Ax1 (Point + Normale). + |
111 | //========================================================================= |
112 | |
113 | gce_MakePln::gce_MakePln(const gp_Ax1& Axis ) |
114 | { |
115 | ThePln = gp_Pln(Axis.Location(),Axis.Direction()); |
116 | TheError = gce_Done; |
117 | } |
118 | |
119 | //========================================================================= |
120 | // Creation d un gp_pln par un tableau de points. + |
121 | //========================================================================= |
122 | |
123 | /*gce_MakePln::gce_MakePln(const gp_Array1OfPnt& Pts , |
124 | Standard_Real ErrMax , |
125 | Standard_Real ErrMean ) |
126 | { |
127 | TheError = gce_ConfusedPoints; |
128 | } |
129 | */ |
130 | const gp_Pln& gce_MakePln::Value () const |
131 | { |
132 | StdFail_NotDone_Raise_if(!TheError == gce_Done,""); |
133 | return ThePln; |
134 | } |
135 | |
136 | const gp_Pln& gce_MakePln::Operator() const |
137 | { |
138 | return Value(); |
139 | } |
140 | |
141 | gce_MakePln::operator gp_Pln() const |
142 | { |
143 | return Value(); |
144 | } |
145 | |
146 | |
147 | |
148 | |
149 | |