Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / java / src / SamplesTopologyPackage / SamplesTopologyPackage.cxx
1 #include <SamplesTopologyPackage.hxx>
2 #include <AIS_InteractiveContext.hxx>
3 #include <TCollection_AsciiString.hxx>
4 #include <gp.hxx>
5 #include <gp_Pnt.hxx>
6 #include <gp_Dir.hxx>
7 #include <gp_Vec.hxx>
8 #include <gp_Ax1.hxx>
9 #include <gp_Ax2.hxx>
10 #include <gp_Ax3.hxx>
11 #include <gp_Trsf.hxx>
12 #include <gp_GTrsf.hxx>
13 #include <gp_Mat.hxx>
14 #include <gp_Lin.hxx>
15 #include <gp_Circ.hxx>
16 #include <gp_Elips.hxx>
17 #include <gp_Pln.hxx>
18 #include <gp_Sphere.hxx>
19 #include <gp_Pnt2d.hxx>
20 #include <gp_Dir2d.hxx>
21 #include <gp_Circ2d.hxx>
22 #include <Geom_Axis1Placement.hxx>
23 #include <Geom_Line.hxx>
24 #include <Geom_Circle.hxx>
25 #include <Geom_BSplineCurve.hxx>
26 #include <Geom_BezierCurve.hxx>
27 #include <Geom_Surface.hxx>
28 #include <Geom_Plane.hxx>
29 #include <Geom_CylindricalSurface.hxx>
30 #include <Geom_BSplineSurface.hxx>
31 #include <Geom_RectangularTrimmedSurface.hxx>
32 #include <Geom_Transformation.hxx>
33 #include <Geom_CartesianPoint.hxx>
34 #include <GeomAPI_PointsToBSpline.hxx>
35 #include <GeomAPI_PointsToBSplineSurface.hxx>
36 #include <GeomFill_BSplineCurves.hxx>
37 #include <Geom2d_Line.hxx>
38 #include <Geom2d_Circle.hxx>
39 #include <GCE2d_MakeLine.hxx>
40 #include <BRepPrimAPI_MakeBox.hxx>
41 #include <BRepPrimAPI_MakeCylinder.hxx>
42 #include <BRepPrimAPI_MakeCone.hxx>
43 #include <BRepPrimAPI_MakeSphere.hxx>
44 #include <BRepPrimAPI_MakeTorus.hxx>
45 #include <BRepPrimAPI_MakeWedge.hxx>
46 #include <BRepPrimAPI_MakePrism.hxx>
47 #include <BRepPrimAPI_MakeRevol.hxx>
48 #include <BRepBuilderAPI_MakeVertex.hxx>
49 #include <BRepBuilderAPI_MakeEdge.hxx>
50 #include <BRepBuilderAPI_MakeWire.hxx>
51 #include <BRepBuilderAPI_MakeFace.hxx>
52 #include <BRepBuilderAPI_MakeShell.hxx>
53 #include <BRepBuilderAPI_MakePolygon.hxx>
54 #include <BRepBuilderAPI_Transform.hxx>
55 #include <BRepBuilderAPI_GTransform.hxx>
56 #include <BRepOffsetAPI_MakePipe.hxx>
57 #include <BRepOffsetAPI_ThruSections.hxx>
58 #include <BRepOffsetAPI_MakeEvolved.hxx>
59 #include <BRepOffsetAPI_DraftAngle.hxx>
60 #include <BRepOffsetAPI_Sewing.hxx>
61 #include <BRepOffsetAPI_MakeOffsetShape.hxx>
62 #include <BRepOffsetAPI_MakeThickSolid.hxx>
63 #include <BRepAlgo.hxx>
64 #include <BRepAlgoAPI_Cut.hxx>
65 #include <BRepAlgoAPI_Fuse.hxx>
66 #include <BRepAlgoAPI_Common.hxx>
67 #include <BRepAlgoAPI_Section.hxx>
68 #include <BRepFilletAPI_MakeFillet.hxx>
69 #include <BRepFilletAPI_MakeChamfer.hxx>
70 #include <BRepFeat_MakePrism.hxx>
71 #include <BRepFeat_MakeDPrism.hxx>
72 #include <BRepFeat_MakeRevol.hxx>
73 #include <BRepFeat_MakePipe.hxx>
74 #include <BRepFeat_MakeLinearForm.hxx>
75 #include <BRepFeat_Gluer.hxx>
76 #include <BRepFeat_SplitShape.hxx>
77 #include <BRep_Builder.hxx>
78 #include <BRep_Tool.hxx>
79 #include <BRepLib.hxx>
80 #include <BRepTools.hxx>
81 #include <BRepMesh.hxx>
82 #include <BRepGProp.hxx>
83 #include <GProp_GProps.hxx>
84 #include <TopLoc_Location.hxx>
85 #include <Poly_Triangulation.hxx>
86 #include <Poly_Triangle.hxx>
87 #include <LocOpe_FindEdges.hxx>
88 #include <TopOpeBRepTool.hxx>
89 #include <TopoDS.hxx>
90 #include <TopoDS_Shape.hxx>
91 #include <TopoDS_Vertex.hxx>
92 #include <TopoDS_Edge.hxx>
93 #include <TopoDS_Wire.hxx>
94 #include <TopoDS_Face.hxx>
95 #include <TopoDS_Shell.hxx>
96 #include <TopoDS_Solid.hxx>
97 #include <TopoDS_Compound.hxx>
98 #include <TopAbs_Orientation.hxx>
99 #include <AIS_Shape.hxx>
100 #include <AIS_Axis.hxx>
101 #include <AIS_Point.hxx>
102 #include <AIS_Line.hxx>
103 #include <AIS_Plane.hxx>
104 #include <AIS_ConnectedInteractive.hxx>
105 #include <ISession_Direction.hxx>
106 #include <Quantity_NameOfColor.hxx>
107 #include <TColStd_Array1OfReal.hxx>
108 #include <TColStd_Array1OfInteger.hxx>
109 #include <TColgp_Array1OfPnt.hxx>
110 #include <TColgp_Array2OfPnt.hxx>
111 #include <TColgp_Array1OfPnt2d.hxx>
112 #include <TopExp.hxx>
113 #include <TopExp_Explorer.hxx>
114 #include <TopTools_ListOfShape.hxx>
115 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
116 #include <Precision.hxx>
117 #include <OSD.hxx>
118
119 #include <V3d_Viewer.hxx>
120 #include <V3d_View.hxx>
121
122 #ifdef WNT
123 #include <WNT_Window.hxx>
124 #include <Graphic3d_WNTGraphicDevice.hxx>
125 #else
126 #include <Xw_Window.hxx>
127 #include <Graphic3d_GraphicDevice.hxx>
128 #endif
129
130
131
132
133 //===============================================================
134 // Function name: CreateViewer
135 //===============================================================
136  Handle(V3d_Viewer) SamplesTopologyPackage::CreateViewer (const Standard_ExtString aName) 
137 {
138 #ifdef WNT
139 static Handle(Graphic3d_WNTGraphicDevice) defaultDevice;
140     
141   if (defaultDevice.IsNull()) 
142     defaultDevice = new Graphic3d_WNTGraphicDevice();
143   return new V3d_Viewer(defaultDevice, aName);
144 #else
145 static Handle(Graphic3d_GraphicDevice) defaultDevice;
146     
147   if (defaultDevice.IsNull()) 
148     defaultDevice = new Graphic3d_GraphicDevice("");
149   return new V3d_Viewer(defaultDevice, aName);
150 #endif //WNT
151 }
152
153 //===============================================================
154 // Function name: SetWindow
155 //===============================================================
156 void SamplesTopologyPackage::SetWindow (const Handle(V3d_View)& aView,
157                                         const Standard_Integer hiwin,
158                                         const Standard_Integer lowin)
159 {
160 #ifdef WNT
161   Handle(Graphic3d_WNTGraphicDevice) d = 
162     Handle(Graphic3d_WNTGraphicDevice)::DownCast(aView->Viewer()->Device());
163   Handle(WNT_Window) w = new WNT_Window(d,hiwin,lowin);
164 #else
165   Handle(Graphic3d_GraphicDevice) d = 
166     Handle(Graphic3d_GraphicDevice)::DownCast(aView->Viewer()->Device());
167   Handle(Xw_Window) w = new Xw_Window(d,hiwin,lowin,Xw_WQ_3DQUALITY);
168 #endif
169   aView->SetWindow(w);
170 }
171
172
173
174 //======================================================================
175 //=                                                                    =
176 //=                      Topology  Primitives                          =
177 //=                                                                    =
178 //======================================================================
179
180 //===============================================================
181 // Function name: MakeBox
182 //===============================================================
183  void SamplesTopologyPackage::MakeBox(const Handle(AIS_InteractiveContext)& aContext,
184                                       TCollection_AsciiString& Message) 
185 {
186   aContext->EraseAll(Standard_False);
187   
188   TopoDS_Shape B1 = BRepPrimAPI_MakeBox (200.,150.,100.).Shape();
189   Handle(AIS_Shape) aBox1 = new AIS_Shape(B1);
190   aContext->SetMaterial(aBox1,Graphic3d_NOM_PLASTIC,Standard_False);    
191   aContext->SetColor(aBox1,Quantity_NOC_GREEN,Standard_False); 
192   aContext->Display(aBox1);
193   TopoDS_Shape B2 = BRepPrimAPI_MakeBox (gp_Ax2(gp_Pnt(-200.,-80.,-70.),gp_Dir(1.,2.,1.)),80.,90.,120.).Shape();
194   Handle(AIS_Shape) aBox2 = new AIS_Shape(B2);
195   aContext->SetMaterial(aBox2,Graphic3d_NOM_PLASTIC,Standard_False);    
196   aContext->SetColor(aBox2,Quantity_NOC_RED,Standard_False); 
197   aContext->Display(aBox2);
198
199   Message = "\
200                 \n\
201 TopoDS_Shape B1 = BRepPrimAPI_MakeBox (200.,150.,100.); \n\
202 TopoDS_Shape B2 = BRepPrimAPI_MakeBox (gp_Ax2(gp_Pnt(-200.,-80.,-70.), \n\
203                                           gp_Dir(1.,2.,1.)), \n\
204                                    80.,90.,120.); \n\
205                 \n";
206 }
207
208 //===============================================================
209 // Function name: MakeCylinder
210 //===============================================================
211  void SamplesTopologyPackage::MakeCylinder(const Handle(AIS_InteractiveContext)& aContext,
212                                            TCollection_AsciiString& Message) 
213 {
214   aContext->EraseAll(Standard_False);
215   
216   TopoDS_Shape C1 = BRepPrimAPI_MakeCylinder (50.,200.).Shape();
217   Handle(AIS_Shape) aCyl1 = new AIS_Shape(C1);
218   aContext->SetMaterial(aCyl1,Graphic3d_NOM_PLASTIC,Standard_False);    
219   aContext->SetColor(aCyl1,Quantity_NOC_RED,Standard_False); 
220   aContext->Display(aCyl1);
221   TopoDS_Shape C2 = BRepPrimAPI_MakeCylinder (gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)),
222                                               40.,110.,210.*PI180).Shape();
223   Handle(AIS_Shape) aCyl2 = new AIS_Shape(C2);
224   aContext->SetMaterial(aCyl2,Graphic3d_NOM_PLASTIC,Standard_False);    
225   aContext->SetColor(aCyl2,Quantity_NOC_MATRABLUE,Standard_False);      
226   aContext->Display(aCyl2);
227
228   Message = "\
229                 \n\
230 TopoDS_Shape C1 = BRepPrimAPI_MakeCylinder (50.,200.); \n\
231 TopoDS_Shape C2 = BRepPrimAPI_MakeCylinder (gp_Ax2(gp_Pnt(200.,200.,0.), \n\
232                                         gp_Dir(0.,0.,1.)), \n\
233                                         40.,110.,210.*PI180.); \n\
234                 \n";
235 }
236
237 //===============================================================
238 // Function name: MakeCone
239 //===============================================================
240  void SamplesTopologyPackage::MakeCone(const Handle(AIS_InteractiveContext)& aContext,
241                                        TCollection_AsciiString& Message) 
242 {
243   aContext->EraseAll(Standard_False);
244
245   TopoDS_Shape C1 = BRepPrimAPI_MakeCone (50.,25.,200.).Shape();
246   Handle(AIS_Shape) ais1 = new AIS_Shape(C1);
247   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);    
248   aContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);               
249   aContext->Display(ais1);
250   TopoDS_Shape C2 = BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(0.,0.,1.)),
251                                      60.,0.,150.,210.*PI180).Shape();
252   Handle(AIS_Shape) ais2 = new AIS_Shape(C2);
253   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);    
254   aContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False); 
255   aContext->Display(ais2);
256
257   Message ="\
258                 \n\
259 TopoDS_Shape C1 = BRepPrimAPI_MakeCone (50.,25.,200.); \n\
260 TopoDS_Shape C2 = BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(100.,100.,0.), \n\
261                                           gp_Dir(0.,0.,1.)), \n\
262                                    605.,0.,150.,210.*PI180); \n\
263                 \n";
264 }
265
266 //===============================================================
267 // Function name: MakeSphere
268 //===============================================================
269  void SamplesTopologyPackage::MakeSphere(const Handle(AIS_InteractiveContext)& aContext,
270                                          TCollection_AsciiString& Message) 
271 {
272   aContext->EraseAll(Standard_False);
273
274   TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(gp_Pnt(-200.,-250.,0.),80.).Shape();
275   Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
276   aContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False); 
277   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);    
278   aContext->Display(ais1);
279   TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(100.,120.*PI180).Shape();
280   Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
281   aContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False); 
282   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);    
283   aContext->Display(ais2);
284   TopoDS_Shape S3 = BRepPrimAPI_MakeSphere(gp_Pnt(200.,250.,0.),100.,
285                                        -60.*PI180, 60.*PI180).Shape();
286   Handle(AIS_Shape) ais3 = new AIS_Shape(S3);
287   aContext->SetColor(ais3,Quantity_NOC_RED,Standard_False); 
288   aContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);    
289   aContext->Display(ais3);
290   TopoDS_Shape S4 = BRepPrimAPI_MakeSphere(gp_Pnt(0.,0.,-300.),150.,
291                                        -45.*PI180, 45.*PI180, 45.*PI180).Shape();
292   Handle(AIS_Shape) ais4 = new AIS_Shape(S4);
293   aContext->SetColor(ais4,Quantity_NOC_MATRABLUE,Standard_False); 
294   aContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);    
295   aContext->Display(ais4);
296
297   Message = "\
298                 \n\
299 TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(gp_Pnt(-200.,-250.,0.),80.); \n\
300 TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(100.,120.*PI180); \n\
301 TopoDS_Shape S3 = BRepPrimAPI_MakeSphere(gp_Pnt(200.,250.,0.),100., \n\
302                                      -60.*PI180, 60.*PI180); \n\
303 TopoDS_Shape S4 = BRepPrimAPI_MakeSphere(gp_Pnt(0.,0.,-300.),150., \n\
304                                      -45.*PI180, 45.*PI180, 45.*PI180); \n\
305                 \n";
306 }
307
308 //===============================================================
309 // Function name: MakeTorus
310 //===============================================================
311  void SamplesTopologyPackage::MakeTorus(const Handle(AIS_InteractiveContext)& aContext,
312                                         TCollection_AsciiString& Message) 
313 {
314   aContext->EraseAll(Standard_False);
315
316   TopoDS_Shape S1 = BRepPrimAPI_MakeTorus(60.,20.).Shape();
317   Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
318   aContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False); 
319   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);    
320   aContext->Display(ais1);
321   TopoDS_Shape S2 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(1.,1.,1.)),
322                                       50.,20.,210.*PI180).Shape();
323   Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
324   aContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False); 
325   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);    
326   aContext->Display(ais2);
327   TopoDS_Shape S3 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(-200.,-150.,-100),gp_Dir(0.,1.,0.)),
328                                       60.,20.,-45.*PI180,45.*PI180,90.*PI180).Shape();
329   Handle(AIS_Shape) ais3= new AIS_Shape(S3);
330   aContext->SetColor(ais3,Quantity_NOC_CORAL,Standard_False); 
331   aContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);    
332   aContext->Display(ais3);
333
334   Message = "\
335                 \n\
336 TopoDS_Shape S1 = BRepPrimAPI_MakeTorus(60.,20.); \n\
337 TopoDS_Shape S2 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(1.,1.,1.)), \n\
338                                     50.,20.,210.*PI180); \n\
339 TopoDS_Shape S3 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(-200.,-150.,-100),gp_Dir(0.,1.,0.)), \n\
340                                     60.,20.,-45.*PI180,45.*PI180,90.*PI180); \n\
341                 \n";
342 }
343
344 //===============================================================
345 // Function name: MakeWedge
346 //===============================================================
347  void SamplesTopologyPackage::MakeWedge(const Handle(AIS_InteractiveContext)& aContext,
348                                         TCollection_AsciiString& Message) 
349 {
350   aContext->EraseAll(Standard_False);
351
352   TopoDS_Shape S1 = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
353   Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
354   aContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False); 
355   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);    
356   aContext->Display(ais1);
357   TopoDS_Shape S2 = BRepPrimAPI_MakeWedge(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(0.,0.,1.)),
358                                       60.,50.,80.,25.,-10.,40.,70.).Shape();
359   Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
360   aContext->SetColor(ais2,Quantity_NOC_CORAL2,Standard_False); 
361   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);    
362   aContext->Display(ais2);
363   
364   Message = "\
365                 \n\
366 TopoDS_Shape S1 = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
367 TopoDS_Shape S2 = BRepPrimAPI_MakeWedge(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(0.,0.,1.)), \n\
368                                     60.,50.,80.,25.,-10.,40.,70.); \n\
369                 \n";
370 }
371
372 //===============================================================
373 // Function name: MakePrism
374 //===============================================================
375  void SamplesTopologyPackage::MakePrism(const Handle(AIS_InteractiveContext)& aContext,
376                                         TCollection_AsciiString& Message) 
377 {
378   aContext->EraseAll(Standard_False);
379   
380   TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.));
381   Handle(AIS_Shape) ais1 = new AIS_Shape(V1);
382   aContext->Display(ais1);
383   TopoDS_Shape S1 = BRepPrimAPI_MakePrism(V1,gp_Vec(0.,0.,100.));
384   Handle(AIS_Shape) ais2 = new AIS_Shape(S1);
385   aContext->Display(ais2);
386   
387   TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-150.,-150,0.), gp_Pnt(-50.,-50,0.));
388   Handle(AIS_Shape) ais3 = new AIS_Shape(E);
389   aContext->Display(ais3);
390   TopoDS_Shape S2 = BRepPrimAPI_MakePrism(E,gp_Vec(0.,0.,100.));
391   Handle(AIS_Shape) ais4 = new AIS_Shape(S2);
392   aContext->SetColor(ais4,Quantity_NOC_CORAL2,Standard_False); 
393   aContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);    
394   aContext->Display(ais4);
395   
396   TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)).Edge();
397   TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)).Edge();
398   TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)).Edge();
399   TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3).Wire();
400   TopoDS_Shape S3 = BRepPrimAPI_MakePrism(W,gp_Vec(0.,0.,100.)).Shape();
401   Handle(AIS_Shape) ais5 = new AIS_Shape(W);
402   aContext->Display(ais5);
403   Handle(AIS_Shape) ais6 = new AIS_Shape(S3);
404   aContext->SetColor(ais6,Quantity_NOC_GREEN,Standard_False); 
405   aContext->SetMaterial(ais6,Graphic3d_NOM_PLASTIC,Standard_False);    
406   aContext->Display(ais6);
407   
408   gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.);
409   TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c).Edge();
410   TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec).Wire();
411   TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc).Face();
412   Handle(AIS_Shape) ais7 = new AIS_Shape(F);
413   aContext->Display(ais7);
414   TopoDS_Shape S4 = BRepPrimAPI_MakePrism(F,gp_Vec(0.,0.,100.)).Shape();
415   Handle(AIS_Shape) ais8 = new AIS_Shape(S4);
416   aContext->SetColor(ais8,Quantity_NOC_MATRABLUE,Standard_False); 
417   aContext->SetMaterial(ais8,Graphic3d_NOM_PLASTIC,Standard_False);    
418   aContext->Display(ais8);
419   
420   Message = "\
421                 \n\
422 --- Prism a vertex -> result is an edge --- \n\
423 \n\
424 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.)); \n\
425 TopoDS_Shape S1 = BRepPrimAPI_MakePrism(V1,gp_Vec(0.,0.,100.)); \n\
426 \n\
427 --- Prism an edge -> result is a face --- \n\
428 \n\
429 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-150.,-150,0.), gp_Pnt(-50.,-50,0.)); \n\
430 TopoDS_Shape S2 = BRepPrimAPI_MakePrism(E,gp_Vec(0.,0.,100.)); \n\
431 \n\
432 --- Prism an wire -> result is a shell --- \n\
433 \n\
434 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)); \n\
435 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)); \n\
436 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)); \n\
437 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3); \n\
438 TopoDS_Shape S3 = BRepPrimAPI_MakePrism(W,gp_Vec(0.,0.,100.)); \n\
439 \n\
440 --- Prism a face or a shell -> result is a solid --- \n\
441 \n\
442 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.gp_Dir(0.,0.,1.)), 80.); \n\
443 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c); \n\
444 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec); \n\
445 TopoDS_Face F = BRepBuilderAPI_MakeFacePI_MakePrism(F,gp_Vec(0.,0.,100.)); \n\
446                 \n";
447 }
448
449 //===============================================================
450 // Function name: MakeRevol
451 //===============================================================
452  void SamplesTopologyPackage::MakeRevol(const Handle(AIS_InteractiveContext)& aContext,
453                                         TCollection_AsciiString& Message) 
454 {
455   aContext->EraseAll(Standard_False);
456
457   TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.)).Vertex();
458   Handle(AIS_Shape) ais1 = new AIS_Shape(V1);
459   aContext->Display(ais1);
460   gp_Ax1 axe = gp_Ax1(gp_Pnt(-170.,-170.,0.),gp_Dir(0.,0.,1.));
461   Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
462   Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
463   aContext->Display(ax1);
464   TopoDS_Shape S1 = BRepPrimAPI_MakeRevol(V1,axe).Shape();
465   Handle(AIS_Shape) ais2 = new AIS_Shape(S1);
466   aContext->Display(ais2);
467   
468   TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-120.,-120,0.), gp_Pnt(-120.,-120,100.)).Edge();
469   Handle(AIS_Shape) ais3 = new AIS_Shape(E);
470   aContext->Display(ais3);
471   axe = gp_Ax1(gp_Pnt(-100.,-100.,0.),gp_Dir(0.,0.,1.));
472   Handle(Geom_Axis1Placement) Gax2 = new Geom_Axis1Placement(axe);
473   Handle (AIS_Axis) ax2 = new AIS_Axis(Gax2);
474   aContext->Display(ax2);
475   TopoDS_Shape S2 = BRepPrimAPI_MakeRevol(E,axe).Shape();
476   Handle(AIS_Shape) ais4 = new AIS_Shape(S2);
477   aContext->SetColor(ais4,Quantity_NOC_YELLOW,Standard_False); 
478   aContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);    
479   aContext->Display(ais4);
480
481   TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)).Edge();
482   TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)).Edge();
483   TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)).Edge();
484   TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3).Wire();
485   axe = gp_Ax1(gp_Pnt(0.,0.,30.),gp_Dir(0.,1.,0.));
486   Handle(Geom_Axis1Placement) Gax3 = new Geom_Axis1Placement(axe);
487   Handle (AIS_Axis) ax3 = new AIS_Axis(Gax3);
488   aContext->Display(ax3);
489   TopoDS_Shape S3 = BRepPrimAPI_MakeRevol(W,axe, 210.*PI180).Shape();
490   Handle(AIS_Shape) ais5 = new AIS_Shape(W);
491   aContext->Display(ais5);
492   Handle(AIS_Shape) ais6 = new AIS_Shape(S3);
493   aContext->SetColor(ais6,Quantity_NOC_GREEN,Standard_False); 
494   aContext->SetMaterial(ais6,Graphic3d_NOM_PLASTIC,Standard_False);    
495   aContext->Display(ais6);
496   
497   gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.);
498   TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c).Edge();
499   TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec).Wire();
500   TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc).Face();
501   axe = gp_Ax1(gp_Pnt(290,290.,0.),gp_Dir(0.,1,0.));
502   Handle(Geom_Axis1Placement) Gax4 = new Geom_Axis1Placement(axe);
503   Handle (AIS_Axis) ax4 = new AIS_Axis(Gax4);
504   aContext->Display(ax4);
505   TopoDS_Shape S4 = BRepPrimAPI_MakeRevol(F,axe, 90.*PI180).Shape();
506   Handle(AIS_Shape) ais8 = new AIS_Shape(S4);
507   aContext->SetColor(ais8,Quantity_NOC_MATRABLUE,Standard_False); 
508   aContext->SetMaterial(ais8,Graphic3d_NOM_PLASTIC,Standard_False);    
509   aContext->Display(ais8);
510
511   Message = "\
512                 \n\
513 --- Revol of a vertex -> result is an edge --- \n\
514 \n\
515 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.)); \n\
516 gp_Ax1 axe = gp_Ax1(gp_Pnt(-170.,-170.,0.),gp_Dir(0.,0.,1.)); \n\
517 TopoDS_Shape S1 = BRepPrimAPI_MakeRevol(V1,axe); \n\
518 \n\
519 --- Revol of an edge -> result is a face --- \n\
520 \n\
521 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-120.,-120,0.), gp_Pnt(-120.,-120,100.)); \n\
522 axe = gp_Ax1(gp_Pnt(-100.,-100.,0.),gp_Dir(0.,0.,1.)); \n\
523 TopoDS_Shape S2 = BRepPrimAPI_MakeRevol(E,axe); \n\
524 \n\
525 --- Revol of a wire -> result is a shell --- \n\
526 \n\
527 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)); \n\
528 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)); \n\
529 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)); \n\
530 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3); \n\
531 axe = gp_Ax1(gp_Pnt(0.,0.,30.),gp_Dir(0.,1.,0.)); \n\
532 TopoDS_Shape S3 = BRepPrimAPI_MakeRevol(W,axe, 210.*PI180); \n\
533 \n\
534 --- Revol of a face -> result is a solid --- \n\
535 \n\
536 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.); \n\
537 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c); \n\
538 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec); \n\
539 TopoDS_Face F = BRepBuilderAPI_MakeFace0.,0.),gp_Dir(0.,1,0.)); \n\
540 TopoDS_Shape S4 = BRepPrimAPI_MakeRevol(F,axe, 90.*PI180); \n\
541                 \n";
542 }
543
544 //===============================================================
545 // Function name: MakePipe
546 //===============================================================
547  void SamplesTopologyPackage::MakePipe(const Handle(AIS_InteractiveContext)& aContext,
548                                        TCollection_AsciiString& Message) 
549 {
550   aContext->EraseAll(Standard_False);
551
552   TColgp_Array1OfPnt CurvePoles(1,4);
553   gp_Pnt pt = gp_Pnt(0.,0.,0.);
554   CurvePoles(1) = pt;
555   pt = gp_Pnt(20.,50.,0.);
556   CurvePoles(2) = pt;
557   pt = gp_Pnt(60.,100.,0.);
558   CurvePoles(3) = pt;
559   pt = gp_Pnt(150.,0.,0.);
560   CurvePoles(4) = pt;
561   Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);
562   TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve).Edge();
563   TopoDS_Wire W = BRepBuilderAPI_MakeWire(E).Wire();
564   Handle(AIS_Shape) ais1 = new AIS_Shape(W);
565   aContext->Display(ais1);
566   gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.);
567   TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c).Edge();
568   TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec).Wire();
569   Handle(AIS_Shape) ais3 = new AIS_Shape(Wc);
570   aContext->Display(ais3);
571   TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::ZOX()),Wc).Face();
572   TopoDS_Shape S = BRepOffsetAPI_MakePipe(W,F).Shape();
573   Handle(AIS_Shape) ais2 = new AIS_Shape(S);
574   aContext->SetColor(ais2,Quantity_NOC_MATRABLUE,Standard_False); 
575   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);   
576   aContext->Display(ais2);
577
578   Message = "\
579                 \n\
580 TColgp_Array1OfPnt CurvePoles(1,6);\n\
581 gp_Pnt pt = gp_Pnt(0.,0.,0.);\n\
582 CurvePoles(1) = pt;\n\
583 pt = gp_Pnt(20.,50.,0.);\n\
584 CurvePoles(2) = pt;\n\
585 pt = gp_Pnt(60.,100.,0.);\n\
586 CurvePoles(3) = pt;\n\
587 pt = gp_Pnt(150.,0.,0.);\n\
588 CurvePoles(4) = pt;\n\
589 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);\n\
590 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);\n\
591 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);\n\
592 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.);\n\
593 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);\n\
594 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);\n\
595 TopoDS_Face F = BRepBuilderAPI_MakeFaceAPI_MakePipe(W,F);\n\
596                 \n";
597 }
598
599 //===============================================================
600 // Function name: MakeThru
601 //===============================================================
602  void SamplesTopologyPackage::MakeThru(const Handle(AIS_InteractiveContext)& aContext,
603                                        TCollection_AsciiString& Message) 
604 {
605   aContext->EraseAll(Standard_False);
606
607   gp_Circ c1 = gp_Circ(gp_Ax2(gp_Pnt(-100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);
608   TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(c1).Edge();
609   TopoDS_Wire W1 = BRepBuilderAPI_MakeWire(E1).Wire();
610   Handle(AIS_Shape) sec1 = new AIS_Shape(W1);
611   aContext->Display(sec1,Standard_False);
612   gp_Circ c2 = gp_Circ(gp_Ax2(gp_Pnt(-10.,0.,-0.),gp_Dir(0.,0.,1.)),40.);
613   TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(c2);
614   TopoDS_Wire W2 = BRepBuilderAPI_MakeWire(E2);
615   Handle(AIS_Shape) sec2 = new AIS_Shape(W2);
616   aContext->Display(sec2,Standard_False);       
617   gp_Circ c3 = gp_Circ(gp_Ax2(gp_Pnt(-75.,0.,100.),gp_Dir(0.,0.,1.)),40.);
618   TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(c3);
619   TopoDS_Wire W3 = BRepBuilderAPI_MakeWire(E3);
620   Handle(AIS_Shape) sec3 = new AIS_Shape(W3);
621   aContext->Display(sec3,Standard_False);
622   gp_Circ c4= gp_Circ(gp_Ax2(gp_Pnt(0.,0.,200.),gp_Dir(0.,0.,1.)),40.);
623   TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);
624   TopoDS_Wire W4 = BRepBuilderAPI_MakeWire(E4);
625   Handle(AIS_Shape) sec4 = new AIS_Shape(W4);
626   aContext->Display(sec4);
627   BRepOffsetAPI_ThruSections generator(Standard_False,Standard_True);
628   generator.AddWire(W1);
629   generator.AddWire(W2);
630   generator.AddWire(W3);
631   generator.AddWire(W4);
632   generator.Build();
633   TopoDS_Shape S1 = generator.Shape();
634   Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
635   aContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False); 
636   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);   
637   aContext->Display(ais1);
638   
639   gp_Circ c1b = gp_Circ(gp_Ax2(gp_Pnt(100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);
640   TopoDS_Edge E1b = BRepBuilderAPI_MakeEdge(c1b).Edge();
641   TopoDS_Wire W1b = BRepBuilderAPI_MakeWire(E1b).Wire();
642   Handle(AIS_Shape) sec1b = new AIS_Shape(W1b);
643   aContext->Display(sec1b,Standard_False);
644   gp_Circ c2b = gp_Circ(gp_Ax2(gp_Pnt(210.,0.,-0.),gp_Dir(0.,0.,1.)),40.);
645   TopoDS_Edge E2b = BRepBuilderAPI_MakeEdge(c2b).Edge();
646   TopoDS_Wire W2b = BRepBuilderAPI_MakeWire(E2b).Wire();
647   Handle(AIS_Shape) sec2b = new AIS_Shape(W2b);
648   aContext->Display(sec2b,Standard_False);      
649   gp_Circ c3b = gp_Circ(gp_Ax2(gp_Pnt(275.,0.,100.),gp_Dir(0.,0.,1.)),40.);
650   TopoDS_Edge E3b = BRepBuilderAPI_MakeEdge(c3b).Edge();
651   TopoDS_Wire W3b = BRepBuilderAPI_MakeWire(E3b).Wire();
652   Handle(AIS_Shape) sec3b = new AIS_Shape(W3b);
653   aContext->Display(sec3b,Standard_False);
654   gp_Circ c4b= gp_Circ(gp_Ax2(gp_Pnt(200.,0.,200.),gp_Dir(0.,0.,1.)),40.);
655   TopoDS_Edge E4b = BRepBuilderAPI_MakeEdge(c4b).Edge();
656   TopoDS_Wire W4b = BRepBuilderAPI_MakeWire(E4b).Wire();
657   Handle(AIS_Shape) sec4b = new AIS_Shape(W4b);
658   aContext->Display(sec4b);
659   BRepOffsetAPI_ThruSections generatorb(Standard_True,Standard_False);
660   generatorb.AddWire(W1b);
661   generatorb.AddWire(W2b);
662   generatorb.AddWire(W3b);
663   generatorb.AddWire(W4b);
664   generatorb.Build();
665   TopoDS_Shape S2 = generatorb.Shape();
666   Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
667   aContext->SetColor(ais2,Quantity_NOC_ALICEBLUE,Standard_False); 
668   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);   
669   aContext->Display(ais2);
670   
671   Message = "\
672                 \n\
673 ---------- ruled -------------- \n\
674 \n\
675 gp_Circ c1 = gp_Circ(gp_Ax2(gp_Pnt(-100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);\n\
676 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(c1);\n\
677 TopoDS_Wire W1 = BRepBuilderAPI_MakeWire(E1);\n\
678 gp_Circ c2 = gp_Circ(gp_Ax2(gp_Pnt(-10.,0.,-0.),gp_Dir(0.,0.,1.)),40.);\n\
679 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(c2);\n\
680 TopoDS_Wire W2 = BRepBuilderAPI_MakeWire(E2);\n\
681 gp_Circ c3 = gp_Circ(gp_Ax2(gp_Pnt(-75.,0.,100.),gp_Dir(0.,0.,1.)),40.);\n\
682 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(c3);\n\
683 TopoDS_Wire W3 = BRepBuilderAPI_MakeWire(E3);\n\
684 gp_Circ c4= gp_Circ(gp_Ax2(gp_Pnt(0.,0.,200.),gp_Dir(0.,0.,1.)),40.);\n\
685 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);\n\
686 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);\n\
687 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);\n\
688 TopoDS_Wire W4 = BRepBuilderAPI_MakeWire(E4);\n\
689 BRepOffsetAPI_ThruSections generator(Standard_False,Standard_True);\n\
690 generator.AddWire(W1);\n\
691 generator.AddWire(W2);\n\
692 generator.AddWire(W3);\n\
693 generator.AddWire(W4);\n\
694 generator.Build();\n\
695 TopoDS_Shape S1 = generator.Shape();\n\
696 \n\
697 ---------- smooth -------------- \n\
698 \n\
699 gp_Circ c1b = gp_Circ(gp_Ax2(gp_Pnt(100.,0.,-100.),gp_Dir(0.,0.,1.)),40.); \n\
700 TopoDS_Edge E1b = BRepBuilderAPI_MakeEdge(c1b); \n\
701 TopoDS_Wire W1b = BRepBuilderAPI_MakeWire(E1b); \n\
702 gp_Circ c2b = gp_Circ(gp_Ax2(gp_Pnt(210.,0.,-0.),gp_Dir(0.,0.,1.)),40.); \n\
703 TopoDS_Edge E2b = BRepBuilderAPI_MakeEdge(c2b);\n\
704 TopoDS_Wire W2b = BRepBuilderAPI_MakeWire(E2b); \n\
705 gp_Circ c3b = gp_Circ(gp_Ax2(gp_Pnt(275.,0.,100.),gp_Dir(0.,0.,1.)),40.);\n\
706 TopoDS_Edge E3b = BRepBuilderAPI_MakeEdge(c3b);\n\
707 TopoDS_Wire W3b = BRepBuilderAPI_MakeWire(E3b);\n\
708 gp_Circ c4b= gp_Circ(gp_Ax2(gp_Pnt(200.,0.,200.),gp_Dir(0.,0.,1.)),40.);\n\
709 TopoDS_Edge E4b = BRepBuilderAPI_MakeEdge(c4b);\n\
710 TopoDS_Wire W4b = BRepBuilderAPI_MakeWire(E4b);\n\
711 BRepOffsetAPI_ThruSections generatorb(Standard_True,Standard_False);\n\
712 generatorb.AddWire(W1b);\n\
713 generatorb.AddWire(W2b);\n\
714 generatorb.AddWire(W3b);\n\
715 generatorb.AddWire(W4b);\n\
716 generatorb.Build();\n\
717 TopoDS_Shape S2 = generatorb.Shape();\n\
718                 \n";
719 }
720
721 //===============================================================
722 // Function name: MakeEvolved
723 //===============================================================
724  void SamplesTopologyPackage::MakeEvolved(const Handle(AIS_InteractiveContext)& aContext,
725                                           TCollection_AsciiString& Message) 
726 {
727   aContext->EraseAll(Standard_False);
728
729   BRepBuilderAPI_MakePolygon P;
730   P.Add(gp_Pnt(0.,0.,0.));
731   P.Add(gp_Pnt(200.,0.,0.));
732   P.Add(gp_Pnt(200.,200.,0.));
733   P.Add(gp_Pnt(0.,200.,0.));
734   P.Add(gp_Pnt(0.,0.,0.));
735   TopoDS_Wire W = P.Wire();
736   Handle(AIS_Shape) ais1 = new AIS_Shape(W);
737   aContext->Display(ais1);
738   TopoDS_Wire wprof = BRepBuilderAPI_MakePolygon(gp_Pnt(0.,0.,0.),gp_Pnt(-60.,-60.,-200.)).Wire();
739   Handle(AIS_Shape) ais3 = new AIS_Shape(wprof);
740   aContext->Display(ais3);
741   TopoDS_Shape S = BRepOffsetAPI_MakeEvolved(W,wprof,GeomAbs_Arc,Standard_True,Standard_False,Standard_True,0.0001);
742   Handle(AIS_Shape) ais2 = new AIS_Shape(S);
743   aContext->SetColor(ais2,Quantity_NOC_MATRABLUE,Standard_False); 
744   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);   
745   aContext->Display(ais2);
746   
747   Message = "\
748                 \n\
749 ---------- Evolved shape -------------- \n\
750 \n\
751 BRepBuilderAPI_MakePolygon P;\n\
752 P.Add(gp_Pnt(0.,0.,0.));\n\
753 P.Add(gp_Pnt(200.,0.,0.));\n\
754 P.Add(gp_Pnt(200.,200.,0.));\n\
755 P.Add(gp_Pnt(0.,200.,0.));\n\
756 P.Add(gp_Pnt(0.,0.,0.));\n\
757 TopoDS_Wire W = P.Wire();\n\
758 TopoDS_Wire wprof = BRepBuilderAPI_MakePolygon(gp_Pnt(0.,0.,0.),gp_Pnt(-60.,-60.,-200.));\n\
759 TopoDS_Shape S = BRepOffsetAPI_MakeEvolved(W,wprof,GeomAbs_Arc,Standard_True,Standard_False,Standard_True,0.0001);\n\
760                 \n";
761 }
762
763 //===============================================================
764 // Function name: MakeDraft
765 //===============================================================
766  void SamplesTopologyPackage::MakeDraft(const Handle(AIS_InteractiveContext)& aContext,
767                                         TCollection_AsciiString& Message) 
768 {
769   aContext->EraseAll(Standard_False);
770   
771   TopoDS_Shape S = BRepPrimAPI_MakeBox(200.,300.,150.).Shape();
772   Handle(AIS_Shape) ais1 = new AIS_Shape(S);
773   aContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); 
774   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);   
775   aContext->Display(ais1);
776   BRepOffsetAPI_DraftAngle adraft(S);
777   TopExp_Explorer Ex;
778   for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {
779     TopoDS_Face F = TopoDS::Face(Ex.Current());
780     Handle(Geom_Plane) surf = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F));
781     gp_Pln apln = surf->Pln();
782     gp_Dir dirF = apln.Axis().Direction();
783     if (dirF.IsNormal(gp_Dir(0.,0.,1.),Precision::Angular()))
784       adraft.Add(F, gp_Dir(0.,0.,1.), 15.*PI180, gp_Pln(gp::XOY()));
785   }
786   ais1->Set(adraft.Shape());
787   aContext->Redisplay(ais1);
788
789   Message = "\
790                 \n\
791 ---------- Tapered shape -------------- \n\
792 \n\
793 TopoDS_Shape S = BRepPrimAPI_MakeBox(200.,300.,150.);\n\
794 BRepOffsetAPI_DraftAngle adraft(S);\n\
795 TopExp_Explorer Ex;\n\
796 for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {\n\
797         TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
798         Handle(Geom_Plane) surf = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F));\n\
799         gp_Pln apln = surf->Pln();\n\
800         gp_Dir dirF = apln.Axis().Direction();\n\
801         if (dirF.IsNormal(gp_Dir(0.,0.,1.),Precision::Angular()))\n\
802                 adraft.Add(F, gp_Dir(0.,0.,1.), 15.*PI180, gp_Pln(gp::XOY()));\n\
803 }\n\
804                 \n";
805 }
806
807
808 //======================================================================
809 //=                                                                    =
810 //=                       Topological  Operations                      =
811 //=                                                                    =
812 //======================================================================
813
814 //===============================================================
815 // Function name: Cut
816 //===============================================================
817  void SamplesTopologyPackage::Cut(const Handle(AIS_InteractiveContext)& aContext,
818                                   TCollection_AsciiString& Message) 
819 {
820   aContext->EraseAll(Standard_False);
821
822   TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,60,60).Shape();
823   Handle (AIS_Shape) ais1 = new AIS_Shape(theBox);
824   aContext->SetDisplayMode(ais1,1);
825   aContext->SetColor(ais1,Quantity_NOC_GREEN);
826   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC);
827   aContext->Display(ais1);
828   
829   TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80).Shape();
830   Handle (AIS_Shape) ais2 = new AIS_Shape(theSphere);
831   aContext->SetDisplayMode(ais2,1);
832   aContext->SetColor(ais2,Quantity_NOC_YELLOW);
833   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC);
834   aContext->Display(ais2);
835   
836   TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox);
837   
838   OSD::MilliSecSleep(1000);
839   aContext->Erase(ais1,Standard_True,Standard_False);
840   aContext->Erase(ais2,Standard_True,Standard_False);
841   
842   Handle (AIS_Shape) aSection = new AIS_Shape(ShapeCut);
843   aContext->SetDisplayMode(aSection,1);
844   aContext->SetColor(aSection,Quantity_NOC_RED);
845   aContext->SetMaterial(aSection,Graphic3d_NOM_PLASTIC);
846   aContext->Display(aSection);
847   
848   Message = "\
849                 \n\
850 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,40,40); \n\
851  \n\
852 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80); \n\
853  \n\
854 TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox); \n\
855  \n";
856 }
857
858 //===============================================================
859 // Function name: Fuse
860 //===============================================================
861  void SamplesTopologyPackage::Fuse(const Handle(AIS_InteractiveContext)& aContext,
862                                    TCollection_AsciiString& Message) 
863 {
864   aContext->EraseAll(Standard_False);
865
866   gp_Pnt P(-5,5,-5);
867   TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(60,200,70).Shape();
868   Handle (AIS_Shape) ais1 = new AIS_Shape(theBox1);
869   aContext->SetColor(ais1,Quantity_NOC_GREEN);
870   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC);
871   aContext->Display(ais1);
872   
873   TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P,20,150,110).Shape();
874   Handle (AIS_Shape) ais2 = new AIS_Shape(theBox2);
875   aContext->SetColor(ais2,Quantity_NOC_YELLOW);
876   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC);
877   aContext->Display(ais2);
878   
879   TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1,theBox2);
880   
881   OSD::MilliSecSleep(1000);
882   aContext->Erase(ais1,Standard_True,Standard_False);
883   aContext->Erase(ais2,Standard_True,Standard_False);
884   
885   Handle (AIS_Shape) aFusion = new AIS_Shape(FusedShape);
886   aContext->SetDisplayMode(aFusion,1);
887   aContext->SetColor(aFusion,Quantity_NOC_RED);
888   aContext->SetMaterial(aFusion,Graphic3d_NOM_PLASTIC);
889   aContext->Display(aFusion);
890
891   Message = "\
892                 \n\
893 TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(50,200,70); \n\
894  \n\
895 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(-30,150,70); \n\
896  \n\
897 TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1,theBox2); \n";
898 }
899
900 //===============================================================
901 // Function name: Common
902 //===============================================================
903  void SamplesTopologyPackage::Common(const Handle(AIS_InteractiveContext)& aContext,
904                                      TCollection_AsciiString& Message) 
905 {
906   aContext->EraseAll(Standard_False);
907
908   gp_Ax2 axe(gp_Pnt(10,10,10),gp_Dir(1,2,1));
909   TopoDS_Shape theBox = BRepPrimAPI_MakeBox(axe,60,80,100).Shape();
910   
911   Handle(AIS_Shape) aboxshape=new AIS_Shape(theBox);
912   aContext->SetColor(aboxshape,Quantity_NOC_YELLOW);
913   aContext->SetMaterial(aboxshape,Graphic3d_NOM_PLASTIC,Standard_False);    
914   aContext->SetDisplayMode(aboxshape,1);
915   aContext->SetTransparency(aboxshape,0.7);
916   aContext->Display(aboxshape);
917   
918   TopoDS_Shape theWedge = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
919   
920   Handle(AIS_Shape) awedge = new AIS_Shape(theWedge);
921   aContext->SetColor(awedge,Quantity_NOC_RED,Standard_False);
922   aContext->SetMaterial(awedge,Graphic3d_NOM_PLASTIC,Standard_False);    
923   aContext->SetTransparency(awedge,0.5);
924   aContext->Display(awedge);
925   
926   TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(theBox,theWedge);
927
928   OSD::MilliSecSleep(1000);
929   aContext->Erase(aboxshape,Standard_True,Standard_False);
930   aContext->Erase(awedge,Standard_True,Standard_False);
931
932   Handle(AIS_Shape) acommon = new AIS_Shape(theCommonSurface);
933   aContext->SetColor(acommon,Quantity_NOC_GREEN,Standard_False); 
934   aContext->SetMaterial(acommon,Graphic3d_NOM_PLASTIC,Standard_False);    
935   aContext->Display(acommon);
936
937   Message = "\
938                 \n\
939 gp_Ax2 axe(gp_Pnt(10,10,10),gp_Dir(1,2,1)); \n\
940  \n\
941 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(axe,60,80,100); \n\
942  \n\
943 TopoDS_Shape theWedge = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
944  \n\
945 TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(theBox,theWedge); \n\
946  \n";
947 }
948
949 //===============================================================
950 // Function name: Section
951 //===============================================================
952  void SamplesTopologyPackage::Section(const Handle(AIS_InteractiveContext)& aContext,
953                                       TCollection_AsciiString& Message) 
954 {
955   aContext->EraseAll(Standard_False);
956
957   TopoDS_Shape atorus = BRepPrimAPI_MakeTorus(120,20).Shape();
958
959   Handle(AIS_Shape) ashape=new AIS_Shape(atorus);
960   aContext->SetColor(ashape,Quantity_NOC_RED);
961   aContext->SetMaterial(ashape,Graphic3d_NOM_PLASTIC,Standard_False);    
962   aContext->SetDisplayMode(ashape,1);
963   aContext->SetTransparency(ashape,0.1);
964   aContext->Display(ashape);
965   
966   //  gp_Vec V1(1,1,1);
967   Standard_Real radius = 120;
968   Standard_Integer i;
969
970   for (i=-3;i<=3;i++) {
971     TopoDS_Shape asphere = BRepPrimAPI_MakeSphere(gp_Pnt(26*3*i,0,0),radius).Shape();
972     
973     Handle (AIS_Shape) theShape=new AIS_Shape (asphere);
974     aContext->SetTransparency(theShape,0.1);
975     aContext->SetColor(theShape,Quantity_NOC_WHITE);
976     aContext->SetDisplayMode(theShape,1);
977     aContext->Display(theShape);
978
979     Standard_Boolean PerformNow=Standard_False; 
980
981     BRepAlgoAPI_Section section(atorus,asphere,PerformNow);
982     section.ComputePCurveOn1(Standard_True);
983     section.Approximation(TopOpeBRepTool_APPROX);
984     section.Build();
985
986     Handle(AIS_Shape) asection=new AIS_Shape(section.Shape());
987     aContext->SetDisplayMode(asection,0);
988     aContext->SetColor(asection,Quantity_NOC_WHITE);
989     aContext->Display(asection);
990     if(i<3) {
991       aContext->Erase(theShape,Standard_True,Standard_False);
992     }
993   }
994
995   Message = "\
996                 \n\
997 TopoDS_Shape atorus = BRepPrimAPI_MakeTorus(120,20); \n\
998 gp_Vec V1(1,1,1); \n\
999 Standard_Real radius = 120; \n\
1000 Standard_Integer i=-3; \n\
1001 for(i;i<=3;i++) { \n\
1002     TopoDS_Shape asphere = BRepPrimAPI_MakeSphere(gp_Pnt(78*i,0,0),radius); \n\
1003     Standard_Boolean PerformNow=Standard_False; \n\
1004     BRepAlgoAPI_Section section(atorus,asphere,PerformNow); \n\
1005     section.ComputePCurveOn1(Standard_True); \n\
1006     section.Approximation(TopOpeBRepTool_APPROX); \n\
1007     section.Build(); \n\
1008         \n";
1009 }
1010
1011 //===============================================================
1012 // Function name: PSection
1013 //===============================================================
1014  void SamplesTopologyPackage::PSection(const Handle(AIS_InteractiveContext)& aContext,
1015                                        TCollection_AsciiString& Message) 
1016 {
1017   aContext->EraseAll(Standard_False);
1018
1019   TopoDS_Shape theTorus = BRepPrimAPI_MakeTorus(35,8).Shape();
1020   Handle(AIS_Shape) atorus = new AIS_Shape(theTorus);
1021   aContext->SetColor(atorus,Quantity_NOC_YELLOW,Standard_False); 
1022   aContext->SetMaterial(atorus,Graphic3d_NOM_PLASTIC,Standard_False);
1023   aContext->SetTransparency(atorus,0.1);
1024   aContext->Display(atorus);
1025   
1026   gp_Pln aplane(1,0.25,3,4);
1027   Handle (Geom_Plane) thePlane = new Geom_Plane(aplane);
1028   Handle (AIS_Plane) ais1 = new AIS_Plane(thePlane);
1029   aContext->Display(ais1);
1030
1031   BRepAlgoAPI_Section section(theTorus,thePlane,Standard_False);
1032   section.ComputePCurveOn1(Standard_True);
1033   section.Approximation(TopOpeBRepTool_APPROX);
1034   section.Build();
1035   Handle(AIS_Shape) asection=new AIS_Shape(section.Shape());
1036   aContext->SetDisplayMode(asection , 0);
1037   aContext->SetColor(asection,Quantity_NOC_WHITE); 
1038   aContext->Display(asection);
1039   
1040   Message = "\
1041                 \n\
1042 TopoDS_Shape theTorus = BRepPrimAPI_MakeTorus(60.,20.); \n\
1043  \n\
1044 gp_Pln P(1,2,1,-15); \n\
1045  \n\
1046 TopoDS_Shape Psection = BRepAlgoAPI_Section(theTorus,P);  \n\
1047 \n";
1048 }
1049
1050 //===============================================================
1051 // Function name: Blend
1052 //===============================================================
1053  void SamplesTopologyPackage::Blend(const Handle(AIS_InteractiveContext)& aContext,
1054                                     TCollection_AsciiString& Message) 
1055 {
1056   aContext->EraseAll(Standard_False);
1057
1058   TopoDS_Shape Box = BRepPrimAPI_MakeBox(gp_Pnt(-400,0,0),200,230,180).Shape();
1059   Handle(AIS_Shape) ais1 = new AIS_Shape(Box);
1060   aContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False); 
1061   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); 
1062   aContext->Display(ais1);
1063   
1064   BRepFilletAPI_MakeFillet fillet(Box);
1065
1066   for (TopExp_Explorer ex(Box,TopAbs_EDGE); ex.More(); ex.Next()) {
1067     TopoDS_Edge Edge =TopoDS::Edge(ex.Current());
1068     fillet.Add(20,Edge);
1069   }
1070
1071   OSD::MilliSecSleep(1000);
1072   aContext->Erase(ais1,Standard_True,Standard_False);
1073
1074   TopoDS_Shape blendedBox = fillet.Shape();
1075   Handle(AIS_Shape) aBlendbox = new AIS_Shape(blendedBox);
1076   aContext->SetColor(aBlendbox,Quantity_NOC_YELLOW,Standard_False); 
1077   aContext->SetMaterial(aBlendbox,Graphic3d_NOM_PLASTIC,Standard_False); 
1078   aContext->Display(aBlendbox);
1079
1080
1081
1082   gp_Pnt P1(250,150,75);
1083   TopoDS_Shape S1 = BRepPrimAPI_MakeBox(300,200,200).Shape();
1084   TopoDS_Shape S2 = BRepPrimAPI_MakeBox(P1,120,180,70).Shape();
1085
1086   TopoDS_Shape fusedShape = BRepAlgoAPI_Fuse(S1,S2);
1087   Handle(AIS_Shape) ais2 = new AIS_Shape(fusedShape);
1088   aContext->SetColor(ais2,Quantity_NOC_RED,Standard_False); 
1089   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);  
1090   aContext->Display(ais2);
1091
1092   BRepFilletAPI_MakeFillet fill(fusedShape);
1093
1094   for (TopExp_Explorer ex1(fusedShape,TopAbs_EDGE); ex1.More(); ex1.Next()) {
1095     TopoDS_Edge E =TopoDS::Edge(ex1.Current());
1096     fill.Add(E);
1097   }
1098
1099   for (Standard_Integer i = 1;i<=fill.NbContours();i++) {
1100     Standard_Real longueur(fill.Length(i));
1101     Standard_Real Rad(0.15*longueur);
1102     for (Standard_Integer j = 1; j <=fill.NbEdges(i);j++)
1103       fill.SetRadius(Rad,i,j);
1104   }
1105
1106   TopoDS_Shape blendedFusedSolids = fill.Shape();
1107
1108   Handle(AIS_Shape) aBlend = new AIS_Shape(blendedFusedSolids);
1109   aContext->SetColor(aBlend,Quantity_NOC_RED,Standard_False); 
1110   aContext->SetMaterial(aBlend,Graphic3d_NOM_PLASTIC,Standard_False);  
1111   aContext->Display(aBlend);
1112
1113   aContext->Erase(ais2,Standard_True,Standard_False);
1114
1115
1116   Message = "\
1117                 \n\
1118 //THE YELLOW BOX\n\
1119 TopoDS_Shape Box = BRepPrimAPI_MakeBox(gp_Pnt(-400,0,0),200,230,180);\n\
1120 \n\
1121 BRepFilletAPI_MakeFillet fillet(Box);\n\
1122 \n\
1123 for (TopExp_Explorer ex(Box,TopAbs_EDGE); ex.More(); ex.Next()) {\n\
1124         TopoDS_Edge Edge =TopoDS::Edge(ex.Current());\n\
1125         fillet.Add(20,Edge);\n\
1126 }\n\
1127 TopoDS_Shape blendedBox = fillet.Shape();\n\
1128 \n\
1129 ////////////////////////////////////////////////////////////////////////\n\
1130 \n\
1131 //THE RED SOLID\n\
1132  \n\
1133 //Warning : On the acute angles of the boxes a fillet is created. \n\
1134 On the angles of fusion a blend is created. \n\
1135 \n\
1136 gp_Pnt P1(150,150,75);\n\
1137 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(300,200,200);\n\
1138 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(P1,100,200,70);\n\
1139 \n\
1140 TopoDS_Shape fusedShape = BRepAlgoAPI_Fuse(S1,S2);\n\
1141 BRepFilletAPI_MakeFillet fill(fusedShape);\n\
1142 \n\
1143 for (TopExp_Explorer ex1(fusedShape,TopAbs_EDGE); ex1.More(); ex1.Next()) {\n\
1144         TopoDS_Edge E =TopoDS::Edge(ex1.Current());\n\
1145         fill.Add(E);\n\
1146 }\n\
1147 \n\
1148 for (Standard_Integer i = 1;i<=fill.NbContours();i++) {\n\
1149         Standard_Real longueur(fill.Length(i));\n\
1150         Standard_Real Rad(0.2*longueur);\n\
1151         fill.SetRadius(Rad,i);\n\
1152 }\n\
1153 \n\
1154 TopoDS_Shape blendedFusedSolids = fill.Shape(); \n";
1155 }
1156
1157 //===============================================================
1158 // Function name: EvolvedBlend
1159 //===============================================================
1160  void SamplesTopologyPackage::EvolvedBlend(const Handle(AIS_InteractiveContext)& aContext,
1161                                            TCollection_AsciiString& Message) 
1162 {
1163   aContext->EraseAll(Standard_False);
1164
1165   TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,200,200).Shape();
1166   Handle(AIS_Shape) ais1 = new AIS_Shape(theBox);
1167   aContext->SetColor(ais1,Quantity_NOC_BROWN,Standard_False); 
1168   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False); 
1169   aContext->Display(ais1);
1170   
1171   BRepFilletAPI_MakeFillet Rake(theBox);
1172   
1173   TopExp_Explorer ex(theBox,TopAbs_EDGE);
1174   ex.Next();
1175   ex.Next();
1176   ex.Next();
1177   ex.Next();
1178   Rake.Add(8,50,TopoDS::Edge(ex.Current()));
1179   Rake.Build();
1180   if (Rake.IsDone() ){
1181     TopoDS_Shape evolvedBox = Rake.Shape();
1182     ais1->Set(evolvedBox);
1183     aContext->Redisplay(ais1);
1184   }
1185   
1186   OSD::MilliSecSleep(1000);
1187
1188 /////////////////////////////////////////////////////////////////////
1189
1190
1191   
1192   TopoDS_Shape theCylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(0,0,1)),100,200).Shape();
1193   Handle(AIS_Shape) ais3 = new AIS_Shape(theCylinder);
1194   aContext->SetColor(ais3,Quantity_NOC_GREEN,Standard_False); 
1195   aContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);    
1196   aContext->Display(ais3);
1197   
1198   BRepFilletAPI_MakeFillet fillet(theCylinder);
1199   
1200   TColgp_Array1OfPnt2d TabPoint2(1,20);
1201   
1202   for (Standard_Integer i=0; i<=19; i++) {
1203     gp_Pnt2d Point2d(i*2*PI/19,60*cos(i*PI/19-PI/2)+10);
1204     TabPoint2.SetValue(i+1,Point2d);
1205   }
1206   
1207   TopExp_Explorer exp2(theCylinder,TopAbs_EDGE);
1208   fillet.Add(TabPoint2,TopoDS::Edge(exp2.Current()));
1209   fillet.Build();
1210   if (fillet.IsDone() ){
1211     TopoDS_Shape LawEvolvedCylinder = fillet.Shape();
1212     ais3->Set(LawEvolvedCylinder);
1213     aContext->Redisplay(ais3);
1214   }
1215   
1216   gp_Pnt P(350,0,0);
1217   TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P,200,200,200).Shape();
1218   Handle(AIS_Shape) ais2 = new AIS_Shape(theBox2);
1219   aContext->SetColor(ais2,Quantity_NOC_RED,Standard_False); 
1220   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);    
1221   aContext->Display(ais2);
1222   
1223   
1224   BRepFilletAPI_MakeFillet afillet(theBox2);
1225   
1226   TColgp_Array1OfPnt2d TabPoint(1,6);
1227   
1228   gp_Pnt2d P1(0.,8.);
1229   gp_Pnt2d P2(0.2,16.);
1230   gp_Pnt2d P3(0.4,25.);
1231   gp_Pnt2d P4(0.6,55.);
1232   gp_Pnt2d P5(0.8,28.);
1233   gp_Pnt2d P6(1.,20.);
1234   TabPoint.SetValue(1,P1);
1235   TabPoint.SetValue(2,P2);
1236   TabPoint.SetValue(3,P3);
1237   TabPoint.SetValue(4,P4);
1238   TabPoint.SetValue(5,P5);
1239   TabPoint.SetValue(6,P6);
1240   
1241   TopExp_Explorer exp(theBox2,TopAbs_EDGE);
1242   exp.Next();
1243   exp.Next();
1244   exp.Next();
1245   exp.Next();
1246   
1247   afillet.Add(TabPoint, TopoDS::Edge(exp.Current()));
1248   
1249   afillet.Build();
1250   if (afillet.IsDone() ){
1251     TopoDS_Shape LawevolvedBox = afillet.Shape();
1252     ais2->Set(LawevolvedBox);
1253     aContext->Redisplay(ais2);
1254   }
1255
1256
1257   Message = "\
1258                 \n\
1259 //THE BROWN BOX \n\
1260 \n\
1261 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,200,200); \n\
1262         \n\
1263 BRepFilletAPI_MakeFillet Rake(theBox);  \n\
1264 ChFi3d_FilletShape FSh = ChFi3d_Rational;       \n\
1265 Rake.SetFilletShape(FSh);       \n\
1266         \n\
1267 TopExp_Explorer ex(theBox,TopAbs_EDGE); \n\
1268 ex.Next();   //in order to recover the front edge       \n\
1269 ex.Next();      \n\
1270 ex.Next();      \n\
1271 ex.Next();      \n\
1272 Rake.Add(8,50,TopoDS::Edge(ex.Current()));      \n\
1273         \n\
1274 Rake.Build();  \n\
1275 if (Rake.IsDone() )  \n\
1276         TopoDS_Shape theBrownBox = Rake.Shape();        \n\
1277         \n\
1278 //////////////////////////////////////////////////////////      \n\
1279         \n\
1280 //THE GREEN CYLINDER    \n\
1281         \n\
1282 TopoDS_Shape theCylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(0,0,1)),100,200);    \n\
1283         \n\
1284 BRepFilletAPI_MakeFillet fillet(theCylinder);   \n\
1285         \n\
1286 TColgp_Array1OfPnt2d TabPoint2(1,20);   \n\
1287         \n\
1288 for (Standard_Integer i=0; i<=19; i++) {        \n\
1289         gp_Pnt2d Point2d(i*2*PI/19,60*cos(i*PI/19-PI/2)+10);    \n\
1290         TabPoint2.SetValue(i+1,Point2d);        \n\
1291 }       \n\
1292         \n\
1293 TopExp_Explorer exp2(theCylinder,TopAbs_EDGE);  \n\
1294 fillet.Add(TabPoint2,TopoDS::Edge(exp2.Current()));     \n\
1295         \n\
1296 fillet.Build();  \n\
1297 if (fillet.IsDone() )  \n\
1298         TopoDS_Shape LawEvolvedCylinder = fillet.Shape();       \n\
1299         \n\
1300 ////////////////////////////////////////////////////////////    \n\
1301         \n\
1302         //THE RED BOX \n\
1303  \n\
1304 gp_Pnt P(350,0,0);      \n\
1305 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P,200,200,200);      \n\
1306         \n\
1307 BRepFilletAPI_MakeFillet fill(theBox2); \n\
1308         \n\
1309 TColgp_Array1OfPnt2d TabPoint(1,6);     \n\
1310 gp_Pnt2d P1(0,8);       \n\
1311 gp_Pnt2d P2(0.2,16);    \n\
1312 gp_Pnt2d P3(0.4,25);    \n\
1313 gp_Pnt2d P4(0.6,55);    \n\
1314 gp_Pnt2d P5(0.8,28);    \n\
1315 gp_Pnt2d P6(1,20);      \n\
1316 TabPoint.SetValue(1,P1);        \n\
1317 TabPoint.SetValue(2,P2);        \n\
1318 TabPoint.SetValue(3,P3);        \n\
1319 TabPoint.SetValue(4,P4);        \n\
1320 TabPoint.SetValue(5,P5);        \n\
1321 TabPoint.SetValue(6,P6);        \n\
1322         \n\
1323 TopExp_Explorer exp(theBox2,TopAbs_EDGE);       \n\
1324 exp.Next();  //in order to trcover the front edge       \n\
1325 exp.Next();     \n\
1326 exp.Next();     \n\
1327 exp.Next();     \n\
1328 fill.Add(TabPoint,TopoDS::Edge(exp.Current())); \n\
1329         \n\
1330 fill.Build();   \n\
1331 if (fillet.IsDone() )  \n\
1332         TopoDS_Shape theRedBox = fill.Shape();  \n\
1333 \n";
1334 }
1335
1336 //===============================================================
1337 // Function name: Chamfer
1338 //===============================================================
1339  void SamplesTopologyPackage::Chamfer(const Handle(AIS_InteractiveContext)& aContext,
1340                                       TCollection_AsciiString& Message) 
1341 {
1342   aContext->EraseAll(Standard_False);
1343
1344   TopoDS_Shape theBox = BRepPrimAPI_MakeBox(60,200,70).Shape();
1345   Handle(AIS_Shape) ais1 = new AIS_Shape(theBox);
1346   aContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False); 
1347   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);    
1348   aContext->Display(ais1);
1349
1350   BRepFilletAPI_MakeChamfer MC(theBox);
1351   // add all the edges to chamfer
1352   TopTools_IndexedDataMapOfShapeListOfShape M;
1353   TopExp::MapShapesAndAncestors(theBox,TopAbs_EDGE,TopAbs_FACE,M);
1354   for (Standard_Integer i = 1;i<=M.Extent();i++) {
1355     TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
1356     TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
1357     MC.Add(5,5,E,F);
1358   }
1359
1360   TopoDS_Shape ChanfrenedBox = MC.Shape();
1361   Handle(AIS_Shape) aBlendedBox = new AIS_Shape(ChanfrenedBox);
1362   aContext->SetColor(aBlendedBox,Quantity_NOC_YELLOW,Standard_False); 
1363   aContext->SetMaterial(aBlendedBox,Graphic3d_NOM_PLASTIC,Standard_False);    
1364   aContext->Display(aBlendedBox);
1365   
1366   OSD::MilliSecSleep(1000);
1367   aContext->Erase(ais1,Standard_True,Standard_False);
1368   
1369   Message = "\
1370                 \n\
1371 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(130,200,170); \n\
1372 BRepFilletAPI_MakeChamfer MC(theBox); \n\
1373 TopTools_IndexedDataMapOfShapeListOfShape M; \n\
1374 TopExp::MapShapesAndAncestors(theBox,TopAbs_EDGE,TopAbs_FACE,M); \n\
1375 for (Standard_Integer i;i<M.Extent();i++) { \n\
1376         TopoDS_Edge E = TopoDS::Edge(M.FindKey(i)); \n\
1377         TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First()); \n\
1378         MC.Add(15,15,E,F); \n\
1379         } \n\
1380 TopoDS_Shape ChanfrenedBox = MC.Shape();  \n";
1381 }
1382
1383
1384 //======================================================================
1385 //=                                                                    =
1386 //=                      Topology  Building                            =
1387 //=                                                                    =
1388 //======================================================================
1389
1390 //===============================================================
1391 // Function name: Vertex
1392 //===============================================================
1393  void SamplesTopologyPackage::Vertex(const Handle(AIS_InteractiveContext)& aContext,
1394                                      TCollection_AsciiString& Message) 
1395 {
1396   aContext->EraseAll(Standard_False);
1397
1398   TopoDS_Vertex V1,V2,V3;
1399   
1400   V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0)).Vertex();
1401   V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,25)).Vertex();
1402         
1403   gp_Pnt P(-12,8,-4);
1404   BRepBuilderAPI_MakeVertex MV(P);
1405   V3 = MV.Vertex();
1406   
1407   Handle(AIS_Shape) Point1 = new AIS_Shape(V1);
1408   aContext->Display(Point1);
1409   Handle(AIS_Shape) Point2 = new AIS_Shape(V2);
1410   aContext->Display(Point2);
1411   Handle(AIS_Shape) Point3 = new AIS_Shape(V3);
1412   aContext->Display(Point3);
1413   
1414   
1415   Message = "\
1416                 \n\
1417 TopoDS_Vertex V1,V2,V3; \n\
1418                 \n\
1419 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));  \n\
1420         \n\
1421 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,25));        \n\
1422                 \n\
1423 gp_Pnt P(-12,8,-4);     \n\
1424 BRepBuilderAPI_MakeVertex MV(P);        \n\
1425 V3 = MV.Vertex();       \n\
1426         \n\
1427 \n";
1428 }
1429
1430 //===============================================================
1431 // Function name: Edge
1432 //===============================================================
1433  void SamplesTopologyPackage::Edge(const Handle(AIS_InteractiveContext)& aContext,
1434                                    TCollection_AsciiString& Message) 
1435 {
1436   aContext->EraseAll(Standard_False);
1437
1438   TopoDS_Edge BlueEdge,YellowEdge,WhiteEdge,RedEdge,GreenEdge;
1439   TopoDS_Vertex V1,V2,V3,V4;
1440         
1441 /////////////The blue edge
1442
1443   BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80,-50,-20),gp_Pnt(-30,-60,-60)).Edge();
1444
1445 /////////////The yellow edge
1446         
1447   V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30)).Vertex();
1448   V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,-25)).Vertex();
1449   YellowEdge = BRepBuilderAPI_MakeEdge(V1,V2).Edge();
1450
1451 /////////////The white edge
1452         
1453   gp_Ax1 aLocalAx1(gp_Pnt(10,10,10),gp_Dir(1,0,0));
1454   gp_Lin line(aLocalAx1);
1455   //  gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));
1456   WhiteEdge = BRepBuilderAPI_MakeEdge(line,-20,10).Edge();
1457
1458 //////////////The red edge
1459
1460   gp_Ax2 aLocalAx2(gp_Pnt(10,0,0),gp_Dir(1,1,1));
1461   gp_Elips Elips(aLocalAx2,60,30);
1462   //  gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),60,30);
1463   RedEdge = BRepBuilderAPI_MakeEdge(Elips,0,PI/2).Edge();
1464
1465 /////////////The green edge and the both extreme vertex
1466
1467   gp_Pnt P1(-15,200,10);
1468   gp_Pnt P2(5,204,0);
1469   gp_Pnt P3(15,200,0);
1470   gp_Pnt P4(-15,20,15);
1471   gp_Pnt P5(-5,20,0);
1472   gp_Pnt P6(15,20,0);
1473   gp_Pnt P7(24,120,0);
1474   gp_Pnt P8(-24,120,12.5);
1475   TColgp_Array1OfPnt array(1,8);
1476   array.SetValue(1,P1);
1477   array.SetValue(2,P2);
1478   array.SetValue(3,P3); 
1479   array.SetValue(4,P4); 
1480   array.SetValue(5,P5); 
1481   array.SetValue(6,P6); 
1482   array.SetValue(7,P7); 
1483   array.SetValue(8,P8); 
1484   Handle (Geom_BezierCurve) curve = new Geom_BezierCurve(array);
1485         
1486   BRepBuilderAPI_MakeEdge ME (curve);
1487   GreenEdge = ME;
1488   V3 = ME.Vertex1();
1489   V4 = ME.Vertex2();
1490
1491 //////////////Display
1492   Handle(AIS_Shape) blue = new AIS_Shape(BlueEdge);
1493   aContext->SetColor(blue,Quantity_NOC_MATRABLUE,Standard_False); 
1494   aContext->Display(blue);
1495   
1496   Handle(AIS_Shape) yellow = new AIS_Shape(YellowEdge);
1497   aContext->SetColor(yellow,Quantity_NOC_YELLOW,Standard_False); 
1498   aContext->Display(yellow);
1499   
1500   Handle(AIS_Shape) white = new AIS_Shape(WhiteEdge);
1501   aContext->SetColor(white,Quantity_NOC_WHITE,Standard_False); 
1502   aContext->Display(white);
1503   
1504   Handle(AIS_Shape) red = new AIS_Shape(RedEdge);
1505   aContext->SetColor(red,Quantity_NOC_RED,Standard_False); 
1506   aContext->Display(red);
1507   
1508   Handle(AIS_Shape) green = new AIS_Shape(GreenEdge);
1509   aContext->SetColor(green,Quantity_NOC_GREEN,Standard_False); 
1510   aContext->Display(green);
1511
1512   Handle(AIS_Shape) Point1 = new AIS_Shape(V3);
1513   aContext->Display(Point1);
1514   Handle(AIS_Shape) Point2 = new AIS_Shape(V4);
1515   aContext->Display(Point2);
1516
1517
1518   Message = "\
1519                 \n\
1520 TopoDS_Edge BlueEdge, YellowEdge, WhiteEdge, RedEdge, GreenEdge;        \n\
1521 TopoDS_Vertex V1,V2,V3,V4;      \n\
1522                 \n\
1523 /////////////The blue edge      \n\
1524         \n\
1525 BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80,-50,-20),gp_Pnt(-30,-60,-60));    \n\
1526         \n\
1527 /////////////The yellow edge    \n\
1528                 \n\
1529 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));     \n\
1530 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,-25));       \n\
1531 YellowEdge = BRepBuilderAPI_MakeEdge(V1,V2);    \n\
1532         \n\
1533 /////////////The white edge     \n\
1534                 \n\
1535 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));    \n\
1536 WhiteEdge = BRepBuilderAPI_MakeEdge(line,-20,10);       \n\
1537         \n\
1538 //////////////The red edge      \n\
1539         \n\
1540 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),60,30);     \n\
1541 RedEdge = BRepBuilderAPI_MakeEdge(Elips,0,PI/2);        \n\
1542         \n\
1543 /////////////The green edge and the both extreme vertex \n\
1544         \n\
1545 gp_Pnt P1(-15,200,10);  \n\
1546 gp_Pnt P2(5,204,0);     \n\
1547 gp_Pnt P3(15,200,0);    \n\
1548 gp_Pnt P4(-15,20,15);   \n\
1549 gp_Pnt P5(-5,20,0);     \n\
1550 gp_Pnt P6(15,20,0);     \n\
1551 gp_Pnt P7(24,120,0);    \n\
1552 gp_Pnt P8(-24,120,12.5);        \n\
1553 TColgp_Array1OfPnt array(1,8);  \n\
1554 array.SetValue(1,P1);   \n\
1555 array.SetValue(2,P2);   \n\
1556 array.SetValue(3,P3);   \n\
1557 array.SetValue(4,P4);   \n\
1558 array.SetValue(5,P5);   \n\
1559 array.SetValue(6,P6);   \n\
1560 array.SetValue(7,P7);   \n\
1561 array.SetValue(8,P8);   \n\
1562 Handle (Geom_BezierCurve) curve = new Geom_BezierCurve(array);  \n\
1563         \n\
1564 BRepBuilderAPI_MakeEdge ME (curve);     \n\
1565 GreenEdge = ME; \n\
1566 V3 = ME.Vertex1();      \n\
1567 V4 = ME.Vertex2();      \n\
1568         \n\
1569 \n";
1570 }
1571
1572 //===============================================================
1573 // Function name: Wire
1574 //===============================================================
1575  void SamplesTopologyPackage::Wire(const Handle(AIS_InteractiveContext)& aContext,
1576                                    TCollection_AsciiString& Message) 
1577 {
1578   aContext->EraseAll(Standard_False);
1579
1580   TopoDS_Wire RedWire,YellowWire,WhiteWire,
1581   ExistingWire, ExistingWire2;
1582
1583   TopoDS_Edge Edge1,Edge2,Edge3,Edge4,Edge5,Edge6,Edge7,LastEdge;
1584   TopoDS_Vertex LastVertex;
1585
1586 ////////////The red wire is build from a single edge
1587
1588   gp_Ax2   alocalAx2(gp_Pnt(250,0,0),gp_Dir(1,1,1));
1589   gp_Elips Elips(alocalAx2,160,90);
1590     //  gp_Elips Elips(gp_Ax2(gp_Pnt(250,0,0),gp_Dir(1,1,1)),160,90);
1591   Edge1 = BRepBuilderAPI_MakeEdge(Elips,0,PI/2).Edge();
1592
1593   RedWire = BRepBuilderAPI_MakeWire(Edge1);
1594
1595 ///////////the yellow wire is build from an existing wire and an edge
1596         
1597   alocalAx2 = gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(1,0,0));
1598   gp_Circ circle(alocalAx2,80);
1599   //  gp_Circ circle(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(1,0,0)),80);
1600   Edge2 = BRepBuilderAPI_MakeEdge(circle,0,PI).Edge();
1601
1602   ExistingWire = BRepBuilderAPI_MakeWire(Edge2);
1603
1604   Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(-300,0,-80),gp_Pnt(-90,20,-30)).Edge();
1605
1606   BRepBuilderAPI_MakeWire MW1(ExistingWire,Edge3);
1607   if (MW1.IsDone()) {
1608     YellowWire = MW1;
1609   }
1610
1611
1612 //////////the white wire is built with an existing wire and 3 edges.
1613 //////////we use the methods Add, Edge and Vertex from BRepBuilderAPI_MakeWire.
1614   
1615   gp_Ax2 aLocalAx2(gp_Pnt(0,0,0),gp_Dir(0,1,0));
1616   gp_Circ circle2(aLocalAx2,200);
1617   //  gp_Circ circle2(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)),200);
1618   Edge4 = BRepBuilderAPI_MakeEdge(circle2,0,PI);
1619
1620   ExistingWire2 = BRepBuilderAPI_MakeWire(Edge4);
1621
1622   gp_Pnt P1(0,0,-200);
1623   gp_Pnt P2(5,204,0);
1624   Edge5 = BRepBuilderAPI_MakeEdge(P1,P2);
1625
1626   gp_Pnt P3(-15,20,15);
1627   Edge6 = BRepBuilderAPI_MakeEdge(P2,P3);
1628   gp_Pnt P4(15,20,0);   
1629   Edge7 = BRepBuilderAPI_MakeEdge(P3,P4);
1630
1631   BRepBuilderAPI_MakeWire MW;
1632   MW.Add(ExistingWire2);
1633   MW.Add(Edge5);
1634   MW.Add(Edge6);
1635   MW.Add(Edge7);
1636
1637   if (MW.IsDone()) {
1638     WhiteWire = MW.Wire();
1639     LastEdge = MW.Edge();
1640     LastVertex = MW.Vertex();
1641   }
1642
1643
1644   Handle(AIS_Shape) red = new AIS_Shape(RedWire);
1645   aContext->SetColor(red,Quantity_NOC_RED); 
1646   aContext->Display(red);
1647
1648   Handle(AIS_Shape) yellow = new AIS_Shape(YellowWire);
1649   aContext->SetColor(yellow,Quantity_NOC_YELLOW); 
1650   aContext->Display(yellow);
1651
1652   Handle(AIS_Shape) white = new AIS_Shape(WhiteWire);
1653   aContext->SetColor(white,Quantity_NOC_WHITE); 
1654   aContext->Display(white);
1655
1656   Handle(AIS_Shape) lastE = new AIS_Shape(LastEdge);
1657   aContext->SetWidth(lastE,3);
1658   aContext->SetColor(lastE,Quantity_NOC_RED); 
1659   aContext->Display(lastE);
1660
1661   Handle(AIS_Shape) lastV = new AIS_Shape(LastVertex);
1662   aContext->Display(lastV);
1663
1664
1665   Message = "\
1666         \n\
1667 TopoDS_Wire RedWire,YellowWire,WhiteWire,       \n\
1668 ExistingWire, ExistingWire2;    \n\
1669         \n\
1670 TopoDS_Edge Edge1,Edge2,Edge3,Edge4,Edge5,Edge6,Edge7,LastEdge; \n\
1671 TopoDS_Vertex LastVertex;       \n\
1672         \n\
1673 ////////////The red wire is build from a single edge    \n\
1674         \n\
1675 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),160,90);    \n\
1676 Edge1 = BRepBuilderAPI_MakeEdge(Elips,0,PI/2);  \n\
1677         \n\
1678 RedWire = BRepBuilderAPI_MakeWire(Edge1);       \n\
1679         \n\
1680 ///////////the yellow wire is build from an existing wire and an edge   \n\
1681                 \n\
1682 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80); \n\
1683 Edge2 = BRepBuilderAPI_MakeEdge(circle,0,PI);   \n\
1684         \n\
1685 ExistingWire = BRepBuilderAPI_MakeWire(Edge2);  \n\
1686         \n\
1687 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(90,20,30));      \n\
1688         \n\
1689 BRepBuilderAPI_MakeWire MW1(ExistingWire,Edge3);        \n\
1690 if (MW1.IsDone()) {     \n\
1691                 YellowWire = MW1;       \n\
1692 }       \n\
1693         \n\
1694 ///the white wire is built with an existing wire and 3 edges.   \n\
1695 ///we use the methods Add, Edge and Vertex from BRepBuilderAPI_MakeWire         \n\
1696 ///in order to display the last edge and the last vertices we   \n\
1697 ///add to the wire.     \n\
1698         \n\
1699 gp_Circ circle2(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)),200);       \n\
1700 Edge4 = BRepBuilderAPI_MakeEdge(circle2,0,PI);  \n\
1701         \n\
1702 ExistingWire2 = BRepBuilderAPI_MakeWire(Edge4); \n\
1703         \n\
1704 gp_Pnt P1(0,0,-200);    \n\
1705 gp_Pnt P2(5,204,0);     \n\
1706 Edge5 = BRepBuilderAPI_MakeEdge(P1,P2); \n\
1707         \n\
1708 gp_Pnt P3(-15,20,15);   \n\
1709 Edge6 = BRepBuilderAPI_MakeEdge(P2,P3); \n\
1710 gp_Pnt P4(15,20,0);             \n\
1711 Edge7 = BRepBuilderAPI_MakeEdge(P3,P4); \n\
1712         \n\
1713 BRepBuilderAPI_MakeWire MW;     \n\
1714 MW.Add(ExistingWire2);  \n\
1715 MW.Add(Edge5);  \n\
1716 MW.Add(Edge6);  \n\
1717 MW.Add(Edge7);  \n\
1718         \n\
1719 if (MW.IsDone()) {      \n\
1720         WhiteWire = MW.Wire();  \n\
1721         LastEdge = MW.Edge();   \n\
1722         LastVertex = MW.Vertex();       \n\
1723 }       \n\
1724         \n\
1725 \n";
1726 }
1727
1728 //===============================================================
1729 // Function name: Face
1730 //===============================================================
1731  void SamplesTopologyPackage::Face(const Handle(AIS_InteractiveContext)& aContext,
1732                                    TCollection_AsciiString& Message) 
1733 {
1734   aContext->EraseAll(Standard_False);
1735
1736   TopoDS_Face WhiteFace, BrownFace, RedFace, PinkFace;
1737   TopoDS_Edge Edge1, Edge2, Edge3, Edge4, Edge5, Edge6, Edge7;
1738   TopoDS_Wire Wire1;
1739   gp_Pnt P1, P2, P3, P4, P5, P6;
1740
1741
1742
1743   gp_Ax3 aLocalAx3(gp_Pnt(0,0,0),gp_Dir(1,0,0));
1744   gp_Sphere sphere (aLocalAx3,150);
1745   //  gp_Sphere sphere (gp_Ax3(gp_Pnt(0,0,0),gp_Dir(1,0,0)),150);
1746
1747   WhiteFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9).Face();
1748
1749 //////////////////////////////////
1750
1751   P1.SetCoord(-15,200,10);
1752   P2.SetCoord(5,204,0);
1753   P3.SetCoord(15,200,0);
1754   P4.SetCoord(-15,20,15);
1755   P5.SetCoord(-5,20,0);
1756   P6.SetCoord(15,20,35);
1757   TColgp_Array2OfPnt array(1,3,1,2);
1758   array.SetValue(1,1,P1);
1759   array.SetValue(2,1,P2);
1760   array.SetValue(3,1,P3); 
1761   array.SetValue(1,2,P4); 
1762   array.SetValue(2,2,P5); 
1763   array.SetValue(3,2,P6);
1764   Handle (Geom_BSplineSurface) curve = GeomAPI_PointsToBSplineSurface(array,3,8,GeomAbs_C2,0.001);
1765
1766   RedFace = BRepBuilderAPI_MakeFace(curve);
1767
1768 ////////////////////
1769
1770   gp_Ax2 aLocalAx2(gp_Pnt(0,0,0),gp_Dir(1,0,0));
1771   gp_Circ circle(aLocalAx2,80);
1772   //  gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80);
1773   Edge1 = BRepBuilderAPI_MakeEdge(circle,0,PI).Edge();
1774
1775   Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(0,-10,40));
1776   Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,-10,40),gp_Pnt(0,0,80));
1777
1778   TopoDS_Wire YellowWire;
1779   BRepBuilderAPI_MakeWire MW1(Edge1,Edge2,Edge3);
1780   if (MW1.IsDone()) {
1781     YellowWire = MW1;
1782   }
1783   
1784   BrownFace = BRepBuilderAPI_MakeFace(YellowWire);
1785
1786
1787 /////////////
1788
1789   P1.SetCoord(35,-200,40);
1790   P2.SetCoord(50,-204,30);
1791   P3.SetCoord(65,-200,30);
1792   P4.SetCoord(35,-20,45);
1793   P5.SetCoord(45,-20,30);
1794   P6.SetCoord(65,-20,65);
1795   TColgp_Array2OfPnt array2(1,3,1,2);
1796   array2.SetValue(1,1,P1);
1797   array2.SetValue(2,1,P2);
1798   array2.SetValue(3,1,P3); 
1799   array2.SetValue(1,2,P4); 
1800   array2.SetValue(2,2,P5); 
1801   array2.SetValue(3,2,P6);
1802   
1803   Handle (Geom_BSplineSurface) BSplineSurf = GeomAPI_PointsToBSplineSurface(array2,3,8,GeomAbs_C2,0.001);
1804   
1805   TopoDS_Face aFace = BRepBuilderAPI_MakeFace(BSplineSurf);
1806
1807   //2d lines
1808   gp_Pnt2d P12d(0.9,0.1);
1809   gp_Pnt2d P22d(0.2,0.7);
1810   gp_Pnt2d P32d(0.02,0.1);
1811   
1812   Handle (Geom2d_Line) line1 = new Geom2d_Line(P12d,gp_Dir2d((0.2-0.9),(0.7-0.1)));
1813   Handle (Geom2d_Line) line2 = new Geom2d_Line(P22d,gp_Dir2d((0.02-0.2),(0.1-0.7)));
1814   Handle (Geom2d_Line) line3 = new Geom2d_Line(P32d,gp_Dir2d((0.9-0.02),(0.1-0.1)));
1815
1816
1817   //Edges are on the BSpline surface
1818   Edge1 = BRepBuilderAPI_MakeEdge(line1,BSplineSurf,0,P12d.Distance(P22d));
1819   Edge2 = BRepBuilderAPI_MakeEdge(line2,BSplineSurf,0,P22d.Distance(P32d));
1820   Edge3 = BRepBuilderAPI_MakeEdge(line3,BSplineSurf,0,P32d.Distance(P12d));
1821
1822   Wire1 = BRepBuilderAPI_MakeWire(Edge1,Edge2,Edge3);
1823   Wire1.Reverse();
1824   PinkFace = BRepBuilderAPI_MakeFace(aFace,Wire1);
1825   BRepLib::BuildCurves3d(PinkFace);
1826   
1827   BRepTools::Write(PinkFace,"PinkFace.rle");
1828
1829
1830 /////////////Display
1831   Handle(AIS_Shape) white = new AIS_Shape(WhiteFace);
1832   aContext->SetColor(white,Quantity_NOC_WHITE);
1833   aContext->SetMaterial(white,Graphic3d_NOM_PLASTIC,Standard_False);    
1834   aContext->Display(white);
1835   
1836   Handle(AIS_Shape) red = new AIS_Shape(RedFace);
1837   aContext->SetColor(red,Quantity_NOC_RED);
1838   aContext->SetMaterial(red,Graphic3d_NOM_PLASTIC,Standard_False);    
1839   aContext->Display(red);
1840   
1841   Handle(AIS_Shape) brown = new AIS_Shape(BrownFace);
1842   aContext->SetColor(brown,Quantity_NOC_BROWN);
1843   aContext->SetMaterial(brown,Graphic3d_NOM_PLASTIC,Standard_False);    
1844   aContext->Display(brown);
1845   
1846   Handle(AIS_Shape) pink = new AIS_Shape(PinkFace);
1847   aContext->SetColor(pink,Quantity_NOC_HOTPINK);
1848   aContext->SetMaterial(pink,Graphic3d_NOM_PLASTIC,Standard_False);    
1849   aContext->Display(pink);
1850
1851
1852   Message = "\
1853         \n\
1854 TopoDS_Face WhiteFace, BrownFace, RedFace, PinkFace;    \n\
1855 TopoDS_Edge Edge1, Edge2, Edge3, Edge4, Edge5, Edge6, Edge7;    \n\
1856 TopoDS_Wire Wire1;      \n\
1857 gp_Pnt P1, P2, P3, P4, P5, P6, P7;      \n\
1858 \n\
1859 ////////The white Face \n\
1860 \n\
1861 gp_Sphere sphere (gp_Ax3(gp_Pnt(0,0,0),gp_Dir(1,0,0)),150);     \n\
1862 \n\
1863 WhiteFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);    \n\
1864 \n\
1865 ////////The red face    \n\
1866 \n\
1867 P1.SetCoord(-15,200,10);        \n\
1868 P2.SetCoord(5,204,0);   \n\
1869 P3.SetCoord(15,200,0);  \n\
1870 P4.SetCoord(-15,20,15); \n\
1871 P5.SetCoord(-5,20,0);   \n\
1872 P6.SetCoord(15,20,35);  \n\
1873 TColgp_Array2OfPnt array(1,3,1,2);      \n\
1874 array.SetValue(1,1,P1); \n\
1875 array.SetValue(2,1,P2); \n\
1876 array.SetValue(3,1,P3);         \n\
1877 array.SetValue(1,2,P4);         \n\
1878 array.SetValue(2,2,P5);         \n\
1879 array.SetValue(3,2,P6); \n\
1880 Handle (Geom_BSplineSurface) curve = GeomAPI_PointsToBSplineSurface(array,3,8,GeomAbs_C2,0.001);        \n\
1881 \n\
1882 RedFace = BRepBuilderAPI_MakeFace(curve);       \n\
1883 \n\
1884 ////////The brown face  \n\
1885 \n\
1886 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80); \n\
1887 Edge1 = BRepBuilderAPI_MakeEdge(circle,0,PI);   \n\
1888 \n\
1889 Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(0,-10,40));      \n\
1890 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,-10,40),gp_Pnt(0,0,80));       \n\
1891 \n\
1892 TopoDS_Wire YellowWire; \n\
1893 BRepBuilderAPI_MakeWire MW1(Edge1,Edge2,Edge3); \n\
1894 if (MW1.IsDone()) {     \n\
1895                 YellowWire = MW1;       \n\
1896 }       \n\
1897 \n\
1898 BrownFace = BRepBuilderAPI_MakeFace(YellowWire);        \n\
1899 \n";
1900 Message += "\
1901 ////////The pink face   \n\
1902 \n\
1903 P1.SetCoord(35,-200,40);        \n\
1904 P2.SetCoord(50,-204,30);        \n\
1905 P3.SetCoord(65,-200,30);        \n\
1906 P4.SetCoord(35,-20,45); \n\
1907 P5.SetCoord(45,-20,30); \n\
1908 P6.SetCoord(65,-20,65); \n\
1909 TColgp_Array2OfPnt array2(1,3,1,2);     \n\
1910 array2.SetValue(1,1,P1);        \n\
1911 array2.SetValue(2,1,P2);        \n\
1912 array2.SetValue(3,1,P3);        \n\
1913 array2.SetValue(1,2,P4);        \n\
1914 array2.SetValue(2,2,P5);        \n\
1915 array2.SetValue(3,2,P6);        \n\
1916         \n\
1917 Handle (Geom_BSplineSurface) BSplineSurf = GeomAPI_PointsToBSplineSurface(array2,3,8,GeomAbs_C2,0.001); \n\
1918         \n\
1919 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(BSplineSurf);       \n\
1920 \n\
1921 //2d lines      \n\
1922 gp_Pnt2d P12d(0.9,0.1); \n\
1923 gp_Pnt2d P22d(0.2,0.7); \n\
1924 gp_Pnt2d P32d(0.02,0.1);        \n\
1925 \n\
1926 Handle (Geom2d_Line) line1=             \n\
1927         new Geom2d_Line(P12d,gp_Dir2d((0.2-0.9),(0.7-0.1)));    \n\
1928 Handle (Geom2d_Line) line2=             \n\
1929         new Geom2d_Line(P22d,gp_Dir2d((0.02-0.2),(0.1-0.7)));   \n\
1930 Handle (Geom2d_Line) line3=             \n\
1931         new Geom2d_Line(P32d,gp_Dir2d((0.9-0.02),(0.1-0.1)));   \n\
1932                 \n\
1933 //Edges are on the BSpline surface      \n\
1934 Edge1 = BRepBuilderAPI_MakeEdge(line1,BSplineSurf,0,P12d.Distance(P22d));       \n\
1935 Edge2 = BRepBuilderAPI_MakeEdge(line2,BSplineSurf,0,P22d.Distance(P32d));       \n\
1936 Edge3 = BRepBuilderAPI_MakeEdge(line3,BSplineSurf,0,P32d.Distance(P12d));       \n\
1937 \n\
1938 Wire1 = BRepBuilderAPI_MakeWire(Edge1,Edge2,Edge3);     \n\
1939 Wire1.Reverse();        \n\
1940 PinkFace = BRepBuilderAPI_MakeFace(aFace,Wire1);        \n\
1941 BRepLib::BuildCurves3d(PinkFace);       \n\
1942 \n\
1943 \n";
1944 }
1945
1946 //===============================================================
1947 // Function name: Shell
1948 //===============================================================
1949  void SamplesTopologyPackage::Shell(const Handle(AIS_InteractiveContext)& aContext,
1950                                     TCollection_AsciiString& Message) 
1951 {
1952   aContext->EraseAll(Standard_False);
1953
1954   TColgp_Array2OfPnt Poles(1,2,1,4);
1955   Poles.SetValue(1,1,gp_Pnt(0,0,0));
1956   Poles.SetValue(1,2,gp_Pnt(0,10,2));
1957   Poles.SetValue(1,3,gp_Pnt(0,20,10)); 
1958   Poles.SetValue(1,4,gp_Pnt(0,30,0)); 
1959   Poles.SetValue(2,1,gp_Pnt(10,0,5));
1960   Poles.SetValue(2,2,gp_Pnt(10,10,3));
1961   Poles.SetValue(2,3,gp_Pnt(10,20,20));
1962   Poles.SetValue(2,4,gp_Pnt(10,30,0));
1963
1964   TColStd_Array1OfReal UKnots(1,2);
1965   UKnots.SetValue(1,0);
1966   UKnots.SetValue(2,1);
1967
1968   TColStd_Array1OfInteger UMults(1,2);
1969   UMults.SetValue(1,2);
1970   UMults.SetValue(2,2);
1971
1972   TColStd_Array1OfReal VKnots(1,3);
1973   VKnots.SetValue(1,0);
1974   VKnots.SetValue(2,1);
1975   VKnots.SetValue(3,2);
1976   
1977   TColStd_Array1OfInteger VMults(1,3);
1978   VMults.SetValue(1,3);
1979   VMults.SetValue(2,1);
1980   VMults.SetValue(3,3);
1981   
1982   Standard_Integer UDegree(1);
1983   Standard_Integer VDegree(2);
1984   
1985   Handle (Geom_BSplineSurface) BSpline = new Geom_BSplineSurface(Poles,UKnots,VKnots,UMults,VMults,UDegree,VDegree);
1986   
1987   TopoDS_Face WhiteFace = BRepBuilderAPI_MakeFace(BSpline);
1988   
1989   Handle(AIS_Shape) white = new AIS_Shape(WhiteFace);
1990   aContext->SetColor(white,Quantity_NOC_WHITE);
1991   aContext->SetMaterial(white,Graphic3d_NOM_PLASTIC,Standard_False);    
1992   aContext->SetTransparency(white,0.7);
1993   aContext->Display(white);
1994   
1995   TopoDS_Shell aShell = BRepBuilderAPI_MakeShell(BSpline);
1996   Handle(AIS_Shape) anAISShell = new AIS_Shape(aShell);
1997   aContext->SetDisplayMode(anAISShell,0);
1998   aContext->Display(anAISShell);
1999   
2000
2001   
2002   Message = "\
2003         \n\
2004 TColgp_Array2OfPnt Poles(1,2,1,4);      \n\
2005 Poles.SetValue(1,1,gp_Pnt(0,0,0));      \n\
2006 Poles.SetValue(1,2,gp_Pnt(0,10,2));     \n\
2007 Poles.SetValue(1,3,gp_Pnt(0,20,10));    \n\
2008 Poles.SetValue(1,4,gp_Pnt(0,30,0));     \n\
2009 Poles.SetValue(2,1,gp_Pnt(10,0,5));     \n\
2010 Poles.SetValue(2,2,gp_Pnt(10,10,3));    \n\
2011 Poles.SetValue(2,3,gp_Pnt(10,20,20));   \n\
2012 Poles.SetValue(2,4,gp_Pnt(10,30,0));    \n\
2013 \n\
2014 TColStd_Array1OfReal UKnots(1,2);       \n\
2015 UKnots.SetValue(1,0);   \n\
2016 UKnots.SetValue(2,1);   \n\
2017 \n\
2018 TColStd_Array1OfInteger UMults(1,2);    \n\
2019 UMults.SetValue(1,2);   \n\
2020 UMults.SetValue(2,2);   \n\
2021 \n\
2022 TColStd_Array1OfReal VKnots(1,3);       \n\
2023 VKnots.SetValue(1,0);   \n\
2024 VKnots.SetValue(2,1);   \n\
2025 VKnots.SetValue(3,2);   \n\
2026 \n\
2027 TColStd_Array1OfInteger VMults(1,3);    \n\
2028 VMults.SetValue(1,3);   \n\
2029 VMults.SetValue(2,1);   \n\
2030 VMults.SetValue(3,3);   \n\
2031 \n\
2032 Standard_Integer UDegree(1);    \n\
2033 Standard_Integer VDegree(2);    \n\
2034         \n\
2035 Handle (Geom_BSplineSurface) BSpline = new Geom_BSplineSurface(Poles,UKnots,VKnots,UMults,VMults,UDegree,VDegree);      \n\
2036         \n\
2037 TopoDS_Shell aShell = BRepBuilderAPI_MakeShell(BSpline);        \n\
2038 \n\
2039 \n";
2040 }
2041
2042 //===============================================================
2043 // Function name: Compound
2044 //===============================================================
2045  void SamplesTopologyPackage::Compound(const Handle(AIS_InteractiveContext)& aContext,
2046                                        TCollection_AsciiString& Message) 
2047 {
2048   aContext->EraseAll(Standard_False);
2049
2050   BRep_Builder builder;
2051   TopoDS_Compound Comp;
2052   builder.MakeCompound(Comp);
2053   
2054   TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30)).Vertex();
2055   builder.Add(Comp,aVertex);
2056   
2057   gp_Ax1 aLocalAx1(gp_Pnt(10,10,10),gp_Dir(1,0,0));
2058   gp_Lin line(aLocalAx1);
2059   //  gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));
2060   TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(line,-20,10).Edge();
2061   builder.Add(Comp,anEdge);
2062   
2063   gp_Ax3 aLocalAx3(gp_Pnt(-80,0,0),gp_Dir(1,0,0));
2064   gp_Sphere sphere (aLocalAx3,150);
2065   //  gp_Sphere sphere (gp_Ax3(gp_Pnt(-80,0,0),gp_Dir(1,0,0)),150);
2066   TopoDS_Face aFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9).Face();
2067   builder.Add(Comp,aFace);
2068   
2069   TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(-60,0,0),30,60,40).Shape();
2070   builder.Add(Comp,aBox);
2071   
2072   Handle(AIS_Shape) white = new AIS_Shape(Comp);
2073   aContext->SetDisplayMode(white,0);
2074   aContext->Display(white);
2075
2076
2077   
2078   Message = "\
2079                 \n\
2080 BRep_Builder builder;   \n\
2081 TopoDS_Compound Comp;   \n\
2082 builder.MakeCompound(Comp);     \n\
2083 \n\
2084 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));  \n\
2085 builder.Add(Comp,aVertex);      \n\
2086         \n\
2087 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));    \n\
2088 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(line,-20,10);      \n\
2089 builder.Add(Comp,anEdge);       \n\
2090         \n\
2091 gp_Sphere sphere (gp_Ax3(gp_Pnt(-80,0,0),gp_Dir(1,0,0)),150);   \n\
2092 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);    \n\
2093 builder.Add(Comp,aFace);        \n\
2094         \n\
2095 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(-60,0,0),30,60,40);      \n\
2096 builder.Add(Comp,aBox); \n\
2097         \n\
2098 \n";
2099 }
2100
2101 //===============================================================
2102 // Function name: Sewing
2103 //===============================================================
2104  void SamplesTopologyPackage::Sewing(const Handle(AIS_InteractiveContext)& aContext,
2105                                      TCollection_AsciiString& Message) 
2106 {
2107   aContext->EraseAll(Standard_False);
2108   
2109   gp_Pnt P(0,0,0);
2110   gp_Vec V(0,0,1);
2111   Handle(Geom_Plane) Pi=new Geom_Plane(P,V);
2112   Handle(Geom_RectangularTrimmedSurface) GeometricSurface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);
2113   TopoDS_Shape FirstShape = BRepBuilderAPI_MakeFace(GeometricSurface);
2114   
2115   Handle(AIS_Shape) white1 = new AIS_Shape(FirstShape);
2116   aContext->SetColor(white1,Quantity_NOC_RED);
2117   aContext->SetMaterial(white1,Graphic3d_NOM_PLASTIC,Standard_False); 
2118   aContext->SetTransparency(white1,0.4);
2119   aContext->Display(white1);
2120
2121   gp_Pnt P1(0,0,0);
2122   gp_Pnt P2(50,0,0);
2123   gp_Pnt P3(100,0,0);
2124   gp_Pnt P4(25,12,85);
2125   gp_Pnt P5(100,0,80);
2126   gp_Pnt P6(135,-12,85);
2127   
2128   TColgp_Array2OfPnt Array(1,3,1,2);
2129   Array.SetValue(1,1,P1);
2130   Array.SetValue(2,1,P2);
2131   Array.SetValue(3,1,P3);
2132   Array.SetValue(1,2,P4);
2133   Array.SetValue(2,2,P5);
2134   Array.SetValue(3,2,P6);
2135   
2136   Handle (Geom_BSplineSurface) aSurf = GeomAPI_PointsToBSplineSurface(Array,3,8,GeomAbs_C2,0.00001);
2137   TopoDS_Shape SecondShape = BRepBuilderAPI_MakeFace(aSurf);
2138   
2139   Handle(AIS_Shape) white2 = new AIS_Shape(SecondShape);
2140   aContext->SetColor(white2,Quantity_NOC_YELLOW);
2141   aContext->SetMaterial(white2,Graphic3d_NOM_PLASTIC,Standard_False);  
2142   aContext->SetTransparency(white2,0.4);
2143   aContext->Display(white2);
2144
2145   
2146   BRepOffsetAPI_Sewing aMethod;
2147   aMethod.Add(FirstShape);      
2148   aMethod.Add(SecondShape);
2149   
2150   aMethod.Perform();
2151   
2152   TopoDS_Shape sewedShape = aMethod.SewedShape();
2153
2154   Handle(AIS_Shape) result = new AIS_Shape(sewedShape);
2155   aContext->SetDisplayMode(result,0);
2156   aContext->Display(result);
2157
2158
2159   Message = "\
2160         \n\
2161 ///////The first shape \n\
2162  \n\
2163 gp_Pnt P(0,0,0);        \n\
2164 gp_Vec V(0,0,1);        \n\
2165 Handle(Geom_Plane) Pi=new Geom_Plane(P,V);      \n\
2166 Handle(Geom_RectangularTrimmedSurface) GeometricSurface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.); \n\
2167 TopoDS_Shape FirstShape = BRepBuilderAPI_MakeFace(GeometricSurface);    \n\
2168         \n\
2169 ///////The second shape \n\
2170  \n\
2171 gp_Pnt P1(0,0,0);       \n\
2172 gp_Pnt P2(50,0,0);      \n\
2173 gp_Pnt P3(100,0,0);     \n\
2174 gp_Pnt P4(25,12,85);    \n\
2175 gp_Pnt P5(100,0,80);    \n\
2176 gp_Pnt P6(135,-12,85);  \n\
2177 \n\
2178 TColgp_Array2OfPnt Array(1,3,1,2);      \n\
2179 Array.SetValue(1,1,P1); \n\
2180 Array.SetValue(2,1,P2); \n\
2181 Array.SetValue(3,1,P3); \n\
2182 Array.SetValue(1,2,P4); \n\
2183 Array.SetValue(2,2,P5); \n\
2184 Array.SetValue(3,2,P6); \n\
2185 \n\
2186 Handle (Geom_BSplineSurface) aSurf = GeomAPI_PointsToBSplineSurface(Array,3,8,GeomAbs_C2,0.00001);      \n\
2187 TopoDS_Shape SecondShape = BRepBuilderAPI_MakeFace(aSurf);      \n\
2188         \n\
2189 BRepOffsetAPI_Sewing aMethod;   \n\
2190 aMethod.Add(FirstShape);                \n\
2191 aMethod.Add(SecondShape);       \n\
2192 \n\
2193 aMethod.Perform();      \n\
2194 \n\
2195 TopoDS_Shape sewedShape = aMethod.SewedShape(); \n\
2196         \n\
2197 \n";
2198 }
2199
2200 //===============================================================
2201 // Function name: Builder
2202 //===============================================================
2203  void SamplesTopologyPackage::Builder(const Handle(AIS_InteractiveContext)& aContext,
2204                                       TCollection_AsciiString& Message) 
2205 {
2206   aContext->EraseAll(Standard_False);
2207
2208   //The tolerance is the tolerance of confusion
2209   Standard_Real precision = Precision::Confusion();
2210
2211   //The builder
2212   BRep_Builder B;
2213
2214   //Build the vertices
2215   TopoDS_Vertex V000, V001, V010, V011, V100, V101, V110, V111;
2216   B.MakeVertex(V000,gp_Pnt(0,0,0),precision);
2217   B.MakeVertex(V001,gp_Pnt(0,0,100),precision);
2218   B.MakeVertex(V010,gp_Pnt(0,150,0),precision);
2219   B.MakeVertex(V011,gp_Pnt(0,150,100),precision);
2220   B.MakeVertex(V100,gp_Pnt(200,0,0),precision);
2221   B.MakeVertex(V101,gp_Pnt(200,0,100),precision);
2222   B.MakeVertex(V110,gp_Pnt(200,150,0),precision);
2223   B.MakeVertex(V111,gp_Pnt(200,150,100),precision);
2224   
2225   //Build the edges
2226   //the edges are oriented as the axis X,Y,Z
2227   TopoDS_Edge EX00, EX01, EX10, EX11;
2228   TopoDS_Edge EY00, EY01, EY10, EY11;
2229   TopoDS_Edge EZ00, EZ01, EZ10, EZ11;
2230   Handle (Geom_Line) L;
2231   
2232   //Edge X00
2233   L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(1,0,0));
2234   B.MakeEdge(EX00,L,precision);
2235   V000.Orientation(TopAbs_FORWARD);
2236   V100.Orientation(TopAbs_REVERSED);
2237   B.Add(EX00,V000);
2238   B.Add(EX00,V100);
2239   //Parameters
2240   B.UpdateVertex(V000,0,EX00,precision);
2241   B.UpdateVertex(V100,200,EX00,precision);
2242   
2243   //Edge X10
2244   L = new Geom_Line(gp_Pnt(0,150,0),gp_Dir(1,0,0));
2245   B.MakeEdge(EX10,L,precision);
2246   V010.Orientation(TopAbs_FORWARD);
2247   V110.Orientation(TopAbs_REVERSED);
2248   B.Add(EX10,V010);
2249   B.Add(EX10,V110);
2250   //Parameters
2251   B.UpdateVertex(V010,0,EX10,precision);
2252   B.UpdateVertex(V110,200,EX10,precision);
2253
2254   //Edge Y00
2255   L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(0,1,0));
2256   B.MakeEdge(EY00,L,precision);
2257   V000.Orientation(TopAbs_FORWARD);
2258   V010.Orientation(TopAbs_REVERSED);
2259   B.Add(EY00,V000);
2260   B.Add(EY00,V010);
2261   //Parameters
2262   B.UpdateVertex(V000,0,EY00,precision);
2263   B.UpdateVertex(V010,150,EY00,precision);
2264   
2265   //Edge Y10
2266   L = new Geom_Line(gp_Pnt(200,0,0),gp_Dir(0,1,0));
2267   B.MakeEdge(EY10,L,precision);
2268   V100.Orientation(TopAbs_FORWARD);
2269   V110.Orientation(TopAbs_REVERSED);
2270   B.Add(EY10,V100);
2271   B.Add(EY10,V110);
2272   //Parameters
2273   B.UpdateVertex(V100,0,EY10,precision);
2274   B.UpdateVertex(V110,150,EY10,precision);
2275   
2276   //Edge Y01
2277   L = new Geom_Line(gp_Pnt(0,0,100),gp_Dir(0,1,0));
2278   B.MakeEdge(EY01,L,precision);
2279   V001.Orientation(TopAbs_FORWARD);
2280   V011.Orientation(TopAbs_REVERSED);
2281   B.Add(EY01,V001);
2282   B.Add(EY01,V011);
2283   //Parameters
2284   B.UpdateVertex(V001,0,EY01,precision);
2285   B.UpdateVertex(V011,150,EY01,precision);
2286   
2287   //Edge Y11
2288   L = new Geom_Line(gp_Pnt(200,0,100),gp_Dir(0,1,0));
2289   B.MakeEdge(EY11,L,precision);
2290   V101.Orientation(TopAbs_FORWARD);
2291   V111.Orientation(TopAbs_REVERSED);
2292   B.Add(EY11,V101);
2293   B.Add(EY11,V111);
2294   //Parameters
2295   B.UpdateVertex(V101,0,EY11,precision);
2296   B.UpdateVertex(V111,150,EY11,precision);
2297
2298   //Edge Z00
2299   L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(0,0,1));
2300   B.MakeEdge(EZ00,L,precision);
2301   V000.Orientation(TopAbs_FORWARD);
2302   V001.Orientation(TopAbs_REVERSED);
2303   B.Add(EZ00,V000);
2304   B.Add(EZ00,V001);
2305   //Parameters
2306   B.UpdateVertex(V000,0,EZ00,precision);
2307   B.UpdateVertex(V001,100,EZ00,precision);
2308   
2309   //Edge Z01
2310   L = new Geom_Line(gp_Pnt(0,150,0),gp_Dir(0,0,1));
2311   B.MakeEdge(EZ01,L,precision);
2312   V010.Orientation(TopAbs_FORWARD);
2313   V011.Orientation(TopAbs_REVERSED);
2314   B.Add(EZ01,V010);
2315   B.Add(EZ01,V011);
2316   //Parameters
2317   B.UpdateVertex(V010,0,EZ01,precision);
2318   B.UpdateVertex(V011,100,EZ01,precision);
2319   
2320   //Edge Z10
2321   L = new Geom_Line(gp_Pnt(200,0,0),gp_Dir(0,0,1));
2322   B.MakeEdge(EZ10,L,precision);
2323   V100.Orientation(TopAbs_FORWARD);
2324   V101.Orientation(TopAbs_REVERSED);
2325   B.Add(EZ10,V100);
2326   B.Add(EZ10,V101);
2327   //Parameters
2328   B.UpdateVertex(V100,0,EZ10,precision);
2329   B.UpdateVertex(V101,100,EZ10,precision);
2330   
2331   //Edge Z11
2332   L = new Geom_Line(gp_Pnt(200,150,0),gp_Dir(0,0,1));
2333   B.MakeEdge(EZ11,L,precision);
2334   V110.Orientation(TopAbs_FORWARD);
2335   V111.Orientation(TopAbs_REVERSED);
2336   B.Add(EZ11,V110);
2337   B.Add(EZ11,V111);
2338   //Parameters
2339   B.UpdateVertex(V110,0,EZ11,precision);
2340   B.UpdateVertex(V111,100,EZ11,precision);
2341   
2342
2343   //Circular Edges
2344   Handle (Geom_Circle) C;
2345   //  Standard_Real R = 100;
2346   
2347   //Edge EX01
2348   C = new Geom_Circle(gp_Ax2(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
2349   B.MakeEdge(EX01,C,precision);
2350   V001.Orientation(TopAbs_FORWARD);
2351   V101.Orientation(TopAbs_REVERSED);
2352   B.Add(EX01,V001);
2353   B.Add(EX01,V101);
2354   //Parameters
2355   B.UpdateVertex(V001,0,EX01,precision);
2356   B.UpdateVertex(V101,PI,EX01,precision);
2357
2358   //Edge EX11
2359   C = new Geom_Circle(gp_Ax2(gp_Pnt(100,150,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
2360   B.MakeEdge(EX11,C,precision);
2361   V011.Orientation(TopAbs_FORWARD);
2362   V111.Orientation(TopAbs_REVERSED);
2363   B.Add(EX11,V011);
2364   B.Add(EX11,V111);
2365   //Parameters
2366   B.UpdateVertex(V011,0,EX11,precision);
2367   B.UpdateVertex(V111,PI,EX11,precision);
2368   
2369   //Build wire and faces
2370   //Faces normals are along the axis X,Y,Z
2371   TopoDS_Face FXMIN, FXMAX, FYMIN, FYMAX, FZMIN, FZMAX;
2372   TopoDS_Wire W;
2373   Handle (Geom_Plane) P;
2374   Handle (Geom2d_Line) L2d;
2375   Handle (Geom2d_Circle) C2d;
2376   Handle (Geom_CylindricalSurface) S;
2377   
2378   //Face FXMAX
2379   P = new Geom_Plane(gp_Ax2(gp_Pnt(200,0,0),gp_Dir(1,0,0),gp_Dir(0,1,0)));
2380   B.MakeFace(FXMAX,P,precision);
2381   //the wire and the edges
2382   B.MakeWire (W);
2383
2384   EY10.Orientation(TopAbs_FORWARD);
2385   B.Add(W,EY10);
2386   //pcurve
2387   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
2388   B.UpdateEdge(EY10,L2d,FXMAX,precision);
2389
2390   EZ11.Orientation(TopAbs_FORWARD);
2391   B.Add(W,EZ11);
2392   //pcurve
2393   L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));
2394   B.UpdateEdge(EZ11,L2d,FXMAX,precision);
2395   
2396   EY11.Orientation(TopAbs_REVERSED);
2397   B.Add(W,EY11);
2398   //pcurve
2399   L2d = new Geom2d_Line(gp_Pnt2d(0,100),gp_Dir2d(1,0));
2400   B.UpdateEdge(EY11,L2d,FXMAX,precision);
2401   
2402   EZ10.Orientation(TopAbs_REVERSED);
2403   B.Add(W,EZ10);
2404   //pcurve
2405   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
2406   B.UpdateEdge(EZ10,L2d,FXMAX,precision);
2407   
2408   B.Add(FXMAX,W);
2409   
2410   BRepTools::Write(FXMAX,"f1.rle");
2411   
2412   //Face FXMIN
2413   P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(-1,0,0),gp_Dir(0,0,1)));
2414   B.MakeFace(FXMIN,P,precision);
2415   //the wire and the edges
2416   B.MakeWire (W);
2417   
2418   EZ00.Orientation(TopAbs_FORWARD);
2419   B.Add(W,EZ00);
2420   //pcurve
2421   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
2422   B.UpdateEdge(EZ00,L2d,FXMIN,precision);
2423   
2424   EY01.Orientation(TopAbs_FORWARD);
2425   B.Add(W,EY01);
2426   //pcurve
2427   L2d = new Geom2d_Line(gp_Pnt2d(100,0),gp_Dir2d(0,1));
2428   B.UpdateEdge(EY01,L2d,FXMIN,precision);
2429   
2430   EZ01.Orientation(TopAbs_REVERSED);
2431   B.Add(W,EZ01);
2432   //pcurve
2433   L2d = new Geom2d_Line(gp_Pnt2d(0,150),gp_Dir2d(1,0));
2434   B.UpdateEdge(EZ01,L2d,FXMIN,precision);
2435   
2436   EY00.Orientation(TopAbs_REVERSED);
2437   B.Add(W,EY00);
2438   //pcurve
2439   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
2440   B.UpdateEdge(EY00,L2d,FXMIN,precision);
2441   
2442   
2443   B.Add(FXMIN,W);
2444         
2445   //Face FYMAX
2446
2447   P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0),gp_Dir(0,0,1)));
2448   B.MakeFace(FYMAX,P,precision);
2449   //the wire and the edges
2450   B.MakeWire (W);
2451   
2452   EZ00.Orientation(TopAbs_FORWARD);
2453   B.Add(W,EZ00);
2454   //pcurve
2455   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
2456   B.UpdateEdge(EZ00,L2d,FYMAX,precision);
2457
2458   EX01.Orientation(TopAbs_FORWARD);
2459   B.Add(W,EX01);
2460   //pcurve
2461   C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(100,100),gp_Dir2d(0,-1)),100);
2462   B.UpdateEdge(EX01,C2d,FYMAX,precision);
2463   B.UpdateVertex(V001,0,EX01,FYMAX,precision);
2464   B.UpdateVertex(V101,PI,EX01,FYMAX,precision);
2465
2466   EZ10.Orientation(TopAbs_REVERSED);
2467   B.Add(W,EZ10);
2468   //pcurve
2469   L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
2470   B.UpdateEdge(EZ10,L2d,FYMAX,precision);
2471   
2472   EX00.Orientation(TopAbs_REVERSED);
2473   B.Add(W,EX00);
2474   //pcurve
2475   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
2476   B.UpdateEdge(EX00,L2d,FYMAX,precision);
2477
2478
2479   B.Add(FYMAX,W);
2480
2481
2482
2483   //Face FYMIN
2484   P = new Geom_Plane(gp_Ax2(gp_Pnt(0,150,0),gp_Dir(0,1,0),gp_Dir(0,0,1)));
2485   B.MakeFace(FYMIN,P,precision);
2486   //the wire and the edges
2487   B.MakeWire (W);
2488   
2489   EZ01.Orientation(TopAbs_FORWARD);
2490   B.Add(W,EZ01);
2491   //pcurve
2492   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
2493   B.UpdateEdge(EZ01,L2d,FYMIN,precision);
2494   
2495   EX11.Orientation(TopAbs_FORWARD);
2496   B.Add(W,EX11);
2497   //pcurve
2498   C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(100,100),gp_Dir2d(0,-1)),100);
2499   B.UpdateEdge(EX11,C2d,FYMIN,precision);
2500   B.UpdateVertex(V011,0,EX11,FYMIN,precision);
2501   B.UpdateVertex(V111,PI,EX11,FYMIN,precision);
2502
2503   EZ11.Orientation(TopAbs_REVERSED);
2504   B.Add(W,EZ11);
2505   //pcurve
2506   L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
2507   B.UpdateEdge(EZ11,L2d,FYMIN,precision);
2508   
2509   EX10.Orientation(TopAbs_REVERSED);
2510   B.Add(W,EX10);
2511   //pcurve
2512   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
2513   B.UpdateEdge(EX10,L2d,FYMIN,precision);
2514   
2515   B.Add(FYMIN,W);
2516   
2517   //Face FZMAX
2518   P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,0,-1),gp_Dir(0,1,0)));
2519   B.MakeFace(FZMAX,P,precision);
2520   //the wire and the edges
2521   B.MakeWire (W);
2522   
2523   EY00.Orientation(TopAbs_FORWARD);
2524   B.Add(W,EY00);
2525   //pcurve
2526   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
2527   B.UpdateEdge(EY00,L2d,FZMAX,precision);
2528   
2529   EX10.Orientation(TopAbs_FORWARD);
2530   B.Add(W,EX10);
2531   //pcurve
2532   L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));
2533   B.UpdateEdge(EX10,L2d,FZMAX,precision);
2534   
2535   EY10.Orientation(TopAbs_REVERSED);
2536   B.Add(W,EY10);
2537   //pcurve
2538   L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
2539   B.UpdateEdge(EY10,L2d,FZMAX,precision);
2540   
2541   EX00.Orientation(TopAbs_REVERSED);
2542   B.Add(W,EX00);
2543   //pcurve
2544   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
2545   B.UpdateEdge(EX00,L2d,FZMAX,precision);
2546   
2547   
2548   B.Add(FZMAX,W);
2549   
2550   //Face FZMIN
2551   S = new Geom_CylindricalSurface(gp_Ax3(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
2552   B.MakeFace(FZMIN,S,precision);
2553   
2554   //the wire and the edges
2555   B.MakeWire (W);
2556   
2557   EX01.Orientation(TopAbs_FORWARD);
2558   B.Add(W,EX01);
2559   //pcurve
2560   L2d = new Geom2d_Line(gp_Ax2d(gp_Pnt2d(0,0),gp_Dir2d(1,0)));
2561   B.UpdateEdge(EX01,L2d,FZMIN,precision);
2562   B.UpdateVertex(V001,0,EX01,FZMIN,precision);
2563   B.UpdateVertex(V101,PI,EX01,FZMIN,precision);
2564   
2565   EY11.Orientation(TopAbs_FORWARD);
2566   B.Add(W,EY11);
2567   //pcurve
2568   L2d = new Geom2d_Line(gp_Pnt2d(PI,0),gp_Dir2d(0,1));
2569   B.UpdateEdge(EY11,L2d,FZMIN,precision);
2570
2571   EX11.Orientation(TopAbs_REVERSED);
2572   B.Add(W,EX11);
2573   //pcurve
2574   L2d = new Geom2d_Line(gp_Ax2d(gp_Pnt2d(0,150),gp_Dir2d(1,0)));
2575   B.UpdateEdge(EX11,L2d,FZMIN,precision);
2576   B.UpdateVertex(V111,PI,EX11,FZMIN,precision);
2577   B.UpdateVertex(V011,0,EX11,FZMIN,precision);
2578   
2579   EY01.Orientation(TopAbs_REVERSED);
2580   B.Add(W,EY01);
2581   //pcurve
2582   L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
2583   B.UpdateEdge(EY01,L2d,FZMIN,precision);
2584   
2585   B.Add(FZMIN,W);
2586   
2587   FYMAX.Orientation(TopAbs_REVERSED);
2588
2589   BRepTools::Write(FZMIN,"f3.rle");
2590   BRepTools::Write(FYMAX,"f2.rle");
2591
2592   //Shell
2593   TopoDS_Shell Sh;
2594   B.MakeShell(Sh);
2595   B.Add(Sh,FXMAX);
2596   B.Add(Sh,FXMIN);
2597   B.Add(Sh,FYMAX);
2598   B.Add(Sh,FYMIN);
2599   B.Add(Sh,FZMAX);
2600   B.Add(Sh,FZMIN);
2601
2602   // Solid
2603   TopoDS_Solid Sol;
2604   B.MakeSolid(Sol);
2605   B.Add(Sol,Sh);
2606
2607   BRepTools::Write(Sol,"solid.rle");
2608   Handle(AIS_Shape) borne = new AIS_Shape(Sol);
2609   aContext->SetDisplayMode(borne,1);
2610   aContext->SetColor(borne,Quantity_NOC_RED);
2611   aContext->SetMaterial(borne,Graphic3d_NOM_PLASTIC,Standard_False);    
2612   aContext->Display(borne);
2613
2614   Message = "\
2615                 \n\
2616 //The tolerance is 0.01         \n\
2617 Standard_Real precision(0.01);  \n\
2618 \n\
2619 //The builder   \n\
2620 BRep_Builder B; \n\
2621 \n\
2622 //Build the vertices    \n\
2623 TopoDS_Vertex V000, V001, V010, V011, V100, V101, V110, V111;   \n\
2624 B.MakeVertex(V000,gp_Pnt(0,0,0),precision);     \n\
2625 B.MakeVertex(V001,gp_Pnt(0,0,100),precision);   \n\
2626 B.MakeVertex(V010,gp_Pnt(0,150,0),precision);   \n\
2627 B.MakeVertex(V011,gp_Pnt(0,150,100),precision); \n\
2628 B.MakeVertex(V100,gp_Pnt(200,0,0),precision);   \n\
2629 B.MakeVertex(V101,gp_Pnt(200,0,100),precision); \n\
2630 B.MakeVertex(V110,gp_Pnt(200,150,0),precision); \n\
2631 B.MakeVertex(V111,gp_Pnt(200,150,100),precision);       \n\
2632 \n\
2633 //Build the edges       \n\
2634 //the edges are oriented as the axis X,Y,Z      \n\
2635 TopoDS_Edge EX00, EX01, EX10, EX11;     \n\
2636 TopoDS_Edge EY00, EY01, EY10, EY11;     \n\
2637 TopoDS_Edge EZ00, EZ01, EZ10, EZ11;     \n\
2638 Handle (Geom_Line) L;   \n\
2639 \n\
2640 //Edge X00      \n\
2641 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(1,0,0)); \n\
2642 B.MakeEdge(EX00,L,precision);   \n\
2643 V000.Orientation(TopAbs_FORWARD);       \n\
2644 V100.Orientation(TopAbs_REVERSED);      \n\
2645 B.Add(EX00,V000);       \n\
2646 B.Add(EX00,V100);       \n\
2647 //Parameters    \n\
2648 B.UpdateVertex(V000,0,EX00,precision);  \n\
2649 B.UpdateVertex(V100,200,EX00,precision);        \n\
2650 \n\
2651 //Idem for all the linear edges...      \n\
2652 \n\
2653 //Circular Edges        \n\
2654 Handle (Geom_Circle) C; \n\
2655 Standard_Real R = 100;  \n\
2656 \n\
2657 //Edge EX01     \n\
2658 C = new Geom_Circle(gp_Ax2(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);        \n\
2659 B.MakeEdge(EX01,C,precision);   \n\
2660 V001.Orientation(TopAbs_FORWARD);       \n\
2661 V101.Orientation(TopAbs_REVERSED);      \n\
2662 B.Add(EX01,V001);       \n\
2663 B.Add(EX01,V101);       \n\
2664 //Parameters    \n\
2665 B.UpdateVertex(V001,0,EX01,precision);  \n\
2666 B.UpdateVertex(V101,PI,EX01,precision); \n\
2667 \n\
2668 //Idem for EX11 \n\
2669 \n\
2670 //Build wire and faces  \n\
2671 //Faces normals are along the axis X,Y,Z        \n\
2672 TopoDS_Face FXMIN, FXMAX, FYMIN, FYMAX, FZMIN, FZMAX;   \n\
2673 TopoDS_Wire W;  \n\
2674 Handle (Geom_Plane) P;  \n\
2675 Handle (Geom2d_Line) L2d;       \n\
2676 Handle (Geom2d_Circle) C2d;     \n\
2677 Handle (Geom_CylindricalSurface) S;     \n\
2678 \n\
2679 //Face FXMAX    \n\
2680 P = new Geom_Plane(gp_Ax2(gp_Pnt(200,0,0),gp_Dir(1,0,0),gp_Dir(0,1,0)));        \n\
2681 B.MakeFace(FXMAX,P,precision);  \n\
2682 //the wire and the edges        \n\
2683 B.MakeWire (W); \n";
2684 Message += "\
2685 \n\
2686 EY10.Orientation(TopAbs_FORWARD);       \n\
2687 B.Add(W,EY10);  \n\
2688 //pcurve        \n\
2689 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));     \n\
2690 B.UpdateEdge(EY10,L2d,FXMAX,precision); \n\
2691         \n\
2692 EZ11.Orientation(TopAbs_FORWARD);       \n\
2693 B.Add(W,EZ11);  \n\
2694 //pcurve        \n\
2695 L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));   \n\
2696 B.UpdateEdge(EZ11,L2d,FXMAX,precision); \n\
2697         \n\
2698 EY11.Orientation(TopAbs_REVERSED);      \n\
2699 B.Add(W,EY11);  \n\
2700 //pcurve        \n\
2701 L2d = new Geom2d_Line(gp_Pnt2d(0,100),gp_Dir2d(1,0));   \n\
2702 B.UpdateEdge(EY11,L2d,FXMAX,precision); \n\
2703         \n\
2704 EZ10.Orientation(TopAbs_REVERSED);      \n\
2705 B.Add(W,EZ10);  \n\
2706 //pcurve        \n\
2707 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));     \n\
2708 B.UpdateEdge(EZ10,L2d,FXMAX,precision); \n\
2709 \n\
2710 B.Add(FXMAX,W); \n\
2711 \n\
2712 //Idem for other faces...       \n\
2713 \n\
2714 //Shell \n\
2715 TopoDS_Shell Sh;        \n\
2716 B.MakeShell(Sh);        \n\
2717 B.Add(Sh,FXMAX);        \n\
2718 B.Add(Sh,FXMIN);        \n\
2719 B.Add(Sh,FYMAX);        \n\
2720 B.Add(Sh,FYMIN);        \n\
2721 B.Add(Sh,FZMAX);        \n\
2722 B.Add(Sh,FZMIN);        \n\
2723 \n\
2724 // Solid        \n\
2725 TopoDS_Solid Sol;       \n\
2726 B.MakeSolid(Sol);       \n\
2727 B.Add(Sol,Sh);  \n\
2728 \n\
2729 \n";
2730 }
2731
2732 //===============================================================
2733 // Function name: Geometry
2734 //===============================================================
2735  void SamplesTopologyPackage::Geometry(const Handle(AIS_InteractiveContext)& aContext,
2736                                        TCollection_AsciiString& Message) 
2737 {
2738   aContext->EraseAll(Standard_False);
2739
2740   //geometrie of a vertex
2741   TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(0,120,70));
2742   //  gp_Pnt GeometricPoint = 
2743   BRep_Tool::Pnt(aVertex);
2744
2745   Handle(AIS_Shape) vert = new AIS_Shape(aVertex);
2746   aContext->Display(vert);
2747
2748   //geometrie of an edge
2749   TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(100,50,250),gp_Pnt(-30,-100,-50));
2750   Handle(AIS_Shape) yellow = new AIS_Shape(anEdge);
2751   aContext->SetWidth(yellow,2);
2752   aContext->Display(yellow);
2753
2754   TopLoc_Location location;
2755   Standard_Real first, last;
2756   Handle (Geom_Curve) aCurve = BRep_Tool::Curve(anEdge,location,first,last);
2757   TopoDS_Edge anEdgeDS = BRepBuilderAPI_MakeEdge(aCurve);
2758
2759   Handle (Geom_Line) aLine = Handle (Geom_Line)::DownCast(aCurve);
2760   if (!aLine.IsNull()) {
2761     Handle (AIS_Line) DispLine = new AIS_Line(aLine);
2762     aContext->Display(DispLine);
2763   }
2764   
2765   //geometrie of a face
2766   gp_Pnt P(-20,-20,-20);
2767   gp_Vec V(0,0,1);
2768   Handle(Geom_Plane) Pi=new Geom_Plane(P,V);
2769   Handle(Geom_RectangularTrimmedSurface) Surface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);
2770   TopoDS_Face RedFace = BRepBuilderAPI_MakeFace(Surface);
2771   
2772   Handle(AIS_Shape) red = new AIS_Shape(RedFace);
2773   aContext->SetColor(red,Quantity_NOC_RED);
2774   aContext->SetMaterial(red,Graphic3d_NOM_PLASTIC,Standard_False);    
2775   aContext->Display(red);
2776   
2777   TopLoc_Location location2;
2778   Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(RedFace,location2);
2779   
2780   Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);
2781   if (!aPlane.IsNull()) {
2782     Handle (AIS_Plane) DispPlane = new AIS_Plane(aPlane);
2783     aContext->Display(DispPlane);
2784   }
2785
2786
2787
2788   Message = "\
2789         \n\
2790 ///////geometrie of a vertex    \n\
2791 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(0,120,70));    \n\
2792 gp_Pnt GeometricPoint = BRep_Tool::Pnt(aVertex);        \n\
2793 \n\
2794 ///////geometrie of an edge     \n\
2795 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(100,50,250),gp_Pnt(-30,-100,-50));  \n\
2796 \n\
2797 TopLoc_Location location;       \n\
2798 Standard_Real first, last;      \n\
2799 Handle (Geom_Curve) aCurve = BRep_Tool::Curve(anEdge,location,first,last);      \n\
2800 TopoDS_Edge anEdgeDS = BRepBuilderAPI_MakeEdge(aCurve); \n\
2801 \n\
2802 Handle (Geom_Line) aLine = Handle (Geom_Line)::DownCast(aCurve);        \n\
2803 if (!aLine.IsNull()) {  \n\
2804         Handle (AIS_Line) DispLine = new AIS_Line(aLine);       \n\
2805 }       \n\
2806                 \n\
2807 ///////geometrie of a face      \n\
2808 gp_Pnt P(-20,-20,-20);  \n\
2809 gp_Vec V(0,0,1);        \n\
2810 Handle(Geom_Plane) Pi=new Geom_Plane(P,V);      \n\
2811 Handle(Geom_RectangularTrimmedSurface) Surface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);  \n\
2812 TopoDS_Face RedFace = BRepBuilderAPI_MakeFace(Surface); \n\
2813 \n\
2814 TopLoc_Location location2;      \n\
2815 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(RedFace,location2);        \n\
2816 \n\
2817 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);  \n\
2818 if (!aPlane.IsNull()) { \n\
2819         Handle (AIS_Plane) DispPlane = new AIS_Plane(aPlane);   \n\
2820 }       \n\
2821 \n\
2822 \n";
2823 }
2824
2825 //===============================================================
2826 // Function name: Explorer
2827 //===============================================================
2828  void SamplesTopologyPackage::Explorer(const Handle(AIS_InteractiveContext)& aContext,
2829                                        TCollection_AsciiString& Message) 
2830 {
2831   aContext->EraseAll(Standard_False);
2832         
2833   TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100,100,100).Shape();
2834   Standard_Integer j(8);
2835   Handle(AIS_Shape) theBox = new AIS_Shape(aBox);
2836   aContext->SetColor(theBox,Quantity_NOC_RED);
2837   aContext->SetMaterial(theBox,Graphic3d_NOM_PLASTIC,Standard_False);  
2838   aContext->Display(theBox);
2839
2840   for (TopExp_Explorer exp (aBox,TopAbs_FACE);exp.More();exp.Next()) {
2841     TopoDS_Face aCurrentFace = TopoDS::Face(exp.Current());
2842     
2843     //test the orientation of the current face
2844     TopAbs_Orientation orient = aCurrentFace.Orientation();
2845     
2846     //Recover the geometric plane
2847     TopLoc_Location location;
2848     Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(aCurrentFace,location);
2849     
2850     Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);
2851     
2852     //Build an AIS_Shape with a new color
2853     Handle(AIS_Shape) theMovingFace = new AIS_Shape(aCurrentFace);
2854     Quantity_NameOfColor aCurrentColor = (Quantity_NameOfColor)j;
2855     aContext->SetColor(theMovingFace,aCurrentColor);
2856     aContext->SetMaterial(theMovingFace,Graphic3d_NOM_PLASTIC,Standard_False);  
2857     //Find the normal vector of each face
2858     gp_Pln agpPlane = aPlane->Pln();
2859     gp_Ax1 norm = agpPlane.Axis();
2860     gp_Dir dir = norm.Direction();
2861     gp_Vec move(dir);
2862
2863     //Connect
2864     TopLoc_Location aLocation;
2865     Handle (AIS_ConnectedInteractive) theTransformedDisplay = new AIS_ConnectedInteractive();
2866     theTransformedDisplay->Connect(theMovingFace, aLocation);
2867
2868
2869     Handle (Geom_Transformation) theMove = new Geom_Transformation(aLocation.Transformation());
2870     aContext->Display(theTransformedDisplay);
2871
2872     for (Standard_Integer i=1;i<=30;i++) {
2873                   
2874       //Build a transformation on the display
2875       theMove->SetTranslation(move*i);
2876       if (orient==TopAbs_FORWARD) aContext->SetLocation(theTransformedDisplay,TopLoc_Location(theMove->Trsf()));
2877       else aContext->SetLocation(theTransformedDisplay,TopLoc_Location(theMove->Inverted()->Trsf()));
2878       
2879       aContext->Redisplay(theTransformedDisplay,Standard_False);
2880     }
2881     j+=15;
2882   }
2883   aContext->Erase(theBox,Standard_True,Standard_False); 
2884
2885
2886   Message = "\
2887 \n\
2888 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100,100,100);   \n\
2889 \n\
2890 for (TopExp_Explorer exp (aBox,TopAbs_FACE);exp.More();exp.Next()) {    \n\
2891         TopoDS_Face aCurrentFace = TopoDS::Face(exp.Current()); \n\
2892 \n\
2893         //Recover the geometric plane   \n\
2894         TopLoc_Location location;       \n\
2895         Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(aCurrentFace,location);    \n\
2896 \n\
2897         Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);  \n\
2898         \n\
2899 \n";
2900 }
2901
2902
2903 //======================================================================
2904 //=                                                                    =
2905 //=                      Topology  Analysis                            =
2906 //=                                                                    =
2907 //======================================================================
2908
2909 //===============================================================
2910 // Function name: Validity
2911 //===============================================================
2912  void SamplesTopologyPackage::Validity(const Handle(AIS_InteractiveContext)& aContext,
2913                                        TCollection_AsciiString& Message,TCollection_AsciiString& Result) 
2914 {
2915   aContext->EraseAll(Standard_False);
2916   TopoDS_Shape S = BRepPrimAPI_MakeBox(200.,300.,150.).Shape();
2917         
2918         
2919   Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2920
2921
2922   aContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); 
2923   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);   
2924   aContext->Display(ais1);
2925
2926
2927   Message = "\
2928                 \n\
2929 TopoDS_Shape S = BRepPrimAPI_MakeBox(200.,300.,150.);\n\
2930 Standard_Boolean theShapeIsValid = BRepAlgo::IsValid(S);\n\
2931 if ( theShapeIsValid )\n\
2932 {\n\
2933    Result = \"The Shape Is Valid !!\";\n\
2934 }\n\
2935 else\n\
2936 {\n\
2937    Result = \"The Shape Is NOT Valid !!\";\n\
2938 }\n\
2939 \n";
2940
2941
2942         Standard_Boolean theShapeIsValid = BRepAlgo::IsValid(S);
2943         if ( theShapeIsValid )
2944         {
2945                 Result = "The Shape Is Valid !! ";
2946         }
2947         else
2948         {
2949                 Result = "The Shape Is NOT Valid !! ";
2950         }
2951 }
2952
2953 //===============================================================
2954 // Function name: LinearProp
2955 //===============================================================
2956  void SamplesTopologyPackage::LinearProp(const Handle(AIS_InteractiveContext)& aContext,
2957                                          TCollection_AsciiString& Message,
2958                                          TCollection_AsciiString& Result) 
2959 {
2960   aContext->EraseAll(Standard_False);
2961
2962
2963   TColgp_Array1OfPnt Points1(1,4);
2964   Points1.SetValue(1,gp_Pnt(0,0,0));
2965   Points1.SetValue(2,gp_Pnt(2,1,0));
2966   Points1.SetValue(3,gp_Pnt(4,0,0));
2967   Points1.SetValue(4,gp_Pnt(6,2,0));
2968   GeomAPI_PointsToBSpline PTBS1(Points1);
2969   Handle(Geom_BSplineCurve) BSC1 = PTBS1.Curve();
2970   TopoDS_Edge S = BRepBuilderAPI_MakeEdge(BSC1).Edge();
2971
2972   Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2973   aContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); 
2974   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);   
2975   aContext->Display(ais1);
2976
2977
2978   GProp_GProps System;
2979   BRepGProp::LinearProperties(S,System);
2980   gp_Pnt G = System.CentreOfMass ();
2981   Standard_Real Length = System.Mass();
2982   gp_Mat I = System.MatrixOfInertia();
2983
2984   Result = "Length Of all the Edges =";
2985   Result += TCollection_AsciiString(Length);
2986   Result += "\nCenterOfMass : \n   X=";
2987   Result += TCollection_AsciiString(G.X());
2988   Result += " Y=";
2989   Result += TCollection_AsciiString(G.Y());
2990   Result += " Z=";
2991   Result += TCollection_AsciiString(G.Z());
2992   Result +="\n";
2993   
2994   Result += "Matrix of Inertia :\n     ";
2995   Result += TCollection_AsciiString(I(1,1));
2996   Result += " " ;
2997   Result += TCollection_AsciiString(I(1,2));
2998   Result += " " ;
2999   Result += TCollection_AsciiString(I(1,3));
3000   Result += "\n     " ;
3001   Result += TCollection_AsciiString(I(2,1));
3002   Result += " " ;
3003   Result += TCollection_AsciiString(I(2,2));
3004   Result += " " ;
3005   Result += TCollection_AsciiString(I(2,3));
3006   Result += "\n     " ;
3007   Result += TCollection_AsciiString(I(3,1));
3008   Result += " " ;
3009   Result += TCollection_AsciiString(I(3,2));
3010   Result += " " ;
3011   Result += TCollection_AsciiString(I(3,3));
3012   Result += "\n" ;
3013
3014
3015   Message = "\
3016                 \n\
3017 TColgp_Array1OfPnt Points1(1,4);\n\
3018 Points1.SetValue(1,gp_Pnt(0,0,0));\n\
3019 Points1.SetValue(2,gp_Pnt(2,1,0));\n\
3020 Points1.SetValue(3,gp_Pnt(4,0,0));\n\
3021 Points1.SetValue(4,gp_Pnt(6,2,0));\n\
3022 GeomAPI_PointsToBSpline PTBS1(Points1);\n\
3023 Handle(Geom_BSplineCurve) BSC1 = PTBS1.Curve();\n\
3024 TopoDS_Shape S = BRepBuilderAPI_MakeEdge(BSC1).Edge();\n\
3025 GProp_GProps System;\n\
3026 BRepGProp::LinearProperties(S,System);\n\
3027 gp_Pnt G = System.CentreOfMass ();\n\
3028 Standard_Real Length = System.Mass();\n\
3029 gp_Mat I = System.MatrixOfInertia();\n\
3030 \n";
3031 }
3032
3033 //===============================================================
3034 // Function name: SurfaceProp
3035 //===============================================================
3036  void SamplesTopologyPackage::SurfaceProp(const Handle(AIS_InteractiveContext)& aContext,
3037                                           TCollection_AsciiString& Message,
3038                                           TCollection_AsciiString& Result) 
3039 {
3040   aContext->EraseAll(Standard_False);
3041
3042   TColgp_Array1OfPnt Pnts1(1,3);
3043   TColgp_Array1OfPnt Pnts2(1,3);
3044   TColgp_Array1OfPnt Pnts3(1,3);
3045   TColgp_Array1OfPnt Pnts4(1,3);
3046
3047   Pnts1(1) = gp_Pnt(0,0,0);
3048   Pnts1(2) = gp_Pnt(5,0,0);
3049   Pnts1(3) = gp_Pnt(10,10,0);
3050
3051   Pnts2(1) = gp_Pnt(10,10,0);
3052   Pnts2(2) = gp_Pnt(5,12,4);
3053   Pnts2(3) = gp_Pnt(0,15,10);
3054
3055   Pnts3(1) = gp_Pnt(0,15,10);
3056   Pnts3(2) = gp_Pnt(-12,10,11);
3057   Pnts3(3) = gp_Pnt(-10,5,13);
3058
3059   Pnts4(1) = gp_Pnt(-10,5,13);
3060   Pnts4(2) = gp_Pnt(-2,-2,2);
3061   Pnts4(3) = gp_Pnt(0,0,0);
3062   
3063   GeomAPI_PointsToBSpline PTBS1(Pnts1);
3064   GeomAPI_PointsToBSpline PTBS2(Pnts2);
3065   GeomAPI_PointsToBSpline PTBS3(Pnts3);
3066   GeomAPI_PointsToBSpline PTBS4(Pnts4);
3067   Handle(Geom_BSplineCurve) C1 = PTBS1.Curve();
3068   Handle(Geom_BSplineCurve) C2 = PTBS2.Curve();
3069   Handle(Geom_BSplineCurve) C3 = PTBS3.Curve();
3070   Handle(Geom_BSplineCurve) C4 = PTBS4.Curve();
3071   
3072   GeomFill_BSplineCurves fill; 
3073   fill.Init(C1,C2,C3,C4,GeomFill_CoonsStyle);
3074   Handle(Geom_BSplineSurface) BSS = fill.Surface();
3075   
3076   TopoDS_Shape S = BRepBuilderAPI_MakeFace(BSS).Face();
3077   
3078   Handle(AIS_Shape) ais1 = new AIS_Shape(S);
3079   aContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); 
3080   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);   
3081   aContext->Display(ais1);
3082
3083
3084   GProp_GProps System;
3085   BRepGProp::SurfaceProperties(S,System);
3086   gp_Pnt G = System.CentreOfMass ();
3087   Standard_Real Area = System.Mass();
3088   gp_Mat I = System.MatrixOfInertia();
3089
3090   Result = "Area Of the Face =";
3091   Result += Area;
3092   Result += "\nCenterOfMass : \n   X=";
3093   Result += TCollection_AsciiString(G.X());
3094   Result += " Y=";
3095   Result += TCollection_AsciiString(G.Y());
3096   Result += " Z=";
3097   Result += TCollection_AsciiString(G.Z());
3098   Result +="\n";
3099   
3100   Result += "Matrix of Inertia :\n     ";
3101   Result += TCollection_AsciiString(I(1,1));
3102   Result += " " ;
3103   Result += TCollection_AsciiString(I(1,2));
3104   Result += " " ;
3105   Result += TCollection_AsciiString(I(1,3));
3106   Result += "\n     " ;
3107   Result += TCollection_AsciiString(I(2,1));
3108   Result += " " ;
3109   Result += TCollection_AsciiString(I(2,2));
3110   Result += " " ;
3111   Result += TCollection_AsciiString(I(2,3));
3112   Result += "\n     " ;
3113   Result += TCollection_AsciiString(I(3,1));
3114   Result += " " ;
3115   Result += TCollection_AsciiString(I(3,2));
3116   Result += " " ;
3117   Result += TCollection_AsciiString(I(3,3));
3118   Result += "\n" ;
3119
3120
3121   Message = "\
3122                 \n\
3123 TopoDS_Shape S = BRepBuilderAPI_MakeFace(BSplineSurf).Face();\n\
3124 GProp_GProps System;\n\
3125 BRepGProp::SurfaceProperties(S,System);\n\
3126 gp_Pnt G = System.CentreOfMass ();\n\
3127 Standard_Real Area = System.Mass();\n\
3128 gp_Mat I = System.MatrixOfInertia();\n\
3129 \n";
3130 }
3131
3132 //===============================================================
3133 // Function name: VolumeProp
3134 //===============================================================
3135  void SamplesTopologyPackage::VolumeProp(const Handle(AIS_InteractiveContext)& aContext,
3136                                          TCollection_AsciiString& Message,
3137                                          TCollection_AsciiString& Result) 
3138 {
3139   aContext->EraseAll(Standard_False);
3140   TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
3141   Handle(AIS_Shape) ais1 = new AIS_Shape(S);
3142   aContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); 
3143   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);   
3144   aContext->Display(ais1);
3145
3146
3147   GProp_GProps System;
3148   BRepGProp::VolumeProperties(S,System);
3149   gp_Pnt G = System.CentreOfMass ();
3150   Standard_Real Volume = System.Mass();
3151   gp_Mat I = System.MatrixOfInertia();
3152   
3153   Result = "Volume Of all the Shape =";
3154   Result += Volume;
3155   Result += "\nCenterOfMass : \n   X=";
3156   Result += TCollection_AsciiString(G.X());
3157   Result += " Y=";
3158   Result += TCollection_AsciiString(G.Y());
3159   Result += " Z=";
3160   Result += TCollection_AsciiString(G.Z());
3161   Result +="\n";
3162   
3163   Result += "Matrix of Inertia :\n     ";
3164   Result += TCollection_AsciiString(I(1,1));
3165   Result += " " ;
3166   Result += TCollection_AsciiString(I(1,2));
3167   Result += " " ;
3168   Result += TCollection_AsciiString(I(1,3));
3169   Result += "\n     " ;
3170   Result += TCollection_AsciiString(I(2,1));
3171   Result += " " ;
3172   Result += TCollection_AsciiString(I(2,2));
3173   Result += " " ;
3174   Result += TCollection_AsciiString(I(2,3));
3175   Result += "\n     " ;
3176   Result += TCollection_AsciiString(I(3,1));
3177   Result += " " ;
3178   Result += TCollection_AsciiString(I(3,2));
3179   Result += " " ;
3180   Result += TCollection_AsciiString(I(3,3));
3181   Result += "\n" ;
3182   
3183
3184   Message = "\
3185                 \n\
3186 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);;\n\
3187 GProp_GProps System;\n\
3188 BRepGProp::VolumeProperties(S,System);\n\
3189 gp_Pnt G = System.CentreOfMass ();\n\
3190 Standard_Real Volume = System.Mass();\n\
3191 gp_Mat I = System.MatrixOfInertia();\n\
3192 \n";
3193 }
3194
3195
3196 //======================================================================
3197 //=                                                                    =
3198 //=                      Topology  Transformations                     =
3199 //=                                                                    =
3200 //======================================================================
3201
3202 //===============================================================
3203 // Function name: Mirror
3204 //===============================================================
3205  void SamplesTopologyPackage::Mirror(const Handle(AIS_InteractiveContext)& aContext,
3206                                      TCollection_AsciiString& Message) 
3207 {
3208   aContext->EraseAll(Standard_False);
3209
3210   TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape(); 
3211   Handle(AIS_Shape) ais1 = new AIS_Shape(S);
3212   aContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); 
3213   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);   
3214   aContext->Display(ais1,Standard_False);
3215   gp_Trsf theTransformation;
3216   gp_Pnt PntCenterOfTheTransformation(110,60,60);
3217   Handle(AIS_Point) aispnt = new AIS_Point(new Geom_CartesianPoint(PntCenterOfTheTransformation));
3218   aContext->Display(aispnt);
3219   theTransformation.SetMirror(PntCenterOfTheTransformation);
3220   BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
3221   TopoDS_Shape S2 = myBRepTransformation.Shape();
3222   Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
3223   aContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False); 
3224   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);   
3225   aContext->Display(ais2);
3226
3227   Message = "\
3228 \n\
3229 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
3230 gp_Trsf theTransformation; \n\
3231 gp_Pnt PntCenterOfTheTransformation(110,60,60); \n\
3232 theTransformation.SetMirror(PntCenterOfTheTransformation);\n\
3233 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
3234 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();   \n";
3235 }
3236
3237 //===============================================================
3238 // Function name: Mirroraxis
3239 //===============================================================
3240  void SamplesTopologyPackage::Mirroraxis(const Handle(AIS_InteractiveContext)& aContext,
3241                                          TCollection_AsciiString& Message) 
3242 {
3243   aContext->EraseAll(Standard_False);
3244   
3245   TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape(); 
3246   Handle(AIS_Shape) ais1 = new AIS_Shape(S);
3247   aContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); 
3248   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);   
3249   aContext->Display(ais1,Standard_False);
3250   gp_Trsf theTransformation;
3251   gp_Ax1 axe = gp_Ax1(gp_Pnt(110,60,60),gp_Dir(0.,1.,0.));
3252   Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
3253   Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
3254   aContext->Display(ax1);
3255   theTransformation.SetMirror(axe);
3256   BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
3257   TopoDS_Shape S2 = myBRepTransformation.Shape();
3258   Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
3259   aContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False); 
3260   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);   
3261   aContext->Display(ais2);
3262
3263   Message = "\
3264 \n\
3265 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
3266 gp_Trsf theTransformation; \n\
3267 gp_Ax1 Axis = gp_Ax1(gp_Pnt(110,60,60),gp_Dir(0.,1.,0.)); \n\
3268 theTransformation.SetMirror(Axis);\n\
3269 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
3270 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();   \n";
3271 }
3272
3273 //===============================================================
3274 // Function name: Rotate
3275 //===============================================================
3276  void SamplesTopologyPackage::Rotate(const Handle(AIS_InteractiveContext)& aContext,
3277                                      TCollection_AsciiString& Message) 
3278 {
3279   aContext->EraseAll(Standard_False);
3280   
3281   TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape(); 
3282   Handle(AIS_Shape) ais1 = new AIS_Shape(S);
3283   aContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False); 
3284   aContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);   
3285   aContext->Display(ais1,Standard_False);
3286   gp_Trsf theTransformation;
3287   gp_Ax1 axe = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.));
3288   Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
3289   Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
3290   aContext->Display(ax1);
3291   theTransformation.SetRotation(axe,30*PI/180);
3292   BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
3293   TopoDS_Shape S2 = myBRepTransformation.Shape();
3294   Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
3295   aContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False); 
3296   aContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);   
3297   aContext->Display(ais2);
3298   
3299   Message = "\
3300 \n\
3301 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
3302 gp_Trsf theTransformation; \n\
3303 gp_Ax1 Axis = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.)); \n\
3304 theTransformation.SetRotation(Axis,30*PI/180); // Rotation of 30 degrees \n\
3305 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
3306 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();   \n";