1 // ModelingDoc.cpp : implementation of the CModelingDoc class
6 #include "ModelingDoc.h"
8 #include "ModelingApp.h"
9 #include "ResultDialog.h"
12 #include "ISession_Direction.h"
13 #include "..\res\resource.h"
15 #include <AIS_ListOfInteractive.hxx>
16 #include <AIS_ListIteratorOfListOfInteractive.hxx>
17 #include <TColStd_Array2OfReal.hxx>
18 #include <OCC_MainFrame.h>
20 Handle(AIS_Shape) AIS1;
24 /////////////////////////////////////////////////////////////////////////////
27 IMPLEMENT_DYNCREATE(CModelingDoc, CDocument)
29 BEGIN_MESSAGE_MAP(CModelingDoc, OCC_3dBaseDoc)
30 //{{AFX_MSG_MAP(CModelingDoc)
31 ON_COMMAND(ID_MIRROR, OnMirror)
32 ON_COMMAND(ID_MIRRORAXIS, OnMirroraxis)
33 ON_COMMAND(ID_ROTATE, OnRotate)
34 ON_COMMAND(ID_SCALE, OnScale)
35 ON_COMMAND(ID_TRANSLATION, OnTranslation)
36 ON_COMMAND(ID_DISPLACEMENT, OnDisplacement)
37 ON_COMMAND(ID_DEFORM, OnDeform)
38 ON_COMMAND(ID_BOX, OnBox)
39 ON_COMMAND(ID_Cylinder, OnCylinder)
40 ON_COMMAND(ID_CONE, OnCone)
41 ON_COMMAND(ID_SPHERE, OnSphere)
42 ON_COMMAND(ID_TORUS, OnTorus)
43 ON_COMMAND(ID_WEDGE, OnWedge)
44 ON_COMMAND(ID_PRISM, OnPrism)
45 ON_COMMAND(ID_REVOL, OnRevol)
46 ON_COMMAND(ID_PIPE, OnPipe)
47 ON_COMMAND(ID_THRU, OnThru)
48 ON_COMMAND(ID_EVOLVED, OnEvolved)
49 ON_COMMAND(ID_DRAFT, OnDraft)
50 ON_COMMAND(ID_CUT, OnCut)
51 ON_COMMAND(ID_FUSE, OnFuse)
52 ON_COMMAND(ID_SECTION, OnSection)
53 ON_COMMAND(ID_COMMON, OnCommon)
54 ON_COMMAND(ID_PSECTION, OnPsection)
55 ON_COMMAND(ID_BLEND, OnBlend)
56 ON_COMMAND(ID_CHAMF, OnChamf)
57 ON_COMMAND(ID_EVOLVEDBLEND, OnEvolvedblend)
58 ON_COMMAND(ID_PRISM_LOCAL, OnPrismLocal)
59 ON_COMMAND(ID_REVOL_LOCAL, OnRevolLocal)
60 ON_COMMAND(ID_GLUE_LOCAL, OnGlueLocal)
61 ON_COMMAND(ID_DPRISM_LOCAL, OnDprismLocal)
62 ON_COMMAND(ID_Pipe_LOCAL, OnPipeLocal)
63 ON_COMMAND(ID_LINEAR_LOCAL, OnLinearLocal)
64 ON_COMMAND(ID_SPLIT_LOCAL, OnSplitLocal)
65 ON_COMMAND(ID_THICK_LOCAL, OnThickLocal)
66 ON_COMMAND(ID_OFFSET_LOCAL, OnOffsetLocal)
67 ON_COMMAND(ID_VERTEX, OnVertex)
68 ON_COMMAND(ID_EDGE, OnEdge)
69 ON_COMMAND(ID_WIRE, OnWire)
70 ON_COMMAND(ID_FACE, OnFace)
71 ON_COMMAND(ID_SHELL, OnShell)
72 ON_COMMAND(ID_COMPOUND, OnCompound)
73 ON_COMMAND(ID_GEOMETRIE, OnGeometrie)
74 ON_COMMAND(ID_SEWING, OnSewing)
75 ON_COMMAND(ID_EXPLORER, OnExplorer)
76 ON_COMMAND(ID_BUILDER, OnBuilder)
77 ON_COMMAND(ID_VALID, OnValid)
78 ON_COMMAND(ID_LINEAR, OnLinear)
79 ON_COMMAND(ID_VOLUME, OnVolume)
80 ON_COMMAND(ID_SURFACE, OnSurface)
81 ON_COMMAND(ID_BUTTON_FILL, OnButtonFill)
82 ON_COMMAND(ID_STOP_STOP, OnStopStop)
83 ON_COMMAND(ID_FILLWITHTANG, OnFillwithtang)
87 /////////////////////////////////////////////////////////////////////////////
88 // CModelingDoc construction/destruction
90 CModelingDoc::CModelingDoc()
92 myAISContext->SetDisplayMode(AIS_Shaded,Standard_False);
95 CModelingDoc::~CModelingDoc()
99 void CModelingDoc::OnMirror()
101 AIS_ListOfInteractive aList;
102 myAISContext->DisplayedObjects(aList);
103 AIS_ListIteratorOfListOfInteractive aListIterator;
104 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
105 myAISContext->Remove(aListIterator.Value());
107 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
108 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
109 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
110 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
111 myAISContext->Display(ais1,Standard_False);
112 gp_Trsf theTransformation;
113 gp_Pnt PntCenterOfTheTransformation(110,60,60);
114 Handle(AIS_Point) aispnt = new AIS_Point(new Geom_CartesianPoint(PntCenterOfTheTransformation));
115 myAISContext->Display(aispnt,Standard_False);
116 theTransformation.SetMirror(PntCenterOfTheTransformation);
117 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
118 TopoDS_Shape S2 = myBRepTransformation.Shape();
119 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
120 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
121 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
122 myAISContext->Display(ais2,Standard_False);
124 TCollection_AsciiString Message ("\
126 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
127 gp_Trsf theTransformation; \n\
128 gp_Pnt PntCenterOfTheTransformation(110,60,60); \n\
129 theTransformation.SetMirror(PntCenterOfTheTransformation);\n\
130 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
131 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
132 PocessTextInDialog("Transform a Shape with Mirror and One point.", Message);
136 void CModelingDoc::OnMirroraxis()
138 AIS_ListOfInteractive aList;
139 myAISContext->DisplayedObjects(aList);
140 AIS_ListIteratorOfListOfInteractive aListIterator;
141 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
142 myAISContext->Remove(aListIterator.Value());
144 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
145 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
146 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
147 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
148 myAISContext->Display(ais1,Standard_False);
149 gp_Trsf theTransformation;
150 gp_Ax1 axe = gp_Ax1(gp_Pnt(110,60,60),gp_Dir(0.,1.,0.));
151 Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
152 Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
153 myAISContext->Display(ax1,Standard_False);
154 theTransformation.SetMirror(axe);
155 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
156 TopoDS_Shape S2 = myBRepTransformation.Shape();
157 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
158 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
159 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
160 myAISContext->Display(ais2,Standard_False);
163 TCollection_AsciiString Message ("\
165 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
166 gp_Trsf theTransformation; \n\
167 gp_Ax1 Axis = gp_Ax1(gp_Pnt(110,60,60),gp_Dir(0.,1.,0.)); \n\
168 theTransformation.SetMirror(Axis);\n\
169 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
170 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
172 PocessTextInDialog("Transform a Shape with Mirror and One axis.", Message);
177 void CModelingDoc::OnRotate()
179 AIS_ListOfInteractive aList;
180 myAISContext->DisplayedObjects(aList);
181 AIS_ListIteratorOfListOfInteractive aListIterator;
182 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
183 myAISContext->Remove(aListIterator.Value());
185 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
186 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
187 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
188 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
189 myAISContext->Display(ais1,Standard_False);
190 gp_Trsf theTransformation;
191 gp_Ax1 axe = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.));
192 Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
193 Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
194 myAISContext->Display(ax1,Standard_False);
195 theTransformation.SetRotation(axe,30*PI/180);
196 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
197 TopoDS_Shape S2 = myBRepTransformation.Shape();
198 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
199 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
200 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
201 myAISContext->Display(ais2,Standard_False);
204 TCollection_AsciiString Message ("\
206 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
207 gp_Trsf theTransformation; \n\
208 gp_Ax1 Axis = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.)); \n\
209 theTransformation.SetRotation(Axis,30*PI/180); // Rotation of 30 degrees \n\
210 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
211 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
213 PocessTextInDialog("Transform a Shape with Rotation.", Message);
217 void CModelingDoc::OnScale()
219 AIS_ListOfInteractive aList;
220 myAISContext->DisplayedObjects(aList);
221 AIS_ListIteratorOfListOfInteractive aListIterator;
222 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
223 myAISContext->Remove(aListIterator.Value());
225 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
226 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
227 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
228 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
229 myAISContext->Display(ais1,Standard_False);
230 gp_Trsf theTransformation;
231 gp_Pnt theCenterOfScale(200,60,60);
232 Handle(AIS_Point) aispnt = new AIS_Point(new Geom_CartesianPoint(theCenterOfScale));
234 myAISContext->Display(aispnt,Standard_False);
235 theTransformation.SetScale(theCenterOfScale,0.5);
236 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
237 TopoDS_Shape S2 = myBRepTransformation.Shape();
239 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
240 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
241 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
242 myAISContext->Display(ais2,Standard_False);
245 TCollection_AsciiString Message ("\
247 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
248 gp_Trsf theTransformation; \n\
249 gp_Pnt theCenterOfScale(200,60,60); \n\
250 theTransformation.SetScale(theCenterOfScale,0.5); // Scale : value = 0.5 \n\
251 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
252 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
254 PocessTextInDialog("Scale a Shape with One point.", Message);
261 void CModelingDoc::OnTranslation()
263 AIS_ListOfInteractive aList;
264 myAISContext->DisplayedObjects(aList);
265 AIS_ListIteratorOfListOfInteractive aListIterator;
266 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
267 myAISContext->Remove(aListIterator.Value());
269 TopoDS_Shape S = BRepPrimAPI_MakeWedge(6.,10.,8.,2.);
270 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
271 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
272 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
273 myAISContext->Display(ais1,Standard_False);
274 gp_Trsf theTransformation;
275 gp_Vec theVectorOfTranslation(-6,-6,6);
277 Handle (ISession_Direction) aDirection1 = new ISession_Direction(gp_Pnt(0,0,0),theVectorOfTranslation);
278 myAISContext->Display(aDirection1,Standard_False);
280 theTransformation.SetTranslation(theVectorOfTranslation);
281 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
282 TopoDS_Shape S2 = myBRepTransformation.Shape();
284 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
285 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
286 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
287 myAISContext->Display(ais2,Standard_False);
291 TCollection_AsciiString Message ("\
293 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(6.,10.,8.,2.); \n\
294 gp_Trsf theTransformation; \n\
295 gp_Vec theVectorOfTranslation(6,6,6); \n\
296 theTransformation.SetTranslation(theVectorOfTranslation); \n\
297 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
298 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
300 PocessTextInDialog("Translate a Shape with One vector.", Message);
304 void CModelingDoc::OnDisplacement()
306 AIS_ListOfInteractive aList;
307 myAISContext->DisplayedObjects(aList);
308 AIS_ListIteratorOfListOfInteractive aListIterator;
309 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
310 myAISContext->Remove(aListIterator.Value());
312 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
313 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
314 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
315 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
316 myAISContext->Display(ais1,Standard_False);
317 gp_Trsf theTransformation;
319 gp_Ax3 ax3_1(gp_Pnt(0,0,0),gp_Dir(0,0,1));
320 gp_Ax3 ax3_2(gp_Pnt(60,60,60),gp_Dir(1,1,1));
322 theTransformation.SetDisplacement(ax3_1,ax3_2);
323 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
324 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();
325 Handle(AIS_Shape) ais2 = new AIS_Shape(TransformedShape);
326 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
327 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
328 myAISContext->Display(ais2,Standard_False);
330 TCollection_AsciiString Message ("\
332 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
333 gp_Trsf theTransformation; \n\
334 gp_Ax3 ax3_1(gp_Pnt(0,0,0),gp_Dir(0,0,1)); \n\
335 gp_Ax3 ax3_2(gp_Pnt(60,60,60),gp_Dir(1,1,1)); \n\
336 theTransformation.SetDisplacement(ax3_1,ax3_2); \n\
337 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
338 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
340 PocessTextInDialog("Displace a Shape with Two coordinate systems.", Message);
346 void CModelingDoc::OnDeform()
348 AIS_ListOfInteractive aList;
349 myAISContext->DisplayedObjects(aList);
350 AIS_ListIteratorOfListOfInteractive aListIterator;
351 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
352 myAISContext->Remove(aListIterator.Value());
354 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
355 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
356 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
357 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
358 myAISContext->Display(ais1,Standard_False);
360 gp_GTrsf theTransformation;
361 gp_Mat rot(1, 0, 0, 0, 0.5, 0, 0, 0, 1.5);
362 theTransformation.SetVectorialPart(rot);
363 theTransformation.SetTranslationPart(gp_XYZ(5,5,5));
365 BRepBuilderAPI_GTransform myBRepTransformation(S,theTransformation);
366 TopoDS_Shape S2 = myBRepTransformation.Shape();
368 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
369 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
370 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
371 myAISContext->Display(ais2,Standard_False);
373 TCollection_AsciiString Message ("\
375 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
376 gp_GTrsf theTransformation; \n\
377 gp_Mat rot(1, 0, 0, 0, 0.5, 0, 0, 0, 1.5); // scaling : 100% on X ; 50% on Y ; 150% on Z . \n\
378 theTransformation.SetVectorialPart(rot); \n\
379 theTransformation.SetTranslationPart(gp_XYZ(5,5,5)); \n\
380 BRepBuilderAPI_GTransform myBRepGTransformation(S,theTransformation);\n\
381 TopoDS_Shape TransformedShape = myBRepGTransformation.Shape(); \n");
383 PocessTextInDialog("Deform a Shape with One matrix of deformation and One translation.", Message);
386 /* =================================================================================
387 ==================== P R I M I T I V E S ====================================
388 ================================================================================= */
390 void CModelingDoc::OnBox()
392 AIS_ListOfInteractive aList;
393 myAISContext->DisplayedObjects(aList);
394 AIS_ListIteratorOfListOfInteractive aListIterator;
395 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
396 myAISContext->Remove(aListIterator.Value());
398 TopoDS_Shape B1 = BRepPrimAPI_MakeBox (200.,150.,100.);
399 Handle(AIS_Shape) aBox1 = new AIS_Shape(B1);
400 myAISContext->SetMaterial(aBox1,Graphic3d_NOM_PLASTIC,Standard_False);
401 myAISContext->SetColor(aBox1,Quantity_NOC_GREEN,Standard_False);
402 myAISContext->Display(aBox1,Standard_False);
403 TopoDS_Shape B2 = BRepPrimAPI_MakeBox (gp_Ax2(gp_Pnt(-200.,-80.,-70.),
406 Handle(AIS_Shape) aBox2 = new AIS_Shape(B2);
407 myAISContext->SetMaterial(aBox2,Graphic3d_NOM_PLASTIC,Standard_False);
408 myAISContext->SetColor(aBox2,Quantity_NOC_RED,Standard_False);
409 myAISContext->Display(aBox2,Standard_False);
411 TCollection_AsciiString Message ("\
413 TopoDS_Shape B1 = BRepPrimAPI_MakeBox (200.,150.,100.); \n\
414 TopoDS_Shape B2 = BRepPrimAPI_MakeBox (gp_Ax2(gp_Pnt(-200.,-80.,-70.), \n\
415 gp_Dir(1.,2.,1.)), \n\
418 PocessTextInDialog("Make a topological box", Message);
421 void CModelingDoc::OnCylinder()
423 AIS_ListOfInteractive aList;
424 myAISContext->DisplayedObjects(aList);
425 AIS_ListIteratorOfListOfInteractive aListIterator;
426 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
427 myAISContext->Remove(aListIterator.Value());
430 TopoDS_Shape C1 = BRepPrimAPI_MakeCylinder (50.,200.);
431 Handle(AIS_Shape) aCyl1 = new AIS_Shape(C1);
432 myAISContext->SetMaterial(aCyl1,Graphic3d_NOM_PLASTIC,Standard_False);
433 myAISContext->SetColor(aCyl1,Quantity_NOC_RED,Standard_False);
434 myAISContext->Display(aCyl1,Standard_False);
435 TopoDS_Shape C2 = BRepPrimAPI_MakeCylinder (gp_Ax2(gp_Pnt(200.,200.,0.),
437 40.,110.,210.*PI180);
438 Handle(AIS_Shape) aCyl2 = new AIS_Shape(C2);
439 myAISContext->SetMaterial(aCyl2,Graphic3d_NOM_PLASTIC,Standard_False);
440 myAISContext->SetColor(aCyl2,Quantity_NOC_MATRABLUE,Standard_False);
441 myAISContext->Display(aCyl2,Standard_False);
444 TCollection_AsciiString Message ("\
446 TopoDS_Shape C1 = BRepPrimAPI_MakeCylinder (50.,200.); \n\
447 TopoDS_Shape C2 = BRepPrimAPI_MakeCylinder (gp_Ax2(gp_Pnt(200.,200.,0.), \n\
448 gp_Dir(0.,0.,1.)), \n\
449 40.,110.,210.*PI180.); \n\
451 PocessTextInDialog("Make a cylinder", Message);
455 void CModelingDoc::OnCone()
457 AIS_ListOfInteractive aList;
458 myAISContext->DisplayedObjects(aList);
459 AIS_ListIteratorOfListOfInteractive aListIterator;
460 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
461 myAISContext->Remove(aListIterator.Value());
463 TopoDS_Shape C1 = BRepPrimAPI_MakeCone (50.,25.,200.);
464 Handle(AIS_Shape) ais1 = new AIS_Shape(C1);
465 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
466 myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
467 myAISContext->Display(ais1,Standard_False);
468 TopoDS_Shape C2 = BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(100.,100.,0.),
470 60.,0.,150.,210.*PI180);
471 Handle(AIS_Shape) ais2 = new AIS_Shape(C2);
472 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
473 myAISContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False);
474 myAISContext->Display(ais2,Standard_False);
477 TCollection_AsciiString Message ("\
479 TopoDS_Shape C1 = BRepPrimAPI_MakeCone (50.,25.,200.); \n\
480 TopoDS_Shape C2 = BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(100.,100.,0.), \n\
481 gp_Dir(0.,0.,1.)), \n\
482 605.,0.,150.,210.*PI180); \n\
484 PocessTextInDialog("Make a cone", Message);
487 void CModelingDoc::OnSphere()
489 AIS_ListOfInteractive aList;
490 myAISContext->DisplayedObjects(aList);
491 AIS_ListIteratorOfListOfInteractive aListIterator;
492 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
493 myAISContext->Remove(aListIterator.Value());
496 TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(gp_Pnt(-200.,-250.,0.),80.);
497 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
498 myAISContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False);
499 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
500 myAISContext->Display(ais1,Standard_False);
501 TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(100.,120.*PI180);
502 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
503 myAISContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False);
504 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
505 myAISContext->Display(ais2,Standard_False);
506 TopoDS_Shape S3 = BRepPrimAPI_MakeSphere(gp_Pnt(200.,250.,0.),100.,
507 -60.*PI180, 60.*PI180);
508 Handle(AIS_Shape) ais3 = new AIS_Shape(S3);
509 myAISContext->SetColor(ais3,Quantity_NOC_RED,Standard_False);
510 myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
511 myAISContext->Display(ais3,Standard_False);
512 TopoDS_Shape S4 = BRepPrimAPI_MakeSphere(gp_Pnt(0.,0.,-300.),150.,
513 -45.*PI180, 45.*PI180, 45.*PI180);
514 Handle(AIS_Shape) ais4 = new AIS_Shape(S4);
515 myAISContext->SetColor(ais4,Quantity_NOC_MATRABLUE,Standard_False);
516 myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
517 myAISContext->Display(ais4,Standard_False);
520 TCollection_AsciiString Message ("\
522 TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(gp_Pnt(-200.,-250.,0.),80.); \n\
523 TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(100.,120.*PI180); \n\
524 TopoDS_Shape S3 = BRepPrimAPI_MakeSphere(gp_Pnt(200.,250.,0.),100., \n\
525 -60.*PI180, 60.*PI180); \n\
526 TopoDS_Shape S4 = BRepPrimAPI_MakeSphere(gp_Pnt(0.,0.,-300.),150., \n\
527 -45.*PI180, 45.*PI180, 45.*PI180); \n\
529 PocessTextInDialog("Make a sphere", Message);
532 void CModelingDoc::OnTorus()
534 AIS_ListOfInteractive aList;
535 myAISContext->DisplayedObjects(aList);
536 AIS_ListIteratorOfListOfInteractive aListIterator;
537 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
538 myAISContext->Remove(aListIterator.Value());
541 TopoDS_Shape S1 = BRepPrimAPI_MakeTorus(60.,20.);
542 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
543 myAISContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False);
544 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
545 myAISContext->Display(ais1,Standard_False);
546 TopoDS_Shape S2 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(1.,1.,1.)),
548 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
549 myAISContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False);
550 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
551 myAISContext->Display(ais2,Standard_False);
552 TopoDS_Shape S3 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(-200.,-150.,-100),gp_Dir(0.,1.,0.)),
553 60.,20.,-45.*PI180,45.*PI180,90.*PI180);
554 Handle(AIS_Shape) ais3= new AIS_Shape(S3);
555 myAISContext->SetColor(ais3,Quantity_NOC_CORAL,Standard_False);
556 myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
557 myAISContext->Display(ais3,Standard_False);
560 TCollection_AsciiString Message ("\
562 TopoDS_Shape S1 = BRepPrimAPI_MakeTorus(60.,20.); \n\
563 TopoDS_Shape S2 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(1.,1.,1.)), \n\
564 50.,20.,210.*PI180); \n\
565 TopoDS_Shape S3 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(-200.,-150.,-100),gp_Dir(0.,1.,0.)), \n\
566 60.,20.,-45.*PI180,45.*PI180,90.*PI180); \n\
568 PocessTextInDialog("Make a torus", Message);
571 void CModelingDoc::OnWedge()
573 AIS_ListOfInteractive aList;
574 myAISContext->DisplayedObjects(aList);
575 AIS_ListIteratorOfListOfInteractive aListIterator;
576 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
577 myAISContext->Remove(aListIterator.Value());
580 TopoDS_Shape S1 = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
581 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
582 myAISContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False);
583 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
584 myAISContext->Display(ais1,Standard_False);
585 TopoDS_Shape S2 = BRepPrimAPI_MakeWedge(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(0.,0.,1.)),
586 60.,50.,80.,25.,-10.,40.,70.);
587 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
588 myAISContext->SetColor(ais2,Quantity_NOC_CORAL2,Standard_False);
589 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
590 myAISContext->Display(ais2,Standard_False);
593 TCollection_AsciiString Message ("\
595 TopoDS_Shape S1 = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
596 TopoDS_Shape S2 = BRepPrimAPI_MakeWedge(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(0.,0.,1.)), \n\
597 60.,50.,80.,25.,-10.,40.,70.); \n\
599 PocessTextInDialog("Make a wedge", Message);
602 void CModelingDoc::OnPrism()
604 AIS_ListOfInteractive aList;
605 myAISContext->DisplayedObjects(aList);
606 AIS_ListIteratorOfListOfInteractive aListIterator;
607 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
608 myAISContext->Remove(aListIterator.Value());
611 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.));
612 Handle(AIS_Shape) ais1 = new AIS_Shape(V1);
613 myAISContext->Display(ais1,Standard_False);
614 TopoDS_Shape S1 = BRepPrimAPI_MakePrism(V1,gp_Vec(0.,0.,100.));
615 Handle(AIS_Shape) ais2 = new AIS_Shape(S1);
616 myAISContext->Display(ais2,Standard_False);
618 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-150.,-150,0.), gp_Pnt(-50.,-50,0.));
619 Handle(AIS_Shape) ais3 = new AIS_Shape(E);
620 myAISContext->Display(ais3,Standard_False);
621 TopoDS_Shape S2 = BRepPrimAPI_MakePrism(E,gp_Vec(0.,0.,100.));
622 Handle(AIS_Shape) ais4 = new AIS_Shape(S2);
623 myAISContext->SetColor(ais4,Quantity_NOC_CORAL2,Standard_False);
624 myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
625 myAISContext->Display(ais4,Standard_False);
627 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.));
628 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.));
629 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.));
630 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3);
631 TopoDS_Shape S3 = BRepPrimAPI_MakePrism(W,gp_Vec(0.,0.,100.));
632 Handle(AIS_Shape) ais5 = new AIS_Shape(W);
633 myAISContext->Display(ais5,Standard_False);
634 Handle(AIS_Shape) ais6 = new AIS_Shape(S3);
635 myAISContext->SetColor(ais6,Quantity_NOC_GREEN,Standard_False);
636 myAISContext->SetMaterial(ais6,Graphic3d_NOM_PLASTIC,Standard_False);
637 myAISContext->Display(ais6,Standard_False);
639 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.);
640 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
641 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);
642 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc);
643 Handle(AIS_Shape) ais7 = new AIS_Shape(F);
644 myAISContext->Display(ais7,Standard_False);
645 TopoDS_Shape S4 = BRepPrimAPI_MakePrism(F,gp_Vec(0.,0.,100.));
646 Handle(AIS_Shape) ais8 = new AIS_Shape(S4);
647 myAISContext->SetColor(ais8,Quantity_NOC_MATRABLUE,Standard_False);
648 myAISContext->SetMaterial(ais8,Graphic3d_NOM_PLASTIC,Standard_False);
649 myAISContext->Display(ais8,Standard_False);
652 TCollection_AsciiString Message ("\
654 --- Prism a vertex -> result is an edge --- \n\
656 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.)); \n\
657 TopoDS_Shape S1 = BRepBuilderAPI_MakePrism(V1,gp_Vec(0.,0.,100.)); \n\
659 --- Prism an edge -> result is a face --- \n\
661 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-150.,-150,0.), gp_Pnt(-50.,-50,0.)); \n\
662 TopoDS_Shape S2 = BRepPrimAPI_MakePrism(E,gp_Vec(0.,0.,100.)); \n\
664 --- Prism an wire -> result is a shell --- \n\
666 TopoDS_Edge E1 = BREpBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)); \n\
667 TopoDS_Edge E2 = BREpBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)); \n\
668 TopoDS_Edge E3 = BREpBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)); \n\
669 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3); \n\
670 TopoDS_Shape S3 = BRepPrimAPI_MakePrism(W,gp_Vec(0.,0.,100.)); \n\
672 --- Prism a face or a shell -> result is a solid --- \n\
674 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.gp_Dir(0.,0.,1.)), 80.); \n\
675 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c); \n\
676 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec); \n\
677 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp::XOY(),Wc); \n\
678 TopoDS_Shape S4 = BRepBuilderAPI_MakePrism(F,gp_Vec(0.,0.,100.)); \n\
680 PocessTextInDialog("Make a prism", Message);
683 void CModelingDoc::OnRevol()
685 AIS_ListOfInteractive aList;
686 myAISContext->DisplayedObjects(aList);
687 AIS_ListIteratorOfListOfInteractive aListIterator;
688 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
689 myAISContext->Remove(aListIterator.Value());
692 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.));
693 Handle(AIS_Shape) ais1 = new AIS_Shape(V1);
694 myAISContext->Display(ais1,Standard_False);
695 gp_Ax1 axe = gp_Ax1(gp_Pnt(-170.,-170.,0.),gp_Dir(0.,0.,1.));
696 Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
697 Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
698 myAISContext->Display(ax1,Standard_False);
699 TopoDS_Shape S1 = BRepPrimAPI_MakeRevol(V1,axe);
700 Handle(AIS_Shape) ais2 = new AIS_Shape(S1);
701 myAISContext->Display(ais2,Standard_False);
703 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-120.,-120,0.), gp_Pnt(-120.,-120,100.));
704 Handle(AIS_Shape) ais3 = new AIS_Shape(E);
705 myAISContext->Display(ais3,Standard_False);
706 axe = gp_Ax1(gp_Pnt(-100.,-100.,0.),gp_Dir(0.,0.,1.));
707 Handle(Geom_Axis1Placement) Gax2 = new Geom_Axis1Placement(axe);
708 Handle (AIS_Axis) ax2 = new AIS_Axis(Gax2);
709 myAISContext->Display(ax2,Standard_False);
710 TopoDS_Shape S2 = BRepPrimAPI_MakeRevol(E,axe);
711 Handle(AIS_Shape) ais4 = new AIS_Shape(S2);
712 myAISContext->SetColor(ais4,Quantity_NOC_YELLOW,Standard_False);
713 myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
714 myAISContext->Display(ais4,Standard_False);
716 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.));
717 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.));
718 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.));
719 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3);
720 axe = gp_Ax1(gp_Pnt(0.,0.,30.),gp_Dir(0.,1.,0.));
721 Handle(Geom_Axis1Placement) Gax3 = new Geom_Axis1Placement(axe);
722 Handle (AIS_Axis) ax3 = new AIS_Axis(Gax3);
723 myAISContext->Display(ax3,Standard_False);
724 TopoDS_Shape S3 = BRepPrimAPI_MakeRevol(W,axe, 210.*PI180);
725 Handle(AIS_Shape) ais5 = new AIS_Shape(W);
726 myAISContext->Display(ais5,Standard_False);
727 Handle(AIS_Shape) ais6 = new AIS_Shape(S3);
728 myAISContext->SetColor(ais6,Quantity_NOC_GREEN,Standard_False);
729 myAISContext->SetMaterial(ais6,Graphic3d_NOM_PLASTIC,Standard_False);
730 myAISContext->Display(ais6,Standard_False);
732 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.);
733 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
734 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);
735 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc);
736 axe = gp_Ax1(gp_Pnt(290,290.,0.),gp_Dir(0.,1,0.));
737 Handle(Geom_Axis1Placement) Gax4 = new Geom_Axis1Placement(axe);
738 Handle (AIS_Axis) ax4 = new AIS_Axis(Gax4);
739 myAISContext->Display(ax4,Standard_False);
740 TopoDS_Shape S4 = BRepPrimAPI_MakeRevol(F,axe, 90.*PI180);
741 Handle(AIS_Shape) ais8 = new AIS_Shape(S4);
742 myAISContext->SetColor(ais8,Quantity_NOC_MATRABLUE,Standard_False);
743 myAISContext->SetMaterial(ais8,Graphic3d_NOM_PLASTIC,Standard_False);
744 myAISContext->Display(ais8,Standard_False);
747 TCollection_AsciiString Message ("\
749 --- Revol of a vertex -> result is an edge --- \n\
751 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.)); \n\
752 gp_Ax1 axe = gp_Ax1(gp_Pnt(-170.,-170.,0.),gp_Dir(0.,0.,1.)); \n\
753 TopoDS_Shape S1 = BRepPrimAPI_MakeRevol(V1,axe); \n\
755 --- Revol of an edge -> result is a face --- \n\
757 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-120.,-120,0.), gp_Pnt(-120.,-120,100.)); \n\
758 axe = gp_Ax1(gp_Pnt(-100.,-100.,0.),gp_Dir(0.,0.,1.)); \n\
759 TopoDS_Shape S2 = BRepPrimAPI_MakeRevol(E,axe); \n\
761 --- Revol of a wire -> result is a shell --- \n\
763 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)); \n\
764 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)); \n\
765 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)); \n\
766 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3); \n\
767 axe = gp_Ax1(gp_Pnt(0.,0.,30.),gp_Dir(0.,1.,0.)); \n\
768 TopoDS_Shape S3 = BRepPrimAPI_MakeRevol(W,axe, 210.*PI180); \n\
770 --- Revol of a face -> result is a solid --- \n\
772 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.); \n\
773 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c); \n\
774 TopoDS_Wire Wc = BRepBuilderPI_MakeWire(Ec); \n\
775 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc); \n\
776 axe = gp_Ax1(gp_Pnt(290,290.,0.),gp_Dir(0.,1,0.)); \n\
777 TopoDS_Shape S4 = BRepPrimAPI_MakeRevol(F,axe, 90.*PI180); \n\
779 PocessTextInDialog("Make a prism", Message);
782 void CModelingDoc::OnPipe()
784 AIS_ListOfInteractive aList;
785 myAISContext->DisplayedObjects(aList);
786 AIS_ListIteratorOfListOfInteractive aListIterator;
787 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
788 myAISContext->Remove(aListIterator.Value());
791 TColgp_Array1OfPnt CurvePoles(1,4);
792 gp_Pnt pt = gp_Pnt(0.,0.,0.);
794 pt = gp_Pnt(20.,50.,0.);
796 pt = gp_Pnt(60.,100.,0.);
798 pt = gp_Pnt(150.,0.,0.);
800 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);
801 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);
802 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);
803 Handle(AIS_Shape) ais1 = new AIS_Shape(W);
804 myAISContext->Display(ais1,Standard_False);
807 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.);
808 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
809 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);
810 Handle(AIS_Shape) ais3 = new AIS_Shape(Wc);
811 myAISContext->Display(ais3,Standard_False);
812 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::ZOX()),Wc);
813 TopoDS_Shape S = BRepOffsetAPI_MakePipe(W,F);
814 Handle(AIS_Shape) ais2 = new AIS_Shape(S);
815 myAISContext->SetColor(ais2,Quantity_NOC_MATRABLUE,Standard_False);
816 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
817 myAISContext->Display(ais2,Standard_False);
820 TCollection_AsciiString Message ("\
822 TColgp_Array1OfPnt CurvePoles(1,6);\n\
823 gp_Pnt pt = gp_Pnt(0.,0.,0.);\n\
824 CurvePoles(1) = pt;\n\
825 pt = gp_Pnt(20.,50.,0.);\n\
826 CurvePoles(2) = pt;\n\
827 pt = gp_Pnt(60.,100.,0.);\n\
828 CurvePoles(3) = pt;\n\
829 pt = gp_Pnt(150.,0.,0.);\n\
830 CurvePoles(4) = pt;\n\
831 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);\n\
832 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);\n\
833 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);\n\
834 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.);\n\
835 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);\n\
836 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);\n\
837 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::ZOX()),Wc);\n\
838 TopoDS_Shape S = BRepBuilderAPI_MakePipe(W,F);\n\
840 PocessTextInDialog("Make a pipe", Message);
844 void CModelingDoc::OnThru()
846 AIS_ListOfInteractive aList;
847 myAISContext->DisplayedObjects(aList);
848 AIS_ListIteratorOfListOfInteractive aListIterator;
849 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
850 myAISContext->Remove(aListIterator.Value());
853 gp_Circ c1 = gp_Circ(gp_Ax2(gp_Pnt(-100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);
854 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(c1);
855 TopoDS_Wire W1 = BRepBuilderAPI_MakeWire(E1);
856 Handle(AIS_Shape) sec1 = new AIS_Shape(W1);
857 myAISContext->Display(sec1,Standard_False);
858 gp_Circ c2 = gp_Circ(gp_Ax2(gp_Pnt(-10.,0.,-0.),gp_Dir(0.,0.,1.)),40.);
859 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(c2);
860 TopoDS_Wire W2 = BRepBuilderAPI_MakeWire(E2);
861 Handle(AIS_Shape) sec2 = new AIS_Shape(W2);
862 myAISContext->Display(sec2,Standard_False);
863 gp_Circ c3 = gp_Circ(gp_Ax2(gp_Pnt(-75.,0.,100.),gp_Dir(0.,0.,1.)),40.);
864 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(c3);
865 TopoDS_Wire W3 = BRepBuilderAPI_MakeWire(E3);
866 Handle(AIS_Shape) sec3 = new AIS_Shape(W3);
867 myAISContext->Display(sec3,Standard_False);
868 gp_Circ c4= gp_Circ(gp_Ax2(gp_Pnt(0.,0.,200.),gp_Dir(0.,0.,1.)),40.);
869 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);
870 TopoDS_Wire W4 = BRepBuilderAPI_MakeWire(E4);
871 Handle(AIS_Shape) sec4 = new AIS_Shape(W4);
872 myAISContext->Display(sec4,Standard_False);
873 BRepOffsetAPI_ThruSections generator(Standard_False,Standard_True);
874 generator.AddWire(W1);
875 generator.AddWire(W2);
876 generator.AddWire(W3);
877 generator.AddWire(W4);
879 TopoDS_Shape S1 = generator.Shape();
880 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
881 myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
882 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
883 myAISContext->Display(ais1,Standard_False);
885 gp_Circ c1b = gp_Circ(gp_Ax2(gp_Pnt(100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);
886 TopoDS_Edge E1b = BRepBuilderAPI_MakeEdge(c1b);
887 TopoDS_Wire W1b = BRepBuilderAPI_MakeWire(E1b);
888 Handle(AIS_Shape) sec1b = new AIS_Shape(W1b);
889 myAISContext->Display(sec1b,Standard_False);
890 gp_Circ c2b = gp_Circ(gp_Ax2(gp_Pnt(210.,0.,-0.),gp_Dir(0.,0.,1.)),40.);
891 TopoDS_Edge E2b = BRepBuilderAPI_MakeEdge(c2b);
892 TopoDS_Wire W2b = BRepBuilderAPI_MakeWire(E2b);
893 Handle(AIS_Shape) sec2b = new AIS_Shape(W2b);
894 myAISContext->Display(sec2b,Standard_False);
895 gp_Circ c3b = gp_Circ(gp_Ax2(gp_Pnt(275.,0.,100.),gp_Dir(0.,0.,1.)),40.);
896 TopoDS_Edge E3b = BRepBuilderAPI_MakeEdge(c3b);
897 TopoDS_Wire W3b = BRepBuilderAPI_MakeWire(E3b);
898 Handle(AIS_Shape) sec3b = new AIS_Shape(W3b);
899 myAISContext->Display(sec3b,Standard_False);
900 gp_Circ c4b= gp_Circ(gp_Ax2(gp_Pnt(200.,0.,200.),gp_Dir(0.,0.,1.)),40.);
901 TopoDS_Edge E4b = BRepBuilderAPI_MakeEdge(c4b);
902 TopoDS_Wire W4b = BRepBuilderAPI_MakeWire(E4b);
903 Handle(AIS_Shape) sec4b = new AIS_Shape(W4b);
904 myAISContext->Display(sec4b,Standard_False);
905 BRepOffsetAPI_ThruSections generatorb(Standard_True,Standard_False);
906 generatorb.AddWire(W1b);
907 generatorb.AddWire(W2b);
908 generatorb.AddWire(W3b);
909 generatorb.AddWire(W4b);
911 TopoDS_Shape S2 = generatorb.Shape();
912 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
913 myAISContext->SetColor(ais2,Quantity_NOC_ALICEBLUE,Standard_False);
914 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
915 myAISContext->Display(ais2,Standard_False);
918 TCollection_AsciiString Message ("\
920 ---------- ruled -------------- \n\
922 gp_Circ c1 = gp_Circ(gp_Ax2(gp_Pnt(-100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);\n\
923 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(c1);\n\
924 TopoDS_Wire W1 = BRepBuilderAPI_MakeWire(E1);\n\
925 gp_Circ c2 = gp_Circ(gp_Ax2(gp_Pnt(-10.,0.,-0.),gp_Dir(0.,0.,1.)),40.);\n\
926 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(c2);\n\
927 TopoDS_Wire W2 = BRepBuilderAPI_MakeWire(E2);\n\
928 gp_Circ c3 = gp_Circ(gp_Ax2(gp_Pnt(-75.,0.,100.),gp_Dir(0.,0.,1.)),40.);\n\
929 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(c3);\n\
930 TopoDS_Wire W3 = BRepBuilderAPI_MakeWire(E3);\n\
931 gp_Circ c4= gp_Circ(gp_Ax2(gp_Pnt(0.,0.,200.),gp_Dir(0.,0.,1.)),40.);\n\
932 TopoDS_Edge E4 = BRep>BuilderAPI_MakeEdge(c4);\n\
933 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);\n\
934 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);\n\
935 TopoDS_Wire W4 = BRepBuilderAPI_MakeWire(E4);\n\
936 BRepOffsetAPI_ThruSections generator(Standard_False,Standard_True);\n\
937 generator.AddWire(W1);\n\
938 generator.AddWire(W2);\n\
939 generator.AddWire(W3);\n\
940 generator.AddWire(W4);\n\
941 generator.Build();\n\
942 TopoDS_Shape S1 = generator.Shape();\n\
944 ---------- smooth -------------- \n\
946 gp_Circ c1b = gp_Circ(gp_Ax2(gp_Pnt(100.,0.,-100.),gp_Dir(0.,0.,1.)),40.); \n\
947 TopoDS_Edge E1b = BRepBuilderAPI_MakeEdge(c1b); \n\
948 TopoDS_Wire W1b = BRepBuilderAPI_MakeWire(E1b); \n\
949 gp_Circ c2b = gp_Circ(gp_Ax2(gp_Pnt(210.,0.,-0.),gp_Dir(0.,0.,1.)),40.); \n\
950 TopoDS_Edge E2b = BRepBuilderAPI_MakeEdge(c2b);\n\
951 TopoDS_Wire W2b = BRepBuilderAPI_MakeWire(E2b); \n\
952 gp_Circ c3b = gp_Circ(gp_Ax2(gp_Pnt(275.,0.,100.),gp_Dir(0.,0.,1.)),40.);\n\
953 TopoDS_Edge E3b = BRepBuilderAPI_MakeEdge(c3b);\n\
954 TopoDS_Wire W3b = BRepBuilderAPI_MakeWire(E3b);\n\
955 gp_Circ c4b= gp_Circ(gp_Ax2(gp_Pnt(200.,0.,200.),gp_Dir(0.,0.,1.)),40.);\n\
956 TopoDS_Edge E4b = BRepBuilderAPI_MakeEdge(c4b);\n\
957 TopoDS_Wire W4b = BRepBuilderAPI_MakeWire(E4b);\n\
958 BRepOffsetAPI_ThruSections generatorb(Standard_True,Standard_False);\n\
959 generatorb.AddWire(W1b);\n\
960 generatorb.AddWire(W2b);\n\
961 generatorb.AddWire(W3b);\n\
962 generatorb.AddWire(W4b);\n\
963 generatorb.Build();\n\
964 TopoDS_Shape S2 = generatorb.Shape();\n\
966 PocessTextInDialog("Make a Thru sections", Message);
970 void CModelingDoc::OnEvolved()
972 AIS_ListOfInteractive aList;
973 myAISContext->DisplayedObjects(aList);
974 AIS_ListIteratorOfListOfInteractive aListIterator;
975 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
976 myAISContext->Remove(aListIterator.Value());
979 BRepBuilderAPI_MakePolygon P;
980 P.Add(gp_Pnt(0.,0.,0.));
981 P.Add(gp_Pnt(200.,0.,0.));
982 P.Add(gp_Pnt(200.,200.,0.));
983 P.Add(gp_Pnt(0.,200.,0.));
984 P.Add(gp_Pnt(0.,0.,0.));
985 TopoDS_Wire W = P.Wire();
987 Handle(AIS_Shape) ais1 = new AIS_Shape(W);
988 myAISContext->Display(ais1,Standard_False);
990 TopoDS_Wire wprof = BRepBuilderAPI_MakePolygon(gp_Pnt(0.,0.,0.),gp_Pnt(-60.,-60.,-200.));
992 Handle(AIS_Shape) ais3 = new AIS_Shape(wprof);
993 myAISContext->Display(ais3,Standard_False);
996 TopoDS_Shape S = BRepOffsetAPI_MakeEvolved(W,wprof,GeomAbs_Arc,Standard_True,Standard_False,Standard_True,0.0001);
998 Handle(AIS_Shape) ais2 = new AIS_Shape(S);
999 myAISContext->SetColor(ais2,Quantity_NOC_MATRABLUE,Standard_False);
1000 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1001 myAISContext->Display(ais2,Standard_False);
1004 TCollection_AsciiString Message ("\
1006 ---------- Evolved shape -------------- \n\
1008 BRepBuilderAPI_MakePolygon P;\n\
1009 P.Add(gp_Pnt(0.,0.,0.));\n\
1010 P.Add(gp_Pnt(200.,0.,0.));\n\
1011 P.Add(gp_Pnt(200.,200.,0.));\n\
1012 P.Add(gp_Pnt(0.,200.,0.));\n\
1013 P.Add(gp_Pnt(0.,0.,0.));\n\
1014 TopoDS_Wire W = P.Wire();\n\
1015 TopoDS_Wire wprof = BRepBuilderAPI_MakePolygon(gp_Pnt(0.,0.,0.),gp_Pnt(-60.,-60.,-200.));\n\
1016 TopoDS_Shape S = BRepBuilderAPI_MakeEvolved(W,wprof,GeomAbs_Arc,Standard_True,Standard_False,Standard_True,0.0001);\n\
1018 PocessTextInDialog("Make an evolved shape", Message);
1022 void CModelingDoc::OnDraft()
1024 AIS_ListOfInteractive aList;
1025 myAISContext->DisplayedObjects(aList);
1026 AIS_ListIteratorOfListOfInteractive aListIterator;
1027 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1028 myAISContext->Remove(aListIterator.Value());
1031 TopoDS_Shape S = BRepPrimAPI_MakeBox(200.,300.,150.);
1032 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
1033 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1034 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1035 myAISContext->Display(ais1,Standard_False);
1038 BRepOffsetAPI_DraftAngle adraft(S);
1040 for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {
1041 TopoDS_Face F = TopoDS::Face(Ex.Current());
1042 Handle(Geom_Plane) surf = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F));
1043 gp_Pln apln = surf->Pln();
1044 gp_Dir dirF = apln.Axis().Direction();
1045 if (dirF.IsNormal(gp_Dir(0.,0.,1.),Precision::Angular()))
1046 adraft.Add(F, gp_Dir(0.,0.,1.), 15.*PI180, gp_Pln(gp::XOY()));
1048 ais1->Set(adraft.Shape());
1049 myAISContext->Redisplay(ais1,Standard_False);
1052 TCollection_AsciiString Message ("\
1054 ---------- Tapered shape -------------- \n\
1056 TopoDS_Shape S = BRepPrimAPI_MakeBox(200.,300.,150.);\n\
1057 BRepOffsetAPI_DraftAngle adraft(S);\n\
1058 TopExp_Explorer Ex;\n\
1059 for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {\n\
1060 TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
1061 Handle(Geom_Plane) surf = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F));\n\
1062 gp_Pln apln = surf->Pln();\n\
1063 gp_Dir dirF = apln.Axis().Direction();\n\
1064 if (dirF.IsNormal(gp_Dir(0.,0.,1.),Precision::Angular()))\n\
1065 adraft.Add(F, gp_Dir(0.,0.,1.), 15.*PI180, gp_Pln(gp::XOY()));\n\
1068 PocessTextInDialog("Make a tapered shape", Message);
1072 /* =================================================================================
1073 ==================== O P E R A T I O N S ====================================
1074 ================================================================================= */
1076 void CModelingDoc::OnCut()
1078 AIS_ListOfInteractive aList;
1079 myAISContext->DisplayedObjects(aList);
1080 AIS_ListIteratorOfListOfInteractive aListIterator;
1081 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1082 myAISContext->Remove(aListIterator.Value());
1085 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,60,60);
1087 Handle (AIS_Shape) ais1 = new AIS_Shape(theBox);
1088 myAISContext->SetDisplayMode(ais1,1,Standard_False);
1089 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1090 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1091 myAISContext->Display(ais1,Standard_False);
1092 myAISContext->SetCurrentObject(ais1,Standard_False);
1097 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80);
1098 Handle (AIS_Shape) ais2 = new AIS_Shape(theSphere);
1099 myAISContext->SetDisplayMode(ais2,1,Standard_False);
1100 myAISContext->SetColor(ais2,Quantity_NOC_YELLOW,Standard_False);
1101 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1102 myAISContext->Display(ais2,Standard_False);
1103 myAISContext->SetCurrentObject(ais2,Standard_False);
1107 TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox);
1109 myAISContext->Erase(ais1,Standard_False,Standard_False);
1110 myAISContext->Erase(ais2,Standard_False,Standard_False);
1112 Handle (AIS_Shape) aSection = new AIS_Shape(ShapeCut);
1113 myAISContext->SetDisplayMode(aSection,1,Standard_False);
1114 myAISContext->SetColor(aSection,Quantity_NOC_RED,Standard_False);
1115 myAISContext->SetMaterial(aSection,Graphic3d_NOM_PLASTIC,Standard_False);
1116 myAISContext->Display(aSection,Standard_False);
1117 myAISContext->SetCurrentObject(aSection,Standard_False);
1120 TCollection_AsciiString Message ("\
1122 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,40,40); \n\
1124 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80); \n\
1126 TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox); \n\
1128 PocessTextInDialog("Cut the sphere with a box", Message);
1142 void CModelingDoc::OnFuse()
1144 AIS_ListOfInteractive aList;
1145 myAISContext->DisplayedObjects(aList);
1146 AIS_ListIteratorOfListOfInteractive aListIterator;
1147 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1148 myAISContext->Remove(aListIterator.Value());
1152 TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(60,200,70);
1153 Handle (AIS_Shape) ais1 = new AIS_Shape(theBox1);
1154 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1155 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1156 myAISContext->Display(ais1,Standard_False);
1157 myAISContext->SetCurrentObject(ais1,Standard_False);
1161 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P,20,150,110);
1162 Handle (AIS_Shape) ais2 = new AIS_Shape(theBox2);
1163 myAISContext->SetColor(ais2,Quantity_NOC_YELLOW,Standard_False);
1164 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1165 myAISContext->Display(ais2,Standard_False);
1166 myAISContext->SetCurrentObject(ais2,Standard_False);
1170 TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1,theBox2);
1172 myAISContext->Erase(ais1,Standard_True,Standard_False);
1173 myAISContext->Erase(ais2,Standard_True,Standard_False);
1175 Handle (AIS_Shape) aFusion = new AIS_Shape(FusedShape);
1176 myAISContext->SetDisplayMode(aFusion,1,Standard_False);
1177 myAISContext->SetColor(aFusion,Quantity_NOC_RED,Standard_False);
1178 myAISContext->SetMaterial(aFusion,Graphic3d_NOM_PLASTIC,Standard_False);
1179 myAISContext->Display(aFusion,Standard_False);
1180 myAISContext->SetCurrentObject(aFusion,Standard_False);
1183 TCollection_AsciiString Message ("\
1185 TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(50,200,70); \n\
1187 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(-30,150,70); \n\
1189 TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1,theBox2); \n");
1190 PocessTextInDialog("Fuse the boxes", Message);
1194 void CModelingDoc::OnCommon()
1196 AIS_ListOfInteractive aList;
1197 myAISContext->DisplayedObjects(aList);
1198 AIS_ListIteratorOfListOfInteractive aListIterator;
1199 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1200 myAISContext->Remove(aListIterator.Value());
1203 gp_Ax2 axe(gp_Pnt(10,10,10),gp_Dir(1,2,1));
1204 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(axe,60,80,100);
1206 Handle(AIS_Shape) aboxshape=new AIS_Shape(theBox);
1207 myAISContext->SetColor(aboxshape,Quantity_NOC_YELLOW,Standard_False);
1208 myAISContext->SetMaterial(aboxshape,Graphic3d_NOM_PLASTIC,Standard_False);
1209 myAISContext->SetDisplayMode(aboxshape,1,Standard_False);
1210 myAISContext->SetTransparency(aboxshape,0.2,Standard_False);
1211 myAISContext->Display(aboxshape,Standard_False);
1212 myAISContext->SetCurrentObject(aboxshape,Standard_False);
1216 TopoDS_Shape theWedge = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
1218 Handle(AIS_Shape) awedge = new AIS_Shape(theWedge);
1219 myAISContext->SetColor(awedge,Quantity_NOC_RED,Standard_False);
1220 myAISContext->SetMaterial(awedge,Graphic3d_NOM_PLASTIC,Standard_False);
1221 myAISContext->SetTransparency(awedge,0.0,Standard_False);
1222 myAISContext->Display(awedge,Standard_False);
1223 myAISContext->SetCurrentObject(awedge,Standard_False);
1227 TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(theBox,theWedge);
1229 myAISContext->Erase(aboxshape,Standard_True,Standard_False);
1230 myAISContext->Erase(awedge,Standard_True,Standard_False);
1232 Handle(AIS_Shape) acommon = new AIS_Shape(theCommonSurface);
1233 myAISContext->SetColor(acommon,Quantity_NOC_GREEN,Standard_False);
1234 myAISContext->SetMaterial(acommon,Graphic3d_NOM_PLASTIC,Standard_False);
1235 myAISContext->Display(acommon,Standard_False);
1236 myAISContext->SetCurrentObject(acommon);
1238 TCollection_AsciiString Message ("\
1240 gp_Ax2 axe(gp_Pnt(10,10,10),gp_Dir(1,2,1)); \n\
1242 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(axe,60,80,100); \n\
1244 TopoDS_Shape theWedge = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
1246 TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(theBox,theWedge); \n\
1249 PocessTextInDialog("Compute the common surface ", Message);
1253 void CModelingDoc::OnSection()
1256 AIS_ListOfInteractive aList;
1257 myAISContext->DisplayedObjects(aList);
1258 AIS_ListIteratorOfListOfInteractive aListIterator;
1259 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1260 myAISContext->Remove(aListIterator.Value());
1263 TopoDS_Shape atorus = BRepPrimAPI_MakeTorus(120,20);
1265 Handle(AIS_Shape) ashape=new AIS_Shape(atorus);
1266 myAISContext->SetColor(ashape,Quantity_NOC_RED,Standard_False);
1267 myAISContext->SetMaterial(ashape,Graphic3d_NOM_PLASTIC,Standard_False);
1268 myAISContext->SetDisplayMode(ashape,1,Standard_False);
1269 myAISContext->SetTransparency(ashape,0.1,Standard_False);
1270 myAISContext->Display(ashape,Standard_False);
1273 Standard_Real radius = 120;
1274 Standard_Integer i=-3;
1277 TopoDS_Shape asphere = BRepPrimAPI_MakeSphere(gp_Pnt(26*3*i,0,0),radius);
1279 Handle (AIS_Shape) theShape=new AIS_Shape (asphere);
1280 myAISContext->SetTransparency(theShape,0.1,Standard_False);
1281 myAISContext->SetColor(theShape,Quantity_NOC_WHITE,Standard_False);
1282 myAISContext->SetDisplayMode(theShape,1,Standard_False);
1283 myAISContext->Display(theShape,Standard_False);
1286 Standard_Boolean PerformNow=Standard_False;
1288 BRepAlgoAPI_Section section(atorus,asphere,PerformNow);
1289 section.ComputePCurveOn1(Standard_True);
1290 section.Approximation(TopOpeBRepTool_APPROX);
1293 Handle(AIS_Shape) asection=new AIS_Shape(section.Shape());
1294 myAISContext->SetDisplayMode(asection,0);
1295 myAISContext->SetColor(asection,Quantity_NOC_WHITE);
1296 myAISContext->Display(asection);
1298 myAISContext->Remove(theShape);
1301 TCollection_AsciiString Message ("\
1303 TopoDS_Shape atorus = BRepPrimAPI_MakeTorus(120,20); \n\
1304 gp_Vec V1(1,1,1); \n\
1305 Standard_Real radius = 120; \n\
1306 Standard_Integer i=-3; \n\
1307 for(i;i<=3;i++) { \n\
1308 TopoDS_Shape asphere = BRepPrimAPI_MakeSphere(gp_Pnt(78*i,0,0),radius); \n\
1309 Standard_Boolean PerformNow=Standard_False; \n\
1310 BRepAlgoAPI_Section section(atorus,asphere,PerformNow); \n\
1311 section.ComputePCurveOn1(Standard_True); \n\
1312 section.Approximation(TopOpeBRepTool_APPROX); \n\
1313 section.Build(); \n\
1316 PocessTextInDialog("Compute the sections ", Message);
1320 void CModelingDoc::OnPsection()
1322 AIS_ListOfInteractive aList;
1323 myAISContext->DisplayedObjects(aList);
1324 AIS_ListIteratorOfListOfInteractive aListIterator;
1325 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1326 myAISContext->Remove(aListIterator.Value());
1329 TopoDS_Shape theTorus = BRepPrimAPI_MakeTorus(35,8);
1330 Handle(AIS_Shape) atorus = new AIS_Shape(theTorus);
1331 myAISContext->SetColor(atorus,Quantity_NOC_YELLOW,Standard_False);
1332 myAISContext->SetMaterial(atorus,Graphic3d_NOM_PLASTIC,Standard_False);
1333 myAISContext->SetTransparency(atorus,0.1,Standard_False);
1334 myAISContext->Display(atorus,Standard_False);
1335 myAISContext->SetCurrentObject(atorus,Standard_False);
1339 gp_Pln aplane(1,0.25,3,4);
1340 Handle (Geom_Plane) thePlane = new Geom_Plane(aplane);
1341 Handle (AIS_Plane) ais1 = new AIS_Plane(thePlane);
1342 myAISContext->Display(ais1,Standard_False);
1343 myAISContext->SetCurrentObject(ais1,Standard_False);
1347 BRepAlgoAPI_Section section(theTorus,thePlane,Standard_False);
1348 section.ComputePCurveOn1(Standard_True);
1349 section.Approximation(TopOpeBRepTool_APPROX);
1352 Handle(AIS_Shape) asection=new AIS_Shape(section.Shape());
1353 myAISContext->SetDisplayMode(asection ,0,Standard_False);
1354 myAISContext->SetColor(asection,Quantity_NOC_WHITE,Standard_False);
1355 myAISContext->Display(asection,Standard_False);
1358 TCollection_AsciiString Message ("\
1360 TopoDS_Shape theTorus = BRepPrimAPI_MakeTorus(60.,20.); \n\
1362 gp_Pln P(1,2,1,-15); \n\
1364 TopoDS_Shape Psection = BRepAlgoAPI_Section(theTorus,P); \n\
1367 PocessTextInDialog("Compute the plane section ", Message);
1371 void CModelingDoc::OnBlend()
1373 AIS_ListOfInteractive aList;
1374 myAISContext->DisplayedObjects(aList);
1375 AIS_ListIteratorOfListOfInteractive aListIterator;
1376 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1377 myAISContext->Remove(aListIterator.Value());
1380 TopoDS_Shape Box = BRepPrimAPI_MakeBox(gp_Pnt(-400,0,0),200,230,180);
1381 Handle(AIS_Shape) ais1 = new AIS_Shape(Box);
1382 myAISContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False);
1383 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1384 myAISContext->Display(ais1,Standard_False);
1385 myAISContext->SetCurrentObject(ais1,Standard_False);
1389 BRepFilletAPI_MakeFillet fillet(Box);
1391 for (TopExp_Explorer ex(Box,TopAbs_EDGE); ex.More(); ex.Next()) {
1392 TopoDS_Edge Edge =TopoDS::Edge(ex.Current());
1393 fillet.Add(20,Edge);
1396 myAISContext->Remove(ais1,Standard_False);
1398 TopoDS_Shape blendedBox = fillet.Shape();
1399 Handle(AIS_Shape) aBlendbox = new AIS_Shape(blendedBox);
1400 myAISContext->SetColor(aBlendbox,Quantity_NOC_YELLOW,Standard_False);
1401 myAISContext->SetMaterial(aBlendbox,Graphic3d_NOM_PLASTIC,Standard_False);
1402 myAISContext->Display(aBlendbox,Standard_False);
1403 myAISContext->SetCurrentObject(aBlendbox,Standard_False);
1408 gp_Pnt P1(250,150,75);
1409 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(300,200,200);
1410 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(P1,120,180,70);
1412 TopoDS_Shape fusedShape = BRepAlgoAPI_Fuse(S1,S2);
1413 Handle(AIS_Shape) ais2 = new AIS_Shape(fusedShape);
1414 myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False);
1415 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1416 myAISContext->Display(ais2,Standard_False);
1417 myAISContext->SetCurrentObject(ais2,Standard_False);
1420 BRepFilletAPI_MakeFillet fill(fusedShape);
1422 for (TopExp_Explorer ex1(fusedShape,TopAbs_EDGE); ex1.More(); ex1.Next()) {
1423 TopoDS_Edge E =TopoDS::Edge(ex1.Current());
1427 for (Standard_Integer i = 1;i<=fill.NbContours();i++) {
1428 Standard_Real longueur(fill.Length(i));
1429 Standard_Real Rad(0.15*longueur);
1430 fill.SetRadius(Rad,i, 1);
1433 TopoDS_Shape blendedFusedSolids = fill.Shape();
1435 Handle(AIS_Shape) aBlend = new AIS_Shape(blendedFusedSolids);
1436 myAISContext->SetColor(aBlend,Quantity_NOC_RED,Standard_False);
1437 myAISContext->SetMaterial(aBlend,Graphic3d_NOM_PLASTIC,Standard_False);
1438 myAISContext->Display(aBlend,Standard_False);
1440 myAISContext->Remove(ais2,Standard_False);
1444 TCollection_AsciiString Message ("\
1447 TopoDS_Shape Box = BRepPrimAPI_MakeBox(gp_Pnt(-400,0,0),200,230,180);\n\
1449 BRepPrimAPI_MakeFillet fillet(Box);\n\
1451 for (TopExp_Explorer ex(Box,TopAbs_EDGE); ex.More(); ex.Next()) {\n\
1452 TopoDS_Edge Edge =TopoDS::Edge(ex.Current());\n\
1453 fillet.Add(20,Edge);\n\
1455 TopoDS_Shape blendedBox = fillet.Shape();\n\
1457 ////////////////////////////////////////////////////////////////////////\n\
1461 //Warning : On the acute angles of the boxes a fillet is created. \n\
1462 On the angles of fusion a blend is created. \n\
1464 gp_Pnt P1(150,150,75);\n\
1465 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(300,200,200);\n\
1466 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(P1,100,200,70);\n\
1468 TopoDS_Shape fusedShape = BRepAlgoAPI_Fuse(S1,S2);\n\
1469 BRepPrimAPI_MakeFillet fill(fusedShape);\n\
1471 for (TopExp_Explorer ex1(fusedShape,TopAbs_EDGE); ex1.More(); ex1.Next()) {\n\
1472 TopoDS_Edge E =TopoDS::Edge(ex1.Current());\n\
1476 for (Standard_Integer i = 1;i<=fill.NbContours();i++) {\n\
1477 Standard_Real longueur(fill.Length(i));\n\
1478 Standard_Real Rad(0.2*longueur);\n\
1479 fill.SetRadius(Rad,i);\n\
1482 TopoDS_Shape blendedFusedSolids = fill.Shape(); \n");
1484 PocessTextInDialog("Compute the blend on the edges ", Message);
1487 void CModelingDoc::OnEvolvedblend()
1490 AIS_ListOfInteractive aList;
1491 myAISContext->DisplayedObjects(aList);
1492 AIS_ListIteratorOfListOfInteractive aListIterator;
1493 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1494 myAISContext->Remove(aListIterator.Value());
1497 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,200,200);
1498 Handle(AIS_Shape) ais1 = new AIS_Shape(theBox);
1499 myAISContext->SetColor(ais1,Quantity_NOC_BROWN,Standard_False);
1500 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1501 myAISContext->Display(ais1,Standard_False);
1502 myAISContext->SetCurrentObject(ais1,Standard_False);
1506 BRepFilletAPI_MakeFillet Rake(theBox);
1508 TopExp_Explorer ex(theBox,TopAbs_EDGE);
1513 Rake.Add(8,50,TopoDS::Edge(ex.Current()));
1515 if (Rake.IsDone() ){
1516 TopoDS_Shape evolvedBox = Rake.Shape();
1517 ais1->Set(evolvedBox);
1518 myAISContext->Redisplay(ais1,Standard_False);
1519 myAISContext->SetCurrentObject(ais1,Standard_False);
1525 TopoDS_Shape theCylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(0,0,1)),100,200);
1526 Handle(AIS_Shape) ais3 = new AIS_Shape(theCylinder);
1527 myAISContext->SetColor(ais3,Quantity_NOC_GREEN,Standard_False);
1528 myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
1529 myAISContext->Display(ais3,Standard_False);
1530 myAISContext->SetCurrentObject(ais3,Standard_False);
1534 BRepFilletAPI_MakeFillet fillet(theCylinder);
1536 TColgp_Array1OfPnt2d TabPoint2(1,20);
1538 for (Standard_Integer i=0; i<=19; i++) {
1539 gp_Pnt2d Point2d(i*2*PI/19,60*cos(i*PI/19-PI/2)+10);
1540 TabPoint2.SetValue(i+1,Point2d);
1543 TopExp_Explorer exp2(theCylinder,TopAbs_EDGE);
1544 fillet.Add(TabPoint2,TopoDS::Edge(exp2.Current()));
1546 if (fillet.IsDone() ){
1547 TopoDS_Shape LawEvolvedCylinder = fillet.Shape();
1548 ais3->Set(LawEvolvedCylinder);
1549 myAISContext->Redisplay(ais3,Standard_False);
1550 myAISContext->SetCurrentObject(ais3,Standard_False);
1556 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P,200,200,200);
1557 Handle(AIS_Shape) ais2 = new AIS_Shape(theBox2);
1558 myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False);
1559 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1560 myAISContext->Display(ais2,Standard_False);
1561 myAISContext->SetCurrentObject(ais2,Standard_False);
1566 BRepFilletAPI_MakeFillet afillet(theBox2);
1568 TColgp_Array1OfPnt2d TabPoint(1,6);
1571 gp_Pnt2d P2(0.2,16.);
1572 gp_Pnt2d P3(0.4,25.);
1573 gp_Pnt2d P4(0.6,55.);
1574 gp_Pnt2d P5(0.8,28.);
1575 gp_Pnt2d P6(1.,20.);
1576 TabPoint.SetValue(1,P1);
1577 TabPoint.SetValue(2,P2);
1578 TabPoint.SetValue(3,P3);
1579 TabPoint.SetValue(4,P4);
1580 TabPoint.SetValue(5,P5);
1581 TabPoint.SetValue(6,P6);
1583 TopExp_Explorer exp(theBox2,TopAbs_EDGE);
1589 afillet.Add(TabPoint, TopoDS::Edge(exp.Current()));
1592 if (afillet.IsDone() ){
1593 TopoDS_Shape LawevolvedBox = afillet.Shape();
1594 ais2->Set(LawevolvedBox);
1595 myAISContext->Redisplay(ais2,Standard_False);
1596 myAISContext->SetCurrentObject(ais2,Standard_False);
1601 TCollection_AsciiString Message ("\
1605 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,200,200); \n\
1607 BRepPrimAPI_MakeFillet Rake(theBox); \n\
1608 ChFi3d_FilletShape FSh = ChFi3d_Rational; \n\
1609 Rake.SetFilletShape(FSh); \n\
1611 TopExp_Explorer ex(theBox,TopAbs_EDGE); \n\
1612 ex.Next(); //in order to recover the front edge \n\
1616 Rake.Add(8,50,TopoDS::Edge(ex.Current())); \n\
1619 if (Rake.IsDone() ) \n\
1620 TopoDS_Shape theBrownBox = Rake.Shape(); \n\
1622 ////////////////////////////////////////////////////////// \n\
1624 //THE GREEN CYLINDER \n\
1626 TopoDS_Shape theCylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(0,0,1)),100,200); \n\
1628 BRepPrimAPI_MakeFillet fillet(theCylinder); \n\
1630 TColgp_Array1OfPnt2d TabPoint2(1,20); \n\
1632 for (Standard_Integer i=0; i<=19; i++) { \n\
1633 gp_Pnt2d Point2d(i*2*PI/19,60*cos(i*PI/19-PI/2)+10); \n\
1634 TabPoint2.SetValue(i+1,Point2d); \n\
1637 TopExp_Explorer exp2(theCylinder,TopAbs_EDGE); \n\
1638 fillet.Add(TabPoint2,TopoDS::Edge(exp2.Current())); \n\
1641 if (fillet.IsDone() ) \n\
1642 TopoDS_Shape LawEvolvedCylinder = fillet.Shape(); \n\
1644 //////////////////////////////////////////////////////////// \n\
1648 gp_Pnt P(350,0,0); \n\
1649 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P,200,200,200); \n\
1651 BRepPrimAPI_MakeFillet fill(theBox2); \n\
1653 TColgp_Array1OfPnt2d TabPoint(1,6); \n\
1654 gp_Pnt2d P1(0,8); \n\
1655 gp_Pnt2d P2(0.2,16); \n\
1656 gp_Pnt2d P3(0.4,25); \n\
1657 gp_Pnt2d P4(0.6,55); \n\
1658 gp_Pnt2d P5(0.8,28); \n\
1659 gp_Pnt2d P6(1,20); \n\
1660 TabPoint.SetValue(1,P1); \n\
1661 TabPoint.SetValue(2,P2); \n\
1662 TabPoint.SetValue(3,P3); \n\
1663 TabPoint.SetValue(4,P4); \n\
1664 TabPoint.SetValue(5,P5); \n\
1665 TabPoint.SetValue(6,P6); \n\
1667 TopExp_Explorer exp(theBox2,TopAbs_EDGE); \n\
1668 exp.Next(); //in order to trcover the front edge \n\
1672 fill.Add(TabPoint,TopoDS::Edge(exp.Current())); \n\
1675 if (fillet.IsDone() ) \n\
1676 TopoDS_Shape theRedBox = fill.Shape(); \n\
1679 PocessTextInDialog("Compute evolutiv blend on an edge ", Message);
1683 void CModelingDoc::OnChamf()
1685 AIS_ListOfInteractive aList;
1686 myAISContext->DisplayedObjects(aList);
1687 AIS_ListIteratorOfListOfInteractive aListIterator;
1688 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1689 myAISContext->Remove(aListIterator.Value());
1692 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(60,200,70);
1693 Handle(AIS_Shape) ais1 = new AIS_Shape(theBox);
1694 myAISContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False);
1695 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1696 myAISContext->Display(ais1,Standard_False);
1697 myAISContext->SetCurrentObject(ais1,Standard_False);
1701 BRepFilletAPI_MakeChamfer MC(theBox);
1702 // add all the edges to chamfer
1703 TopTools_IndexedDataMapOfShapeListOfShape M;
1704 TopExp::MapShapesAndAncestors(theBox,TopAbs_EDGE,TopAbs_FACE,M);
1705 for (Standard_Integer i = 1;i<=M.Extent();i++) {
1706 TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
1707 TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
1711 TopoDS_Shape ChanfrenedBox = MC.Shape();
1712 Handle(AIS_Shape) aBlendedBox = new AIS_Shape(ChanfrenedBox);
1713 myAISContext->SetColor(aBlendedBox,Quantity_NOC_YELLOW,Standard_False);
1714 myAISContext->SetMaterial(aBlendedBox,Graphic3d_NOM_PLASTIC,Standard_False);
1715 myAISContext->Display(aBlendedBox,Standard_False);
1716 myAISContext->SetCurrentObject(aBlendedBox,Standard_False);
1720 myAISContext->Erase(ais1,Standard_True,Standard_False);
1722 TCollection_AsciiString Message ("\
1724 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(130,200,170); \n\
1725 BRepFilletAPI_MakeChamfer MC(theBox); \n\
1726 TopTools_IndexedDataMapOfShapeListOfShape M; \n\
1727 TopExp::MapShapesAndAncestors(theBox,TopAbs_EDGE,TopAbs_FACE,M); \n\
1728 for (Standar1d_Integer i;i<M.Extent();i++) { \n\
1729 TopoDS_Edge E = TopoDS::Edge(M.FindKey(i)); \n\
1730 TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First()); \n\
1731 MC.Add(15,15,E,F); \n\
1733 TopoDS_Shape ChanfrenedBox = MC.Shape(); \n");
1735 PocessTextInDialog("Compute the chamfers on all the edges ", Message);
1738 /* =================================================================================
1739 ==================== L O C A L O P E R A T I O N S ========================
1740 ================================================================================= */
1742 void CModelingDoc::OnPrismLocal()
1744 AIS_ListOfInteractive aList;
1745 myAISContext->DisplayedObjects(aList);
1746 AIS_ListIteratorOfListOfInteractive aListIterator;
1747 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1748 myAISContext->Remove(aListIterator.Value());
1750 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);
1751 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
1753 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1754 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1755 myAISContext->Display(ais1,Standard_False);
1756 myAISContext->SetCurrentObject(ais1,Standard_False);
1761 Ex.Init(S,TopAbs_FACE);
1763 TopoDS_Face F = TopoDS::Face(Ex.Current());
1764 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
1765 Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);
1766 gp_Dir D = Pl->Pln().Axis().Direction();
1767 // new in 2.0 ..use the trigonometric orientation to make the extrusion.
1770 Handle(Geom2d_Curve) aline;
1771 BRepBuilderAPI_MakeWire MW;
1772 p1 = gp_Pnt2d(200.,-100.);
1773 p2 = gp_Pnt2d(100.,-100.);
1774 aline = GCE2d_MakeLine(p1,p2).Value();
1775 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1777 p2 = gp_Pnt2d(100.,-200.);
1778 aline = GCE2d_MakeLine(p1,p2).Value();
1779 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1781 p2 = gp_Pnt2d(200.,-200.);
1782 aline = GCE2d_MakeLine(p1,p2).Value();
1783 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1785 p2 = gp_Pnt2d(200.,-100.);
1786 aline = GCE2d_MakeLine(p1,p2).Value();
1787 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1788 BRepBuilderAPI_MakeFace MKF;
1789 MKF.Init(surf,Standard_False);
1791 TopoDS_Shape FP = MKF.Face();
1792 BRepLib::BuildCurves3d(FP);
1793 BRepFeat_MakePrism MKP(S,FP,F,D,0,Standard_True);
1795 TopoDS_Shape res1 = MKP.Shape();
1798 myAISContext->Redisplay(ais1,Standard_False);
1799 myAISContext->SetCurrentObject(ais1,Standard_False);
1804 TopoDS_Face F2 = TopoDS::Face(Ex.Current());
1805 surf = BRep_Tool::Surface(F2);
1806 Pl = Handle(Geom_Plane)::DownCast(surf);
1807 D = Pl->Pln().Axis().Direction();
1809 BRepBuilderAPI_MakeWire MW2;
1810 p1 = gp_Pnt2d(100.,100.);
1811 p2 = gp_Pnt2d(200.,100.);
1812 aline = GCE2d_MakeLine(p1,p2).Value();
1813 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1815 p2 = gp_Pnt2d(150.,200.);
1816 aline = GCE2d_MakeLine(p1,p2).Value();
1817 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1819 p2 = gp_Pnt2d(100.,100.);
1820 aline = GCE2d_MakeLine(p1,p2).Value();
1821 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1822 BRepBuilderAPI_MakeFace MKF2;
1823 MKF2.Init(surf,Standard_False);
1824 MKF2.Add(MW2.Wire());
1826 BRepLib::BuildCurves3d(FP);
1827 BRepFeat_MakePrism MKP2(res1,FP,F2,D,1,Standard_True);
1829 TopoDS_Shape res2 = MKP2.Shape();
1832 myAISContext->Redisplay(ais1);
1833 myAISContext->SetCurrentObject(ais1,Standard_False);
1836 TCollection_AsciiString Message ("\
1838 --- Extrusion ---\n\
1840 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
1841 TopExp_Explorer Ex;\n\
1842 Ex.Init(S,TopAbs_FACE);\n\
1844 TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
1845 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);\n\
1846 Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);\n\
1847 gp_Dir D = Pl->Pln().Axis().Direction();\n\
1850 Handle(Geom2d_Curve) aline;\n\
1851 BRepBuilderAPI_MakeWire MW;\n\
1852 p1 = gp_Pnt2d(200.,-100.);\n\
1853 p2 = gp_Pnt2d(100.,-100.);\n\
1854 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1855 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1857 p2 = gp_Pnt2d(100.,-200.);\n\
1858 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1859 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1861 p2 = gp_Pnt2d(200.,-200.);\n\
1862 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1863 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1865 p2 = gp_Pnt2d(200.,-100.);\n\
1866 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1867 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1868 BRepBuilderAPI_MakeFace MKF;\n\
1869 MKF.Init(surf,Standard_False);\n\
1870 MKF.Add(MW.Wire());\n\
1871 TopoDS_Shape FP = MKF.Face();\n\
1872 BRepLib::BuildCurves3d(FP);\n\
1873 BRepFeat_MakePrism MKP(S,FP,F,D,0,Standard_True);\n\
1874 MKP.Perform(200);\n\
1875 TopoDS_Shape res1 = MKP.Shape();\n\
1878 --- Protrusion --- \n\
1881 TopoDS_Face F2 = TopoDS::Face(Ex.Current());\n\
1882 surf = BRep_Tool::Surface(F2);\n\
1883 Pl = Handle(Geom_Plane)::DownCast(surf);\n\
1884 D = Pl->Pln().Axis().Direction();\n\
1886 BRepBuilderAPI_MakeWire MW2;\n\
1887 p1 = gp_Pnt2d(100.,100.);\n\
1888 p2 = gp_Pnt2d(200.,100.);\n\
1889 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1890 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1892 p2 = gp_Pnt2d(150.,200.);\n\
1893 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1894 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1896 p2 = gp_Pnt2d(100.,100.);\n\
1897 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1898 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1899 BRepBuilderAPI_MakeFace MKF2;\n\
1900 MKF2.Init(surf,Standard_False);\n\
1901 MKF2.Add(MW2.Wire());\n\
1902 FP = MKF2.Face();\n\
1903 BRepLib::BuildCurves3d(FP);\n\
1904 BRepFeat_MakePrism MKP2(res1,FP,F2,D,1,Standard_True);\n\
1905 MKP2.Perform(100.);\n\
1906 TopoDS_Shape res2 = MKP2.Shape();\n\
1908 PocessTextInDialog("Make an extrusion or a protrusion", Message);
1912 // BRepFeat_MakeDPrism
1914 void CModelingDoc::OnDprismLocal()
1916 AIS_ListOfInteractive aList;
1917 myAISContext->DisplayedObjects(aList);
1918 AIS_ListIteratorOfListOfInteractive aListIterator;
1919 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1920 myAISContext->Remove(aListIterator.Value());
1923 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);
1924 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
1926 myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
1927 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1930 Ex.Init(S,TopAbs_FACE);
1936 TopoDS_Face F = TopoDS::Face(Ex.Current());
1937 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
1938 gp_Circ2d c(gp_Ax2d(gp_Pnt2d(200.,130.),gp_Dir2d(1.,0.)),50.);
1939 BRepBuilderAPI_MakeWire MW;
1940 Handle(Geom2d_Curve) aline = new Geom2d_Circle(c);
1941 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,PI));
1942 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,PI,2.*PI));
1943 BRepBuilderAPI_MakeFace MKF;
1944 MKF.Init(surf,Standard_False);
1946 TopoDS_Face FP = MKF.Face();
1947 BRepLib::BuildCurves3d(FP);
1948 BRepFeat_MakeDPrism MKDP(S,FP,F,10*PI180,1,Standard_True);
1950 TopoDS_Shape res1 = MKDP.Shape();
1952 myAISContext->Display(ais1,Standard_False);
1953 myAISContext->SetCurrentObject(ais1,Standard_False);
1959 myAISContext->Redisplay(ais1,Standard_False);
1960 myAISContext->SetCurrentObject(ais1,Standard_False);
1964 TCollection_AsciiString Message ("\
1966 --- Protrusion with draft angle --- \n\
1968 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
1969 TopExp_Explorer Ex;\n\
1970 Ex.Init(S,TopAbs_FACE);\n\
1976 TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
1977 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);\n\
1978 gp_Circ2d c(gp_Ax2d(gp_Pnt2d(200.,130.),gp_Dir2d(1.,0.)),50.);\n\
1979 BRepBuilderAPI_MakeWire MW;\n\
1980 Handle(Geom2d_Curve) aline = new Geom2d_Circle(c);\n\
1981 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,PI));\n\
1982 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,PI,2.*PI));\n\
1983 BRepBuilderAPI_MakeFace MKF;\n\
1984 MKF.Init(surf,Standard_False);\n\
1985 MKF.Add(MW.Wire());\n\
1986 TopoDS_Face FP = MKF.Face();\n\
1987 BRepLib::BuildCurves3d(FP);\n\
1988 BRepFeat_MakeDPrism MKDP(S,FP,F,10*PI180,1,Standard_True);\n\
1989 MKDP.Perform(200);\n\
1990 TopoDS_Shape res1 = MKDP.Shape();\n\
1992 PocessTextInDialog("Make an extrusion or a protrusion with a draft angle", Message);
1995 void CModelingDoc::OnRevolLocal()
1997 AIS_ListOfInteractive aList;
1998 myAISContext->DisplayedObjects(aList);
1999 AIS_ListIteratorOfListOfInteractive aListIterator;
2000 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2001 myAISContext->Remove(aListIterator.Value());
2003 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);
2005 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2007 myAISContext->SetColor(ais1,Quantity_NOC_CORAL,Standard_False);
2008 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2009 myAISContext->Display(ais1,Standard_False);
2010 myAISContext->SetCurrentObject(ais1,Standard_False);
2015 Ex.Init(S,TopAbs_FACE);
2018 TopoDS_Face F1 = TopoDS::Face(Ex.Current());
2019 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);
2020 Handle (Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);
2021 gp_Ax1 D = gp::OX();
2022 BRepBuilderAPI_MakeWire MW1;
2024 p1 = gp_Pnt2d(100.,100.);
2025 p2 = gp_Pnt2d(200.,100.);
2026 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();
2027 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2029 p2 = gp_Pnt2d(150.,200.);
2030 aline = GCE2d_MakeLine(p1,p2).Value();
2031 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2033 p2 = gp_Pnt2d(100.,100.);
2034 aline = GCE2d_MakeLine(p1,p2).Value();
2035 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2036 BRepBuilderAPI_MakeFace MKF1;
2037 MKF1.Init(surf,Standard_False);
2038 MKF1.Add(MW1.Wire());
2039 TopoDS_Face FP = MKF1.Face();
2040 BRepLib::BuildCurves3d(FP);
2041 BRepFeat_MakeRevol MKrev(S,FP,F1,D,1,Standard_True);
2044 TopoDS_Face F2 = TopoDS::Face(Ex.Current());
2046 TopoDS_Shape res1 = MKrev.Shape();
2049 myAISContext->Remove(ais1);
2050 Handle(AIS_Shape) ais2 = new AIS_Shape(res1);
2051 myAISContext->Display(ais2,Standard_False);
2052 myAISContext->SetCurrentObject(ais2,Standard_False);
2055 TCollection_AsciiString Message ("\
2057 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
2058 TopExp_Explorer Ex;\n\
2059 Ex.Init(S,TopAbs_FACE);\n\
2062 TopoDS_Face F1 = TopoDS::Face(Ex.Current());\n\
2063 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);\n\
2064 Handle (Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);\n\
2065 gp_Ax1 D = gp::OX();\n\
2066 BRepBuilderAPI_MakeWire MW1;\n\
2068 p1 = gp_Pnt2d(100.,100.);\n\
2069 p2 = gp_Pnt2d(200.,100.);\n\
2070 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();\n\
2071 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2073 p2 = gp_Pnt2d(150.,200.);\n\
2074 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2075 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2077 p2 = gp_Pnt2d(100.,100.);\n\
2078 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2079 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2080 BRepBuilderAPI_MakeFace MKF1;\n\
2081 MKF1.Init(surf,Standard_False);\n\
2082 MKF1.Add(MW1.Wire());\n\
2083 TopoDS_Face FP = MKF1.Face();\n\
2084 BRepLib::BuildCurves3d(FP);\n\
2085 BRepFeat_MakeRevol MKrev(S,FP,F1,D,1,Standard_True);\n\
2087 TopoDS_Face F2 = TopoDS::Face(Ex.Current());\n\
2088 MKrev.Perform(F2);\n\
2089 TopoDS_Shape res1 = MKrev.Shape();\n\
2091 PocessTextInDialog("Make a local revolution", Message);
2094 void CModelingDoc::OnGlueLocal()
2096 AIS_ListOfInteractive aList;
2097 myAISContext->DisplayedObjects(aList);
2098 AIS_ListIteratorOfListOfInteractive aListIterator;
2099 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2100 myAISContext->Remove(aListIterator.Value());
2102 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(gp_Pnt(-500.,-500.,0.),gp_Pnt(-100.,-250.,300.));
2104 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
2105 myAISContext->SetColor(ais1,Quantity_NOC_ORANGE,Standard_False);
2106 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2107 myAISContext->Display(ais1,Standard_False);
2108 myAISContext->SetCurrentObject(ais1,Standard_False);
2112 TopExp_Explorer Ex1;
2113 Ex1.Init(S1,TopAbs_FACE);
2119 TopoDS_Face F1 = TopoDS::Face(Ex1.Current());
2120 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(-400.,-400.,300.),gp_Pnt(-200.,-300.,500.));
2121 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
2123 myAISContext->SetColor(ais2,Quantity_NOC_AZURE,Standard_False);
2124 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
2125 myAISContext->Display(ais2,Standard_False);
2126 myAISContext->SetCurrentObject(ais2,Standard_False);
2130 TopExp_Explorer Ex2;
2131 Ex2.Init(S2,TopAbs_FACE);
2136 TopoDS_Face F2 = TopoDS::Face(Ex2.Current());
2137 BRepFeat_Gluer glue(S2,S1);
2139 TopoDS_Shape res1 = glue.Shape();
2140 myAISContext->Erase(ais2,Standard_False,Standard_False);
2144 myAISContext->Redisplay(ais1);
2145 myAISContext->SetCurrentObject(ais1,Standard_False);
2149 TopoDS_Shape S3 = BRepPrimAPI_MakeBox(500.,400.,300.);
2151 Handle(AIS_Shape) ais3 = new AIS_Shape(S3);
2152 myAISContext->SetColor(ais3,Quantity_NOC_ORANGE,Standard_False);
2153 myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
2154 myAISContext->Display(ais3,Standard_False);
2155 myAISContext->SetCurrentObject(ais3,Standard_False);
2159 TopExp_Explorer Ex3;
2160 Ex3.Init(S3,TopAbs_FACE);
2166 TopoDS_Face F3 = TopoDS::Face(Ex3.Current());
2167 TopoDS_Shape S4 = BRepPrimAPI_MakeBox(gp_Pnt(0.,0.,300.),gp_Pnt(200.,200.,500.));
2169 Handle(AIS_Shape) ais4 = new AIS_Shape(S4);
2170 myAISContext->SetColor(ais4,Quantity_NOC_AZURE,Standard_False);
2171 myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
2172 myAISContext->Display(ais4,Standard_False);
2173 myAISContext->SetCurrentObject(ais4,Standard_False);
2177 TopExp_Explorer Ex4;
2178 Ex4.Init(S4,TopAbs_FACE);
2183 TopoDS_Face F4 = TopoDS::Face(Ex4.Current());
2184 BRepFeat_Gluer glue2(S4,S3);
2186 LocOpe_FindEdges CommonEdges(F4,F3);
2187 for (CommonEdges.InitIterator(); CommonEdges.More(); CommonEdges.Next())
2188 glue2.Bind(CommonEdges.EdgeFrom(),CommonEdges.EdgeTo());
2189 TopoDS_Shape res2 = glue2.Shape();
2190 myAISContext->Erase(ais3,Standard_False,Standard_False);
2194 myAISContext->Redisplay(ais4,Standard_False);
2195 myAISContext->SetCurrentObject(ais4,Standard_False);
2199 TCollection_AsciiString Message ("\
2201 --- Without common edges ---\n\
2203 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(gp_Pnt(-500.,-500.,0.),gp_Pnt(-100.,-250.,300.));\n\
2204 TopExp_Explorer Ex1;\n\
2205 Ex1.Init(S1,TopAbs_FACE);\n\
2211 TopoDS_Face F1 = TopoDS::Face(Ex1.Current());\n\
2212 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(-400.,-400.,300.),gp_Pnt(-200.,-300.,500.));\n\
2213 TopExp_Explorer Ex2;\n\
2214 Ex2.Init(S2,TopAbs_FACE);\n\
2219 TopoDS_Face F2 = TopoDS::Face(Ex2.Current());\n\
2220 BRepFeat_Gluer glue(S2,S1);\n\
2221 glue.Bind(F2,F1);\n\
2222 TopoDS_Shape res1 = glue.Shape();\n\
2224 --- With common edges ---\n\
2226 TopoDS_Shape S3 = BRepPrimAPI_MakeBox(500.,400.,300.);\n\
2227 TopExp_Explorer Ex3;\n\
2228 Ex3.Init(S3,TopAbs_FACE);\n\
2234 TopoDS_Face F3 = TopoDS::Face(Ex3.Current());\n\
2235 TopoDS_Shape S4 = BRepPrimAPI_MakeBox(gp_Pnt(0.,0.,300.),gp_Pnt(200.,200.,500.));\n\
2236 TopExp_Explorer Ex4;\n\
2237 Ex4.Init(S4,TopAbs_FACE);\n\
2242 TopoDS_Face F4 = TopoDS::Face(Ex4.Current());\n\
2243 BRepFeat_Gluer glue2(S4,S3);\n\
2244 glue2.Bind(F4,F3);\n\
2245 LocOpe_FindEdges CommonEdges(F4,F3);\n\
2246 for (CommonEdges.InitIterator(); CommonEdges.More(); CommonEdges.Next()) \n\
2247 glue2.Bind(CommonEdges.EdgeFrom(),CommonEdges.EdgeTo());\n\
2248 TopoDS_Shape res2 = glue2.Shape();\n\
2250 PocessTextInDialog("Glue two solids", Message);
2254 void CModelingDoc::OnPipeLocal()
2256 AIS_ListOfInteractive aList;
2257 myAISContext->DisplayedObjects(aList);
2258 AIS_ListIteratorOfListOfInteractive aListIterator;
2259 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2260 myAISContext->Remove(aListIterator.Value());
2262 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);
2263 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2265 myAISContext->SetColor(ais1,Quantity_NOC_CORAL,Standard_False);
2266 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2267 myAISContext->Display(ais1,Standard_False);
2268 myAISContext->SetCurrentObject(ais1,Standard_False);
2273 Ex.Init(S,TopAbs_FACE);
2276 TopoDS_Face F1 = TopoDS::Face(Ex.Current());
2277 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);
2278 BRepBuilderAPI_MakeWire MW1;
2280 p1 = gp_Pnt2d(100.,100.);
2281 p2 = gp_Pnt2d(200.,100.);
2282 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();
2283 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2285 p2 = gp_Pnt2d(150.,200.);
2286 aline = GCE2d_MakeLine(p1,p2).Value();
2287 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2289 p2 = gp_Pnt2d(100.,100.);
2290 aline = GCE2d_MakeLine(p1,p2).Value();
2291 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2292 BRepBuilderAPI_MakeFace MKF1;
2293 MKF1.Init(surf,Standard_False);
2294 MKF1.Add(MW1.Wire());
2295 TopoDS_Face FP = MKF1.Face();
2296 BRepLib::BuildCurves3d(FP);
2297 TColgp_Array1OfPnt CurvePoles(1,3);
2298 gp_Pnt pt = gp_Pnt(150.,0.,150.);
2300 pt = gp_Pnt(200.,-100.,150.);
2302 pt = gp_Pnt(150.,-200.,150.);
2304 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);
2305 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);
2306 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);
2307 BRepFeat_MakePipe MKPipe(S,FP,F1,W,1,Standard_True);
2309 TopoDS_Shape res1 = MKPipe.Shape();
2312 myAISContext->Redisplay(ais1,Standard_False);
2313 myAISContext->SetCurrentObject(ais1,Standard_False);
2316 TCollection_AsciiString Message ("\
2318 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
2319 TopExp_Explorer Ex;\n\
2320 Ex.Init(S,TopAbs_FACE);\n\
2323 TopoDS_Face F1 = TopoDS::Face(Ex.Current());\n\
2324 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);\n\
2325 BRepBuilderAPI_MakeWire MW1;\n\
2327 p1 = gp_Pnt2d(100.,100.);\n\
2328 p2 = gp_Pnt2d(200.,100.);\n\
2329 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();\n\
2330 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2332 p2 = gp_Pnt2d(150.,200.);\n\
2333 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2334 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2336 p2 = gp_Pnt2d(100.,100.);\n\
2337 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2338 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2339 BRepBuilderAPI_MakeFace MKF1;\n\
2340 MKF1.Init(surf,Standard_False);\n\
2341 TopoDS_Face FP = MKF1.Face();\n\
2342 BRepLib::BuildCurves3d(FP);\n\
2343 TColgp_Array1OfPnt CurvePoles(1,3);\n\
2344 gp_Pnt pt = gp_Pnt(150.,0.,150.);\n\
2345 CurvePoles(1) = pt;\n\
2346 pt = gp_Pnt(200.,-100.,150.);\n\
2347 CurvePoles(2) = pt;\n\
2348 pt = gp_Pnt(150.,-200.,150.);\n\
2349 CurvePoles(3) = pt;\n\
2350 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);\n\
2351 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);\n\
2352 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);\n\
2353 BRepFeat_MakePipe MKPipe(S,FP,F1,W,1,Standard_True);\n\
2354 MKPipe.Perform();\n\
2355 TopoDS_Shape res1 = MKPipe.Shape();\n\
2357 PocessTextInDialog("Make a local pipe", Message);
2361 void CModelingDoc::OnLinearLocal()
2363 AIS_ListOfInteractive aList;
2364 myAISContext->DisplayedObjects(aList);
2365 AIS_ListIteratorOfListOfInteractive aListIterator;
2366 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2367 myAISContext->Remove(aListIterator.Value());
2369 BRepBuilderAPI_MakeWire mkw;
2370 gp_Pnt p1 = gp_Pnt(0.,0.,0.);
2371 gp_Pnt p2 = gp_Pnt(200.,0.,0.);
2372 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2374 p2 = gp_Pnt(200.,0.,50.);
2375 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2377 p2 = gp_Pnt(50.,0.,50.);
2378 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2380 p2 = gp_Pnt(50.,0.,200.);
2381 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2383 p2 = gp_Pnt(0.,0.,200.);
2384 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2386 mkw.Add(BRepBuilderAPI_MakeEdge(p2,gp_Pnt(0.,0.,0.)));
2388 TopoDS_Shape S = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(mkw.Wire()),
2389 gp_Vec(gp_Pnt(0.,0.,0.),gp_Pnt(0.,100.,0.)));
2391 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2392 myAISContext->SetColor(ais1,Quantity_NOC_CYAN2,Standard_False);
2393 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2394 myAISContext->Display(ais1,Standard_False);
2395 myAISContext->SetCurrentObject(ais1,Standard_False);
2399 TopoDS_Wire W = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(gp_Pnt(50.,45.,100.),
2400 gp_Pnt(100.,45.,50.)));
2401 Handle(Geom_Plane) aplane = new Geom_Plane(0.,1.,0.,-45.);
2402 BRepFeat_MakeLinearForm aform(S, W, aplane, gp_Vec(0.,10.,0.), gp_Vec(0.,0.,0.),
2404 aform.Perform(/*10.*/); // new in 2.0
2406 TopoDS_Shape res = aform.Shape();
2408 myAISContext->Redisplay(ais1,Standard_False);
2409 myAISContext->SetCurrentObject(ais1);
2412 TCollection_AsciiString Message ("\
2414 BRepBuilderAPI_MakeWire mkw;\n\
2415 gp_Pnt p1 = gp_Pnt(0.,0.,0.);\n\
2416 gp_Pnt p2 = gp_Pnt(200.,0.,0.);\n\
2417 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2419 p2 = gp_Pnt(200.,0.,50.);\n\
2420 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2422 p2 = gp_Pnt(50.,0.,50.);\n\
2423 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2425 p2 = gp_Pnt(50.,0.,200.);\n\
2426 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2428 p2 = gp_Pnt(0.,0.,200.);\n\
2429 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2431 mkw.Add(BRepBuilderAPI_MakeEdge(p2,gp_Pnt(0.,0.,0.)));\n\
2432 TopoDS_Shape S = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(mkw.Wire()), \n\
2433 gp_Vec(gp_Pnt(0.,0.,0.),gp_Pnt(0.,100.,0.)));\n\
2434 TopoDS_Wire W = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(gp_Pnt(50.,45.,100.),\n\
2435 gp_Pnt(100.,45.,50.)));\n\
2436 Handle(Geom_Plane) aplane = new Geom_Plane(0.,1.,0.,-45.);\n\
2437 BRepFeat_MakeLinearForm aform(S, W, aplane, gp_Dir(0.,10.,0.), gp_Dir(0.,0.,0.),\n\
2438 1, Standard_True);\n\
2439 aform.Perform(10.);\n\
2440 TopoDS_Shape res = aform.Shape();\n\
2442 PocessTextInDialog("Make a rib", Message);
2446 void CModelingDoc::OnSplitLocal()
2448 AIS_ListOfInteractive aList;
2449 myAISContext->DisplayedObjects(aList);
2450 AIS_ListIteratorOfListOfInteractive aListIterator;
2451 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2452 myAISContext->Remove(aListIterator.Value());
2455 TopoDS_Shape S = BRepPrimAPI_MakeBox(gp_Pnt(-100,-60,-80),150,200,170);
2457 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2458 myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
2459 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2460 myAISContext->Display(ais1,Standard_False);
2461 myAISContext->SetCurrentObject(ais1,Standard_False);
2465 BRepAlgoAPI_Section asect(S, gp_Pln(1,2,1,-15),Standard_False);
2466 asect.ComputePCurveOn1(Standard_True);
2467 asect.Approximation(Standard_True);
2469 TopoDS_Shape R = asect.Shape();
2470 BRepTools::Write(R,"E:\\temp\\R");
2472 BRepFeat_SplitShape asplit(S);
2474 for (TopExp_Explorer Ex(R,TopAbs_EDGE); Ex.More(); Ex.Next()) {
2475 TopoDS_Shape anEdge = Ex.Current();
2477 if (asect.HasAncestorFaceOn1(anEdge,aFace)) {
2478 TopoDS_Face F = TopoDS::Face(aFace);
2479 TopoDS_Edge E = TopoDS::Edge(anEdge);
2487 myAISContext->Erase(ais1,Standard_False,Standard_False);
2490 TopoDS_Shape Result = asplit.Shape();
2492 Handle(AIS_Shape) ais2 = new AIS_Shape(Result);
2494 myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False);
2495 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
2496 myAISContext->SetDisplayMode(ais2,1,Standard_False);
2497 myAISContext->Display(ais2,Standard_False);
2498 myAISContext->SetCurrentObject(ais2,Standard_False);
2500 TCollection_AsciiString Message ("\
2502 TopoDS_Shape S = BRepPrimAPI_MakeBox(gp_Pnt(-100,-60,-80),150,200,170); \n\
2504 BRepBuilderAPI_Section asect(S, gp_Pln(1,2,1,-15),Standard_False); \n\
2505 asect.ComputePCurveOn1(Standard_True); \n\
2506 asect.Approximation(Standard_True); \n\
2508 TopoDS_Shape R = asect.Shape(); \n\
2510 BRepFeat_SplitShape asplit(S); \n\
2512 for (TopExp_Explorer Ex(R,TopAbs_EDGE); Ex.More(); Ex.Next()) { \n\
2513 TopoDS_Shape anEdge = Ex.Current(); \n\
2514 TopoDS_Shape aFace; \n\
2515 if (asect.HasAncestorFaceOn1(anEdge,aFace)) { \n\
2516 TopoDS_Face F = TopoDS::Face(aFace); \n\
2517 TopoDS_Edge E = TopoDS::Edge(anEdge); \n\
2518 asplit.Add(E,F); \n\
2524 TopoDS_Shape Result = asplit.Shape(); \n\
2528 PocessTextInDialog("Split a shape", Message);
2533 void CModelingDoc::OnThickLocal()
2535 AIS_ListOfInteractive L;
2536 myAISContext->DisplayedObjects(L);
2537 AIS_ListIteratorOfListOfInteractive aListIterator;
2538 for(aListIterator.Initialize(L);aListIterator.More();aListIterator.Next()){
2539 myAISContext->Remove(aListIterator.Value());
2542 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(150,200,110);
2544 Handle(AIS_Shape) abox1 = new AIS_Shape(S1);
2545 myAISContext->SetColor(abox1,Quantity_NOC_WHITE);
2546 myAISContext->SetMaterial(abox1,Graphic3d_NOM_PLASTIC,Standard_False);
2547 myAISContext->Display(abox1,Standard_False);
2548 myAISContext->SetCurrentObject(abox1,Standard_False);
2552 TopTools_ListOfShape aList;
2553 TopExp_Explorer Ex(S1,TopAbs_FACE);
2554 Ex.Next(); //this is the front face
2555 TopoDS_Shape aFace = Ex.Current();
2556 aList.Append(aFace);
2558 TopoDS_Shape aThickSolid = BRepOffsetAPI_MakeThickSolid(S1,aList,10,0.01);
2560 Handle(AIS_Shape) ais1 = new AIS_Shape(aThickSolid);
2561 myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
2562 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2563 myAISContext->Display(ais1,Standard_False);
2564 myAISContext->SetCurrentObject(ais1,Standard_False);
2568 myAISContext->Erase(abox1,Standard_True,Standard_False);
2572 TCollection_AsciiString Message ("\
2574 TopoDS_Shape S = BRepPrimAPI_MakeBox(150,200,110); \n\
2576 TopTools_ListOfShape aList; \n\
2577 TopExp_Explorer Ex(S,TopAbs_FACE); \n\
2578 Ex.Next(); //in order to recover the front face \n\
2579 TopoDS_Shape aFace = Ex.Current(); \n\
2580 aList.Append(aFace); \n\
2582 TopoDS_Shape aThickSolid = BRepPrimAPI_MakeThickSolid(S,aList,15,0.01); \n\
2585 PocessTextInDialog("Make a thick solid", Message);
2588 void CModelingDoc::OnOffsetLocal()
2590 AIS_ListOfInteractive aList;
2591 myAISContext->DisplayedObjects(aList);
2592 AIS_ListIteratorOfListOfInteractive aListIterator;
2593 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2594 myAISContext->Remove(aListIterator.Value());
2597 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(150,200,110);
2599 Handle(AIS_Shape) aisBox1 = new AIS_Shape(S1);
2600 myAISContext->SetColor(aisBox1,Quantity_NOC_BROWN,Standard_False);
2601 myAISContext->SetMaterial(aisBox1,Graphic3d_NOM_GOLD,Standard_False);
2602 myAISContext->Display(aisBox1,Standard_False);
2606 TopoDS_Shape anOffsetShape1 = BRepOffsetAPI_MakeOffsetShape(S1,60,0.01);
2608 Handle(AIS_Shape) ais1 = new AIS_Shape(anOffsetShape1);
2609 myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
2610 myAISContext->SetMaterial(ais1,Graphic3d_NOM_GOLD,Standard_False);
2611 myAISContext->SetTransparency(ais1,0.5,Standard_False);
2612 myAISContext->Display(ais1,Standard_False);
2616 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(500,0,0),220,140,180);
2618 Handle(AIS_Shape) aisBox2 = new AIS_Shape(S2);
2619 myAISContext->SetColor(aisBox2,Quantity_NOC_WHITE,Standard_False);
2620 myAISContext->SetMaterial(aisBox2,Graphic3d_NOM_GOLD,Standard_False);
2621 myAISContext->SetTransparency(aisBox2,0.5,Standard_False);
2622 myAISContext->Display(aisBox2,Standard_False);
2626 TopoDS_Shape anOffsetShape2 = BRepOffsetAPI_MakeOffsetShape(S2,-40,0.01,
2627 BRepOffset_Skin,Standard_False,Standard_False,GeomAbs_Arc);
2629 Handle(AIS_Shape) ais2 = new AIS_Shape(anOffsetShape2);
2630 myAISContext->SetColor(ais2,Quantity_NOC_MATRABLUE);
2631 myAISContext->SetMaterial(ais2,Graphic3d_NOM_GOLD,Standard_False);
2632 myAISContext->Display(ais2);
2635 TCollection_AsciiString Message ("\
2638 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(150,200,110); \n\
2640 TopoDS_Shape anOffsetShape1 = BRepPrimAPI_MakeOffsetShape(S1,60,0.01); \n\
2644 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(300,0,0),220,140,180); \n\
2646 TopoDS_Shape anOffsetShape2 = BRepPrimAPI_MakeOffsetShape(S2,-20,0.01, \n\
2647 BRepOffset_Skin,Standard_False,Standard_False,GeomAbs_Arc); \n\
2651 PocessTextInDialog("Make an offset shape", Message);
2655 /* =================================================================================
2656 ==================== B U I L D I N G ========================================
2657 ================================================================================= */
2660 void CModelingDoc::OnVertex()
2662 AIS_ListOfInteractive aList;
2663 myAISContext->DisplayedObjects(aList);
2664 AIS_ListIteratorOfListOfInteractive aListIterator;
2665 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2666 myAISContext->Remove(aListIterator.Value());
2669 TopoDS_Vertex V1,V2,V3;
2671 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
2672 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,25));
2675 BRepBuilderAPI_MakeVertex MV(P);
2678 Handle(AIS_Shape) Point1 = new AIS_Shape(V1);
2679 myAISContext->Display(Point1,Standard_False);
2680 Handle(AIS_Shape) Point2 = new AIS_Shape(V2);
2681 myAISContext->Display(Point2,Standard_False);
2682 Handle(AIS_Shape) Point3 = new AIS_Shape(V3);
2683 myAISContext->Display(Point3,Standard_False);
2687 TCollection_AsciiString Message ("\
2689 TopoDS_Vertex V1,V2,V3; \n\
2691 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0)); \n\
2693 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,25)); \n\
2695 gp_Pnt P(-12,8,-4); \n\
2696 BRepBuilderAPI_MakeVertex MV(P); \n\
2697 V3 = MV.Vertex(); \n\
2701 PocessTextInDialog("Make vertex from point ", Message);
2705 void CModelingDoc::OnEdge()
2708 AIS_ListOfInteractive aList;
2709 myAISContext->DisplayedObjects(aList);
2710 AIS_ListIteratorOfListOfInteractive aListIterator;
2711 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2712 myAISContext->Remove(aListIterator.Value());
2716 TopoDS_Edge BlueEdge,YellowEdge,WhiteEdge,RedEdge,GreenEdge;
2717 TopoDS_Vertex V1,V2,V3,V4;
2719 /////////////The blue edge
2721 BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80,-50,-20),gp_Pnt(-30,-60,-60));
2723 /////////////The yellow edge
2725 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));
2726 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,-25));
2727 YellowEdge = BRepBuilderAPI_MakeEdge(V1,V2);
2729 /////////////The white edge
2731 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));
2732 WhiteEdge = BRepBuilderAPI_MakeEdge(line,-20,10);
2734 //////////////The red edge
2736 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),60,30);
2737 RedEdge = BRepBuilderAPI_MakeEdge(Elips,0,PI/2);
2739 /////////////The green edge and the both extreme vertex
2741 gp_Pnt P1(-15,200,10);
2743 gp_Pnt P3(15,200,0);
2744 gp_Pnt P4(-15,20,15);
2747 gp_Pnt P7(24,120,0);
2748 gp_Pnt P8(-24,120,12.5);
2749 TColgp_Array1OfPnt array(1,8);
2750 array.SetValue(1,P1);
2751 array.SetValue(2,P2);
2752 array.SetValue(3,P3);
2753 array.SetValue(4,P4);
2754 array.SetValue(5,P5);
2755 array.SetValue(6,P6);
2756 array.SetValue(7,P7);
2757 array.SetValue(8,P8);
2758 Handle (Geom_BezierCurve) curve = new Geom_BezierCurve(array);
2760 BRepBuilderAPI_MakeEdge ME (curve);
2765 //////////////Display
2766 Handle(AIS_Shape) blue = new AIS_Shape(BlueEdge);
2767 myAISContext->SetColor(blue,Quantity_NOC_MATRABLUE,Standard_False);
2768 myAISContext->Display(blue,Standard_False);
2770 Handle(AIS_Shape) yellow = new AIS_Shape(YellowEdge);
2771 myAISContext->SetColor(yellow,Quantity_NOC_YELLOW,Standard_False);
2772 myAISContext->Display(yellow,Standard_False);
2774 Handle(AIS_Shape) white = new AIS_Shape(WhiteEdge);
2775 myAISContext->SetColor(white,Quantity_NOC_WHITE,Standard_False);
2776 myAISContext->Display(white,Standard_False);
2778 Handle(AIS_Shape) red = new AIS_Shape(RedEdge);
2779 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
2780 myAISContext->Display(red,Standard_False);
2782 Handle(AIS_Shape) green = new AIS_Shape(GreenEdge);
2783 myAISContext->SetColor(green,Quantity_NOC_GREEN,Standard_False);
2784 myAISContext->Display(green,Standard_False);
2786 Handle(AIS_Shape) Point1 = new AIS_Shape(V3);
2787 myAISContext->Display(Point1,Standard_False);
2788 Handle(AIS_Shape) Point2 = new AIS_Shape(V4);
2789 myAISContext->Display(Point2,Standard_False);
2793 TCollection_AsciiString Message ("\
2795 TopoDS_Edge BlueEdge, YellowEdge, WhiteEdge, RedEdge, GreenEdge; \n\
2796 TopoDS_Vertex V1,V2,V3,V4; \n\
2798 /////////////The blue edge \n\
2800 BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80,-50,-20),gp_Pnt(-30,-60,-60)); \n\
2802 /////////////The yellow edge \n\
2804 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30)); \n\
2805 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,-25)); \n\
2806 YellowEdge = BRepBuilderAPI_MakeEdge(V1,V2); \n\
2808 /////////////The white edge \n\
2810 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0))); \n\
2811 WhiteEdge = BRepBuilderAPI_MakeEdge(line,-20,10); \n\
2813 //////////////The red edge \n\
2815 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),60,30); \n\
2816 RedEdge = BRepBuilderAPI_MakeEdge(Elips,0,PI/2); \n\
2818 /////////////The green edge and the both extreme vertex \n\
2820 gp_Pnt P1(-15,200,10); \n\
2821 gp_Pnt P2(5,204,0); \n\
2822 gp_Pnt P3(15,200,0); \n\
2823 gp_Pnt P4(-15,20,15); \n\
2824 gp_Pnt P5(-5,20,0); \n\
2825 gp_Pnt P6(15,20,0); \n\
2826 gp_Pnt P7(24,120,0); \n\
2827 gp_Pnt P8(-24,120,12.5); \n\
2828 TColgp_Array1OfPnt array(1,8); \n\
2829 array.SetValue(1,P1); \n\
2830 array.SetValue(2,P2); \n\
2831 array.SetValue(3,P3); \n\
2832 array.SetValue(4,P4); \n\
2833 array.SetValue(5,P5); \n\
2834 array.SetValue(6,P6); \n\
2835 array.SetValue(7,P7); \n\
2836 array.SetValue(8,P8); \n\
2837 Handle (Geom_BezierCurve) curve = new Geom_BezierCurve(array); \n\
2839 BRepBuilderAPI_MakeEdge ME (curve); \n\
2841 V3 = ME.Vertex1(); \n\
2842 V4 = ME.Vertex2(); \n\
2846 PocessTextInDialog("Make edge", Message);
2850 void CModelingDoc::OnWire()
2852 AIS_ListOfInteractive aList;
2853 myAISContext->DisplayedObjects(aList);
2854 AIS_ListIteratorOfListOfInteractive aListIterator;
2855 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2856 myAISContext->Remove(aListIterator.Value());
2859 TopoDS_Wire RedWire,YellowWire,WhiteWire,
2860 ExistingWire, ExistingWire2;
2862 TopoDS_Edge Edge1,Edge2,Edge3,Edge4,Edge5,Edge6,Edge7,LastEdge;
2863 TopoDS_Vertex LastVertex;
2865 ////////////The red wire is build from a single edge
2867 gp_Elips Elips(gp_Ax2(gp_Pnt(250,0,0),gp_Dir(1,1,1)),160,90);
2868 Edge1 = BRepBuilderAPI_MakeEdge(Elips,0,PI/2);
2870 RedWire = BRepBuilderAPI_MakeWire(Edge1);
2872 ///////////the yellow wire is build from an existing wire and an edge
2874 gp_Circ circle(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(1,0,0)),80);
2875 Edge2 = BRepBuilderAPI_MakeEdge(circle,0,PI);
2877 ExistingWire = BRepBuilderAPI_MakeWire(Edge2);
2879 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(-300,0,-80),gp_Pnt(-90,20,-30));
2881 BRepBuilderAPI_MakeWire MW1(ExistingWire,Edge3);
2887 //////////the white wire is built with an existing wire and 3 edges.
2888 //////////we use the methods Add, Edge and Vertex from BRepBuilderAPI_MakeWire.
2890 gp_Circ circle2(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)),200);
2891 Edge4 = BRepBuilderAPI_MakeEdge(circle2,0,PI);
2893 ExistingWire2 = BRepBuilderAPI_MakeWire(Edge4);
2895 gp_Pnt P1(0,0,-200);
2897 Edge5 = BRepBuilderAPI_MakeEdge(P1,P2);
2899 gp_Pnt P3(-15,20,15);
2900 Edge6 = BRepBuilderAPI_MakeEdge(P2,P3);
2902 Edge7 = BRepBuilderAPI_MakeEdge(P3,P4);
2904 BRepBuilderAPI_MakeWire MW;
2905 MW.Add(ExistingWire2);
2911 WhiteWire = MW.Wire();
2912 LastEdge = MW.Edge();
2913 LastVertex = MW.Vertex();
2917 Handle(AIS_Shape) red = new AIS_Shape(RedWire);
2918 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
2919 myAISContext->Display(red,Standard_False);
2921 Handle(AIS_Shape) yellow = new AIS_Shape(YellowWire);
2922 myAISContext->SetColor(yellow,Quantity_NOC_YELLOW,Standard_False);
2923 myAISContext->Display(yellow,Standard_False);
2925 Handle(AIS_Shape) white = new AIS_Shape(WhiteWire);
2926 myAISContext->SetColor(white,Quantity_NOC_WHITE,Standard_False);
2927 myAISContext->Display(white,Standard_False);
2929 Handle(AIS_Shape) lastE = new AIS_Shape(LastEdge);
2930 myAISContext->SetWidth(lastE,3,Standard_False);
2931 myAISContext->SetColor(lastE,Quantity_NOC_RED,Standard_False);
2932 myAISContext->Display(lastE,Standard_False);
2934 Handle(AIS_Shape) lastV = new AIS_Shape(LastVertex);
2935 myAISContext->Display(lastV,Standard_False);
2939 TCollection_AsciiString Message ("\
2941 TopoDS_Wire RedWire,YellowWire,WhiteWire, \n\
2942 ExistingWire, ExistingWire2; \n\
2944 TopoDS_Edge Edge1,Edge2,Edge3,Edge4,Edge5,Edge6,Edge7,LastEdge; \n\
2945 TopoDS_Vertex LastVertex; \n\
2947 ////////////The red wire is build from a single edge \n\
2949 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),160,90); \n\
2950 Edge1 = BRepBuilderAPI_MakeEdge(Elips,0,PI/2); \n\
2952 RedWire = BRepBuilderAPI_MakeWire(Edge1); \n\
2954 ///////////the yellow wire is build from an existing wire and an edge \n\
2956 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80); \n\
2957 Edge2 = BRepBuilderAPI_MakeEdge(circle,0,PI); \n\
2959 ExistingWire = BRepBuilderAPI_MakeWire(Edge2); \n\
2961 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(90,20,30)); \n\
2963 BRepBuilderAPI_MakeWire MW1(ExistingWire,Edge3); \n\
2964 if (MW1.IsDone()) { \n\
2965 YellowWire = MW1; \n\
2968 ///the white wire is built with an existing wire and 3 edges. \n\
2969 ///we use the methods Add, Edge and Vertex from BRepBuilderAPI_MakeWire \n\
2970 ///in order to display the last edge and the last vertices we \n\
2971 ///add to the wire. \n\
2973 gp_Circ circle2(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)),200); \n\
2974 Edge4 = BRepBuilderAPI_MakeEdge(circle2,0,PI); \n\
2976 ExistingWire2 = BRepBuilderAPI_MakeWire(Edge4); \n\
2978 gp_Pnt P1(0,0,-200); \n\
2979 gp_Pnt P2(5,204,0); \n\
2980 Edge5 = BRepBuilderAPI_MakeEdge(P1,P2); \n\
2982 gp_Pnt P3(-15,20,15); \n\
2983 Edge6 = BRepBuilderAPI_MakeEdge(P2,P3); \n\
2984 gp_Pnt P4(15,20,0); \n\
2985 Edge7 = BRepBuilderAPI_MakeEdge(P3,P4); \n\
2987 BRepBuilderAPI_MakeWire MW; \n\
2988 MW.Add(ExistingWire2); \n\
2993 if (MW.IsDone()) { \n\
2994 WhiteWire = MW.Wire(); \n\
2995 LastEdge = MW.Edge(); \n\
2996 LastVertex = MW.Vertex(); \n\
3001 PocessTextInDialog("Make wire ", Message);
3004 void CModelingDoc::OnFace()
3006 AIS_ListOfInteractive aList;
3007 myAISContext->DisplayedObjects(aList);
3008 AIS_ListIteratorOfListOfInteractive aListIterator;
3009 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3010 myAISContext->Remove(aListIterator.Value());
3015 TopoDS_Face WhiteFace, BrownFace, RedFace, PinkFace;
3016 TopoDS_Edge Edge1, Edge2, Edge3, Edge4, Edge5, Edge6, Edge7;
3018 gp_Pnt P1, P2, P3, P4, P5, P6, P7;
3020 gp_Sphere sphere (gp_Ax3(gp_Pnt(0,0,0),gp_Dir(1,0,0)),150);
3022 WhiteFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);
3024 //////////////////////////////////
3026 P1.SetCoord(-15,200,10);
3027 P2.SetCoord(5,204,0);
3028 P3.SetCoord(15,200,0);
3029 P4.SetCoord(-15,20,15);
3030 P5.SetCoord(-5,20,0);
3031 P6.SetCoord(15,20,35);
3032 TColgp_Array2OfPnt array(1,3,1,2);
3033 array.SetValue(1,1,P1);
3034 array.SetValue(2,1,P2);
3035 array.SetValue(3,1,P3);
3036 array.SetValue(1,2,P4);
3037 array.SetValue(2,2,P5);
3038 array.SetValue(3,2,P6);
3039 Handle (Geom_BSplineSurface) curve = GeomAPI_PointsToBSplineSurface(array,3,8,GeomAbs_C2,0.001);
3041 RedFace = BRepBuilderAPI_MakeFace(curve);
3043 ////////////////////
3045 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80);
3046 Edge1 = BRepBuilderAPI_MakeEdge(circle,0,PI);
3048 Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(0,-10,40));
3049 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,-10,40),gp_Pnt(0,0,80));
3051 TopoDS_Wire YellowWire;
3052 BRepBuilderAPI_MakeWire MW1(Edge1,Edge2,Edge3);
3057 BrownFace = BRepBuilderAPI_MakeFace(YellowWire);
3062 P1.SetCoord(35,-200,40);
3063 P2.SetCoord(50,-204,30);
3064 P3.SetCoord(65,-200,30);
3065 P4.SetCoord(35,-20,45);
3066 P5.SetCoord(45,-20,30);
3067 P6.SetCoord(65,-20,65);
3068 TColgp_Array2OfPnt array2(1,3,1,2);
3069 array2.SetValue(1,1,P1);
3070 array2.SetValue(2,1,P2);
3071 array2.SetValue(3,1,P3);
3072 array2.SetValue(1,2,P4);
3073 array2.SetValue(2,2,P5);
3074 array2.SetValue(3,2,P6);
3076 Handle (Geom_BSplineSurface) BSplineSurf = GeomAPI_PointsToBSplineSurface(array2,3,8,GeomAbs_C2,0.001);
3078 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(BSplineSurf);
3081 gp_Pnt2d P12d(0.9,0.1);
3082 gp_Pnt2d P22d(0.2,0.7);
3083 gp_Pnt2d P32d(0.02,0.1);
3085 Handle (Geom2d_Line) line1 = new Geom2d_Line(P12d,gp_Dir2d((0.2-0.9),(0.7-0.1)));
3086 Handle (Geom2d_Line) line2 = new Geom2d_Line(P22d,gp_Dir2d((0.02-0.2),(0.1-0.7)));
3087 Handle (Geom2d_Line) line3 = new Geom2d_Line(P32d,gp_Dir2d((0.9-0.02),(0.1-0.1)));
3090 //Edges are on the BSpline surface
3091 Edge1 = BRepBuilderAPI_MakeEdge(line1,BSplineSurf,0,P12d.Distance(P22d));
3092 Edge2 = BRepBuilderAPI_MakeEdge(line2,BSplineSurf,0,P22d.Distance(P32d));
3093 Edge3 = BRepBuilderAPI_MakeEdge(line3,BSplineSurf,0,P32d.Distance(P12d));
3095 Wire1 = BRepBuilderAPI_MakeWire(Edge1,Edge2,Edge3);
3097 PinkFace = BRepBuilderAPI_MakeFace(aFace,Wire1);
3098 BRepLib::BuildCurves3d(PinkFace);
3100 BRepTools::Write(PinkFace,"E:\\temp\\PinkFace.rle");
3103 /////////////Display
3104 Handle(AIS_Shape) white = new AIS_Shape(WhiteFace);
3105 myAISContext->SetColor(white,Quantity_NOC_WHITE,Standard_False);
3106 myAISContext->SetMaterial(white,Graphic3d_NOM_PLASTIC,Standard_False);
3107 myAISContext->Display(white,Standard_False);
3109 Handle(AIS_Shape) red = new AIS_Shape(RedFace);
3110 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
3111 myAISContext->SetMaterial(red,Graphic3d_NOM_PLASTIC,Standard_False);
3112 myAISContext->Display(red,Standard_False);
3114 Handle(AIS_Shape) brown = new AIS_Shape(BrownFace);
3115 myAISContext->SetColor(brown,Quantity_NOC_BROWN,Standard_False);
3116 myAISContext->SetMaterial(brown,Graphic3d_NOM_PLASTIC,Standard_False);
3117 myAISContext->Display(brown,Standard_False);
3119 Handle(AIS_Shape) pink = new AIS_Shape(PinkFace);
3120 myAISContext->SetColor(pink,Quantity_NOC_HOTPINK,Standard_False);
3121 myAISContext->SetMaterial(pink,Graphic3d_NOM_PLASTIC,Standard_False);
3122 myAISContext->Display(pink,Standard_False);
3127 TCollection_AsciiString Message ("\
3129 TopoDS_Face WhiteFace, BrownFace, RedFace, PinkFace; \n\
3130 TopoDS_Edge Edge1, Edge2, Edge3, Edge4, Edge5, Edge6, Edge7; \n\
3131 TopoDS_Wire Wire1; \n\
3132 gp_Pnt P1, P2, P3, P4, P5, P6, P7; \n\
3134 ////////The white Face \n\
3136 gp_Sphere sphere (gp_Ax3(gp_Pnt(0,0,0),gp_Dir(1,0,0)),150); \n\
3138 WhiteFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9); \n\
3140 ////////The red face \n\
3142 P1.SetCoord(-15,200,10); \n\
3143 P2.SetCoord(5,204,0); \n\
3144 P3.SetCoord(15,200,0); \n\
3145 P4.SetCoord(-15,20,15); \n\
3146 P5.SetCoord(-5,20,0); \n\
3147 P6.SetCoord(15,20,35); \n\
3148 TColgp_Array2OfPnt array(1,3,1,2); \n\
3149 array.SetValue(1,1,P1); \n\
3150 array.SetValue(2,1,P2); \n\
3151 array.SetValue(3,1,P3); \n\
3152 array.SetValue(1,2,P4); \n\
3153 array.SetValue(2,2,P5); \n\
3154 array.SetValue(3,2,P6); \n\
3155 Handle (Geom_BSplineSurface) curve = GeomAPI_PointsToBSplineSurface(array,3,8,GeomAbs_C2,0.001); \n\
3157 RedFace = BRepBuilderAPI_MakeFace(curve); \n\
3159 ////////The brown face \n\
3161 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80); \n\
3162 Edge1 = BRepBuilderAPI_MakeEdge(circle,0,PI); \n\
3164 Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(0,-10,40)); \n\
3165 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,-10,40),gp_Pnt(0,0,80)); \n\
3167 TopoDS_Wire YellowWire; \n\
3168 BRepBuilderAPI_MakeWire MW1(Edge1,Edge2,Edge3); \n\
3169 if (MW1.IsDone()) { \n\
3170 YellowWire = MW1; \n\
3173 BrownFace = BRepBuilderAPI_MakeFace(YellowWire); \n\
3176 ////////The pink face \n\
3178 P1.SetCoord(35,-200,40); \n\
3179 P2.SetCoord(50,-204,30); \n\
3180 P3.SetCoord(65,-200,30); \n\
3181 P4.SetCoord(35,-20,45); \n\
3182 P5.SetCoord(45,-20,30); \n\
3183 P6.SetCoord(65,-20,65); \n\
3184 TColgp_Array2OfPnt array2(1,3,1,2); \n\
3185 array2.SetValue(1,1,P1); \n\
3186 array2.SetValue(2,1,P2); \n\
3187 array2.SetValue(3,1,P3); \n\
3188 array2.SetValue(1,2,P4); \n\
3189 array2.SetValue(2,2,P5); \n\
3190 array2.SetValue(3,2,P6); \n\
3192 Handle (Geom_BSplineSurface) BSplineSurf = GeomAPI_PointsToBSplineSurface(array2,3,8,GeomAbs_C2,0.001); \n\
3194 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(BSplineSurf); \n\
3197 gp_Pnt2d P12d(0.9,0.1); \n\
3198 gp_Pnt2d P22d(0.2,0.7); \n\
3199 gp_Pnt2d P32d(0.02,0.1); \n\
3201 Handle (Geom2d_Line) line1= \n\
3202 new Geom2d_Line(P12d,gp_Dir2d((0.2-0.9),(0.7-0.1))); \n\
3203 Handle (Geom2d_Line) line2= \n\
3204 new Geom2d_Line(P22d,gp_Dir2d((0.02-0.2),(0.1-0.7))); \n\
3205 Handle (Geom2d_Line) line3= \n\
3206 new Geom2d_Line(P32d,gp_Dir2d((0.9-0.02),(0.1-0.1))); \n\
3208 //Edges are on the BSpline surface \n\
3209 Edge1 = BRepBuilderAPI_MakeEdge(line1,BSplineSurf,0,P12d.Distance(P22d)); \n\
3210 Edge2 = BRepBuilderAPI_MakeEdge(line2,BSplineSurf,0,P22d.Distance(P32d)); \n\
3211 Edge3 = BRepBuilderAPI_MakeEdge(line3,BSplineSurf,0,P32d.Distance(P12d)); \n\
3213 Wire1 = BRepBuilderAPI_MakeWire(Edge1,Edge2,Edge3); \n\
3214 Wire1.Reverse(); \n\
3215 PinkFace = BRepBuilderAPI_MakeFace(aFace,Wire1); \n\
3216 BRepLib::BuildCurves3d(PinkFace); \n\
3220 PocessTextInDialog("Make face ", Message);
3223 void CModelingDoc::OnShell()
3225 AIS_ListOfInteractive aList;
3226 myAISContext->DisplayedObjects(aList);
3227 AIS_ListIteratorOfListOfInteractive aListIterator;
3228 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3229 myAISContext->Remove(aListIterator.Value());
3232 TColgp_Array2OfPnt Poles(1,2,1,4);
3233 Poles.SetValue(1,1,gp_Pnt(0,0,0));
3234 Poles.SetValue(1,2,gp_Pnt(0,10,2));
3235 Poles.SetValue(1,3,gp_Pnt(0,20,10));
3236 Poles.SetValue(1,4,gp_Pnt(0,30,0));
3237 Poles.SetValue(2,1,gp_Pnt(10,0,5));
3238 Poles.SetValue(2,2,gp_Pnt(10,10,3));
3239 Poles.SetValue(2,3,gp_Pnt(10,20,20));
3240 Poles.SetValue(2,4,gp_Pnt(10,30,0));
3242 TColStd_Array1OfReal UKnots(1,2);
3243 UKnots.SetValue(1,0);
3244 UKnots.SetValue(2,1);
3246 TColStd_Array1OfInteger UMults(1,2);
3247 UMults.SetValue(1,2);
3248 UMults.SetValue(2,2);
3250 TColStd_Array1OfReal VKnots(1,3);
3251 VKnots.SetValue(1,0);
3252 VKnots.SetValue(2,1);
3253 VKnots.SetValue(3,2);
3255 TColStd_Array1OfInteger VMults(1,3);
3256 VMults.SetValue(1,3);
3257 VMults.SetValue(2,1);
3258 VMults.SetValue(3,3);
3260 Standard_Integer UDegree(1);
3261 Standard_Integer VDegree(2);
3263 Handle (Geom_BSplineSurface) BSpline = new Geom_BSplineSurface(Poles,UKnots,VKnots,UMults,VMults,UDegree,VDegree);
3265 TopoDS_Face WhiteFace = BRepBuilderAPI_MakeFace(BSpline);
3268 Handle(AIS_Shape) white = new AIS_Shape(WhiteFace);
3269 myAISContext->SetColor(white,Quantity_NOC_WHITE);
3270 myAISContext->SetMaterial(white,Graphic3d_NOM_PLASTIC,Standard_False);
3271 myAISContext->SetTransparency(white,0.7);
3272 myAISContext->Display(white,Standard_False);
3275 TopoDS_Shell aShell = BRepBuilderAPI_MakeShell(BSpline);
3276 Handle(AIS_Shape) anAISShell = new AIS_Shape(aShell);
3277 myAISContext->SetDisplayMode(anAISShell,0);
3278 myAISContext->Display(anAISShell,Standard_False);
3279 //myAISContext->SetCurrentObject(anAISShell);
3283 TCollection_AsciiString Message ("\
3285 TColgp_Array2OfPnt Poles(1,2,1,4); \n\
3286 Poles.SetValue(1,1,gp_Pnt(0,0,0)); \n\
3287 Poles.SetValue(1,2,gp_Pnt(0,10,2)); \n\
3288 Poles.SetValue(1,3,gp_Pnt(0,20,10)); \n\
3289 Poles.SetValue(1,4,gp_Pnt(0,30,0)); \n\
3290 Poles.SetValue(2,1,gp_Pnt(10,0,5)); \n\
3291 Poles.SetValue(2,2,gp_Pnt(10,10,3)); \n\
3292 Poles.SetValue(2,3,gp_Pnt(10,20,20)); \n\
3293 Poles.SetValue(2,4,gp_Pnt(10,30,0)); \n\
3295 TColStd_Array1OfReal UKnots(1,2); \n\
3296 UKnots.SetValue(1,0); \n\
3297 UKnots.SetValue(2,1); \n\
3299 TColStd_Array1OfInteger UMults(1,2); \n\
3300 UMults.SetValue(1,2); \n\
3301 UMults.SetValue(2,2); \n\
3303 TColStd_Array1OfReal VKnots(1,3); \n\
3304 VKnots.SetValue(1,0); \n\
3305 VKnots.SetValue(2,1); \n\
3306 VKnots.SetValue(3,2); \n\
3308 TColStd_Array1OfInteger VMults(1,3); \n\
3309 VMults.SetValue(1,3); \n\
3310 VMults.SetValue(2,1); \n\
3311 VMults.SetValue(3,3); \n\
3313 Standard_Integer UDegree(1); \n\
3314 Standard_Integer VDegree(2); \n\
3316 Handle (Geom_BSplineSurface) BSpline = new Geom_BSplineSurface(Poles,UKnots,VKnots,UMults,VMults,UDegree,VDegree); \n\
3318 TopoDS_Shell aShell = BRepBuilderAPI_MakeShell(BSpline); \n\
3322 PocessTextInDialog("Make shell", Message);
3326 void CModelingDoc::OnCompound()
3328 AIS_ListOfInteractive aList;
3329 myAISContext->DisplayedObjects(aList);
3330 AIS_ListIteratorOfListOfInteractive aListIterator;
3331 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3332 myAISContext->Remove(aListIterator.Value());
3335 BRep_Builder builder;
3336 TopoDS_Compound Comp;
3337 builder.MakeCompound(Comp);
3339 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));
3340 builder.Add(Comp,aVertex);
3342 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));
3343 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(line,-20,10);
3344 builder.Add(Comp,anEdge);
3346 gp_Sphere sphere (gp_Ax3(gp_Pnt(-80,0,0),gp_Dir(1,0,0)),150);
3347 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);
3348 builder.Add(Comp,aFace);
3350 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(-60,0,0),30,60,40);
3351 builder.Add(Comp,aBox);
3353 Handle(AIS_Shape) white = new AIS_Shape(Comp);
3354 myAISContext->SetDisplayMode(white,0);
3355 myAISContext->Display(white,Standard_False);
3360 TCollection_AsciiString Message ("\
3362 BRep_Builder builder; \n\
3363 TopoDS_Compound Comp; \n\
3364 builder.MakeCompound(Comp); \n\
3366 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30)); \n\
3367 builder.Add(Comp,aVertex); \n\
3369 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0))); \n\
3370 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(line,-20,10); \n\
3371 builder.Add(Comp,anEdge); \n\
3373 gp_Sphere sphere (gp_Ax3(gp_Pnt(-80,0,0),gp_Dir(1,0,0)),150); \n\
3374 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9); \n\
3375 builder.Add(Comp,aFace); \n\
3377 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(-60,0,0),30,60,40); \n\
3378 builder.Add(Comp,aBox); \n\
3382 PocessTextInDialog("Make compound ", Message);
3390 void CModelingDoc::OnSewing()
3392 AIS_ListOfInteractive aList;
3393 myAISContext->DisplayedObjects(aList);
3394 AIS_ListIteratorOfListOfInteractive aListIterator;
3395 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3396 myAISContext->Remove(aListIterator.Value());
3401 Handle(Geom_Plane) Pi=new Geom_Plane(P,V);
3402 Handle(Geom_RectangularTrimmedSurface) GeometricSurface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);
3403 TopoDS_Shape FirstShape = BRepBuilderAPI_MakeFace(GeometricSurface);
3405 Handle(AIS_Shape) white1 = new AIS_Shape(FirstShape);
3407 myAISContext->SetColor(white1,Quantity_NOC_RED,Standard_False);
3408 myAISContext->SetMaterial(white1,Graphic3d_NOM_PLASTIC,Standard_False);
3409 myAISContext->SetTransparency(white1,0.4,Standard_False);
3410 myAISContext->Display(white1,Standard_False);
3416 gp_Pnt P4(25,12,85);
3417 gp_Pnt P5(100,0,80);
3418 gp_Pnt P6(135,-12,85);
3420 TColgp_Array2OfPnt Array(1,3,1,2);
3421 Array.SetValue(1,1,P1);
3422 Array.SetValue(2,1,P2);
3423 Array.SetValue(3,1,P3);
3424 Array.SetValue(1,2,P4);
3425 Array.SetValue(2,2,P5);
3426 Array.SetValue(3,2,P6);
3428 Handle (Geom_BSplineSurface) aSurf = GeomAPI_PointsToBSplineSurface(Array,3,8,GeomAbs_C2,0.00001);
3429 TopoDS_Shape SecondShape = BRepBuilderAPI_MakeFace(aSurf);
3431 Handle(AIS_Shape) white2 = new AIS_Shape(SecondShape);
3433 myAISContext->SetColor(white2,Quantity_NOC_YELLOW,Standard_False);
3434 myAISContext->SetMaterial(white2,Graphic3d_NOM_PLASTIC,Standard_False);
3435 myAISContext->SetTransparency(white2,0.4,Standard_False);
3436 myAISContext->Display(white2,Standard_False);
3440 BRepOffsetAPI_Sewing aMethod;
3441 aMethod.Add(FirstShape);
3442 aMethod.Add(SecondShape);
3446 TopoDS_Shape sewedShape = aMethod.SewedShape();
3448 Handle(AIS_Shape) result = new AIS_Shape(sewedShape);
3449 myAISContext->SetDisplayMode(result,0,Standard_False);
3450 myAISContext->Display(result,Standard_False);
3454 TCollection_AsciiString Message ("\
3456 ///////The first shape \n\
3458 gp_Pnt P(0,0,0); \n\
3459 gp_Vec V(0,0,1); \n\
3460 Handle(Geom_Plane) Pi=new Geom_Plane(P,V); \n\
3461 Handle(Geom_RectangularTrimmedSurface) GeometricSurface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.); \n\
3462 TopoDS_Shape FirstShape = BRepBuilderAPI_MakeFace(GeometricSurface); \n\
3464 ///////The second shape \n\
3466 gp_Pnt P1(0,0,0); \n\
3467 gp_Pnt P2(50,0,0); \n\
3468 gp_Pnt P3(100,0,0); \n\
3469 gp_Pnt P4(25,12,85); \n\
3470 gp_Pnt P5(100,0,80); \n\
3471 gp_Pnt P6(135,-12,85); \n\
3473 TColgp_Array2OfPnt Array(1,3,1,2); \n\
3474 Array.SetValue(1,1,P1); \n\
3475 Array.SetValue(2,1,P2); \n\
3476 Array.SetValue(3,1,P3); \n\
3477 Array.SetValue(1,2,P4); \n\
3478 Array.SetValue(2,2,P5); \n\
3479 Array.SetValue(3,2,P6); \n\
3481 Handle (Geom_BSplineSurface) aSurf = GeomAPI_PointsToBSplineSurface(Array,3,8,GeomAbs_C2,0.00001); \n\
3482 TopoDS_Shape SecondShape = BRepBuilderAPI_MakeFace(aSurf); \n\
3484 BRepOffsetAPI_Sewing aMethod; \n\
3485 aMethod.Add(FirstShape); \n\
3486 aMethod.Add(SecondShape); \n\
3488 aMethod.Perform(); \n\
3490 TopoDS_Shape sewedShape = aMethod.SewedShape(); \n\
3494 PocessTextInDialog("Sew faces ", Message);
3504 void CModelingDoc::OnBuilder()
3506 AIS_ListOfInteractive aList;
3507 myAISContext->DisplayedObjects(aList);
3508 AIS_ListIteratorOfListOfInteractive aListIterator;
3509 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3510 myAISContext->Remove(aListIterator.Value());
3513 //The tolerance is the tolerance of confusion
3514 Standard_Real precision = Precision::Confusion();
3519 //Build the vertices
3520 TopoDS_Vertex V000, V001, V010, V011, V100, V101, V110, V111;
3521 B.MakeVertex(V000,gp_Pnt(0,0,0),precision);
3522 B.MakeVertex(V001,gp_Pnt(0,0,100),precision);
3523 B.MakeVertex(V010,gp_Pnt(0,150,0),precision);
3524 B.MakeVertex(V011,gp_Pnt(0,150,100),precision);
3525 B.MakeVertex(V100,gp_Pnt(200,0,0),precision);
3526 B.MakeVertex(V101,gp_Pnt(200,0,100),precision);
3527 B.MakeVertex(V110,gp_Pnt(200,150,0),precision);
3528 B.MakeVertex(V111,gp_Pnt(200,150,100),precision);
3531 //the edges are oriented as the axis X,Y,Z
3532 TopoDS_Edge EX00, EX01, EX10, EX11;
3533 TopoDS_Edge EY00, EY01, EY10, EY11;
3534 TopoDS_Edge EZ00, EZ01, EZ10, EZ11;
3535 Handle (Geom_Line) L;
3538 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(1,0,0));
3539 B.MakeEdge(EX00,L,precision);
3540 V000.Orientation(TopAbs_FORWARD);
3541 V100.Orientation(TopAbs_REVERSED);
3545 B.UpdateVertex(V000,0,EX00,precision);
3546 B.UpdateVertex(V100,200,EX00,precision);
3549 L = new Geom_Line(gp_Pnt(0,150,0),gp_Dir(1,0,0));
3550 B.MakeEdge(EX10,L,precision);
3551 V010.Orientation(TopAbs_FORWARD);
3552 V110.Orientation(TopAbs_REVERSED);
3556 B.UpdateVertex(V010,0,EX10,precision);
3557 B.UpdateVertex(V110,200,EX10,precision);
3560 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(0,1,0));
3561 B.MakeEdge(EY00,L,precision);
3562 V000.Orientation(TopAbs_FORWARD);
3563 V010.Orientation(TopAbs_REVERSED);
3567 B.UpdateVertex(V000,0,EY00,precision);
3568 B.UpdateVertex(V010,150,EY00,precision);
3571 L = new Geom_Line(gp_Pnt(200,0,0),gp_Dir(0,1,0));
3572 B.MakeEdge(EY10,L,precision);
3573 V100.Orientation(TopAbs_FORWARD);
3574 V110.Orientation(TopAbs_REVERSED);
3578 B.UpdateVertex(V100,0,EY10,precision);
3579 B.UpdateVertex(V110,150,EY10,precision);
3582 L = new Geom_Line(gp_Pnt(0,0,100),gp_Dir(0,1,0));
3583 B.MakeEdge(EY01,L,precision);
3584 V001.Orientation(TopAbs_FORWARD);
3585 V011.Orientation(TopAbs_REVERSED);
3589 B.UpdateVertex(V001,0,EY01,precision);
3590 B.UpdateVertex(V011,150,EY01,precision);
3593 L = new Geom_Line(gp_Pnt(200,0,100),gp_Dir(0,1,0));
3594 B.MakeEdge(EY11,L,precision);
3595 V101.Orientation(TopAbs_FORWARD);
3596 V111.Orientation(TopAbs_REVERSED);
3600 B.UpdateVertex(V101,0,EY11,precision);
3601 B.UpdateVertex(V111,150,EY11,precision);
3604 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(0,0,1));
3605 B.MakeEdge(EZ00,L,precision);
3606 V000.Orientation(TopAbs_FORWARD);
3607 V001.Orientation(TopAbs_REVERSED);
3611 B.UpdateVertex(V000,0,EZ00,precision);
3612 B.UpdateVertex(V001,100,EZ00,precision);
3615 L = new Geom_Line(gp_Pnt(0,150,0),gp_Dir(0,0,1));
3616 B.MakeEdge(EZ01,L,precision);
3617 V010.Orientation(TopAbs_FORWARD);
3618 V011.Orientation(TopAbs_REVERSED);
3622 B.UpdateVertex(V010,0,EZ01,precision);
3623 B.UpdateVertex(V011,100,EZ01,precision);
3626 L = new Geom_Line(gp_Pnt(200,0,0),gp_Dir(0,0,1));
3627 B.MakeEdge(EZ10,L,precision);
3628 V100.Orientation(TopAbs_FORWARD);
3629 V101.Orientation(TopAbs_REVERSED);
3633 B.UpdateVertex(V100,0,EZ10,precision);
3634 B.UpdateVertex(V101,100,EZ10,precision);
3637 L = new Geom_Line(gp_Pnt(200,150,0),gp_Dir(0,0,1));
3638 B.MakeEdge(EZ11,L,precision);
3639 V110.Orientation(TopAbs_FORWARD);
3640 V111.Orientation(TopAbs_REVERSED);
3644 B.UpdateVertex(V110,0,EZ11,precision);
3645 B.UpdateVertex(V111,100,EZ11,precision);
3649 Handle (Geom_Circle) C;
3650 Standard_Real R = 100;
3653 C = new Geom_Circle(gp_Ax2(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
3654 B.MakeEdge(EX01,C,precision);
3655 V001.Orientation(TopAbs_FORWARD);
3656 V101.Orientation(TopAbs_REVERSED);
3660 B.UpdateVertex(V001,0,EX01,precision);
3661 B.UpdateVertex(V101,PI,EX01,precision);
3664 C = new Geom_Circle(gp_Ax2(gp_Pnt(100,150,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
3665 B.MakeEdge(EX11,C,precision);
3666 V011.Orientation(TopAbs_FORWARD);
3667 V111.Orientation(TopAbs_REVERSED);
3671 B.UpdateVertex(V011,0,EX11,precision);
3672 B.UpdateVertex(V111,PI,EX11,precision);
3674 //Build wire and faces
3675 //Faces normals are along the axis X,Y,Z
3676 TopoDS_Face FXMIN, FXMAX, FYMIN, FYMAX, FZMIN, FZMAX;
3678 Handle (Geom_Plane) P;
3679 Handle (Geom2d_Line) L2d;
3680 Handle (Geom2d_Circle) C2d;
3681 Handle (Geom_CylindricalSurface) S;
3684 P = new Geom_Plane(gp_Ax2(gp_Pnt(200,0,0),gp_Dir(1,0,0),gp_Dir(0,1,0)));
3685 B.MakeFace(FXMAX,P,precision);
3686 //the wire and the edges
3689 EY10.Orientation(TopAbs_FORWARD);
3692 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3693 B.UpdateEdge(EY10,L2d,FXMAX,precision);
3695 EZ11.Orientation(TopAbs_FORWARD);
3698 L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));
3699 B.UpdateEdge(EZ11,L2d,FXMAX,precision);
3701 EY11.Orientation(TopAbs_REVERSED);
3704 L2d = new Geom2d_Line(gp_Pnt2d(0,100),gp_Dir2d(1,0));
3705 B.UpdateEdge(EY11,L2d,FXMAX,precision);
3707 EZ10.Orientation(TopAbs_REVERSED);
3710 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3711 B.UpdateEdge(EZ10,L2d,FXMAX,precision);
3715 BRepTools::Write(FXMAX,"E:\\temp\\f1.rle");
3718 P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(-1,0,0),gp_Dir(0,0,1)));
3719 B.MakeFace(FXMIN,P,precision);
3720 //the wire and the edges
3723 EZ00.Orientation(TopAbs_FORWARD);
3726 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3727 B.UpdateEdge(EZ00,L2d,FXMIN,precision);
3729 EY01.Orientation(TopAbs_FORWARD);
3732 L2d = new Geom2d_Line(gp_Pnt2d(100,0),gp_Dir2d(0,1));
3733 B.UpdateEdge(EY01,L2d,FXMIN,precision);
3735 EZ01.Orientation(TopAbs_REVERSED);
3738 L2d = new Geom2d_Line(gp_Pnt2d(0,150),gp_Dir2d(1,0));
3739 B.UpdateEdge(EZ01,L2d,FXMIN,precision);
3741 EY00.Orientation(TopAbs_REVERSED);
3744 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3745 B.UpdateEdge(EY00,L2d,FXMIN,precision);
3752 P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0),gp_Dir(0,0,1)));
3753 B.MakeFace(FYMAX,P,precision);
3754 //the wire and the edges
3757 EZ00.Orientation(TopAbs_FORWARD);
3760 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3761 B.UpdateEdge(EZ00,L2d,FYMAX,precision);
3763 EX01.Orientation(TopAbs_FORWARD);
3766 C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(100,100),gp_Dir2d(0,-1)),100);
3767 B.UpdateEdge(EX01,C2d,FYMAX,precision);
3768 B.UpdateVertex(V001,0,EX01,FYMAX,precision);
3769 B.UpdateVertex(V101,PI,EX01,FYMAX,precision);
3771 EZ10.Orientation(TopAbs_REVERSED);
3774 L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
3775 B.UpdateEdge(EZ10,L2d,FYMAX,precision);
3777 EX00.Orientation(TopAbs_REVERSED);
3780 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3781 B.UpdateEdge(EX00,L2d,FYMAX,precision);
3789 P = new Geom_Plane(gp_Ax2(gp_Pnt(0,150,0),gp_Dir(0,1,0),gp_Dir(0,0,1)));
3790 B.MakeFace(FYMIN,P,precision);
3791 //the wire and the edges
3794 EZ01.Orientation(TopAbs_FORWARD);
3797 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3798 B.UpdateEdge(EZ01,L2d,FYMIN,precision);
3800 EX11.Orientation(TopAbs_FORWARD);
3803 C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(100,100),gp_Dir2d(0,-1)),100);
3804 B.UpdateEdge(EX11,C2d,FYMIN,precision);
3805 B.UpdateVertex(V011,0,EX11,FYMIN,precision);
3806 B.UpdateVertex(V111,PI,EX11,FYMIN,precision);
3808 EZ11.Orientation(TopAbs_REVERSED);
3811 L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
3812 B.UpdateEdge(EZ11,L2d,FYMIN,precision);
3814 EX10.Orientation(TopAbs_REVERSED);
3817 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3818 B.UpdateEdge(EX10,L2d,FYMIN,precision);
3823 P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,0,-1),gp_Dir(0,1,0)));
3824 B.MakeFace(FZMAX,P,precision);
3825 //the wire and the edges
3828 EY00.Orientation(TopAbs_FORWARD);
3831 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3832 B.UpdateEdge(EY00,L2d,FZMAX,precision);
3834 EX10.Orientation(TopAbs_FORWARD);
3837 L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));
3838 B.UpdateEdge(EX10,L2d,FZMAX,precision);
3840 EY10.Orientation(TopAbs_REVERSED);
3843 L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
3844 B.UpdateEdge(EY10,L2d,FZMAX,precision);
3846 EX00.Orientation(TopAbs_REVERSED);
3849 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3850 B.UpdateEdge(EX00,L2d,FZMAX,precision);
3856 S = new Geom_CylindricalSurface(gp_Ax3(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
3857 B.MakeFace(FZMIN,S,precision);
3859 //the wire and the edges
3862 EX01.Orientation(TopAbs_FORWARD);
3865 L2d = new Geom2d_Line(gp_Ax2d(gp_Pnt2d(0,0),gp_Dir2d(1,0)));
3866 B.UpdateEdge(EX01,L2d,FZMIN,precision);
3867 B.UpdateVertex(V001,0,EX01,FZMIN,precision);
3868 B.UpdateVertex(V101,PI,EX01,FZMIN,precision);
3870 EY11.Orientation(TopAbs_FORWARD);
3873 L2d = new Geom2d_Line(gp_Pnt2d(PI,0),gp_Dir2d(0,1));
3874 B.UpdateEdge(EY11,L2d,FZMIN,precision);
3876 EX11.Orientation(TopAbs_REVERSED);
3879 L2d = new Geom2d_Line(gp_Ax2d(gp_Pnt2d(0,150),gp_Dir2d(1,0)));
3880 B.UpdateEdge(EX11,L2d,FZMIN,precision);
3881 B.UpdateVertex(V111,PI,EX11,FZMIN,precision);
3882 B.UpdateVertex(V011,0,EX11,FZMIN,precision);
3884 EY01.Orientation(TopAbs_REVERSED);
3887 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3888 B.UpdateEdge(EY01,L2d,FZMIN,precision);
3892 FYMAX.Orientation(TopAbs_REVERSED);
3894 BRepTools::Write(FZMIN,"E:\\temp\\f3.rle");
3895 BRepTools::Write(FYMAX,"E:\\temp\\f2.rle");
3912 BRepTools::Write(Sol,"e://temp//solid");
3913 Handle(AIS_Shape) borne = new AIS_Shape(Sol);
3914 myAISContext->SetDisplayMode(borne,1);
3915 myAISContext->SetColor(borne,Quantity_NOC_RED);
3916 myAISContext->SetMaterial(borne,Graphic3d_NOM_PLASTIC,Standard_False);
3917 myAISContext->Display(borne,Standard_False);
3921 TCollection_AsciiString Message ("\
3923 //The tolerance is 0.01 \n\
3924 Standard_Real precision(0.01); \n\
3929 //Build the vertices \n\
3930 TopoDS_Vertex V000, V001, V010, V011, V100, V101, V110, V111; \n\
3931 B.MakeVertex(V000,gp_Pnt(0,0,0),precision); \n\
3932 B.MakeVertex(V001,gp_Pnt(0,0,100),precision); \n\
3933 B.MakeVertex(V010,gp_Pnt(0,150,0),precision); \n\
3934 B.MakeVertex(V011,gp_Pnt(0,150,100),precision); \n\
3935 B.MakeVertex(V100,gp_Pnt(200,0,0),precision); \n\
3936 B.MakeVertex(V101,gp_Pnt(200,0,100),precision); \n\
3937 B.MakeVertex(V110,gp_Pnt(200,150,0),precision); \n\
3938 B.MakeVertex(V111,gp_Pnt(200,150,100),precision); \n\
3940 //Build the edges \n\
3941 //the edges are oriented as the axis X,Y,Z \n\
3942 TopoDS_Edge EX00, EX01, EX10, EX11; \n\
3943 TopoDS_Edge EY00, EY01, EY10, EY11; \n\
3944 TopoDS_Edge EZ00, EZ01, EZ10, EZ11; \n\
3945 Handle (Geom_Line) L; \n\
3948 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(1,0,0)); \n\
3949 B.MakeEdge(EX00,L,precision); \n\
3950 V000.Orientation(TopAbs_FORWARD); \n\
3951 V100.Orientation(TopAbs_REVERSED); \n\
3952 B.Add(EX00,V000); \n\
3953 B.Add(EX00,V100); \n\
3955 B.UpdateVertex(V000,0,EX00,precision); \n\
3956 B.UpdateVertex(V100,200,EX00,precision); \n\
3958 //Idem for all the linear edges... \n\
3960 //Circular Edges \n\
3961 Handle (Geom_Circle) C; \n\
3962 Standard_Real R = 100; \n\
3965 C = new Geom_Circle(gp_Ax2(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100); \n\
3966 B.MakeEdge(EX01,C,precision); \n\
3967 V001.Orientation(TopAbs_FORWARD); \n\
3968 V101.Orientation(TopAbs_REVERSED); \n\
3969 B.Add(EX01,V001); \n\
3970 B.Add(EX01,V101); \n\
3972 B.UpdateVertex(V001,0,EX01,precision); \n\
3973 B.UpdateVertex(V101,PI,EX01,precision); \n\
3977 //Build wire and faces \n\
3978 //Faces normals are along the axis X,Y,Z \n\
3979 TopoDS_Face FXMIN, FXMAX, FYMIN, FYMAX, FZMIN, FZMAX; \n\
3981 Handle (Geom_Plane) P; \n\
3982 Handle (Geom2d_Line) L2d; \n\
3983 Handle (Geom2d_Circle) C2d; \n\
3984 Handle (Geom_CylindricalSurface) S; \n\
3987 P = new Geom_Plane(gp_Ax2(gp_Pnt(200,0,0),gp_Dir(1,0,0),gp_Dir(0,1,0))); \n\
3988 B.MakeFace(FXMAX,P,precision); \n\
3989 //the wire and the edges \n\
3990 B.MakeWire (W); \n");
3993 EY10.Orientation(TopAbs_FORWARD); \n\
3996 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0)); \n\
3997 B.UpdateEdge(EY10,L2d,FXMAX,precision); \n\
3999 EZ11.Orientation(TopAbs_FORWARD); \n\
4002 L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1)); \n\
4003 B.UpdateEdge(EZ11,L2d,FXMAX,precision); \n\
4005 EY11.Orientation(TopAbs_REVERSED); \n\
4008 L2d = new Geom2d_Line(gp_Pnt2d(0,100),gp_Dir2d(1,0)); \n\
4009 B.UpdateEdge(EY11,L2d,FXMAX,precision); \n\
4011 EZ10.Orientation(TopAbs_REVERSED); \n\
4014 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1)); \n\
4015 B.UpdateEdge(EZ10,L2d,FXMAX,precision); \n\
4019 //Idem for other faces... \n\
4022 TopoDS_Shell Sh; \n\
4023 B.MakeShell(Sh); \n\
4024 B.Add(Sh,FXMAX); \n\
4025 B.Add(Sh,FXMIN); \n\
4026 B.Add(Sh,FYMAX); \n\
4027 B.Add(Sh,FYMIN); \n\
4028 B.Add(Sh,FZMAX); \n\
4029 B.Add(Sh,FZMIN); \n\
4032 TopoDS_Solid Sol; \n\
4033 B.MakeSolid(Sol); \n\
4038 PocessTextInDialog("Make a shape with a builder", Message);
4042 void CModelingDoc::OnGeometrie()
4044 AIS_ListOfInteractive aList;
4045 myAISContext->DisplayedObjects(aList);
4046 AIS_ListIteratorOfListOfInteractive aListIterator;
4047 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4048 myAISContext->Remove(aListIterator.Value());
4051 //geometrie of a vertex
4052 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(0,120,70));
4053 gp_Pnt GeometricPoint = BRep_Tool::Pnt(aVertex);
4055 Handle(AIS_Shape) vert = new AIS_Shape(aVertex);
4056 myAISContext->Display(vert,Standard_False);
4060 //geometrie of an edge
4061 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(100,50,250),gp_Pnt(-30,-100,-50));
4062 Handle(AIS_Shape) yellow = new AIS_Shape(anEdge);
4063 myAISContext->SetWidth(yellow,2,Standard_False);
4064 myAISContext->Display(yellow,Standard_False);
4068 TopLoc_Location location;
4069 Standard_Real first, last;
4070 Handle (Geom_Curve) aCurve = BRep_Tool::Curve(anEdge,location,first,last);
4071 TopoDS_Edge anEdgeDS = BRepBuilderAPI_MakeEdge(aCurve);
4073 Handle (Geom_Line) aLine = Handle (Geom_Line)::DownCast(aCurve);
4074 if (!aLine.IsNull()) {
4075 Handle (AIS_Line) DispLine = new AIS_Line(aLine);
4076 myAISContext->Display(DispLine,Standard_False);
4081 //geometrie of a face
4082 gp_Pnt P(-20,-20,-20);
4084 Handle(Geom_Plane) Pi=new Geom_Plane(P,V);
4085 Handle(Geom_RectangularTrimmedSurface) Surface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);
4086 TopoDS_Face RedFace = BRepBuilderAPI_MakeFace(Surface);
4088 Handle(AIS_Shape) red = new AIS_Shape(RedFace);
4089 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
4090 myAISContext->SetMaterial(red,Graphic3d_NOM_PLASTIC,Standard_False);
4091 myAISContext->Display(red,Standard_False);
4095 TopLoc_Location location2;
4096 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(RedFace,location2);
4098 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);
4099 if (!aPlane.IsNull()) {
4100 Handle (AIS_Plane) DispPlane = new AIS_Plane(aPlane);
4101 myAISContext->Display(DispPlane,Standard_False);
4110 TCollection_AsciiString Message ("\
4112 ///////geometrie of a vertex \n\
4113 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(0,120,70)); \n\
4114 gp_Pnt GeometricPoint = BRep_Tool::Pnt(aVertex); \n\
4116 ///////geometrie of an edge \n\
4117 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(100,50,250),gp_Pnt(-30,-100,-50)); \n\
4119 TopLoc_Location location; \n\
4120 Standard_Real first, last; \n\
4121 Handle (Geom_Curve) aCurve = BRep_Tool::Curve(anEdge,location,first,last); \n\
4122 TopoDS_Edge anEdgeDS = BRepBuilderAPI_MakeEdge(aCurve); \n\
4124 Handle (Geom_Line) aLine = Handle (Geom_Line)::DownCast(aCurve); \n\
4125 if (!aLine.IsNull()) { \n\
4126 Handle (AIS_Line) DispLine = new AIS_Line(aLine); \n\
4129 ///////geometrie of a face \n\
4130 gp_Pnt P(-20,-20,-20); \n\
4131 gp_Vec V(0,0,1); \n\
4132 Handle(Geom_Plane) Pi=new Geom_Plane(P,V); \n\
4133 Handle(Geom_RectangularTrimmedSurface) Surface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.); \n\
4134 TopoDS_Face RedFace = BRepBuilderAPI_MakeFace(Surface); \n\
4136 TopLoc_Location location2; \n\
4137 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(RedFace,location2); \n\
4139 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface); \n\
4140 if (!aPlane.IsNull()) { \n\
4141 Handle (AIS_Plane) DispPlane = new AIS_Plane(aPlane); \n\
4146 PocessTextInDialog("Recover the geometrie of vertex, edge and face ", Message);
4151 void CModelingDoc::OnExplorer()
4153 AIS_ListOfInteractive aList;
4154 myAISContext->DisplayedObjects(aList);
4155 AIS_ListIteratorOfListOfInteractive aListIterator;
4156 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4157 myAISContext->Remove(aListIterator.Value());
4160 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100,100,100);
4161 Standard_Integer j(8);
4162 Handle(AIS_Shape) theBox = new AIS_Shape(aBox);
4163 myAISContext->SetColor(theBox,Quantity_NOC_RED,Standard_False);
4164 myAISContext->SetMaterial(theBox,Graphic3d_NOM_PLASTIC,Standard_False);
4165 myAISContext->Display(theBox,Standard_False);
4169 for (TopExp_Explorer exp (aBox,TopAbs_FACE);exp.More();exp.Next()) {
4170 TopoDS_Face aCurrentFace = TopoDS::Face(exp.Current());
4172 //test the orientation of the current face
4173 TopAbs_Orientation orient = aCurrentFace.Orientation();
4175 //Recover the geometric plane
4176 TopLoc_Location location;
4177 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(aCurrentFace,location);
4179 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);
4181 //Build an AIS_Shape with a new color
4182 Handle(AIS_Shape) theMovingFace = new AIS_Shape(aCurrentFace);
4183 Quantity_NameOfColor aCurrentColor = (Quantity_NameOfColor)j;
4184 myAISContext->SetColor(theMovingFace,aCurrentColor,Standard_False);
4185 myAISContext->SetMaterial(theMovingFace,Graphic3d_NOM_PLASTIC,Standard_False);
4186 //Find the normal vector of each face
4187 gp_Pln agpPlane = aPlane->Pln();
4188 gp_Ax1 norm = agpPlane.Axis();
4189 gp_Dir dir = norm.Direction();
4192 // new in 2.0 ... AIS_ConnectedInteractive wants a TopLoc_Location instead of a Geom_Transformation
4193 // TopLoc_Location aLocation;
4194 // Handle (AIS_ConnectedInteractive) theTransformedDisplay = new AIS_ConnectedInteractive();
4195 // theTransformedDisplay->Connect(theMovingFace,theMove);
4196 // theTransformedDisplay->Connect(theMovingFace, aLocation);
4197 // Handle (Geom_Transformation) theMove = new Geom_Transformation(aLocation->Transformation());
4199 // myAISContext->Display(theTransformedDisplay);
4201 TopLoc_Location aLocation;
4202 Handle (AIS_ConnectedInteractive) theTransformedDisplay = new AIS_ConnectedInteractive();
4203 theTransformedDisplay->Connect(theMovingFace, aLocation);
4206 // = myAISContext->Location(theMovingFace);
4207 Handle (Geom_Transformation) theMove = new Geom_Transformation(aLocation.Transformation());
4208 myAISContext->Display(theTransformedDisplay,Standard_False);
4212 for (Standard_Integer i=1;i<=30;i++) {
4214 //Build a transformation on the display
4215 // theMove->SetTranslation(move*i);
4217 // if (orient==TopAbs_FORWARD) theTransformedDisplay->SetTransformation(theMove);
4218 // else theTransformedDisplay->SetTransformation(theMove->Inverted());
4220 // myAISContext->Redisplay(theTransformedDisplay);
4223 theMove->SetTranslation(move*i);
4224 if (orient==TopAbs_FORWARD) myAISContext->SetLocation(theTransformedDisplay,TopLoc_Location(theMove->Trsf()));
4225 else myAISContext->SetLocation(theTransformedDisplay,TopLoc_Location(theMove->Inverted()->Trsf()));
4227 myAISContext->Redisplay(theTransformedDisplay,Standard_False);
4231 //myAISContext->Erase(theBox,Standard_True,Standard_False);
4232 myAISContext->Remove(theBox);
4236 TCollection_AsciiString Message ("\
4238 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100,100,100); \n\
4240 for (TopExp_Explorer exp (aBox,TopAbs_FACE);exp.More();exp.Next()) { \n\
4241 TopoDS_Face aCurrentFace = TopoDS::Face(exp.Current()); \n\
4243 //Recover the geometric plane \n\
4244 TopLoc_Location location; \n\
4245 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(aCurrentFace,location); \n\
4247 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface); \n\
4250 PocessTextInDialog("Explode a shape in faces ", Message);
4254 /* =================================================================================
4255 ==================== A N A L Y S I S ========================================
4256 ================================================================================= */
4258 void CModelingDoc::OnValid()
4260 AIS_ListOfInteractive aList;
4261 myAISContext->DisplayedObjects(aList);
4262 AIS_ListIteratorOfListOfInteractive aListIterator;
4263 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4264 myAISContext->Remove(aListIterator.Value());
4267 TopoDS_Shape S = BRepPrimAPI_MakeBox(200.,300.,150.);
4268 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4269 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4270 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4271 myAISContext->Display(ais1,Standard_False);
4274 TCollection_AsciiString Message ("\
4276 TopoDS_Shape S = BRepPrimI_MakeBox(200.,300.,150.);\n\
4277 Standard_Boolean theShapeIsValid = BRepAlgo::IsValid(S);\n\
4278 if ( theShapeIsValid )\n\
4280 MessageBox(\"The Shape Is Valid !! \",\"Checking Shape\");\n\
4284 MessageBox(\"The Shape Is NOT Valid !! \",\"Checking Shape\");\n\
4287 PocessTextInDialog("Check a shape", Message);
4289 Standard_Boolean theShapeIsValid = BRepAlgo::IsValid(S);
4290 if ( theShapeIsValid )
4292 MessageBox(0,"The Shape Is Valid !! ","Checking Shape",MB_OK);
4296 MessageBox(0,"The Shape Is NOT Valid !! ","Checking Shape",MB_OK);
4303 void CModelingDoc::OnLinear()
4305 AIS_ListOfInteractive aList;
4306 myAISContext->DisplayedObjects(aList);
4307 AIS_ListIteratorOfListOfInteractive aListIterator;
4308 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4309 myAISContext->Remove(aListIterator.Value());
4313 TColgp_Array1OfPnt Points1(1,4);
4314 Points1.SetValue(1,gp_Pnt(0,0,0));
4315 Points1.SetValue(2,gp_Pnt(2,1,0));
4316 Points1.SetValue(3,gp_Pnt(4,0,0));
4317 Points1.SetValue(4,gp_Pnt(6,2,0));
4318 GeomAPI_PointsToBSpline PTBS1(Points1);
4319 Handle(Geom_BSplineCurve) BSC1 = PTBS1.Curve();
4320 TopoDS_Edge S = BRepBuilderAPI_MakeEdge(BSC1).Edge();
4322 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4323 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4324 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4325 myAISContext->Display(ais1,Standard_False);
4329 GProp_GProps System;
4330 BRepGProp::LinearProperties(S,System);
4331 gp_Pnt G = System.CentreOfMass ();
4332 Standard_Real Length = System.Mass();
4333 gp_Mat I = System.MatrixOfInertia();
4335 TCollection_AsciiString string("Length Of all the Edges =");
4336 TCollection_AsciiString string1(Length);
4339 string += "\nCenterOfMass : \n X=";
4350 string += "Matrix of Inertia :\n ";
4378 Standard_CString CSTR = string.ToCString();
4379 TCollection_AsciiString Message ("\
4381 TColgp_Array1OfPnt Points1(1,4);\n\
4382 Points1.SetValue(1,gp_Pnt(0,0,0));\n\
4383 Points1.SetValue(2,gp_Pnt(2,1,0));\n\
4384 Points1.SetValue(3,gp_Pnt(4,0,0));\n\
4385 Points1.SetValue(4,gp_Pnt(6,2,0));\n\
4386 GeomAPI_PointsToBSpline PTBS1(Points1);\n\
4387 Handle(Geom_BSplineCurve) BSC1 = PTBS1.Curve();\n\
4388 TopoDS_Shape S = BRepBuilderAPI_MakeEdge(BSC1).Edge();\n\
4389 GProp_GProps System;\n\
4390 BRepGProp::LinearProperties(S,System);\n\
4391 gp_Pnt G = System.CentreOfMass ();\n\
4392 Standard_Real Length = System.Mass();\n\
4393 gp_Mat I = System.MatrixOfInertia();\n\
4395 PocessTextInDialog("Linear Properties", Message);
4396 MessageBox(0,CSTR,"Linear Properties",MB_OK);
4400 void CModelingDoc::OnSurface()
4402 AIS_ListOfInteractive aList;
4403 myAISContext->DisplayedObjects(aList);
4404 AIS_ListIteratorOfListOfInteractive aListIterator;
4405 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4406 myAISContext->Remove(aListIterator.Value());
4409 TColgp_Array1OfPnt Pnts1(1,3);
4410 TColgp_Array1OfPnt Pnts2(1,3);
4411 TColgp_Array1OfPnt Pnts3(1,3);
4412 TColgp_Array1OfPnt Pnts4(1,3);
4414 Pnts1(1) = gp_Pnt(0,0,0);
4415 Pnts1(2) = gp_Pnt(5,0,0);
4416 Pnts1(3) = gp_Pnt(10,10,0);
4418 Pnts2(1) = gp_Pnt(10,10,0);
4419 Pnts2(2) = gp_Pnt(5,12,4);
4420 Pnts2(3) = gp_Pnt(0,15,10);
4422 Pnts3(1) = gp_Pnt(0,15,10);
4423 Pnts3(2) = gp_Pnt(-12,10,11);
4424 Pnts3(3) = gp_Pnt(-10,5,13);
4426 Pnts4(1) = gp_Pnt(-10,5,13);
4427 Pnts4(2) = gp_Pnt(-2,-2,2);
4428 Pnts4(3) = gp_Pnt(0,0,0);
4430 GeomAPI_PointsToBSpline PTBS1(Pnts1);
4431 GeomAPI_PointsToBSpline PTBS2(Pnts2);
4432 GeomAPI_PointsToBSpline PTBS3(Pnts3);
4433 GeomAPI_PointsToBSpline PTBS4(Pnts4);
4434 Handle(Geom_BSplineCurve) C1 = PTBS1.Curve();
4435 Handle(Geom_BSplineCurve) C2 = PTBS2.Curve();
4436 Handle(Geom_BSplineCurve) C3 = PTBS3.Curve();
4437 Handle(Geom_BSplineCurve) C4 = PTBS4.Curve();
4439 GeomFill_BSplineCurves fill;
4440 fill.Init(C1,C2,C3,C4,GeomFill_CoonsStyle);
4441 Handle(Geom_BSplineSurface) BSS = fill.Surface();
4443 TopoDS_Shape S = BRepBuilderAPI_MakeFace(BSS).Face();
4445 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4446 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4447 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4448 myAISContext->Display(ais1,Standard_False);
4452 GProp_GProps System;
4453 BRepGProp::SurfaceProperties(S,System);
4454 gp_Pnt G = System.CentreOfMass ();
4455 Standard_Real Area = System.Mass();
4456 gp_Mat I = System.MatrixOfInertia();
4458 TCollection_AsciiString string("Area Of the Face =");
4459 TCollection_AsciiString string1(Area);
4462 string += "\nCenterOfMass : \n X=";
4473 string += "Matrix of Inertia :\n ";
4501 Standard_CString CSTR = string.ToCString();
4502 TCollection_AsciiString Message ("\
4504 TopoDS_Shape S = BRepBuilderAPI_MakeFace(BSplineSurf).Face();\n\
4505 GProp_GProps System;\n\
4506 BRepGProp::SurfaceProperties(S,System);\n\
4507 gp_Pnt G = System.CentreOfMass ();\n\
4508 Standard_Real Area = System.Mass();\n\
4509 gp_Mat I = System.MatrixOfInertia();\n\
4511 PocessTextInDialog("Surface Properties", Message);
4512 MessageBox(0,CSTR,"Surface Properties",MB_OK);
4516 void CModelingDoc::OnVolume()
4518 AIS_ListOfInteractive aList;
4519 myAISContext->DisplayedObjects(aList);
4520 AIS_ListIteratorOfListOfInteractive aListIterator;
4521 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4522 myAISContext->Remove(aListIterator.Value());
4526 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
4527 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4528 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4529 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4530 myAISContext->Display(ais1,Standard_False);
4534 GProp_GProps System;
4535 BRepGProp::VolumeProperties(S,System);
4536 gp_Pnt G = System.CentreOfMass ();
4537 Standard_Real Volume = System.Mass();
4538 gp_Mat I = System.MatrixOfInertia();
4540 TCollection_AsciiString string("Volume Of all the Shape =");
4541 TCollection_AsciiString string1(Volume);
4544 string += "\nCenterOfMass : \n X=";
4555 string += "Matrix of Inertia :\n ";
4583 Standard_CString CSTR = string.ToCString();
4584 TCollection_AsciiString Message ("\
4586 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.);;\n\
4587 GProp_GProps System;\n\
4588 BRepGProp::VolumeProperties(S,System);\n\
4589 gp_Pnt G = System.CentreOfMass ();\n\
4590 Standard_Real Volume = System.Mass();\n\
4591 gp_Mat I = System.MatrixOfInertia();\n\
4593 PocessTextInDialog("Volume Properties", Message);
4594 MessageBox(0,CSTR,"Volume Properties",MB_OK);
4599 void CModelingDoc::OnButtonFill()
4601 // TODO: Add your command handler code here
4602 myAISContext->InitCurrent();
4603 if (myAISContext->MoreCurrent()) {
4604 AIS1 = Handle(AIS_Shape)::DownCast(myAISContext->Current());
4605 myAISContext->OpenLocalContext();
4606 myAISContext->Unhilight(AIS1);
4607 myAISContext->Activate(AIS1,2);
4608 myState = SELECT_EDGE_PLATE;
4609 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select hole contour edges and then press right mouse button"); }
4611 AIS_ListOfInteractive LI;
4612 myAISContext->DisplayedObjects(LI);
4614 if(OnFileImportBrep_WithInitDir("HoleFilling") == 1)
4616 myAISContext->DisplayedObjects(LI);
4617 myAISContext->SetCurrentObject(LI.First());
4621 AfxMessageBox("Select a shape before!");
4625 void CModelingDoc::OnStopStop()
4627 // TODO: Add your command handler code here
4629 if (myState == SELECT_EDGE_PLATE ) {
4630 Standard_Integer nbedges = 0;
4631 for (myAISContext->InitSelected(); myAISContext->MoreSelected();
4632 myAISContext->NextSelected()) {
4636 Handle(GeomPlate_HArray1OfHCurveOnSurface) Fronts =
4637 new GeomPlate_HArray1OfHCurveOnSurface(1,nbedges);
4638 Handle(TColStd_HArray1OfInteger) Tang =
4639 new TColStd_HArray1OfInteger(1,nbedges);
4640 Handle(TColStd_HArray1OfInteger) NbPtsCur =
4641 new TColStd_HArray1OfInteger(1,nbedges);
4642 Standard_Integer i = 0;
4643 TopoDS_Shape S1 = AIS1->Shape();
4644 TopTools_IndexedDataMapOfShapeListOfShape M;
4645 TopExp::MapShapesAndAncestors(S1, TopAbs_EDGE, TopAbs_FACE, M);
4647 for (myAISContext->InitSelected(); myAISContext->MoreSelected();myAISContext->NextSelected()) {
4649 Tang->SetValue(i,1);
4650 NbPtsCur->SetValue(i,10);
4651 TopoDS_Edge E = TopoDS::Edge(myAISContext->SelectedShape());
4652 TopoDS_Face F = TopoDS::Face(M.FindFromKey(E).First());
4654 BRepAdaptor_Surface S(F);
4655 GeomAdaptor_Surface aGAS = S.Surface();
4656 Handle(GeomAdaptor_HSurface) aHGAS = new GeomAdaptor_HSurface(aGAS);
4658 Handle(BRepAdaptor_HCurve2d) C = new BRepAdaptor_HCurve2d();
4659 C->ChangeCurve2d().Initialize(E,F);
4661 Adaptor3d_CurveOnSurface ConS(C,aHGAS);
4663 Handle (Adaptor3d_HCurveOnSurface) HConS = new Adaptor3d_HCurveOnSurface(ConS);
4664 Fronts->SetValue(i,HConS);
4666 GeomPlate_BuildPlateSurface abuildplate(NbPtsCur,Fronts,Tang,3);
4667 abuildplate.Perform();
4668 if (!abuildplate.IsDone()){ // New in 2.0
4669 MessageBox(AfxGetApp()->m_pMainWnd->m_hWnd,"Error : Build plate not valid!","CasCade Error",MB_ICONERROR);
4672 Handle(GeomPlate_Surface) aplate = abuildplate.Surface();
4674 GeomPlate_MakeApprox aMKS(aplate, Precision::Approximation(), 4, 7, 0.001, 1);
4675 Handle(Geom_BSplineSurface) support = aMKS.Surface();
4676 BRepBuilderAPI_MakeWire MW;
4677 TopTools_Array1OfShape tab(1,nbedges);
4678 for (i=1 ; i<=nbedges ; i++) {
4679 if (abuildplate.Sense()->Value(abuildplate.Order()->Value(i))==1) {
4680 BRepBuilderAPI_MakeEdge ME(abuildplate.Curves2d()->Value(abuildplate.Order()->Value(i)),
4682 Fronts->Value(abuildplate.Order()->Value(i))->LastParameter(),
4683 Fronts->Value(abuildplate.Order()->Value(i))->FirstParameter());
4684 TopoDS_Edge E = ME.Edge();
4685 BRepLib::BuildCurves3d(E);
4686 tab(abuildplate.Order()->Value(i)) = E;
4690 BRepBuilderAPI_MakeEdge ME(abuildplate.Curves2d()->Value(abuildplate.Order()->Value(i)),
4692 Fronts->Value(abuildplate.Order()->Value(i))->FirstParameter(),
4693 Fronts->Value(abuildplate.Order()->Value(i))->LastParameter());
4694 TopoDS_Edge E = ME.Edge();
4695 BRepLib::BuildCurves3d(E);
4696 tab(abuildplate.Order()->Value(i)) = E;
4699 for (i=1 ; i<=nbedges ; i++)
4700 MW.Add(TopoDS::Edge(tab(i)));
4706 catch(StdFail_NotDone)
4708 AfxMessageBox("Can't build wire!");
4713 AfxMessageBox("Wire is not closed!");
4715 //Standard_Failure::Raise("Wire is not closed");
4718 BRepBuilderAPI_MakeFace MF(support,W,Standard_True);
4721 BRepTopAdaptor_FClass2d clas2d(aface,Precision::Confusion());
4722 if (clas2d.PerformInfinitePoint() == TopAbs_IN) {
4724 BRepBuilderAPI_MakeFace MF1(support,W,Standard_True);
4727 if (!BRepAlgo::IsValid(aface))
4728 MessageBox(AfxGetApp()->m_pMainWnd->m_hWnd,"Error : The plate face is not valid!","CasCade Error",MB_ICONERROR);
4729 myAISContext->CloseLocalContext();
4731 Handle_AIS_Shape anAISShape = new AIS_Shape(aface);
4732 myAISContext->SetColor(anAISShape,Quantity_NOC_AZURE);
4733 myAISContext->SetMaterial(anAISShape,Graphic3d_NOM_SILVER);
4734 myAISContext->SetDisplayMode(anAISShape,1);
4735 myAISContext->Display(anAISShape);
4739 void CModelingDoc::OnFillwithtang()
4741 static BOOL flag = 0;
4744 Handle(AIS_InteractiveObject) aObject;
4745 myAISContext ->InitCurrent();
4746 if(myAISContext->MoreCurrent())
4747 aObject = myAISContext->Current();
4748 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with second face");
4749 if(OnFileImportBrep_WithInitDir("TangentSurface") == 1){
4750 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
4751 AIS_ListOfInteractive aList;
4752 myAISContext->DisplayedObjects(aList);
4753 AIS_ListIteratorOfListOfInteractive aListIterator;
4754 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4755 myAISContext->Remove(aListIterator.Value());
4759 myAISContext->SetCurrentObject(aObject);
4762 myAISContext->InitCurrent();
4763 if (myAISContext->MoreCurrent()) {
4764 Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->Current());
4766 F1 = TopoDS::Face(ashape->Shape());
4768 catch(Standard_Failure){}
4771 AfxMessageBox("Current object is not a face!\n\
4772 Please, select a face to continue\nthe creation of a tangent surface.");
4775 myAISContext->OpenLocalContext();
4776 myAISContext->Activate(ashape,2);
4777 myState = SELECT_EDGE_PLATE_TGTES_1;
4779 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the first face");
4782 AIS_ListOfInteractive LI;
4783 myAISContext->DisplayedObjects(LI);
4785 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with first face");
4786 if(OnFileImportBrep_WithInitDir("TangentSurface") == 1){
4787 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
4788 AIS_ListOfInteractive aList;
4789 myAISContext->DisplayedObjects(aList);
4790 AIS_ListIteratorOfListOfInteractive aListIterator;
4791 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4792 myAISContext->Remove(aListIterator.Value());
4797 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
4798 myAISContext->DisplayedObjects(LI);
4799 myAISContext->SetCurrentObject(LI.First());
4805 AfxMessageBox("Select a face before");
4809 void CModelingDoc::InputEvent(const Standard_Integer x ,
4810 const Standard_Integer y ,
4811 const Handle(V3d_View)& aView )
4813 myAISContext->Select();
4814 if (myState == SELECT_EDGE_PLATE_TGTES_1) {
4815 myAISContext->InitSelected();
4816 if (myAISContext->MoreSelected()) {
4817 E1 = TopoDS::Edge(myAISContext->SelectedShape());
4818 myAISContext->CloseLocalContext();
4819 myState = SELECT_EDGE_PLATE_TGTES_2;
4821 AIS_ListOfInteractive aLI;
4822 myAISContext->DisplayedObjects(aLI);
4823 if(aLI.Extent() == 2){
4824 myState = SELECT_EDGE_PLATE_TGTES_2;
4825 if (myAISContext->IsCurrent(aLI.First()))
4826 myAISContext->SetCurrentObject(aLI.Last());
4828 myAISContext->SetCurrentObject(aLI.First());
4829 myAISContext->InitCurrent();
4830 Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->Current());
4831 F2 = TopoDS::Face(ashape->Shape());
4832 myAISContext->OpenLocalContext();
4833 myAISContext->Activate(ashape,2);
4834 myState = SELECT_EDGE_PLATE_TGTES_3;
4835 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the second face");
4839 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select second face");
4840 AIS_ListOfInteractive LI;
4841 myAISContext->DisplayedObjects(LI);
4842 if(LI.Extent() == 1){
4843 if(OnFileImportBrep_WithInitDir("TangentSurface") == 1)
4848 AfxMessageBox("Select an edge on the face!");
4851 else if (myState == SELECT_EDGE_PLATE_TGTES_2) {
4852 myAISContext->InitCurrent();
4853 if (myAISContext->MoreCurrent()) {
4854 Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->Current());
4855 F2 = TopoDS::Face(ashape->Shape());
4856 myAISContext->OpenLocalContext();
4857 myAISContext->Activate(ashape,2);
4858 myState = SELECT_EDGE_PLATE_TGTES_3;
4859 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the second face");
4862 AfxMessageBox("Select the second face!");
4864 else if (myState == SELECT_EDGE_PLATE_TGTES_3) {
4865 myAISContext->InitSelected();
4866 if (myAISContext->MoreSelected()) {
4867 E2 = TopoDS::Edge(myAISContext->SelectedShape());
4868 myAISContext->CloseLocalContext();
4870 Standard_Integer i, nbPntsOnFaces=10;
4871 Standard_Real u,First, Last, Delta, Tol=0.001, TolProj;
4877 //get the pcurve, curve and surface
4878 BRepAdaptor_Curve Curve3d1(E1), Curve3d2(E2);
4879 BRepAdaptor_Curve2d Curve2d1(E1,F1), Curve2d2(E2,F2);
4880 BRepAdaptor_Surface Surf1(F1), Surf2(F2);
4882 //compute the average plane : initial surface
4883 Handle(TColgp_HArray1OfPnt) theTanPoints = new
4884 TColgp_HArray1OfPnt (1,2*nbPntsOnFaces );
4886 Delta = (Curve3d1.LastParameter()-Curve3d1.FirstParameter())/(nbPntsOnFaces-1);
4887 for (u=Curve3d1.FirstParameter(),i=1;i<=nbPntsOnFaces; i++,u+=Delta)
4888 theTanPoints->SetValue(i,Curve3d1.Value(u));
4890 Delta = (Curve3d2.LastParameter()-Curve3d2.FirstParameter())/(nbPntsOnFaces-1);
4891 for (u=Curve3d2.FirstParameter(),i=1;i<=nbPntsOnFaces; i++,u+=Delta)
4892 theTanPoints->SetValue(nbPntsOnFaces+i,Curve3d2.Value(u));
4894 //Building an initial plane
4895 GeomPlate_BuildAveragePlane aMkPlane (theTanPoints,int(Tol),1,1,1);
4896 Handle(Geom_Plane) aPlane = aMkPlane.Plane();
4897 gp_Pln aPln = aPlane->Pln();
4898 gp_XYZ aNormale = aPln.Axis().Direction().XYZ();
4899 gp_Trsf aTrsf; // to compute the U and V of the points
4900 aTrsf.SetTransformation(aPln.Position());
4902 aPlane->D1(0,0,P,W1,W2); // extract plane DU & DV
4904 // 1st surface tangencies constraints
4905 Delta = (Curve3d1.LastParameter()-Curve3d1.FirstParameter())/(nbPntsOnFaces-1);
4906 for (u=Curve3d1.FirstParameter(),i=1; i<=nbPntsOnFaces; i++,u+=Delta) {
4907 P = Curve3d1.Value(u).Transformed(aTrsf);
4908 gp_XY UV(P.X(),P.Y());
4909 aPlate.Load(Plate_PinpointConstraint(UV,aNormale*P.Z()));
4911 Surf1.D1(P2d.X(),P2d.Y(),P,V1,V2); // extract surface UV of the point
4912 aPlate.Load(Plate_GtoCConstraint(UV,
4913 Plate_D1(W1.XYZ(),W2.XYZ()),
4914 Plate_D1(V1.XYZ(),V2.XYZ())));
4917 Delta = (Curve3d2.LastParameter()-Curve3d2.FirstParameter())/(nbPntsOnFaces-1);
4918 for (u=Curve3d2.FirstParameter(),i=1; i<=nbPntsOnFaces; i++,u+=Delta) {
4919 P = Curve3d2.Value(u).Transformed(aTrsf);
4920 gp_XY UV(P.X(),P.Y());
4921 aPlate.Load(Plate_PinpointConstraint(UV,aNormale*P.Z()));
4924 Surf2.D1(P2d.X(),P2d.Y(),P,V1,V2);
4925 aPlate.Load(Plate_GtoCConstraint(UV,
4926 Plate_D1(W1.XYZ(),W2.XYZ()),
4927 Plate_D1(V1.XYZ()*-1,V2.XYZ()*-1)));
4930 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with passing points");
4931 //Some passing points
4932 CFileDialog dlg(TRUE,
4935 OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
4936 "Points Files (*.pass)|*.pass; |All Files (*.*)|*.*||",
4939 CString initdir(((OCC_BaseApp*) AfxGetApp())->GetInitDataDir());
4940 initdir += "\\Data\\TangentSurface";
4942 dlg.m_ofn.lpstrInitialDir = initdir;
4944 if (dlg.DoModal() == IDOK)
4946 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Building the tangent surface...");
4947 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
4948 CString filename = dlg.GetPathName();
4951 if (!fic.open((Standard_CString)(LPCTSTR)filename,ios::in))
4952 MessageBox(0,"Error : Unable to open file","CasCade Error",MB_ICONERROR);
4953 Standard_Real x,y,z;
4957 while (!in.fail()|| !in.eof()){
4958 if (in >> x && in >> y && in >> z){
4959 PP = gp_Pnt(x, y, z);
4960 P = PP.Transformed(aTrsf);
4961 aPlate.Load(Plate_PinpointConstraint(gp_XY(P.X(),P.Y()),
4963 BRepBuilderAPI_MakeVertex V(PP);
4964 B.Add(C,V.Vertex());
4968 Handle(AIS_Shape) anAISCompound = new AIS_Shape(C);
4969 myAISContext->Display(anAISCompound, Standard_False);
4973 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
4974 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Building the tangent surface...");
4976 Standard_Integer Order = 3; // constraints continuity + 2
4977 aPlate.SolveTI(Order,1.);
4978 if (!aPlate.IsDone()){
4979 MessageBox(0,"Error : Build plate not valid!","CasCade Error",MB_ICONERROR);
4982 //Plate Surface creation
4983 Handle(GeomPlate_Surface) aPlateSurface = new GeomPlate_Surface(aPlane,aPlate);
4984 //BSplineSurface approximation
4985 GeomPlate_MakeApprox aMkSurf(aPlateSurface,Tol,1,8,0.1,1);
4986 Handle(Geom_Surface) theSurface =aMkSurf.Surface();
4988 // Face building ...
4989 Handle(Geom2d_Curve)C1,C2,C3,C4;
4990 Handle(Geom_Curve)C;
4991 C = BRep_Tool::Curve(E1,First,Last);
4993 C1 = GeomProjLib::Curve2d(C,First,Last,theSurface,TolProj);
4994 TopoDS_Edge Ed1 = BRepBuilderAPI_MakeEdge(C1,theSurface).Edge();
4996 C = BRep_Tool::Curve(E2,First,Last);
4998 C3 = GeomProjLib::Curve2d(C,First,Last,theSurface,TolProj);
4999 TopoDS_Edge Ed3 = BRepBuilderAPI_MakeEdge(C3,theSurface).Edge();
5001 C2 = GCE2d_MakeSegment(C1->Value(C1->FirstParameter()),
5002 C3->Value(C3->FirstParameter()));
5003 TopoDS_Edge Ed2 = BRepBuilderAPI_MakeEdge(C2,theSurface).Edge();
5004 C4 = GCE2d_MakeSegment(C1->Value(C1->LastParameter()),
5005 C3->Value(C3->LastParameter()));
5006 TopoDS_Edge Ed4 = BRepBuilderAPI_MakeEdge(C4,theSurface).Edge();
5009 TopoDS_Wire theWire = BRepBuilderAPI_MakeWire(Ed1,Ed2,Ed3,Ed4);
5010 TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire);
5011 BRepLib::BuildCurves3d(theFace);
5012 if (!BRepAlgo::IsValid(theFace)){
5013 C2 = GCE2d_MakeSegment(C1->Value(C1->LastParameter()),
5014 C3->Value(C3->FirstParameter()));
5015 TopoDS_Edge Ed2 = BRepBuilderAPI_MakeEdge(C2,theSurface).Edge();
5016 C4 = GCE2d_MakeSegment(C3->Value(C3->LastParameter()),
5017 C1->Value(C1->FirstParameter()));
5018 TopoDS_Edge Ed4 = BRepBuilderAPI_MakeEdge(C4,theSurface).Edge();
5020 theWire = BRepBuilderAPI_MakeWire(Ed1,Ed2,Ed3,Ed4);
5021 theFace = BRepBuilderAPI_MakeFace(theWire);
5022 BRepLib::BuildCurves3d(theFace);
5023 if (!BRepAlgo::IsValid(theFace))
5024 MessageBox(AfxGetApp()->m_pMainWnd->m_hWnd,"Error : The plate surface is not valid!!!","CasCade Error",MB_ICONERROR);
5027 Handle_AIS_Shape anAISShape=new AIS_Shape(theFace);
5028 myAISContext->SetColor(anAISShape,Quantity_NOC_BLUE1);
5029 myAISContext->SetMaterial(anAISShape,Graphic3d_NOM_SILVER);
5030 myAISContext->SetDisplayMode(anAISShape,1);
5031 myAISContext->Display(anAISShape);
5035 AfxMessageBox("Select an edge on the second face!");
5036 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
5041 void CModelingDoc::Popup(const Standard_Integer x,
5042 const Standard_Integer y ,
5043 const Handle(V3d_View)& aView)
5045 Standard_Integer PopupMenuNumber=0;
5046 myAISContext->InitCurrent();
5047 if (myState == SELECT_EDGE_PLATE)
5049 else if (myAISContext->MoreCurrent())
5053 VERIFY(menu.LoadMenu(IDR_Popup3D));
5054 CMenu* pPopup = menu.GetSubMenu(PopupMenuNumber);
5055 ASSERT(pPopup != NULL);
5057 if (PopupMenuNumber == 1) // more than 1 object.
5059 bool OneOrMoreInShading = false;
5060 for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
5061 if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true;
5062 if(!OneOrMoreInShading)
5063 pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
5067 POINT winCoord = { x , y };
5068 Handle(WNT_Window) aWNTWindow=
5069 Handle(WNT_Window)::DownCast(aView->Window());
5070 ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord);
5071 pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y ,