7fd59977 |
1 | // File: gce_MakePln.cxx |
2 | // Created: Wed Sep 2 10:34:28 1992 |
3 | // Author: Remi GILET |
4 | // <reg@sdsun1> |
5 | |
6 | #include <gce_MakePln.ixx> |
7 | #include <StdFail_NotDone.hxx> |
8 | #include <gp.hxx> |
9 | #include <gp_Ax3.hxx> |
10 | |
11 | gce_MakePln::gce_MakePln(const gp_Ax2& A2) |
12 | { |
13 | ThePln = gp_Pln(gp_Ax3(A2)); |
14 | TheError = gce_Done; |
15 | } |
16 | |
17 | gce_MakePln::gce_MakePln(const gp_Pnt& P, |
18 | const gp_Dir& V) |
19 | { |
20 | ThePln = gp_Pln(P,V); |
21 | TheError = gce_Done; |
22 | } |
23 | |
24 | gce_MakePln::gce_MakePln(const gp_Pnt& P1, |
25 | const gp_Pnt& P2) |
26 | { |
27 | if (P1.Distance(P2) <= gp::Resolution()) { TheError = gce_ConfusedPoints; } |
28 | else { |
29 | gp_Dir dir(P2.XYZ()-P1.XYZ()); |
30 | ThePln = gp_Pln(P1,dir); |
31 | TheError = gce_Done; |
32 | } |
33 | } |
34 | |
35 | gce_MakePln::gce_MakePln(const Standard_Real A, |
36 | const Standard_Real B, |
37 | const Standard_Real C, |
38 | const Standard_Real D) |
39 | { |
40 | if (A*A + B*B + C*C <= gp::Resolution()) { |
41 | TheError = gce_BadEquation; |
42 | } |
43 | else { |
44 | ThePln = gp_Pln(A,B,C,D); |
45 | TheError = gce_Done; |
46 | } |
47 | } |
48 | |
49 | //========================================================================= |
50 | // Creation d un gp_pln passant par trois points. + |
51 | //========================================================================= |
52 | |
53 | gce_MakePln::gce_MakePln(const gp_Pnt& P1 , |
54 | const gp_Pnt& P2 , |
55 | const gp_Pnt& P3 ) |
56 | { |
57 | gp_XYZ V1(P2.XYZ()-P1.XYZ()); |
58 | gp_XYZ V2(P3.XYZ()-P1.XYZ()); |
59 | gp_XYZ Norm(V1.Crossed(V2)); |
60 | if (Norm.Modulus() < gp::Resolution()) { TheError = gce_ColinearPoints; } |
61 | else { |
62 | gp_Dir DNorm(Norm); |
63 | gp_Dir Dx(V1); |
64 | ThePln = gp_Pln(gp_Ax3(P1,DNorm,Dx)); |
65 | TheError = gce_Done; |
66 | } |
67 | } |
68 | |
69 | //========================================================================= |
70 | // Creation d un gp_pln parallele a un autre pln a une distance donnee. + |
71 | //========================================================================= |
72 | |
73 | gce_MakePln::gce_MakePln(const gp_Pln& Pl , |
74 | const Standard_Real Dist ) |
75 | { |
76 | gp_Pnt Center(Pl.Location().XYZ()+Dist*gp_XYZ(Pl.Axis().Direction().XYZ())); |
77 | ThePln=gp_Pln(gp_Ax3(Center,Pl.Axis().Direction(),Pl.XAxis().Direction())); |
78 | TheError = gce_Done; |
79 | } |
80 | |
81 | //========================================================================= |
82 | // Creation d un gp_pln parallele a un autre pln passant par un point + |
83 | // <Point1>. + |
84 | //========================================================================= |
85 | |
86 | gce_MakePln::gce_MakePln(const gp_Pln& Pl , |
87 | const gp_Pnt& Point ) |
88 | { |
89 | ThePln = gp_Pln(gp_Ax3(Point,Pl.Axis().Direction(),Pl.XAxis().Direction())); |
90 | TheError = gce_Done; |
91 | } |
92 | |
93 | //========================================================================= |
94 | // Creation d un gp_pln a partir d un Ax1 (Point + Normale). + |
95 | //========================================================================= |
96 | |
97 | gce_MakePln::gce_MakePln(const gp_Ax1& Axis ) |
98 | { |
99 | ThePln = gp_Pln(Axis.Location(),Axis.Direction()); |
100 | TheError = gce_Done; |
101 | } |
102 | |
103 | //========================================================================= |
104 | // Creation d un gp_pln par un tableau de points. + |
105 | //========================================================================= |
106 | |
107 | /*gce_MakePln::gce_MakePln(const gp_Array1OfPnt& Pts , |
108 | Standard_Real ErrMax , |
109 | Standard_Real ErrMean ) |
110 | { |
111 | TheError = gce_ConfusedPoints; |
112 | } |
113 | */ |
114 | const gp_Pln& gce_MakePln::Value () const |
115 | { |
116 | StdFail_NotDone_Raise_if(!TheError == gce_Done,""); |
117 | return ThePln; |
118 | } |
119 | |
120 | const gp_Pln& gce_MakePln::Operator() const |
121 | { |
122 | return Value(); |
123 | } |
124 | |
125 | gce_MakePln::operator gp_Pln() const |
126 | { |
127 | return Value(); |
128 | } |
129 | |
130 | |
131 | |
132 | |
133 | |