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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepPrimAPI_MakeBox.ixx>
18 #include <BRepBuilderAPI.hxx>
20 #include <BRepPrim_Direction.hxx>
23 inline gp_Pnt pmin(const gp_Pnt& p,
24 const Standard_Real dx,
25 const Standard_Real dy,
26 const Standard_Real dz)
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);
35 //=======================================================================
36 //function : BRepPrimAPI_MakeBox
38 //=======================================================================
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))
49 //=======================================================================
50 //function : BRepPrimAPI_MakeBox
52 //=======================================================================
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))
64 //=======================================================================
65 //function : BRepPrimAPI_MakeBox
67 //=======================================================================
69 inline gp_Pnt pmin(const gp_Pnt& p1, const gp_Pnt& p2)
71 return gp_Pnt(Min(p1.X(),p2.X()),Min(p1.Y(),p2.Y()),Min(p1.Z(),p2.Z()));
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)),
83 //=======================================================================
84 //function : BRepPrimAPI_MakeBox
86 //=======================================================================
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)
97 //=======================================================================
100 //=======================================================================
102 BRepPrim_Wedge& BRepPrimAPI_MakeBox::Wedge()
108 //=======================================================================
111 //=======================================================================
113 const TopoDS_Shell& BRepPrimAPI_MakeBox::Shell()
115 myShape = myWedge.Shell();
117 return TopoDS::Shell(myShape);
120 //=======================================================================
123 //=======================================================================
125 void BRepPrimAPI_MakeBox::Build()
130 //=======================================================================
133 //=======================================================================
135 const TopoDS_Solid& BRepPrimAPI_MakeBox::Solid()
138 B.MakeSolid(TopoDS::Solid(myShape));
139 B.Add(myShape,myWedge.Shell());
141 return TopoDS::Solid(myShape);
146 //=======================================================================
147 //function : operator
149 //=======================================================================
151 BRepPrimAPI_MakeBox::operator TopoDS_Shell()
156 //=======================================================================
157 //function : operator
159 //=======================================================================
161 BRepPrimAPI_MakeBox::operator TopoDS_Solid()
167 //=======================================================================
168 //function : BottomFace
170 //=======================================================================
172 const TopoDS_Face& BRepPrimAPI_MakeBox::BottomFace () {
174 return myWedge.Face (BRepPrim_ZMin);
179 //=======================================================================
180 //function : BackFace
182 //=======================================================================
184 const TopoDS_Face& BRepPrimAPI_MakeBox::BackFace () {
186 return myWedge.Face (BRepPrim_XMin);
190 //=======================================================================
191 //function : FrontFace
193 //=======================================================================
195 const TopoDS_Face& BRepPrimAPI_MakeBox::FrontFace () {
197 return myWedge.Face (BRepPrim_XMax);
201 //=======================================================================
202 //function : LeftFace
204 //=======================================================================
206 const TopoDS_Face& BRepPrimAPI_MakeBox::LeftFace () {
208 return myWedge.Face (BRepPrim_YMin);
212 //=======================================================================
213 //function : RightFace
215 //=======================================================================
217 const TopoDS_Face& BRepPrimAPI_MakeBox::RightFace () {
219 return myWedge.Face (BRepPrim_YMax);
223 //=======================================================================
226 //=======================================================================
228 const TopoDS_Face& BRepPrimAPI_MakeBox::TopFace () {
230 return myWedge.Face (BRepPrim_ZMax);