2 // Created: Thu Jul 22 11:46:12 1993
3 // Author: Remi LEQUETTE
7 #include <BRepTest.hxx>
9 #include <Draw_Interpretor.hxx>
10 #include <Draw_Appli.hxx>
11 #include <DrawTrSurf.hxx>
12 #include <TopoDS_Solid.hxx>
13 #include <BRep_Builder.hxx>
14 #include <BRepBuilderAPI.hxx>
15 #include <BRepPrimAPI_MakeBox.hxx>
16 #include <BRepPrimAPI_MakeWedge.hxx>
17 #include <BRepPrimAPI_MakeCylinder.hxx>
18 #include <BRepPrimAPI_MakeCone.hxx>
19 #include <BRepPrimAPI_MakeSphere.hxx>
20 #include <BRepPrimAPI_MakeTorus.hxx>
21 #include <BRepPrimAPI_MakeSphere.hxx>
22 #include <Geom_Plane.hxx>
26 //=======================================================================
28 //=======================================================================
30 static Standard_Integer box(Draw_Interpretor& , Standard_Integer n, const char** a)
33 Standard_Real dx = atof(a[n-3]);
34 Standard_Real dy = atof(a[n-2]);
35 Standard_Real dz = atof(a[n-1]);
41 Standard_Real x = atof(a[2]);
42 Standard_Real y = atof(a[3]);
43 Standard_Real z = atof(a[4]);
44 S = BRepPrimAPI_MakeBox(gp_Pnt(x,y,z),dx,dy,dz);
47 S = BRepPrimAPI_MakeBox(dx,dy,dz);
54 //=======================================================================
56 //=======================================================================
58 static Standard_Integer wedge(Draw_Interpretor& , Standard_Integer n, const char** a)
62 // Standard_Integer i = 0;
63 if ( n == 15 || n == 18) {
64 gp_Pnt LocalP(atof(a[2]),atof(a[3]),atof(a[4]));
65 gp_Dir LocalN(atof(a[5]),atof(a[6]),atof(a[7]));
66 gp_Dir LocalVx(atof(a[8]),atof(a[9]),atof(a[10]));
67 gp_Ax2 Axis(LocalP,LocalN,LocalVx);
68 // gp_Ax2 Axis(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
69 // gp_Dir(atof(a[5]),atof(a[6]),atof(a[7])),
70 // gp_Dir(atof(a[8]),atof(a[9]),atof(a[10])));
72 S = BRepPrimAPI_MakeWedge(Axis,
73 atof(a[11]),atof(a[12]),atof(a[13]),atof(a[14]));
76 S = BRepPrimAPI_MakeWedge(Axis,
77 atof(a[11]),atof(a[12]),atof(a[13]),
78 atof(a[14]),atof(a[15]),atof(a[16]),atof(a[17]));
82 S = BRepPrimAPI_MakeWedge(atof(a[2]),atof(a[3]),atof(a[4]),atof(a[5]));
85 S = BRepPrimAPI_MakeWedge(atof(a[2]),atof(a[3]),atof(a[4]),
86 atof(a[5]),atof(a[6]),atof(a[7]),atof(a[8]));
95 //=======================================================================
97 //=======================================================================
99 static Standard_Integer cylinder(Draw_Interpretor& , Standard_Integer n, const char** a)
103 Handle(Geom_Plane) P =
104 Handle(Geom_Plane)::DownCast(DrawTrSurf::Get(a[2]));
107 S = BRepPrimAPI_MakeCylinder(atof(a[2]),atof(a[3]));
111 S = BRepPrimAPI_MakeCylinder(atof(a[2]),atof(a[3]),atof(a[4]) * (M_PI / 180.0));
113 S = BRepPrimAPI_MakeCylinder(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]));
119 S = BRepPrimAPI_MakeCylinder(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]),atof(a[5]) * (M_PI / 180.0));
128 //=======================================================================
130 //=======================================================================
132 static Standard_Integer cone(Draw_Interpretor& , Standard_Integer n, const char** a)
137 Handle(Geom_Plane) P =
138 Handle(Geom_Plane)::DownCast(DrawTrSurf::Get(a[2]));
141 S = BRepPrimAPI_MakeCone(atof(a[2]),atof(a[3]),atof(a[4]));
145 S = BRepPrimAPI_MakeCone(atof(a[2]),atof(a[3]),atof(a[4]),atof(a[5]) * (M_PI / 180.0));
147 S = BRepPrimAPI_MakeCone(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]),atof(a[5]));
150 S = BRepPrimAPI_MakeCone(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]),atof(a[5]),atof(a[6]) * (M_PI / 180.0));
159 //=======================================================================
161 //=======================================================================
163 static Standard_Integer sphere(Draw_Interpretor& , Standard_Integer n, const char** a)
168 Handle(Geom_Plane) P =
169 Handle(Geom_Plane)::DownCast(DrawTrSurf::Get(a[2]));
172 S = BRepPrimAPI_MakeSphere(atof(a[2]));
176 S = BRepPrimAPI_MakeSphere(atof(a[2]),atof(a[3]) * (M_PI / 180.0));
178 S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(),atof(a[3]));
182 S = BRepPrimAPI_MakeSphere(atof(a[2]),atof(a[3]) * (M_PI / 180.0),atof(a[4]) * (M_PI / 180.0));
184 S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]) * (M_PI / 180.0));
188 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));
190 S = BRepPrimAPI_MakeSphere(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]) * (M_PI / 180.0),atof(a[5]) * (M_PI / 180.0));
193 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));
202 //=======================================================================
204 //=======================================================================
206 static Standard_Integer torus(Draw_Interpretor& , Standard_Integer n, const char** a)
211 Handle(Geom_Plane) P =
212 Handle(Geom_Plane)::DownCast(DrawTrSurf::Get(a[2]));
215 S = BRepPrimAPI_MakeTorus(atof(a[2]),atof(a[3]));
219 S = BRepPrimAPI_MakeTorus(atof(a[2]),atof(a[3]),atof(a[4]) * (M_PI / 180.0));
221 S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]));
225 S = BRepPrimAPI_MakeTorus(atof(a[2]),atof(a[3]),
226 atof(a[4]) * (M_PI / 180.0),atof(a[5]) * (M_PI / 180.0));
228 S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(),
229 atof(a[3]),atof(a[4]),atof(a[5]) * (M_PI / 180.0));
233 S = BRepPrimAPI_MakeTorus(atof(a[2]),atof(a[3]),
234 atof(a[4]) * (M_PI / 180.0),atof(a[5]) * (M_PI / 180.0),atof(a[6]) * (M_PI / 180.0));
236 S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(),atof(a[3]),
237 atof(a[4]),atof(a[5]) * (M_PI / 180.0),atof(a[6]) * (M_PI / 180.0));
240 S = BRepPrimAPI_MakeTorus(P->Pln().Position().Ax2(),atof(a[3]),atof(a[4]),
241 atof(a[5]) * (M_PI / 180.0),atof(a[6]) * (M_PI / 180.0),atof(a[7]) * (M_PI / 180.0));
252 //=======================================================================
253 //function : PrimitiveCommands
255 //=======================================================================
257 void BRepTest::PrimitiveCommands(Draw_Interpretor& theCommands)
259 static Standard_Boolean done = Standard_False;
261 done = Standard_True;
263 DBRep::BasicCommands(theCommands);
265 const char* g = "Primitive building commands";
267 theCommands.Add("box","box name [x1 y1 z1] dx dy dz",__FILE__,box,g);
268 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);
270 theCommands.Add("pcylinder","pcylinder name [plane(ax2)] R H [angle]",__FILE__,cylinder,g);
271 theCommands.Add("pcone", "pcone name [plane(ax2)] R1 R2 H [angle]",__FILE__,cone,g);
272 theCommands.Add("psphere", "psphere name [plane(ax2)] R [angle1 angle2] [angle]",__FILE__,sphere,g);
273 theCommands.Add("ptorus", "ptorus name [plane(ax2)] R1 R2 [angle1 angle2] [angle]",__FILE__,torus,g);