0024734: Convertation of the generic classes to the non-generic. Part 4
[occt.git] / src / BRepPrimAPI / BRepPrimAPI_MakeBox.cxx
1 // Created on: 1993-07-23
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-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 <BRepPrimAPI_MakeBox.ixx>
18 #include <BRepBuilderAPI.hxx>
19 #include <TopoDS.hxx>
20 #include <BRepPrim_Direction.hxx>
21
22
23 inline gp_Pnt pmin(const gp_Pnt& p, 
24                    const Standard_Real dx,
25                    const Standard_Real dy, 
26                    const Standard_Real dz)
27 {
28   gp_Pnt P = p;
29   if (dx < 0) P.SetX(P.X()+dx);
30   if (dy < 0) P.SetY(P.Y()+dy);
31   if (dz < 0) P.SetZ(P.Z()+dz);
32   return P;
33 }
34
35 //=======================================================================
36 //function : BRepPrimAPI_MakeBox
37 //purpose  : 
38 //=======================================================================
39
40 BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(const Standard_Real dx,
41                                  const Standard_Real dy,
42                                  const Standard_Real dz) :
43        myWedge(gp_Ax2(pmin(gp_Pnt(0,0,0),dx,dy,dz),gp_Dir(0,0,1),gp_Dir(1,0,0)),
44                Abs(dx),Abs(dy),Abs(dz))
45 {
46 }
47
48
49 //=======================================================================
50 //function : BRepPrimAPI_MakeBox
51 //purpose  : 
52 //=======================================================================
53
54 BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(const gp_Pnt& P, 
55                                  const Standard_Real dx,
56                                  const Standard_Real dy, 
57                                  const Standard_Real dz) :
58        myWedge(gp_Ax2(pmin(P,dx,dy,dz),gp_Dir(0,0,1),gp_Dir(1,0,0)),
59                Abs(dx),Abs(dy),Abs(dz))
60 {
61 }
62
63
64 //=======================================================================
65 //function : BRepPrimAPI_MakeBox
66 //purpose  : 
67 //=======================================================================
68
69 inline gp_Pnt pmin(const gp_Pnt& p1, const gp_Pnt& p2)
70 {
71   return gp_Pnt(Min(p1.X(),p2.X()),Min(p1.Y(),p2.Y()),Min(p1.Z(),p2.Z()));
72 }
73
74 BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(const gp_Pnt& P1, const gp_Pnt& P2) :
75        myWedge(gp_Ax2(pmin(P1,P2),gp_Dir(0,0,1),gp_Dir(1,0,0)),
76                Abs(P2.X()-P1.X()),
77                Abs(P2.Y()-P1.Y()),
78                Abs(P2.Z()-P1.Z()))
79 {
80 }
81
82
83 //=======================================================================
84 //function : BRepPrimAPI_MakeBox
85 //purpose  : 
86 //=======================================================================
87
88 BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(const gp_Ax2& Axes, 
89                                  const Standard_Real dx, 
90                                  const Standard_Real dy, 
91                                  const Standard_Real dz) :
92        myWedge(Axes,dx,dy,dz)
93 {
94 }
95
96
97 //=======================================================================
98 //function : Wedge
99 //purpose  : 
100 //=======================================================================
101
102 BRepPrim_Wedge&  BRepPrimAPI_MakeBox::Wedge()
103 {
104   return myWedge;
105 }
106
107
108 //=======================================================================
109 //function : Shell
110 //purpose  : 
111 //=======================================================================
112
113 const TopoDS_Shell&  BRepPrimAPI_MakeBox::Shell()
114 {
115   myShape = myWedge.Shell();
116   Done();
117   return TopoDS::Shell(myShape);
118 }
119
120 //=======================================================================
121 //function : Build
122 //purpose  : 
123 //=======================================================================
124
125 void BRepPrimAPI_MakeBox::Build()
126 {
127   Solid();
128 }
129
130 //=======================================================================
131 //function : Solid
132 //purpose  : 
133 //=======================================================================
134
135 const TopoDS_Solid&  BRepPrimAPI_MakeBox::Solid()
136 {
137   BRep_Builder B;
138   B.MakeSolid(TopoDS::Solid(myShape));
139   B.Add(myShape,myWedge.Shell());
140   Done();
141   return TopoDS::Solid(myShape);
142 }
143
144
145
146 //=======================================================================
147 //function : operator
148 //purpose  : 
149 //=======================================================================
150
151 BRepPrimAPI_MakeBox::operator TopoDS_Shell()
152 {
153   return Shell();
154 }
155
156 //=======================================================================
157 //function : operator
158 //purpose  : 
159 //=======================================================================
160
161 BRepPrimAPI_MakeBox::operator TopoDS_Solid()
162 {
163   return Solid();
164 }
165
166
167 //=======================================================================
168 //function : BottomFace
169 //purpose  : 
170 //=======================================================================
171
172 const TopoDS_Face& BRepPrimAPI_MakeBox::BottomFace () {
173
174  return myWedge.Face (BRepPrim_ZMin);
175 }
176
177
178
179 //=======================================================================
180 //function : BackFace
181 //purpose  : 
182 //=======================================================================
183
184 const TopoDS_Face& BRepPrimAPI_MakeBox::BackFace () {
185
186  return myWedge.Face (BRepPrim_XMin);
187 }
188
189
190 //=======================================================================
191 //function : FrontFace
192 //purpose  : 
193 //=======================================================================
194
195 const TopoDS_Face& BRepPrimAPI_MakeBox::FrontFace () {
196
197  return myWedge.Face (BRepPrim_XMax);
198 }
199
200
201 //=======================================================================
202 //function : LeftFace
203 //purpose  : 
204 //=======================================================================
205
206 const TopoDS_Face& BRepPrimAPI_MakeBox::LeftFace () {
207
208  return myWedge.Face (BRepPrim_YMin);
209 }
210
211
212 //=======================================================================
213 //function : RightFace
214 //purpose  : 
215 //=======================================================================
216
217 const TopoDS_Face& BRepPrimAPI_MakeBox::RightFace () {
218
219  return myWedge.Face (BRepPrim_YMax);
220 }
221
222
223 //=======================================================================
224 //function : TopFace
225 //purpose  : 
226 //=======================================================================
227
228 const TopoDS_Face& BRepPrimAPI_MakeBox::TopFace () {
229
230  return myWedge.Face (BRepPrim_ZMax);
231 }
232
233
234
235
236
237