1 // Created on: 1993-07-22
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
23 #include <BRepTest.hxx>
25 #include <Draw_Interpretor.hxx>
26 #include <Draw_Appli.hxx>
27 #include <DrawTrSurf.hxx>
28 #include <TopoDS_Solid.hxx>
29 #include <BRep_Builder.hxx>
30 #include <BRepBuilderAPI.hxx>
31 #include <BRepPrimAPI_MakeBox.hxx>
32 #include <BRepPrimAPI_MakeWedge.hxx>
33 #include <BRepPrimAPI_MakeCylinder.hxx>
34 #include <BRepPrimAPI_MakeCone.hxx>
35 #include <BRepPrimAPI_MakeSphere.hxx>
36 #include <BRepPrimAPI_MakeTorus.hxx>
37 #include <BRepPrimAPI_MakeSphere.hxx>
38 #include <Geom_Plane.hxx>
42 //=======================================================================
44 //=======================================================================
46 static Standard_Integer box(Draw_Interpretor& , Standard_Integer n, const char** a)
49 Standard_Real dx = atof(a[n-3]);
50 Standard_Real dy = atof(a[n-2]);
51 Standard_Real dz = atof(a[n-1]);
57 Standard_Real x = atof(a[2]);
58 Standard_Real y = atof(a[3]);
59 Standard_Real z = atof(a[4]);
60 S = BRepPrimAPI_MakeBox(gp_Pnt(x,y,z),dx,dy,dz);
63 S = BRepPrimAPI_MakeBox(dx,dy,dz);
70 //=======================================================================
72 //=======================================================================
74 static Standard_Integer wedge(Draw_Interpretor& , Standard_Integer n, const char** a)
78 // Standard_Integer i = 0;
79 if ( n == 15 || n == 18) {
80 gp_Pnt LocalP(atof(a[2]),atof(a[3]),atof(a[4]));
81 gp_Dir LocalN(atof(a[5]),atof(a[6]),atof(a[7]));
82 gp_Dir LocalVx(atof(a[8]),atof(a[9]),atof(a[10]));
83 gp_Ax2 Axis(LocalP,LocalN,LocalVx);
84 // gp_Ax2 Axis(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
85 // gp_Dir(atof(a[5]),atof(a[6]),atof(a[7])),
86 // gp_Dir(atof(a[8]),atof(a[9]),atof(a[10])));
88 S = BRepPrimAPI_MakeWedge(Axis,
89 atof(a[11]),atof(a[12]),atof(a[13]),atof(a[14]));
92 S = BRepPrimAPI_MakeWedge(Axis,
93 atof(a[11]),atof(a[12]),atof(a[13]),
94 atof(a[14]),atof(a[15]),atof(a[16]),atof(a[17]));
98 S = BRepPrimAPI_MakeWedge(atof(a[2]),atof(a[3]),atof(a[4]),atof(a[5]));
101 S = BRepPrimAPI_MakeWedge(atof(a[2]),atof(a[3]),atof(a[4]),
102 atof(a[5]),atof(a[6]),atof(a[7]),atof(a[8]));
111 //=======================================================================
113 //=======================================================================
115 static Standard_Integer cylinder(Draw_Interpretor& , Standard_Integer n, const char** a)
119 Handle(Geom_Plane) P =
120 Handle(Geom_Plane)::DownCast(DrawTrSurf::Get(a[2]));
123 S = BRepPrimAPI_MakeCylinder(atof(a[2]),atof(a[3]));
127 S = BRepPrimAPI_MakeCylinder(atof(a[2]),atof(a[3]),atof(a[4]) * (M_PI / 180.0));
129 S = BRepPrimAPI_MakeCylinder(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]));
135 S = BRepPrimAPI_MakeCylinder(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]),atof(a[5]) * (M_PI / 180.0));
144 //=======================================================================
146 //=======================================================================
148 static Standard_Integer cone(Draw_Interpretor& , Standard_Integer n, const char** a)
153 Handle(Geom_Plane) P =
154 Handle(Geom_Plane)::DownCast(DrawTrSurf::Get(a[2]));
157 S = BRepPrimAPI_MakeCone(atof(a[2]),atof(a[3]),atof(a[4]));
161 S = BRepPrimAPI_MakeCone(atof(a[2]),atof(a[3]),atof(a[4]),atof(a[5]) * (M_PI / 180.0));
163 S = BRepPrimAPI_MakeCone(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]),atof(a[5]));
166 S = BRepPrimAPI_MakeCone(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]),atof(a[5]),atof(a[6]) * (M_PI / 180.0));
175 //=======================================================================
177 //=======================================================================
179 static Standard_Integer sphere(Draw_Interpretor& , Standard_Integer n, const char** a)
184 Handle(Geom_Plane) P =
185 Handle(Geom_Plane)::DownCast(DrawTrSurf::Get(a[2]));
188 S = BRepPrimAPI_MakeSphere(atof(a[2]));
192 S = BRepPrimAPI_MakeSphere(atof(a[2]),atof(a[3]) * (M_PI / 180.0));
194 S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(),atof(a[3]));
198 S = BRepPrimAPI_MakeSphere(atof(a[2]),atof(a[3]) * (M_PI / 180.0),atof(a[4]) * (M_PI / 180.0));
200 S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]) * (M_PI / 180.0));
204 S = BRepPrimAPI_MakeSphere(atof(a[2]),atof(a[3]) * (M_PI / 180.0),atof(a[4]) * (M_PI / 180.0),atof(a[5]) * (M_PI / 180.0));
206 S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]) * (M_PI / 180.0),atof(a[5]) * (M_PI / 180.0));
209 S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]) * (M_PI / 180.0),atof(a[5]) * (M_PI / 180.0),atof(a[6]) * (M_PI / 180.0));
218 //=======================================================================
220 //=======================================================================
222 static Standard_Integer torus(Draw_Interpretor& , Standard_Integer n, const char** a)
227 Handle(Geom_Plane) P =
228 Handle(Geom_Plane)::DownCast(DrawTrSurf::Get(a[2]));
231 S = BRepPrimAPI_MakeTorus(atof(a[2]),atof(a[3]));
235 S = BRepPrimAPI_MakeTorus(atof(a[2]),atof(a[3]),atof(a[4]) * (M_PI / 180.0));
237 S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]));
241 S = BRepPrimAPI_MakeTorus(atof(a[2]),atof(a[3]),
242 atof(a[4]) * (M_PI / 180.0),atof(a[5]) * (M_PI / 180.0));
244 S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(),
245 atof(a[3]),atof(a[4]),atof(a[5]) * (M_PI / 180.0));
249 S = BRepPrimAPI_MakeTorus(atof(a[2]),atof(a[3]),
250 atof(a[4]) * (M_PI / 180.0),atof(a[5]) * (M_PI / 180.0),atof(a[6]) * (M_PI / 180.0));
252 S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(),atof(a[3]),
253 atof(a[4]),atof(a[5]) * (M_PI / 180.0),atof(a[6]) * (M_PI / 180.0));
256 S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]),
257 atof(a[5]) * (M_PI / 180.0),atof(a[6]) * (M_PI / 180.0),atof(a[7]) * (M_PI / 180.0));
268 //=======================================================================
269 //function : PrimitiveCommands
271 //=======================================================================
273 void BRepTest::PrimitiveCommands(Draw_Interpretor& theCommands)
275 static Standard_Boolean done = Standard_False;
277 done = Standard_True;
279 DBRep::BasicCommands(theCommands);
281 const char* g = "Primitive building commands";
283 theCommands.Add("box","box name [x1 y1 z1] dx dy dz",__FILE__,box,g);
284 theCommands.Add("wedge","wedge name [Ox Oy Oz Zx Zy Zz Xx Xy Xz] dx dy dz ltx / xmin zmin xmax zmax",__FILE__,wedge,g);
286 theCommands.Add("pcylinder","pcylinder name [plane(ax2)] R H [angle]",__FILE__,cylinder,g);
287 theCommands.Add("pcone", "pcone name [plane(ax2)] R1 R2 H [angle]",__FILE__,cone,g);
288 theCommands.Add("psphere", "psphere name [plane(ax2)] R [angle1 angle2] [angle]",__FILE__,sphere,g);
289 theCommands.Add("ptorus", "ptorus name [plane(ax2)] R1 R2 [angle1 angle2] [angle]",__FILE__,torus,g);