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 <Adaptor3d_CurveOnSurface.hxx>
16 #include <AIS_ColoredShape.hxx>
17 #include <AIS_ListOfInteractive.hxx>
18 #include <AIS_ListIteratorOfListOfInteractive.hxx>
19 #include <TColStd_Array2OfReal.hxx>
20 #include <OCC_MainFrame.h>
21 #include <BRepPrimAPI_MakeCylinder.hxx>
22 #include <TopExp_Explorer.hxx>
23 #include <Geom_Plane.hxx>
24 #include <BRepTools.hxx>
25 
26 static Handle(AIS_Shape) AIS1;
27 static TopoDS_Face THE_F1, THE_F2;
28 static TopoDS_Edge THE_E1, THE_E2;
29 
30 /////////////////////////////////////////////////////////////////////////////
31 // CModelingDoc
32 
IMPLEMENT_DYNCREATE(CModelingDoc,CDocument)33 IMPLEMENT_DYNCREATE(CModelingDoc, CDocument)
34 
35 BEGIN_MESSAGE_MAP(CModelingDoc, OCC_3dBaseDoc)
36 	//{{AFX_MSG_MAP(CModelingDoc)
37 	ON_COMMAND(ID_MIRROR, OnMirror)
38 	ON_COMMAND(ID_MIRRORAXIS, OnMirroraxis)
39 	ON_COMMAND(ID_ROTATE, OnRotate)
40 	ON_COMMAND(ID_SCALE, OnScale)
41 	ON_COMMAND(ID_TRANSLATION, OnTranslation)
42 	ON_COMMAND(ID_DISPLACEMENT, OnDisplacement)
43 	ON_COMMAND(ID_DEFORM, OnDeform)
44 	ON_COMMAND(ID_BOX, OnBox)
45 	ON_COMMAND(ID_Cylinder, OnCylinder)
46 	ON_COMMAND(ID_CONE, OnCone)
47 	ON_COMMAND(ID_SPHERE, OnSphere)
48 	ON_COMMAND(ID_TORUS, OnTorus)
49 	ON_COMMAND(ID_WEDGE, OnWedge)
50 	ON_COMMAND(ID_PRISM, OnPrism)
51 	ON_COMMAND(ID_REVOL, OnRevol)
52 	ON_COMMAND(ID_PIPE, OnPipe)
53 	ON_COMMAND(ID_THRU, OnThru)
54 	ON_COMMAND(ID_EVOLVED, OnEvolved)
55 	ON_COMMAND(ID_DRAFT, OnDraft)
56 	ON_COMMAND(ID_CUT, OnCut)
57 	ON_COMMAND(ID_FUSE, OnFuse)
58 	ON_COMMAND(ID_SECTION, OnSection)
59 	ON_COMMAND(ID_COMMON, OnCommon)
60 	ON_COMMAND(ID_PSECTION, OnPsection)
61 	ON_COMMAND(ID_BLEND, OnBlend)
62 	ON_COMMAND(ID_CHAMF, OnChamf)
63 	ON_COMMAND(ID_EVOLVEDBLEND, OnEvolvedblend)
64 	ON_COMMAND(ID_PRISM_LOCAL, OnPrismLocal)
65 	ON_COMMAND(ID_REVOL_LOCAL, OnRevolLocal)
66 	ON_COMMAND(ID_GLUE_LOCAL, OnGlueLocal)
67  	ON_COMMAND(ID_DPRISM_LOCAL, OnDprismLocal)
68  	ON_COMMAND(ID_Pipe_LOCAL, OnPipeLocal)
69 	ON_COMMAND(ID_LINEAR_LOCAL, OnLinearLocal)
70 	ON_COMMAND(ID_SPLIT_LOCAL, OnSplitLocal)
71 	ON_COMMAND(ID_THICK_LOCAL, OnThickLocal)
72 	ON_COMMAND(ID_OFFSET_LOCAL, OnOffsetLocal)
73 	ON_COMMAND(ID_VERTEX, OnVertex)
74 	ON_COMMAND(ID_EDGE, OnEdge)
75 	ON_COMMAND(ID_WIRE, OnWire)
76 	ON_COMMAND(ID_FACE, OnFace)
77 	ON_COMMAND(ID_SHELL, OnShell)
78 	ON_COMMAND(ID_COMPOUND, OnCompound)
79 	ON_COMMAND(ID_GEOMETRIE, OnGeometrie)
80 	ON_COMMAND(ID_SEWING, OnSewing)
81 	ON_COMMAND(ID_EXPLORER, OnExplorer)
82 	ON_COMMAND(ID_BUILDER, OnBuilder)
83 	ON_COMMAND(ID_VALID, OnValid)
84 	ON_COMMAND(ID_LINEAR, OnLinear)
85 	ON_COMMAND(ID_VOLUME, OnVolume)
86 	ON_COMMAND(ID_SURFACE, OnSurface)
87 	ON_COMMAND(ID_BUTTON_FILL, OnButtonFill)
88 	ON_COMMAND(ID_STOP_STOP, OnStopStop)
89 	ON_COMMAND(ID_FILLWITHTANG, OnFillwithtang)
90 	//}}AFX_MSG_MAP
91 END_MESSAGE_MAP()
92 
93 /////////////////////////////////////////////////////////////////////////////
94 // CModelingDoc construction/destruction
95 
96 CModelingDoc::CModelingDoc()
97 {
98 	myAISContext->SetDisplayMode(AIS_Shaded,Standard_False);
99 }
100 
~CModelingDoc()101 CModelingDoc::~CModelingDoc()
102 {
103 }
104 
OnMirror()105 void CModelingDoc::OnMirror()
106 {
107 	AIS_ListOfInteractive aList;
108 	myAISContext->DisplayedObjects(aList);
109 	AIS_ListIteratorOfListOfInteractive aListIterator;
110 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
111 		myAISContext->Remove (aListIterator.Value(), Standard_False);
112 	}
113 	TopoDS_Shape S = BRepPrimAPI_MakeWedge (60.,100.,80.,20.).Shape();
114 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
115 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
116 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
117 	myAISContext->Display(ais1,Standard_False);
118 	gp_Trsf theTransformation;
119 	gp_Pnt PntCenterOfTheTransformation(110,60,60);
120 	Handle(AIS_Point) aispnt = new AIS_Point(new Geom_CartesianPoint(PntCenterOfTheTransformation));
121 	myAISContext->Display(aispnt,Standard_False);
122 	theTransformation.SetMirror(PntCenterOfTheTransformation);
123 	BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
124 	TopoDS_Shape S2 = myBRepTransformation.Shape();
125 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
126 	myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
127 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
128 	myAISContext->Display(ais2,Standard_False);
129 	Fit();
130     TCollection_AsciiString Message ("\
131 \n\
132 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
133 gp_Trsf theTransformation; \n\
134 gp_Pnt PntCenterOfTheTransformation(110,60,60); \n\
135 theTransformation.SetMirror(PntCenterOfTheTransformation);\n\
136 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
137 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();	\n");
138 	PocessTextInDialog("Transform a Shape with Mirror and One point.", Message);
139 
140 }
141 
OnMirroraxis()142 void CModelingDoc::OnMirroraxis()
143 {
144 	AIS_ListOfInteractive aList;
145 	myAISContext->DisplayedObjects(aList);
146 	AIS_ListIteratorOfListOfInteractive aListIterator;
147 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
148 		myAISContext->Remove (aListIterator.Value(), Standard_False);
149 	}
150 	TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
151 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
152 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
153 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
154 	myAISContext->Display(ais1,Standard_False);
155 	gp_Trsf theTransformation;
156 	gp_Ax1 axe = gp_Ax1(gp_Pnt(110,60,60),gp_Dir(0.,1.,0.));
157 	Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
158 	Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
159 	myAISContext->Display(ax1,Standard_False);
160 	theTransformation.SetMirror(axe);
161 	BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
162 	TopoDS_Shape S2 = myBRepTransformation.Shape();
163 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
164 	myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
165 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
166 	myAISContext->Display(ais2,Standard_False);
167 	Fit();
168 
169     TCollection_AsciiString Message ("\
170 \n\
171 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
172 gp_Trsf theTransformation; \n\
173 gp_Ax1 Axis = gp_Ax1(gp_Pnt(110,60,60),gp_Dir(0.,1.,0.)); \n\
174 theTransformation.SetMirror(Axis);\n\
175 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
176 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();	\n");
177 
178 	PocessTextInDialog("Transform a Shape with Mirror and One axis.", Message);
179 
180 }
181 
182 
OnRotate()183 void CModelingDoc::OnRotate()
184 {
185 	AIS_ListOfInteractive aList;
186 	myAISContext->DisplayedObjects(aList);
187 	AIS_ListIteratorOfListOfInteractive aListIterator;
188 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
189 		myAISContext->Remove (aListIterator.Value(), Standard_False);
190 	}
191 	TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
192 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
193 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
194 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
195 	myAISContext->Display(ais1,Standard_False);
196 	gp_Trsf theTransformation;
197 	gp_Ax1 axe = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.));
198 	Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
199 	Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
200 	myAISContext->Display(ax1,Standard_False);
201 	theTransformation.SetRotation(axe,30*M_PI/180);
202 	BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
203 	TopoDS_Shape S2 = myBRepTransformation.Shape();
204 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
205 	myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
206 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
207 	myAISContext->Display(ais2,Standard_False);
208 	Fit();
209 
210     TCollection_AsciiString Message ("\
211 \n\
212 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
213 gp_Trsf theTransformation; \n\
214 gp_Ax1 Axis = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.)); \n\
215 theTransformation.SetRotation(Axis,30*PI/180); // Rotation of 30 degrees \n\
216 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
217 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();	\n");
218 
219 	PocessTextInDialog("Transform a Shape with Rotation.", Message);
220 
221 }
222 
OnScale()223 void CModelingDoc::OnScale()
224 {
225 	AIS_ListOfInteractive aList;
226 	myAISContext->DisplayedObjects(aList);
227 	AIS_ListIteratorOfListOfInteractive aListIterator;
228 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
229 		myAISContext->Remove (aListIterator.Value(), Standard_False);
230 	}
231 	TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
232 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
233 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
234 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
235 	myAISContext->Display(ais1,Standard_False);
236 	gp_Trsf theTransformation;
237 	gp_Pnt theCenterOfScale(200,60,60);
238 	Handle(AIS_Point) aispnt = new AIS_Point(new Geom_CartesianPoint(theCenterOfScale));
239 
240 	myAISContext->Display(aispnt,Standard_False);
241 	theTransformation.SetScale(theCenterOfScale,0.5);
242 	BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
243 	TopoDS_Shape S2 = myBRepTransformation.Shape();
244 
245 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
246 	myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
247 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
248 	myAISContext->Display(ais2,Standard_False);
249 	Fit();
250 
251     TCollection_AsciiString Message ("\
252 \n\
253 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
254 gp_Trsf theTransformation; \n\
255 gp_Pnt theCenterOfScale(200,60,60); \n\
256 theTransformation.SetScale(theCenterOfScale,0.5); // Scale : value = 0.5 \n\
257 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
258 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();	\n");
259 
260 	PocessTextInDialog("Scale a Shape with One point.", Message);
261 
262 
263 }
264 
265 
266 
OnTranslation()267 void CModelingDoc::OnTranslation()
268 {
269 	AIS_ListOfInteractive aList;
270 	myAISContext->DisplayedObjects(aList);
271 	AIS_ListIteratorOfListOfInteractive aListIterator;
272 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
273 		myAISContext->Remove (aListIterator.Value(), Standard_False);
274 	}
275 	TopoDS_Shape S = BRepPrimAPI_MakeWedge(6.,10.,8.,2.).Shape();
276 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
277 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
278 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
279 	myAISContext->Display(ais1,Standard_False);
280 	gp_Trsf theTransformation;
281 	gp_Vec theVectorOfTranslation(-6,-6,6);
282 
283 	Handle(ISession_Direction) aDirection1 = new ISession_Direction(gp_Pnt(0,0,0),theVectorOfTranslation);
284 	myAISContext->Display(aDirection1,Standard_False);
285 
286 	theTransformation.SetTranslation(theVectorOfTranslation);
287 	BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
288 	TopoDS_Shape S2 = myBRepTransformation.Shape();
289 
290 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
291 	myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
292 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
293 	myAISContext->Display(ais2,Standard_False);
294 
295 	Fit();
296 
297     TCollection_AsciiString Message ("\
298 \n\
299 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(6.,10.,8.,2.); \n\
300 gp_Trsf theTransformation; \n\
301 gp_Vec theVectorOfTranslation(6,6,6); \n\
302 theTransformation.SetTranslation(theVectorOfTranslation); \n\
303 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
304 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();	\n");
305 
306 	PocessTextInDialog("Translate a Shape with One vector.", Message);
307 
308 }
309 
OnDisplacement()310 void CModelingDoc::OnDisplacement()
311 {
312 	AIS_ListOfInteractive aList;
313 	myAISContext->DisplayedObjects(aList);
314 	AIS_ListIteratorOfListOfInteractive aListIterator;
315 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
316 		myAISContext->Remove (aListIterator.Value(), Standard_False);
317 	}
318   TopoDS_Shape S = BRepPrimAPI_MakeWedge(60., 100., 80., 20.).Shape();
319 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
320 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
321 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
322 	myAISContext->Display(ais1,Standard_False);
323 	gp_Trsf theTransformation;
324 
325 	gp_Ax3 ax3_1(gp_Pnt(0,0,0),gp_Dir(0,0,1));
326 	gp_Ax3 ax3_2(gp_Pnt(60,60,60),gp_Dir(1,1,1));
327 
328 	theTransformation.SetDisplacement(ax3_1,ax3_2);
329 	BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
330 	TopoDS_Shape TransformedShape = myBRepTransformation.Shape();
331 	Handle(AIS_Shape) ais2 = new AIS_Shape(TransformedShape);
332 	myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
333 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
334 	myAISContext->Display(ais2,Standard_False);
335 	Fit();
336     TCollection_AsciiString Message ("\
337 \n\
338 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
339 gp_Trsf theTransformation; \n\
340 gp_Ax3 ax3_1(gp_Pnt(0,0,0),gp_Dir(0,0,1)); \n\
341 gp_Ax3 ax3_2(gp_Pnt(60,60,60),gp_Dir(1,1,1)); \n\
342 theTransformation.SetDisplacement(ax3_1,ax3_2); \n\
343 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
344 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();	\n");
345 
346 	PocessTextInDialog("Displace a Shape with Two coordinate systems.", Message);
347 
348 
349 }
350 
351 
OnDeform()352 void CModelingDoc::OnDeform()
353 {
354 	AIS_ListOfInteractive aList;
355 	myAISContext->DisplayedObjects(aList);
356 	AIS_ListIteratorOfListOfInteractive aListIterator;
357 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
358 		myAISContext->Remove (aListIterator.Value(), Standard_False);
359 	}
360   TopoDS_Shape S = BRepPrimAPI_MakeWedge(60., 100., 80., 20.).Shape();
361 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
362 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
363 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
364 	myAISContext->Display(ais1,Standard_False);
365 
366 	gp_GTrsf theTransformation;
367 	gp_Mat rot(1, 0, 0, 0, 0.5, 0, 0, 0, 1.5);
368 	theTransformation.SetVectorialPart(rot);
369 	theTransformation.SetTranslationPart(gp_XYZ(5,5,5));
370 
371 	BRepBuilderAPI_GTransform myBRepTransformation(S,theTransformation);
372 	TopoDS_Shape S2 = myBRepTransformation.Shape();
373 
374 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
375 	myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
376 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
377 	myAISContext->Display(ais2,Standard_False);
378 	Fit();
379     TCollection_AsciiString Message ("\
380 \n\
381 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
382 gp_GTrsf theTransformation; \n\
383 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\
384 theTransformation.SetVectorialPart(rot); \n\
385 theTransformation.SetTranslationPart(gp_XYZ(5,5,5)); \n\
386 BRepBuilderAPI_GTransform myBRepGTransformation(S,theTransformation);\n\
387 TopoDS_Shape TransformedShape = myBRepGTransformation.Shape();	\n");
388 
389 	PocessTextInDialog("Deform a Shape with One matrix of deformation and One translation.", Message);
390 }
391 
392 /* =================================================================================
393    ====================   P R I M I T I V E S   ====================================
394    ================================================================================= */
395 
OnBox()396 void CModelingDoc::OnBox()
397 {
398 	AIS_ListOfInteractive aList;
399 	myAISContext->DisplayedObjects(aList);
400 	AIS_ListIteratorOfListOfInteractive aListIterator;
401 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
402 		myAISContext->Remove (aListIterator.Value(), Standard_False);
403 	}
404   TopoDS_Shape B1 = BRepPrimAPI_MakeBox(200., 150., 100.).Shape();
405 	Handle(AIS_Shape) aBox1 = new AIS_Shape(B1);
406 	myAISContext->SetMaterial(aBox1,Graphic3d_NOM_PLASTIC,Standard_False);
407 	myAISContext->SetColor(aBox1,Quantity_NOC_GREEN,Standard_False);
408 	myAISContext->Display(aBox1,Standard_False);
409 	TopoDS_Shape B2 = BRepPrimAPI_MakeBox (gp_Ax2(gp_Pnt(-200.,-80.,-70.),
410                                          gp_Dir(1.,2.,1.)),
411                                          80., 90., 120.).Shape();
412 	Handle(AIS_Shape) aBox2 = new AIS_Shape(B2);
413 	myAISContext->SetMaterial(aBox2,Graphic3d_NOM_PLASTIC,Standard_False);
414 	myAISContext->SetColor(aBox2,Quantity_NOC_RED,Standard_False);
415 	myAISContext->Display(aBox2,Standard_False);
416 	Fit();
417     TCollection_AsciiString Message ("\
418 		\n\
419 TopoDS_Shape B1 = BRepPrimAPI_MakeBox (200.,150.,100.); \n\
420 TopoDS_Shape B2 = BRepPrimAPI_MakeBox (gp_Ax2(gp_Pnt(-200.,-80.,-70.), \n\
421                                           gp_Dir(1.,2.,1.)), \n\
422                                    80.,90.,120.); \n\
423 		\n");
424 	PocessTextInDialog("Make a topological box", Message);
425 }
426 
OnCylinder()427 void CModelingDoc::OnCylinder()
428 {
429 	AIS_ListOfInteractive aList;
430 	myAISContext->DisplayedObjects(aList);
431 	AIS_ListIteratorOfListOfInteractive aListIterator;
432 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
433 		myAISContext->Remove (aListIterator.Value(), Standard_False);
434 	}
435 
436   TopoDS_Shape C1 = BRepPrimAPI_MakeCylinder(50., 200.).Shape();
437 	Handle(AIS_Shape) aCyl1 = new AIS_Shape(C1);
438 	myAISContext->SetMaterial(aCyl1,Graphic3d_NOM_PLASTIC,Standard_False);
439 	myAISContext->SetColor(aCyl1,Quantity_NOC_RED,Standard_False);
440 	myAISContext->Display(aCyl1,Standard_False);
441 	TopoDS_Shape C2 = BRepPrimAPI_MakeCylinder (gp_Ax2(gp_Pnt(200.,200.,0.),
442 												                      gp_Dir(0.,0.,1.)),
443                                               40., 110., 210.*M_PI / 180).Shape();
444 	Handle(AIS_Shape) aCyl2 = new AIS_Shape(C2);
445 	myAISContext->SetMaterial(aCyl2,Graphic3d_NOM_PLASTIC,Standard_False);
446 	myAISContext->SetColor(aCyl2,Quantity_NOC_MATRABLUE,Standard_False);
447 	myAISContext->Display(aCyl2,Standard_False);
448 	Fit();
449 
450     TCollection_AsciiString Message ("\
451 		\n\
452 TopoDS_Shape C1 = BRepPrimAPI_MakeCylinder (50.,200.); \n\
453 TopoDS_Shape C2 = BRepPrimAPI_MakeCylinder (gp_Ax2(gp_Pnt(200.,200.,0.), \n\
454                                         gp_Dir(0.,0.,1.)), \n\
455                                         40.,110.,210.*PI180.); \n\
456 		\n");
457 	PocessTextInDialog("Make a cylinder", Message);
458 }
459 
460 
OnCone()461 void CModelingDoc::OnCone()
462 {
463 	AIS_ListOfInteractive aList;
464 	myAISContext->DisplayedObjects(aList);
465 	AIS_ListIteratorOfListOfInteractive aListIterator;
466 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
467 		myAISContext->Remove (aListIterator.Value(), Standard_False);
468 	}
469   TopoDS_Shape C1 = BRepPrimAPI_MakeCone(50., 25., 200.).Shape();
470 	Handle(AIS_Shape) ais1 = new AIS_Shape(C1);
471 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
472 	myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
473 	myAISContext->Display(ais1,Standard_False);
474 	TopoDS_Shape C2 = BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(100.,100.,0.),
475 												                 gp_Dir(0.,0.,1.)),
476                                          60., 0., 150., 210.*M_PI / 180).Shape();
477 	Handle(AIS_Shape) ais2 = new AIS_Shape(C2);
478 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
479 	myAISContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False);
480 	myAISContext->Display(ais2,Standard_False);
481 	Fit();
482 
483     TCollection_AsciiString Message ("\
484 		\n\
485 TopoDS_Shape C1 = BRepPrimAPI_MakeCone (50.,25.,200.); \n\
486 TopoDS_Shape C2 = BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(100.,100.,0.), \n\
487                                           gp_Dir(0.,0.,1.)), \n\
488                                    605.,0.,150.,210.*PI180); \n\
489 		\n");
490 	PocessTextInDialog("Make a cone", Message);
491 }
492 
OnSphere()493 void CModelingDoc::OnSphere()
494 {
495 	AIS_ListOfInteractive aList;
496 	myAISContext->DisplayedObjects(aList);
497 	AIS_ListIteratorOfListOfInteractive aListIterator;
498 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
499 		myAISContext->Remove (aListIterator.Value(), Standard_False);
500 	}
501 
502   TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(gp_Pnt(-200., -250., 0.), 80.).Shape();
503 	Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
504 	myAISContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False);
505 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
506 	myAISContext->Display(ais1,Standard_False);
507   TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(100., 120.*M_PI / 180).Shape();
508 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
509 	myAISContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False);
510 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
511 	myAISContext->Display(ais2,Standard_False);
512 	TopoDS_Shape S3 = BRepPrimAPI_MakeSphere(gp_Pnt(200.,250.,0.),100.,
513                                            -60.*M_PI / 180, 60.*M_PI / 180).Shape();
514 	Handle(AIS_Shape) ais3 = new AIS_Shape(S3);
515 	myAISContext->SetColor(ais3,Quantity_NOC_RED,Standard_False);
516 	myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
517 	myAISContext->Display(ais3,Standard_False);
518 	TopoDS_Shape S4 = BRepPrimAPI_MakeSphere(gp_Pnt(0.,0.,-300.),150.,
519                                            -45.*M_PI / 180, 45.*M_PI / 180, 45.*M_PI / 180).Shape();
520 	Handle(AIS_Shape) ais4 = new AIS_Shape(S4);
521 	myAISContext->SetColor(ais4,Quantity_NOC_MATRABLUE,Standard_False);
522 	myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
523 	myAISContext->Display(ais4,Standard_False);
524 	Fit();
525 
526     TCollection_AsciiString Message ("\
527 		\n\
528 TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(gp_Pnt(-200.,-250.,0.),80.); \n\
529 TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(100.,120.*PI180); \n\
530 TopoDS_Shape S3 = BRepPrimAPI_MakeSphere(gp_Pnt(200.,250.,0.),100., \n\
531                                      -60.*PI180, 60.*PI180); \n\
532 TopoDS_Shape S4 = BRepPrimAPI_MakeSphere(gp_Pnt(0.,0.,-300.),150., \n\
533                                      -45.*PI180, 45.*PI180, 45.*PI180); \n\
534 		\n");
535 	PocessTextInDialog("Make a sphere", Message);
536 }
537 
OnTorus()538 void CModelingDoc::OnTorus()
539 {
540 	AIS_ListOfInteractive aList;
541 	myAISContext->DisplayedObjects(aList);
542 	AIS_ListIteratorOfListOfInteractive aListIterator;
543 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
544 		myAISContext->Remove (aListIterator.Value(), Standard_False);
545 	}
546 
547   TopoDS_Shape S1 = BRepPrimAPI_MakeTorus(60., 20.).Shape();
548 	Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
549 	myAISContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False);
550 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
551 	myAISContext->Display(ais1,Standard_False);
552 	TopoDS_Shape S2 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(1.,1.,1.)),
553                                           50., 20., 210.*M_PI / 180).Shape();
554 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
555 	myAISContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False);
556 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
557 	myAISContext->Display(ais2,Standard_False);
558 	TopoDS_Shape S3 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(-200.,-150.,-100),gp_Dir(0.,1.,0.)),
559                                           60., 20., -45.*M_PI / 180, 45.*M_PI / 180, 90.*M_PI / 180).Shape();
560 	Handle(AIS_Shape) ais3= new AIS_Shape(S3);
561 	myAISContext->SetColor(ais3,Quantity_NOC_CORAL,Standard_False);
562 	myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
563 	myAISContext->Display(ais3,Standard_False);
564 	Fit();
565 
566     TCollection_AsciiString Message ("\
567 		\n\
568 TopoDS_Shape S1 = BRepPrimAPI_MakeTorus(60.,20.); \n\
569 TopoDS_Shape S2 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(1.,1.,1.)), \n\
570                                     50.,20.,210.*PI180); \n\
571 TopoDS_Shape S3 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(-200.,-150.,-100),gp_Dir(0.,1.,0.)), \n\
572                                     60.,20.,-45.*PI180,45.*PI180,90.*PI180); \n\
573 		\n");
574 	PocessTextInDialog("Make a torus", Message);
575 }
576 
OnWedge()577 void CModelingDoc::OnWedge()
578 {
579 	AIS_ListOfInteractive aList;
580 	myAISContext->DisplayedObjects(aList);
581 	AIS_ListIteratorOfListOfInteractive aListIterator;
582 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
583 		myAISContext->Remove (aListIterator.Value(), Standard_False);
584 	}
585 
586   TopoDS_Shape S1 = BRepPrimAPI_MakeWedge(60., 100., 80., 20.).Shape();
587 	Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
588 	myAISContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False);
589 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
590 	myAISContext->Display(ais1,Standard_False);
591 	TopoDS_Shape S2 = BRepPrimAPI_MakeWedge(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(0.,0.,1.)),
592                                           60., 50., 80., 25., -10., 40., 70.).Shape();
593 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
594 	myAISContext->SetColor(ais2,Quantity_NOC_CORAL2,Standard_False);
595 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
596 	myAISContext->Display(ais2,Standard_False);
597 	Fit();
598 
599     TCollection_AsciiString Message ("\
600 		\n\
601 TopoDS_Shape S1 = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
602 TopoDS_Shape S2 = BRepPrimAPI_MakeWedge(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(0.,0.,1.)), \n\
603                                     60.,50.,80.,25.,-10.,40.,70.); \n\
604 		\n");
605 	PocessTextInDialog("Make a wedge", Message);
606 }
607 
OnPrism()608 void CModelingDoc::OnPrism()
609 {
610 	AIS_ListOfInteractive aList;
611 	myAISContext->DisplayedObjects(aList);
612 	AIS_ListIteratorOfListOfInteractive aListIterator;
613 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
614 		myAISContext->Remove (aListIterator.Value(), Standard_False);
615 	}
616 
617 	TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.));
618 	Handle(AIS_Shape) ais1 = new AIS_Shape(V1);
619 	myAISContext->Display(ais1,Standard_False);
620 	TopoDS_Shape S1 = BRepPrimAPI_MakePrism(V1,gp_Vec(0.,0.,100.));
621 	Handle(AIS_Shape) ais2 = new AIS_Shape(S1);
622 	myAISContext->Display(ais2,Standard_False);
623 
624 	TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-150.,-150,0.), gp_Pnt(-50.,-50,0.));
625 	Handle(AIS_Shape) ais3 = new AIS_Shape(E);
626 	myAISContext->Display(ais3,Standard_False);
627 	TopoDS_Shape S2 = BRepPrimAPI_MakePrism(E,gp_Vec(0.,0.,100.));
628 	Handle(AIS_Shape) ais4 = new AIS_Shape(S2);
629 	myAISContext->SetColor(ais4,Quantity_NOC_CORAL2,Standard_False);
630 	myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
631 	myAISContext->Display(ais4,Standard_False);
632 
633 	TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.));
634 	TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.));
635 	TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.));
636 	TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3);
637 	TopoDS_Shape S3 = BRepPrimAPI_MakePrism(W,gp_Vec(0.,0.,100.));
638 	Handle(AIS_Shape) ais5 = new AIS_Shape(W);
639 	myAISContext->Display(ais5,Standard_False);
640 	Handle(AIS_Shape) ais6 = new AIS_Shape(S3);
641 	myAISContext->SetColor(ais6,Quantity_NOC_GREEN,Standard_False);
642 	myAISContext->SetMaterial(ais6,Graphic3d_NOM_PLASTIC,Standard_False);
643 	myAISContext->Display(ais6,Standard_False);
644 
645 	gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.);
646 	TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
647 	TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);
648 	TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc);
649 	Handle(AIS_Shape) ais7 = new AIS_Shape(F);
650 	myAISContext->Display(ais7,Standard_False);
651 	TopoDS_Shape S4 = BRepPrimAPI_MakePrism(F,gp_Vec(0.,0.,100.));
652 	Handle(AIS_Shape) ais8 = new AIS_Shape(S4);
653 	myAISContext->SetColor(ais8,Quantity_NOC_MATRABLUE,Standard_False);
654 	myAISContext->SetMaterial(ais8,Graphic3d_NOM_PLASTIC,Standard_False);
655 	myAISContext->Display(ais8,Standard_False);
656 	Fit();
657 
658     TCollection_AsciiString Message ("\
659 		\n\
660 --- Prism a vertex -> result is an edge --- \n\
661 \n\
662 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.)); \n\
663 TopoDS_Shape S1 = BRepBuilderAPI_MakePrism(V1,gp_Vec(0.,0.,100.)); \n\
664 \n\
665 --- Prism an edge -> result is a face --- \n\
666 \n\
667 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-150.,-150,0.), gp_Pnt(-50.,-50,0.)); \n\
668 TopoDS_Shape S2 = BRepPrimAPI_MakePrism(E,gp_Vec(0.,0.,100.)); \n\
669 \n\
670 --- Prism an wire -> result is a shell --- \n\
671 \n\
672 TopoDS_Edge E1 = BREpBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)); \n\
673 TopoDS_Edge E2 = BREpBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)); \n\
674 TopoDS_Edge E3 = BREpBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)); \n\
675 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3); \n\
676 TopoDS_Shape S3 = BRepPrimAPI_MakePrism(W,gp_Vec(0.,0.,100.)); \n\
677 \n\
678 --- Prism a face or a shell -> result is a solid --- \n\
679 \n\
680 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.gp_Dir(0.,0.,1.)), 80.); \n\
681 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c); \n\
682 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec); \n\
683 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp::XOY(),Wc); \n\
684 TopoDS_Shape S4 = BRepBuilderAPI_MakePrism(F,gp_Vec(0.,0.,100.)); \n\
685 		\n");
686 	PocessTextInDialog("Make a prism", Message);
687 }
688 
OnRevol()689 void CModelingDoc::OnRevol()
690 {
691 	AIS_ListOfInteractive aList;
692 	myAISContext->DisplayedObjects(aList);
693 	AIS_ListIteratorOfListOfInteractive aListIterator;
694 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
695 		myAISContext->Remove (aListIterator.Value(), Standard_False);
696 	}
697 
698 	TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.));
699 	Handle(AIS_Shape) ais1 = new AIS_Shape(V1);
700 	myAISContext->Display(ais1,Standard_False);
701 	gp_Ax1 axe = gp_Ax1(gp_Pnt(-170.,-170.,0.),gp_Dir(0.,0.,1.));
702 	Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
703 	Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
704 	myAISContext->Display(ax1,Standard_False);
705 	TopoDS_Shape S1 = BRepPrimAPI_MakeRevol(V1,axe);
706 	Handle(AIS_Shape) ais2 = new AIS_Shape(S1);
707 	myAISContext->Display(ais2,Standard_False);
708 
709 	TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-120.,-120,0.), gp_Pnt(-120.,-120,100.));
710 	Handle(AIS_Shape) ais3 = new AIS_Shape(E);
711 	myAISContext->Display(ais3,Standard_False);
712 	axe = gp_Ax1(gp_Pnt(-100.,-100.,0.),gp_Dir(0.,0.,1.));
713 	Handle(Geom_Axis1Placement) Gax2 = new Geom_Axis1Placement(axe);
714 	Handle (AIS_Axis) ax2 = new AIS_Axis(Gax2);
715 	myAISContext->Display(ax2,Standard_False);
716 	TopoDS_Shape S2 = BRepPrimAPI_MakeRevol(E,axe);
717 	Handle(AIS_Shape) ais4 = new AIS_Shape(S2);
718 	myAISContext->SetColor(ais4,Quantity_NOC_YELLOW,Standard_False);
719 	myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
720 	myAISContext->Display(ais4,Standard_False);
721 
722 	TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.));
723 	TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.));
724 	TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.));
725 	TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3);
726 	axe = gp_Ax1(gp_Pnt(0.,0.,30.),gp_Dir(0.,1.,0.));
727 	Handle(Geom_Axis1Placement) Gax3 = new Geom_Axis1Placement(axe);
728 	Handle (AIS_Axis) ax3 = new AIS_Axis(Gax3);
729 	myAISContext->Display(ax3,Standard_False);
730 	TopoDS_Shape S3 = BRepPrimAPI_MakeRevol(W,axe, 210.*M_PI/180);
731 	Handle(AIS_Shape) ais5 = new AIS_Shape(W);
732 	myAISContext->Display(ais5,Standard_False);
733 	Handle(AIS_Shape) ais6 = new AIS_Shape(S3);
734 	myAISContext->SetColor(ais6,Quantity_NOC_GREEN,Standard_False);
735 	myAISContext->SetMaterial(ais6,Graphic3d_NOM_PLASTIC,Standard_False);
736 	myAISContext->Display(ais6,Standard_False);
737 
738 	gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.);
739 	TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
740 	TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);
741 	TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc);
742 	axe = gp_Ax1(gp_Pnt(290,290.,0.),gp_Dir(0.,1,0.));
743 	Handle(Geom_Axis1Placement) Gax4 = new Geom_Axis1Placement(axe);
744 	Handle (AIS_Axis) ax4 = new AIS_Axis(Gax4);
745 	myAISContext->Display(ax4,Standard_False);
746 	TopoDS_Shape S4 = BRepPrimAPI_MakeRevol(F,axe, 90.*M_PI/180);
747 	Handle(AIS_Shape) ais8 = new AIS_Shape(S4);
748 	myAISContext->SetColor(ais8,Quantity_NOC_MATRABLUE,Standard_False);
749 	myAISContext->SetMaterial(ais8,Graphic3d_NOM_PLASTIC,Standard_False);
750 	myAISContext->Display(ais8,Standard_False);
751 	Fit();
752 
753 	TCollection_AsciiString Message ("\
754 		\n\
755 --- Revol of a vertex -> result is an edge --- \n\
756 \n\
757 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.)); \n\
758 gp_Ax1 axe = gp_Ax1(gp_Pnt(-170.,-170.,0.),gp_Dir(0.,0.,1.)); \n\
759 TopoDS_Shape S1 = BRepPrimAPI_MakeRevol(V1,axe); \n\
760 \n\
761 --- Revol of an edge -> result is a face --- \n\
762 \n\
763 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-120.,-120,0.), gp_Pnt(-120.,-120,100.)); \n\
764 axe = gp_Ax1(gp_Pnt(-100.,-100.,0.),gp_Dir(0.,0.,1.)); \n\
765 TopoDS_Shape S2 = BRepPrimAPI_MakeRevol(E,axe); \n\
766 \n\
767 --- Revol of a wire -> result is a shell --- \n\
768 \n\
769 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)); \n\
770 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)); \n\
771 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)); \n\
772 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3); \n\
773 axe = gp_Ax1(gp_Pnt(0.,0.,30.),gp_Dir(0.,1.,0.)); \n\
774 TopoDS_Shape S3 = BRepPrimAPI_MakeRevol(W,axe, 210.*PI180); \n\
775 \n\
776 --- Revol of a face -> result is a solid --- \n\
777 \n\
778 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.); \n\
779 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c); \n\
780 TopoDS_Wire Wc = BRepBuilderPI_MakeWire(Ec); \n\
781 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc); \n\
782 axe = gp_Ax1(gp_Pnt(290,290.,0.),gp_Dir(0.,1,0.)); \n\
783 TopoDS_Shape S4 = BRepPrimAPI_MakeRevol(F,axe, 90.*PI180); \n\
784 		\n");
785   PocessTextInDialog("Make a revol", Message);
786 }
787 
OnPipe()788 void CModelingDoc::OnPipe()
789 {
790 	AIS_ListOfInteractive aList;
791 	myAISContext->DisplayedObjects(aList);
792 	AIS_ListIteratorOfListOfInteractive aListIterator;
793 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
794 		myAISContext->Remove (aListIterator.Value(), Standard_False);
795 	}
796 
797 	TColgp_Array1OfPnt CurvePoles(1,4);
798 	gp_Pnt pt = gp_Pnt(0.,0.,0.);
799 	CurvePoles(1) = pt;
800 	pt = gp_Pnt(20.,50.,0.);
801 	CurvePoles(2) = pt;
802 	pt = gp_Pnt(60.,100.,0.);
803 	CurvePoles(3) = pt;
804 	pt = gp_Pnt(150.,0.,0.);
805 	CurvePoles(4) = pt;
806 	Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);
807 	TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);
808 	TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);
809 	Handle(AIS_Shape) ais1 = new AIS_Shape(W);
810 	myAISContext->Display(ais1,Standard_False);
811 	Fit();
812 	Sleep(500);
813 	gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.);
814 	TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
815 	TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);
816 	Handle(AIS_Shape) ais3 = new AIS_Shape(Wc);
817 	myAISContext->Display(ais3,Standard_False);
818 	TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::ZOX()),Wc);
819 	TopoDS_Shape S = BRepOffsetAPI_MakePipe(W,F);
820 	Handle(AIS_Shape) ais2 = new AIS_Shape(S);
821 	myAISContext->SetColor(ais2,Quantity_NOC_MATRABLUE,Standard_False);
822 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
823 	myAISContext->Display(ais2,Standard_False);
824 	Fit();
825 
826 	TCollection_AsciiString Message ("\
827 		\n\
828 TColgp_Array1OfPnt CurvePoles(1,6);\n\
829 gp_Pnt pt = gp_Pnt(0.,0.,0.);\n\
830 CurvePoles(1) = pt;\n\
831 pt = gp_Pnt(20.,50.,0.);\n\
832 CurvePoles(2) = pt;\n\
833 pt = gp_Pnt(60.,100.,0.);\n\
834 CurvePoles(3) = pt;\n\
835 pt = gp_Pnt(150.,0.,0.);\n\
836 CurvePoles(4) = pt;\n\
837 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);\n\
838 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);\n\
839 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);\n\
840 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.);\n\
841 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);\n\
842 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);\n\
843 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::ZOX()),Wc);\n\
844 TopoDS_Shape S = BRepBuilderAPI_MakePipe(W,F);\n\
845 		\n");
846   PocessTextInDialog("Make a pipe", Message);
847 
848 }
849 
OnThru()850 void CModelingDoc::OnThru()
851 {
852 	AIS_ListOfInteractive aList;
853 	myAISContext->DisplayedObjects(aList);
854 	AIS_ListIteratorOfListOfInteractive aListIterator;
855 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
856 		myAISContext->Remove (aListIterator.Value(), Standard_False);
857 	}
858 
859 	gp_Circ c1 = gp_Circ(gp_Ax2(gp_Pnt(-100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);
860 	TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(c1);
861 	TopoDS_Wire W1 = BRepBuilderAPI_MakeWire(E1);
862 	Handle(AIS_Shape) sec1 = new AIS_Shape(W1);
863 	myAISContext->Display(sec1,Standard_False);
864 	gp_Circ c2 = gp_Circ(gp_Ax2(gp_Pnt(-10.,0.,-0.),gp_Dir(0.,0.,1.)),40.);
865 	TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(c2);
866 	TopoDS_Wire W2 = BRepBuilderAPI_MakeWire(E2);
867 	Handle(AIS_Shape) sec2 = new AIS_Shape(W2);
868 	myAISContext->Display(sec2,Standard_False);
869 	gp_Circ c3 = gp_Circ(gp_Ax2(gp_Pnt(-75.,0.,100.),gp_Dir(0.,0.,1.)),40.);
870 	TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(c3);
871 	TopoDS_Wire W3 = BRepBuilderAPI_MakeWire(E3);
872 	Handle(AIS_Shape) sec3 = new AIS_Shape(W3);
873 	myAISContext->Display(sec3,Standard_False);
874 	gp_Circ c4= gp_Circ(gp_Ax2(gp_Pnt(0.,0.,200.),gp_Dir(0.,0.,1.)),40.);
875 	TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);
876 	TopoDS_Wire W4 = BRepBuilderAPI_MakeWire(E4);
877 	Handle(AIS_Shape) sec4 = new AIS_Shape(W4);
878 	myAISContext->Display(sec4,Standard_False);
879 	BRepOffsetAPI_ThruSections generator(Standard_False,Standard_True);
880 	generator.AddWire(W1);
881 	generator.AddWire(W2);
882 	generator.AddWire(W3);
883 	generator.AddWire(W4);
884 	generator.Build();
885 	TopoDS_Shape S1 = generator.Shape();
886 	Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
887 	myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
888 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
889 	myAISContext->Display(ais1,Standard_False);
890 
891 	gp_Circ c1b = gp_Circ(gp_Ax2(gp_Pnt(100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);
892 	TopoDS_Edge E1b = BRepBuilderAPI_MakeEdge(c1b);
893 	TopoDS_Wire W1b = BRepBuilderAPI_MakeWire(E1b);
894 	Handle(AIS_Shape) sec1b = new AIS_Shape(W1b);
895 	myAISContext->Display(sec1b,Standard_False);
896 	gp_Circ c2b = gp_Circ(gp_Ax2(gp_Pnt(210.,0.,-0.),gp_Dir(0.,0.,1.)),40.);
897 	TopoDS_Edge E2b = BRepBuilderAPI_MakeEdge(c2b);
898 	TopoDS_Wire W2b = BRepBuilderAPI_MakeWire(E2b);
899 	Handle(AIS_Shape) sec2b = new AIS_Shape(W2b);
900 	myAISContext->Display(sec2b,Standard_False);
901 	gp_Circ c3b = gp_Circ(gp_Ax2(gp_Pnt(275.,0.,100.),gp_Dir(0.,0.,1.)),40.);
902 	TopoDS_Edge E3b = BRepBuilderAPI_MakeEdge(c3b);
903 	TopoDS_Wire W3b = BRepBuilderAPI_MakeWire(E3b);
904 	Handle(AIS_Shape) sec3b = new AIS_Shape(W3b);
905 	myAISContext->Display(sec3b,Standard_False);
906 	gp_Circ c4b= gp_Circ(gp_Ax2(gp_Pnt(200.,0.,200.),gp_Dir(0.,0.,1.)),40.);
907 	TopoDS_Edge E4b = BRepBuilderAPI_MakeEdge(c4b);
908 	TopoDS_Wire W4b = BRepBuilderAPI_MakeWire(E4b);
909 	Handle(AIS_Shape) sec4b = new AIS_Shape(W4b);
910 	myAISContext->Display(sec4b,Standard_False);
911 	BRepOffsetAPI_ThruSections generatorb(Standard_True,Standard_False);
912 	generatorb.AddWire(W1b);
913 	generatorb.AddWire(W2b);
914 	generatorb.AddWire(W3b);
915 	generatorb.AddWire(W4b);
916 	generatorb.Build();
917 	TopoDS_Shape S2 = generatorb.Shape();
918 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
919 	myAISContext->SetColor(ais2,Quantity_NOC_ALICEBLUE,Standard_False);
920 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
921 	myAISContext->Display(ais2,Standard_False);
922 	Fit();
923 
924 	TCollection_AsciiString Message ("\
925 		\n\
926 ---------- ruled -------------- \n\
927 \n\
928 gp_Circ c1 = gp_Circ(gp_Ax2(gp_Pnt(-100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);\n\
929 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(c1);\n\
930 TopoDS_Wire W1 = BRepBuilderAPI_MakeWire(E1);\n\
931 gp_Circ c2 = gp_Circ(gp_Ax2(gp_Pnt(-10.,0.,-0.),gp_Dir(0.,0.,1.)),40.);\n\
932 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(c2);\n\
933 TopoDS_Wire W2 = BRepBuilderAPI_MakeWire(E2);\n\
934 gp_Circ c3 = gp_Circ(gp_Ax2(gp_Pnt(-75.,0.,100.),gp_Dir(0.,0.,1.)),40.);\n\
935 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(c3);\n\
936 TopoDS_Wire W3 = BRepBuilderAPI_MakeWire(E3);\n\
937 gp_Circ c4= gp_Circ(gp_Ax2(gp_Pnt(0.,0.,200.),gp_Dir(0.,0.,1.)),40.);\n\
938 TopoDS_Edge E4 = BRep>BuilderAPI_MakeEdge(c4);\n\
939 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);\n\
940 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);\n\
941 TopoDS_Wire W4 = BRepBuilderAPI_MakeWire(E4);\n\
942 BRepOffsetAPI_ThruSections generator(Standard_False,Standard_True);\n\
943 generator.AddWire(W1);\n\
944 generator.AddWire(W2);\n\
945 generator.AddWire(W3);\n\
946 generator.AddWire(W4);\n\
947 generator.Build();\n\
948 TopoDS_Shape S1 = generator.Shape();\n\
949 \n\
950 ---------- smooth -------------- \n\
951 \n\
952 gp_Circ c1b = gp_Circ(gp_Ax2(gp_Pnt(100.,0.,-100.),gp_Dir(0.,0.,1.)),40.); \n\
953 TopoDS_Edge E1b = BRepBuilderAPI_MakeEdge(c1b); \n\
954 TopoDS_Wire W1b = BRepBuilderAPI_MakeWire(E1b); \n\
955 gp_Circ c2b = gp_Circ(gp_Ax2(gp_Pnt(210.,0.,-0.),gp_Dir(0.,0.,1.)),40.); \n\
956 TopoDS_Edge E2b = BRepBuilderAPI_MakeEdge(c2b);\n\
957 TopoDS_Wire W2b = BRepBuilderAPI_MakeWire(E2b); \n\
958 gp_Circ c3b = gp_Circ(gp_Ax2(gp_Pnt(275.,0.,100.),gp_Dir(0.,0.,1.)),40.);\n\
959 TopoDS_Edge E3b = BRepBuilderAPI_MakeEdge(c3b);\n\
960 TopoDS_Wire W3b = BRepBuilderAPI_MakeWire(E3b);\n\
961 gp_Circ c4b= gp_Circ(gp_Ax2(gp_Pnt(200.,0.,200.),gp_Dir(0.,0.,1.)),40.);\n\
962 TopoDS_Edge E4b = BRepBuilderAPI_MakeEdge(c4b);\n\
963 TopoDS_Wire W4b = BRepBuilderAPI_MakeWire(E4b);\n\
964 BRepOffsetAPI_ThruSections generatorb(Standard_True,Standard_False);\n\
965 generatorb.AddWire(W1b);\n\
966 generatorb.AddWire(W2b);\n\
967 generatorb.AddWire(W3b);\n\
968 generatorb.AddWire(W4b);\n\
969 generatorb.Build();\n\
970 TopoDS_Shape S2 = generatorb.Shape();\n\
971 		\n");
972   PocessTextInDialog("Make a Thru sections", Message);
973 
974 }
975 
OnEvolved()976 void CModelingDoc::OnEvolved()
977 {
978 	AIS_ListOfInteractive aList;
979 	myAISContext->DisplayedObjects(aList);
980 	AIS_ListIteratorOfListOfInteractive aListIterator;
981 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
982 		myAISContext->Remove (aListIterator.Value(), Standard_False);
983 	}
984 
985 	BRepBuilderAPI_MakePolygon P;
986 	P.Add(gp_Pnt(0.,0.,0.));
987 	P.Add(gp_Pnt(200.,0.,0.));
988 	P.Add(gp_Pnt(200.,200.,0.));
989 	P.Add(gp_Pnt(0.,200.,0.));
990 	P.Add(gp_Pnt(0.,0.,0.));
991 	TopoDS_Wire W = P.Wire();
992 
993 	Handle(AIS_Shape) ais1 = new AIS_Shape(W);
994 	myAISContext->Display(ais1,Standard_False);
995 
996 	TopoDS_Wire wprof = BRepBuilderAPI_MakePolygon(gp_Pnt(0.,0.,0.),gp_Pnt(-60.,-60.,-200.));
997 
998 	Handle(AIS_Shape) ais3 = new AIS_Shape(wprof);
999 	myAISContext->Display(ais3,Standard_False);
1000 	Fit();
1001 	Sleep(500);
1002 	TopoDS_Shape S = BRepOffsetAPI_MakeEvolved(W,wprof,GeomAbs_Arc,Standard_True,Standard_False,Standard_True,0.0001);
1003 
1004 	Handle(AIS_Shape) ais2 = new AIS_Shape(S);
1005 	myAISContext->SetColor(ais2,Quantity_NOC_MATRABLUE,Standard_False);
1006 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1007 	myAISContext->Display(ais2,Standard_False);
1008 	Fit();
1009 
1010 	TCollection_AsciiString Message ("\
1011 		\n\
1012 ---------- Evolved shape -------------- \n\
1013 \n\
1014 BRepBuilderAPI_MakePolygon P;\n\
1015 P.Add(gp_Pnt(0.,0.,0.));\n\
1016 P.Add(gp_Pnt(200.,0.,0.));\n\
1017 P.Add(gp_Pnt(200.,200.,0.));\n\
1018 P.Add(gp_Pnt(0.,200.,0.));\n\
1019 P.Add(gp_Pnt(0.,0.,0.));\n\
1020 TopoDS_Wire W = P.Wire();\n\
1021 TopoDS_Wire wprof = BRepBuilderAPI_MakePolygon(gp_Pnt(0.,0.,0.),gp_Pnt(-60.,-60.,-200.));\n\
1022 TopoDS_Shape S = BRepBuilderAPI_MakeEvolved(W,wprof,GeomAbs_Arc,Standard_True,Standard_False,Standard_True,0.0001);\n\
1023 		\n");
1024   PocessTextInDialog("Make an evolved shape", Message);
1025 
1026 }
1027 
OnDraft()1028 void CModelingDoc::OnDraft()
1029 {
1030 	AIS_ListOfInteractive aList;
1031 	myAISContext->DisplayedObjects(aList);
1032 	AIS_ListIteratorOfListOfInteractive aListIterator;
1033 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1034 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1035 	}
1036 
1037   TopoDS_Shape S = BRepPrimAPI_MakeBox(200., 300., 150.).Shape();
1038 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
1039 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1040 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1041 	myAISContext->Display(ais1,Standard_False);
1042 	Fit();
1043 	Sleep(500);
1044 	BRepOffsetAPI_DraftAngle adraft(S);
1045 	TopExp_Explorer Ex;
1046 	for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {
1047 		TopoDS_Face F = TopoDS::Face(Ex.Current());
1048 		Handle(Geom_Plane) surf = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F));
1049 		gp_Pln apln = surf->Pln();
1050 		gp_Dir dirF = apln.Axis().Direction();
1051 		if (dirF.IsNormal(gp_Dir(0.,0.,1.),Precision::Angular()))
1052 			adraft.Add(F, gp_Dir(0.,0.,1.), 15.*M_PI/180, gp_Pln(gp::XOY()));
1053 	}
1054 	ais1->Set(adraft.Shape());
1055 	myAISContext->Redisplay(ais1,Standard_False);
1056 	Fit();
1057 
1058 	TCollection_AsciiString Message ("\
1059 		\n\
1060 ---------- Tapered shape -------------- \n\
1061 \n\
1062 TopoDS_Shape S = BRepPrimAPI_MakeBox(200.,300.,150.);\n\
1063 BRepOffsetAPI_DraftAngle adraft(S);\n\
1064 TopExp_Explorer Ex;\n\
1065 for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {\n\
1066 	TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
1067 	Handle(Geom_Plane) surf = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F));\n\
1068 	gp_Pln apln = surf->Pln();\n\
1069 	gp_Dir dirF = apln.Axis().Direction();\n\
1070 	if (dirF.IsNormal(gp_Dir(0.,0.,1.),Precision::Angular()))\n\
1071 		adraft.Add(F, gp_Dir(0.,0.,1.), 15.*PI180, gp_Pln(gp::XOY()));\n\
1072 }\n\
1073 		\n");
1074   PocessTextInDialog("Make a tapered shape", Message);
1075 
1076 }
1077 
1078 /* =================================================================================
1079    ====================   O P E R A T I O N S   ====================================
1080    ================================================================================= */
1081 
OnCut()1082 void CModelingDoc::OnCut()
1083 {
1084 	AIS_ListOfInteractive aList;
1085 	myAISContext->DisplayedObjects(aList);
1086 	AIS_ListIteratorOfListOfInteractive aListIterator;
1087 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1088 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1089 	}
1090 
1091   TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200, 60, 60).Shape();
1092 
1093 Handle (AIS_Shape)	ais1 = new AIS_Shape(theBox);
1094 myAISContext->SetDisplayMode(ais1,1,Standard_False);
1095 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1096 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1097 myAISContext->Display(ais1,Standard_False);
1098 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1099 myAISContext->SetSelected (anIO1, Standard_False);
1100 Fit();
1101 Sleep(1000);
1102 
1103 
1104 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100, 20, 20), 80).Shape();
1105 Handle (AIS_Shape)	ais2 = new AIS_Shape(theSphere);
1106 myAISContext->SetDisplayMode(ais2,1,Standard_False);
1107 myAISContext->SetColor(ais2,Quantity_NOC_YELLOW,Standard_False);
1108 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1109 myAISContext->Display(ais2,Standard_False);
1110 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
1111 myAISContext->SetSelected (anIO2, Standard_False);
1112 Fit();
1113 Sleep(1000);
1114 
1115 TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox);
1116 
1117 myAISContext->Erase(ais1,Standard_False);
1118 myAISContext->Erase(ais2,Standard_False);
1119 
1120 Handle (AIS_Shape)	aSection = new AIS_Shape(ShapeCut);
1121 myAISContext->SetDisplayMode(aSection,1,Standard_False);
1122 myAISContext->SetColor(aSection,Quantity_NOC_RED,Standard_False);
1123 myAISContext->SetMaterial(aSection,Graphic3d_NOM_PLASTIC,Standard_False);
1124 myAISContext->Display(aSection,Standard_False);
1125 const Handle(AIS_InteractiveObject)& anIOSection = aSection;
1126 myAISContext->SetSelected (anIOSection, Standard_False);
1127 Fit();
1128 
1129     TCollection_AsciiString Message ("\
1130 		\n\
1131 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,40,40); \n\
1132  \n\
1133 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80); \n\
1134  \n\
1135 TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox); \n\
1136  \n");
1137 	PocessTextInDialog("Cut the sphere with a box", Message);
1138 
1139 
1140 }
1141 
1142 
1143 
1144 
1145 
1146 
1147 
1148 
1149 
1150 
OnFuse()1151 void CModelingDoc::OnFuse()
1152 {
1153 	AIS_ListOfInteractive aList;
1154 	myAISContext->DisplayedObjects(aList);
1155 	AIS_ListIteratorOfListOfInteractive aListIterator;
1156 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1157 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1158 	}
1159 
1160 gp_Pnt P(-5,5,-5);
1161 TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(60, 200, 70).Shape();
1162 Handle (AIS_Shape)	ais1 = new AIS_Shape(theBox1);
1163 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1164 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1165 myAISContext->Display(ais1,Standard_False);
1166 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1167 myAISContext->SetSelected (anIO1, Standard_False);
1168 Fit();
1169 Sleep(1000);
1170 
1171 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P, 20, 150, 110).Shape();
1172 Handle (AIS_Shape)	ais2 = new AIS_Shape(theBox2);
1173 myAISContext->SetColor(ais2,Quantity_NOC_YELLOW,Standard_False);
1174 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1175 myAISContext->Display(ais2,Standard_False);
1176 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
1177 myAISContext->SetSelected (anIO2, Standard_False);
1178 Fit();
1179 Sleep(1000);
1180 
1181 TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1,theBox2);
1182 
1183 myAISContext->Erase(ais1,false);
1184 myAISContext->Erase(ais2,false);
1185 
1186 Handle (AIS_Shape)	aFusion = new AIS_Shape(FusedShape);
1187 myAISContext->SetDisplayMode(aFusion,1,Standard_False);
1188 myAISContext->SetColor(aFusion,Quantity_NOC_RED,Standard_False);
1189 myAISContext->SetMaterial(aFusion,Graphic3d_NOM_PLASTIC,Standard_False);
1190 myAISContext->Display(aFusion,Standard_False);
1191 const Handle(AIS_InteractiveObject)& anIOFusion = aFusion;
1192 myAISContext->SetSelected (anIOFusion, Standard_False);
1193 myAISContext->UpdateCurrentViewer();
1194 
1195     TCollection_AsciiString Message ("\
1196 		\n\
1197 TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(50,200,70); \n\
1198  \n\
1199 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(-30,150,70); \n\
1200  \n\
1201 TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1,theBox2); \n");
1202 	PocessTextInDialog("Fuse the boxes", Message);
1203 
1204 }
1205 
OnCommon()1206 void CModelingDoc::OnCommon()
1207 {
1208 	AIS_ListOfInteractive aList;
1209 	myAISContext->DisplayedObjects(aList);
1210 	AIS_ListIteratorOfListOfInteractive aListIterator;
1211 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1212 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1213 	}
1214 
1215 gp_Ax2 axe(gp_Pnt(10,10,10),gp_Dir(1,2,1));
1216 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(axe, 60, 80, 100).Shape();
1217 
1218 Handle(AIS_Shape) aboxshape=new AIS_Shape(theBox);
1219 myAISContext->SetColor(aboxshape,Quantity_NOC_YELLOW,Standard_False);
1220 myAISContext->SetMaterial(aboxshape,Graphic3d_NOM_PLASTIC,Standard_False);
1221 myAISContext->SetTransparency(aboxshape,0.2,Standard_False);
1222 myAISContext->Display(aboxshape, AIS_Shaded, 0, Standard_False);
1223 const Handle(AIS_InteractiveObject)& anIOBoxShape = aboxshape;
1224 myAISContext->SetSelected (anIOBoxShape, Standard_False);
1225 Fit();
1226 Sleep(500);
1227 
1228 TopoDS_Shape theWedge = BRepPrimAPI_MakeWedge(60., 100., 80., 20.).Shape();
1229 
1230 Handle(AIS_Shape) awedge = new AIS_Shape(theWedge);
1231 myAISContext->SetColor(awedge,Quantity_NOC_RED,Standard_False);
1232 myAISContext->SetMaterial(awedge,Graphic3d_NOM_PLASTIC,Standard_False);
1233 myAISContext->SetTransparency(awedge,0.0,Standard_False);
1234 myAISContext->Display(awedge,Standard_False);
1235 const Handle(AIS_InteractiveObject)& anIOWedge = awedge;
1236 myAISContext->SetSelected (anIOWedge, Standard_False);
1237 myAISContext->UpdateCurrentViewer();
1238 Sleep(500);
1239 
1240 TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(theBox,theWedge);
1241 
1242 myAISContext->Erase(aboxshape, false);
1243 myAISContext->Erase(awedge, false);
1244 
1245 Handle(AIS_Shape) acommon = new AIS_Shape(theCommonSurface);
1246 myAISContext->SetColor(acommon,Quantity_NOC_GREEN,Standard_False);
1247 myAISContext->SetMaterial(acommon,Graphic3d_NOM_PLASTIC,Standard_False);
1248 myAISContext->Display (acommon, AIS_Shaded, 0,Standard_False);
1249 const Handle(AIS_InteractiveObject)& anIOCommon = acommon;
1250 myAISContext->SetSelected (anIOCommon, Standard_False);
1251 myAISContext->UpdateCurrentViewer();
1252 
1253    TCollection_AsciiString Message ("\
1254 		\n\
1255 gp_Ax2 axe(gp_Pnt(10,10,10),gp_Dir(1,2,1)); \n\
1256  \n\
1257 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(axe,60,80,100); \n\
1258  \n\
1259 TopoDS_Shape theWedge = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
1260  \n\
1261 TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(theBox,theWedge); \n\
1262  \n");
1263 
1264 	PocessTextInDialog("Compute the common surface ", Message);
1265 
1266 }
1267 
OnSection()1268 void CModelingDoc::OnSection()
1269 {
1270 
1271 	AIS_ListOfInteractive aList;
1272 	myAISContext->DisplayedObjects(aList);
1273 	AIS_ListIteratorOfListOfInteractive aListIterator;
1274 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1275 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1276 	}
1277 
1278   TopoDS_Shape atorus = BRepPrimAPI_MakeTorus(120, 20).Shape();
1279 
1280     Handle(AIS_Shape) ashape=new AIS_Shape(atorus);
1281     myAISContext->SetColor(ashape,Quantity_NOC_RED,Standard_False);
1282     myAISContext->SetMaterial(ashape,Graphic3d_NOM_PLASTIC,Standard_False);
1283     myAISContext->SetDisplayMode(ashape,1,Standard_False);
1284 	myAISContext->SetTransparency(ashape,0.1,Standard_False);
1285     myAISContext->Display(ashape,Standard_False);
1286 
1287 gp_Vec V1(1,1,1);
1288 Standard_Real radius = 120;
1289 Standard_Integer i=-3;
1290 
1291 for(i;i<=3;i++) {
1292     TopoDS_Shape asphere = BRepPrimAPI_MakeSphere(gp_Pnt(26 * 3 * i, 0, 0), radius).Shape();
1293 
1294     Handle (AIS_Shape) theShape=new AIS_Shape (asphere);
1295     myAISContext->SetTransparency(theShape,0.1,Standard_False);
1296     myAISContext->SetColor(theShape,Quantity_NOC_WHITE,Standard_False);
1297     myAISContext->SetDisplayMode(theShape,1,Standard_False);
1298     myAISContext->Display(theShape,Standard_False);
1299 	Fit();
1300 
1301     Standard_Boolean PerformNow=Standard_False;
1302 
1303     BRepAlgoAPI_Section section(atorus,asphere,PerformNow);
1304     section.ComputePCurveOn1(Standard_True);
1305     section.Approximation(TopOpeBRepTool_APPROX);
1306     section.Build();
1307 
1308     Handle(AIS_Shape) asection=new AIS_Shape(section.Shape());
1309     myAISContext->SetDisplayMode (asection, 0, Standard_False);
1310     myAISContext->SetColor (asection, Quantity_NOC_WHITE, Standard_False);
1311     myAISContext->Display (asection, Standard_False);
1312     if(i<3) {
1313     myAISContext->Remove (theShape, Standard_False);
1314 	}
1315 }
1316   myAISContext->UpdateCurrentViewer();
1317    TCollection_AsciiString Message ("\
1318 		\n\
1319 TopoDS_Shape atorus = BRepPrimAPI_MakeTorus(120,20); \n\
1320 gp_Vec V1(1,1,1); \n\
1321 Standard_Real radius = 120; \n\
1322 Standard_Integer i=-3; \n\
1323 for(i;i<=3;i++) { \n\
1324     TopoDS_Shape asphere = BRepPrimAPI_MakeSphere(gp_Pnt(78*i,0,0),radius); \n\
1325     Standard_Boolean PerformNow=Standard_False; \n\
1326     BRepAlgoAPI_Section section(atorus,asphere,PerformNow); \n\
1327     section.ComputePCurveOn1(Standard_True); \n\
1328     section.Approximation(TopOpeBRepTool_APPROX); \n\
1329     section.Build(); \n\
1330 	\n");
1331 
1332 	PocessTextInDialog("Compute the sections ", Message);
1333 
1334 }
1335 
OnPsection()1336 void CModelingDoc::OnPsection()
1337 {
1338 	AIS_ListOfInteractive aList;
1339 	myAISContext->DisplayedObjects(aList);
1340 	AIS_ListIteratorOfListOfInteractive aListIterator;
1341 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1342 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1343 	}
1344 
1345 TopoDS_Shape theTorus = BRepPrimAPI_MakeTorus(35, 8).Shape();
1346 Handle(AIS_Shape) atorus = new AIS_Shape(theTorus);
1347 myAISContext->SetColor(atorus,Quantity_NOC_YELLOW,Standard_False);
1348 myAISContext->SetMaterial(atorus,Graphic3d_NOM_PLASTIC,Standard_False);
1349 myAISContext->SetTransparency(atorus,0.1,Standard_False);
1350 myAISContext->Display(atorus,Standard_False);
1351 const Handle(AIS_InteractiveObject)& anIOTorus = atorus;
1352 myAISContext->SetSelected (anIOTorus, Standard_False);
1353 Fit();
1354 Sleep(500);
1355 
1356 gp_Pln aplane(1,0.25,3,4);
1357 Handle (Geom_Plane) thePlane = new Geom_Plane(aplane);
1358 Handle (AIS_Plane) ais1 = new AIS_Plane(thePlane);
1359 myAISContext->Display(ais1,Standard_False);
1360 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1361 myAISContext->SetSelected (anIO1, Standard_False);
1362 Fit();
1363 Sleep(300);
1364 
1365 BRepAlgoAPI_Section section(theTorus,thePlane,Standard_False);
1366 section.ComputePCurveOn1(Standard_True);
1367 section.Approximation(TopOpeBRepTool_APPROX);
1368 section.Build();
1369 
1370 Handle(AIS_Shape) asection=new AIS_Shape(section.Shape());
1371 myAISContext->SetDisplayMode(asection ,0,Standard_False);
1372 myAISContext->SetColor(asection,Quantity_NOC_WHITE,Standard_False);
1373 myAISContext->Display(asection,Standard_False);
1374 Fit();
1375 
1376    TCollection_AsciiString Message ("\
1377 		\n\
1378 TopoDS_Shape theTorus = BRepPrimAPI_MakeTorus(60.,20.); \n\
1379  \n\
1380 gp_Pln P(1,2,1,-15); \n\
1381  \n\
1382 TopoDS_Shape Psection = BRepAlgoAPI_Section(theTorus,P);  \n\
1383 \n");
1384 
1385 	PocessTextInDialog("Compute the plane section ", Message);
1386 
1387 }
1388 
OnBlend()1389 void CModelingDoc::OnBlend()
1390 {
1391 	AIS_ListOfInteractive aList;
1392 	myAISContext->DisplayedObjects(aList);
1393 	AIS_ListIteratorOfListOfInteractive aListIterator;
1394 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1395 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1396 	}
1397 
1398 TopoDS_Shape Box = BRepPrimAPI_MakeBox(gp_Pnt(-400,0,0),200,230,180).Shape();
1399 Handle(AIS_Shape) ais1 = new AIS_Shape(Box);
1400 myAISContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False);
1401 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1402 myAISContext->Display(ais1,Standard_False);
1403 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1404 myAISContext->SetSelected (anIO1, Standard_False);
1405 Fit();
1406 Sleep(500);
1407 
1408 BRepFilletAPI_MakeFillet fillet(Box);
1409 
1410 for (TopExp_Explorer ex(Box,TopAbs_EDGE); ex.More(); ex.Next()) {
1411 	TopoDS_Edge Edge =TopoDS::Edge(ex.Current());
1412 	fillet.Add(20,Edge);
1413 }
1414 
1415 myAISContext->Remove(ais1,Standard_False);
1416 
1417 TopoDS_Shape blendedBox = fillet.Shape();
1418 Handle(AIS_Shape) aBlendbox = new AIS_Shape(blendedBox);
1419 myAISContext->SetColor(aBlendbox,Quantity_NOC_YELLOW,Standard_False);
1420 myAISContext->SetMaterial(aBlendbox,Graphic3d_NOM_PLASTIC,Standard_False);
1421 myAISContext->Display(aBlendbox,Standard_False);
1422 const Handle(AIS_InteractiveObject)& anIOBlendBox = aBlendbox;
1423 myAISContext->SetSelected (anIOBlendBox, Standard_False);
1424 Fit();
1425 Sleep(500);
1426 
1427 
1428 gp_Pnt P1(250,150,75);
1429 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(300, 200, 200).Shape();
1430 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(P1, 120, 180, 70).Shape();
1431 
1432 TopoDS_Shape fusedShape = BRepAlgoAPI_Fuse(S1,S2);
1433 Handle(AIS_Shape) ais2 = new AIS_Shape(fusedShape);
1434 myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False);
1435 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1436 myAISContext->Display(ais2,Standard_False);
1437 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
1438 myAISContext->SetSelected (anIO2, Standard_False);
1439 Fit();
1440 
1441 BRepFilletAPI_MakeFillet fill(fusedShape);
1442 
1443 for (TopExp_Explorer ex1(fusedShape,TopAbs_EDGE); ex1.More(); ex1.Next()) {
1444 	TopoDS_Edge E =TopoDS::Edge(ex1.Current());
1445 	fill.Add(E);
1446 }
1447 
1448 for (Standard_Integer i = 1;i<=fill.NbContours();i++) {
1449 	Standard_Real longueur(fill.Length(i));
1450 	Standard_Real Rad(0.15*longueur);
1451 	fill.SetRadius(Rad,i, 1);
1452 }
1453 
1454 TopoDS_Shape blendedFusedSolids = fill.Shape();
1455 
1456 Handle(AIS_Shape) aBlend = new AIS_Shape(blendedFusedSolids);
1457 myAISContext->SetColor(aBlend,Quantity_NOC_RED,Standard_False);
1458 myAISContext->SetMaterial(aBlend,Graphic3d_NOM_PLASTIC,Standard_False);
1459 myAISContext->Display(aBlend,Standard_False);
1460 
1461 myAISContext->Remove(ais2,Standard_False);
1462 Fit();
1463 
1464 
1465  TCollection_AsciiString Message ("\
1466 		\n\
1467 //THE YELLOW BOX\n\
1468 TopoDS_Shape Box = BRepPrimAPI_MakeBox(gp_Pnt(-400,0,0),200,230,180);\n\
1469 \n\
1470 BRepPrimAPI_MakeFillet fillet(Box);\n\
1471 \n\
1472 for (TopExp_Explorer ex(Box,TopAbs_EDGE); ex.More(); ex.Next()) {\n\
1473 	TopoDS_Edge Edge =TopoDS::Edge(ex.Current());\n\
1474 	fillet.Add(20,Edge);\n\
1475 }\n\
1476 TopoDS_Shape blendedBox = fillet.Shape();\n\
1477 \n\
1478 ////////////////////////////////////////////////////////////////////////\n\
1479 \n\
1480 //THE RED SOLID\n\
1481  \n\
1482 //Warning : On the acute angles of the boxes a fillet is created. \n\
1483 On the angles of fusion a blend is created. \n\
1484 \n\
1485 gp_Pnt P1(150,150,75);\n\
1486 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(300,200,200);\n\
1487 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(P1,100,200,70);\n\
1488 \n\
1489 TopoDS_Shape fusedShape = BRepAlgoAPI_Fuse(S1,S2);\n\
1490 BRepPrimAPI_MakeFillet fill(fusedShape);\n\
1491 \n\
1492 for (TopExp_Explorer ex1(fusedShape,TopAbs_EDGE); ex1.More(); ex1.Next()) {\n\
1493 	TopoDS_Edge E =TopoDS::Edge(ex1.Current());\n\
1494 	fill.Add(E);\n\
1495 }\n\
1496 \n\
1497 for (Standard_Integer i = 1;i<=fill.NbContours();i++) {\n\
1498 	Standard_Real longueur(fill.Length(i));\n\
1499 	Standard_Real Rad(0.2*longueur);\n\
1500 	fill.SetRadius(Rad,i);\n\
1501 }\n\
1502 \n\
1503 TopoDS_Shape blendedFusedSolids = fill.Shape(); \n");
1504 
1505 	PocessTextInDialog("Compute the blend on the edges ", Message);
1506 }
1507 
OnEvolvedblend()1508 void CModelingDoc::OnEvolvedblend()
1509 {
1510 
1511 	AIS_ListOfInteractive aList;
1512 	myAISContext->DisplayedObjects(aList);
1513 	AIS_ListIteratorOfListOfInteractive aListIterator;
1514 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1515 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1516 	}
1517 
1518 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200, 200, 200).Shape();
1519 Handle(AIS_Shape) ais1 = new AIS_Shape(theBox);
1520 myAISContext->SetColor(ais1,Quantity_NOC_BROWN,Standard_False);
1521 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1522 myAISContext->Display(ais1,Standard_False);
1523 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1524 myAISContext->SetSelected (anIO1, Standard_False);
1525 Fit();
1526 Sleep(500);
1527 
1528 BRepFilletAPI_MakeFillet Rake(theBox);
1529 
1530 TopExp_Explorer ex(theBox,TopAbs_EDGE);
1531 ex.Next();
1532 ex.Next();
1533 ex.Next();
1534 ex.Next();
1535 Rake.Add(8,50,TopoDS::Edge(ex.Current()));
1536 Rake.Build();
1537 if (Rake.IsDone() ){
1538 	TopoDS_Shape evolvedBox = Rake.Shape();
1539 	ais1->Set(evolvedBox);
1540 	myAISContext->Redisplay(ais1,Standard_False);
1541 	myAISContext->SetSelected(anIO1, Standard_False);
1542 	Fit();
1543 	Sleep(500);
1544 
1545 }
1546 
1547 TopoDS_Shape theCylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-300, 0, 0), gp::DZ()), 100, 200).Shape();
1548 Handle(AIS_Shape) ais3 = new AIS_Shape(theCylinder);
1549 myAISContext->SetColor(ais3,Quantity_NOC_GREEN,Standard_False);
1550 myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
1551 myAISContext->Display(ais3,Standard_False);
1552 const Handle(AIS_InteractiveObject)& anIO3 = ais3;
1553 myAISContext->SetSelected (anIO3, Standard_False);
1554 Fit();
1555 Sleep(500);
1556 
1557 BRepFilletAPI_MakeFillet fillet(theCylinder);
1558 
1559 TColgp_Array1OfPnt2d TabPoint2(1,20);
1560 
1561 for (Standard_Integer i=0; i<=19; i++) {
1562 	gp_Pnt2d Point2d(i*2*M_PI/19,60*cos(i*M_PI/19-M_PI/2)+10);
1563 	TabPoint2.SetValue(i+1,Point2d);
1564 }
1565 
1566 TopExp_Explorer exp2(theCylinder,TopAbs_EDGE);
1567 fillet.Add(TabPoint2,TopoDS::Edge(exp2.Current()));
1568 fillet.Build();
1569 if (fillet.IsDone() ){
1570 	TopoDS_Shape LawEvolvedCylinder = fillet.Shape();
1571 	ais3->Set(LawEvolvedCylinder);
1572 	myAISContext->Redisplay(ais3,Standard_False);
1573 	myAISContext->SetSelected(anIO3,Standard_False);
1574 	Fit();
1575 	Sleep(500);
1576 }
1577 
1578 gp_Pnt P(350,0,0);
1579 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P, 200, 200, 200).Shape();
1580 Handle(AIS_Shape) ais2 = new AIS_Shape(theBox2);
1581 myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False);
1582 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1583 myAISContext->Display(ais2,Standard_False);
1584 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
1585 myAISContext->SetSelected (anIO2, Standard_False);
1586 Fit();
1587 Sleep(500);
1588 
1589 
1590 BRepFilletAPI_MakeFillet afillet(theBox2);
1591 
1592 TColgp_Array1OfPnt2d TabPoint(1,6);
1593 
1594 gp_Pnt2d P1(0.,8.);
1595 gp_Pnt2d P2(0.2,16.);
1596 gp_Pnt2d P3(0.4,25.);
1597 gp_Pnt2d P4(0.6,55.);
1598 gp_Pnt2d P5(0.8,28.);
1599 gp_Pnt2d P6(1.,20.);
1600 TabPoint.SetValue(1,P1);
1601 TabPoint.SetValue(2,P2);
1602 TabPoint.SetValue(3,P3);
1603 TabPoint.SetValue(4,P4);
1604 TabPoint.SetValue(5,P5);
1605 TabPoint.SetValue(6,P6);
1606 
1607 TopExp_Explorer exp(theBox2,TopAbs_EDGE);
1608 exp.Next();
1609 exp.Next();
1610 exp.Next();
1611 exp.Next();
1612 
1613 afillet.Add(TabPoint, TopoDS::Edge(exp.Current()));
1614 
1615 afillet.Build();
1616 if (afillet.IsDone() ){
1617 	TopoDS_Shape LawevolvedBox = afillet.Shape();
1618 	ais2->Set(LawevolvedBox);
1619 	myAISContext->Redisplay(ais2,Standard_False);
1620 	myAISContext->SetSelected(anIO2,Standard_False);
1621 	Fit();
1622 
1623 }
1624 
1625    TCollection_AsciiString Message ("\
1626 		\n\
1627 //THE BROWN BOX \n\
1628 \n\
1629 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,200,200);	\n\
1630 	\n\
1631 BRepPrimAPI_MakeFillet Rake(theBox);	\n\
1632 ChFi3d_FilletShape FSh = ChFi3d_Rational;	\n\
1633 Rake.SetFilletShape(FSh);	\n\
1634 	\n\
1635 TopExp_Explorer ex(theBox,TopAbs_EDGE);	\n\
1636 ex.Next();   //in order to recover the front edge	\n\
1637 ex.Next();	\n\
1638 ex.Next();	\n\
1639 ex.Next();	\n\
1640 Rake.Add(8,50,TopoDS::Edge(ex.Current()));	\n\
1641  	\n\
1642 Rake.Build();  \n\
1643 if (Rake.IsDone() )  \n\
1644 	TopoDS_Shape theBrownBox = Rake.Shape();	\n\
1645 	\n\
1646 //////////////////////////////////////////////////////////	\n\
1647 	\n\
1648 //THE GREEN CYLINDER	\n\
1649 	\n\
1650 TopoDS_Shape theCylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(0,0,1)),100,200);	\n\
1651 	\n\
1652 BRepPrimAPI_MakeFillet fillet(theCylinder);	\n\
1653 	\n\
1654 TColgp_Array1OfPnt2d TabPoint2(1,20);	\n\
1655 	\n\
1656 for (Standard_Integer i=0; i<=19; i++) {	\n\
1657 	gp_Pnt2d Point2d(i*2*PI/19,60*cos(i*PI/19-PI/2)+10);	\n\
1658 	TabPoint2.SetValue(i+1,Point2d);	\n\
1659 }	\n\
1660 	\n\
1661 TopExp_Explorer exp2(theCylinder,TopAbs_EDGE);	\n\
1662 fillet.Add(TabPoint2,TopoDS::Edge(exp2.Current()));	\n\
1663  	\n\
1664 fillet.Build();  \n\
1665 if (fillet.IsDone() )  \n\
1666 	TopoDS_Shape LawEvolvedCylinder = fillet.Shape();	\n\
1667 	\n\
1668 ////////////////////////////////////////////////////////////	\n\
1669 	\n\
1670 	//THE RED BOX \n\
1671  \n\
1672 gp_Pnt P(350,0,0);	\n\
1673 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P,200,200,200);	\n\
1674 	\n\
1675 BRepPrimAPI_MakeFillet fill(theBox2);	\n\
1676 	\n\
1677 TColgp_Array1OfPnt2d TabPoint(1,6);	\n\
1678 gp_Pnt2d P1(0,8);	\n\
1679 gp_Pnt2d P2(0.2,16);	\n\
1680 gp_Pnt2d P3(0.4,25);	\n\
1681 gp_Pnt2d P4(0.6,55);	\n\
1682 gp_Pnt2d P5(0.8,28);	\n\
1683 gp_Pnt2d P6(1,20);	\n\
1684 TabPoint.SetValue(1,P1);	\n\
1685 TabPoint.SetValue(2,P2);	\n\
1686 TabPoint.SetValue(3,P3);	\n\
1687 TabPoint.SetValue(4,P4);	\n\
1688 TabPoint.SetValue(5,P5);	\n\
1689 TabPoint.SetValue(6,P6);	\n\
1690 	\n\
1691 TopExp_Explorer exp(theBox2,TopAbs_EDGE);	\n\
1692 exp.Next();  //in order to trcover the front edge	\n\
1693 exp.Next();	\n\
1694 exp.Next();	\n\
1695 exp.Next();	\n\
1696 fill.Add(TabPoint,TopoDS::Edge(exp.Current()));	\n\
1697  	\n\
1698 fill.Build();   \n\
1699 if (fillet.IsDone() )  \n\
1700 	TopoDS_Shape theRedBox = fill.Shape();	\n\
1701 \n");
1702 
1703 	PocessTextInDialog("Compute evolutiv blend on an edge ", Message);
1704 
1705 }
1706 
OnChamf()1707 void CModelingDoc::OnChamf()
1708 {
1709 	AIS_ListOfInteractive aList;
1710 	myAISContext->DisplayedObjects(aList);
1711 	AIS_ListIteratorOfListOfInteractive aListIterator;
1712 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1713 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1714 	}
1715 
1716 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(60,200,70).Shape();
1717 Handle(AIS_Shape) ais1 = new AIS_Shape(theBox);
1718 myAISContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False);
1719 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1720 myAISContext->Display(ais1,Standard_False);
1721 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1722 myAISContext->SetSelected (anIO1, Standard_False);
1723 Fit();
1724 Sleep(500);
1725 
1726 BRepFilletAPI_MakeChamfer MC(theBox);
1727 // add all the edges to chamfer
1728 TopTools_IndexedDataMapOfShapeListOfShape M;
1729 TopExp::MapShapesAndAncestors(theBox,TopAbs_EDGE,TopAbs_FACE,M);
1730 for (Standard_Integer i = 1;i<=M.Extent();i++) {
1731 	TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
1732 	TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
1733 	MC.Add(5,5,E,F);
1734 	}
1735 
1736 TopoDS_Shape ChanfrenedBox = MC.Shape();
1737 Handle(AIS_Shape) aBlendedBox = new AIS_Shape(ChanfrenedBox);
1738 myAISContext->SetColor(aBlendedBox,Quantity_NOC_YELLOW,Standard_False);
1739 myAISContext->SetMaterial(aBlendedBox,Graphic3d_NOM_PLASTIC,Standard_False);
1740 myAISContext->Display(aBlendedBox,Standard_False);
1741 const Handle(AIS_InteractiveObject)& anIOBlendedBox = aBlendedBox;
1742 myAISContext->SetSelected (anIOBlendedBox, Standard_False);
1743 Fit();
1744 Sleep(500);
1745 
1746 myAISContext->Erase(ais1,Standard_True);
1747 
1748    TCollection_AsciiString Message ("\
1749 		\n\
1750 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(130,200,170); \n\
1751 BRepFilletAPI_MakeChamfer MC(theBox); \n\
1752 TopTools_IndexedDataMapOfShapeListOfShape M; \n\
1753 TopExp::MapShapesAndAncestors(theBox,TopAbs_EDGE,TopAbs_FACE,M); \n\
1754 for (Standar1d_Integer i;i<M.Extent();i++) { \n\
1755 	TopoDS_Edge E = TopoDS::Edge(M.FindKey(i)); \n\
1756 	TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First()); \n\
1757 	MC.Add(15,15,E,F); \n\
1758 	} \n\
1759 TopoDS_Shape ChanfrenedBox = MC.Shape();  \n");
1760 
1761 	PocessTextInDialog("Compute the chamfers on all the edges ", Message);
1762 }
1763 
1764 /* =================================================================================
1765    ====================   L O C A L   O P E R A T I O N S   ========================
1766    ================================================================================= */
1767 
OnPrismLocal()1768 void CModelingDoc::OnPrismLocal()
1769 {
1770 	AIS_ListOfInteractive aList;
1771 	myAISContext->DisplayedObjects(aList);
1772 	AIS_ListIteratorOfListOfInteractive aListIterator;
1773 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1774 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1775 	}
1776   TopoDS_Shape S = BRepPrimAPI_MakeBox(400., 250., 300.).Shape();
1777 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
1778 
1779 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1780 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1781 	myAISContext->Display(ais1,Standard_False);
1782 	const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1783 	myAISContext->SetSelected (anIO1, Standard_False);
1784 	Fit();
1785 	Sleep(500);
1786 
1787 	TopExp_Explorer Ex;
1788 	Ex.Init(S,TopAbs_FACE);
1789 	Ex.Next();
1790 	TopoDS_Face F = TopoDS::Face(Ex.Current());
1791 	Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
1792 	Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);
1793 	gp_Dir D = Pl->Pln().Axis().Direction();
1794 // new in 2.0 ..use the trigonometric orientation to make the extrusion.
1795 	D.Reverse();
1796 	gp_Pnt2d p1,p2;
1797 	Handle(Geom2d_Curve) aline;
1798 	BRepBuilderAPI_MakeWire MW;
1799 	p1 = gp_Pnt2d(200.,-100.);
1800 	p2 = gp_Pnt2d(100.,-100.);
1801 	aline = GCE2d_MakeLine(p1,p2).Value();
1802 	MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1803 	p1 = p2;
1804 	p2 = gp_Pnt2d(100.,-200.);
1805 	aline = GCE2d_MakeLine(p1,p2).Value();
1806 	MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1807 	p1 = p2;
1808 	p2 = gp_Pnt2d(200.,-200.);
1809 	aline = GCE2d_MakeLine(p1,p2).Value();
1810 	MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1811 	p1 = p2;
1812 	p2 = gp_Pnt2d(200.,-100.);
1813 	aline = GCE2d_MakeLine(p1,p2).Value();
1814 	MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1815 	BRepBuilderAPI_MakeFace MKF;
1816 	MKF.Init(surf,Standard_False, Precision::Confusion());
1817 	MKF.Add(MW.Wire());
1818 	TopoDS_Shape FP = MKF.Face();
1819 	BRepLib::BuildCurves3d(FP);
1820 	BRepFeat_MakePrism MKP(S,FP,F,D,0,Standard_True);
1821 	MKP.Perform(200.);
1822 	TopoDS_Shape res1 = MKP.Shape();
1823 	ais1->Set(res1);
1824 
1825 	myAISContext->Redisplay(ais1,Standard_False);
1826 	myAISContext->SetSelected(anIO1,Standard_False);
1827 	Fit();
1828 	Sleep(500);
1829 
1830 	Ex.Next();
1831 	TopoDS_Face F2 = TopoDS::Face(Ex.Current());
1832 	surf = BRep_Tool::Surface(F2);
1833 	Pl = Handle(Geom_Plane)::DownCast(surf);
1834 	D = Pl->Pln().Axis().Direction();
1835 	D.Reverse();
1836 	BRepBuilderAPI_MakeWire MW2;
1837 	p1 = gp_Pnt2d(100.,100.);
1838 	p2 = gp_Pnt2d(200.,100.);
1839 	aline = GCE2d_MakeLine(p1,p2).Value();
1840 	MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1841 	p1 = p2;
1842 	p2 = gp_Pnt2d(150.,200.);
1843 	aline = GCE2d_MakeLine(p1,p2).Value();
1844 	MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1845 	p1 = p2;
1846 	p2 = gp_Pnt2d(100.,100.);
1847 	aline = GCE2d_MakeLine(p1,p2).Value();
1848 	MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1849 	BRepBuilderAPI_MakeFace MKF2;
1850 	MKF2.Init(surf,Standard_False, Precision::Confusion());
1851 	MKF2.Add(MW2.Wire());
1852 	FP = MKF2.Face();
1853 	BRepLib::BuildCurves3d(FP);
1854 	BRepFeat_MakePrism MKP2(res1,FP,F2,D,1,Standard_True);
1855 	MKP2.Perform(100.);
1856 	TopoDS_Shape res2 = MKP2.Shape();
1857 	ais1->Set(res2);
1858 
1859 	myAISContext->Redisplay (ais1, Standard_False);
1860 	myAISContext->SetSelected (anIO1, Standard_False);
1861 	Fit();
1862 
1863 	TCollection_AsciiString Message ("\
1864 	\n\
1865 --- Extrusion ---\n\
1866 	\n\
1867 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
1868 TopExp_Explorer Ex;\n\
1869 Ex.Init(S,TopAbs_FACE);\n\
1870 Ex.Next();\n\
1871 TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
1872 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);\n\
1873 Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);\n\
1874 gp_Dir D = Pl->Pln().Axis().Direction();\n\
1875 D.Reverse();\n\
1876 gp_Pnt2d p1,p2;\n\
1877 Handle(Geom2d_Curve) aline;\n\
1878 BRepBuilderAPI_MakeWire MW;\n\
1879 p1 = gp_Pnt2d(200.,-100.);\n\
1880 p2 = gp_Pnt2d(100.,-100.);\n\
1881 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1882 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1883 p1 = p2;\n\
1884 p2 = gp_Pnt2d(100.,-200.);\n\
1885 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1886 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1887 p1 = p2;\n\
1888 p2 = gp_Pnt2d(200.,-200.);\n\
1889 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1890 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1891 p1 = p2;\n\
1892 p2 = gp_Pnt2d(200.,-100.);\n\
1893 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1894 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1895 BRepBuilderAPI_MakeFace MKF;\n\
1896 MKF.Init(surf,Standard_False);\n\
1897 MKF.Add(MW.Wire());\n\
1898 TopoDS_Shape FP = MKF.Face();\n\
1899 BRepLib::BuildCurves3d(FP);\n\
1900 BRepFeat_MakePrism MKP(S,FP,F,D,0,Standard_True);\n\
1901 MKP.Perform(200);\n\
1902 TopoDS_Shape res1 = MKP.Shape();\n\
1903 	\n");
1904 		Message += "\n\
1905 --- Protrusion --- \n\
1906 \n\
1907 Ex.Next();\n\
1908 TopoDS_Face F2 = TopoDS::Face(Ex.Current());\n\
1909 surf = BRep_Tool::Surface(F2);\n\
1910 Pl = Handle(Geom_Plane)::DownCast(surf);\n\
1911 D = Pl->Pln().Axis().Direction();\n\
1912 D.Reverse();\n\
1913 BRepBuilderAPI_MakeWire MW2;\n\
1914 p1 = gp_Pnt2d(100.,100.);\n\
1915 p2 = gp_Pnt2d(200.,100.);\n\
1916 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1917 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1918 p1 = p2;\n\
1919 p2 = gp_Pnt2d(150.,200.);\n\
1920 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1921 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1922 p1 = p2;\n\
1923 p2 = gp_Pnt2d(100.,100.);\n\
1924 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1925 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1926 BRepBuilderAPI_MakeFace MKF2;\n\
1927 MKF2.Init(surf,Standard_False);\n\
1928 MKF2.Add(MW2.Wire());\n\
1929 FP = MKF2.Face();\n\
1930 BRepLib::BuildCurves3d(FP);\n\
1931 BRepFeat_MakePrism MKP2(res1,FP,F2,D,1,Standard_True);\n\
1932 MKP2.Perform(100.);\n\
1933 TopoDS_Shape res2 = MKP2.Shape();\n\
1934 	\n";
1935 	PocessTextInDialog("Make an extrusion or a protrusion", Message);
1936 }
1937 
1938 //
1939 // BRepFeat_MakeDPrism
1940 //
OnDprismLocal()1941 void CModelingDoc::OnDprismLocal()
1942 {
1943 	AIS_ListOfInteractive aList;
1944 	myAISContext->DisplayedObjects(aList);
1945 	AIS_ListIteratorOfListOfInteractive aListIterator;
1946 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1947 		myAISContext->Remove (aListIterator.Value(), Standard_False);
1948 	}
1949 
1950   TopoDS_Shape S = BRepPrimAPI_MakeBox(400., 250., 300.).Shape();
1951 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
1952 
1953 	myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
1954 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1955 
1956 	TopExp_Explorer Ex;
1957 	Ex.Init(S,TopAbs_FACE);
1958 	Ex.Next();
1959 	Ex.Next();
1960 	Ex.Next();
1961 	Ex.Next();
1962 	Ex.Next();
1963 	TopoDS_Face F = TopoDS::Face(Ex.Current());
1964 	Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
1965 	gp_Circ2d c(gp_Ax2d(gp_Pnt2d(200.,130.),gp_Dir2d(1.,0.)),50.);
1966 	BRepBuilderAPI_MakeWire MW;
1967 	Handle(Geom2d_Curve) aline = new Geom2d_Circle(c);
1968 	MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,M_PI));
1969 	MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,M_PI,2.*M_PI));
1970 	BRepBuilderAPI_MakeFace MKF;
1971 	MKF.Init(surf,Standard_False, Precision::Confusion());
1972 	MKF.Add(MW.Wire());
1973 	TopoDS_Face FP = MKF.Face();
1974 	BRepLib::BuildCurves3d(FP);
1975 	BRepFeat_MakeDPrism MKDP(S,FP,F,10*M_PI/180,1,Standard_True);
1976 	MKDP.Perform(200);
1977 	TopoDS_Shape res1 = MKDP.Shape();
1978 
1979 	myAISContext->Display(ais1,Standard_False);
1980 	const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1981 	myAISContext->SetSelected (anIO1, Standard_False);
1982 	Fit();
1983 	Sleep(500);
1984 
1985 	ais1->Set(res1);
1986 
1987 	myAISContext->Redisplay(ais1,Standard_False);
1988 	myAISContext->SetSelected(anIO1,Standard_False);
1989 
1990 	Fit();
1991 
1992 	TCollection_AsciiString Message ("\
1993 	\n\
1994 --- Protrusion with draft angle --- \n\
1995 	\n\
1996 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
1997 TopExp_Explorer Ex;\n\
1998 Ex.Init(S,TopAbs_FACE);\n\
1999 Ex.Next();\n\
2000 Ex.Next();\n\
2001 Ex.Next();\n\
2002 Ex.Next();\n\
2003 Ex.Next();\n\
2004 TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
2005 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);\n\
2006 gp_Circ2d c(gp_Ax2d(gp_Pnt2d(200.,130.),gp_Dir2d(1.,0.)),50.);\n\
2007 BRepBuilderAPI_MakeWire MW;\n\
2008 Handle(Geom2d_Curve) aline = new Geom2d_Circle(c);\n\
2009 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,PI));\n\
2010 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,PI,2.*PI));\n\
2011 BRepBuilderAPI_MakeFace MKF;\n\
2012 MKF.Init(surf,Standard_False);\n\
2013 MKF.Add(MW.Wire());\n\
2014 TopoDS_Face FP = MKF.Face();\n\
2015 BRepLib::BuildCurves3d(FP);\n\
2016 BRepFeat_MakeDPrism MKDP(S,FP,F,10*PI180,1,Standard_True);\n\
2017 MKDP.Perform(200);\n\
2018 TopoDS_Shape res1 = MKDP.Shape();\n\
2019 	\n");
2020 	PocessTextInDialog("Make an extrusion or a protrusion with a draft angle", Message);
2021 }
2022 
OnRevolLocal()2023 void CModelingDoc::OnRevolLocal()
2024 {
2025 	AIS_ListOfInteractive aList;
2026 	myAISContext->DisplayedObjects(aList);
2027 	AIS_ListIteratorOfListOfInteractive aListIterator;
2028 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2029 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2030 	}
2031   TopoDS_Shape S = BRepPrimAPI_MakeBox(400., 250., 300.).Shape();
2032 
2033 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2034 
2035 	myAISContext->SetColor(ais1,Quantity_NOC_CORAL,Standard_False);
2036 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2037 	myAISContext->Display(ais1,Standard_False);
2038 	const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2039 	myAISContext->SetSelected (anIO1, Standard_False);
2040 	Fit();
2041 	Sleep(500);
2042 
2043 	TopExp_Explorer Ex;
2044 	Ex.Init(S,TopAbs_FACE);
2045 	Ex.Next();
2046 	Ex.Next();
2047 	TopoDS_Face F1 = TopoDS::Face(Ex.Current());
2048 	Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);
2049 	Handle (Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);
2050 	gp_Ax1 D = gp::OX();
2051 	BRepBuilderAPI_MakeWire MW1;
2052 	gp_Pnt2d p1,p2;
2053 	p1 = gp_Pnt2d(100.,100.);
2054 	p2 = gp_Pnt2d(200.,100.);
2055 	Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();
2056 	MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2057 	p1 = p2;
2058 	p2 = gp_Pnt2d(150.,200.);
2059 	aline = GCE2d_MakeLine(p1,p2).Value();
2060 	MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2061 	p1 = p2;
2062 	p2 = gp_Pnt2d(100.,100.);
2063 	aline = GCE2d_MakeLine(p1,p2).Value();
2064 	MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2065 	BRepBuilderAPI_MakeFace MKF1;
2066 	MKF1.Init(surf,Standard_False, Precision::Confusion());
2067 	MKF1.Add(MW1.Wire());
2068 	TopoDS_Face FP = MKF1.Face();
2069 	BRepLib::BuildCurves3d(FP);
2070 	BRepFeat_MakeRevol MKrev(S,FP,F1,D,1,Standard_True);
2071 	Ex.Next();
2072 	Ex.Next();
2073 	TopoDS_Face F2 = TopoDS::Face(Ex.Current());
2074 	MKrev.Perform(F2);
2075 	TopoDS_Shape res1 = MKrev.Shape();
2076 
2077 
2078 	myAISContext->Remove (ais1, Standard_False);
2079 	Handle(AIS_Shape) ais2 = new AIS_Shape(res1);
2080 	myAISContext->Display(ais2,Standard_False);
2081 	const Handle(AIS_InteractiveObject)& anIO2 = ais2;
2082 	myAISContext->SetSelected (anIO2, Standard_False);
2083 	Fit();
2084 
2085 	TCollection_AsciiString Message ("\
2086 	\n\
2087 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
2088 TopExp_Explorer Ex;\n\
2089 Ex.Init(S,TopAbs_FACE);\n\
2090 Ex.Next();\n\
2091 Ex.Next();\n\
2092 TopoDS_Face F1 = TopoDS::Face(Ex.Current());\n\
2093 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);\n\
2094 Handle (Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);\n\
2095 gp_Ax1 D = gp::OX();\n\
2096 BRepBuilderAPI_MakeWire MW1;\n\
2097 gp_Pnt2d p1,p2;\n\
2098 p1 = gp_Pnt2d(100.,100.);\n\
2099 p2 = gp_Pnt2d(200.,100.);\n\
2100 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();\n\
2101 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2102 p1 = p2;\n\
2103 p2 = gp_Pnt2d(150.,200.);\n\
2104 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2105 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2106 p1 = p2;\n\
2107 p2 = gp_Pnt2d(100.,100.);\n\
2108 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2109 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2110 BRepBuilderAPI_MakeFace MKF1;\n\
2111 MKF1.Init(surf,Standard_False);\n\
2112 MKF1.Add(MW1.Wire());\n\
2113 TopoDS_Face FP = MKF1.Face();\n\
2114 BRepLib::BuildCurves3d(FP);\n\
2115 BRepFeat_MakeRevol MKrev(S,FP,F1,D,1,Standard_True);\n\
2116 Ex.Next();\n\
2117 TopoDS_Face F2 = TopoDS::Face(Ex.Current());\n\
2118 MKrev.Perform(F2);\n\
2119 TopoDS_Shape res1 = MKrev.Shape();\n\
2120 	\n");
2121   PocessTextInDialog("Make a local revolution", Message);
2122 }
2123 
OnGlueLocal()2124 void CModelingDoc::OnGlueLocal()
2125 {
2126 	AIS_ListOfInteractive aList;
2127 	myAISContext->DisplayedObjects(aList);
2128 	AIS_ListIteratorOfListOfInteractive aListIterator;
2129 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2130 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2131 	}
2132   TopoDS_Shape S1 = BRepPrimAPI_MakeBox(gp_Pnt(-500., -500., 0.), gp_Pnt(-100., -250., 300.)).Shape();
2133 
2134 	Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
2135 	myAISContext->SetColor(ais1,Quantity_NOC_ORANGE,Standard_False);
2136 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2137 	myAISContext->Display(ais1,Standard_False);
2138 	const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2139 	myAISContext->SetSelected (anIO1, Standard_False);
2140 	Fit();
2141 	Sleep(1000);
2142 
2143 	TopExp_Explorer Ex1;
2144 	Ex1.Init(S1,TopAbs_FACE);
2145 	Ex1.Next();
2146 	Ex1.Next();
2147 	Ex1.Next();
2148 	Ex1.Next();
2149 	Ex1.Next();
2150 	TopoDS_Face F1 = TopoDS::Face(Ex1.Current());
2151   TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(-400., -400., 300.), gp_Pnt(-200., -300., 500.)).Shape();
2152 	Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
2153 
2154 	myAISContext->SetColor(ais2,Quantity_NOC_AZURE,Standard_False);
2155 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
2156 	myAISContext->Display(ais2,Standard_False);
2157 	const Handle(AIS_InteractiveObject)& anIO2 = ais2;
2158 	myAISContext->SetSelected (anIO2, Standard_False);
2159 	Fit();
2160 	Sleep(1000);
2161 
2162 	TopExp_Explorer Ex2;
2163 	Ex2.Init(S2,TopAbs_FACE);
2164 	Ex2.Next();
2165 	Ex2.Next();
2166 	Ex2.Next();
2167 	Ex2.Next();
2168 	TopoDS_Face F2 = TopoDS::Face(Ex2.Current());
2169 	BRepFeat_Gluer glue(S2,S1);
2170 	glue.Bind(F2,F1);
2171 	TopoDS_Shape res1 = glue.Shape();
2172 	myAISContext->Erase(ais2,Standard_False);
2173 
2174 	ais1->Set(res1);
2175 
2176 	myAISContext->Redisplay (ais1, Standard_False);
2177 	myAISContext->SetSelected(anIO1,Standard_False);
2178 	Fit();
2179 	Sleep(1000);
2180 
2181   TopoDS_Shape S3 = BRepPrimAPI_MakeBox(500., 400., 300.).Shape();
2182 
2183 	Handle(AIS_Shape) ais3 = new AIS_Shape(S3);
2184 	myAISContext->SetColor(ais3,Quantity_NOC_ORANGE,Standard_False);
2185 	myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
2186 	myAISContext->Display(ais3,Standard_False);
2187 	const Handle(AIS_InteractiveObject)& anIO3 = ais3;
2188 	myAISContext->SetSelected (anIO3, Standard_False);
2189 	Fit();
2190 	Sleep(1000);
2191 
2192 	TopExp_Explorer Ex3;
2193 	Ex3.Init(S3,TopAbs_FACE);
2194 	Ex3.Next();
2195 	Ex3.Next();
2196 	Ex3.Next();
2197 	Ex3.Next();
2198 	Ex3.Next();
2199 	TopoDS_Face F3 = TopoDS::Face(Ex3.Current());
2200   TopoDS_Shape S4 = BRepPrimAPI_MakeBox(gp_Pnt(0., 0., 300.), gp_Pnt(200., 200., 500.)).Shape();
2201 
2202 	Handle(AIS_Shape) ais4 = new AIS_Shape(S4);
2203 	myAISContext->SetColor(ais4,Quantity_NOC_AZURE,Standard_False);
2204 	myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
2205 	myAISContext->Display(ais4,Standard_False);
2206 	const Handle(AIS_InteractiveObject)& anIO4 = ais4;
2207 	myAISContext->SetSelected (anIO4, Standard_False);
2208 	Fit();
2209 	Sleep(1000);
2210 
2211 	TopExp_Explorer Ex4;
2212 	Ex4.Init(S4,TopAbs_FACE);
2213 	Ex4.Next();
2214 	Ex4.Next();
2215 	Ex4.Next();
2216 	Ex4.Next();
2217 	TopoDS_Face F4 = TopoDS::Face(Ex4.Current());
2218 	BRepFeat_Gluer glue2(S4,S3);
2219 	glue2.Bind(F4,F3);
2220 	LocOpe_FindEdges CommonEdges(F4,F3);
2221 	for (CommonEdges.InitIterator(); CommonEdges.More(); CommonEdges.Next())
2222 		glue2.Bind(CommonEdges.EdgeFrom(),CommonEdges.EdgeTo());
2223 	TopoDS_Shape res2 = glue2.Shape();
2224 	myAISContext->Erase(ais3,Standard_False);
2225 
2226 	ais4->Set(res2);
2227 
2228 	myAISContext->Redisplay(ais4,Standard_False);
2229 	myAISContext->SetSelected(anIO4,Standard_False);
2230 	Fit();
2231 	Sleep(1000);
2232 
2233 	TCollection_AsciiString Message ("\
2234 	\n\
2235 --- Without common edges ---\n\
2236 	\n\
2237 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(gp_Pnt(-500.,-500.,0.),gp_Pnt(-100.,-250.,300.));\n\
2238 TopExp_Explorer Ex1;\n\
2239 Ex1.Init(S1,TopAbs_FACE);\n\
2240 Ex1.Next();\n\
2241 Ex1.Next();\n\
2242 Ex1.Next();\n\
2243 Ex1.Next();\n\
2244 Ex1.Next();\n\
2245 TopoDS_Face F1 = TopoDS::Face(Ex1.Current());\n\
2246 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(-400.,-400.,300.),gp_Pnt(-200.,-300.,500.));\n\
2247 TopExp_Explorer Ex2;\n\
2248 Ex2.Init(S2,TopAbs_FACE);\n\
2249 Ex2.Next();\n\
2250 Ex2.Next();\n\
2251 Ex2.Next();\n\
2252 Ex2.Next();\n\
2253 TopoDS_Face F2 = TopoDS::Face(Ex2.Current());\n\
2254 BRepFeat_Gluer glue(S2,S1);\n\
2255 glue.Bind(F2,F1);\n\
2256 TopoDS_Shape res1 = glue.Shape();\n\
2257 \n\
2258 --- With common edges ---\n\
2259 \n\
2260 TopoDS_Shape S3 = BRepPrimAPI_MakeBox(500.,400.,300.);\n\
2261 TopExp_Explorer Ex3;\n\
2262 Ex3.Init(S3,TopAbs_FACE);\n\
2263 Ex3.Next();\n\
2264 Ex3.Next();\n\
2265 Ex3.Next();\n\
2266 Ex3.Next();\n\
2267 Ex3.Next();\n\
2268 TopoDS_Face F3 = TopoDS::Face(Ex3.Current());\n\
2269 TopoDS_Shape S4 = BRepPrimAPI_MakeBox(gp_Pnt(0.,0.,300.),gp_Pnt(200.,200.,500.));\n\
2270 TopExp_Explorer Ex4;\n\
2271 Ex4.Init(S4,TopAbs_FACE);\n\
2272 Ex4.Next();\n\
2273 Ex4.Next();\n\
2274 Ex4.Next();\n\
2275 Ex4.Next();\n\
2276 TopoDS_Face F4 = TopoDS::Face(Ex4.Current());\n\
2277 BRepFeat_Gluer glue2(S4,S3);\n\
2278 glue2.Bind(F4,F3);\n\
2279 LocOpe_FindEdges CommonEdges(F4,F3);\n\
2280 for (CommonEdges.InitIterator(); CommonEdges.More(); CommonEdges.Next()) \n\
2281 	glue2.Bind(CommonEdges.EdgeFrom(),CommonEdges.EdgeTo());\n\
2282 TopoDS_Shape res2 = glue2.Shape();\n\
2283 	\n");
2284   PocessTextInDialog("Glue two solids", Message);
2285 }
2286 
2287 
OnPipeLocal()2288 void CModelingDoc::OnPipeLocal()
2289 {
2290 	AIS_ListOfInteractive aList;
2291 	myAISContext->DisplayedObjects(aList);
2292 	AIS_ListIteratorOfListOfInteractive aListIterator;
2293 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2294 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2295 	}
2296   TopoDS_Shape S = BRepPrimAPI_MakeBox(400., 250., 300.).Shape();
2297 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2298 
2299 	myAISContext->SetColor(ais1,Quantity_NOC_CORAL,Standard_False);
2300 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2301 	myAISContext->Display(ais1,Standard_False);
2302 	const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2303 	myAISContext->SetSelected (anIO1, Standard_False);
2304 	Fit();
2305 	Sleep(500);
2306 
2307 	TopExp_Explorer Ex;
2308 	Ex.Init(S,TopAbs_FACE);
2309 	Ex.Next();
2310 	Ex.Next();
2311 	TopoDS_Face F1 = TopoDS::Face(Ex.Current());
2312 	Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);
2313 	BRepBuilderAPI_MakeWire MW1;
2314 	gp_Pnt2d p1,p2;
2315 	p1 = gp_Pnt2d(100.,100.);
2316 	p2 = gp_Pnt2d(200.,100.);
2317 	Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();
2318 	MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2319 	p1 = p2;
2320 	p2 = gp_Pnt2d(150.,200.);
2321 	aline = GCE2d_MakeLine(p1,p2).Value();
2322 	MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2323 	p1 = p2;
2324 	p2 = gp_Pnt2d(100.,100.);
2325 	aline = GCE2d_MakeLine(p1,p2).Value();
2326 	MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2327 	BRepBuilderAPI_MakeFace MKF1;
2328 	MKF1.Init(surf,Standard_False, Precision::Confusion());
2329 	MKF1.Add(MW1.Wire());
2330 	TopoDS_Face FP = MKF1.Face();
2331 	BRepLib::BuildCurves3d(FP);
2332 	TColgp_Array1OfPnt CurvePoles(1,3);
2333 	gp_Pnt pt = gp_Pnt(150.,0.,150.);
2334 	CurvePoles(1) = pt;
2335 	pt = gp_Pnt(200.,-100.,150.);
2336 	CurvePoles(2) = pt;
2337 	pt = gp_Pnt(150.,-200.,150.);
2338 	CurvePoles(3) = pt;
2339 	Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);
2340 	TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);
2341 	TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);
2342 	BRepFeat_MakePipe MKPipe(S,FP,F1,W,1,Standard_True);
2343 	MKPipe.Perform();
2344 	TopoDS_Shape res1 = MKPipe.Shape();
2345 	ais1->Set(res1);
2346 
2347 	myAISContext->Redisplay(ais1,Standard_False);
2348 	myAISContext->SetSelected(anIO1,Standard_False);
2349 	Fit();
2350 
2351 	TCollection_AsciiString Message ("\
2352 	\n\
2353 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
2354 TopExp_Explorer Ex;\n\
2355 Ex.Init(S,TopAbs_FACE);\n\
2356 Ex.Next();\n\
2357 Ex.Next();\n\
2358 TopoDS_Face F1 = TopoDS::Face(Ex.Current());\n\
2359 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);\n\
2360 BRepBuilderAPI_MakeWire MW1;\n\
2361 gp_Pnt2d p1,p2;\n\
2362 p1 = gp_Pnt2d(100.,100.);\n\
2363 p2 = gp_Pnt2d(200.,100.);\n\
2364 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();\n\
2365 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2366 p1 = p2;\n\
2367 p2 = gp_Pnt2d(150.,200.);\n\
2368 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2369 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2370 p1 = p2;\n\
2371 p2 = gp_Pnt2d(100.,100.);\n\
2372 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2373 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2374 BRepBuilderAPI_MakeFace MKF1;\n\
2375 MKF1.Init(surf,Standard_False);\n\
2376 TopoDS_Face FP = MKF1.Face();\n\
2377 BRepLib::BuildCurves3d(FP);\n\
2378 TColgp_Array1OfPnt CurvePoles(1,3);\n\
2379 gp_Pnt pt = gp_Pnt(150.,0.,150.);\n\
2380 CurvePoles(1) = pt;\n\
2381 pt = gp_Pnt(200.,-100.,150.);\n\
2382 CurvePoles(2) = pt;\n\
2383 pt = gp_Pnt(150.,-200.,150.);\n\
2384 CurvePoles(3) = pt;\n\
2385 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);\n\
2386 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);\n\
2387 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);\n\
2388 BRepFeat_MakePipe MKPipe(S,FP,F1,W,1,Standard_True);\n\
2389 MKPipe.Perform();\n\
2390 TopoDS_Shape res1 = MKPipe.Shape();\n\
2391 	\n");
2392   PocessTextInDialog("Make a local pipe", Message);
2393 }
2394 
2395 
OnLinearLocal()2396 void CModelingDoc::OnLinearLocal()
2397 {
2398 	AIS_ListOfInteractive aList;
2399 	myAISContext->DisplayedObjects(aList);
2400 	AIS_ListIteratorOfListOfInteractive aListIterator;
2401 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2402 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2403 	}
2404 	BRepBuilderAPI_MakeWire mkw;
2405 	gp_Pnt p1 = gp_Pnt(0.,0.,0.);
2406 	gp_Pnt p2 = gp_Pnt(200.,0.,0.);
2407 	mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2408 	p1 = p2;
2409 	p2 = gp_Pnt(200.,0.,50.);
2410 	mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2411 	p1 = p2;
2412 	p2 = gp_Pnt(50.,0.,50.);
2413 	mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2414 	p1 = p2;
2415 	p2 = gp_Pnt(50.,0.,200.);
2416 	mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2417 	p1 = p2;
2418 	p2 = gp_Pnt(0.,0.,200.);
2419 	mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2420 	p1 = p2;
2421 	mkw.Add(BRepBuilderAPI_MakeEdge(p2,gp_Pnt(0.,0.,0.)));
2422 
2423 	TopoDS_Shape S = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(mkw.Wire()),
2424 									   gp_Vec(gp_Pnt(0.,0.,0.),gp_Pnt(0.,100.,0.)));
2425 
2426 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2427 	myAISContext->SetColor(ais1,Quantity_NOC_CYAN2,Standard_False);
2428 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2429 	myAISContext->Display(ais1,Standard_False);
2430 	const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2431 	myAISContext->SetSelected (anIO1, Standard_False);
2432 	Fit();
2433 	Sleep(500);
2434 
2435 	TopoDS_Wire W = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(gp_Pnt(50.,45.,100.),
2436 													  gp_Pnt(100.,45.,50.)));
2437 	Handle(Geom_Plane) aplane = new Geom_Plane(0.,1.,0.,-45.);
2438 	BRepFeat_MakeLinearForm aform(S, W, aplane, gp_Vec(0.,10.,0.), gp_Vec(0.,0.,0.),
2439 								  1, Standard_True);
2440 	aform.Perform(/*10.*/); // new in 2.0
2441 
2442 	TopoDS_Shape res = aform.Shape();
2443 	ais1->Set(res);
2444 	myAISContext->Redisplay(ais1,Standard_False);
2445 	myAISContext->SetSelected (anIO1, Standard_False);
2446 	Fit();
2447 
2448 	TCollection_AsciiString Message ("\
2449 	\n\
2450 BRepBuilderAPI_MakeWire mkw;\n\
2451 gp_Pnt p1 = gp_Pnt(0.,0.,0.);\n\
2452 gp_Pnt p2 = gp_Pnt(200.,0.,0.);\n\
2453 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2454 p1 = p2;\n\
2455 p2 = gp_Pnt(200.,0.,50.);\n\
2456 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2457 p1 = p2;\n\
2458 p2 = gp_Pnt(50.,0.,50.);\n\
2459 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2460 p1 = p2;\n\
2461 p2 = gp_Pnt(50.,0.,200.);\n\
2462 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2463 p1 = p2;\n\
2464 p2 = gp_Pnt(0.,0.,200.);\n\
2465 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2466 p1 = p2;\n\
2467 mkw.Add(BRepBuilderAPI_MakeEdge(p2,gp_Pnt(0.,0.,0.)));\n\
2468 TopoDS_Shape S = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(mkw.Wire()), \n\
2469 								gp_Vec(gp_Pnt(0.,0.,0.),gp_Pnt(0.,100.,0.)));\n\
2470 TopoDS_Wire W = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(gp_Pnt(50.,45.,100.),\n\
2471 												gp_Pnt(100.,45.,50.)));\n\
2472 Handle(Geom_Plane) aplane = new Geom_Plane(0.,1.,0.,-45.);\n\
2473 BRepFeat_MakeLinearForm aform(S, W, aplane, gp_Dir(0.,10.,0.), gp_Dir(0.,0.,0.),\n\
2474 							1, Standard_True);\n\
2475 aform.Perform(10.);\n\
2476 TopoDS_Shape res = aform.Shape();\n\
2477 	\n");
2478   PocessTextInDialog("Make a rib", Message);
2479 }
2480 
2481 
OnSplitLocal()2482 void CModelingDoc::OnSplitLocal()
2483 {
2484 	AIS_ListOfInteractive aList;
2485 	myAISContext->DisplayedObjects(aList);
2486 	AIS_ListIteratorOfListOfInteractive aListIterator;
2487 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2488 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2489 	}
2490 
2491   TopoDS_Shape S = BRepPrimAPI_MakeBox(gp_Pnt(-100, -60, -80), 150, 200, 170).Shape();
2492 
2493 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2494 	myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
2495 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2496 	myAISContext->Display(ais1,Standard_False);
2497 	const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2498 	myAISContext->SetSelected (anIO1, Standard_False);
2499 	Fit();
2500 	Sleep(500);
2501 
2502 	BRepAlgoAPI_Section asect(S, gp_Pln(1,2,1,-15),Standard_False);
2503 	asect.ComputePCurveOn1(Standard_True);
2504 	asect.Approximation(Standard_True);
2505 	asect.Build();
2506 	TopoDS_Shape R = asect.Shape();
2507 
2508 	BRepFeat_SplitShape asplit(S);
2509 
2510 	for (TopExp_Explorer Ex(R,TopAbs_EDGE); Ex.More(); Ex.Next()) {
2511 		TopoDS_Shape anEdge = Ex.Current();
2512 		TopoDS_Shape aFace;
2513 		if (asect.HasAncestorFaceOn1(anEdge,aFace)) {
2514 			TopoDS_Face F = TopoDS::Face(aFace);
2515 			TopoDS_Edge E = TopoDS::Edge(anEdge);
2516 			asplit.Add(E,F);
2517 		}
2518 	}
2519 
2520 	asplit.Build();
2521 
2522 	//Sleep(1000);
2523 	myAISContext->Erase(ais1,Standard_False);
2524 	//Fit();
2525 
2526 	TopoDS_Shape Result = asplit.Shape();
2527 
2528 	Handle(AIS_Shape) ais2 = new AIS_Shape(Result);
2529 
2530 	myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False);
2531 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
2532 	myAISContext->SetDisplayMode(ais2,1,Standard_False);
2533 	myAISContext->Display(ais2,Standard_False);
2534 	const Handle(AIS_InteractiveObject)& anIO2 = ais2;
2535 	myAISContext->SetSelected (anIO2, Standard_False);
2536 	Fit();
2537 		TCollection_AsciiString Message ("\
2538 	\n\
2539 TopoDS_Shape S = BRepPrimAPI_MakeBox(gp_Pnt(-100,-60,-80),150,200,170); 	\n\
2540 		\n\
2541 BRepBuilderAPI_Section asect(S, gp_Pln(1,2,1,-15),Standard_False);	\n\
2542 asect.ComputePCurveOn1(Standard_True);	\n\
2543 asect.Approximation(Standard_True);	\n\
2544 asect.Build();	\n\
2545 TopoDS_Shape R = asect.Shape();	\n\
2546 	\n\
2547 BRepFeat_SplitShape asplit(S);	\n\
2548 	\n\
2549 for (TopExp_Explorer Ex(R,TopAbs_EDGE); Ex.More(); Ex.Next()) {	\n\
2550 TopoDS_Shape anEdge = Ex.Current();	\n\
2551 	TopoDS_Shape aFace;	\n\
2552 	if (asect.HasAncestorFaceOn1(anEdge,aFace)) {	\n\
2553 		TopoDS_Face F = TopoDS::Face(aFace);	\n\
2554 		TopoDS_Edge E = TopoDS::Edge(anEdge);	\n\
2555 		asplit.Add(E,F);	\n\
2556 	}	\n\
2557 }	\n\
2558 	\n\
2559 asplit.Build();	\n\
2560 	\n\
2561 TopoDS_Shape Result = asplit.Shape();	\n\
2562 	\n\
2563 \n");
2564 
2565 PocessTextInDialog("Split a shape", Message);
2566 }
2567 
2568 
2569 
OnThickLocal()2570 void CModelingDoc::OnThickLocal()
2571 {
2572 	AIS_ListOfInteractive L;
2573 	myAISContext->DisplayedObjects(L);
2574 	AIS_ListIteratorOfListOfInteractive aListIterator;
2575 	for(aListIterator.Initialize(L);aListIterator.More();aListIterator.Next()){
2576 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2577 	}
2578 
2579   TopoDS_Shape S1 = BRepPrimAPI_MakeBox(150, 200, 110).Shape();
2580 
2581 	Handle(AIS_Shape) abox1 = new AIS_Shape(S1);
2582 	myAISContext->SetColor (abox1, Quantity_NOC_WHITE, Standard_False);
2583 	myAISContext->SetMaterial(abox1,Graphic3d_NOM_PLASTIC,Standard_False);
2584 	myAISContext->Display(abox1,Standard_False);
2585 	const Handle(AIS_InteractiveObject)& anIOBox1 = abox1;
2586 	myAISContext->SetSelected (anIOBox1, Standard_False);
2587 	Fit();
2588 	Sleep(1000);
2589 
2590 	TopTools_ListOfShape aList;
2591 	TopExp_Explorer Ex(S1,TopAbs_FACE);
2592 	Ex.Next();	//this is the front face
2593 	TopoDS_Shape aFace = Ex.Current();
2594 	aList.Append(aFace);
2595 
2596     BRepOffsetAPI_MakeThickSolid aSolidMaker;
2597     aSolidMaker.MakeThickSolidByJoin(S1,aList,10,0.01);
2598 	TopoDS_Shape aThickSolid = aSolidMaker.Shape();
2599 
2600 	Handle(AIS_Shape) ais1 = new AIS_Shape(aThickSolid);
2601 	myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
2602 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2603 	myAISContext->Display(ais1,Standard_False);
2604 	const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2605 	myAISContext->SetSelected (anIO1, Standard_False);
2606 	Fit();
2607 	Sleep(1000);
2608 
2609 	myAISContext->Erase(abox1,Standard_True);
2610 	Fit();
2611 
2612 
2613 		TCollection_AsciiString Message ("\
2614 	\n\
2615 TopoDS_Shape S = BRepPrimAPI_MakeBox(150,200,110);	\n\
2616 	\n\
2617 TopTools_ListOfShape aList;	\n\
2618 TopExp_Explorer Ex(S,TopAbs_FACE);	\n\
2619 Ex.Next();	//in order to recover the front face	\n\
2620 TopoDS_Shape aFace = Ex.Current();	\n\
2621 aList.Append(aFace);	\n\
2622 			\n\
2623 TopoDS_Shape aThickSolid = BRepPrimAPI_MakeThickSolid(S,aList,15,0.01);	\n\
2624 	\n\
2625 \n");
2626 PocessTextInDialog("Make a thick solid", Message);
2627 }
2628 
OnOffsetLocal()2629 void CModelingDoc::OnOffsetLocal()
2630 {
2631 	AIS_ListOfInteractive aList;
2632 	myAISContext->DisplayedObjects(aList);
2633 	AIS_ListIteratorOfListOfInteractive aListIterator;
2634 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2635 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2636 	}
2637 
2638   TopoDS_Shape S1 = BRepPrimAPI_MakeBox(150, 200, 110).Shape();
2639 
2640 	Handle(AIS_Shape) aisBox1 = new AIS_Shape(S1);
2641 	myAISContext->SetColor(aisBox1,Quantity_NOC_BROWN,Standard_False);
2642 	myAISContext->SetMaterial(aisBox1,Graphic3d_NOM_GOLD,Standard_False);
2643 	myAISContext->Display(aisBox1,Standard_False);
2644 	Fit();
2645 	Sleep(500);
2646 
2647     BRepOffsetAPI_MakeOffsetShape aShapeMaker1;
2648     aShapeMaker1.PerformByJoin(S1,60,0.01);
2649 	TopoDS_Shape anOffsetShape1 = aShapeMaker1.Shape();
2650 
2651 	Handle(AIS_Shape) ais1 = new AIS_Shape(anOffsetShape1);
2652 	myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
2653 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_GOLD,Standard_False);
2654 	myAISContext->SetTransparency(ais1,0.5,Standard_False);
2655 	myAISContext->Display(ais1,Standard_False);
2656 	Fit();
2657 	Sleep(500);
2658 
2659   TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(500, 0, 0), 220, 140, 180).Shape();
2660 
2661 	Handle(AIS_Shape) aisBox2 = new AIS_Shape(S2);
2662 	myAISContext->SetColor(aisBox2,Quantity_NOC_WHITE,Standard_False);
2663 	myAISContext->SetMaterial(aisBox2,Graphic3d_NOM_GOLD,Standard_False);
2664 	myAISContext->SetTransparency(aisBox2,0.5,Standard_False);
2665 	myAISContext->Display(aisBox2,Standard_False);
2666 	Fit();
2667 	Sleep(500);
2668 
2669     BRepOffsetAPI_MakeOffsetShape aShapeMaker2;
2670     aShapeMaker2.PerformByJoin(S2,-40,0.01,
2671       BRepOffset_Skin,Standard_False,Standard_False,GeomAbs_Arc);
2672 	TopoDS_Shape anOffsetShape2 = aShapeMaker2.Shape();
2673 
2674 	Handle(AIS_Shape) ais2 = new AIS_Shape(anOffsetShape2);
2675 	myAISContext->SetColor (ais2, Quantity_NOC_MATRABLUE, Standard_False);
2676 	myAISContext->SetMaterial(ais2,Graphic3d_NOM_GOLD,Standard_False);
2677 	myAISContext->Display (ais2, Standard_False);
2678 	Fit();
2679 
2680 	TCollection_AsciiString Message ("\
2681 	\n\
2682 \n\
2683 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(150,200,110);	\n\
2684 \n\
2685 TopoDS_Shape anOffsetShape1 = BRepPrimAPI_MakeOffsetShape(S1,60,0.01);	\n\
2686 \n\
2687 //The white box	\n\
2688 	\n\
2689 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(300,0,0),220,140,180);	\n\
2690 \n\
2691 TopoDS_Shape anOffsetShape2 = BRepPrimAPI_MakeOffsetShape(S2,-20,0.01,	\n\
2692 	BRepOffset_Skin,Standard_False,Standard_False,GeomAbs_Arc);	\n\
2693 	\n\
2694 \n\
2695 \n");
2696 PocessTextInDialog("Make an offset shape", Message);
2697 
2698 }
2699 
2700 /* =================================================================================
2701    ====================   B U I L D I N G   ========================================
2702    ================================================================================= */
2703 
2704 
OnVertex()2705 void CModelingDoc::OnVertex()
2706 {
2707 	AIS_ListOfInteractive aList;
2708 	myAISContext->DisplayedObjects(aList);
2709 	AIS_ListIteratorOfListOfInteractive aListIterator;
2710 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2711 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2712 	}
2713 
2714 	TopoDS_Vertex V1,V2,V3;
2715 
2716 	V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
2717 	V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,25));
2718 
2719 	gp_Pnt P(-12,8,-4);
2720 	BRepBuilderAPI_MakeVertex MV(P);
2721 	V3 = MV.Vertex();
2722 
2723 	Handle(AIS_Shape) Point1 = new AIS_Shape(V1);
2724 	myAISContext->Display(Point1,Standard_False);
2725 	Handle(AIS_Shape) Point2 = new AIS_Shape(V2);
2726 	myAISContext->Display(Point2,Standard_False);
2727 	Handle(AIS_Shape) Point3 = new AIS_Shape(V3);
2728 	myAISContext->Display(Point3,Standard_False);
2729 
2730 	Fit();
2731 
2732    TCollection_AsciiString Message ("\
2733 		\n\
2734 TopoDS_Vertex V1,V2,V3;	\n\
2735 		\n\
2736 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));	\n\
2737 	\n\
2738 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,25));	\n\
2739 		\n\
2740 gp_Pnt P(-12,8,-4);	\n\
2741 BRepBuilderAPI_MakeVertex MV(P);	\n\
2742 V3 = MV.Vertex();	\n\
2743 	\n\
2744 \n");
2745 
2746 	PocessTextInDialog("Make vertex from point ", Message);
2747 
2748 }
2749 
OnEdge()2750 void CModelingDoc::OnEdge()
2751 {
2752 
2753 	AIS_ListOfInteractive aList;
2754 	myAISContext->DisplayedObjects(aList);
2755 	AIS_ListIteratorOfListOfInteractive aListIterator;
2756 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2757 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2758 	}
2759 
2760 
2761 	TopoDS_Edge BlueEdge,YellowEdge,WhiteEdge,RedEdge,GreenEdge;
2762 	TopoDS_Vertex V1,V2,V3,V4;
2763 
2764 /////////////The blue edge
2765 
2766 	BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80,-50,-20),gp_Pnt(-30,-60,-60));
2767 
2768 /////////////The yellow edge
2769 
2770 	V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));
2771 	V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,-25));
2772 	YellowEdge = BRepBuilderAPI_MakeEdge(V1,V2);
2773 
2774 /////////////The white edge
2775 
2776 	gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));
2777 	WhiteEdge = BRepBuilderAPI_MakeEdge(line,-20,10);
2778 
2779 //////////////The red edge
2780 
2781 	gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),60,30);
2782 	RedEdge = BRepBuilderAPI_MakeEdge(Elips,0,M_PI/2);
2783 
2784 /////////////The green edge and the both extreme vertex
2785 
2786 	gp_Pnt P1(-15,200,10);
2787 	gp_Pnt P2(5,204,0);
2788 	gp_Pnt P3(15,200,0);
2789 	gp_Pnt P4(-15,20,15);
2790 	gp_Pnt P5(-5,20,0);
2791 	gp_Pnt P6(15,20,0);
2792 	gp_Pnt P7(24,120,0);
2793 	gp_Pnt P8(-24,120,12.5);
2794 	TColgp_Array1OfPnt array(1,8);
2795 	array.SetValue(1,P1);
2796 	array.SetValue(2,P2);
2797 	array.SetValue(3,P3);
2798 	array.SetValue(4,P4);
2799 	array.SetValue(5,P5);
2800 	array.SetValue(6,P6);
2801 	array.SetValue(7,P7);
2802 	array.SetValue(8,P8);
2803 	Handle (Geom_BezierCurve) curve = new Geom_BezierCurve(array);
2804 
2805 	BRepBuilderAPI_MakeEdge ME (curve);
2806 	GreenEdge = ME;
2807 	V3 = ME.Vertex1();
2808 	V4 = ME.Vertex2();
2809 
2810 //////////////Display
2811 Handle(AIS_Shape) blue = new AIS_Shape(BlueEdge);
2812 myAISContext->SetColor(blue,Quantity_NOC_MATRABLUE,Standard_False);
2813 myAISContext->Display(blue,Standard_False);
2814 
2815 Handle(AIS_Shape) yellow = new AIS_Shape(YellowEdge);
2816 myAISContext->SetColor(yellow,Quantity_NOC_YELLOW,Standard_False);
2817 myAISContext->Display(yellow,Standard_False);
2818 
2819 Handle(AIS_Shape) white = new AIS_Shape(WhiteEdge);
2820 myAISContext->SetColor(white,Quantity_NOC_WHITE,Standard_False);
2821 myAISContext->Display(white,Standard_False);
2822 
2823 Handle(AIS_Shape) red = new AIS_Shape(RedEdge);
2824 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
2825 myAISContext->Display(red,Standard_False);
2826 
2827 Handle(AIS_Shape) green = new AIS_Shape(GreenEdge);
2828 myAISContext->SetColor(green,Quantity_NOC_GREEN,Standard_False);
2829 myAISContext->Display(green,Standard_False);
2830 
2831 Handle(AIS_Shape) Point1 = new AIS_Shape(V3);
2832 myAISContext->Display(Point1,Standard_False);
2833 Handle(AIS_Shape) Point2 = new AIS_Shape(V4);
2834 myAISContext->Display(Point2,Standard_False);
2835 
2836 Fit();
2837 
2838    TCollection_AsciiString Message ("\
2839 		\n\
2840 TopoDS_Edge BlueEdge, YellowEdge, WhiteEdge, RedEdge, GreenEdge;	\n\
2841 TopoDS_Vertex V1,V2,V3,V4;	\n\
2842 		\n\
2843 /////////////The blue edge	\n\
2844 	\n\
2845 BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80,-50,-20),gp_Pnt(-30,-60,-60));	\n\
2846 	\n\
2847 /////////////The yellow edge	\n\
2848 		\n\
2849 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));	\n\
2850 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,-25));	\n\
2851 YellowEdge = BRepBuilderAPI_MakeEdge(V1,V2);	\n\
2852 	\n\
2853 /////////////The white edge	\n\
2854 		\n\
2855 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));	\n\
2856 WhiteEdge = BRepBuilderAPI_MakeEdge(line,-20,10);	\n\
2857 	\n\
2858 //////////////The red edge	\n\
2859 	\n\
2860 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),60,30);	\n\
2861 RedEdge = BRepBuilderAPI_MakeEdge(Elips,0,PI/2);	\n\
2862 	\n\
2863 /////////////The green edge and the both extreme vertex	\n\
2864 	\n\
2865 gp_Pnt P1(-15,200,10);	\n\
2866 gp_Pnt P2(5,204,0);	\n\
2867 gp_Pnt P3(15,200,0);	\n\
2868 gp_Pnt P4(-15,20,15);	\n\
2869 gp_Pnt P5(-5,20,0);	\n\
2870 gp_Pnt P6(15,20,0);	\n\
2871 gp_Pnt P7(24,120,0);	\n\
2872 gp_Pnt P8(-24,120,12.5);	\n\
2873 TColgp_Array1OfPnt array(1,8);	\n\
2874 array.SetValue(1,P1);	\n\
2875 array.SetValue(2,P2);	\n\
2876 array.SetValue(3,P3); 	\n\
2877 array.SetValue(4,P4); 	\n\
2878 array.SetValue(5,P5); 	\n\
2879 array.SetValue(6,P6); 	\n\
2880 array.SetValue(7,P7); 	\n\
2881 array.SetValue(8,P8); 	\n\
2882 Handle (Geom_BezierCurve) curve = new Geom_BezierCurve(array);	\n\
2883 	\n\
2884 BRepBuilderAPI_MakeEdge ME (curve);	\n\
2885 GreenEdge = ME;	\n\
2886 V3 = ME.Vertex1();	\n\
2887 V4 = ME.Vertex2();	\n\
2888 	\n\
2889 \n");
2890 
2891 	PocessTextInDialog("Make edge", Message);
2892 
2893 }
2894 
OnWire()2895 void CModelingDoc::OnWire()
2896 {
2897 	AIS_ListOfInteractive aList;
2898 	myAISContext->DisplayedObjects(aList);
2899 	AIS_ListIteratorOfListOfInteractive aListIterator;
2900 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2901 		myAISContext->Remove (aListIterator.Value(), Standard_False);
2902 	}
2903 
2904 	TopoDS_Wire RedWire,YellowWire,WhiteWire,
2905 		ExistingWire, ExistingWire2;
2906 
2907 	TopoDS_Edge Edge1,Edge2,Edge3,Edge4,Edge5,Edge6,Edge7,LastEdge;
2908 	TopoDS_Vertex LastVertex;
2909 
2910 ////////////The red wire is build from a single edge
2911 
2912 	gp_Elips Elips(gp_Ax2(gp_Pnt(250,0,0),gp_Dir(1,1,1)),160,90);
2913 	Edge1 = BRepBuilderAPI_MakeEdge(Elips,0,M_PI/2);
2914 
2915 	RedWire = BRepBuilderAPI_MakeWire(Edge1);
2916 
2917 ///////////the yellow wire is build from an existing wire and an edge
2918 
2919 	gp_Circ circle(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(1,0,0)),80);
2920 	Edge2 = BRepBuilderAPI_MakeEdge(circle,0,M_PI);
2921 
2922 	ExistingWire = BRepBuilderAPI_MakeWire(Edge2);
2923 
2924 	Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(-300,0,-80),gp_Pnt(-90,20,-30));
2925 
2926 	BRepBuilderAPI_MakeWire MW1(ExistingWire,Edge3);
2927 	if (MW1.IsDone()) {
2928 			YellowWire = MW1;
2929 	}
2930 
2931 
2932 //////////the white wire is built with an existing wire and 3 edges.
2933 //////////we use the methods Add, Edge and Vertex from BRepBuilderAPI_MakeWire.
2934 
2935 	gp_Circ circle2(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)),200);
2936 	Edge4 = BRepBuilderAPI_MakeEdge(circle2,0,M_PI);
2937 
2938 	ExistingWire2 = BRepBuilderAPI_MakeWire(Edge4);
2939 
2940 	gp_Pnt P1(0,0,-200);
2941 	gp_Pnt P2(5,204,0);
2942 	Edge5 = BRepBuilderAPI_MakeEdge(P1,P2);
2943 
2944 	gp_Pnt P3(-15,20,15);
2945 	Edge6 = BRepBuilderAPI_MakeEdge(P2,P3);
2946 	gp_Pnt P4(15,20,0);
2947 	Edge7 = BRepBuilderAPI_MakeEdge(P3,P4);
2948 
2949 	BRepBuilderAPI_MakeWire MW;
2950 	MW.Add(ExistingWire2);
2951 	MW.Add(Edge5);
2952 	MW.Add(Edge6);
2953 	MW.Add(Edge7);
2954 
2955 	if (MW.IsDone()) {
2956 		WhiteWire = MW.Wire();
2957 		LastEdge = MW.Edge();
2958 		LastVertex = MW.Vertex();
2959 	}
2960 
2961 
2962 Handle(AIS_Shape) red = new AIS_Shape(RedWire);
2963 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
2964 myAISContext->Display(red,Standard_False);
2965 
2966 Handle(AIS_Shape) yellow = new AIS_Shape(YellowWire);
2967 myAISContext->SetColor(yellow,Quantity_NOC_YELLOW,Standard_False);
2968 myAISContext->Display(yellow,Standard_False);
2969 
2970 Handle(AIS_Shape) white = new AIS_Shape(WhiteWire);
2971 myAISContext->SetColor(white,Quantity_NOC_WHITE,Standard_False);
2972 myAISContext->Display(white,Standard_False);
2973 
2974 Handle(AIS_Shape) lastE = new AIS_Shape(LastEdge);
2975 myAISContext->SetWidth(lastE,3,Standard_False);
2976 myAISContext->SetColor(lastE,Quantity_NOC_RED,Standard_False);
2977 myAISContext->Display(lastE,Standard_False);
2978 
2979 Handle(AIS_Shape) lastV = new AIS_Shape(LastVertex);
2980 myAISContext->Display(lastV,Standard_False);
2981 
2982 Fit();
2983 
2984    TCollection_AsciiString Message ("\
2985 	\n\
2986 TopoDS_Wire RedWire,YellowWire,WhiteWire,	\n\
2987 ExistingWire, ExistingWire2;	\n\
2988 	\n\
2989 TopoDS_Edge Edge1,Edge2,Edge3,Edge4,Edge5,Edge6,Edge7,LastEdge;	\n\
2990 TopoDS_Vertex LastVertex;	\n\
2991 	\n\
2992 ////////////The red wire is build from a single edge	\n\
2993 	\n\
2994 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),160,90);	\n\
2995 Edge1 = BRepBuilderAPI_MakeEdge(Elips,0,PI/2);	\n\
2996 	\n\
2997 RedWire = BRepBuilderAPI_MakeWire(Edge1);	\n\
2998 	\n\
2999 ///////////the yellow wire is build from an existing wire and an edge	\n\
3000 		\n\
3001 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80);	\n\
3002 Edge2 = BRepBuilderAPI_MakeEdge(circle,0,PI);	\n\
3003 	\n\
3004 ExistingWire = BRepBuilderAPI_MakeWire(Edge2);	\n\
3005 	\n\
3006 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(90,20,30));	\n\
3007 	\n\
3008 BRepBuilderAPI_MakeWire MW1(ExistingWire,Edge3);	\n\
3009 if (MW1.IsDone()) {	\n\
3010 		YellowWire = MW1;	\n\
3011 }	\n\
3012 	\n\
3013 ///the white wire is built with an existing wire and 3 edges.	\n\
3014 ///we use the methods Add, Edge and Vertex from BRepBuilderAPI_MakeWire	\n\
3015 ///in order to display the last edge and the last vertices we	\n\
3016 ///add to the wire. 	\n\
3017 	\n\
3018 gp_Circ circle2(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)),200);	\n\
3019 Edge4 = BRepBuilderAPI_MakeEdge(circle2,0,PI);	\n\
3020 	\n\
3021 ExistingWire2 = BRepBuilderAPI_MakeWire(Edge4);	\n\
3022 	\n\
3023 gp_Pnt P1(0,0,-200);	\n\
3024 gp_Pnt P2(5,204,0);	\n\
3025 Edge5 = BRepBuilderAPI_MakeEdge(P1,P2);	\n\
3026 	\n\
3027 gp_Pnt P3(-15,20,15);	\n\
3028 Edge6 = BRepBuilderAPI_MakeEdge(P2,P3);	\n\
3029 gp_Pnt P4(15,20,0);		\n\
3030 Edge7 = BRepBuilderAPI_MakeEdge(P3,P4);	\n\
3031 	\n\
3032 BRepBuilderAPI_MakeWire MW;	\n\
3033 MW.Add(ExistingWire2);	\n\
3034 MW.Add(Edge5);	\n\
3035 MW.Add(Edge6);	\n\
3036 MW.Add(Edge7);	\n\
3037 	\n\
3038 if (MW.IsDone()) {	\n\
3039 	WhiteWire = MW.Wire();	\n\
3040 	LastEdge = MW.Edge();	\n\
3041 	LastVertex = MW.Vertex();	\n\
3042 }	\n\
3043 	\n\
3044 \n");
3045 
3046 	PocessTextInDialog("Make wire ", Message);
3047 }
3048 
OnFace()3049 void CModelingDoc::OnFace()
3050 {
3051 	AIS_ListOfInteractive aList;
3052 	myAISContext->DisplayedObjects(aList);
3053 	AIS_ListIteratorOfListOfInteractive aListIterator;
3054 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3055 		myAISContext->Remove (aListIterator.Value(), Standard_False);
3056 	}
3057 
3058 
3059 
3060 	TopoDS_Face WhiteFace, BrownFace, RedFace, PinkFace;
3061 	TopoDS_Edge Edge1, Edge2, Edge3, Edge4, Edge5, Edge6, Edge7;
3062 	TopoDS_Wire Wire1;
3063 	gp_Pnt P1, P2, P3, P4, P5, P6, P7;
3064 
3065 	gp_Sphere sphere (gp_Ax3(gp_Pnt(0,0,0),gp_Dir(1,0,0)),150);
3066 
3067 	WhiteFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);
3068 
3069 //////////////////////////////////
3070 
3071 	P1.SetCoord(-15,200,10);
3072 	P2.SetCoord(5,204,0);
3073 	P3.SetCoord(15,200,0);
3074 	P4.SetCoord(-15,20,15);
3075 	P5.SetCoord(-5,20,0);
3076 	P6.SetCoord(15,20,35);
3077 	TColgp_Array2OfPnt array(1,3,1,2);
3078 	array.SetValue(1,1,P1);
3079 	array.SetValue(2,1,P2);
3080 	array.SetValue(3,1,P3);
3081 	array.SetValue(1,2,P4);
3082 	array.SetValue(2,2,P5);
3083 	array.SetValue(3,2,P6);
3084 	Handle (Geom_BSplineSurface) curve = GeomAPI_PointsToBSplineSurface(array,3,8,GeomAbs_C2,0.001);
3085 
3086 	RedFace = BRepBuilderAPI_MakeFace(curve, Precision::Confusion());
3087 
3088 ////////////////////
3089 
3090 	gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80);
3091 	Edge1 = BRepBuilderAPI_MakeEdge(circle,0,M_PI);
3092 
3093 	Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(0,-10,40));
3094 	Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,-10,40),gp_Pnt(0,0,80));
3095 
3096 	TopoDS_Wire YellowWire;
3097 	BRepBuilderAPI_MakeWire MW1(Edge1,Edge2,Edge3);
3098 	if (MW1.IsDone()) {
3099 			YellowWire = MW1;
3100 	}
3101 
3102 	BrownFace = BRepBuilderAPI_MakeFace(YellowWire);
3103 
3104 
3105 /////////////
3106 
3107 	P1.SetCoord(35,-200,40);
3108 	P2.SetCoord(50,-204,30);
3109 	P3.SetCoord(65,-200,30);
3110 	P4.SetCoord(35,-20,45);
3111 	P5.SetCoord(45,-20,30);
3112 	P6.SetCoord(65,-20,65);
3113 	TColgp_Array2OfPnt array2(1,3,1,2);
3114 	array2.SetValue(1,1,P1);
3115 	array2.SetValue(2,1,P2);
3116 	array2.SetValue(3,1,P3);
3117 	array2.SetValue(1,2,P4);
3118 	array2.SetValue(2,2,P5);
3119 	array2.SetValue(3,2,P6);
3120 
3121 	Handle (Geom_BSplineSurface) BSplineSurf = GeomAPI_PointsToBSplineSurface(array2,3,8,GeomAbs_C2,0.001);
3122 
3123 	TopoDS_Face aFace = BRepBuilderAPI_MakeFace(BSplineSurf, Precision::Confusion());
3124 
3125 	//2d lines
3126 	gp_Pnt2d P12d(0.9,0.1);
3127 	gp_Pnt2d P22d(0.2,0.7);
3128 	gp_Pnt2d P32d(0.02,0.1);
3129 
3130 	Handle (Geom2d_Line) line1 = new Geom2d_Line(P12d,gp_Dir2d((0.2-0.9),(0.7-0.1)));
3131 	Handle (Geom2d_Line) line2 = new Geom2d_Line(P22d,gp_Dir2d((0.02-0.2),(0.1-0.7)));
3132 	Handle (Geom2d_Line) line3 = new Geom2d_Line(P32d,gp_Dir2d((0.9-0.02),(0.1-0.1)));
3133 
3134 
3135 	//Edges are on the BSpline surface
3136 	Edge1 = BRepBuilderAPI_MakeEdge(line1,BSplineSurf,0,P12d.Distance(P22d));
3137 	Edge2 = BRepBuilderAPI_MakeEdge(line2,BSplineSurf,0,P22d.Distance(P32d));
3138 	Edge3 = BRepBuilderAPI_MakeEdge(line3,BSplineSurf,0,P32d.Distance(P12d));
3139 
3140 	Wire1 = BRepBuilderAPI_MakeWire(Edge1,Edge2,Edge3);
3141 	Wire1.Reverse();
3142 	PinkFace = BRepBuilderAPI_MakeFace(aFace,Wire1);
3143 	BRepLib::BuildCurves3d(PinkFace);
3144 
3145 /////////////Display
3146 	Handle(AIS_Shape) white = new AIS_Shape(WhiteFace);
3147 	myAISContext->SetColor(white,Quantity_NOC_WHITE,Standard_False);
3148 	myAISContext->SetMaterial(white,Graphic3d_NOM_PLASTIC,Standard_False);
3149 	myAISContext->Display(white,Standard_False);
3150 
3151 	Handle(AIS_Shape) red = new AIS_Shape(RedFace);
3152 	myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
3153 	myAISContext->SetMaterial(red,Graphic3d_NOM_PLASTIC,Standard_False);
3154 	myAISContext->Display(red,Standard_False);
3155 
3156 	Handle(AIS_Shape) brown = new AIS_Shape(BrownFace);
3157 	myAISContext->SetColor(brown,Quantity_NOC_BROWN,Standard_False);
3158 	myAISContext->SetMaterial(brown,Graphic3d_NOM_PLASTIC,Standard_False);
3159 	myAISContext->Display(brown,Standard_False);
3160 
3161 	Handle(AIS_Shape) pink = new AIS_Shape(PinkFace);
3162 	myAISContext->SetColor(pink,Quantity_NOC_HOTPINK,Standard_False);
3163 	myAISContext->SetMaterial(pink,Graphic3d_NOM_PLASTIC,Standard_False);
3164 	myAISContext->Display(pink,Standard_False);
3165 
3166 	Fit();
3167 
3168 
3169   TCollection_AsciiString Message ("\
3170  	\n\
3171 TopoDS_Face WhiteFace, BrownFace, RedFace, PinkFace;	\n\
3172 TopoDS_Edge Edge1, Edge2, Edge3, Edge4, Edge5, Edge6, Edge7;	\n\
3173 TopoDS_Wire Wire1;	\n\
3174 gp_Pnt P1, P2, P3, P4, P5, P6, P7;	\n\
3175 \n\
3176 ////////The white Face \n\
3177 \n\
3178 gp_Sphere sphere (gp_Ax3(gp_Pnt(0,0,0),gp_Dir(1,0,0)),150);	\n\
3179 \n\
3180 WhiteFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);	\n\
3181 \n\
3182 ////////The red face	\n\
3183 \n\
3184 P1.SetCoord(-15,200,10);	\n\
3185 P2.SetCoord(5,204,0);	\n\
3186 P3.SetCoord(15,200,0);	\n\
3187 P4.SetCoord(-15,20,15);	\n\
3188 P5.SetCoord(-5,20,0);	\n\
3189 P6.SetCoord(15,20,35);	\n\
3190 TColgp_Array2OfPnt array(1,3,1,2);	\n\
3191 array.SetValue(1,1,P1);	\n\
3192 array.SetValue(2,1,P2);	\n\
3193 array.SetValue(3,1,P3); 	\n\
3194 array.SetValue(1,2,P4); 	\n\
3195 array.SetValue(2,2,P5); 	\n\
3196 array.SetValue(3,2,P6);	\n\
3197 Handle (Geom_BSplineSurface) curve = GeomAPI_PointsToBSplineSurface(array,3,8,GeomAbs_C2,0.001);	\n\
3198 \n\
3199 RedFace = BRepBuilderAPI_MakeFace(curve);	\n\
3200 \n\
3201 ////////The brown face	\n\
3202 \n\
3203 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80);	\n\
3204 Edge1 = BRepBuilderAPI_MakeEdge(circle,0,PI);	\n\
3205 \n\
3206 Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(0,-10,40));	\n\
3207 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,-10,40),gp_Pnt(0,0,80));	\n\
3208 \n\
3209 TopoDS_Wire YellowWire;	\n\
3210 BRepBuilderAPI_MakeWire MW1(Edge1,Edge2,Edge3);	\n\
3211 if (MW1.IsDone()) {	\n\
3212 		YellowWire = MW1;	\n\
3213 }	\n\
3214 \n\
3215 BrownFace = BRepBuilderAPI_MakeFace(YellowWire);	\n\
3216 \n");
3217 Message +=("\
3218 ////////The pink face	\n\
3219 \n\
3220 P1.SetCoord(35,-200,40);	\n\
3221 P2.SetCoord(50,-204,30);	\n\
3222 P3.SetCoord(65,-200,30);	\n\
3223 P4.SetCoord(35,-20,45);	\n\
3224 P5.SetCoord(45,-20,30);	\n\
3225 P6.SetCoord(65,-20,65);	\n\
3226 TColgp_Array2OfPnt array2(1,3,1,2);	\n\
3227 array2.SetValue(1,1,P1);	\n\
3228 array2.SetValue(2,1,P2);	\n\
3229 array2.SetValue(3,1,P3); 	\n\
3230 array2.SetValue(1,2,P4); 	\n\
3231 array2.SetValue(2,2,P5); 	\n\
3232 array2.SetValue(3,2,P6);	\n\
3233 	\n\
3234 Handle (Geom_BSplineSurface) BSplineSurf = GeomAPI_PointsToBSplineSurface(array2,3,8,GeomAbs_C2,0.001);	\n\
3235 	\n\
3236 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(BSplineSurf);	\n\
3237 \n\
3238 //2d lines	\n\
3239 gp_Pnt2d P12d(0.9,0.1);	\n\
3240 gp_Pnt2d P22d(0.2,0.7);	\n\
3241 gp_Pnt2d P32d(0.02,0.1);	\n\
3242 \n\
3243 Handle (Geom2d_Line) line1=		\n\
3244 	new Geom2d_Line(P12d,gp_Dir2d((0.2-0.9),(0.7-0.1)));	\n\
3245 Handle (Geom2d_Line) line2=		\n\
3246 	new Geom2d_Line(P22d,gp_Dir2d((0.02-0.2),(0.1-0.7)));   \n\
3247 Handle (Geom2d_Line) line3=		\n\
3248 	new Geom2d_Line(P32d,gp_Dir2d((0.9-0.02),(0.1-0.1)));	\n\
3249 		\n\
3250 //Edges are on the BSpline surface	\n\
3251 Edge1 = BRepBuilderAPI_MakeEdge(line1,BSplineSurf,0,P12d.Distance(P22d));	\n\
3252 Edge2 = BRepBuilderAPI_MakeEdge(line2,BSplineSurf,0,P22d.Distance(P32d));	\n\
3253 Edge3 = BRepBuilderAPI_MakeEdge(line3,BSplineSurf,0,P32d.Distance(P12d));	\n\
3254 \n\
3255 Wire1 = BRepBuilderAPI_MakeWire(Edge1,Edge2,Edge3);	\n\
3256 Wire1.Reverse();	\n\
3257 PinkFace = BRepBuilderAPI_MakeFace(aFace,Wire1);	\n\
3258 BRepLib::BuildCurves3d(PinkFace);	\n\
3259 \n\
3260 \n");
3261 
3262 PocessTextInDialog("Make face ", Message);
3263 }
3264 
OnShell()3265 void CModelingDoc::OnShell()
3266 {
3267 	AIS_ListOfInteractive aList;
3268 	myAISContext->DisplayedObjects(aList);
3269 	AIS_ListIteratorOfListOfInteractive aListIterator;
3270 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3271 		myAISContext->Remove (aListIterator.Value(), Standard_False);
3272 	}
3273 
3274 	TColgp_Array2OfPnt Poles(1,2,1,4);
3275 	Poles.SetValue(1,1,gp_Pnt(0,0,0));
3276 	Poles.SetValue(1,2,gp_Pnt(0,10,2));
3277 	Poles.SetValue(1,3,gp_Pnt(0,20,10));
3278 	Poles.SetValue(1,4,gp_Pnt(0,30,0));
3279 	Poles.SetValue(2,1,gp_Pnt(10,0,5));
3280 	Poles.SetValue(2,2,gp_Pnt(10,10,3));
3281 	Poles.SetValue(2,3,gp_Pnt(10,20,20));
3282 	Poles.SetValue(2,4,gp_Pnt(10,30,0));
3283 
3284 	TColStd_Array1OfReal UKnots(1,2);
3285 	UKnots.SetValue(1,0);
3286 	UKnots.SetValue(2,1);
3287 
3288 	TColStd_Array1OfInteger UMults(1,2);
3289 	UMults.SetValue(1,2);
3290 	UMults.SetValue(2,2);
3291 
3292 	TColStd_Array1OfReal VKnots(1,3);
3293 	VKnots.SetValue(1,0);
3294 	VKnots.SetValue(2,1);
3295 	VKnots.SetValue(3,2);
3296 
3297 	TColStd_Array1OfInteger VMults(1,3);
3298 	VMults.SetValue(1,3);
3299 	VMults.SetValue(2,1);
3300 	VMults.SetValue(3,3);
3301 
3302 	Standard_Integer UDegree(1);
3303 	Standard_Integer VDegree(2);
3304 
3305 	Handle (Geom_BSplineSurface) BSpline = new Geom_BSplineSurface(Poles,UKnots,VKnots,UMults,VMults,UDegree,VDegree);
3306 
3307 	TopoDS_Face WhiteFace = BRepBuilderAPI_MakeFace(BSpline, Precision::Confusion());
3308 
3309 
3310 	Handle(AIS_Shape) white = new AIS_Shape(WhiteFace);
3311 	myAISContext->SetColor (white, Quantity_NOC_WHITE, Standard_False);
3312 	myAISContext->SetMaterial(white,Graphic3d_NOM_PLASTIC,Standard_False);
3313 	myAISContext->SetTransparency (white, 0.7, Standard_False);
3314 	myAISContext->Display(white,Standard_False);
3315 
3316 
3317 	TopoDS_Shell aShell = BRepBuilderAPI_MakeShell(BSpline);
3318 	Handle(AIS_Shape) anAISShell = new AIS_Shape(aShell);
3319 	myAISContext->SetDisplayMode (anAISShell, 0, Standard_False);
3320 	myAISContext->Display(anAISShell,Standard_False);
3321 	//myAISContext->SetSelected(anAISShell);
3322 
3323 	Fit();
3324 
3325 	TCollection_AsciiString Message ("\
3326 	\n\
3327 TColgp_Array2OfPnt Poles(1,2,1,4);	\n\
3328 Poles.SetValue(1,1,gp_Pnt(0,0,0));	\n\
3329 Poles.SetValue(1,2,gp_Pnt(0,10,2));	\n\
3330 Poles.SetValue(1,3,gp_Pnt(0,20,10)); 	\n\
3331 Poles.SetValue(1,4,gp_Pnt(0,30,0)); 	\n\
3332 Poles.SetValue(2,1,gp_Pnt(10,0,5));	\n\
3333 Poles.SetValue(2,2,gp_Pnt(10,10,3));	\n\
3334 Poles.SetValue(2,3,gp_Pnt(10,20,20));	\n\
3335 Poles.SetValue(2,4,gp_Pnt(10,30,0));	\n\
3336 \n\
3337 TColStd_Array1OfReal UKnots(1,2);	\n\
3338 UKnots.SetValue(1,0);	\n\
3339 UKnots.SetValue(2,1);	\n\
3340 \n\
3341 TColStd_Array1OfInteger UMults(1,2);	\n\
3342 UMults.SetValue(1,2);	\n\
3343 UMults.SetValue(2,2);	\n\
3344 \n\
3345 TColStd_Array1OfReal VKnots(1,3);	\n\
3346 VKnots.SetValue(1,0);	\n\
3347 VKnots.SetValue(2,1);	\n\
3348 VKnots.SetValue(3,2);	\n\
3349 \n\
3350 TColStd_Array1OfInteger VMults(1,3);	\n\
3351 VMults.SetValue(1,3);	\n\
3352 VMults.SetValue(2,1);	\n\
3353 VMults.SetValue(3,3);	\n\
3354 \n\
3355 Standard_Integer UDegree(1);	\n\
3356 Standard_Integer VDegree(2);	\n\
3357 	\n\
3358 Handle (Geom_BSplineSurface) BSpline = new Geom_BSplineSurface(Poles,UKnots,VKnots,UMults,VMults,UDegree,VDegree);	\n\
3359 	\n\
3360 TopoDS_Shell aShell = BRepBuilderAPI_MakeShell(BSpline);	\n\
3361 \n\
3362 \n");
3363 
3364   PocessTextInDialog("Make shell", Message);
3365 
3366 }
3367 
OnCompound()3368 void CModelingDoc::OnCompound()
3369 {
3370 	AIS_ListOfInteractive aList;
3371 	myAISContext->DisplayedObjects(aList);
3372 	AIS_ListIteratorOfListOfInteractive aListIterator;
3373 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3374 		myAISContext->Remove (aListIterator.Value(), Standard_False);
3375 	}
3376 
3377 	BRep_Builder builder;
3378 	TopoDS_Compound Comp;
3379 	builder.MakeCompound(Comp);
3380 
3381 	TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));
3382 	builder.Add(Comp,aVertex);
3383 
3384 	gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));
3385 	TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(line,-20,10);
3386 	builder.Add(Comp,anEdge);
3387 
3388 	gp_Sphere sphere (gp_Ax3(gp_Pnt(-80,0,0),gp_Dir(1,0,0)),150);
3389 	TopoDS_Face aFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);
3390 	builder.Add(Comp,aFace);
3391 
3392   TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(-60, 0, 0), 30, 60, 40).Shape();
3393 	builder.Add(Comp,aBox);
3394 
3395 	Handle(AIS_Shape) white = new AIS_Shape(Comp);
3396 	myAISContext->SetDisplayMode (white, 0, Standard_False);
3397 	myAISContext->Display(white,Standard_False);
3398 
3399 	Fit();
3400 
3401 
3402    TCollection_AsciiString Message ("\
3403 		\n\
3404 BRep_Builder builder;	\n\
3405 TopoDS_Compound Comp;	\n\
3406 builder.MakeCompound(Comp);	\n\
3407 \n\
3408 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));	\n\
3409 builder.Add(Comp,aVertex);	\n\
3410 	\n\
3411 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));	\n\
3412 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(line,-20,10);	\n\
3413 builder.Add(Comp,anEdge);	\n\
3414 	\n\
3415 gp_Sphere sphere (gp_Ax3(gp_Pnt(-80,0,0),gp_Dir(1,0,0)),150);	\n\
3416 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);	\n\
3417 builder.Add(Comp,aFace);	\n\
3418 	\n\
3419 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(-60,0,0),30,60,40);	\n\
3420 builder.Add(Comp,aBox);	\n\
3421 	\n\
3422 \n");
3423 
3424 	PocessTextInDialog("Make compound ", Message);
3425 
3426 }
3427 
3428 
3429 
3430 
3431 
OnSewing()3432 void CModelingDoc::OnSewing()
3433 {
3434 	AIS_ListOfInteractive aList;
3435 	myAISContext->DisplayedObjects(aList);
3436 	AIS_ListIteratorOfListOfInteractive aListIterator;
3437 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3438 		myAISContext->Remove (aListIterator.Value(), Standard_False);
3439 	}
3440 
3441 	gp_Pnt P(0,0,0);
3442 	gp_Vec V(0,0,1);
3443 	Handle(Geom_Plane) Pi=new Geom_Plane(P,V);
3444 	Handle(Geom_RectangularTrimmedSurface) GeometricSurface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);
3445 	TopoDS_Shape FirstShape = BRepBuilderAPI_MakeFace(GeometricSurface, Precision::Confusion());
3446 
3447 	Handle(AIS_Shape) white1 = new AIS_Shape(FirstShape);
3448 
3449 	myAISContext->SetColor(white1,Quantity_NOC_RED,Standard_False);
3450 	myAISContext->SetMaterial(white1,Graphic3d_NOM_PLASTIC,Standard_False);
3451 	myAISContext->SetTransparency(white1,0.4,Standard_False);
3452 	myAISContext->Display(white1,Standard_False);
3453 	//Sleep(1000);
3454 
3455 	gp_Pnt P1(0,0,0);
3456 	gp_Pnt P2(50,0,0);
3457 	gp_Pnt P3(100,0,0);
3458 	gp_Pnt P4(25,12,85);
3459 	gp_Pnt P5(100,0,80);
3460 	gp_Pnt P6(135,-12,85);
3461 
3462 	TColgp_Array2OfPnt Array(1,3,1,2);
3463 	Array.SetValue(1,1,P1);
3464 	Array.SetValue(2,1,P2);
3465 	Array.SetValue(3,1,P3);
3466 	Array.SetValue(1,2,P4);
3467 	Array.SetValue(2,2,P5);
3468 	Array.SetValue(3,2,P6);
3469 
3470 	Handle (Geom_BSplineSurface) aSurf = GeomAPI_PointsToBSplineSurface(Array,3,8,GeomAbs_C2,0.00001);
3471 	TopoDS_Shape SecondShape = BRepBuilderAPI_MakeFace(aSurf, Precision::Confusion());
3472 
3473 	Handle(AIS_Shape) white2 = new AIS_Shape(SecondShape);
3474 
3475 	myAISContext->SetColor(white2,Quantity_NOC_YELLOW,Standard_False);
3476 	myAISContext->SetMaterial(white2,Graphic3d_NOM_PLASTIC,Standard_False);
3477 	myAISContext->SetTransparency(white2,0.4,Standard_False);
3478 	myAISContext->Display(white2,Standard_False);
3479 
3480 	//Sleep(1000);
3481 
3482 	BRepOffsetAPI_Sewing aMethod;
3483 	aMethod.Add(FirstShape);
3484 	aMethod.Add(SecondShape);
3485 
3486 	aMethod.Perform();
3487 
3488 	TopoDS_Shape sewedShape = aMethod.SewedShape();
3489 
3490 	Handle(AIS_Shape) result = new AIS_Shape(sewedShape);
3491 	myAISContext->SetDisplayMode(result,0,Standard_False);
3492 	myAISContext->Display(result,Standard_False);
3493 
3494 	Fit();
3495 
3496    TCollection_AsciiString Message ("\
3497 	\n\
3498 ///////The first shape \n\
3499  \n\
3500 gp_Pnt P(0,0,0);	\n\
3501 gp_Vec V(0,0,1);	\n\
3502 Handle(Geom_Plane) Pi=new Geom_Plane(P,V);	\n\
3503 Handle(Geom_RectangularTrimmedSurface) GeometricSurface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);	\n\
3504 TopoDS_Shape FirstShape = BRepBuilderAPI_MakeFace(GeometricSurface);	\n\
3505 	\n\
3506 ///////The second shape \n\
3507  \n\
3508 gp_Pnt P1(0,0,0);	\n\
3509 gp_Pnt P2(50,0,0);	\n\
3510 gp_Pnt P3(100,0,0);	\n\
3511 gp_Pnt P4(25,12,85);	\n\
3512 gp_Pnt P5(100,0,80);	\n\
3513 gp_Pnt P6(135,-12,85);	\n\
3514 \n\
3515 TColgp_Array2OfPnt Array(1,3,1,2);	\n\
3516 Array.SetValue(1,1,P1);	\n\
3517 Array.SetValue(2,1,P2);	\n\
3518 Array.SetValue(3,1,P3);	\n\
3519 Array.SetValue(1,2,P4);	\n\
3520 Array.SetValue(2,2,P5);	\n\
3521 Array.SetValue(3,2,P6);	\n\
3522 \n\
3523 Handle (Geom_BSplineSurface) aSurf = GeomAPI_PointsToBSplineSurface(Array,3,8,GeomAbs_C2,0.00001);	\n\
3524 TopoDS_Shape SecondShape = BRepBuilderAPI_MakeFace(aSurf);	\n\
3525 	\n\
3526 BRepOffsetAPI_Sewing aMethod;	\n\
3527 aMethod.Add(FirstShape);		\n\
3528 aMethod.Add(SecondShape);	\n\
3529 \n\
3530 aMethod.Perform();	\n\
3531 \n\
3532 TopoDS_Shape sewedShape = aMethod.SewedShape();	\n\
3533 	\n\
3534 \n");
3535 
3536 	PocessTextInDialog("Sew faces ", Message);
3537 
3538 }
3539 
3540 
3541 
3542 
3543 
3544 
3545 
OnBuilder()3546 void CModelingDoc::OnBuilder()
3547 {
3548 	AIS_ListOfInteractive aList;
3549 	myAISContext->DisplayedObjects(aList);
3550 	AIS_ListIteratorOfListOfInteractive aListIterator;
3551 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3552 		myAISContext->Remove (aListIterator.Value(), Standard_False);
3553 	}
3554 
3555 	//The tolerance is the tolerance of confusion
3556 	Standard_Real precision = Precision::Confusion();
3557 
3558 	//The builder
3559 	BRep_Builder B;
3560 
3561 	//Build the vertices
3562 	TopoDS_Vertex V000, V001, V010, V011, V100, V101, V110, V111;
3563 	B.MakeVertex(V000,gp_Pnt(0,0,0),precision);
3564 	B.MakeVertex(V001,gp_Pnt(0,0,100),precision);
3565 	B.MakeVertex(V010,gp_Pnt(0,150,0),precision);
3566 	B.MakeVertex(V011,gp_Pnt(0,150,100),precision);
3567 	B.MakeVertex(V100,gp_Pnt(200,0,0),precision);
3568 	B.MakeVertex(V101,gp_Pnt(200,0,100),precision);
3569 	B.MakeVertex(V110,gp_Pnt(200,150,0),precision);
3570 	B.MakeVertex(V111,gp_Pnt(200,150,100),precision);
3571 
3572 	//Build the edges
3573 	//the edges are oriented as the axis X,Y,Z
3574 	TopoDS_Edge EX00, EX01, EX10, EX11;
3575 	TopoDS_Edge EY00, EY01, EY10, EY11;
3576 	TopoDS_Edge EZ00, EZ01, EZ10, EZ11;
3577 	Handle (Geom_Line) L;
3578 
3579 	//Edge X00
3580 	L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(1,0,0));
3581 	B.MakeEdge(EX00,L,precision);
3582 	V000.Orientation(TopAbs_FORWARD);
3583 	V100.Orientation(TopAbs_REVERSED);
3584 	B.Add(EX00,V000);
3585 	B.Add(EX00,V100);
3586 	//Parameters
3587 	B.UpdateVertex(V000,0,EX00,precision);
3588 	B.UpdateVertex(V100,200,EX00,precision);
3589 
3590 	//Edge X10
3591 	L = new Geom_Line(gp_Pnt(0,150,0),gp_Dir(1,0,0));
3592 	B.MakeEdge(EX10,L,precision);
3593 	V010.Orientation(TopAbs_FORWARD);
3594 	V110.Orientation(TopAbs_REVERSED);
3595 	B.Add(EX10,V010);
3596 	B.Add(EX10,V110);
3597 	//Parameters
3598 	B.UpdateVertex(V010,0,EX10,precision);
3599 	B.UpdateVertex(V110,200,EX10,precision);
3600 
3601 	//Edge Y00
3602 	L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(0,1,0));
3603 	B.MakeEdge(EY00,L,precision);
3604 	V000.Orientation(TopAbs_FORWARD);
3605 	V010.Orientation(TopAbs_REVERSED);
3606 	B.Add(EY00,V000);
3607 	B.Add(EY00,V010);
3608 	//Parameters
3609 	B.UpdateVertex(V000,0,EY00,precision);
3610 	B.UpdateVertex(V010,150,EY00,precision);
3611 
3612 	//Edge Y10
3613 	L = new Geom_Line(gp_Pnt(200,0,0),gp_Dir(0,1,0));
3614 	B.MakeEdge(EY10,L,precision);
3615 	V100.Orientation(TopAbs_FORWARD);
3616 	V110.Orientation(TopAbs_REVERSED);
3617 	B.Add(EY10,V100);
3618 	B.Add(EY10,V110);
3619 	//Parameters
3620 	B.UpdateVertex(V100,0,EY10,precision);
3621 	B.UpdateVertex(V110,150,EY10,precision);
3622 
3623 	//Edge Y01
3624 	L = new Geom_Line(gp_Pnt(0,0,100),gp_Dir(0,1,0));
3625 	B.MakeEdge(EY01,L,precision);
3626 	V001.Orientation(TopAbs_FORWARD);
3627 	V011.Orientation(TopAbs_REVERSED);
3628 	B.Add(EY01,V001);
3629 	B.Add(EY01,V011);
3630 	//Parameters
3631 	B.UpdateVertex(V001,0,EY01,precision);
3632 	B.UpdateVertex(V011,150,EY01,precision);
3633 
3634 	//Edge Y11
3635 	L = new Geom_Line(gp_Pnt(200,0,100),gp_Dir(0,1,0));
3636 	B.MakeEdge(EY11,L,precision);
3637 	V101.Orientation(TopAbs_FORWARD);
3638 	V111.Orientation(TopAbs_REVERSED);
3639 	B.Add(EY11,V101);
3640 	B.Add(EY11,V111);
3641 	//Parameters
3642 	B.UpdateVertex(V101,0,EY11,precision);
3643 	B.UpdateVertex(V111,150,EY11,precision);
3644 
3645 	//Edge Z00
3646 	L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(0,0,1));
3647 	B.MakeEdge(EZ00,L,precision);
3648 	V000.Orientation(TopAbs_FORWARD);
3649 	V001.Orientation(TopAbs_REVERSED);
3650 	B.Add(EZ00,V000);
3651 	B.Add(EZ00,V001);
3652 	//Parameters
3653 	B.UpdateVertex(V000,0,EZ00,precision);
3654 	B.UpdateVertex(V001,100,EZ00,precision);
3655 
3656 	//Edge Z01
3657 	L = new Geom_Line(gp_Pnt(0,150,0),gp_Dir(0,0,1));
3658 	B.MakeEdge(EZ01,L,precision);
3659 	V010.Orientation(TopAbs_FORWARD);
3660 	V011.Orientation(TopAbs_REVERSED);
3661 	B.Add(EZ01,V010);
3662 	B.Add(EZ01,V011);
3663 	//Parameters
3664 	B.UpdateVertex(V010,0,EZ01,precision);
3665 	B.UpdateVertex(V011,100,EZ01,precision);
3666 
3667 	//Edge Z10
3668 	L = new Geom_Line(gp_Pnt(200,0,0),gp_Dir(0,0,1));
3669 	B.MakeEdge(EZ10,L,precision);
3670 	V100.Orientation(TopAbs_FORWARD);
3671 	V101.Orientation(TopAbs_REVERSED);
3672 	B.Add(EZ10,V100);
3673 	B.Add(EZ10,V101);
3674 	//Parameters
3675 	B.UpdateVertex(V100,0,EZ10,precision);
3676 	B.UpdateVertex(V101,100,EZ10,precision);
3677 
3678 	//Edge Z11
3679 	L = new Geom_Line(gp_Pnt(200,150,0),gp_Dir(0,0,1));
3680 	B.MakeEdge(EZ11,L,precision);
3681 	V110.Orientation(TopAbs_FORWARD);
3682 	V111.Orientation(TopAbs_REVERSED);
3683 	B.Add(EZ11,V110);
3684 	B.Add(EZ11,V111);
3685 	//Parameters
3686 	B.UpdateVertex(V110,0,EZ11,precision);
3687 	B.UpdateVertex(V111,100,EZ11,precision);
3688 
3689 
3690 	//Circular Edges
3691 	Handle (Geom_Circle) C;
3692 	//Standard_Real R = 100;
3693 
3694 	//Edge EX01
3695 	C = new Geom_Circle(gp_Ax2(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
3696 	B.MakeEdge(EX01,C,precision);
3697 	V001.Orientation(TopAbs_FORWARD);
3698 	V101.Orientation(TopAbs_REVERSED);
3699 	B.Add(EX01,V001);
3700 	B.Add(EX01,V101);
3701 	//Parameters
3702 	B.UpdateVertex(V001,0,EX01,precision);
3703 	B.UpdateVertex(V101,M_PI,EX01,precision);
3704 
3705 	//Edge EX11
3706 	C = new Geom_Circle(gp_Ax2(gp_Pnt(100,150,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
3707 	B.MakeEdge(EX11,C,precision);
3708 	V011.Orientation(TopAbs_FORWARD);
3709 	V111.Orientation(TopAbs_REVERSED);
3710 	B.Add(EX11,V011);
3711 	B.Add(EX11,V111);
3712 	//Parameters
3713 	B.UpdateVertex(V011,0,EX11,precision);
3714 	B.UpdateVertex(V111,M_PI,EX11,precision);
3715 
3716 	//Build wire and faces
3717 	//Faces normals are along the axis X,Y,Z
3718 	TopoDS_Face FXMIN, FXMAX, FYMIN, FYMAX, FZMIN, FZMAX;
3719 	TopoDS_Wire W;
3720 	Handle (Geom_Plane) P;
3721 	Handle (Geom2d_Line) L2d;
3722 	Handle (Geom2d_Circle) C2d;
3723 	Handle (Geom_CylindricalSurface) S;
3724 
3725 	//Face FXMAX
3726 	P = new Geom_Plane(gp_Ax2(gp_Pnt(200,0,0),gp_Dir(1,0,0),gp_Dir(0,1,0)));
3727 	B.MakeFace(FXMAX,P,precision);
3728 	//the wire and the edges
3729 	B.MakeWire (W);
3730 
3731 	EY10.Orientation(TopAbs_FORWARD);
3732 	B.Add(W,EY10);
3733 	//pcurve
3734 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3735 	B.UpdateEdge(EY10,L2d,FXMAX,precision);
3736 
3737 	EZ11.Orientation(TopAbs_FORWARD);
3738 	B.Add(W,EZ11);
3739 	//pcurve
3740 	L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));
3741 	B.UpdateEdge(EZ11,L2d,FXMAX,precision);
3742 
3743 	EY11.Orientation(TopAbs_REVERSED);
3744 	B.Add(W,EY11);
3745 	//pcurve
3746 	L2d = new Geom2d_Line(gp_Pnt2d(0,100),gp_Dir2d(1,0));
3747 	B.UpdateEdge(EY11,L2d,FXMAX,precision);
3748 
3749 	EZ10.Orientation(TopAbs_REVERSED);
3750 	B.Add(W,EZ10);
3751 	//pcurve
3752 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3753 	B.UpdateEdge(EZ10,L2d,FXMAX,precision);
3754 
3755 	B.Add(FXMAX,W);
3756 
3757 	//Face FXMIN
3758 	P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(-1,0,0),gp_Dir(0,0,1)));
3759 	B.MakeFace(FXMIN,P,precision);
3760 	//the wire and the edges
3761 	B.MakeWire (W);
3762 
3763 	EZ00.Orientation(TopAbs_FORWARD);
3764 	B.Add(W,EZ00);
3765 	//pcurve
3766 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3767 	B.UpdateEdge(EZ00,L2d,FXMIN,precision);
3768 
3769 	EY01.Orientation(TopAbs_FORWARD);
3770 	B.Add(W,EY01);
3771 	//pcurve
3772 	L2d = new Geom2d_Line(gp_Pnt2d(100,0),gp_Dir2d(0,1));
3773 	B.UpdateEdge(EY01,L2d,FXMIN,precision);
3774 
3775 	EZ01.Orientation(TopAbs_REVERSED);
3776 	B.Add(W,EZ01);
3777 	//pcurve
3778 	L2d = new Geom2d_Line(gp_Pnt2d(0,150),gp_Dir2d(1,0));
3779 	B.UpdateEdge(EZ01,L2d,FXMIN,precision);
3780 
3781 	EY00.Orientation(TopAbs_REVERSED);
3782 	B.Add(W,EY00);
3783 	//pcurve
3784 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3785 	B.UpdateEdge(EY00,L2d,FXMIN,precision);
3786 
3787 
3788 	B.Add(FXMIN,W);
3789 
3790 	//Face FYMAX
3791 
3792 	P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0),gp_Dir(0,0,1)));
3793 	B.MakeFace(FYMAX,P,precision);
3794 	//the wire and the edges
3795 	B.MakeWire (W);
3796 
3797 	EZ00.Orientation(TopAbs_FORWARD);
3798 	B.Add(W,EZ00);
3799 	//pcurve
3800 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3801 	B.UpdateEdge(EZ00,L2d,FYMAX,precision);
3802 
3803 	EX01.Orientation(TopAbs_FORWARD);
3804 	B.Add(W,EX01);
3805 	//pcurve
3806 	C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(100,100),gp_Dir2d(0,-1)),100);
3807 	B.UpdateEdge(EX01,C2d,FYMAX,precision);
3808 	B.UpdateVertex(V001,0,EX01,FYMAX,precision);
3809 	B.UpdateVertex(V101,M_PI,EX01,FYMAX,precision);
3810 
3811 	EZ10.Orientation(TopAbs_REVERSED);
3812 	B.Add(W,EZ10);
3813 	//pcurve
3814 	L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
3815 	B.UpdateEdge(EZ10,L2d,FYMAX,precision);
3816 
3817 	EX00.Orientation(TopAbs_REVERSED);
3818 	B.Add(W,EX00);
3819 	//pcurve
3820 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3821 	B.UpdateEdge(EX00,L2d,FYMAX,precision);
3822 
3823 
3824 	B.Add(FYMAX,W);
3825 
3826 
3827 
3828 	//Face FYMIN
3829 	P = new Geom_Plane(gp_Ax2(gp_Pnt(0,150,0),gp_Dir(0,1,0),gp_Dir(0,0,1)));
3830 	B.MakeFace(FYMIN,P,precision);
3831 	//the wire and the edges
3832 	B.MakeWire (W);
3833 
3834 	EZ01.Orientation(TopAbs_FORWARD);
3835 	B.Add(W,EZ01);
3836 	//pcurve
3837 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3838 	B.UpdateEdge(EZ01,L2d,FYMIN,precision);
3839 
3840 	EX11.Orientation(TopAbs_FORWARD);
3841 	B.Add(W,EX11);
3842 	//pcurve
3843 	C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(100,100),gp_Dir2d(0,-1)),100);
3844 	B.UpdateEdge(EX11,C2d,FYMIN,precision);
3845 	B.UpdateVertex(V011,0,EX11,FYMIN,precision);
3846 	B.UpdateVertex(V111,M_PI,EX11,FYMIN,precision);
3847 
3848 	EZ11.Orientation(TopAbs_REVERSED);
3849 	B.Add(W,EZ11);
3850 	//pcurve
3851 	L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
3852 	B.UpdateEdge(EZ11,L2d,FYMIN,precision);
3853 
3854 	EX10.Orientation(TopAbs_REVERSED);
3855 	B.Add(W,EX10);
3856 	//pcurve
3857 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3858 	B.UpdateEdge(EX10,L2d,FYMIN,precision);
3859 
3860 	B.Add(FYMIN,W);
3861 
3862 	//Face FZMAX
3863 	P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,0,-1),gp_Dir(0,1,0)));
3864 	B.MakeFace(FZMAX,P,precision);
3865 	//the wire and the edges
3866 	B.MakeWire (W);
3867 
3868 	EY00.Orientation(TopAbs_FORWARD);
3869 	B.Add(W,EY00);
3870 	//pcurve
3871 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3872 	B.UpdateEdge(EY00,L2d,FZMAX,precision);
3873 
3874 	EX10.Orientation(TopAbs_FORWARD);
3875 	B.Add(W,EX10);
3876 	//pcurve
3877 	L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));
3878 	B.UpdateEdge(EX10,L2d,FZMAX,precision);
3879 
3880 	EY10.Orientation(TopAbs_REVERSED);
3881 	B.Add(W,EY10);
3882 	//pcurve
3883 	L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
3884 	B.UpdateEdge(EY10,L2d,FZMAX,precision);
3885 
3886 	EX00.Orientation(TopAbs_REVERSED);
3887 	B.Add(W,EX00);
3888 	//pcurve
3889 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3890 	B.UpdateEdge(EX00,L2d,FZMAX,precision);
3891 
3892 
3893 	B.Add(FZMAX,W);
3894 
3895 	//Face FZMIN
3896 	S = new Geom_CylindricalSurface(gp_Ax3(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
3897 	B.MakeFace(FZMIN,S,precision);
3898 
3899 	//the wire and the edges
3900 	B.MakeWire (W);
3901 
3902 	EX01.Orientation(TopAbs_FORWARD);
3903 	B.Add(W,EX01);
3904 	//pcurve
3905 	L2d = new Geom2d_Line(gp_Ax2d(gp_Pnt2d(0,0),gp_Dir2d(1,0)));
3906 	B.UpdateEdge(EX01,L2d,FZMIN,precision);
3907 	B.UpdateVertex(V001,0,EX01,FZMIN,precision);
3908 	B.UpdateVertex(V101,M_PI,EX01,FZMIN,precision);
3909 
3910 	EY11.Orientation(TopAbs_FORWARD);
3911 	B.Add(W,EY11);
3912 	//pcurve
3913 	L2d = new Geom2d_Line(gp_Pnt2d(M_PI,0),gp_Dir2d(0,1));
3914 	B.UpdateEdge(EY11,L2d,FZMIN,precision);
3915 
3916 	EX11.Orientation(TopAbs_REVERSED);
3917 	B.Add(W,EX11);
3918 	//pcurve
3919 	L2d = new Geom2d_Line(gp_Ax2d(gp_Pnt2d(0,150),gp_Dir2d(1,0)));
3920 	B.UpdateEdge(EX11,L2d,FZMIN,precision);
3921 	B.UpdateVertex(V111,M_PI,EX11,FZMIN,precision);
3922 	B.UpdateVertex(V011,0,EX11,FZMIN,precision);
3923 
3924 	EY01.Orientation(TopAbs_REVERSED);
3925 	B.Add(W,EY01);
3926 	//pcurve
3927 	L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3928 	B.UpdateEdge(EY01,L2d,FZMIN,precision);
3929 
3930 	B.Add(FZMIN,W);
3931 
3932 	FYMAX.Orientation(TopAbs_REVERSED);
3933 
3934 	//Shell
3935 	TopoDS_Shell Sh;
3936 	B.MakeShell(Sh);
3937 	B.Add(Sh,FXMAX);
3938 	B.Add(Sh,FXMIN);
3939 	B.Add(Sh,FYMAX);
3940 	B.Add(Sh,FYMIN);
3941 	B.Add(Sh,FZMAX);
3942 	B.Add(Sh,FZMIN);
3943 
3944 	// Solid
3945 	TopoDS_Solid Sol;
3946 	B.MakeSolid(Sol);
3947 	B.Add(Sol,Sh);
3948 
3949 	Handle(AIS_Shape) borne = new AIS_Shape(Sol);
3950 	myAISContext->SetDisplayMode (borne, 1, Standard_False);
3951 	myAISContext->SetColor (borne, Quantity_NOC_RED, Standard_False);
3952 	myAISContext->SetMaterial(borne,Graphic3d_NOM_PLASTIC,Standard_False);
3953 	myAISContext->Display(borne,Standard_False);
3954 
3955 
3956 	Fit();
3957    TCollection_AsciiString Message ("\
3958 		\n\
3959 //The tolerance is 0.01 	\n\
3960 Standard_Real precision(0.01);	\n\
3961 \n\
3962 //The builder	\n\
3963 BRep_Builder B;	\n\
3964 \n\
3965 //Build the vertices	\n\
3966 TopoDS_Vertex V000, V001, V010, V011, V100, V101, V110, V111;	\n\
3967 B.MakeVertex(V000,gp_Pnt(0,0,0),precision);	\n\
3968 B.MakeVertex(V001,gp_Pnt(0,0,100),precision);	\n\
3969 B.MakeVertex(V010,gp_Pnt(0,150,0),precision);	\n\
3970 B.MakeVertex(V011,gp_Pnt(0,150,100),precision);	\n\
3971 B.MakeVertex(V100,gp_Pnt(200,0,0),precision);	\n\
3972 B.MakeVertex(V101,gp_Pnt(200,0,100),precision);	\n\
3973 B.MakeVertex(V110,gp_Pnt(200,150,0),precision);	\n\
3974 B.MakeVertex(V111,gp_Pnt(200,150,100),precision);	\n\
3975 \n\
3976 //Build the edges	\n\
3977 //the edges are oriented as the axis X,Y,Z	\n\
3978 TopoDS_Edge EX00, EX01, EX10, EX11;	\n\
3979 TopoDS_Edge EY00, EY01, EY10, EY11;	\n\
3980 TopoDS_Edge EZ00, EZ01, EZ10, EZ11;	\n\
3981 Handle (Geom_Line) L;	\n\
3982 \n\
3983 //Edge X00	\n\
3984 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(1,0,0));	\n\
3985 B.MakeEdge(EX00,L,precision);	\n\
3986 V000.Orientation(TopAbs_FORWARD);	\n\
3987 V100.Orientation(TopAbs_REVERSED);	\n\
3988 B.Add(EX00,V000);	\n\
3989 B.Add(EX00,V100);	\n\
3990 //Parameters	\n\
3991 B.UpdateVertex(V000,0,EX00,precision);	\n\
3992 B.UpdateVertex(V100,200,EX00,precision);	\n\
3993 \n\
3994 //Idem for all the linear edges...	\n\
3995 \n\
3996 //Circular Edges	\n\
3997 Handle (Geom_Circle) C;	\n\
3998 Standard_Real R = 100;	\n\
3999 \n\
4000 //Edge EX01	\n\
4001 C = new Geom_Circle(gp_Ax2(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);	\n\
4002 B.MakeEdge(EX01,C,precision);	\n\
4003 V001.Orientation(TopAbs_FORWARD);	\n\
4004 V101.Orientation(TopAbs_REVERSED);	\n\
4005 B.Add(EX01,V001);	\n\
4006 B.Add(EX01,V101);	\n\
4007 //Parameters	\n\
4008 B.UpdateVertex(V001,0,EX01,precision);	\n\
4009 B.UpdateVertex(V101,PI,EX01,precision);	\n\
4010 \n\
4011 //Idem for EX11	\n\
4012 \n\
4013 //Build wire and faces	\n\
4014 //Faces normals are along the axis X,Y,Z	\n\
4015 TopoDS_Face FXMIN, FXMAX, FYMIN, FYMAX, FZMIN, FZMAX;	\n\
4016 TopoDS_Wire W;	\n\
4017 Handle (Geom_Plane) P;	\n\
4018 Handle (Geom2d_Line) L2d;	\n\
4019 Handle (Geom2d_Circle) C2d;	\n\
4020 Handle (Geom_CylindricalSurface) S;	\n\
4021 \n\
4022 //Face FXMAX	\n\
4023 P = new Geom_Plane(gp_Ax2(gp_Pnt(200,0,0),gp_Dir(1,0,0),gp_Dir(0,1,0)));	\n\
4024 B.MakeFace(FXMAX,P,precision);	\n\
4025 //the wire and the edges	\n\
4026 B.MakeWire (W);	\n");
4027 Message += ("\
4028 \n\
4029 EY10.Orientation(TopAbs_FORWARD);	\n\
4030 B.Add(W,EY10);	\n\
4031 //pcurve	\n\
4032 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));	\n\
4033 B.UpdateEdge(EY10,L2d,FXMAX,precision);	\n\
4034 	\n\
4035 EZ11.Orientation(TopAbs_FORWARD);	\n\
4036 B.Add(W,EZ11);	\n\
4037 //pcurve	\n\
4038 L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));	\n\
4039 B.UpdateEdge(EZ11,L2d,FXMAX,precision);	\n\
4040 	\n\
4041 EY11.Orientation(TopAbs_REVERSED);	\n\
4042 B.Add(W,EY11);	\n\
4043 //pcurve	\n\
4044 L2d = new Geom2d_Line(gp_Pnt2d(0,100),gp_Dir2d(1,0));	\n\
4045 B.UpdateEdge(EY11,L2d,FXMAX,precision);	\n\
4046 	\n\
4047 EZ10.Orientation(TopAbs_REVERSED);	\n\
4048 B.Add(W,EZ10);	\n\
4049 //pcurve	\n\
4050 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));	\n\
4051 B.UpdateEdge(EZ10,L2d,FXMAX,precision);	\n\
4052 \n\
4053 B.Add(FXMAX,W);	\n\
4054 \n\
4055 //Idem for other faces...	\n\
4056 \n\
4057 //Shell	\n\
4058 TopoDS_Shell Sh;	\n\
4059 B.MakeShell(Sh);	\n\
4060 B.Add(Sh,FXMAX);	\n\
4061 B.Add(Sh,FXMIN);	\n\
4062 B.Add(Sh,FYMAX);	\n\
4063 B.Add(Sh,FYMIN);	\n\
4064 B.Add(Sh,FZMAX);	\n\
4065 B.Add(Sh,FZMIN);	\n\
4066 \n\
4067 // Solid	\n\
4068 TopoDS_Solid Sol;	\n\
4069 B.MakeSolid(Sol);	\n\
4070 B.Add(Sol,Sh);	\n\
4071 \n\
4072 \n");
4073 
4074 PocessTextInDialog("Make a shape with a builder", Message);
4075 
4076 }
4077 
OnGeometrie()4078 void CModelingDoc::OnGeometrie()
4079 {
4080 	AIS_ListOfInteractive aList;
4081 	myAISContext->DisplayedObjects(aList);
4082 	AIS_ListIteratorOfListOfInteractive aListIterator;
4083 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4084 		myAISContext->Remove (aListIterator.Value(), Standard_False);
4085 	}
4086 
4087 	//geometry of a vertex
4088 	TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(0,120,70));
4089 	gp_Pnt GeometricPoint = BRep_Tool::Pnt(aVertex);
4090 
4091 	Handle(AIS_Shape) vert = new AIS_Shape(aVertex);
4092 	myAISContext->Display(vert,Standard_False);
4093 	Fit();
4094 	Sleep (500);
4095 
4096 	//geometry of an edge
4097 	TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(100,50,250),gp_Pnt(-30,-100,-50));
4098 	Handle(AIS_Shape) yellow = new AIS_Shape(anEdge);
4099 	myAISContext->SetWidth(yellow,2,Standard_False);
4100 	myAISContext->Display(yellow,Standard_False);
4101 	Fit();
4102 	Sleep (500);
4103 
4104 	TopLoc_Location location;
4105 	Standard_Real first, last;
4106 	Handle (Geom_Curve) aCurve = BRep_Tool::Curve(anEdge,location,first,last);
4107 	TopoDS_Edge anEdgeDS = BRepBuilderAPI_MakeEdge(aCurve);
4108 
4109 	Handle (Geom_Line) aLine = Handle (Geom_Line)::DownCast(aCurve);
4110 	if (!aLine.IsNull()) {
4111 		Handle (AIS_Line) DispLine = new AIS_Line(aLine);
4112 		myAISContext->Display(DispLine,Standard_False);
4113 		Fit();
4114 		Sleep (500);
4115 	}
4116 
4117 	//geometry of a face
4118 	gp_Pnt P(-20,-20,-20);
4119 	gp_Vec V(0,0,1);
4120 	Handle(Geom_Plane) Pi=new Geom_Plane(P,V);
4121 	Handle(Geom_RectangularTrimmedSurface) Surface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);
4122 	TopoDS_Face RedFace = BRepBuilderAPI_MakeFace(Surface, Precision::Confusion());
4123 
4124 	Handle(AIS_Shape) red = new AIS_Shape(RedFace);
4125 	myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
4126 	myAISContext->SetMaterial(red,Graphic3d_NOM_PLASTIC,Standard_False);
4127 	myAISContext->Display(red,Standard_False);
4128 	Fit();
4129 	Sleep (500);
4130 
4131 	TopLoc_Location location2;
4132 	Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(RedFace,location2);
4133 
4134 	Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);
4135 	if (!aPlane.IsNull()) {
4136 		Handle (AIS_Plane) DispPlane = new AIS_Plane(aPlane);
4137 		myAISContext->Display(DispPlane,Standard_False);
4138 
4139 	}
4140 
4141 
4142 	Fit();
4143 	Sleep (500);
4144 
4145 
4146    TCollection_AsciiString Message ("\
4147 	\n\
4148 ///////geometry of a vertex	\n\
4149 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(0,120,70));	\n\
4150 gp_Pnt GeometricPoint = BRep_Tool::Pnt(aVertex);	\n\
4151 \n\
4152 ///////geometry of an edge	\n\
4153 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(100,50,250),gp_Pnt(-30,-100,-50));	\n\
4154 \n\
4155 TopLoc_Location location;	\n\
4156 Standard_Real first, last;	\n\
4157 Handle (Geom_Curve) aCurve = BRep_Tool::Curve(anEdge,location,first,last);	\n\
4158 TopoDS_Edge anEdgeDS = BRepBuilderAPI_MakeEdge(aCurve);	\n\
4159 \n\
4160 Handle (Geom_Line) aLine = Handle (Geom_Line)::DownCast(aCurve);	\n\
4161 if (!aLine.IsNull()) {	\n\
4162 	Handle (AIS_Line) DispLine = new AIS_Line(aLine);	\n\
4163 }	\n\
4164 		\n\
4165 ///////geometry of a face	\n\
4166 gp_Pnt P(-20,-20,-20);	\n\
4167 gp_Vec V(0,0,1);	\n\
4168 Handle(Geom_Plane) Pi=new Geom_Plane(P,V);	\n\
4169 Handle(Geom_RectangularTrimmedSurface) Surface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);	\n\
4170 TopoDS_Face RedFace = BRepBuilderAPI_MakeFace(Surface);	\n\
4171 \n\
4172 TopLoc_Location location2;	\n\
4173 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(RedFace,location2);	\n\
4174 \n\
4175 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);	\n\
4176 if (!aPlane.IsNull()) {	\n\
4177 	Handle (AIS_Plane) DispPlane = new AIS_Plane(aPlane);	\n\
4178 }	\n\
4179 \n\
4180 \n");
4181 
4182 	PocessTextInDialog("Recover the geometry of vertex, edge and face ", Message);
4183 
4184 
4185 }
4186 
OnExplorer()4187 void CModelingDoc::OnExplorer()
4188 {
4189 	myAISContext->RemoveAll (false);
4190 
4191 	TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100, 100, 100).Shape();
4192 	Standard_Integer j(8);
4193 	Handle(AIS_ColoredShape) theBox = new AIS_ColoredShape(aBox);
4194 	myAISContext->SetColor(theBox,Quantity_NOC_RED,Standard_False);
4195 	myAISContext->SetMaterial(theBox,Graphic3d_NOM_PLASTIC,Standard_False);
4196 	myAISContext->Display(theBox, AIS_Shaded, 0,Standard_False);
4197 	Fit();
4198 	Sleep(500);
4199 
4200 	for (TopExp_Explorer exp (aBox,TopAbs_FACE);exp.More();exp.Next())
4201 	{
4202 		TopoDS_Face aCurrentFace = TopoDS::Face(exp.Current());
4203 		{
4204 			Handle(AIS_ColoredDrawer) aSubFaceAspects = theBox->CustomAspects (aCurrentFace);
4205 			aSubFaceAspects->SetShadingAspect (new Prs3d_ShadingAspect());
4206 			*aSubFaceAspects->ShadingAspect()->Aspect() = *theBox->Attributes()->ShadingAspect()->Aspect();
4207 			aSubFaceAspects->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (0.8f);
4208 			myAISContext->Redisplay (theBox, false);
4209 		}
4210 
4211 		//test the orientation of the current face
4212 		TopAbs_Orientation orient = aCurrentFace.Orientation();
4213 
4214 		//Recover the geometric plane
4215 		TopLoc_Location location;
4216 		Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(aCurrentFace,location);
4217 
4218 		Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);
4219 
4220 		//Build an AIS_Shape with a new color
4221 		Handle(AIS_Shape) theMovingFace = new AIS_Shape(aCurrentFace);
4222 		Quantity_NameOfColor aCurrentColor = (Quantity_NameOfColor)j;
4223 		myAISContext->SetColor(theMovingFace,aCurrentColor,Standard_False);
4224 		myAISContext->SetMaterial(theMovingFace,Graphic3d_NOM_PLASTIC,Standard_False);
4225 		//Find the normal vector of each face
4226 		gp_Pln agpPlane = aPlane->Pln();
4227 		gp_Ax1 norm = agpPlane.Axis();
4228 		gp_Dir dir = norm.Direction();
4229 		gp_Vec move(dir);
4230 
4231 		TopLoc_Location aLocation;
4232 		Handle (AIS_ConnectedInteractive) theTransformedDisplay = new AIS_ConnectedInteractive();
4233 		theTransformedDisplay->Connect(theMovingFace, aLocation);
4234 
4235 		Handle (Geom_Transformation) theMove = new Geom_Transformation(aLocation.Transformation());
4236         myAISContext->Display(theTransformedDisplay,Standard_False);
4237 		myAISContext->UpdateCurrentViewer();
4238 		Sleep (500);
4239 
4240 		for (Standard_Integer i=1;i<=30;i++)
4241 		{
4242 			theMove->SetTranslation(move*i);
4243 			if (orient==TopAbs_FORWARD) myAISContext->SetLocation(theTransformedDisplay,TopLoc_Location(theMove->Trsf()));
4244 			else myAISContext->SetLocation(theTransformedDisplay,TopLoc_Location(theMove->Inverted()->Trsf()));
4245 
4246 			myAISContext->Redisplay(theTransformedDisplay,true);
4247 		}
4248 		j+=15;
4249 	}
4250 
4251 	myAISContext->UpdateCurrentViewer();
4252 	Sleep (500);
4253 
4254 	   TCollection_AsciiString Message ("\
4255 \n\
4256 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100,100,100);	\n\
4257 \n\
4258 for (TopExp_Explorer exp (aBox,TopAbs_FACE);exp.More();exp.Next()) {	\n\
4259 	TopoDS_Face aCurrentFace = TopoDS::Face(exp.Current());	\n\
4260 \n\
4261 	//Recover the geometric plane	\n\
4262 	TopLoc_Location location;	\n\
4263 	Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(aCurrentFace,location);	\n\
4264 \n\
4265 	Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);	\n\
4266 	\n\
4267 \n");
4268 	PocessTextInDialog("Explode a shape in faces ", Message);
4269 
4270 }
4271 
4272 /* =================================================================================
4273    ====================   A N A L Y S I S   ========================================
4274    ================================================================================= */
4275 
OnValid()4276 void CModelingDoc::OnValid()
4277 {
4278 	AIS_ListOfInteractive aList;
4279 	myAISContext->DisplayedObjects(aList);
4280 	AIS_ListIteratorOfListOfInteractive aListIterator;
4281 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4282 		myAISContext->Remove (aListIterator.Value(), Standard_False);
4283 	}
4284 
4285   TopoDS_Shape S = BRepPrimAPI_MakeBox(200., 300., 150.).Shape();
4286 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4287 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4288 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4289 	myAISContext->Display(ais1,Standard_False);
4290 	Fit();
4291 
4292 	TCollection_AsciiString Message ("\
4293 		\n\
4294 TopoDS_Shape S = BRepPrimI_MakeBox(200.,300.,150.);\n\
4295 Standard_Boolean theShapeIsValid = BRepAlgo::IsValid(S);\n\
4296 if ( theShapeIsValid )\n\
4297 {\n\
4298   MessageBox(\"The Shape Is Valid !! \",\"Checking Shape\");\n\
4299 }\n\
4300 else\n\
4301 {\n\
4302   MessageBox(\"The Shape Is NOT Valid !! \",\"Checking Shape\");\n\
4303 }\n\
4304 \n");
4305 	PocessTextInDialog("Check a shape", Message);
4306 
4307 	Standard_Boolean theShapeIsValid = BRepAlgo::IsValid(S);
4308   MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, theShapeIsValid ? L"The Shape Is Valid !! " : L"The Shape Is NOT Valid !! ", L"Checking Shape", MB_OK);
4309 }
4310 
4311 
OnLinear()4312 void CModelingDoc::OnLinear()
4313 {
4314 	AIS_ListOfInteractive aList;
4315 	myAISContext->DisplayedObjects(aList);
4316 	AIS_ListIteratorOfListOfInteractive aListIterator;
4317 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4318 		myAISContext->Remove (aListIterator.Value(), Standard_False);
4319 	}
4320 
4321 
4322 	TColgp_Array1OfPnt Points1(1,4);
4323 	Points1.SetValue(1,gp_Pnt(0,0,0));
4324 	Points1.SetValue(2,gp_Pnt(2,1,0));
4325 	Points1.SetValue(3,gp_Pnt(4,0,0));
4326 	Points1.SetValue(4,gp_Pnt(6,2,0));
4327 	GeomAPI_PointsToBSpline PTBS1(Points1);
4328 	Handle(Geom_BSplineCurve) BSC1 = PTBS1.Curve();
4329 	TopoDS_Edge S = BRepBuilderAPI_MakeEdge(BSC1).Edge();
4330 
4331 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4332 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4333 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4334 	myAISContext->Display(ais1,Standard_False);
4335 	Fit();
4336 
4337 
4338 	GProp_GProps System;
4339 	BRepGProp::LinearProperties(S,System);
4340 	gp_Pnt G = System.CentreOfMass ();
4341 	Standard_Real Length = System.Mass();
4342 	gp_Mat I = System.MatrixOfInertia();
4343 
4344 	TCollection_ExtendedString string("Length Of all the Edges =");
4345   TCollection_ExtendedString string1(Length);
4346 
4347 	string += string1;
4348 	string += "\nCenterOfMass : \n   X=";
4349 	string1 = G.X();
4350 	string += string1;
4351 	string += " Y=";
4352 	string1 = G.Y();
4353 	string += string1;
4354 	string += " Z=";
4355 	string1 = G.Z();
4356 	string += string1;
4357 	string +="\n";
4358 
4359 	string += "Matrix of Inertia :\n     ";
4360 	string1 = I(1,1);
4361 	string += string1;
4362 	string += " " ;
4363 	string1 = I(1,2);
4364 	string += string1;
4365 	string += " " ;
4366 	string1 = I(1,3);
4367 	string += string1;
4368 	string += "\n     " ;
4369 	string1 = I(2,1);
4370 	string += string1;
4371 	string += " " ;
4372 	string1 = I(2,2);
4373 	string += string1;
4374 	string += " " ;
4375 	string1 = I(2,3);
4376 	string += string1;
4377 	string += "\n     " ;
4378 	string1 = I(3,1);
4379 	string += string1;
4380 	string += " " ;
4381 	string1 = I(3,2);
4382 	string += string1;
4383 	string += " " ;
4384 	string1 = I(3,3);
4385 	string += string1;
4386 	string += "\n" ;
4387 
4388   TCollection_AsciiString Message ("\
4389 		\n\
4390 TColgp_Array1OfPnt Points1(1,4);\n\
4391 Points1.SetValue(1,gp_Pnt(0,0,0));\n\
4392 Points1.SetValue(2,gp_Pnt(2,1,0));\n\
4393 Points1.SetValue(3,gp_Pnt(4,0,0));\n\
4394 Points1.SetValue(4,gp_Pnt(6,2,0));\n\
4395 GeomAPI_PointsToBSpline PTBS1(Points1);\n\
4396 Handle(Geom_BSplineCurve) BSC1 = PTBS1.Curve();\n\
4397 TopoDS_Shape S = BRepBuilderAPI_MakeEdge(BSC1).Edge();\n\
4398 GProp_GProps System;\n\
4399 BRepGProp::LinearProperties(S,System);\n\
4400 gp_Pnt G = System.CentreOfMass ();\n\
4401 Standard_Real Length = System.Mass();\n\
4402 gp_Mat I = System.MatrixOfInertia();\n\
4403 \n");
4404 	PocessTextInDialog("Linear Properties", Message);
4405 	MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, string.ToWideString(), L"Linear Properties", MB_OK);
4406 }
4407 
OnSurface()4408 void CModelingDoc::OnSurface()
4409 {
4410 	AIS_ListOfInteractive aList;
4411 	myAISContext->DisplayedObjects(aList);
4412 	AIS_ListIteratorOfListOfInteractive aListIterator;
4413 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4414 		myAISContext->Remove (aListIterator.Value(), Standard_False);
4415 	}
4416 
4417 	TColgp_Array1OfPnt Pnts1(1,3);
4418 	TColgp_Array1OfPnt Pnts2(1,3);
4419 	TColgp_Array1OfPnt Pnts3(1,3);
4420 	TColgp_Array1OfPnt Pnts4(1,3);
4421 
4422 	Pnts1(1) = gp_Pnt(0,0,0);
4423 	Pnts1(2) = gp_Pnt(5,0,0);
4424 	Pnts1(3) = gp_Pnt(10,10,0);
4425 
4426 	Pnts2(1) = gp_Pnt(10,10,0);
4427 	Pnts2(2) = gp_Pnt(5,12,4);
4428 	Pnts2(3) = gp_Pnt(0,15,10);
4429 
4430 	Pnts3(1) = gp_Pnt(0,15,10);
4431 	Pnts3(2) = gp_Pnt(-12,10,11);
4432 	Pnts3(3) = gp_Pnt(-10,5,13);
4433 
4434 	Pnts4(1) = gp_Pnt(-10,5,13);
4435 	Pnts4(2) = gp_Pnt(-2,-2,2);
4436 	Pnts4(3) = gp_Pnt(0,0,0);
4437 
4438 	GeomAPI_PointsToBSpline PTBS1(Pnts1);
4439 	GeomAPI_PointsToBSpline PTBS2(Pnts2);
4440 	GeomAPI_PointsToBSpline PTBS3(Pnts3);
4441 	GeomAPI_PointsToBSpline PTBS4(Pnts4);
4442 	Handle(Geom_BSplineCurve) C1 = PTBS1.Curve();
4443 	Handle(Geom_BSplineCurve) C2 = PTBS2.Curve();
4444 	Handle(Geom_BSplineCurve) C3 = PTBS3.Curve();
4445 	Handle(Geom_BSplineCurve) C4 = PTBS4.Curve();
4446 
4447 	GeomFill_BSplineCurves fill;
4448 	fill.Init(C1,C2,C3,C4,GeomFill_CoonsStyle);
4449 	Handle(Geom_BSplineSurface) BSS = fill.Surface();
4450 
4451 	TopoDS_Shape S = BRepBuilderAPI_MakeFace(BSS, Precision::Confusion()).Face();
4452 
4453 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4454 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4455 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4456 	myAISContext->Display(ais1,Standard_False);
4457 	Fit();
4458 
4459 
4460 	GProp_GProps System;
4461 	BRepGProp::SurfaceProperties(S,System);
4462 	gp_Pnt G = System.CentreOfMass ();
4463 	Standard_Real Area = System.Mass();
4464 	gp_Mat I = System.MatrixOfInertia();
4465 
4466 	TCollection_ExtendedString string("Area Of the Face =");
4467   TCollection_ExtendedString string1(Area);
4468 
4469 	string += string1;
4470 	string += "\nCenterOfMass : \n   X=";
4471 	string1 = G.X();
4472 	string += string1;
4473 	string += " Y=";
4474 	string1 = G.Y();
4475 	string += string1;
4476 	string += " Z=";
4477 	string1 = G.Z();
4478 	string += string1;
4479 	string +="\n";
4480 
4481 	string += "Matrix of Inertia :\n     ";
4482 	string1 = I(1,1);
4483 	string += string1;
4484 	string += " " ;
4485 	string1 = I(1,2);
4486 	string += string1;
4487 	string += " " ;
4488 	string1 = I(1,3);
4489 	string += string1;
4490 	string += "\n     " ;
4491 	string1 = I(2,1);
4492 	string += string1;
4493 	string += " " ;
4494 	string1 = I(2,2);
4495 	string += string1;
4496 	string += " " ;
4497 	string1 = I(2,3);
4498 	string += string1;
4499 	string += "\n     " ;
4500 	string1 = I(3,1);
4501 	string += string1;
4502 	string += " " ;
4503 	string1 = I(3,2);
4504 	string += string1;
4505 	string += " " ;
4506 	string1 = I(3,3);
4507 	string += string1;
4508 	string += "\n" ;
4509 
4510   TCollection_AsciiString Message ("\
4511 		\n\
4512 TopoDS_Shape S = BRepBuilderAPI_MakeFace(BSplineSurf).Face();\n\
4513 GProp_GProps System;\n\
4514 BRepGProp::SurfaceProperties(S,System);\n\
4515 gp_Pnt G = System.CentreOfMass ();\n\
4516 Standard_Real Area = System.Mass();\n\
4517 gp_Mat I = System.MatrixOfInertia();\n\
4518 \n");
4519   PocessTextInDialog("Surface Properties", Message);
4520 	MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, string.ToWideString(), L"Surface Properties", MB_OK);
4521 
4522 }
4523 
OnVolume()4524 void CModelingDoc::OnVolume()
4525 {
4526 	AIS_ListOfInteractive aList;
4527 	myAISContext->DisplayedObjects(aList);
4528 	AIS_ListIteratorOfListOfInteractive aListIterator;
4529 	for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4530 		myAISContext->Remove (aListIterator.Value(), Standard_False);
4531 	}
4532 
4533 
4534 	TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
4535 	Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4536 	myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4537 	myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4538 	myAISContext->Display(ais1,Standard_False);
4539 	Fit();
4540 
4541 
4542 	GProp_GProps System;
4543 	BRepGProp::VolumeProperties(S,System);
4544 	gp_Pnt G = System.CentreOfMass ();
4545 	Standard_Real Volume = System.Mass();
4546 	gp_Mat I = System.MatrixOfInertia();
4547 
4548 	TCollection_ExtendedString string("Volume Of all the Shape =");
4549   TCollection_ExtendedString string1(Volume);
4550 
4551 	string += string1;
4552 	string += "\nCenterOfMass : \n   X=";
4553 	string1 = G.X();
4554 	string += string1;
4555 	string += " Y=";
4556 	string1 = G.Y();
4557 	string += string1;
4558 	string += " Z=";
4559 	string1 = G.Z();
4560 	string += string1;
4561 	string +="\n";
4562 
4563 	string += "Matrix of Inertia :\n     ";
4564 	string1 = I(1,1);
4565 	string += string1;
4566 	string += " " ;
4567 	string1 = I(1,2);
4568 	string += string1;
4569 	string += " " ;
4570 	string1 = I(1,3);
4571 	string += string1;
4572 	string += "\n     " ;
4573 	string1 = I(2,1);
4574 	string += string1;
4575 	string += " " ;
4576 	string1 = I(2,2);
4577 	string += string1;
4578 	string += " " ;
4579 	string1 = I(2,3);
4580 	string += string1;
4581 	string += "\n     " ;
4582 	string1 = I(3,1);
4583 	string += string1;
4584 	string += " " ;
4585 	string1 = I(3,2);
4586 	string += string1;
4587 	string += " " ;
4588 	string1 = I(3,3);
4589 	string += string1;
4590 	string += "\n" ;
4591 
4592 	TCollection_AsciiString Message ("\
4593 		\n\
4594 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.);;\n\
4595 GProp_GProps System;\n\
4596 BRepGProp::VolumeProperties(S,System);\n\
4597 gp_Pnt G = System.CentreOfMass ();\n\
4598 Standard_Real Volume = System.Mass();\n\
4599 gp_Mat I = System.MatrixOfInertia();\n\
4600 \n");
4601   PocessTextInDialog("Volume Properties", Message);
4602 	MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, string.ToWideString(), L"Volume Properties", MB_OK);
4603 }
4604 
4605 
OnButtonFill()4606 void CModelingDoc::OnButtonFill()
4607 {
4608 	// TODO: Add your command handler code here
4609 	myAISContext->InitSelected();
4610 	if (myAISContext->MoreSelected()) {
4611 		AIS1 = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive());
4612 		myAISContext->Unhilight (AIS1, Standard_True);
4613 		myAISContext->Activate(AIS1,2);
4614 		myState = SELECT_EDGE_PLATE;
4615 		((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select hole contour edges and then press right mouse button");	}
4616 	else {
4617 		AIS_ListOfInteractive LI;
4618 		myAISContext->DisplayedObjects(LI);
4619 		if(LI.IsEmpty()){
4620 			if(OnFileImportBrep_WithInitDir (L"HoleFilling") == 1)
4621 				return;
4622 		myAISContext->DisplayedObjects(LI);
4623 		myAISContext->SetSelected(LI.First(), Standard_True);
4624 			OnButtonFill();
4625 			return;
4626 		}
4627 	AfxMessageBox (L"Select a shape before!");
4628 	}
4629 }
4630 
OnStopStop()4631 void CModelingDoc::OnStopStop()
4632 {
4633 	// TODO: Add your command handler code here
4634 	// Stop selection
4635 	if (myState == SELECT_EDGE_PLATE ) {
4636 		Standard_Integer nbedges = 0;
4637 		for (myAISContext->InitSelected(); myAISContext->MoreSelected();
4638 		     myAISContext->NextSelected()) {
4639 			nbedges++;
4640 
4641 		}
4642                 Handle(GeomPlate_HArray1OfHCurve) Fronts =
4643                         new GeomPlate_HArray1OfHCurve(1, nbedges);
4644 		Handle(TColStd_HArray1OfInteger) Tang =
4645 			new TColStd_HArray1OfInteger(1,nbedges);
4646 		Handle(TColStd_HArray1OfInteger) NbPtsCur =
4647 			new TColStd_HArray1OfInteger(1,nbedges);
4648 		Standard_Integer i = 0;
4649 		TopoDS_Shape S1 = AIS1->Shape();
4650 		TopTools_IndexedDataMapOfShapeListOfShape M;
4651 		TopExp::MapShapesAndAncestors(S1, TopAbs_EDGE, TopAbs_FACE, M);
4652 
4653 		for (myAISContext->InitSelected(); myAISContext->MoreSelected();myAISContext->NextSelected()) {
4654 			i++;
4655 			Tang->SetValue(i,1);
4656 			NbPtsCur->SetValue(i,10);
4657 			TopoDS_Edge E = TopoDS::Edge(myAISContext->SelectedShape());
4658 			TopoDS_Face F = TopoDS::Face(M.FindFromKey(E).First());
4659 
4660 			BRepAdaptor_Surface S(F);
4661 			GeomAdaptor_Surface aGAS = S.Surface();
4662 			Handle(GeomAdaptor_Surface) aHGAS = new GeomAdaptor_Surface(aGAS);
4663 
4664 			Handle(BRepAdaptor_Curve2d) C = new BRepAdaptor_Curve2d();
4665 			C->Initialize(E,F);
4666 
4667 			Adaptor3d_CurveOnSurface ConS(C,aHGAS);
4668 
4669 			Handle (Adaptor3d_CurveOnSurface) HConS = new Adaptor3d_CurveOnSurface(ConS);
4670 			Fronts->SetValue(i,HConS);
4671 		}
4672 		GeomPlate_BuildPlateSurface abuildplate(NbPtsCur,Fronts,Tang,3);
4673 		abuildplate.Perform();
4674 		if (!abuildplate.IsDone()){ // New in 2.0
4675 			MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : Build plate not valid!", L"CasCade Error", MB_ICONERROR);
4676 			return;
4677 		}
4678 		Handle(GeomPlate_Surface) aplate = abuildplate.Surface();
4679 
4680 		GeomPlate_MakeApprox aMKS(aplate, Precision::Approximation(), 4, 7, 0.001, 1);
4681 		Handle(Geom_BSplineSurface) support = aMKS.Surface();
4682 		BRepBuilderAPI_MakeWire MW;
4683 		TopTools_Array1OfShape tab(1,nbedges);
4684 		for (i=1 ; i<=nbedges ; i++) {
4685 			if (abuildplate.Sense()->Value(abuildplate.Order()->Value(i))==1) {
4686 				BRepBuilderAPI_MakeEdge ME(abuildplate.Curves2d()->Value(abuildplate.Order()->Value(i)),
4687 									support,
4688 									Fronts->Value(abuildplate.Order()->Value(i))->LastParameter(),
4689 									Fronts->Value(abuildplate.Order()->Value(i))->FirstParameter());
4690 				TopoDS_Edge E = ME.Edge();
4691 				BRepLib::BuildCurves3d(E);
4692 				tab(abuildplate.Order()->Value(i)) = E;
4693 				//MW.Add(E);
4694 			}
4695 			else {
4696 				BRepBuilderAPI_MakeEdge ME(abuildplate.Curves2d()->Value(abuildplate.Order()->Value(i)),
4697 									support,
4698 									Fronts->Value(abuildplate.Order()->Value(i))->FirstParameter(),
4699 									Fronts->Value(abuildplate.Order()->Value(i))->LastParameter());
4700 				TopoDS_Edge E = ME.Edge();
4701 				BRepLib::BuildCurves3d(E);
4702 				tab(abuildplate.Order()->Value(i)) = E;
4703 			}
4704 		}
4705 		for (i=1 ; i<=nbedges ; i++)
4706 			MW.Add(TopoDS::Edge(tab(i)));
4707 		TopoDS_Wire W;
4708 		try{
4709 		W=MW.Wire();
4710 		}
4711 
4712 		catch(StdFail_NotDone)
4713 		{
4714 			AfxMessageBox (L"Can't build wire!");
4715 			return;
4716 		}
4717 
4718 		if (!(W.Closed())){
4719 			AfxMessageBox (L"Wire is not closed!");
4720 			return;
4721 			//throw Standard_Failure("Wire is not closed");
4722 
4723 		}
4724 		BRepBuilderAPI_MakeFace MF(support,W,Standard_True);
4725 		TopoDS_Face aface;
4726 		aface = MF.Face();
4727 		BRepTopAdaptor_FClass2d clas2d(aface,Precision::Confusion());
4728 		if (clas2d.PerformInfinitePoint() == TopAbs_IN) {
4729 			W.Reverse();
4730 			BRepBuilderAPI_MakeFace MF1(support,W,Standard_True);
4731 			aface = MF1.Face();
4732 		}
4733 		if (!BRepAlgo::IsValid(aface))
4734 			MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : The plate face is not valid!", L"CasCade Error", MB_ICONERROR);
4735 		myState = -1;
4736 		Handle(AIS_Shape) anAISShape = new AIS_Shape(aface);
4737 		myAISContext->SetColor (anAISShape,Quantity_NOC_AZURE, Standard_False);
4738 		myAISContext->SetMaterial (anAISShape, Graphic3d_NOM_SILVER, Standard_False);
4739     myAISContext->SetDisplayMode (anAISShape, 1, Standard_False);
4740 		myAISContext->Display (anAISShape, Standard_True);
4741 	}
4742 }
4743 
OnFillwithtang()4744 void CModelingDoc::OnFillwithtang()
4745 {
4746 	static BOOL flag = 0;
4747 	if (flag == 1){
4748 		flag = 0;
4749 		Handle(AIS_InteractiveObject) aObject;
4750 		myAISContext ->InitSelected();
4751 		if(myAISContext->MoreSelected())
4752 			aObject = myAISContext->SelectedInteractive();
4753 		((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with second face");
4754 		if(OnFileImportBrep_WithInitDir (L"TangentSurface") == 1){
4755 			((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
4756 				AIS_ListOfInteractive aList;
4757 				myAISContext->DisplayedObjects(aList);
4758 				AIS_ListIteratorOfListOfInteractive aListIterator;
4759 				for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4760 					myAISContext->Remove (aListIterator.Value(), Standard_False);
4761 				}
4762         myAISContext->UpdateCurrentViewer();
4763 				return;
4764 			}
4765 		myAISContext->SetSelected(aObject, Standard_True);
4766 	}
4767 
4768 	myAISContext->InitSelected();
4769 	if (myAISContext->MoreSelected()) {
4770 		Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive());
4771 		try {
4772                   THE_F1 = TopoDS::Face(ashape->Shape());
4773 		}
4774 	    catch(Standard_Failure){}
4775 		if (THE_F1.IsNull())
4776                 {
4777                     AfxMessageBox (L"Current object is not a face!\n\
4778 Please, select a face to continue\nthe creation of a tangent surface.");
4779                     return;
4780                 }
4781 		myAISContext->Activate(ashape,2);
4782 		myState = SELECT_EDGE_PLATE_TGTES_1;
4783 
4784 		((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the first face");
4785 	}
4786 	else {
4787 		AIS_ListOfInteractive LI;
4788 		myAISContext->DisplayedObjects(LI);
4789 		if(LI.IsEmpty()){
4790 			((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with first face");
4791 			if(OnFileImportBrep_WithInitDir (L"TangentSurface") == 1){
4792 				((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
4793 				AIS_ListOfInteractive aList;
4794 				myAISContext->DisplayedObjects(aList);
4795 				AIS_ListIteratorOfListOfInteractive aListIterator;
4796 				for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4797 					myAISContext->Remove(aListIterator.Value(), Standard_False);
4798 				}
4799         myAISContext->UpdateCurrentViewer();
4800 				return;
4801 			}
4802 			((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
4803 			myAISContext->DisplayedObjects(LI);
4804 			myAISContext->SetSelected (LI.First(), Standard_True);
4805 			Sleep(700);
4806 			flag = 1;
4807 			OnFillwithtang();
4808 			return;
4809 		}
4810 		AfxMessageBox (L"Select a face before");
4811 	}
4812 }
4813 
InputEvent(const Standard_Integer,const Standard_Integer,const Handle (V3d_View)&)4814 void CModelingDoc::InputEvent(const Standard_Integer /*x*/,
4815                               const Standard_Integer /*y*/,
4816                               const Handle(V3d_View)& /*aView*/)
4817 {
4818     myAISContext->SelectDetected();
4819     myAISContext->UpdateCurrentViewer();
4820 
4821 	if (myState == SELECT_EDGE_PLATE_TGTES_1) {
4822 		myAISContext->InitSelected();
4823  		if (myAISContext->MoreSelected()) {
4824  			THE_E1 = TopoDS::Edge(myAISContext->SelectedShape());
4825  			myState = SELECT_EDGE_PLATE_TGTES_2;
4826 
4827 			AIS_ListOfInteractive aLI;
4828 			myAISContext->DisplayedObjects(aLI);
4829 			if(aLI.Extent() == 2){
4830 				myState = SELECT_EDGE_PLATE_TGTES_2;
4831 				if (myAISContext->IsSelected(aLI.First()))
4832 					myAISContext->SetSelected (aLI.Last(), Standard_True);
4833 				else
4834 					myAISContext->SetSelected (aLI.First(), Standard_True);
4835 				myAISContext->InitSelected();
4836 				Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive());
4837  				THE_F2 = TopoDS::Face(ashape->Shape());
4838 				myAISContext->Activate(ashape,2);
4839 				myState = SELECT_EDGE_PLATE_TGTES_3;
4840 				((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the second face");
4841 				return;
4842 			}
4843 
4844 			((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select second face");
4845 			AIS_ListOfInteractive LI;
4846 			myAISContext->DisplayedObjects(LI);
4847 			if(LI.Extent() == 1){
4848 				if(OnFileImportBrep_WithInitDir (L"TangentSurface") == 1)
4849 				return;
4850 			}
4851  		}
4852  		else
4853  			AfxMessageBox (L"Select an edge on the face!");
4854 
4855  	}
4856  	else if (myState == SELECT_EDGE_PLATE_TGTES_2) {
4857 		myAISContext->InitSelected();
4858 		if (myAISContext->MoreSelected()) {
4859 			Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive());
4860 			THE_F2 = TopoDS::Face(ashape->Shape());
4861 			myAISContext->Activate(ashape,2);
4862 			myState = SELECT_EDGE_PLATE_TGTES_3;
4863 			((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the second face");
4864 		}
4865 		else
4866 			AfxMessageBox (L"Select the second face!");
4867 	}
4868 	else if (myState == SELECT_EDGE_PLATE_TGTES_3) {
4869 		myAISContext->InitSelected();
4870 		if (myAISContext->MoreSelected()) {
4871 			THE_E2 = TopoDS::Edge(myAISContext->SelectedShape());
4872 
4873 			Standard_Integer i, nbPntsOnFaces=10;
4874 			Standard_Real u,First, Last, Delta, Tol=0.001, TolProj;
4875 			Plate_Plate aPlate;
4876 			gp_Vec V1,V2,W1,W2;
4877 			gp_Pnt2d P2d;
4878 			gp_Pnt P, PP;
4879 
4880 			//get the pcurve, curve and surface
4881 			BRepAdaptor_Curve   Curve3d1(THE_E1), Curve3d2(THE_E2);
4882 			BRepAdaptor_Curve2d Curve2d1(THE_E1,THE_F1), Curve2d2(THE_E2,THE_F2);
4883 			BRepAdaptor_Surface Surf1(THE_F1), Surf2(THE_F2);
4884 
4885 			//compute the average plane : initial surface
4886 			Handle(TColgp_HArray1OfPnt) theTanPoints = new
4887 				TColgp_HArray1OfPnt (1,2*nbPntsOnFaces );
4888 
4889 			Delta = (Curve3d1.LastParameter()-Curve3d1.FirstParameter())/(nbPntsOnFaces-1);
4890 			for (u=Curve3d1.FirstParameter(),i=1;i<=nbPntsOnFaces; i++,u+=Delta)
4891 				theTanPoints->SetValue(i,Curve3d1.Value(u));
4892 
4893 			Delta = (Curve3d2.LastParameter()-Curve3d2.FirstParameter())/(nbPntsOnFaces-1);
4894 			for (u=Curve3d2.FirstParameter(),i=1;i<=nbPntsOnFaces; i++,u+=Delta)
4895 				theTanPoints->SetValue(nbPntsOnFaces+i,Curve3d2.Value(u));
4896 
4897 			//Building an initial plane
4898 			GeomPlate_BuildAveragePlane aMkPlane (theTanPoints,int(Tol),1,1,1);
4899 			Handle(Geom_Plane) aPlane = aMkPlane.Plane();
4900 			gp_Pln aPln = aPlane->Pln();
4901 			gp_XYZ aNormale = aPln.Axis().Direction().XYZ();
4902 			gp_Trsf aTrsf; // to compute the U and V of the points
4903 			aTrsf.SetTransformation(aPln.Position());
4904 
4905 			aPlane->D1(0,0,P,W1,W2); // extract plane DU & DV
4906 
4907 			// 1st surface tangencies constraints
4908 			Delta = (Curve3d1.LastParameter()-Curve3d1.FirstParameter())/(nbPntsOnFaces-1);
4909 			for (u=Curve3d1.FirstParameter(),i=1; i<=nbPntsOnFaces; i++,u+=Delta) {
4910 				P = Curve3d1.Value(u).Transformed(aTrsf);
4911 				gp_XY UV(P.X(),P.Y());
4912 				aPlate.Load(Plate_PinpointConstraint(UV,aNormale*P.Z()));
4913 				Curve2d1.D0(u,P2d);
4914 				Surf1.D1(P2d.X(),P2d.Y(),P,V1,V2);  // extract surface UV of the point
4915 				aPlate.Load(Plate_GtoCConstraint(UV,
4916 												 Plate_D1(W1.XYZ(),W2.XYZ()),
4917 												 Plate_D1(V1.XYZ(),V2.XYZ())));
4918 			}
4919 			// 2nd surface
4920 			Delta = (Curve3d2.LastParameter()-Curve3d2.FirstParameter())/(nbPntsOnFaces-1);
4921 			for (u=Curve3d2.FirstParameter(),i=1; i<=nbPntsOnFaces; i++,u+=Delta) {
4922 				P = Curve3d2.Value(u).Transformed(aTrsf);
4923 				gp_XY UV(P.X(),P.Y());
4924 				aPlate.Load(Plate_PinpointConstraint(UV,aNormale*P.Z()));
4925 
4926 				Curve2d2.D0(u,P2d);
4927 				Surf2.D1(P2d.X(),P2d.Y(),P,V1,V2);
4928 				aPlate.Load(Plate_GtoCConstraint(UV,
4929 												 Plate_D1(W1.XYZ(),W2.XYZ()),
4930 												 Plate_D1(V1.XYZ()*-1,V2.XYZ()*-1)));
4931 			}
4932 
4933 			((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with passing points");
4934 			//Some passing points
4935 			CFileDialog dlg(TRUE,
4936 					NULL,
4937 					NULL,
4938 					OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
4939 					L"Points Files (*.pass)|*.pass; |All Files (*.*)|*.*||",
4940 					NULL);
4941 
4942 			CString initdir;
4943 			initdir.GetEnvironmentVariable (L"CSF_OCCTDataPath");
4944 			initdir += L"\\occ";
4945 
4946 			dlg.m_ofn.lpstrInitialDir = initdir;
4947 
4948 			if (dlg.DoModal() == IDOK)
4949 			{
4950 				((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Building the tangent surface...");
4951 				SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
4952 				CString filename = dlg.GetPathName();
4953 				std::filebuf fic;
4954 				std::istream in(&fic);
4955 				if (!fic.open(filename, std::ios::in))
4956 					MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : Unable to open file", L"CasCade Error", MB_ICONERROR);
4957 				Standard_Real x,y,z;
4958 				BRep_Builder B;
4959 				TopoDS_Compound C;
4960 				B.MakeCompound(C);
4961 				while (!in.fail()|| !in.eof()){
4962 					if (in >> x && in >> y && in >> z){
4963 						PP = gp_Pnt(x, y, z);
4964 						P = PP.Transformed(aTrsf);
4965 						aPlate.Load(Plate_PinpointConstraint(gp_XY(P.X(),P.Y()),
4966 															aNormale*P.Z()));
4967 						BRepBuilderAPI_MakeVertex V(PP);
4968 						B.Add(C,V.Vertex());
4969 					}
4970 				}
4971 				fic.close();
4972  				Handle(AIS_Shape) anAISCompound = new AIS_Shape(C);
4973 				myAISContext->Display(anAISCompound, Standard_False);
4974 				Fit();
4975 				Sleep(500);
4976 			}
4977 			SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
4978 			((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Building the tangent surface...");
4979 			//Solving ...
4980 			Standard_Integer Order = 3; // constraints continuity + 2
4981 			aPlate.SolveTI(Order,1.);
4982 			if (!aPlate.IsDone()){
4983 				MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : Build plate not valid!", L"CasCade Error", MB_ICONERROR);
4984 				return;
4985 			}
4986 			//Plate Surface creation
4987 			Handle(GeomPlate_Surface) aPlateSurface = new GeomPlate_Surface(aPlane,aPlate);
4988 			//BSplineSurface approximation
4989 			GeomPlate_MakeApprox aMkSurf(aPlateSurface,Tol,1,8,0.1,1);
4990 			Handle(Geom_Surface) theSurface =aMkSurf.Surface();
4991 
4992 			// Face building ...
4993 			Handle(Geom2d_Curve)C1,C2,C3,C4;
4994 			Handle(Geom_Curve)C;
4995 			C = BRep_Tool::Curve(THE_E1,First,Last);
4996 			TolProj = 0.01;
4997 			C1 = GeomProjLib::Curve2d(C,First,Last,theSurface,TolProj);
4998 			TopoDS_Edge Ed1 = BRepBuilderAPI_MakeEdge(C1,theSurface).Edge();
4999 
5000 			C = BRep_Tool::Curve(THE_E2,First,Last);
5001 			TolProj = 0.01;
5002 			C3 = GeomProjLib::Curve2d(C,First,Last,theSurface,TolProj);
5003 			TopoDS_Edge Ed3 = BRepBuilderAPI_MakeEdge(C3,theSurface).Edge();
5004 
5005 			C2 = GCE2d_MakeSegment(C1->Value(C1->FirstParameter()),
5006 								C3->Value(C3->FirstParameter())).Value();
5007 			TopoDS_Edge Ed2 = BRepBuilderAPI_MakeEdge(C2,theSurface).Edge();
5008 			C4 = GCE2d_MakeSegment(C1->Value(C1->LastParameter()),
5009 								C3->Value(C3->LastParameter())).Value();
5010 			TopoDS_Edge Ed4 = BRepBuilderAPI_MakeEdge(C4,theSurface).Edge();
5011 			Ed2.Reverse();
5012 			Ed3.Reverse();
5013 			TopoDS_Wire theWire = BRepBuilderAPI_MakeWire(Ed1,Ed2,Ed3,Ed4);
5014 			TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire);
5015 			BRepLib::BuildCurves3d(theFace);
5016 			if (!BRepAlgo::IsValid(theFace)){
5017 				C2 = GCE2d_MakeSegment(C1->Value(C1->LastParameter()),
5018 										C3->Value(C3->FirstParameter())).Value();
5019 				Ed2 = BRepBuilderAPI_MakeEdge(C2,theSurface).Edge();
5020 				C4 = GCE2d_MakeSegment(C3->Value(C3->LastParameter()),
5021 								C1->Value(C1->FirstParameter())).Value();
5022 				Ed4 = BRepBuilderAPI_MakeEdge(C4,theSurface).Edge();
5023 				Ed3.Reverse();
5024 				theWire = BRepBuilderAPI_MakeWire(Ed1,Ed2,Ed3,Ed4);
5025 				theFace = BRepBuilderAPI_MakeFace(theWire);
5026 				BRepLib::BuildCurves3d(theFace);
5027 				if (!BRepAlgo::IsValid(theFace))
5028 					MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : The plate surface is not valid!!!", L"CasCade Error", MB_ICONERROR);
5029 			}
5030 
5031 			Handle(AIS_Shape) anAISShape=new AIS_Shape(theFace);
5032 			myAISContext->SetColor (anAISShape, Quantity_NOC_BLUE1, Standard_False);
5033 			myAISContext->SetMaterial (anAISShape, Graphic3d_NOM_SILVER, Standard_False);
5034 			myAISContext->SetDisplayMode (anAISShape, 1, Standard_False);
5035 			myAISContext->Display (anAISShape, Standard_False);
5036 			myState = -1;
5037 		}
5038 		else
5039 			AfxMessageBox (L"Select an edge on the second face!");
5040 		((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
5041 
5042 	}
5043 }
5044 
Popup(const Standard_Integer x,const Standard_Integer y,const Handle (V3d_View)& aView)5045 void CModelingDoc::Popup(const Standard_Integer  x,
5046 					     const Standard_Integer  y ,
5047                          const Handle(V3d_View)& aView)
5048 {
5049   Standard_Integer PopupMenuNumber=0;
5050   myAISContext->InitSelected();
5051   if (myState == SELECT_EDGE_PLATE)
5052     PopupMenuNumber=2;
5053   else if (myAISContext->MoreSelected())
5054     PopupMenuNumber=1;
5055 
5056   CMenu menu;
5057   VERIFY(menu.LoadMenu(IDR_Popup3D));
5058   CMenu* pPopup = menu.GetSubMenu(PopupMenuNumber);
5059   ASSERT(pPopup != NULL);
5060 
5061   if (PopupMenuNumber == 1) // more than 1 object.
5062   {
5063     bool OneOrMoreInShading = false;
5064 	for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ())
5065     if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true;
5066 	if(!OneOrMoreInShading)
5067    	pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
5068    }
5069 
5070 
5071   POINT winCoord = { x , y };
5072   Handle(WNT_Window) aWNTWindow=
5073   Handle(WNT_Window)::DownCast(aView->Window());
5074   ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord);
5075   pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y ,
5076                          AfxGetMainWnd());
5077 }
5078