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