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>
19 #include <BRepPrimAPI_MakeCylinder.hxx>
20 #include <TopExp_Explorer.hxx>
21 #include <Geom_Plane.hxx>
22 #include <BRepTools.hxx>
24 static Handle(AIS_Shape) AIS1;
25 static TopoDS_Face THE_F1, THE_F2;
26 static TopoDS_Edge THE_E1, THE_E2;
28 /////////////////////////////////////////////////////////////////////////////
31 IMPLEMENT_DYNCREATE(CModelingDoc, CDocument)
33 BEGIN_MESSAGE_MAP(CModelingDoc, OCC_3dBaseDoc)
34 //{{AFX_MSG_MAP(CModelingDoc)
35 ON_COMMAND(ID_MIRROR, OnMirror)
36 ON_COMMAND(ID_MIRRORAXIS, OnMirroraxis)
37 ON_COMMAND(ID_ROTATE, OnRotate)
38 ON_COMMAND(ID_SCALE, OnScale)
39 ON_COMMAND(ID_TRANSLATION, OnTranslation)
40 ON_COMMAND(ID_DISPLACEMENT, OnDisplacement)
41 ON_COMMAND(ID_DEFORM, OnDeform)
42 ON_COMMAND(ID_BOX, OnBox)
43 ON_COMMAND(ID_Cylinder, OnCylinder)
44 ON_COMMAND(ID_CONE, OnCone)
45 ON_COMMAND(ID_SPHERE, OnSphere)
46 ON_COMMAND(ID_TORUS, OnTorus)
47 ON_COMMAND(ID_WEDGE, OnWedge)
48 ON_COMMAND(ID_PRISM, OnPrism)
49 ON_COMMAND(ID_REVOL, OnRevol)
50 ON_COMMAND(ID_PIPE, OnPipe)
51 ON_COMMAND(ID_THRU, OnThru)
52 ON_COMMAND(ID_EVOLVED, OnEvolved)
53 ON_COMMAND(ID_DRAFT, OnDraft)
54 ON_COMMAND(ID_CUT, OnCut)
55 ON_COMMAND(ID_FUSE, OnFuse)
56 ON_COMMAND(ID_SECTION, OnSection)
57 ON_COMMAND(ID_COMMON, OnCommon)
58 ON_COMMAND(ID_PSECTION, OnPsection)
59 ON_COMMAND(ID_BLEND, OnBlend)
60 ON_COMMAND(ID_CHAMF, OnChamf)
61 ON_COMMAND(ID_EVOLVEDBLEND, OnEvolvedblend)
62 ON_COMMAND(ID_PRISM_LOCAL, OnPrismLocal)
63 ON_COMMAND(ID_REVOL_LOCAL, OnRevolLocal)
64 ON_COMMAND(ID_GLUE_LOCAL, OnGlueLocal)
65 ON_COMMAND(ID_DPRISM_LOCAL, OnDprismLocal)
66 ON_COMMAND(ID_Pipe_LOCAL, OnPipeLocal)
67 ON_COMMAND(ID_LINEAR_LOCAL, OnLinearLocal)
68 ON_COMMAND(ID_SPLIT_LOCAL, OnSplitLocal)
69 ON_COMMAND(ID_THICK_LOCAL, OnThickLocal)
70 ON_COMMAND(ID_OFFSET_LOCAL, OnOffsetLocal)
71 ON_COMMAND(ID_VERTEX, OnVertex)
72 ON_COMMAND(ID_EDGE, OnEdge)
73 ON_COMMAND(ID_WIRE, OnWire)
74 ON_COMMAND(ID_FACE, OnFace)
75 ON_COMMAND(ID_SHELL, OnShell)
76 ON_COMMAND(ID_COMPOUND, OnCompound)
77 ON_COMMAND(ID_GEOMETRIE, OnGeometrie)
78 ON_COMMAND(ID_SEWING, OnSewing)
79 ON_COMMAND(ID_EXPLORER, OnExplorer)
80 ON_COMMAND(ID_BUILDER, OnBuilder)
81 ON_COMMAND(ID_VALID, OnValid)
82 ON_COMMAND(ID_LINEAR, OnLinear)
83 ON_COMMAND(ID_VOLUME, OnVolume)
84 ON_COMMAND(ID_SURFACE, OnSurface)
85 ON_COMMAND(ID_BUTTON_FILL, OnButtonFill)
86 ON_COMMAND(ID_STOP_STOP, OnStopStop)
87 ON_COMMAND(ID_FILLWITHTANG, OnFillwithtang)
91 /////////////////////////////////////////////////////////////////////////////
92 // CModelingDoc construction/destruction
94 CModelingDoc::CModelingDoc()
96 myAISContext->SetDisplayMode(AIS_Shaded,Standard_False);
99 CModelingDoc::~CModelingDoc()
103 void CModelingDoc::OnMirror()
105 AIS_ListOfInteractive aList;
106 myAISContext->DisplayedObjects(aList);
107 AIS_ListIteratorOfListOfInteractive aListIterator;
108 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
109 myAISContext->Remove(aListIterator.Value());
111 TopoDS_Shape S = BRepPrimAPI_MakeWedge (60.,100.,80.,20.).Shape();
112 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
113 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
114 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
115 myAISContext->Display(ais1,Standard_False);
116 gp_Trsf theTransformation;
117 gp_Pnt PntCenterOfTheTransformation(110,60,60);
118 Handle(AIS_Point) aispnt = new AIS_Point(new Geom_CartesianPoint(PntCenterOfTheTransformation));
119 myAISContext->Display(aispnt,Standard_False);
120 theTransformation.SetMirror(PntCenterOfTheTransformation);
121 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
122 TopoDS_Shape S2 = myBRepTransformation.Shape();
123 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
124 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
125 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
126 myAISContext->Display(ais2,Standard_False);
128 TCollection_AsciiString Message ("\
130 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
131 gp_Trsf theTransformation; \n\
132 gp_Pnt PntCenterOfTheTransformation(110,60,60); \n\
133 theTransformation.SetMirror(PntCenterOfTheTransformation);\n\
134 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
135 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
136 PocessTextInDialog("Transform a Shape with Mirror and One point.", Message);
140 void CModelingDoc::OnMirroraxis()
142 AIS_ListOfInteractive aList;
143 myAISContext->DisplayedObjects(aList);
144 AIS_ListIteratorOfListOfInteractive aListIterator;
145 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
146 myAISContext->Remove(aListIterator.Value());
148 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
149 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
150 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
151 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
152 myAISContext->Display(ais1,Standard_False);
153 gp_Trsf theTransformation;
154 gp_Ax1 axe = gp_Ax1(gp_Pnt(110,60,60),gp_Dir(0.,1.,0.));
155 Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
156 Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
157 myAISContext->Display(ax1,Standard_False);
158 theTransformation.SetMirror(axe);
159 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
160 TopoDS_Shape S2 = myBRepTransformation.Shape();
161 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
162 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
163 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
164 myAISContext->Display(ais2,Standard_False);
167 TCollection_AsciiString Message ("\
169 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
170 gp_Trsf theTransformation; \n\
171 gp_Ax1 Axis = gp_Ax1(gp_Pnt(110,60,60),gp_Dir(0.,1.,0.)); \n\
172 theTransformation.SetMirror(Axis);\n\
173 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
174 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
176 PocessTextInDialog("Transform a Shape with Mirror and One axis.", Message);
181 void CModelingDoc::OnRotate()
183 AIS_ListOfInteractive aList;
184 myAISContext->DisplayedObjects(aList);
185 AIS_ListIteratorOfListOfInteractive aListIterator;
186 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
187 myAISContext->Remove(aListIterator.Value());
189 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
190 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
191 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
192 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
193 myAISContext->Display(ais1,Standard_False);
194 gp_Trsf theTransformation;
195 gp_Ax1 axe = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.));
196 Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
197 Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
198 myAISContext->Display(ax1,Standard_False);
199 theTransformation.SetRotation(axe,30*M_PI/180);
200 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
201 TopoDS_Shape S2 = myBRepTransformation.Shape();
202 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
203 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
204 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
205 myAISContext->Display(ais2,Standard_False);
208 TCollection_AsciiString Message ("\
210 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
211 gp_Trsf theTransformation; \n\
212 gp_Ax1 Axis = gp_Ax1(gp_Pnt(200,60,60),gp_Dir(0.,1.,0.)); \n\
213 theTransformation.SetRotation(Axis,30*PI/180); // Rotation of 30 degrees \n\
214 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
215 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
217 PocessTextInDialog("Transform a Shape with Rotation.", Message);
221 void CModelingDoc::OnScale()
223 AIS_ListOfInteractive aList;
224 myAISContext->DisplayedObjects(aList);
225 AIS_ListIteratorOfListOfInteractive aListIterator;
226 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
227 myAISContext->Remove(aListIterator.Value());
229 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
230 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
231 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
232 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
233 myAISContext->Display(ais1,Standard_False);
234 gp_Trsf theTransformation;
235 gp_Pnt theCenterOfScale(200,60,60);
236 Handle(AIS_Point) aispnt = new AIS_Point(new Geom_CartesianPoint(theCenterOfScale));
238 myAISContext->Display(aispnt,Standard_False);
239 theTransformation.SetScale(theCenterOfScale,0.5);
240 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
241 TopoDS_Shape S2 = myBRepTransformation.Shape();
243 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
244 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
245 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
246 myAISContext->Display(ais2,Standard_False);
249 TCollection_AsciiString Message ("\
251 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
252 gp_Trsf theTransformation; \n\
253 gp_Pnt theCenterOfScale(200,60,60); \n\
254 theTransformation.SetScale(theCenterOfScale,0.5); // Scale : value = 0.5 \n\
255 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
256 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
258 PocessTextInDialog("Scale a Shape with One point.", Message);
265 void CModelingDoc::OnTranslation()
267 AIS_ListOfInteractive aList;
268 myAISContext->DisplayedObjects(aList);
269 AIS_ListIteratorOfListOfInteractive aListIterator;
270 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
271 myAISContext->Remove(aListIterator.Value());
273 TopoDS_Shape S = BRepPrimAPI_MakeWedge(6.,10.,8.,2.).Shape();
274 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
275 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
276 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
277 myAISContext->Display(ais1,Standard_False);
278 gp_Trsf theTransformation;
279 gp_Vec theVectorOfTranslation(-6,-6,6);
281 Handle(ISession_Direction) aDirection1 = new ISession_Direction(gp_Pnt(0,0,0),theVectorOfTranslation);
282 myAISContext->Display(aDirection1,Standard_False);
284 theTransformation.SetTranslation(theVectorOfTranslation);
285 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
286 TopoDS_Shape S2 = myBRepTransformation.Shape();
288 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
289 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
290 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
291 myAISContext->Display(ais2,Standard_False);
295 TCollection_AsciiString Message ("\
297 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(6.,10.,8.,2.); \n\
298 gp_Trsf theTransformation; \n\
299 gp_Vec theVectorOfTranslation(6,6,6); \n\
300 theTransformation.SetTranslation(theVectorOfTranslation); \n\
301 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
302 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
304 PocessTextInDialog("Translate a Shape with One vector.", Message);
308 void CModelingDoc::OnDisplacement()
310 AIS_ListOfInteractive aList;
311 myAISContext->DisplayedObjects(aList);
312 AIS_ListIteratorOfListOfInteractive aListIterator;
313 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
314 myAISContext->Remove(aListIterator.Value());
316 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60., 100., 80., 20.).Shape();
317 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
318 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
319 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
320 myAISContext->Display(ais1,Standard_False);
321 gp_Trsf theTransformation;
323 gp_Ax3 ax3_1(gp_Pnt(0,0,0),gp_Dir(0,0,1));
324 gp_Ax3 ax3_2(gp_Pnt(60,60,60),gp_Dir(1,1,1));
326 theTransformation.SetDisplacement(ax3_1,ax3_2);
327 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);
328 TopoDS_Shape TransformedShape = myBRepTransformation.Shape();
329 Handle(AIS_Shape) ais2 = new AIS_Shape(TransformedShape);
330 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
331 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
332 myAISContext->Display(ais2,Standard_False);
334 TCollection_AsciiString Message ("\
336 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
337 gp_Trsf theTransformation; \n\
338 gp_Ax3 ax3_1(gp_Pnt(0,0,0),gp_Dir(0,0,1)); \n\
339 gp_Ax3 ax3_2(gp_Pnt(60,60,60),gp_Dir(1,1,1)); \n\
340 theTransformation.SetDisplacement(ax3_1,ax3_2); \n\
341 BRepBuilderAPI_Transform myBRepTransformation(S,theTransformation);\n\
342 TopoDS_Shape TransformedShape = myBRepTransformation.Shape(); \n");
344 PocessTextInDialog("Displace a Shape with Two coordinate systems.", Message);
350 void CModelingDoc::OnDeform()
352 AIS_ListOfInteractive aList;
353 myAISContext->DisplayedObjects(aList);
354 AIS_ListIteratorOfListOfInteractive aListIterator;
355 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
356 myAISContext->Remove(aListIterator.Value());
358 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60., 100., 80., 20.).Shape();
359 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
360 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
361 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
362 myAISContext->Display(ais1,Standard_False);
364 gp_GTrsf theTransformation;
365 gp_Mat rot(1, 0, 0, 0, 0.5, 0, 0, 0, 1.5);
366 theTransformation.SetVectorialPart(rot);
367 theTransformation.SetTranslationPart(gp_XYZ(5,5,5));
369 BRepBuilderAPI_GTransform myBRepTransformation(S,theTransformation);
370 TopoDS_Shape S2 = myBRepTransformation.Shape();
372 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
373 myAISContext->SetColor(ais2,Quantity_NOC_BLUE1,Standard_False);
374 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
375 myAISContext->Display(ais2,Standard_False);
377 TCollection_AsciiString Message ("\
379 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.); \n\
380 gp_GTrsf theTransformation; \n\
381 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\
382 theTransformation.SetVectorialPart(rot); \n\
383 theTransformation.SetTranslationPart(gp_XYZ(5,5,5)); \n\
384 BRepBuilderAPI_GTransform myBRepGTransformation(S,theTransformation);\n\
385 TopoDS_Shape TransformedShape = myBRepGTransformation.Shape(); \n");
387 PocessTextInDialog("Deform a Shape with One matrix of deformation and One translation.", Message);
390 /* =================================================================================
391 ==================== P R I M I T I V E S ====================================
392 ================================================================================= */
394 void CModelingDoc::OnBox()
396 AIS_ListOfInteractive aList;
397 myAISContext->DisplayedObjects(aList);
398 AIS_ListIteratorOfListOfInteractive aListIterator;
399 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
400 myAISContext->Remove(aListIterator.Value());
402 TopoDS_Shape B1 = BRepPrimAPI_MakeBox(200., 150., 100.).Shape();
403 Handle(AIS_Shape) aBox1 = new AIS_Shape(B1);
404 myAISContext->SetMaterial(aBox1,Graphic3d_NOM_PLASTIC,Standard_False);
405 myAISContext->SetColor(aBox1,Quantity_NOC_GREEN,Standard_False);
406 myAISContext->Display(aBox1,Standard_False);
407 TopoDS_Shape B2 = BRepPrimAPI_MakeBox (gp_Ax2(gp_Pnt(-200.,-80.,-70.),
409 80., 90., 120.).Shape();
410 Handle(AIS_Shape) aBox2 = new AIS_Shape(B2);
411 myAISContext->SetMaterial(aBox2,Graphic3d_NOM_PLASTIC,Standard_False);
412 myAISContext->SetColor(aBox2,Quantity_NOC_RED,Standard_False);
413 myAISContext->Display(aBox2,Standard_False);
415 TCollection_AsciiString Message ("\
417 TopoDS_Shape B1 = BRepPrimAPI_MakeBox (200.,150.,100.); \n\
418 TopoDS_Shape B2 = BRepPrimAPI_MakeBox (gp_Ax2(gp_Pnt(-200.,-80.,-70.), \n\
419 gp_Dir(1.,2.,1.)), \n\
422 PocessTextInDialog("Make a topological box", Message);
425 void CModelingDoc::OnCylinder()
427 AIS_ListOfInteractive aList;
428 myAISContext->DisplayedObjects(aList);
429 AIS_ListIteratorOfListOfInteractive aListIterator;
430 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
431 myAISContext->Remove(aListIterator.Value());
434 TopoDS_Shape C1 = BRepPrimAPI_MakeCylinder(50., 200.).Shape();
435 Handle(AIS_Shape) aCyl1 = new AIS_Shape(C1);
436 myAISContext->SetMaterial(aCyl1,Graphic3d_NOM_PLASTIC,Standard_False);
437 myAISContext->SetColor(aCyl1,Quantity_NOC_RED,Standard_False);
438 myAISContext->Display(aCyl1,Standard_False);
439 TopoDS_Shape C2 = BRepPrimAPI_MakeCylinder (gp_Ax2(gp_Pnt(200.,200.,0.),
441 40., 110., 210.*M_PI / 180).Shape();
442 Handle(AIS_Shape) aCyl2 = new AIS_Shape(C2);
443 myAISContext->SetMaterial(aCyl2,Graphic3d_NOM_PLASTIC,Standard_False);
444 myAISContext->SetColor(aCyl2,Quantity_NOC_MATRABLUE,Standard_False);
445 myAISContext->Display(aCyl2,Standard_False);
448 TCollection_AsciiString Message ("\
450 TopoDS_Shape C1 = BRepPrimAPI_MakeCylinder (50.,200.); \n\
451 TopoDS_Shape C2 = BRepPrimAPI_MakeCylinder (gp_Ax2(gp_Pnt(200.,200.,0.), \n\
452 gp_Dir(0.,0.,1.)), \n\
453 40.,110.,210.*PI180.); \n\
455 PocessTextInDialog("Make a cylinder", Message);
459 void CModelingDoc::OnCone()
461 AIS_ListOfInteractive aList;
462 myAISContext->DisplayedObjects(aList);
463 AIS_ListIteratorOfListOfInteractive aListIterator;
464 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
465 myAISContext->Remove(aListIterator.Value());
467 TopoDS_Shape C1 = BRepPrimAPI_MakeCone(50., 25., 200.).Shape();
468 Handle(AIS_Shape) ais1 = new AIS_Shape(C1);
469 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
470 myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
471 myAISContext->Display(ais1,Standard_False);
472 TopoDS_Shape C2 = BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(100.,100.,0.),
474 60., 0., 150., 210.*M_PI / 180).Shape();
475 Handle(AIS_Shape) ais2 = new AIS_Shape(C2);
476 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
477 myAISContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False);
478 myAISContext->Display(ais2,Standard_False);
481 TCollection_AsciiString Message ("\
483 TopoDS_Shape C1 = BRepPrimAPI_MakeCone (50.,25.,200.); \n\
484 TopoDS_Shape C2 = BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(100.,100.,0.), \n\
485 gp_Dir(0.,0.,1.)), \n\
486 605.,0.,150.,210.*PI180); \n\
488 PocessTextInDialog("Make a cone", Message);
491 void CModelingDoc::OnSphere()
493 AIS_ListOfInteractive aList;
494 myAISContext->DisplayedObjects(aList);
495 AIS_ListIteratorOfListOfInteractive aListIterator;
496 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
497 myAISContext->Remove(aListIterator.Value());
500 TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(gp_Pnt(-200., -250., 0.), 80.).Shape();
501 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
502 myAISContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False);
503 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
504 myAISContext->Display(ais1,Standard_False);
505 TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(100., 120.*M_PI / 180).Shape();
506 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
507 myAISContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False);
508 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
509 myAISContext->Display(ais2,Standard_False);
510 TopoDS_Shape S3 = BRepPrimAPI_MakeSphere(gp_Pnt(200.,250.,0.),100.,
511 -60.*M_PI / 180, 60.*M_PI / 180).Shape();
512 Handle(AIS_Shape) ais3 = new AIS_Shape(S3);
513 myAISContext->SetColor(ais3,Quantity_NOC_RED,Standard_False);
514 myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
515 myAISContext->Display(ais3,Standard_False);
516 TopoDS_Shape S4 = BRepPrimAPI_MakeSphere(gp_Pnt(0.,0.,-300.),150.,
517 -45.*M_PI / 180, 45.*M_PI / 180, 45.*M_PI / 180).Shape();
518 Handle(AIS_Shape) ais4 = new AIS_Shape(S4);
519 myAISContext->SetColor(ais4,Quantity_NOC_MATRABLUE,Standard_False);
520 myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
521 myAISContext->Display(ais4,Standard_False);
524 TCollection_AsciiString Message ("\
526 TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(gp_Pnt(-200.,-250.,0.),80.); \n\
527 TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(100.,120.*PI180); \n\
528 TopoDS_Shape S3 = BRepPrimAPI_MakeSphere(gp_Pnt(200.,250.,0.),100., \n\
529 -60.*PI180, 60.*PI180); \n\
530 TopoDS_Shape S4 = BRepPrimAPI_MakeSphere(gp_Pnt(0.,0.,-300.),150., \n\
531 -45.*PI180, 45.*PI180, 45.*PI180); \n\
533 PocessTextInDialog("Make a sphere", Message);
536 void CModelingDoc::OnTorus()
538 AIS_ListOfInteractive aList;
539 myAISContext->DisplayedObjects(aList);
540 AIS_ListIteratorOfListOfInteractive aListIterator;
541 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
542 myAISContext->Remove(aListIterator.Value());
545 TopoDS_Shape S1 = BRepPrimAPI_MakeTorus(60., 20.).Shape();
546 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
547 myAISContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False);
548 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
549 myAISContext->Display(ais1,Standard_False);
550 TopoDS_Shape S2 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(1.,1.,1.)),
551 50., 20., 210.*M_PI / 180).Shape();
552 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
553 myAISContext->SetColor(ais2,Quantity_NOC_GREEN,Standard_False);
554 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
555 myAISContext->Display(ais2,Standard_False);
556 TopoDS_Shape S3 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(-200.,-150.,-100),gp_Dir(0.,1.,0.)),
557 60., 20., -45.*M_PI / 180, 45.*M_PI / 180, 90.*M_PI / 180).Shape();
558 Handle(AIS_Shape) ais3= new AIS_Shape(S3);
559 myAISContext->SetColor(ais3,Quantity_NOC_CORAL,Standard_False);
560 myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
561 myAISContext->Display(ais3,Standard_False);
564 TCollection_AsciiString Message ("\
566 TopoDS_Shape S1 = BRepPrimAPI_MakeTorus(60.,20.); \n\
567 TopoDS_Shape S2 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(1.,1.,1.)), \n\
568 50.,20.,210.*PI180); \n\
569 TopoDS_Shape S3 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(-200.,-150.,-100),gp_Dir(0.,1.,0.)), \n\
570 60.,20.,-45.*PI180,45.*PI180,90.*PI180); \n\
572 PocessTextInDialog("Make a torus", Message);
575 void CModelingDoc::OnWedge()
577 AIS_ListOfInteractive aList;
578 myAISContext->DisplayedObjects(aList);
579 AIS_ListIteratorOfListOfInteractive aListIterator;
580 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
581 myAISContext->Remove(aListIterator.Value());
584 TopoDS_Shape S1 = BRepPrimAPI_MakeWedge(60., 100., 80., 20.).Shape();
585 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
586 myAISContext->SetColor(ais1,Quantity_NOC_AZURE,Standard_False);
587 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
588 myAISContext->Display(ais1,Standard_False);
589 TopoDS_Shape S2 = BRepPrimAPI_MakeWedge(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(0.,0.,1.)),
590 60., 50., 80., 25., -10., 40., 70.).Shape();
591 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
592 myAISContext->SetColor(ais2,Quantity_NOC_CORAL2,Standard_False);
593 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
594 myAISContext->Display(ais2,Standard_False);
597 TCollection_AsciiString Message ("\
599 TopoDS_Shape S1 = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
600 TopoDS_Shape S2 = BRepPrimAPI_MakeWedge(gp_Ax2(gp_Pnt(100.,100.,0.),gp_Dir(0.,0.,1.)), \n\
601 60.,50.,80.,25.,-10.,40.,70.); \n\
603 PocessTextInDialog("Make a wedge", Message);
606 void CModelingDoc::OnPrism()
608 AIS_ListOfInteractive aList;
609 myAISContext->DisplayedObjects(aList);
610 AIS_ListIteratorOfListOfInteractive aListIterator;
611 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
612 myAISContext->Remove(aListIterator.Value());
615 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.));
616 Handle(AIS_Shape) ais1 = new AIS_Shape(V1);
617 myAISContext->Display(ais1,Standard_False);
618 TopoDS_Shape S1 = BRepPrimAPI_MakePrism(V1,gp_Vec(0.,0.,100.));
619 Handle(AIS_Shape) ais2 = new AIS_Shape(S1);
620 myAISContext->Display(ais2,Standard_False);
622 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-150.,-150,0.), gp_Pnt(-50.,-50,0.));
623 Handle(AIS_Shape) ais3 = new AIS_Shape(E);
624 myAISContext->Display(ais3,Standard_False);
625 TopoDS_Shape S2 = BRepPrimAPI_MakePrism(E,gp_Vec(0.,0.,100.));
626 Handle(AIS_Shape) ais4 = new AIS_Shape(S2);
627 myAISContext->SetColor(ais4,Quantity_NOC_CORAL2,Standard_False);
628 myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
629 myAISContext->Display(ais4,Standard_False);
631 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.));
632 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.));
633 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.));
634 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3);
635 TopoDS_Shape S3 = BRepPrimAPI_MakePrism(W,gp_Vec(0.,0.,100.));
636 Handle(AIS_Shape) ais5 = new AIS_Shape(W);
637 myAISContext->Display(ais5,Standard_False);
638 Handle(AIS_Shape) ais6 = new AIS_Shape(S3);
639 myAISContext->SetColor(ais6,Quantity_NOC_GREEN,Standard_False);
640 myAISContext->SetMaterial(ais6,Graphic3d_NOM_PLASTIC,Standard_False);
641 myAISContext->Display(ais6,Standard_False);
643 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.);
644 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
645 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);
646 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc);
647 Handle(AIS_Shape) ais7 = new AIS_Shape(F);
648 myAISContext->Display(ais7,Standard_False);
649 TopoDS_Shape S4 = BRepPrimAPI_MakePrism(F,gp_Vec(0.,0.,100.));
650 Handle(AIS_Shape) ais8 = new AIS_Shape(S4);
651 myAISContext->SetColor(ais8,Quantity_NOC_MATRABLUE,Standard_False);
652 myAISContext->SetMaterial(ais8,Graphic3d_NOM_PLASTIC,Standard_False);
653 myAISContext->Display(ais8,Standard_False);
656 TCollection_AsciiString Message ("\
658 --- Prism a vertex -> result is an edge --- \n\
660 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.)); \n\
661 TopoDS_Shape S1 = BRepBuilderAPI_MakePrism(V1,gp_Vec(0.,0.,100.)); \n\
663 --- Prism an edge -> result is a face --- \n\
665 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-150.,-150,0.), gp_Pnt(-50.,-50,0.)); \n\
666 TopoDS_Shape S2 = BRepPrimAPI_MakePrism(E,gp_Vec(0.,0.,100.)); \n\
668 --- Prism an wire -> result is a shell --- \n\
670 TopoDS_Edge E1 = BREpBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)); \n\
671 TopoDS_Edge E2 = BREpBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)); \n\
672 TopoDS_Edge E3 = BREpBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)); \n\
673 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3); \n\
674 TopoDS_Shape S3 = BRepPrimAPI_MakePrism(W,gp_Vec(0.,0.,100.)); \n\
676 --- Prism a face or a shell -> result is a solid --- \n\
678 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.gp_Dir(0.,0.,1.)), 80.); \n\
679 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c); \n\
680 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec); \n\
681 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp::XOY(),Wc); \n\
682 TopoDS_Shape S4 = BRepBuilderAPI_MakePrism(F,gp_Vec(0.,0.,100.)); \n\
684 PocessTextInDialog("Make a prism", Message);
687 void CModelingDoc::OnRevol()
689 AIS_ListOfInteractive aList;
690 myAISContext->DisplayedObjects(aList);
691 AIS_ListIteratorOfListOfInteractive aListIterator;
692 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
693 myAISContext->Remove(aListIterator.Value());
696 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.));
697 Handle(AIS_Shape) ais1 = new AIS_Shape(V1);
698 myAISContext->Display(ais1,Standard_False);
699 gp_Ax1 axe = gp_Ax1(gp_Pnt(-170.,-170.,0.),gp_Dir(0.,0.,1.));
700 Handle(Geom_Axis1Placement) Gax1 = new Geom_Axis1Placement(axe);
701 Handle (AIS_Axis) ax1 = new AIS_Axis(Gax1);
702 myAISContext->Display(ax1,Standard_False);
703 TopoDS_Shape S1 = BRepPrimAPI_MakeRevol(V1,axe);
704 Handle(AIS_Shape) ais2 = new AIS_Shape(S1);
705 myAISContext->Display(ais2,Standard_False);
707 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-120.,-120,0.), gp_Pnt(-120.,-120,100.));
708 Handle(AIS_Shape) ais3 = new AIS_Shape(E);
709 myAISContext->Display(ais3,Standard_False);
710 axe = gp_Ax1(gp_Pnt(-100.,-100.,0.),gp_Dir(0.,0.,1.));
711 Handle(Geom_Axis1Placement) Gax2 = new Geom_Axis1Placement(axe);
712 Handle (AIS_Axis) ax2 = new AIS_Axis(Gax2);
713 myAISContext->Display(ax2,Standard_False);
714 TopoDS_Shape S2 = BRepPrimAPI_MakeRevol(E,axe);
715 Handle(AIS_Shape) ais4 = new AIS_Shape(S2);
716 myAISContext->SetColor(ais4,Quantity_NOC_YELLOW,Standard_False);
717 myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
718 myAISContext->Display(ais4,Standard_False);
720 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.));
721 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.));
722 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.));
723 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3);
724 axe = gp_Ax1(gp_Pnt(0.,0.,30.),gp_Dir(0.,1.,0.));
725 Handle(Geom_Axis1Placement) Gax3 = new Geom_Axis1Placement(axe);
726 Handle (AIS_Axis) ax3 = new AIS_Axis(Gax3);
727 myAISContext->Display(ax3,Standard_False);
728 TopoDS_Shape S3 = BRepPrimAPI_MakeRevol(W,axe, 210.*M_PI/180);
729 Handle(AIS_Shape) ais5 = new AIS_Shape(W);
730 myAISContext->Display(ais5,Standard_False);
731 Handle(AIS_Shape) ais6 = new AIS_Shape(S3);
732 myAISContext->SetColor(ais6,Quantity_NOC_GREEN,Standard_False);
733 myAISContext->SetMaterial(ais6,Graphic3d_NOM_PLASTIC,Standard_False);
734 myAISContext->Display(ais6,Standard_False);
736 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.);
737 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
738 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);
739 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc);
740 axe = gp_Ax1(gp_Pnt(290,290.,0.),gp_Dir(0.,1,0.));
741 Handle(Geom_Axis1Placement) Gax4 = new Geom_Axis1Placement(axe);
742 Handle (AIS_Axis) ax4 = new AIS_Axis(Gax4);
743 myAISContext->Display(ax4,Standard_False);
744 TopoDS_Shape S4 = BRepPrimAPI_MakeRevol(F,axe, 90.*M_PI/180);
745 Handle(AIS_Shape) ais8 = new AIS_Shape(S4);
746 myAISContext->SetColor(ais8,Quantity_NOC_MATRABLUE,Standard_False);
747 myAISContext->SetMaterial(ais8,Graphic3d_NOM_PLASTIC,Standard_False);
748 myAISContext->Display(ais8,Standard_False);
751 TCollection_AsciiString Message ("\
753 --- Revol of a vertex -> result is an edge --- \n\
755 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-200.,-200.,0.)); \n\
756 gp_Ax1 axe = gp_Ax1(gp_Pnt(-170.,-170.,0.),gp_Dir(0.,0.,1.)); \n\
757 TopoDS_Shape S1 = BRepPrimAPI_MakeRevol(V1,axe); \n\
759 --- Revol of an edge -> result is a face --- \n\
761 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(gp_Pnt(-120.,-120,0.), gp_Pnt(-120.,-120,100.)); \n\
762 axe = gp_Ax1(gp_Pnt(-100.,-100.,0.),gp_Dir(0.,0.,1.)); \n\
763 TopoDS_Shape S2 = BRepPrimAPI_MakeRevol(E,axe); \n\
765 --- Revol of a wire -> result is a shell --- \n\
767 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(50.,0.,0.)); \n\
768 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,0.,0.), gp_Pnt(50.,50.,0.)); \n\
769 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(50.,50.,0.), gp_Pnt(0.,0.,0.)); \n\
770 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3); \n\
771 axe = gp_Ax1(gp_Pnt(0.,0.,30.),gp_Dir(0.,1.,0.)); \n\
772 TopoDS_Shape S3 = BRepPrimAPI_MakeRevol(W,axe, 210.*PI180); \n\
774 --- Revol of a face -> result is a solid --- \n\
776 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(200.,200.,0.),gp_Dir(0.,0.,1.)), 80.); \n\
777 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c); \n\
778 TopoDS_Wire Wc = BRepBuilderPI_MakeWire(Ec); \n\
779 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()),Wc); \n\
780 axe = gp_Ax1(gp_Pnt(290,290.,0.),gp_Dir(0.,1,0.)); \n\
781 TopoDS_Shape S4 = BRepPrimAPI_MakeRevol(F,axe, 90.*PI180); \n\
783 PocessTextInDialog("Make a revol", Message);
786 void CModelingDoc::OnPipe()
788 AIS_ListOfInteractive aList;
789 myAISContext->DisplayedObjects(aList);
790 AIS_ListIteratorOfListOfInteractive aListIterator;
791 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
792 myAISContext->Remove(aListIterator.Value());
795 TColgp_Array1OfPnt CurvePoles(1,4);
796 gp_Pnt pt = gp_Pnt(0.,0.,0.);
798 pt = gp_Pnt(20.,50.,0.);
800 pt = gp_Pnt(60.,100.,0.);
802 pt = gp_Pnt(150.,0.,0.);
804 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);
805 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);
806 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);
807 Handle(AIS_Shape) ais1 = new AIS_Shape(W);
808 myAISContext->Display(ais1,Standard_False);
811 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.);
812 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
813 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);
814 Handle(AIS_Shape) ais3 = new AIS_Shape(Wc);
815 myAISContext->Display(ais3,Standard_False);
816 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::ZOX()),Wc);
817 TopoDS_Shape S = BRepOffsetAPI_MakePipe(W,F);
818 Handle(AIS_Shape) ais2 = new AIS_Shape(S);
819 myAISContext->SetColor(ais2,Quantity_NOC_MATRABLUE,Standard_False);
820 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
821 myAISContext->Display(ais2,Standard_False);
824 TCollection_AsciiString Message ("\
826 TColgp_Array1OfPnt CurvePoles(1,6);\n\
827 gp_Pnt pt = gp_Pnt(0.,0.,0.);\n\
828 CurvePoles(1) = pt;\n\
829 pt = gp_Pnt(20.,50.,0.);\n\
830 CurvePoles(2) = pt;\n\
831 pt = gp_Pnt(60.,100.,0.);\n\
832 CurvePoles(3) = pt;\n\
833 pt = gp_Pnt(150.,0.,0.);\n\
834 CurvePoles(4) = pt;\n\
835 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);\n\
836 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);\n\
837 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);\n\
838 gp_Circ c = gp_Circ(gp_Ax2(gp_Pnt(0.,0.,0.),gp_Dir(0.,1.,0.)),10.);\n\
839 TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);\n\
840 TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);\n\
841 TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln(gp::ZOX()),Wc);\n\
842 TopoDS_Shape S = BRepBuilderAPI_MakePipe(W,F);\n\
844 PocessTextInDialog("Make a pipe", Message);
848 void CModelingDoc::OnThru()
850 AIS_ListOfInteractive aList;
851 myAISContext->DisplayedObjects(aList);
852 AIS_ListIteratorOfListOfInteractive aListIterator;
853 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
854 myAISContext->Remove(aListIterator.Value());
857 gp_Circ c1 = gp_Circ(gp_Ax2(gp_Pnt(-100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);
858 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(c1);
859 TopoDS_Wire W1 = BRepBuilderAPI_MakeWire(E1);
860 Handle(AIS_Shape) sec1 = new AIS_Shape(W1);
861 myAISContext->Display(sec1,Standard_False);
862 gp_Circ c2 = gp_Circ(gp_Ax2(gp_Pnt(-10.,0.,-0.),gp_Dir(0.,0.,1.)),40.);
863 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(c2);
864 TopoDS_Wire W2 = BRepBuilderAPI_MakeWire(E2);
865 Handle(AIS_Shape) sec2 = new AIS_Shape(W2);
866 myAISContext->Display(sec2,Standard_False);
867 gp_Circ c3 = gp_Circ(gp_Ax2(gp_Pnt(-75.,0.,100.),gp_Dir(0.,0.,1.)),40.);
868 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(c3);
869 TopoDS_Wire W3 = BRepBuilderAPI_MakeWire(E3);
870 Handle(AIS_Shape) sec3 = new AIS_Shape(W3);
871 myAISContext->Display(sec3,Standard_False);
872 gp_Circ c4= gp_Circ(gp_Ax2(gp_Pnt(0.,0.,200.),gp_Dir(0.,0.,1.)),40.);
873 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);
874 TopoDS_Wire W4 = BRepBuilderAPI_MakeWire(E4);
875 Handle(AIS_Shape) sec4 = new AIS_Shape(W4);
876 myAISContext->Display(sec4,Standard_False);
877 BRepOffsetAPI_ThruSections generator(Standard_False,Standard_True);
878 generator.AddWire(W1);
879 generator.AddWire(W2);
880 generator.AddWire(W3);
881 generator.AddWire(W4);
883 TopoDS_Shape S1 = generator.Shape();
884 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
885 myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
886 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
887 myAISContext->Display(ais1,Standard_False);
889 gp_Circ c1b = gp_Circ(gp_Ax2(gp_Pnt(100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);
890 TopoDS_Edge E1b = BRepBuilderAPI_MakeEdge(c1b);
891 TopoDS_Wire W1b = BRepBuilderAPI_MakeWire(E1b);
892 Handle(AIS_Shape) sec1b = new AIS_Shape(W1b);
893 myAISContext->Display(sec1b,Standard_False);
894 gp_Circ c2b = gp_Circ(gp_Ax2(gp_Pnt(210.,0.,-0.),gp_Dir(0.,0.,1.)),40.);
895 TopoDS_Edge E2b = BRepBuilderAPI_MakeEdge(c2b);
896 TopoDS_Wire W2b = BRepBuilderAPI_MakeWire(E2b);
897 Handle(AIS_Shape) sec2b = new AIS_Shape(W2b);
898 myAISContext->Display(sec2b,Standard_False);
899 gp_Circ c3b = gp_Circ(gp_Ax2(gp_Pnt(275.,0.,100.),gp_Dir(0.,0.,1.)),40.);
900 TopoDS_Edge E3b = BRepBuilderAPI_MakeEdge(c3b);
901 TopoDS_Wire W3b = BRepBuilderAPI_MakeWire(E3b);
902 Handle(AIS_Shape) sec3b = new AIS_Shape(W3b);
903 myAISContext->Display(sec3b,Standard_False);
904 gp_Circ c4b= gp_Circ(gp_Ax2(gp_Pnt(200.,0.,200.),gp_Dir(0.,0.,1.)),40.);
905 TopoDS_Edge E4b = BRepBuilderAPI_MakeEdge(c4b);
906 TopoDS_Wire W4b = BRepBuilderAPI_MakeWire(E4b);
907 Handle(AIS_Shape) sec4b = new AIS_Shape(W4b);
908 myAISContext->Display(sec4b,Standard_False);
909 BRepOffsetAPI_ThruSections generatorb(Standard_True,Standard_False);
910 generatorb.AddWire(W1b);
911 generatorb.AddWire(W2b);
912 generatorb.AddWire(W3b);
913 generatorb.AddWire(W4b);
915 TopoDS_Shape S2 = generatorb.Shape();
916 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
917 myAISContext->SetColor(ais2,Quantity_NOC_ALICEBLUE,Standard_False);
918 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
919 myAISContext->Display(ais2,Standard_False);
922 TCollection_AsciiString Message ("\
924 ---------- ruled -------------- \n\
926 gp_Circ c1 = gp_Circ(gp_Ax2(gp_Pnt(-100.,0.,-100.),gp_Dir(0.,0.,1.)),40.);\n\
927 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(c1);\n\
928 TopoDS_Wire W1 = BRepBuilderAPI_MakeWire(E1);\n\
929 gp_Circ c2 = gp_Circ(gp_Ax2(gp_Pnt(-10.,0.,-0.),gp_Dir(0.,0.,1.)),40.);\n\
930 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(c2);\n\
931 TopoDS_Wire W2 = BRepBuilderAPI_MakeWire(E2);\n\
932 gp_Circ c3 = gp_Circ(gp_Ax2(gp_Pnt(-75.,0.,100.),gp_Dir(0.,0.,1.)),40.);\n\
933 TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(c3);\n\
934 TopoDS_Wire W3 = BRepBuilderAPI_MakeWire(E3);\n\
935 gp_Circ c4= gp_Circ(gp_Ax2(gp_Pnt(0.,0.,200.),gp_Dir(0.,0.,1.)),40.);\n\
936 TopoDS_Edge E4 = BRep>BuilderAPI_MakeEdge(c4);\n\
937 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);\n\
938 TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(c4);\n\
939 TopoDS_Wire W4 = BRepBuilderAPI_MakeWire(E4);\n\
940 BRepOffsetAPI_ThruSections generator(Standard_False,Standard_True);\n\
941 generator.AddWire(W1);\n\
942 generator.AddWire(W2);\n\
943 generator.AddWire(W3);\n\
944 generator.AddWire(W4);\n\
945 generator.Build();\n\
946 TopoDS_Shape S1 = generator.Shape();\n\
948 ---------- smooth -------------- \n\
950 gp_Circ c1b = gp_Circ(gp_Ax2(gp_Pnt(100.,0.,-100.),gp_Dir(0.,0.,1.)),40.); \n\
951 TopoDS_Edge E1b = BRepBuilderAPI_MakeEdge(c1b); \n\
952 TopoDS_Wire W1b = BRepBuilderAPI_MakeWire(E1b); \n\
953 gp_Circ c2b = gp_Circ(gp_Ax2(gp_Pnt(210.,0.,-0.),gp_Dir(0.,0.,1.)),40.); \n\
954 TopoDS_Edge E2b = BRepBuilderAPI_MakeEdge(c2b);\n\
955 TopoDS_Wire W2b = BRepBuilderAPI_MakeWire(E2b); \n\
956 gp_Circ c3b = gp_Circ(gp_Ax2(gp_Pnt(275.,0.,100.),gp_Dir(0.,0.,1.)),40.);\n\
957 TopoDS_Edge E3b = BRepBuilderAPI_MakeEdge(c3b);\n\
958 TopoDS_Wire W3b = BRepBuilderAPI_MakeWire(E3b);\n\
959 gp_Circ c4b= gp_Circ(gp_Ax2(gp_Pnt(200.,0.,200.),gp_Dir(0.,0.,1.)),40.);\n\
960 TopoDS_Edge E4b = BRepBuilderAPI_MakeEdge(c4b);\n\
961 TopoDS_Wire W4b = BRepBuilderAPI_MakeWire(E4b);\n\
962 BRepOffsetAPI_ThruSections generatorb(Standard_True,Standard_False);\n\
963 generatorb.AddWire(W1b);\n\
964 generatorb.AddWire(W2b);\n\
965 generatorb.AddWire(W3b);\n\
966 generatorb.AddWire(W4b);\n\
967 generatorb.Build();\n\
968 TopoDS_Shape S2 = generatorb.Shape();\n\
970 PocessTextInDialog("Make a Thru sections", Message);
974 void CModelingDoc::OnEvolved()
976 AIS_ListOfInteractive aList;
977 myAISContext->DisplayedObjects(aList);
978 AIS_ListIteratorOfListOfInteractive aListIterator;
979 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
980 myAISContext->Remove(aListIterator.Value());
983 BRepBuilderAPI_MakePolygon P;
984 P.Add(gp_Pnt(0.,0.,0.));
985 P.Add(gp_Pnt(200.,0.,0.));
986 P.Add(gp_Pnt(200.,200.,0.));
987 P.Add(gp_Pnt(0.,200.,0.));
988 P.Add(gp_Pnt(0.,0.,0.));
989 TopoDS_Wire W = P.Wire();
991 Handle(AIS_Shape) ais1 = new AIS_Shape(W);
992 myAISContext->Display(ais1,Standard_False);
994 TopoDS_Wire wprof = BRepBuilderAPI_MakePolygon(gp_Pnt(0.,0.,0.),gp_Pnt(-60.,-60.,-200.));
996 Handle(AIS_Shape) ais3 = new AIS_Shape(wprof);
997 myAISContext->Display(ais3,Standard_False);
1000 TopoDS_Shape S = BRepOffsetAPI_MakeEvolved(W,wprof,GeomAbs_Arc,Standard_True,Standard_False,Standard_True,0.0001);
1002 Handle(AIS_Shape) ais2 = new AIS_Shape(S);
1003 myAISContext->SetColor(ais2,Quantity_NOC_MATRABLUE,Standard_False);
1004 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1005 myAISContext->Display(ais2,Standard_False);
1008 TCollection_AsciiString Message ("\
1010 ---------- Evolved shape -------------- \n\
1012 BRepBuilderAPI_MakePolygon P;\n\
1013 P.Add(gp_Pnt(0.,0.,0.));\n\
1014 P.Add(gp_Pnt(200.,0.,0.));\n\
1015 P.Add(gp_Pnt(200.,200.,0.));\n\
1016 P.Add(gp_Pnt(0.,200.,0.));\n\
1017 P.Add(gp_Pnt(0.,0.,0.));\n\
1018 TopoDS_Wire W = P.Wire();\n\
1019 TopoDS_Wire wprof = BRepBuilderAPI_MakePolygon(gp_Pnt(0.,0.,0.),gp_Pnt(-60.,-60.,-200.));\n\
1020 TopoDS_Shape S = BRepBuilderAPI_MakeEvolved(W,wprof,GeomAbs_Arc,Standard_True,Standard_False,Standard_True,0.0001);\n\
1022 PocessTextInDialog("Make an evolved shape", Message);
1026 void CModelingDoc::OnDraft()
1028 AIS_ListOfInteractive aList;
1029 myAISContext->DisplayedObjects(aList);
1030 AIS_ListIteratorOfListOfInteractive aListIterator;
1031 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1032 myAISContext->Remove(aListIterator.Value());
1035 TopoDS_Shape S = BRepPrimAPI_MakeBox(200., 300., 150.).Shape();
1036 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
1037 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1038 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1039 myAISContext->Display(ais1,Standard_False);
1042 BRepOffsetAPI_DraftAngle adraft(S);
1044 for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {
1045 TopoDS_Face F = TopoDS::Face(Ex.Current());
1046 Handle(Geom_Plane) surf = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F));
1047 gp_Pln apln = surf->Pln();
1048 gp_Dir dirF = apln.Axis().Direction();
1049 if (dirF.IsNormal(gp_Dir(0.,0.,1.),Precision::Angular()))
1050 adraft.Add(F, gp_Dir(0.,0.,1.), 15.*M_PI/180, gp_Pln(gp::XOY()));
1052 ais1->Set(adraft.Shape());
1053 myAISContext->Redisplay(ais1,Standard_False);
1056 TCollection_AsciiString Message ("\
1058 ---------- Tapered shape -------------- \n\
1060 TopoDS_Shape S = BRepPrimAPI_MakeBox(200.,300.,150.);\n\
1061 BRepOffsetAPI_DraftAngle adraft(S);\n\
1062 TopExp_Explorer Ex;\n\
1063 for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {\n\
1064 TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
1065 Handle(Geom_Plane) surf = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F));\n\
1066 gp_Pln apln = surf->Pln();\n\
1067 gp_Dir dirF = apln.Axis().Direction();\n\
1068 if (dirF.IsNormal(gp_Dir(0.,0.,1.),Precision::Angular()))\n\
1069 adraft.Add(F, gp_Dir(0.,0.,1.), 15.*PI180, gp_Pln(gp::XOY()));\n\
1072 PocessTextInDialog("Make a tapered shape", Message);
1076 /* =================================================================================
1077 ==================== O P E R A T I O N S ====================================
1078 ================================================================================= */
1080 void CModelingDoc::OnCut()
1082 AIS_ListOfInteractive aList;
1083 myAISContext->DisplayedObjects(aList);
1084 AIS_ListIteratorOfListOfInteractive aListIterator;
1085 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1086 myAISContext->Remove(aListIterator.Value());
1089 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200, 60, 60).Shape();
1091 Handle (AIS_Shape) ais1 = new AIS_Shape(theBox);
1092 myAISContext->SetDisplayMode(ais1,1,Standard_False);
1093 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1094 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1095 myAISContext->Display(ais1,Standard_False);
1096 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1097 myAISContext->SetSelected (anIO1, Standard_False);
1102 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100, 20, 20), 80).Shape();
1103 Handle (AIS_Shape) ais2 = new AIS_Shape(theSphere);
1104 myAISContext->SetDisplayMode(ais2,1,Standard_False);
1105 myAISContext->SetColor(ais2,Quantity_NOC_YELLOW,Standard_False);
1106 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1107 myAISContext->Display(ais2,Standard_False);
1108 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
1109 myAISContext->SetSelected (anIO2, Standard_False);
1113 TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox);
1115 myAISContext->Erase(ais1,Standard_False);
1116 myAISContext->Erase(ais2,Standard_False);
1118 Handle (AIS_Shape) aSection = new AIS_Shape(ShapeCut);
1119 myAISContext->SetDisplayMode(aSection,1,Standard_False);
1120 myAISContext->SetColor(aSection,Quantity_NOC_RED,Standard_False);
1121 myAISContext->SetMaterial(aSection,Graphic3d_NOM_PLASTIC,Standard_False);
1122 myAISContext->Display(aSection,Standard_False);
1123 const Handle(AIS_InteractiveObject)& anIOSection = aSection;
1124 myAISContext->SetSelected (anIOSection, Standard_False);
1127 TCollection_AsciiString Message ("\
1129 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,40,40); \n\
1131 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80); \n\
1133 TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox); \n\
1135 PocessTextInDialog("Cut the sphere with a box", Message);
1149 void CModelingDoc::OnFuse()
1151 AIS_ListOfInteractive aList;
1152 myAISContext->DisplayedObjects(aList);
1153 AIS_ListIteratorOfListOfInteractive aListIterator;
1154 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1155 myAISContext->Remove(aListIterator.Value());
1159 TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(60, 200, 70).Shape();
1160 Handle (AIS_Shape) ais1 = new AIS_Shape(theBox1);
1161 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1162 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1163 myAISContext->Display(ais1,Standard_False);
1164 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1165 myAISContext->SetSelected (anIO1, Standard_False);
1169 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P, 20, 150, 110).Shape();
1170 Handle (AIS_Shape) ais2 = new AIS_Shape(theBox2);
1171 myAISContext->SetColor(ais2,Quantity_NOC_YELLOW,Standard_False);
1172 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1173 myAISContext->Display(ais2,Standard_False);
1174 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
1175 myAISContext->SetSelected (anIO2, Standard_False);
1179 TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1,theBox2);
1181 myAISContext->Erase(ais1,Standard_True);
1182 myAISContext->Erase(ais2,Standard_True);
1184 Handle (AIS_Shape) aFusion = new AIS_Shape(FusedShape);
1185 myAISContext->SetDisplayMode(aFusion,1,Standard_False);
1186 myAISContext->SetColor(aFusion,Quantity_NOC_RED,Standard_False);
1187 myAISContext->SetMaterial(aFusion,Graphic3d_NOM_PLASTIC,Standard_False);
1188 myAISContext->Display(aFusion,Standard_False);
1189 const Handle(AIS_InteractiveObject)& anIOFusion = aFusion;
1190 myAISContext->SetSelected (anIOFusion, Standard_False);
1193 TCollection_AsciiString Message ("\
1195 TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(50,200,70); \n\
1197 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(-30,150,70); \n\
1199 TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1,theBox2); \n");
1200 PocessTextInDialog("Fuse the boxes", Message);
1204 void CModelingDoc::OnCommon()
1206 AIS_ListOfInteractive aList;
1207 myAISContext->DisplayedObjects(aList);
1208 AIS_ListIteratorOfListOfInteractive aListIterator;
1209 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1210 myAISContext->Remove(aListIterator.Value());
1213 gp_Ax2 axe(gp_Pnt(10,10,10),gp_Dir(1,2,1));
1214 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(axe, 60, 80, 100).Shape();
1216 Handle(AIS_Shape) aboxshape=new AIS_Shape(theBox);
1217 myAISContext->SetColor(aboxshape,Quantity_NOC_YELLOW,Standard_False);
1218 myAISContext->SetMaterial(aboxshape,Graphic3d_NOM_PLASTIC,Standard_False);
1219 myAISContext->SetDisplayMode(aboxshape,1,Standard_False);
1220 myAISContext->SetTransparency(aboxshape,0.2,Standard_False);
1221 myAISContext->Display(aboxshape,Standard_False);
1222 const Handle(AIS_InteractiveObject)& anIOBoxShape = aboxshape;
1223 myAISContext->SetSelected (anIOBoxShape, Standard_False);
1227 TopoDS_Shape theWedge = BRepPrimAPI_MakeWedge(60., 100., 80., 20.).Shape();
1229 Handle(AIS_Shape) awedge = new AIS_Shape(theWedge);
1230 myAISContext->SetColor(awedge,Quantity_NOC_RED,Standard_False);
1231 myAISContext->SetMaterial(awedge,Graphic3d_NOM_PLASTIC,Standard_False);
1232 myAISContext->SetTransparency(awedge,0.0,Standard_False);
1233 myAISContext->Display(awedge,Standard_False);
1234 const Handle(AIS_InteractiveObject)& anIOWedge = awedge;
1235 myAISContext->SetSelected (anIOWedge, Standard_False);
1239 TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(theBox,theWedge);
1241 myAISContext->Erase(aboxshape,Standard_True);
1242 myAISContext->Erase(awedge,Standard_True);
1244 Handle(AIS_Shape) acommon = new AIS_Shape(theCommonSurface);
1245 myAISContext->SetColor(acommon,Quantity_NOC_GREEN,Standard_False);
1246 myAISContext->SetMaterial(acommon,Graphic3d_NOM_PLASTIC,Standard_False);
1247 myAISContext->Display(acommon,Standard_False);
1248 const Handle(AIS_InteractiveObject)& anIOCommon = acommon;
1249 myAISContext->SetSelected (anIOCommon, Standard_False);
1251 TCollection_AsciiString Message ("\
1253 gp_Ax2 axe(gp_Pnt(10,10,10),gp_Dir(1,2,1)); \n\
1255 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(axe,60,80,100); \n\
1257 TopoDS_Shape theWedge = BRepPrimAPI_MakeWedge(60.,100.,80.,20.); \n\
1259 TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(theBox,theWedge); \n\
1262 PocessTextInDialog("Compute the common surface ", Message);
1266 void CModelingDoc::OnSection()
1269 AIS_ListOfInteractive aList;
1270 myAISContext->DisplayedObjects(aList);
1271 AIS_ListIteratorOfListOfInteractive aListIterator;
1272 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1273 myAISContext->Remove(aListIterator.Value());
1276 TopoDS_Shape atorus = BRepPrimAPI_MakeTorus(120, 20).Shape();
1278 Handle(AIS_Shape) ashape=new AIS_Shape(atorus);
1279 myAISContext->SetColor(ashape,Quantity_NOC_RED,Standard_False);
1280 myAISContext->SetMaterial(ashape,Graphic3d_NOM_PLASTIC,Standard_False);
1281 myAISContext->SetDisplayMode(ashape,1,Standard_False);
1282 myAISContext->SetTransparency(ashape,0.1,Standard_False);
1283 myAISContext->Display(ashape,Standard_False);
1286 Standard_Real radius = 120;
1287 Standard_Integer i=-3;
1290 TopoDS_Shape asphere = BRepPrimAPI_MakeSphere(gp_Pnt(26 * 3 * i, 0, 0), radius).Shape();
1292 Handle (AIS_Shape) theShape=new AIS_Shape (asphere);
1293 myAISContext->SetTransparency(theShape,0.1,Standard_False);
1294 myAISContext->SetColor(theShape,Quantity_NOC_WHITE,Standard_False);
1295 myAISContext->SetDisplayMode(theShape,1,Standard_False);
1296 myAISContext->Display(theShape,Standard_False);
1299 Standard_Boolean PerformNow=Standard_False;
1301 BRepAlgoAPI_Section section(atorus,asphere,PerformNow);
1302 section.ComputePCurveOn1(Standard_True);
1303 section.Approximation(TopOpeBRepTool_APPROX);
1306 Handle(AIS_Shape) asection=new AIS_Shape(section.Shape());
1307 myAISContext->SetDisplayMode(asection,0);
1308 myAISContext->SetColor(asection,Quantity_NOC_WHITE);
1309 myAISContext->Display(asection);
1311 myAISContext->Remove(theShape);
1314 TCollection_AsciiString Message ("\
1316 TopoDS_Shape atorus = BRepPrimAPI_MakeTorus(120,20); \n\
1317 gp_Vec V1(1,1,1); \n\
1318 Standard_Real radius = 120; \n\
1319 Standard_Integer i=-3; \n\
1320 for(i;i<=3;i++) { \n\
1321 TopoDS_Shape asphere = BRepPrimAPI_MakeSphere(gp_Pnt(78*i,0,0),radius); \n\
1322 Standard_Boolean PerformNow=Standard_False; \n\
1323 BRepAlgoAPI_Section section(atorus,asphere,PerformNow); \n\
1324 section.ComputePCurveOn1(Standard_True); \n\
1325 section.Approximation(TopOpeBRepTool_APPROX); \n\
1326 section.Build(); \n\
1329 PocessTextInDialog("Compute the sections ", Message);
1333 void CModelingDoc::OnPsection()
1335 AIS_ListOfInteractive aList;
1336 myAISContext->DisplayedObjects(aList);
1337 AIS_ListIteratorOfListOfInteractive aListIterator;
1338 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1339 myAISContext->Remove(aListIterator.Value());
1342 TopoDS_Shape theTorus = BRepPrimAPI_MakeTorus(35, 8).Shape();
1343 Handle(AIS_Shape) atorus = new AIS_Shape(theTorus);
1344 myAISContext->SetColor(atorus,Quantity_NOC_YELLOW,Standard_False);
1345 myAISContext->SetMaterial(atorus,Graphic3d_NOM_PLASTIC,Standard_False);
1346 myAISContext->SetTransparency(atorus,0.1,Standard_False);
1347 myAISContext->Display(atorus,Standard_False);
1348 const Handle(AIS_InteractiveObject)& anIOTorus = atorus;
1349 myAISContext->SetSelected (anIOTorus, Standard_False);
1353 gp_Pln aplane(1,0.25,3,4);
1354 Handle (Geom_Plane) thePlane = new Geom_Plane(aplane);
1355 Handle (AIS_Plane) ais1 = new AIS_Plane(thePlane);
1356 myAISContext->Display(ais1,Standard_False);
1357 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1358 myAISContext->SetSelected (anIO1, Standard_False);
1362 BRepAlgoAPI_Section section(theTorus,thePlane,Standard_False);
1363 section.ComputePCurveOn1(Standard_True);
1364 section.Approximation(TopOpeBRepTool_APPROX);
1367 Handle(AIS_Shape) asection=new AIS_Shape(section.Shape());
1368 myAISContext->SetDisplayMode(asection ,0,Standard_False);
1369 myAISContext->SetColor(asection,Quantity_NOC_WHITE,Standard_False);
1370 myAISContext->Display(asection,Standard_False);
1373 TCollection_AsciiString Message ("\
1375 TopoDS_Shape theTorus = BRepPrimAPI_MakeTorus(60.,20.); \n\
1377 gp_Pln P(1,2,1,-15); \n\
1379 TopoDS_Shape Psection = BRepAlgoAPI_Section(theTorus,P); \n\
1382 PocessTextInDialog("Compute the plane section ", Message);
1386 void CModelingDoc::OnBlend()
1388 AIS_ListOfInteractive aList;
1389 myAISContext->DisplayedObjects(aList);
1390 AIS_ListIteratorOfListOfInteractive aListIterator;
1391 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1392 myAISContext->Remove(aListIterator.Value());
1395 TopoDS_Shape Box = BRepPrimAPI_MakeBox(gp_Pnt(-400,0,0),200,230,180).Shape();
1396 Handle(AIS_Shape) ais1 = new AIS_Shape(Box);
1397 myAISContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False);
1398 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1399 myAISContext->Display(ais1,Standard_False);
1400 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1401 myAISContext->SetSelected (anIO1, Standard_False);
1405 BRepFilletAPI_MakeFillet fillet(Box);
1407 for (TopExp_Explorer ex(Box,TopAbs_EDGE); ex.More(); ex.Next()) {
1408 TopoDS_Edge Edge =TopoDS::Edge(ex.Current());
1409 fillet.Add(20,Edge);
1412 myAISContext->Remove(ais1,Standard_False);
1414 TopoDS_Shape blendedBox = fillet.Shape();
1415 Handle(AIS_Shape) aBlendbox = new AIS_Shape(blendedBox);
1416 myAISContext->SetColor(aBlendbox,Quantity_NOC_YELLOW,Standard_False);
1417 myAISContext->SetMaterial(aBlendbox,Graphic3d_NOM_PLASTIC,Standard_False);
1418 myAISContext->Display(aBlendbox,Standard_False);
1419 const Handle(AIS_InteractiveObject)& anIOBlendBox = aBlendbox;
1420 myAISContext->SetSelected (anIOBlendBox, Standard_False);
1425 gp_Pnt P1(250,150,75);
1426 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(300, 200, 200).Shape();
1427 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(P1, 120, 180, 70).Shape();
1429 TopoDS_Shape fusedShape = BRepAlgoAPI_Fuse(S1,S2);
1430 Handle(AIS_Shape) ais2 = new AIS_Shape(fusedShape);
1431 myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False);
1432 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1433 myAISContext->Display(ais2,Standard_False);
1434 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
1435 myAISContext->SetSelected (anIO2, Standard_False);
1438 BRepFilletAPI_MakeFillet fill(fusedShape);
1440 for (TopExp_Explorer ex1(fusedShape,TopAbs_EDGE); ex1.More(); ex1.Next()) {
1441 TopoDS_Edge E =TopoDS::Edge(ex1.Current());
1445 for (Standard_Integer i = 1;i<=fill.NbContours();i++) {
1446 Standard_Real longueur(fill.Length(i));
1447 Standard_Real Rad(0.15*longueur);
1448 fill.SetRadius(Rad,i, 1);
1451 TopoDS_Shape blendedFusedSolids = fill.Shape();
1453 Handle(AIS_Shape) aBlend = new AIS_Shape(blendedFusedSolids);
1454 myAISContext->SetColor(aBlend,Quantity_NOC_RED,Standard_False);
1455 myAISContext->SetMaterial(aBlend,Graphic3d_NOM_PLASTIC,Standard_False);
1456 myAISContext->Display(aBlend,Standard_False);
1458 myAISContext->Remove(ais2,Standard_False);
1462 TCollection_AsciiString Message ("\
1465 TopoDS_Shape Box = BRepPrimAPI_MakeBox(gp_Pnt(-400,0,0),200,230,180);\n\
1467 BRepPrimAPI_MakeFillet fillet(Box);\n\
1469 for (TopExp_Explorer ex(Box,TopAbs_EDGE); ex.More(); ex.Next()) {\n\
1470 TopoDS_Edge Edge =TopoDS::Edge(ex.Current());\n\
1471 fillet.Add(20,Edge);\n\
1473 TopoDS_Shape blendedBox = fillet.Shape();\n\
1475 ////////////////////////////////////////////////////////////////////////\n\
1479 //Warning : On the acute angles of the boxes a fillet is created. \n\
1480 On the angles of fusion a blend is created. \n\
1482 gp_Pnt P1(150,150,75);\n\
1483 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(300,200,200);\n\
1484 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(P1,100,200,70);\n\
1486 TopoDS_Shape fusedShape = BRepAlgoAPI_Fuse(S1,S2);\n\
1487 BRepPrimAPI_MakeFillet fill(fusedShape);\n\
1489 for (TopExp_Explorer ex1(fusedShape,TopAbs_EDGE); ex1.More(); ex1.Next()) {\n\
1490 TopoDS_Edge E =TopoDS::Edge(ex1.Current());\n\
1494 for (Standard_Integer i = 1;i<=fill.NbContours();i++) {\n\
1495 Standard_Real longueur(fill.Length(i));\n\
1496 Standard_Real Rad(0.2*longueur);\n\
1497 fill.SetRadius(Rad,i);\n\
1500 TopoDS_Shape blendedFusedSolids = fill.Shape(); \n");
1502 PocessTextInDialog("Compute the blend on the edges ", Message);
1505 void CModelingDoc::OnEvolvedblend()
1508 AIS_ListOfInteractive aList;
1509 myAISContext->DisplayedObjects(aList);
1510 AIS_ListIteratorOfListOfInteractive aListIterator;
1511 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1512 myAISContext->Remove(aListIterator.Value());
1515 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200, 200, 200).Shape();
1516 Handle(AIS_Shape) ais1 = new AIS_Shape(theBox);
1517 myAISContext->SetColor(ais1,Quantity_NOC_BROWN,Standard_False);
1518 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1519 myAISContext->Display(ais1,Standard_False);
1520 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1521 myAISContext->SetSelected (anIO1, Standard_False);
1525 BRepFilletAPI_MakeFillet Rake(theBox);
1527 TopExp_Explorer ex(theBox,TopAbs_EDGE);
1532 Rake.Add(8,50,TopoDS::Edge(ex.Current()));
1534 if (Rake.IsDone() ){
1535 TopoDS_Shape evolvedBox = Rake.Shape();
1536 ais1->Set(evolvedBox);
1537 myAISContext->Redisplay(ais1,Standard_False);
1538 myAISContext->SetSelected(anIO1, Standard_False);
1544 TopoDS_Shape theCylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-300, 0, 0), gp::DZ()), 100, 200).Shape();
1545 Handle(AIS_Shape) ais3 = new AIS_Shape(theCylinder);
1546 myAISContext->SetColor(ais3,Quantity_NOC_GREEN,Standard_False);
1547 myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
1548 myAISContext->Display(ais3,Standard_False);
1549 const Handle(AIS_InteractiveObject)& anIO3 = ais3;
1550 myAISContext->SetSelected (anIO3, Standard_False);
1554 BRepFilletAPI_MakeFillet fillet(theCylinder);
1556 TColgp_Array1OfPnt2d TabPoint2(1,20);
1558 for (Standard_Integer i=0; i<=19; i++) {
1559 gp_Pnt2d Point2d(i*2*M_PI/19,60*cos(i*M_PI/19-M_PI/2)+10);
1560 TabPoint2.SetValue(i+1,Point2d);
1563 TopExp_Explorer exp2(theCylinder,TopAbs_EDGE);
1564 fillet.Add(TabPoint2,TopoDS::Edge(exp2.Current()));
1566 if (fillet.IsDone() ){
1567 TopoDS_Shape LawEvolvedCylinder = fillet.Shape();
1568 ais3->Set(LawEvolvedCylinder);
1569 myAISContext->Redisplay(ais3,Standard_False);
1570 myAISContext->SetSelected(anIO3,Standard_False);
1576 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P, 200, 200, 200).Shape();
1577 Handle(AIS_Shape) ais2 = new AIS_Shape(theBox2);
1578 myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False);
1579 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
1580 myAISContext->Display(ais2,Standard_False);
1581 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
1582 myAISContext->SetSelected (anIO2, Standard_False);
1587 BRepFilletAPI_MakeFillet afillet(theBox2);
1589 TColgp_Array1OfPnt2d TabPoint(1,6);
1592 gp_Pnt2d P2(0.2,16.);
1593 gp_Pnt2d P3(0.4,25.);
1594 gp_Pnt2d P4(0.6,55.);
1595 gp_Pnt2d P5(0.8,28.);
1596 gp_Pnt2d P6(1.,20.);
1597 TabPoint.SetValue(1,P1);
1598 TabPoint.SetValue(2,P2);
1599 TabPoint.SetValue(3,P3);
1600 TabPoint.SetValue(4,P4);
1601 TabPoint.SetValue(5,P5);
1602 TabPoint.SetValue(6,P6);
1604 TopExp_Explorer exp(theBox2,TopAbs_EDGE);
1610 afillet.Add(TabPoint, TopoDS::Edge(exp.Current()));
1613 if (afillet.IsDone() ){
1614 TopoDS_Shape LawevolvedBox = afillet.Shape();
1615 ais2->Set(LawevolvedBox);
1616 myAISContext->Redisplay(ais2,Standard_False);
1617 myAISContext->SetSelected(anIO2,Standard_False);
1622 TCollection_AsciiString Message ("\
1626 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,200,200); \n\
1628 BRepPrimAPI_MakeFillet Rake(theBox); \n\
1629 ChFi3d_FilletShape FSh = ChFi3d_Rational; \n\
1630 Rake.SetFilletShape(FSh); \n\
1632 TopExp_Explorer ex(theBox,TopAbs_EDGE); \n\
1633 ex.Next(); //in order to recover the front edge \n\
1637 Rake.Add(8,50,TopoDS::Edge(ex.Current())); \n\
1640 if (Rake.IsDone() ) \n\
1641 TopoDS_Shape theBrownBox = Rake.Shape(); \n\
1643 ////////////////////////////////////////////////////////// \n\
1645 //THE GREEN CYLINDER \n\
1647 TopoDS_Shape theCylinder = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(0,0,1)),100,200); \n\
1649 BRepPrimAPI_MakeFillet fillet(theCylinder); \n\
1651 TColgp_Array1OfPnt2d TabPoint2(1,20); \n\
1653 for (Standard_Integer i=0; i<=19; i++) { \n\
1654 gp_Pnt2d Point2d(i*2*PI/19,60*cos(i*PI/19-PI/2)+10); \n\
1655 TabPoint2.SetValue(i+1,Point2d); \n\
1658 TopExp_Explorer exp2(theCylinder,TopAbs_EDGE); \n\
1659 fillet.Add(TabPoint2,TopoDS::Edge(exp2.Current())); \n\
1662 if (fillet.IsDone() ) \n\
1663 TopoDS_Shape LawEvolvedCylinder = fillet.Shape(); \n\
1665 //////////////////////////////////////////////////////////// \n\
1669 gp_Pnt P(350,0,0); \n\
1670 TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(P,200,200,200); \n\
1672 BRepPrimAPI_MakeFillet fill(theBox2); \n\
1674 TColgp_Array1OfPnt2d TabPoint(1,6); \n\
1675 gp_Pnt2d P1(0,8); \n\
1676 gp_Pnt2d P2(0.2,16); \n\
1677 gp_Pnt2d P3(0.4,25); \n\
1678 gp_Pnt2d P4(0.6,55); \n\
1679 gp_Pnt2d P5(0.8,28); \n\
1680 gp_Pnt2d P6(1,20); \n\
1681 TabPoint.SetValue(1,P1); \n\
1682 TabPoint.SetValue(2,P2); \n\
1683 TabPoint.SetValue(3,P3); \n\
1684 TabPoint.SetValue(4,P4); \n\
1685 TabPoint.SetValue(5,P5); \n\
1686 TabPoint.SetValue(6,P6); \n\
1688 TopExp_Explorer exp(theBox2,TopAbs_EDGE); \n\
1689 exp.Next(); //in order to trcover the front edge \n\
1693 fill.Add(TabPoint,TopoDS::Edge(exp.Current())); \n\
1696 if (fillet.IsDone() ) \n\
1697 TopoDS_Shape theRedBox = fill.Shape(); \n\
1700 PocessTextInDialog("Compute evolutiv blend on an edge ", Message);
1704 void CModelingDoc::OnChamf()
1706 AIS_ListOfInteractive aList;
1707 myAISContext->DisplayedObjects(aList);
1708 AIS_ListIteratorOfListOfInteractive aListIterator;
1709 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1710 myAISContext->Remove(aListIterator.Value());
1713 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(60,200,70).Shape();
1714 Handle(AIS_Shape) ais1 = new AIS_Shape(theBox);
1715 myAISContext->SetColor(ais1,Quantity_NOC_YELLOW,Standard_False);
1716 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1717 myAISContext->Display(ais1,Standard_False);
1718 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1719 myAISContext->SetSelected (anIO1, Standard_False);
1723 BRepFilletAPI_MakeChamfer MC(theBox);
1724 // add all the edges to chamfer
1725 TopTools_IndexedDataMapOfShapeListOfShape M;
1726 TopExp::MapShapesAndAncestors(theBox,TopAbs_EDGE,TopAbs_FACE,M);
1727 for (Standard_Integer i = 1;i<=M.Extent();i++) {
1728 TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
1729 TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
1733 TopoDS_Shape ChanfrenedBox = MC.Shape();
1734 Handle(AIS_Shape) aBlendedBox = new AIS_Shape(ChanfrenedBox);
1735 myAISContext->SetColor(aBlendedBox,Quantity_NOC_YELLOW,Standard_False);
1736 myAISContext->SetMaterial(aBlendedBox,Graphic3d_NOM_PLASTIC,Standard_False);
1737 myAISContext->Display(aBlendedBox,Standard_False);
1738 const Handle(AIS_InteractiveObject)& anIOBlendedBox = aBlendedBox;
1739 myAISContext->SetSelected (anIOBlendedBox, Standard_False);
1743 myAISContext->Erase(ais1,Standard_True);
1745 TCollection_AsciiString Message ("\
1747 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(130,200,170); \n\
1748 BRepFilletAPI_MakeChamfer MC(theBox); \n\
1749 TopTools_IndexedDataMapOfShapeListOfShape M; \n\
1750 TopExp::MapShapesAndAncestors(theBox,TopAbs_EDGE,TopAbs_FACE,M); \n\
1751 for (Standar1d_Integer i;i<M.Extent();i++) { \n\
1752 TopoDS_Edge E = TopoDS::Edge(M.FindKey(i)); \n\
1753 TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First()); \n\
1754 MC.Add(15,15,E,F); \n\
1756 TopoDS_Shape ChanfrenedBox = MC.Shape(); \n");
1758 PocessTextInDialog("Compute the chamfers on all the edges ", Message);
1761 /* =================================================================================
1762 ==================== L O C A L O P E R A T I O N S ========================
1763 ================================================================================= */
1765 void CModelingDoc::OnPrismLocal()
1767 AIS_ListOfInteractive aList;
1768 myAISContext->DisplayedObjects(aList);
1769 AIS_ListIteratorOfListOfInteractive aListIterator;
1770 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1771 myAISContext->Remove(aListIterator.Value());
1773 TopoDS_Shape S = BRepPrimAPI_MakeBox(400., 250., 300.).Shape();
1774 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
1776 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
1777 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1778 myAISContext->Display(ais1,Standard_False);
1779 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1780 myAISContext->SetSelected (anIO1, Standard_False);
1785 Ex.Init(S,TopAbs_FACE);
1787 TopoDS_Face F = TopoDS::Face(Ex.Current());
1788 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
1789 Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);
1790 gp_Dir D = Pl->Pln().Axis().Direction();
1791 // new in 2.0 ..use the trigonometric orientation to make the extrusion.
1794 Handle(Geom2d_Curve) aline;
1795 BRepBuilderAPI_MakeWire MW;
1796 p1 = gp_Pnt2d(200.,-100.);
1797 p2 = gp_Pnt2d(100.,-100.);
1798 aline = GCE2d_MakeLine(p1,p2).Value();
1799 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1801 p2 = gp_Pnt2d(100.,-200.);
1802 aline = GCE2d_MakeLine(p1,p2).Value();
1803 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1805 p2 = gp_Pnt2d(200.,-200.);
1806 aline = GCE2d_MakeLine(p1,p2).Value();
1807 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1809 p2 = gp_Pnt2d(200.,-100.);
1810 aline = GCE2d_MakeLine(p1,p2).Value();
1811 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1812 BRepBuilderAPI_MakeFace MKF;
1813 MKF.Init(surf,Standard_False, Precision::Confusion());
1815 TopoDS_Shape FP = MKF.Face();
1816 BRepLib::BuildCurves3d(FP);
1817 BRepFeat_MakePrism MKP(S,FP,F,D,0,Standard_True);
1819 TopoDS_Shape res1 = MKP.Shape();
1822 myAISContext->Redisplay(ais1,Standard_False);
1823 myAISContext->SetSelected(anIO1,Standard_False);
1828 TopoDS_Face F2 = TopoDS::Face(Ex.Current());
1829 surf = BRep_Tool::Surface(F2);
1830 Pl = Handle(Geom_Plane)::DownCast(surf);
1831 D = Pl->Pln().Axis().Direction();
1833 BRepBuilderAPI_MakeWire MW2;
1834 p1 = gp_Pnt2d(100.,100.);
1835 p2 = gp_Pnt2d(200.,100.);
1836 aline = GCE2d_MakeLine(p1,p2).Value();
1837 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1839 p2 = gp_Pnt2d(150.,200.);
1840 aline = GCE2d_MakeLine(p1,p2).Value();
1841 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1843 p2 = gp_Pnt2d(100.,100.);
1844 aline = GCE2d_MakeLine(p1,p2).Value();
1845 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
1846 BRepBuilderAPI_MakeFace MKF2;
1847 MKF2.Init(surf,Standard_False, Precision::Confusion());
1848 MKF2.Add(MW2.Wire());
1850 BRepLib::BuildCurves3d(FP);
1851 BRepFeat_MakePrism MKP2(res1,FP,F2,D,1,Standard_True);
1853 TopoDS_Shape res2 = MKP2.Shape();
1856 myAISContext->Redisplay(ais1);
1857 myAISContext->SetSelected(anIO1,Standard_False);
1860 TCollection_AsciiString Message ("\
1862 --- Extrusion ---\n\
1864 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
1865 TopExp_Explorer Ex;\n\
1866 Ex.Init(S,TopAbs_FACE);\n\
1868 TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
1869 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);\n\
1870 Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);\n\
1871 gp_Dir D = Pl->Pln().Axis().Direction();\n\
1874 Handle(Geom2d_Curve) aline;\n\
1875 BRepBuilderAPI_MakeWire MW;\n\
1876 p1 = gp_Pnt2d(200.,-100.);\n\
1877 p2 = gp_Pnt2d(100.,-100.);\n\
1878 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1879 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1881 p2 = gp_Pnt2d(100.,-200.);\n\
1882 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1883 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1885 p2 = gp_Pnt2d(200.,-200.);\n\
1886 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1887 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1889 p2 = gp_Pnt2d(200.,-100.);\n\
1890 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1891 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1892 BRepBuilderAPI_MakeFace MKF;\n\
1893 MKF.Init(surf,Standard_False);\n\
1894 MKF.Add(MW.Wire());\n\
1895 TopoDS_Shape FP = MKF.Face();\n\
1896 BRepLib::BuildCurves3d(FP);\n\
1897 BRepFeat_MakePrism MKP(S,FP,F,D,0,Standard_True);\n\
1898 MKP.Perform(200);\n\
1899 TopoDS_Shape res1 = MKP.Shape();\n\
1902 --- Protrusion --- \n\
1905 TopoDS_Face F2 = TopoDS::Face(Ex.Current());\n\
1906 surf = BRep_Tool::Surface(F2);\n\
1907 Pl = Handle(Geom_Plane)::DownCast(surf);\n\
1908 D = Pl->Pln().Axis().Direction();\n\
1910 BRepBuilderAPI_MakeWire MW2;\n\
1911 p1 = gp_Pnt2d(100.,100.);\n\
1912 p2 = gp_Pnt2d(200.,100.);\n\
1913 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1914 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1916 p2 = gp_Pnt2d(150.,200.);\n\
1917 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1918 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1920 p2 = gp_Pnt2d(100.,100.);\n\
1921 aline = GCE2d_MakeLine(p1,p2).Value();\n\
1922 MW2.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
1923 BRepBuilderAPI_MakeFace MKF2;\n\
1924 MKF2.Init(surf,Standard_False);\n\
1925 MKF2.Add(MW2.Wire());\n\
1926 FP = MKF2.Face();\n\
1927 BRepLib::BuildCurves3d(FP);\n\
1928 BRepFeat_MakePrism MKP2(res1,FP,F2,D,1,Standard_True);\n\
1929 MKP2.Perform(100.);\n\
1930 TopoDS_Shape res2 = MKP2.Shape();\n\
1932 PocessTextInDialog("Make an extrusion or a protrusion", Message);
1936 // BRepFeat_MakeDPrism
1938 void CModelingDoc::OnDprismLocal()
1940 AIS_ListOfInteractive aList;
1941 myAISContext->DisplayedObjects(aList);
1942 AIS_ListIteratorOfListOfInteractive aListIterator;
1943 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
1944 myAISContext->Remove(aListIterator.Value());
1947 TopoDS_Shape S = BRepPrimAPI_MakeBox(400., 250., 300.).Shape();
1948 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
1950 myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
1951 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
1954 Ex.Init(S,TopAbs_FACE);
1960 TopoDS_Face F = TopoDS::Face(Ex.Current());
1961 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
1962 gp_Circ2d c(gp_Ax2d(gp_Pnt2d(200.,130.),gp_Dir2d(1.,0.)),50.);
1963 BRepBuilderAPI_MakeWire MW;
1964 Handle(Geom2d_Curve) aline = new Geom2d_Circle(c);
1965 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,M_PI));
1966 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,M_PI,2.*M_PI));
1967 BRepBuilderAPI_MakeFace MKF;
1968 MKF.Init(surf,Standard_False, Precision::Confusion());
1970 TopoDS_Face FP = MKF.Face();
1971 BRepLib::BuildCurves3d(FP);
1972 BRepFeat_MakeDPrism MKDP(S,FP,F,10*M_PI/180,1,Standard_True);
1974 TopoDS_Shape res1 = MKDP.Shape();
1976 myAISContext->Display(ais1,Standard_False);
1977 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
1978 myAISContext->SetSelected (anIO1, Standard_False);
1984 myAISContext->Redisplay(ais1,Standard_False);
1985 myAISContext->SetSelected(anIO1,Standard_False);
1989 TCollection_AsciiString Message ("\
1991 --- Protrusion with draft angle --- \n\
1993 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
1994 TopExp_Explorer Ex;\n\
1995 Ex.Init(S,TopAbs_FACE);\n\
2001 TopoDS_Face F = TopoDS::Face(Ex.Current());\n\
2002 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);\n\
2003 gp_Circ2d c(gp_Ax2d(gp_Pnt2d(200.,130.),gp_Dir2d(1.,0.)),50.);\n\
2004 BRepBuilderAPI_MakeWire MW;\n\
2005 Handle(Geom2d_Curve) aline = new Geom2d_Circle(c);\n\
2006 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,PI));\n\
2007 MW.Add(BRepBuilderAPI_MakeEdge(aline,surf,PI,2.*PI));\n\
2008 BRepBuilderAPI_MakeFace MKF;\n\
2009 MKF.Init(surf,Standard_False);\n\
2010 MKF.Add(MW.Wire());\n\
2011 TopoDS_Face FP = MKF.Face();\n\
2012 BRepLib::BuildCurves3d(FP);\n\
2013 BRepFeat_MakeDPrism MKDP(S,FP,F,10*PI180,1,Standard_True);\n\
2014 MKDP.Perform(200);\n\
2015 TopoDS_Shape res1 = MKDP.Shape();\n\
2017 PocessTextInDialog("Make an extrusion or a protrusion with a draft angle", Message);
2020 void CModelingDoc::OnRevolLocal()
2022 AIS_ListOfInteractive aList;
2023 myAISContext->DisplayedObjects(aList);
2024 AIS_ListIteratorOfListOfInteractive aListIterator;
2025 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2026 myAISContext->Remove(aListIterator.Value());
2028 TopoDS_Shape S = BRepPrimAPI_MakeBox(400., 250., 300.).Shape();
2030 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2032 myAISContext->SetColor(ais1,Quantity_NOC_CORAL,Standard_False);
2033 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2034 myAISContext->Display(ais1,Standard_False);
2035 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2036 myAISContext->SetSelected (anIO1, Standard_False);
2041 Ex.Init(S,TopAbs_FACE);
2044 TopoDS_Face F1 = TopoDS::Face(Ex.Current());
2045 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);
2046 Handle (Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);
2047 gp_Ax1 D = gp::OX();
2048 BRepBuilderAPI_MakeWire MW1;
2050 p1 = gp_Pnt2d(100.,100.);
2051 p2 = gp_Pnt2d(200.,100.);
2052 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();
2053 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2055 p2 = gp_Pnt2d(150.,200.);
2056 aline = GCE2d_MakeLine(p1,p2).Value();
2057 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2059 p2 = gp_Pnt2d(100.,100.);
2060 aline = GCE2d_MakeLine(p1,p2).Value();
2061 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2062 BRepBuilderAPI_MakeFace MKF1;
2063 MKF1.Init(surf,Standard_False, Precision::Confusion());
2064 MKF1.Add(MW1.Wire());
2065 TopoDS_Face FP = MKF1.Face();
2066 BRepLib::BuildCurves3d(FP);
2067 BRepFeat_MakeRevol MKrev(S,FP,F1,D,1,Standard_True);
2070 TopoDS_Face F2 = TopoDS::Face(Ex.Current());
2072 TopoDS_Shape res1 = MKrev.Shape();
2075 myAISContext->Remove(ais1);
2076 Handle(AIS_Shape) ais2 = new AIS_Shape(res1);
2077 myAISContext->Display(ais2,Standard_False);
2078 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
2079 myAISContext->SetSelected (anIO2, Standard_False);
2082 TCollection_AsciiString Message ("\
2084 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
2085 TopExp_Explorer Ex;\n\
2086 Ex.Init(S,TopAbs_FACE);\n\
2089 TopoDS_Face F1 = TopoDS::Face(Ex.Current());\n\
2090 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);\n\
2091 Handle (Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(surf);\n\
2092 gp_Ax1 D = gp::OX();\n\
2093 BRepBuilderAPI_MakeWire MW1;\n\
2095 p1 = gp_Pnt2d(100.,100.);\n\
2096 p2 = gp_Pnt2d(200.,100.);\n\
2097 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();\n\
2098 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2100 p2 = gp_Pnt2d(150.,200.);\n\
2101 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2102 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2104 p2 = gp_Pnt2d(100.,100.);\n\
2105 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2106 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2107 BRepBuilderAPI_MakeFace MKF1;\n\
2108 MKF1.Init(surf,Standard_False);\n\
2109 MKF1.Add(MW1.Wire());\n\
2110 TopoDS_Face FP = MKF1.Face();\n\
2111 BRepLib::BuildCurves3d(FP);\n\
2112 BRepFeat_MakeRevol MKrev(S,FP,F1,D,1,Standard_True);\n\
2114 TopoDS_Face F2 = TopoDS::Face(Ex.Current());\n\
2115 MKrev.Perform(F2);\n\
2116 TopoDS_Shape res1 = MKrev.Shape();\n\
2118 PocessTextInDialog("Make a local revolution", Message);
2121 void CModelingDoc::OnGlueLocal()
2123 AIS_ListOfInteractive aList;
2124 myAISContext->DisplayedObjects(aList);
2125 AIS_ListIteratorOfListOfInteractive aListIterator;
2126 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2127 myAISContext->Remove(aListIterator.Value());
2129 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(gp_Pnt(-500., -500., 0.), gp_Pnt(-100., -250., 300.)).Shape();
2131 Handle(AIS_Shape) ais1 = new AIS_Shape(S1);
2132 myAISContext->SetColor(ais1,Quantity_NOC_ORANGE,Standard_False);
2133 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2134 myAISContext->Display(ais1,Standard_False);
2135 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2136 myAISContext->SetSelected (anIO1, Standard_False);
2140 TopExp_Explorer Ex1;
2141 Ex1.Init(S1,TopAbs_FACE);
2147 TopoDS_Face F1 = TopoDS::Face(Ex1.Current());
2148 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(-400., -400., 300.), gp_Pnt(-200., -300., 500.)).Shape();
2149 Handle(AIS_Shape) ais2 = new AIS_Shape(S2);
2151 myAISContext->SetColor(ais2,Quantity_NOC_AZURE,Standard_False);
2152 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
2153 myAISContext->Display(ais2,Standard_False);
2154 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
2155 myAISContext->SetSelected (anIO2, Standard_False);
2159 TopExp_Explorer Ex2;
2160 Ex2.Init(S2,TopAbs_FACE);
2165 TopoDS_Face F2 = TopoDS::Face(Ex2.Current());
2166 BRepFeat_Gluer glue(S2,S1);
2168 TopoDS_Shape res1 = glue.Shape();
2169 myAISContext->Erase(ais2,Standard_False);
2173 myAISContext->Redisplay(ais1);
2174 myAISContext->SetSelected(anIO1,Standard_False);
2178 TopoDS_Shape S3 = BRepPrimAPI_MakeBox(500., 400., 300.).Shape();
2180 Handle(AIS_Shape) ais3 = new AIS_Shape(S3);
2181 myAISContext->SetColor(ais3,Quantity_NOC_ORANGE,Standard_False);
2182 myAISContext->SetMaterial(ais3,Graphic3d_NOM_PLASTIC,Standard_False);
2183 myAISContext->Display(ais3,Standard_False);
2184 const Handle(AIS_InteractiveObject)& anIO3 = ais3;
2185 myAISContext->SetSelected (anIO3, Standard_False);
2189 TopExp_Explorer Ex3;
2190 Ex3.Init(S3,TopAbs_FACE);
2196 TopoDS_Face F3 = TopoDS::Face(Ex3.Current());
2197 TopoDS_Shape S4 = BRepPrimAPI_MakeBox(gp_Pnt(0., 0., 300.), gp_Pnt(200., 200., 500.)).Shape();
2199 Handle(AIS_Shape) ais4 = new AIS_Shape(S4);
2200 myAISContext->SetColor(ais4,Quantity_NOC_AZURE,Standard_False);
2201 myAISContext->SetMaterial(ais4,Graphic3d_NOM_PLASTIC,Standard_False);
2202 myAISContext->Display(ais4,Standard_False);
2203 const Handle(AIS_InteractiveObject)& anIO4 = ais4;
2204 myAISContext->SetSelected (anIO4, Standard_False);
2208 TopExp_Explorer Ex4;
2209 Ex4.Init(S4,TopAbs_FACE);
2214 TopoDS_Face F4 = TopoDS::Face(Ex4.Current());
2215 BRepFeat_Gluer glue2(S4,S3);
2217 LocOpe_FindEdges CommonEdges(F4,F3);
2218 for (CommonEdges.InitIterator(); CommonEdges.More(); CommonEdges.Next())
2219 glue2.Bind(CommonEdges.EdgeFrom(),CommonEdges.EdgeTo());
2220 TopoDS_Shape res2 = glue2.Shape();
2221 myAISContext->Erase(ais3,Standard_False);
2225 myAISContext->Redisplay(ais4,Standard_False);
2226 myAISContext->SetSelected(anIO4,Standard_False);
2230 TCollection_AsciiString Message ("\
2232 --- Without common edges ---\n\
2234 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(gp_Pnt(-500.,-500.,0.),gp_Pnt(-100.,-250.,300.));\n\
2235 TopExp_Explorer Ex1;\n\
2236 Ex1.Init(S1,TopAbs_FACE);\n\
2242 TopoDS_Face F1 = TopoDS::Face(Ex1.Current());\n\
2243 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(-400.,-400.,300.),gp_Pnt(-200.,-300.,500.));\n\
2244 TopExp_Explorer Ex2;\n\
2245 Ex2.Init(S2,TopAbs_FACE);\n\
2250 TopoDS_Face F2 = TopoDS::Face(Ex2.Current());\n\
2251 BRepFeat_Gluer glue(S2,S1);\n\
2252 glue.Bind(F2,F1);\n\
2253 TopoDS_Shape res1 = glue.Shape();\n\
2255 --- With common edges ---\n\
2257 TopoDS_Shape S3 = BRepPrimAPI_MakeBox(500.,400.,300.);\n\
2258 TopExp_Explorer Ex3;\n\
2259 Ex3.Init(S3,TopAbs_FACE);\n\
2265 TopoDS_Face F3 = TopoDS::Face(Ex3.Current());\n\
2266 TopoDS_Shape S4 = BRepPrimAPI_MakeBox(gp_Pnt(0.,0.,300.),gp_Pnt(200.,200.,500.));\n\
2267 TopExp_Explorer Ex4;\n\
2268 Ex4.Init(S4,TopAbs_FACE);\n\
2273 TopoDS_Face F4 = TopoDS::Face(Ex4.Current());\n\
2274 BRepFeat_Gluer glue2(S4,S3);\n\
2275 glue2.Bind(F4,F3);\n\
2276 LocOpe_FindEdges CommonEdges(F4,F3);\n\
2277 for (CommonEdges.InitIterator(); CommonEdges.More(); CommonEdges.Next()) \n\
2278 glue2.Bind(CommonEdges.EdgeFrom(),CommonEdges.EdgeTo());\n\
2279 TopoDS_Shape res2 = glue2.Shape();\n\
2281 PocessTextInDialog("Glue two solids", Message);
2285 void CModelingDoc::OnPipeLocal()
2287 AIS_ListOfInteractive aList;
2288 myAISContext->DisplayedObjects(aList);
2289 AIS_ListIteratorOfListOfInteractive aListIterator;
2290 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2291 myAISContext->Remove(aListIterator.Value());
2293 TopoDS_Shape S = BRepPrimAPI_MakeBox(400., 250., 300.).Shape();
2294 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2296 myAISContext->SetColor(ais1,Quantity_NOC_CORAL,Standard_False);
2297 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2298 myAISContext->Display(ais1,Standard_False);
2299 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2300 myAISContext->SetSelected (anIO1, Standard_False);
2305 Ex.Init(S,TopAbs_FACE);
2308 TopoDS_Face F1 = TopoDS::Face(Ex.Current());
2309 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);
2310 BRepBuilderAPI_MakeWire MW1;
2312 p1 = gp_Pnt2d(100.,100.);
2313 p2 = gp_Pnt2d(200.,100.);
2314 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();
2315 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2317 p2 = gp_Pnt2d(150.,200.);
2318 aline = GCE2d_MakeLine(p1,p2).Value();
2319 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2321 p2 = gp_Pnt2d(100.,100.);
2322 aline = GCE2d_MakeLine(p1,p2).Value();
2323 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));
2324 BRepBuilderAPI_MakeFace MKF1;
2325 MKF1.Init(surf,Standard_False, Precision::Confusion());
2326 MKF1.Add(MW1.Wire());
2327 TopoDS_Face FP = MKF1.Face();
2328 BRepLib::BuildCurves3d(FP);
2329 TColgp_Array1OfPnt CurvePoles(1,3);
2330 gp_Pnt pt = gp_Pnt(150.,0.,150.);
2332 pt = gp_Pnt(200.,-100.,150.);
2334 pt = gp_Pnt(150.,-200.,150.);
2336 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);
2337 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);
2338 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);
2339 BRepFeat_MakePipe MKPipe(S,FP,F1,W,1,Standard_True);
2341 TopoDS_Shape res1 = MKPipe.Shape();
2344 myAISContext->Redisplay(ais1,Standard_False);
2345 myAISContext->SetSelected(anIO1,Standard_False);
2348 TCollection_AsciiString Message ("\
2350 TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);\n\
2351 TopExp_Explorer Ex;\n\
2352 Ex.Init(S,TopAbs_FACE);\n\
2355 TopoDS_Face F1 = TopoDS::Face(Ex.Current());\n\
2356 Handle(Geom_Surface) surf = BRep_Tool::Surface(F1);\n\
2357 BRepBuilderAPI_MakeWire MW1;\n\
2359 p1 = gp_Pnt2d(100.,100.);\n\
2360 p2 = gp_Pnt2d(200.,100.);\n\
2361 Handle(Geom2d_Line) aline = GCE2d_MakeLine(p1,p2).Value();\n\
2362 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2364 p2 = gp_Pnt2d(150.,200.);\n\
2365 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2366 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2368 p2 = gp_Pnt2d(100.,100.);\n\
2369 aline = GCE2d_MakeLine(p1,p2).Value();\n\
2370 MW1.Add(BRepBuilderAPI_MakeEdge(aline,surf,0.,p1.Distance(p2)));\n\
2371 BRepBuilderAPI_MakeFace MKF1;\n\
2372 MKF1.Init(surf,Standard_False);\n\
2373 TopoDS_Face FP = MKF1.Face();\n\
2374 BRepLib::BuildCurves3d(FP);\n\
2375 TColgp_Array1OfPnt CurvePoles(1,3);\n\
2376 gp_Pnt pt = gp_Pnt(150.,0.,150.);\n\
2377 CurvePoles(1) = pt;\n\
2378 pt = gp_Pnt(200.,-100.,150.);\n\
2379 CurvePoles(2) = pt;\n\
2380 pt = gp_Pnt(150.,-200.,150.);\n\
2381 CurvePoles(3) = pt;\n\
2382 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(CurvePoles);\n\
2383 TopoDS_Edge E = BRepBuilderAPI_MakeEdge(curve);\n\
2384 TopoDS_Wire W = BRepBuilderAPI_MakeWire(E);\n\
2385 BRepFeat_MakePipe MKPipe(S,FP,F1,W,1,Standard_True);\n\
2386 MKPipe.Perform();\n\
2387 TopoDS_Shape res1 = MKPipe.Shape();\n\
2389 PocessTextInDialog("Make a local pipe", Message);
2393 void CModelingDoc::OnLinearLocal()
2395 AIS_ListOfInteractive aList;
2396 myAISContext->DisplayedObjects(aList);
2397 AIS_ListIteratorOfListOfInteractive aListIterator;
2398 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2399 myAISContext->Remove(aListIterator.Value());
2401 BRepBuilderAPI_MakeWire mkw;
2402 gp_Pnt p1 = gp_Pnt(0.,0.,0.);
2403 gp_Pnt p2 = gp_Pnt(200.,0.,0.);
2404 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2406 p2 = gp_Pnt(200.,0.,50.);
2407 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2409 p2 = gp_Pnt(50.,0.,50.);
2410 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2412 p2 = gp_Pnt(50.,0.,200.);
2413 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2415 p2 = gp_Pnt(0.,0.,200.);
2416 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));
2418 mkw.Add(BRepBuilderAPI_MakeEdge(p2,gp_Pnt(0.,0.,0.)));
2420 TopoDS_Shape S = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(mkw.Wire()),
2421 gp_Vec(gp_Pnt(0.,0.,0.),gp_Pnt(0.,100.,0.)));
2423 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2424 myAISContext->SetColor(ais1,Quantity_NOC_CYAN2,Standard_False);
2425 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2426 myAISContext->Display(ais1,Standard_False);
2427 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2428 myAISContext->SetSelected (anIO1, Standard_False);
2432 TopoDS_Wire W = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(gp_Pnt(50.,45.,100.),
2433 gp_Pnt(100.,45.,50.)));
2434 Handle(Geom_Plane) aplane = new Geom_Plane(0.,1.,0.,-45.);
2435 BRepFeat_MakeLinearForm aform(S, W, aplane, gp_Vec(0.,10.,0.), gp_Vec(0.,0.,0.),
2437 aform.Perform(/*10.*/); // new in 2.0
2439 TopoDS_Shape res = aform.Shape();
2441 myAISContext->Redisplay(ais1,Standard_False);
2442 myAISContext->SetSelected(anIO1);
2445 TCollection_AsciiString Message ("\
2447 BRepBuilderAPI_MakeWire mkw;\n\
2448 gp_Pnt p1 = gp_Pnt(0.,0.,0.);\n\
2449 gp_Pnt p2 = gp_Pnt(200.,0.,0.);\n\
2450 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2452 p2 = gp_Pnt(200.,0.,50.);\n\
2453 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2455 p2 = gp_Pnt(50.,0.,50.);\n\
2456 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2458 p2 = gp_Pnt(50.,0.,200.);\n\
2459 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2461 p2 = gp_Pnt(0.,0.,200.);\n\
2462 mkw.Add(BRepBuilderAPI_MakeEdge(p1,p2));\n\
2464 mkw.Add(BRepBuilderAPI_MakeEdge(p2,gp_Pnt(0.,0.,0.)));\n\
2465 TopoDS_Shape S = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(mkw.Wire()), \n\
2466 gp_Vec(gp_Pnt(0.,0.,0.),gp_Pnt(0.,100.,0.)));\n\
2467 TopoDS_Wire W = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(gp_Pnt(50.,45.,100.),\n\
2468 gp_Pnt(100.,45.,50.)));\n\
2469 Handle(Geom_Plane) aplane = new Geom_Plane(0.,1.,0.,-45.);\n\
2470 BRepFeat_MakeLinearForm aform(S, W, aplane, gp_Dir(0.,10.,0.), gp_Dir(0.,0.,0.),\n\
2471 1, Standard_True);\n\
2472 aform.Perform(10.);\n\
2473 TopoDS_Shape res = aform.Shape();\n\
2475 PocessTextInDialog("Make a rib", Message);
2479 void CModelingDoc::OnSplitLocal()
2481 AIS_ListOfInteractive aList;
2482 myAISContext->DisplayedObjects(aList);
2483 AIS_ListIteratorOfListOfInteractive aListIterator;
2484 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2485 myAISContext->Remove(aListIterator.Value());
2488 TopoDS_Shape S = BRepPrimAPI_MakeBox(gp_Pnt(-100, -60, -80), 150, 200, 170).Shape();
2490 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
2491 myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
2492 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2493 myAISContext->Display(ais1,Standard_False);
2494 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2495 myAISContext->SetSelected (anIO1, Standard_False);
2499 BRepAlgoAPI_Section asect(S, gp_Pln(1,2,1,-15),Standard_False);
2500 asect.ComputePCurveOn1(Standard_True);
2501 asect.Approximation(Standard_True);
2503 TopoDS_Shape R = asect.Shape();
2504 BRepTools::Write(R,"E:\\temp\\R");
2506 BRepFeat_SplitShape asplit(S);
2508 for (TopExp_Explorer Ex(R,TopAbs_EDGE); Ex.More(); Ex.Next()) {
2509 TopoDS_Shape anEdge = Ex.Current();
2511 if (asect.HasAncestorFaceOn1(anEdge,aFace)) {
2512 TopoDS_Face F = TopoDS::Face(aFace);
2513 TopoDS_Edge E = TopoDS::Edge(anEdge);
2521 myAISContext->Erase(ais1,Standard_False);
2524 TopoDS_Shape Result = asplit.Shape();
2526 Handle(AIS_Shape) ais2 = new AIS_Shape(Result);
2528 myAISContext->SetColor(ais2,Quantity_NOC_RED,Standard_False);
2529 myAISContext->SetMaterial(ais2,Graphic3d_NOM_PLASTIC,Standard_False);
2530 myAISContext->SetDisplayMode(ais2,1,Standard_False);
2531 myAISContext->Display(ais2,Standard_False);
2532 const Handle(AIS_InteractiveObject)& anIO2 = ais2;
2533 myAISContext->SetSelected (anIO2, Standard_False);
2535 TCollection_AsciiString Message ("\
2537 TopoDS_Shape S = BRepPrimAPI_MakeBox(gp_Pnt(-100,-60,-80),150,200,170); \n\
2539 BRepBuilderAPI_Section asect(S, gp_Pln(1,2,1,-15),Standard_False); \n\
2540 asect.ComputePCurveOn1(Standard_True); \n\
2541 asect.Approximation(Standard_True); \n\
2543 TopoDS_Shape R = asect.Shape(); \n\
2545 BRepFeat_SplitShape asplit(S); \n\
2547 for (TopExp_Explorer Ex(R,TopAbs_EDGE); Ex.More(); Ex.Next()) { \n\
2548 TopoDS_Shape anEdge = Ex.Current(); \n\
2549 TopoDS_Shape aFace; \n\
2550 if (asect.HasAncestorFaceOn1(anEdge,aFace)) { \n\
2551 TopoDS_Face F = TopoDS::Face(aFace); \n\
2552 TopoDS_Edge E = TopoDS::Edge(anEdge); \n\
2553 asplit.Add(E,F); \n\
2559 TopoDS_Shape Result = asplit.Shape(); \n\
2563 PocessTextInDialog("Split a shape", Message);
2568 void CModelingDoc::OnThickLocal()
2570 AIS_ListOfInteractive L;
2571 myAISContext->DisplayedObjects(L);
2572 AIS_ListIteratorOfListOfInteractive aListIterator;
2573 for(aListIterator.Initialize(L);aListIterator.More();aListIterator.Next()){
2574 myAISContext->Remove(aListIterator.Value());
2577 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(150, 200, 110).Shape();
2579 Handle(AIS_Shape) abox1 = new AIS_Shape(S1);
2580 myAISContext->SetColor(abox1,Quantity_NOC_WHITE);
2581 myAISContext->SetMaterial(abox1,Graphic3d_NOM_PLASTIC,Standard_False);
2582 myAISContext->Display(abox1,Standard_False);
2583 const Handle(AIS_InteractiveObject)& anIOBox1 = abox1;
2584 myAISContext->SetSelected (anIOBox1, Standard_False);
2588 TopTools_ListOfShape aList;
2589 TopExp_Explorer Ex(S1,TopAbs_FACE);
2590 Ex.Next(); //this is the front face
2591 TopoDS_Shape aFace = Ex.Current();
2592 aList.Append(aFace);
2594 BRepOffsetAPI_MakeThickSolid aSolidMaker;
2595 aSolidMaker.MakeThickSolidByJoin(S1,aList,10,0.01);
2596 TopoDS_Shape aThickSolid = aSolidMaker.Shape();
2598 Handle(AIS_Shape) ais1 = new AIS_Shape(aThickSolid);
2599 myAISContext->SetColor(ais1,Quantity_NOC_RED,Standard_False);
2600 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
2601 myAISContext->Display(ais1,Standard_False);
2602 const Handle(AIS_InteractiveObject)& anIO1 = ais1;
2603 myAISContext->SetSelected (anIO1, Standard_False);
2607 myAISContext->Erase(abox1,Standard_True);
2611 TCollection_AsciiString Message ("\
2613 TopoDS_Shape S = BRepPrimAPI_MakeBox(150,200,110); \n\
2615 TopTools_ListOfShape aList; \n\
2616 TopExp_Explorer Ex(S,TopAbs_FACE); \n\
2617 Ex.Next(); //in order to recover the front face \n\
2618 TopoDS_Shape aFace = Ex.Current(); \n\
2619 aList.Append(aFace); \n\
2621 TopoDS_Shape aThickSolid = BRepPrimAPI_MakeThickSolid(S,aList,15,0.01); \n\
2624 PocessTextInDialog("Make a thick solid", Message);
2627 void CModelingDoc::OnOffsetLocal()
2629 AIS_ListOfInteractive aList;
2630 myAISContext->DisplayedObjects(aList);
2631 AIS_ListIteratorOfListOfInteractive aListIterator;
2632 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2633 myAISContext->Remove(aListIterator.Value());
2636 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(150, 200, 110).Shape();
2638 Handle(AIS_Shape) aisBox1 = new AIS_Shape(S1);
2639 myAISContext->SetColor(aisBox1,Quantity_NOC_BROWN,Standard_False);
2640 myAISContext->SetMaterial(aisBox1,Graphic3d_NOM_GOLD,Standard_False);
2641 myAISContext->Display(aisBox1,Standard_False);
2645 BRepOffsetAPI_MakeOffsetShape aShapeMaker1;
2646 aShapeMaker1.PerformByJoin(S1,60,0.01);
2647 TopoDS_Shape anOffsetShape1 = aShapeMaker1.Shape();
2649 Handle(AIS_Shape) ais1 = new AIS_Shape(anOffsetShape1);
2650 myAISContext->SetColor(ais1,Quantity_NOC_MATRABLUE,Standard_False);
2651 myAISContext->SetMaterial(ais1,Graphic3d_NOM_GOLD,Standard_False);
2652 myAISContext->SetTransparency(ais1,0.5,Standard_False);
2653 myAISContext->Display(ais1,Standard_False);
2657 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(500, 0, 0), 220, 140, 180).Shape();
2659 Handle(AIS_Shape) aisBox2 = new AIS_Shape(S2);
2660 myAISContext->SetColor(aisBox2,Quantity_NOC_WHITE,Standard_False);
2661 myAISContext->SetMaterial(aisBox2,Graphic3d_NOM_GOLD,Standard_False);
2662 myAISContext->SetTransparency(aisBox2,0.5,Standard_False);
2663 myAISContext->Display(aisBox2,Standard_False);
2667 BRepOffsetAPI_MakeOffsetShape aShapeMaker2;
2668 aShapeMaker2.PerformByJoin(S2,-40,0.01,
2669 BRepOffset_Skin,Standard_False,Standard_False,GeomAbs_Arc);
2670 TopoDS_Shape anOffsetShape2 = aShapeMaker2.Shape();
2672 Handle(AIS_Shape) ais2 = new AIS_Shape(anOffsetShape2);
2673 myAISContext->SetColor(ais2,Quantity_NOC_MATRABLUE);
2674 myAISContext->SetMaterial(ais2,Graphic3d_NOM_GOLD,Standard_False);
2675 myAISContext->Display(ais2);
2678 TCollection_AsciiString Message ("\
2681 TopoDS_Shape S1 = BRepPrimAPI_MakeBox(150,200,110); \n\
2683 TopoDS_Shape anOffsetShape1 = BRepPrimAPI_MakeOffsetShape(S1,60,0.01); \n\
2687 TopoDS_Shape S2 = BRepPrimAPI_MakeBox(gp_Pnt(300,0,0),220,140,180); \n\
2689 TopoDS_Shape anOffsetShape2 = BRepPrimAPI_MakeOffsetShape(S2,-20,0.01, \n\
2690 BRepOffset_Skin,Standard_False,Standard_False,GeomAbs_Arc); \n\
2694 PocessTextInDialog("Make an offset shape", Message);
2698 /* =================================================================================
2699 ==================== B U I L D I N G ========================================
2700 ================================================================================= */
2703 void CModelingDoc::OnVertex()
2705 AIS_ListOfInteractive aList;
2706 myAISContext->DisplayedObjects(aList);
2707 AIS_ListIteratorOfListOfInteractive aListIterator;
2708 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2709 myAISContext->Remove(aListIterator.Value());
2712 TopoDS_Vertex V1,V2,V3;
2714 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
2715 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,25));
2718 BRepBuilderAPI_MakeVertex MV(P);
2721 Handle(AIS_Shape) Point1 = new AIS_Shape(V1);
2722 myAISContext->Display(Point1,Standard_False);
2723 Handle(AIS_Shape) Point2 = new AIS_Shape(V2);
2724 myAISContext->Display(Point2,Standard_False);
2725 Handle(AIS_Shape) Point3 = new AIS_Shape(V3);
2726 myAISContext->Display(Point3,Standard_False);
2730 TCollection_AsciiString Message ("\
2732 TopoDS_Vertex V1,V2,V3; \n\
2734 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0)); \n\
2736 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,25)); \n\
2738 gp_Pnt P(-12,8,-4); \n\
2739 BRepBuilderAPI_MakeVertex MV(P); \n\
2740 V3 = MV.Vertex(); \n\
2744 PocessTextInDialog("Make vertex from point ", Message);
2748 void CModelingDoc::OnEdge()
2751 AIS_ListOfInteractive aList;
2752 myAISContext->DisplayedObjects(aList);
2753 AIS_ListIteratorOfListOfInteractive aListIterator;
2754 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2755 myAISContext->Remove(aListIterator.Value());
2759 TopoDS_Edge BlueEdge,YellowEdge,WhiteEdge,RedEdge,GreenEdge;
2760 TopoDS_Vertex V1,V2,V3,V4;
2762 /////////////The blue edge
2764 BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80,-50,-20),gp_Pnt(-30,-60,-60));
2766 /////////////The yellow edge
2768 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));
2769 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,-25));
2770 YellowEdge = BRepBuilderAPI_MakeEdge(V1,V2);
2772 /////////////The white edge
2774 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));
2775 WhiteEdge = BRepBuilderAPI_MakeEdge(line,-20,10);
2777 //////////////The red edge
2779 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),60,30);
2780 RedEdge = BRepBuilderAPI_MakeEdge(Elips,0,M_PI/2);
2782 /////////////The green edge and the both extreme vertex
2784 gp_Pnt P1(-15,200,10);
2786 gp_Pnt P3(15,200,0);
2787 gp_Pnt P4(-15,20,15);
2790 gp_Pnt P7(24,120,0);
2791 gp_Pnt P8(-24,120,12.5);
2792 TColgp_Array1OfPnt array(1,8);
2793 array.SetValue(1,P1);
2794 array.SetValue(2,P2);
2795 array.SetValue(3,P3);
2796 array.SetValue(4,P4);
2797 array.SetValue(5,P5);
2798 array.SetValue(6,P6);
2799 array.SetValue(7,P7);
2800 array.SetValue(8,P8);
2801 Handle (Geom_BezierCurve) curve = new Geom_BezierCurve(array);
2803 BRepBuilderAPI_MakeEdge ME (curve);
2808 //////////////Display
2809 Handle(AIS_Shape) blue = new AIS_Shape(BlueEdge);
2810 myAISContext->SetColor(blue,Quantity_NOC_MATRABLUE,Standard_False);
2811 myAISContext->Display(blue,Standard_False);
2813 Handle(AIS_Shape) yellow = new AIS_Shape(YellowEdge);
2814 myAISContext->SetColor(yellow,Quantity_NOC_YELLOW,Standard_False);
2815 myAISContext->Display(yellow,Standard_False);
2817 Handle(AIS_Shape) white = new AIS_Shape(WhiteEdge);
2818 myAISContext->SetColor(white,Quantity_NOC_WHITE,Standard_False);
2819 myAISContext->Display(white,Standard_False);
2821 Handle(AIS_Shape) red = new AIS_Shape(RedEdge);
2822 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
2823 myAISContext->Display(red,Standard_False);
2825 Handle(AIS_Shape) green = new AIS_Shape(GreenEdge);
2826 myAISContext->SetColor(green,Quantity_NOC_GREEN,Standard_False);
2827 myAISContext->Display(green,Standard_False);
2829 Handle(AIS_Shape) Point1 = new AIS_Shape(V3);
2830 myAISContext->Display(Point1,Standard_False);
2831 Handle(AIS_Shape) Point2 = new AIS_Shape(V4);
2832 myAISContext->Display(Point2,Standard_False);
2836 TCollection_AsciiString Message ("\
2838 TopoDS_Edge BlueEdge, YellowEdge, WhiteEdge, RedEdge, GreenEdge; \n\
2839 TopoDS_Vertex V1,V2,V3,V4; \n\
2841 /////////////The blue edge \n\
2843 BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80,-50,-20),gp_Pnt(-30,-60,-60)); \n\
2845 /////////////The yellow edge \n\
2847 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30)); \n\
2848 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,7,-25)); \n\
2849 YellowEdge = BRepBuilderAPI_MakeEdge(V1,V2); \n\
2851 /////////////The white edge \n\
2853 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0))); \n\
2854 WhiteEdge = BRepBuilderAPI_MakeEdge(line,-20,10); \n\
2856 //////////////The red edge \n\
2858 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),60,30); \n\
2859 RedEdge = BRepBuilderAPI_MakeEdge(Elips,0,PI/2); \n\
2861 /////////////The green edge and the both extreme vertex \n\
2863 gp_Pnt P1(-15,200,10); \n\
2864 gp_Pnt P2(5,204,0); \n\
2865 gp_Pnt P3(15,200,0); \n\
2866 gp_Pnt P4(-15,20,15); \n\
2867 gp_Pnt P5(-5,20,0); \n\
2868 gp_Pnt P6(15,20,0); \n\
2869 gp_Pnt P7(24,120,0); \n\
2870 gp_Pnt P8(-24,120,12.5); \n\
2871 TColgp_Array1OfPnt array(1,8); \n\
2872 array.SetValue(1,P1); \n\
2873 array.SetValue(2,P2); \n\
2874 array.SetValue(3,P3); \n\
2875 array.SetValue(4,P4); \n\
2876 array.SetValue(5,P5); \n\
2877 array.SetValue(6,P6); \n\
2878 array.SetValue(7,P7); \n\
2879 array.SetValue(8,P8); \n\
2880 Handle (Geom_BezierCurve) curve = new Geom_BezierCurve(array); \n\
2882 BRepBuilderAPI_MakeEdge ME (curve); \n\
2884 V3 = ME.Vertex1(); \n\
2885 V4 = ME.Vertex2(); \n\
2889 PocessTextInDialog("Make edge", Message);
2893 void CModelingDoc::OnWire()
2895 AIS_ListOfInteractive aList;
2896 myAISContext->DisplayedObjects(aList);
2897 AIS_ListIteratorOfListOfInteractive aListIterator;
2898 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
2899 myAISContext->Remove(aListIterator.Value());
2902 TopoDS_Wire RedWire,YellowWire,WhiteWire,
2903 ExistingWire, ExistingWire2;
2905 TopoDS_Edge Edge1,Edge2,Edge3,Edge4,Edge5,Edge6,Edge7,LastEdge;
2906 TopoDS_Vertex LastVertex;
2908 ////////////The red wire is build from a single edge
2910 gp_Elips Elips(gp_Ax2(gp_Pnt(250,0,0),gp_Dir(1,1,1)),160,90);
2911 Edge1 = BRepBuilderAPI_MakeEdge(Elips,0,M_PI/2);
2913 RedWire = BRepBuilderAPI_MakeWire(Edge1);
2915 ///////////the yellow wire is build from an existing wire and an edge
2917 gp_Circ circle(gp_Ax2(gp_Pnt(-300,0,0),gp_Dir(1,0,0)),80);
2918 Edge2 = BRepBuilderAPI_MakeEdge(circle,0,M_PI);
2920 ExistingWire = BRepBuilderAPI_MakeWire(Edge2);
2922 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(-300,0,-80),gp_Pnt(-90,20,-30));
2924 BRepBuilderAPI_MakeWire MW1(ExistingWire,Edge3);
2930 //////////the white wire is built with an existing wire and 3 edges.
2931 //////////we use the methods Add, Edge and Vertex from BRepBuilderAPI_MakeWire.
2933 gp_Circ circle2(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)),200);
2934 Edge4 = BRepBuilderAPI_MakeEdge(circle2,0,M_PI);
2936 ExistingWire2 = BRepBuilderAPI_MakeWire(Edge4);
2938 gp_Pnt P1(0,0,-200);
2940 Edge5 = BRepBuilderAPI_MakeEdge(P1,P2);
2942 gp_Pnt P3(-15,20,15);
2943 Edge6 = BRepBuilderAPI_MakeEdge(P2,P3);
2945 Edge7 = BRepBuilderAPI_MakeEdge(P3,P4);
2947 BRepBuilderAPI_MakeWire MW;
2948 MW.Add(ExistingWire2);
2954 WhiteWire = MW.Wire();
2955 LastEdge = MW.Edge();
2956 LastVertex = MW.Vertex();
2960 Handle(AIS_Shape) red = new AIS_Shape(RedWire);
2961 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
2962 myAISContext->Display(red,Standard_False);
2964 Handle(AIS_Shape) yellow = new AIS_Shape(YellowWire);
2965 myAISContext->SetColor(yellow,Quantity_NOC_YELLOW,Standard_False);
2966 myAISContext->Display(yellow,Standard_False);
2968 Handle(AIS_Shape) white = new AIS_Shape(WhiteWire);
2969 myAISContext->SetColor(white,Quantity_NOC_WHITE,Standard_False);
2970 myAISContext->Display(white,Standard_False);
2972 Handle(AIS_Shape) lastE = new AIS_Shape(LastEdge);
2973 myAISContext->SetWidth(lastE,3,Standard_False);
2974 myAISContext->SetColor(lastE,Quantity_NOC_RED,Standard_False);
2975 myAISContext->Display(lastE,Standard_False);
2977 Handle(AIS_Shape) lastV = new AIS_Shape(LastVertex);
2978 myAISContext->Display(lastV,Standard_False);
2982 TCollection_AsciiString Message ("\
2984 TopoDS_Wire RedWire,YellowWire,WhiteWire, \n\
2985 ExistingWire, ExistingWire2; \n\
2987 TopoDS_Edge Edge1,Edge2,Edge3,Edge4,Edge5,Edge6,Edge7,LastEdge; \n\
2988 TopoDS_Vertex LastVertex; \n\
2990 ////////////The red wire is build from a single edge \n\
2992 gp_Elips Elips(gp_Ax2(gp_Pnt(10,0,0),gp_Dir(1,1,1)),160,90); \n\
2993 Edge1 = BRepBuilderAPI_MakeEdge(Elips,0,PI/2); \n\
2995 RedWire = BRepBuilderAPI_MakeWire(Edge1); \n\
2997 ///////////the yellow wire is build from an existing wire and an edge \n\
2999 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80); \n\
3000 Edge2 = BRepBuilderAPI_MakeEdge(circle,0,PI); \n\
3002 ExistingWire = BRepBuilderAPI_MakeWire(Edge2); \n\
3004 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(90,20,30)); \n\
3006 BRepBuilderAPI_MakeWire MW1(ExistingWire,Edge3); \n\
3007 if (MW1.IsDone()) { \n\
3008 YellowWire = MW1; \n\
3011 ///the white wire is built with an existing wire and 3 edges. \n\
3012 ///we use the methods Add, Edge and Vertex from BRepBuilderAPI_MakeWire \n\
3013 ///in order to display the last edge and the last vertices we \n\
3014 ///add to the wire. \n\
3016 gp_Circ circle2(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)),200); \n\
3017 Edge4 = BRepBuilderAPI_MakeEdge(circle2,0,PI); \n\
3019 ExistingWire2 = BRepBuilderAPI_MakeWire(Edge4); \n\
3021 gp_Pnt P1(0,0,-200); \n\
3022 gp_Pnt P2(5,204,0); \n\
3023 Edge5 = BRepBuilderAPI_MakeEdge(P1,P2); \n\
3025 gp_Pnt P3(-15,20,15); \n\
3026 Edge6 = BRepBuilderAPI_MakeEdge(P2,P3); \n\
3027 gp_Pnt P4(15,20,0); \n\
3028 Edge7 = BRepBuilderAPI_MakeEdge(P3,P4); \n\
3030 BRepBuilderAPI_MakeWire MW; \n\
3031 MW.Add(ExistingWire2); \n\
3036 if (MW.IsDone()) { \n\
3037 WhiteWire = MW.Wire(); \n\
3038 LastEdge = MW.Edge(); \n\
3039 LastVertex = MW.Vertex(); \n\
3044 PocessTextInDialog("Make wire ", Message);
3047 void CModelingDoc::OnFace()
3049 AIS_ListOfInteractive aList;
3050 myAISContext->DisplayedObjects(aList);
3051 AIS_ListIteratorOfListOfInteractive aListIterator;
3052 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3053 myAISContext->Remove(aListIterator.Value());
3058 TopoDS_Face WhiteFace, BrownFace, RedFace, PinkFace;
3059 TopoDS_Edge Edge1, Edge2, Edge3, Edge4, Edge5, Edge6, Edge7;
3061 gp_Pnt P1, P2, P3, P4, P5, P6, P7;
3063 gp_Sphere sphere (gp_Ax3(gp_Pnt(0,0,0),gp_Dir(1,0,0)),150);
3065 WhiteFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);
3067 //////////////////////////////////
3069 P1.SetCoord(-15,200,10);
3070 P2.SetCoord(5,204,0);
3071 P3.SetCoord(15,200,0);
3072 P4.SetCoord(-15,20,15);
3073 P5.SetCoord(-5,20,0);
3074 P6.SetCoord(15,20,35);
3075 TColgp_Array2OfPnt array(1,3,1,2);
3076 array.SetValue(1,1,P1);
3077 array.SetValue(2,1,P2);
3078 array.SetValue(3,1,P3);
3079 array.SetValue(1,2,P4);
3080 array.SetValue(2,2,P5);
3081 array.SetValue(3,2,P6);
3082 Handle (Geom_BSplineSurface) curve = GeomAPI_PointsToBSplineSurface(array,3,8,GeomAbs_C2,0.001);
3084 RedFace = BRepBuilderAPI_MakeFace(curve, Precision::Confusion());
3086 ////////////////////
3088 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80);
3089 Edge1 = BRepBuilderAPI_MakeEdge(circle,0,M_PI);
3091 Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(0,-10,40));
3092 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,-10,40),gp_Pnt(0,0,80));
3094 TopoDS_Wire YellowWire;
3095 BRepBuilderAPI_MakeWire MW1(Edge1,Edge2,Edge3);
3100 BrownFace = BRepBuilderAPI_MakeFace(YellowWire);
3105 P1.SetCoord(35,-200,40);
3106 P2.SetCoord(50,-204,30);
3107 P3.SetCoord(65,-200,30);
3108 P4.SetCoord(35,-20,45);
3109 P5.SetCoord(45,-20,30);
3110 P6.SetCoord(65,-20,65);
3111 TColgp_Array2OfPnt array2(1,3,1,2);
3112 array2.SetValue(1,1,P1);
3113 array2.SetValue(2,1,P2);
3114 array2.SetValue(3,1,P3);
3115 array2.SetValue(1,2,P4);
3116 array2.SetValue(2,2,P5);
3117 array2.SetValue(3,2,P6);
3119 Handle (Geom_BSplineSurface) BSplineSurf = GeomAPI_PointsToBSplineSurface(array2,3,8,GeomAbs_C2,0.001);
3121 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(BSplineSurf, Precision::Confusion());
3124 gp_Pnt2d P12d(0.9,0.1);
3125 gp_Pnt2d P22d(0.2,0.7);
3126 gp_Pnt2d P32d(0.02,0.1);
3128 Handle (Geom2d_Line) line1 = new Geom2d_Line(P12d,gp_Dir2d((0.2-0.9),(0.7-0.1)));
3129 Handle (Geom2d_Line) line2 = new Geom2d_Line(P22d,gp_Dir2d((0.02-0.2),(0.1-0.7)));
3130 Handle (Geom2d_Line) line3 = new Geom2d_Line(P32d,gp_Dir2d((0.9-0.02),(0.1-0.1)));
3133 //Edges are on the BSpline surface
3134 Edge1 = BRepBuilderAPI_MakeEdge(line1,BSplineSurf,0,P12d.Distance(P22d));
3135 Edge2 = BRepBuilderAPI_MakeEdge(line2,BSplineSurf,0,P22d.Distance(P32d));
3136 Edge3 = BRepBuilderAPI_MakeEdge(line3,BSplineSurf,0,P32d.Distance(P12d));
3138 Wire1 = BRepBuilderAPI_MakeWire(Edge1,Edge2,Edge3);
3140 PinkFace = BRepBuilderAPI_MakeFace(aFace,Wire1);
3141 BRepLib::BuildCurves3d(PinkFace);
3143 BRepTools::Write(PinkFace,"E:\\temp\\PinkFace.rle");
3146 /////////////Display
3147 Handle(AIS_Shape) white = new AIS_Shape(WhiteFace);
3148 myAISContext->SetColor(white,Quantity_NOC_WHITE,Standard_False);
3149 myAISContext->SetMaterial(white,Graphic3d_NOM_PLASTIC,Standard_False);
3150 myAISContext->Display(white,Standard_False);
3152 Handle(AIS_Shape) red = new AIS_Shape(RedFace);
3153 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
3154 myAISContext->SetMaterial(red,Graphic3d_NOM_PLASTIC,Standard_False);
3155 myAISContext->Display(red,Standard_False);
3157 Handle(AIS_Shape) brown = new AIS_Shape(BrownFace);
3158 myAISContext->SetColor(brown,Quantity_NOC_BROWN,Standard_False);
3159 myAISContext->SetMaterial(brown,Graphic3d_NOM_PLASTIC,Standard_False);
3160 myAISContext->Display(brown,Standard_False);
3162 Handle(AIS_Shape) pink = new AIS_Shape(PinkFace);
3163 myAISContext->SetColor(pink,Quantity_NOC_HOTPINK,Standard_False);
3164 myAISContext->SetMaterial(pink,Graphic3d_NOM_PLASTIC,Standard_False);
3165 myAISContext->Display(pink,Standard_False);
3170 TCollection_AsciiString Message ("\
3172 TopoDS_Face WhiteFace, BrownFace, RedFace, PinkFace; \n\
3173 TopoDS_Edge Edge1, Edge2, Edge3, Edge4, Edge5, Edge6, Edge7; \n\
3174 TopoDS_Wire Wire1; \n\
3175 gp_Pnt P1, P2, P3, P4, P5, P6, P7; \n\
3177 ////////The white Face \n\
3179 gp_Sphere sphere (gp_Ax3(gp_Pnt(0,0,0),gp_Dir(1,0,0)),150); \n\
3181 WhiteFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9); \n\
3183 ////////The red face \n\
3185 P1.SetCoord(-15,200,10); \n\
3186 P2.SetCoord(5,204,0); \n\
3187 P3.SetCoord(15,200,0); \n\
3188 P4.SetCoord(-15,20,15); \n\
3189 P5.SetCoord(-5,20,0); \n\
3190 P6.SetCoord(15,20,35); \n\
3191 TColgp_Array2OfPnt array(1,3,1,2); \n\
3192 array.SetValue(1,1,P1); \n\
3193 array.SetValue(2,1,P2); \n\
3194 array.SetValue(3,1,P3); \n\
3195 array.SetValue(1,2,P4); \n\
3196 array.SetValue(2,2,P5); \n\
3197 array.SetValue(3,2,P6); \n\
3198 Handle (Geom_BSplineSurface) curve = GeomAPI_PointsToBSplineSurface(array,3,8,GeomAbs_C2,0.001); \n\
3200 RedFace = BRepBuilderAPI_MakeFace(curve); \n\
3202 ////////The brown face \n\
3204 gp_Circ circle(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)),80); \n\
3205 Edge1 = BRepBuilderAPI_MakeEdge(circle,0,PI); \n\
3207 Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,-80),gp_Pnt(0,-10,40)); \n\
3208 Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0,-10,40),gp_Pnt(0,0,80)); \n\
3210 TopoDS_Wire YellowWire; \n\
3211 BRepBuilderAPI_MakeWire MW1(Edge1,Edge2,Edge3); \n\
3212 if (MW1.IsDone()) { \n\
3213 YellowWire = MW1; \n\
3216 BrownFace = BRepBuilderAPI_MakeFace(YellowWire); \n\
3219 ////////The pink face \n\
3221 P1.SetCoord(35,-200,40); \n\
3222 P2.SetCoord(50,-204,30); \n\
3223 P3.SetCoord(65,-200,30); \n\
3224 P4.SetCoord(35,-20,45); \n\
3225 P5.SetCoord(45,-20,30); \n\
3226 P6.SetCoord(65,-20,65); \n\
3227 TColgp_Array2OfPnt array2(1,3,1,2); \n\
3228 array2.SetValue(1,1,P1); \n\
3229 array2.SetValue(2,1,P2); \n\
3230 array2.SetValue(3,1,P3); \n\
3231 array2.SetValue(1,2,P4); \n\
3232 array2.SetValue(2,2,P5); \n\
3233 array2.SetValue(3,2,P6); \n\
3235 Handle (Geom_BSplineSurface) BSplineSurf = GeomAPI_PointsToBSplineSurface(array2,3,8,GeomAbs_C2,0.001); \n\
3237 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(BSplineSurf); \n\
3240 gp_Pnt2d P12d(0.9,0.1); \n\
3241 gp_Pnt2d P22d(0.2,0.7); \n\
3242 gp_Pnt2d P32d(0.02,0.1); \n\
3244 Handle (Geom2d_Line) line1= \n\
3245 new Geom2d_Line(P12d,gp_Dir2d((0.2-0.9),(0.7-0.1))); \n\
3246 Handle (Geom2d_Line) line2= \n\
3247 new Geom2d_Line(P22d,gp_Dir2d((0.02-0.2),(0.1-0.7))); \n\
3248 Handle (Geom2d_Line) line3= \n\
3249 new Geom2d_Line(P32d,gp_Dir2d((0.9-0.02),(0.1-0.1))); \n\
3251 //Edges are on the BSpline surface \n\
3252 Edge1 = BRepBuilderAPI_MakeEdge(line1,BSplineSurf,0,P12d.Distance(P22d)); \n\
3253 Edge2 = BRepBuilderAPI_MakeEdge(line2,BSplineSurf,0,P22d.Distance(P32d)); \n\
3254 Edge3 = BRepBuilderAPI_MakeEdge(line3,BSplineSurf,0,P32d.Distance(P12d)); \n\
3256 Wire1 = BRepBuilderAPI_MakeWire(Edge1,Edge2,Edge3); \n\
3257 Wire1.Reverse(); \n\
3258 PinkFace = BRepBuilderAPI_MakeFace(aFace,Wire1); \n\
3259 BRepLib::BuildCurves3d(PinkFace); \n\
3263 PocessTextInDialog("Make face ", Message);
3266 void CModelingDoc::OnShell()
3268 AIS_ListOfInteractive aList;
3269 myAISContext->DisplayedObjects(aList);
3270 AIS_ListIteratorOfListOfInteractive aListIterator;
3271 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3272 myAISContext->Remove(aListIterator.Value());
3275 TColgp_Array2OfPnt Poles(1,2,1,4);
3276 Poles.SetValue(1,1,gp_Pnt(0,0,0));
3277 Poles.SetValue(1,2,gp_Pnt(0,10,2));
3278 Poles.SetValue(1,3,gp_Pnt(0,20,10));
3279 Poles.SetValue(1,4,gp_Pnt(0,30,0));
3280 Poles.SetValue(2,1,gp_Pnt(10,0,5));
3281 Poles.SetValue(2,2,gp_Pnt(10,10,3));
3282 Poles.SetValue(2,3,gp_Pnt(10,20,20));
3283 Poles.SetValue(2,4,gp_Pnt(10,30,0));
3285 TColStd_Array1OfReal UKnots(1,2);
3286 UKnots.SetValue(1,0);
3287 UKnots.SetValue(2,1);
3289 TColStd_Array1OfInteger UMults(1,2);
3290 UMults.SetValue(1,2);
3291 UMults.SetValue(2,2);
3293 TColStd_Array1OfReal VKnots(1,3);
3294 VKnots.SetValue(1,0);
3295 VKnots.SetValue(2,1);
3296 VKnots.SetValue(3,2);
3298 TColStd_Array1OfInteger VMults(1,3);
3299 VMults.SetValue(1,3);
3300 VMults.SetValue(2,1);
3301 VMults.SetValue(3,3);
3303 Standard_Integer UDegree(1);
3304 Standard_Integer VDegree(2);
3306 Handle (Geom_BSplineSurface) BSpline = new Geom_BSplineSurface(Poles,UKnots,VKnots,UMults,VMults,UDegree,VDegree);
3308 TopoDS_Face WhiteFace = BRepBuilderAPI_MakeFace(BSpline, Precision::Confusion());
3311 Handle(AIS_Shape) white = new AIS_Shape(WhiteFace);
3312 myAISContext->SetColor(white,Quantity_NOC_WHITE);
3313 myAISContext->SetMaterial(white,Graphic3d_NOM_PLASTIC,Standard_False);
3314 myAISContext->SetTransparency(white,0.7);
3315 myAISContext->Display(white,Standard_False);
3318 TopoDS_Shell aShell = BRepBuilderAPI_MakeShell(BSpline);
3319 Handle(AIS_Shape) anAISShell = new AIS_Shape(aShell);
3320 myAISContext->SetDisplayMode(anAISShell,0);
3321 myAISContext->Display(anAISShell,Standard_False);
3322 //myAISContext->SetSelected(anAISShell);
3326 TCollection_AsciiString Message ("\
3328 TColgp_Array2OfPnt Poles(1,2,1,4); \n\
3329 Poles.SetValue(1,1,gp_Pnt(0,0,0)); \n\
3330 Poles.SetValue(1,2,gp_Pnt(0,10,2)); \n\
3331 Poles.SetValue(1,3,gp_Pnt(0,20,10)); \n\
3332 Poles.SetValue(1,4,gp_Pnt(0,30,0)); \n\
3333 Poles.SetValue(2,1,gp_Pnt(10,0,5)); \n\
3334 Poles.SetValue(2,2,gp_Pnt(10,10,3)); \n\
3335 Poles.SetValue(2,3,gp_Pnt(10,20,20)); \n\
3336 Poles.SetValue(2,4,gp_Pnt(10,30,0)); \n\
3338 TColStd_Array1OfReal UKnots(1,2); \n\
3339 UKnots.SetValue(1,0); \n\
3340 UKnots.SetValue(2,1); \n\
3342 TColStd_Array1OfInteger UMults(1,2); \n\
3343 UMults.SetValue(1,2); \n\
3344 UMults.SetValue(2,2); \n\
3346 TColStd_Array1OfReal VKnots(1,3); \n\
3347 VKnots.SetValue(1,0); \n\
3348 VKnots.SetValue(2,1); \n\
3349 VKnots.SetValue(3,2); \n\
3351 TColStd_Array1OfInteger VMults(1,3); \n\
3352 VMults.SetValue(1,3); \n\
3353 VMults.SetValue(2,1); \n\
3354 VMults.SetValue(3,3); \n\
3356 Standard_Integer UDegree(1); \n\
3357 Standard_Integer VDegree(2); \n\
3359 Handle (Geom_BSplineSurface) BSpline = new Geom_BSplineSurface(Poles,UKnots,VKnots,UMults,VMults,UDegree,VDegree); \n\
3361 TopoDS_Shell aShell = BRepBuilderAPI_MakeShell(BSpline); \n\
3365 PocessTextInDialog("Make shell", Message);
3369 void CModelingDoc::OnCompound()
3371 AIS_ListOfInteractive aList;
3372 myAISContext->DisplayedObjects(aList);
3373 AIS_ListIteratorOfListOfInteractive aListIterator;
3374 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3375 myAISContext->Remove(aListIterator.Value());
3378 BRep_Builder builder;
3379 TopoDS_Compound Comp;
3380 builder.MakeCompound(Comp);
3382 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30));
3383 builder.Add(Comp,aVertex);
3385 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0)));
3386 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(line,-20,10);
3387 builder.Add(Comp,anEdge);
3389 gp_Sphere sphere (gp_Ax3(gp_Pnt(-80,0,0),gp_Dir(1,0,0)),150);
3390 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9);
3391 builder.Add(Comp,aFace);
3393 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(-60, 0, 0), 30, 60, 40).Shape();
3394 builder.Add(Comp,aBox);
3396 Handle(AIS_Shape) white = new AIS_Shape(Comp);
3397 myAISContext->SetDisplayMode(white,0);
3398 myAISContext->Display(white,Standard_False);
3403 TCollection_AsciiString Message ("\
3405 BRep_Builder builder; \n\
3406 TopoDS_Compound Comp; \n\
3407 builder.MakeCompound(Comp); \n\
3409 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(-20,10,-30)); \n\
3410 builder.Add(Comp,aVertex); \n\
3412 gp_Lin line(gp_Ax1(gp_Pnt(10,10,10),gp_Dir(1,0,0))); \n\
3413 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(line,-20,10); \n\
3414 builder.Add(Comp,anEdge); \n\
3416 gp_Sphere sphere (gp_Ax3(gp_Pnt(-80,0,0),gp_Dir(1,0,0)),150); \n\
3417 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(sphere,0.1,0.7,0.2,0.9); \n\
3418 builder.Add(Comp,aFace); \n\
3420 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(-60,0,0),30,60,40); \n\
3421 builder.Add(Comp,aBox); \n\
3425 PocessTextInDialog("Make compound ", Message);
3433 void CModelingDoc::OnSewing()
3435 AIS_ListOfInteractive aList;
3436 myAISContext->DisplayedObjects(aList);
3437 AIS_ListIteratorOfListOfInteractive aListIterator;
3438 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3439 myAISContext->Remove(aListIterator.Value());
3444 Handle(Geom_Plane) Pi=new Geom_Plane(P,V);
3445 Handle(Geom_RectangularTrimmedSurface) GeometricSurface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);
3446 TopoDS_Shape FirstShape = BRepBuilderAPI_MakeFace(GeometricSurface, Precision::Confusion());
3448 Handle(AIS_Shape) white1 = new AIS_Shape(FirstShape);
3450 myAISContext->SetColor(white1,Quantity_NOC_RED,Standard_False);
3451 myAISContext->SetMaterial(white1,Graphic3d_NOM_PLASTIC,Standard_False);
3452 myAISContext->SetTransparency(white1,0.4,Standard_False);
3453 myAISContext->Display(white1,Standard_False);
3459 gp_Pnt P4(25,12,85);
3460 gp_Pnt P5(100,0,80);
3461 gp_Pnt P6(135,-12,85);
3463 TColgp_Array2OfPnt Array(1,3,1,2);
3464 Array.SetValue(1,1,P1);
3465 Array.SetValue(2,1,P2);
3466 Array.SetValue(3,1,P3);
3467 Array.SetValue(1,2,P4);
3468 Array.SetValue(2,2,P5);
3469 Array.SetValue(3,2,P6);
3471 Handle (Geom_BSplineSurface) aSurf = GeomAPI_PointsToBSplineSurface(Array,3,8,GeomAbs_C2,0.00001);
3472 TopoDS_Shape SecondShape = BRepBuilderAPI_MakeFace(aSurf, Precision::Confusion());
3474 Handle(AIS_Shape) white2 = new AIS_Shape(SecondShape);
3476 myAISContext->SetColor(white2,Quantity_NOC_YELLOW,Standard_False);
3477 myAISContext->SetMaterial(white2,Graphic3d_NOM_PLASTIC,Standard_False);
3478 myAISContext->SetTransparency(white2,0.4,Standard_False);
3479 myAISContext->Display(white2,Standard_False);
3483 BRepOffsetAPI_Sewing aMethod;
3484 aMethod.Add(FirstShape);
3485 aMethod.Add(SecondShape);
3489 TopoDS_Shape sewedShape = aMethod.SewedShape();
3491 Handle(AIS_Shape) result = new AIS_Shape(sewedShape);
3492 myAISContext->SetDisplayMode(result,0,Standard_False);
3493 myAISContext->Display(result,Standard_False);
3497 TCollection_AsciiString Message ("\
3499 ///////The first shape \n\
3501 gp_Pnt P(0,0,0); \n\
3502 gp_Vec V(0,0,1); \n\
3503 Handle(Geom_Plane) Pi=new Geom_Plane(P,V); \n\
3504 Handle(Geom_RectangularTrimmedSurface) GeometricSurface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.); \n\
3505 TopoDS_Shape FirstShape = BRepBuilderAPI_MakeFace(GeometricSurface); \n\
3507 ///////The second shape \n\
3509 gp_Pnt P1(0,0,0); \n\
3510 gp_Pnt P2(50,0,0); \n\
3511 gp_Pnt P3(100,0,0); \n\
3512 gp_Pnt P4(25,12,85); \n\
3513 gp_Pnt P5(100,0,80); \n\
3514 gp_Pnt P6(135,-12,85); \n\
3516 TColgp_Array2OfPnt Array(1,3,1,2); \n\
3517 Array.SetValue(1,1,P1); \n\
3518 Array.SetValue(2,1,P2); \n\
3519 Array.SetValue(3,1,P3); \n\
3520 Array.SetValue(1,2,P4); \n\
3521 Array.SetValue(2,2,P5); \n\
3522 Array.SetValue(3,2,P6); \n\
3524 Handle (Geom_BSplineSurface) aSurf = GeomAPI_PointsToBSplineSurface(Array,3,8,GeomAbs_C2,0.00001); \n\
3525 TopoDS_Shape SecondShape = BRepBuilderAPI_MakeFace(aSurf); \n\
3527 BRepOffsetAPI_Sewing aMethod; \n\
3528 aMethod.Add(FirstShape); \n\
3529 aMethod.Add(SecondShape); \n\
3531 aMethod.Perform(); \n\
3533 TopoDS_Shape sewedShape = aMethod.SewedShape(); \n\
3537 PocessTextInDialog("Sew faces ", Message);
3547 void CModelingDoc::OnBuilder()
3549 AIS_ListOfInteractive aList;
3550 myAISContext->DisplayedObjects(aList);
3551 AIS_ListIteratorOfListOfInteractive aListIterator;
3552 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
3553 myAISContext->Remove(aListIterator.Value());
3556 //The tolerance is the tolerance of confusion
3557 Standard_Real precision = Precision::Confusion();
3562 //Build the vertices
3563 TopoDS_Vertex V000, V001, V010, V011, V100, V101, V110, V111;
3564 B.MakeVertex(V000,gp_Pnt(0,0,0),precision);
3565 B.MakeVertex(V001,gp_Pnt(0,0,100),precision);
3566 B.MakeVertex(V010,gp_Pnt(0,150,0),precision);
3567 B.MakeVertex(V011,gp_Pnt(0,150,100),precision);
3568 B.MakeVertex(V100,gp_Pnt(200,0,0),precision);
3569 B.MakeVertex(V101,gp_Pnt(200,0,100),precision);
3570 B.MakeVertex(V110,gp_Pnt(200,150,0),precision);
3571 B.MakeVertex(V111,gp_Pnt(200,150,100),precision);
3574 //the edges are oriented as the axis X,Y,Z
3575 TopoDS_Edge EX00, EX01, EX10, EX11;
3576 TopoDS_Edge EY00, EY01, EY10, EY11;
3577 TopoDS_Edge EZ00, EZ01, EZ10, EZ11;
3578 Handle (Geom_Line) L;
3581 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(1,0,0));
3582 B.MakeEdge(EX00,L,precision);
3583 V000.Orientation(TopAbs_FORWARD);
3584 V100.Orientation(TopAbs_REVERSED);
3588 B.UpdateVertex(V000,0,EX00,precision);
3589 B.UpdateVertex(V100,200,EX00,precision);
3592 L = new Geom_Line(gp_Pnt(0,150,0),gp_Dir(1,0,0));
3593 B.MakeEdge(EX10,L,precision);
3594 V010.Orientation(TopAbs_FORWARD);
3595 V110.Orientation(TopAbs_REVERSED);
3599 B.UpdateVertex(V010,0,EX10,precision);
3600 B.UpdateVertex(V110,200,EX10,precision);
3603 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(0,1,0));
3604 B.MakeEdge(EY00,L,precision);
3605 V000.Orientation(TopAbs_FORWARD);
3606 V010.Orientation(TopAbs_REVERSED);
3610 B.UpdateVertex(V000,0,EY00,precision);
3611 B.UpdateVertex(V010,150,EY00,precision);
3614 L = new Geom_Line(gp_Pnt(200,0,0),gp_Dir(0,1,0));
3615 B.MakeEdge(EY10,L,precision);
3616 V100.Orientation(TopAbs_FORWARD);
3617 V110.Orientation(TopAbs_REVERSED);
3621 B.UpdateVertex(V100,0,EY10,precision);
3622 B.UpdateVertex(V110,150,EY10,precision);
3625 L = new Geom_Line(gp_Pnt(0,0,100),gp_Dir(0,1,0));
3626 B.MakeEdge(EY01,L,precision);
3627 V001.Orientation(TopAbs_FORWARD);
3628 V011.Orientation(TopAbs_REVERSED);
3632 B.UpdateVertex(V001,0,EY01,precision);
3633 B.UpdateVertex(V011,150,EY01,precision);
3636 L = new Geom_Line(gp_Pnt(200,0,100),gp_Dir(0,1,0));
3637 B.MakeEdge(EY11,L,precision);
3638 V101.Orientation(TopAbs_FORWARD);
3639 V111.Orientation(TopAbs_REVERSED);
3643 B.UpdateVertex(V101,0,EY11,precision);
3644 B.UpdateVertex(V111,150,EY11,precision);
3647 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(0,0,1));
3648 B.MakeEdge(EZ00,L,precision);
3649 V000.Orientation(TopAbs_FORWARD);
3650 V001.Orientation(TopAbs_REVERSED);
3654 B.UpdateVertex(V000,0,EZ00,precision);
3655 B.UpdateVertex(V001,100,EZ00,precision);
3658 L = new Geom_Line(gp_Pnt(0,150,0),gp_Dir(0,0,1));
3659 B.MakeEdge(EZ01,L,precision);
3660 V010.Orientation(TopAbs_FORWARD);
3661 V011.Orientation(TopAbs_REVERSED);
3665 B.UpdateVertex(V010,0,EZ01,precision);
3666 B.UpdateVertex(V011,100,EZ01,precision);
3669 L = new Geom_Line(gp_Pnt(200,0,0),gp_Dir(0,0,1));
3670 B.MakeEdge(EZ10,L,precision);
3671 V100.Orientation(TopAbs_FORWARD);
3672 V101.Orientation(TopAbs_REVERSED);
3676 B.UpdateVertex(V100,0,EZ10,precision);
3677 B.UpdateVertex(V101,100,EZ10,precision);
3680 L = new Geom_Line(gp_Pnt(200,150,0),gp_Dir(0,0,1));
3681 B.MakeEdge(EZ11,L,precision);
3682 V110.Orientation(TopAbs_FORWARD);
3683 V111.Orientation(TopAbs_REVERSED);
3687 B.UpdateVertex(V110,0,EZ11,precision);
3688 B.UpdateVertex(V111,100,EZ11,precision);
3692 Handle (Geom_Circle) C;
3693 //Standard_Real R = 100;
3696 C = new Geom_Circle(gp_Ax2(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
3697 B.MakeEdge(EX01,C,precision);
3698 V001.Orientation(TopAbs_FORWARD);
3699 V101.Orientation(TopAbs_REVERSED);
3703 B.UpdateVertex(V001,0,EX01,precision);
3704 B.UpdateVertex(V101,M_PI,EX01,precision);
3707 C = new Geom_Circle(gp_Ax2(gp_Pnt(100,150,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
3708 B.MakeEdge(EX11,C,precision);
3709 V011.Orientation(TopAbs_FORWARD);
3710 V111.Orientation(TopAbs_REVERSED);
3714 B.UpdateVertex(V011,0,EX11,precision);
3715 B.UpdateVertex(V111,M_PI,EX11,precision);
3717 //Build wire and faces
3718 //Faces normals are along the axis X,Y,Z
3719 TopoDS_Face FXMIN, FXMAX, FYMIN, FYMAX, FZMIN, FZMAX;
3721 Handle (Geom_Plane) P;
3722 Handle (Geom2d_Line) L2d;
3723 Handle (Geom2d_Circle) C2d;
3724 Handle (Geom_CylindricalSurface) S;
3727 P = new Geom_Plane(gp_Ax2(gp_Pnt(200,0,0),gp_Dir(1,0,0),gp_Dir(0,1,0)));
3728 B.MakeFace(FXMAX,P,precision);
3729 //the wire and the edges
3732 EY10.Orientation(TopAbs_FORWARD);
3735 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3736 B.UpdateEdge(EY10,L2d,FXMAX,precision);
3738 EZ11.Orientation(TopAbs_FORWARD);
3741 L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));
3742 B.UpdateEdge(EZ11,L2d,FXMAX,precision);
3744 EY11.Orientation(TopAbs_REVERSED);
3747 L2d = new Geom2d_Line(gp_Pnt2d(0,100),gp_Dir2d(1,0));
3748 B.UpdateEdge(EY11,L2d,FXMAX,precision);
3750 EZ10.Orientation(TopAbs_REVERSED);
3753 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3754 B.UpdateEdge(EZ10,L2d,FXMAX,precision);
3758 BRepTools::Write(FXMAX,"E:\\temp\\f1.rle");
3761 P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(-1,0,0),gp_Dir(0,0,1)));
3762 B.MakeFace(FXMIN,P,precision);
3763 //the wire and the edges
3766 EZ00.Orientation(TopAbs_FORWARD);
3769 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3770 B.UpdateEdge(EZ00,L2d,FXMIN,precision);
3772 EY01.Orientation(TopAbs_FORWARD);
3775 L2d = new Geom2d_Line(gp_Pnt2d(100,0),gp_Dir2d(0,1));
3776 B.UpdateEdge(EY01,L2d,FXMIN,precision);
3778 EZ01.Orientation(TopAbs_REVERSED);
3781 L2d = new Geom2d_Line(gp_Pnt2d(0,150),gp_Dir2d(1,0));
3782 B.UpdateEdge(EZ01,L2d,FXMIN,precision);
3784 EY00.Orientation(TopAbs_REVERSED);
3787 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3788 B.UpdateEdge(EY00,L2d,FXMIN,precision);
3795 P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0),gp_Dir(0,0,1)));
3796 B.MakeFace(FYMAX,P,precision);
3797 //the wire and the edges
3800 EZ00.Orientation(TopAbs_FORWARD);
3803 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3804 B.UpdateEdge(EZ00,L2d,FYMAX,precision);
3806 EX01.Orientation(TopAbs_FORWARD);
3809 C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(100,100),gp_Dir2d(0,-1)),100);
3810 B.UpdateEdge(EX01,C2d,FYMAX,precision);
3811 B.UpdateVertex(V001,0,EX01,FYMAX,precision);
3812 B.UpdateVertex(V101,M_PI,EX01,FYMAX,precision);
3814 EZ10.Orientation(TopAbs_REVERSED);
3817 L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
3818 B.UpdateEdge(EZ10,L2d,FYMAX,precision);
3820 EX00.Orientation(TopAbs_REVERSED);
3823 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3824 B.UpdateEdge(EX00,L2d,FYMAX,precision);
3832 P = new Geom_Plane(gp_Ax2(gp_Pnt(0,150,0),gp_Dir(0,1,0),gp_Dir(0,0,1)));
3833 B.MakeFace(FYMIN,P,precision);
3834 //the wire and the edges
3837 EZ01.Orientation(TopAbs_FORWARD);
3840 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3841 B.UpdateEdge(EZ01,L2d,FYMIN,precision);
3843 EX11.Orientation(TopAbs_FORWARD);
3846 C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(100,100),gp_Dir2d(0,-1)),100);
3847 B.UpdateEdge(EX11,C2d,FYMIN,precision);
3848 B.UpdateVertex(V011,0,EX11,FYMIN,precision);
3849 B.UpdateVertex(V111,M_PI,EX11,FYMIN,precision);
3851 EZ11.Orientation(TopAbs_REVERSED);
3854 L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
3855 B.UpdateEdge(EZ11,L2d,FYMIN,precision);
3857 EX10.Orientation(TopAbs_REVERSED);
3860 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3861 B.UpdateEdge(EX10,L2d,FYMIN,precision);
3866 P = new Geom_Plane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,0,-1),gp_Dir(0,1,0)));
3867 B.MakeFace(FZMAX,P,precision);
3868 //the wire and the edges
3871 EY00.Orientation(TopAbs_FORWARD);
3874 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0));
3875 B.UpdateEdge(EY00,L2d,FZMAX,precision);
3877 EX10.Orientation(TopAbs_FORWARD);
3880 L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1));
3881 B.UpdateEdge(EX10,L2d,FZMAX,precision);
3883 EY10.Orientation(TopAbs_REVERSED);
3886 L2d = new Geom2d_Line(gp_Pnt2d(0,200),gp_Dir2d(1,0));
3887 B.UpdateEdge(EY10,L2d,FZMAX,precision);
3889 EX00.Orientation(TopAbs_REVERSED);
3892 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3893 B.UpdateEdge(EX00,L2d,FZMAX,precision);
3899 S = new Geom_CylindricalSurface(gp_Ax3(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100);
3900 B.MakeFace(FZMIN,S,precision);
3902 //the wire and the edges
3905 EX01.Orientation(TopAbs_FORWARD);
3908 L2d = new Geom2d_Line(gp_Ax2d(gp_Pnt2d(0,0),gp_Dir2d(1,0)));
3909 B.UpdateEdge(EX01,L2d,FZMIN,precision);
3910 B.UpdateVertex(V001,0,EX01,FZMIN,precision);
3911 B.UpdateVertex(V101,M_PI,EX01,FZMIN,precision);
3913 EY11.Orientation(TopAbs_FORWARD);
3916 L2d = new Geom2d_Line(gp_Pnt2d(M_PI,0),gp_Dir2d(0,1));
3917 B.UpdateEdge(EY11,L2d,FZMIN,precision);
3919 EX11.Orientation(TopAbs_REVERSED);
3922 L2d = new Geom2d_Line(gp_Ax2d(gp_Pnt2d(0,150),gp_Dir2d(1,0)));
3923 B.UpdateEdge(EX11,L2d,FZMIN,precision);
3924 B.UpdateVertex(V111,M_PI,EX11,FZMIN,precision);
3925 B.UpdateVertex(V011,0,EX11,FZMIN,precision);
3927 EY01.Orientation(TopAbs_REVERSED);
3930 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1));
3931 B.UpdateEdge(EY01,L2d,FZMIN,precision);
3935 FYMAX.Orientation(TopAbs_REVERSED);
3937 BRepTools::Write(FZMIN,"E:\\temp\\f3.rle");
3938 BRepTools::Write(FYMAX,"E:\\temp\\f2.rle");
3955 BRepTools::Write(Sol,"e://temp//solid");
3956 Handle(AIS_Shape) borne = new AIS_Shape(Sol);
3957 myAISContext->SetDisplayMode(borne,1);
3958 myAISContext->SetColor(borne,Quantity_NOC_RED);
3959 myAISContext->SetMaterial(borne,Graphic3d_NOM_PLASTIC,Standard_False);
3960 myAISContext->Display(borne,Standard_False);
3964 TCollection_AsciiString Message ("\
3966 //The tolerance is 0.01 \n\
3967 Standard_Real precision(0.01); \n\
3972 //Build the vertices \n\
3973 TopoDS_Vertex V000, V001, V010, V011, V100, V101, V110, V111; \n\
3974 B.MakeVertex(V000,gp_Pnt(0,0,0),precision); \n\
3975 B.MakeVertex(V001,gp_Pnt(0,0,100),precision); \n\
3976 B.MakeVertex(V010,gp_Pnt(0,150,0),precision); \n\
3977 B.MakeVertex(V011,gp_Pnt(0,150,100),precision); \n\
3978 B.MakeVertex(V100,gp_Pnt(200,0,0),precision); \n\
3979 B.MakeVertex(V101,gp_Pnt(200,0,100),precision); \n\
3980 B.MakeVertex(V110,gp_Pnt(200,150,0),precision); \n\
3981 B.MakeVertex(V111,gp_Pnt(200,150,100),precision); \n\
3983 //Build the edges \n\
3984 //the edges are oriented as the axis X,Y,Z \n\
3985 TopoDS_Edge EX00, EX01, EX10, EX11; \n\
3986 TopoDS_Edge EY00, EY01, EY10, EY11; \n\
3987 TopoDS_Edge EZ00, EZ01, EZ10, EZ11; \n\
3988 Handle (Geom_Line) L; \n\
3991 L = new Geom_Line(gp_Pnt(0,0,0),gp_Dir(1,0,0)); \n\
3992 B.MakeEdge(EX00,L,precision); \n\
3993 V000.Orientation(TopAbs_FORWARD); \n\
3994 V100.Orientation(TopAbs_REVERSED); \n\
3995 B.Add(EX00,V000); \n\
3996 B.Add(EX00,V100); \n\
3998 B.UpdateVertex(V000,0,EX00,precision); \n\
3999 B.UpdateVertex(V100,200,EX00,precision); \n\
4001 //Idem for all the linear edges... \n\
4003 //Circular Edges \n\
4004 Handle (Geom_Circle) C; \n\
4005 Standard_Real R = 100; \n\
4008 C = new Geom_Circle(gp_Ax2(gp_Pnt(100,0,100),gp_Dir(0,1,0),gp_Dir(-1,0,0)),100); \n\
4009 B.MakeEdge(EX01,C,precision); \n\
4010 V001.Orientation(TopAbs_FORWARD); \n\
4011 V101.Orientation(TopAbs_REVERSED); \n\
4012 B.Add(EX01,V001); \n\
4013 B.Add(EX01,V101); \n\
4015 B.UpdateVertex(V001,0,EX01,precision); \n\
4016 B.UpdateVertex(V101,PI,EX01,precision); \n\
4020 //Build wire and faces \n\
4021 //Faces normals are along the axis X,Y,Z \n\
4022 TopoDS_Face FXMIN, FXMAX, FYMIN, FYMAX, FZMIN, FZMAX; \n\
4024 Handle (Geom_Plane) P; \n\
4025 Handle (Geom2d_Line) L2d; \n\
4026 Handle (Geom2d_Circle) C2d; \n\
4027 Handle (Geom_CylindricalSurface) S; \n\
4030 P = new Geom_Plane(gp_Ax2(gp_Pnt(200,0,0),gp_Dir(1,0,0),gp_Dir(0,1,0))); \n\
4031 B.MakeFace(FXMAX,P,precision); \n\
4032 //the wire and the edges \n\
4033 B.MakeWire (W); \n");
4036 EY10.Orientation(TopAbs_FORWARD); \n\
4039 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(1,0)); \n\
4040 B.UpdateEdge(EY10,L2d,FXMAX,precision); \n\
4042 EZ11.Orientation(TopAbs_FORWARD); \n\
4045 L2d = new Geom2d_Line(gp_Pnt2d(150,0),gp_Dir2d(0,1)); \n\
4046 B.UpdateEdge(EZ11,L2d,FXMAX,precision); \n\
4048 EY11.Orientation(TopAbs_REVERSED); \n\
4051 L2d = new Geom2d_Line(gp_Pnt2d(0,100),gp_Dir2d(1,0)); \n\
4052 B.UpdateEdge(EY11,L2d,FXMAX,precision); \n\
4054 EZ10.Orientation(TopAbs_REVERSED); \n\
4057 L2d = new Geom2d_Line(gp_Pnt2d(0,0),gp_Dir2d(0,1)); \n\
4058 B.UpdateEdge(EZ10,L2d,FXMAX,precision); \n\
4062 //Idem for other faces... \n\
4065 TopoDS_Shell Sh; \n\
4066 B.MakeShell(Sh); \n\
4067 B.Add(Sh,FXMAX); \n\
4068 B.Add(Sh,FXMIN); \n\
4069 B.Add(Sh,FYMAX); \n\
4070 B.Add(Sh,FYMIN); \n\
4071 B.Add(Sh,FZMAX); \n\
4072 B.Add(Sh,FZMIN); \n\
4075 TopoDS_Solid Sol; \n\
4076 B.MakeSolid(Sol); \n\
4081 PocessTextInDialog("Make a shape with a builder", Message);
4085 void CModelingDoc::OnGeometrie()
4087 AIS_ListOfInteractive aList;
4088 myAISContext->DisplayedObjects(aList);
4089 AIS_ListIteratorOfListOfInteractive aListIterator;
4090 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4091 myAISContext->Remove(aListIterator.Value());
4094 //geometrie of a vertex
4095 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(0,120,70));
4096 gp_Pnt GeometricPoint = BRep_Tool::Pnt(aVertex);
4098 Handle(AIS_Shape) vert = new AIS_Shape(aVertex);
4099 myAISContext->Display(vert,Standard_False);
4103 //geometrie of an edge
4104 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(100,50,250),gp_Pnt(-30,-100,-50));
4105 Handle(AIS_Shape) yellow = new AIS_Shape(anEdge);
4106 myAISContext->SetWidth(yellow,2,Standard_False);
4107 myAISContext->Display(yellow,Standard_False);
4111 TopLoc_Location location;
4112 Standard_Real first, last;
4113 Handle (Geom_Curve) aCurve = BRep_Tool::Curve(anEdge,location,first,last);
4114 TopoDS_Edge anEdgeDS = BRepBuilderAPI_MakeEdge(aCurve);
4116 Handle (Geom_Line) aLine = Handle (Geom_Line)::DownCast(aCurve);
4117 if (!aLine.IsNull()) {
4118 Handle (AIS_Line) DispLine = new AIS_Line(aLine);
4119 myAISContext->Display(DispLine,Standard_False);
4124 //geometrie of a face
4125 gp_Pnt P(-20,-20,-20);
4127 Handle(Geom_Plane) Pi=new Geom_Plane(P,V);
4128 Handle(Geom_RectangularTrimmedSurface) Surface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.);
4129 TopoDS_Face RedFace = BRepBuilderAPI_MakeFace(Surface, Precision::Confusion());
4131 Handle(AIS_Shape) red = new AIS_Shape(RedFace);
4132 myAISContext->SetColor(red,Quantity_NOC_RED,Standard_False);
4133 myAISContext->SetMaterial(red,Graphic3d_NOM_PLASTIC,Standard_False);
4134 myAISContext->Display(red,Standard_False);
4138 TopLoc_Location location2;
4139 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(RedFace,location2);
4141 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);
4142 if (!aPlane.IsNull()) {
4143 Handle (AIS_Plane) DispPlane = new AIS_Plane(aPlane);
4144 myAISContext->Display(DispPlane,Standard_False);
4153 TCollection_AsciiString Message ("\
4155 ///////geometrie of a vertex \n\
4156 TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(gp_Pnt(0,120,70)); \n\
4157 gp_Pnt GeometricPoint = BRep_Tool::Pnt(aVertex); \n\
4159 ///////geometrie of an edge \n\
4160 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(100,50,250),gp_Pnt(-30,-100,-50)); \n\
4162 TopLoc_Location location; \n\
4163 Standard_Real first, last; \n\
4164 Handle (Geom_Curve) aCurve = BRep_Tool::Curve(anEdge,location,first,last); \n\
4165 TopoDS_Edge anEdgeDS = BRepBuilderAPI_MakeEdge(aCurve); \n\
4167 Handle (Geom_Line) aLine = Handle (Geom_Line)::DownCast(aCurve); \n\
4168 if (!aLine.IsNull()) { \n\
4169 Handle (AIS_Line) DispLine = new AIS_Line(aLine); \n\
4172 ///////geometrie of a face \n\
4173 gp_Pnt P(-20,-20,-20); \n\
4174 gp_Vec V(0,0,1); \n\
4175 Handle(Geom_Plane) Pi=new Geom_Plane(P,V); \n\
4176 Handle(Geom_RectangularTrimmedSurface) Surface=new Geom_RectangularTrimmedSurface(Pi,0.,100.,0.,100.); \n\
4177 TopoDS_Face RedFace = BRepBuilderAPI_MakeFace(Surface); \n\
4179 TopLoc_Location location2; \n\
4180 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(RedFace,location2); \n\
4182 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface); \n\
4183 if (!aPlane.IsNull()) { \n\
4184 Handle (AIS_Plane) DispPlane = new AIS_Plane(aPlane); \n\
4189 PocessTextInDialog("Recover the geometrie of vertex, edge and face ", Message);
4194 void CModelingDoc::OnExplorer()
4196 AIS_ListOfInteractive aList;
4197 myAISContext->DisplayedObjects(aList);
4198 AIS_ListIteratorOfListOfInteractive aListIterator;
4199 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4200 myAISContext->Remove(aListIterator.Value());
4203 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100, 100, 100).Shape();
4204 Standard_Integer j(8);
4205 Handle(AIS_Shape) theBox = new AIS_Shape(aBox);
4206 myAISContext->SetColor(theBox,Quantity_NOC_RED,Standard_False);
4207 myAISContext->SetMaterial(theBox,Graphic3d_NOM_PLASTIC,Standard_False);
4208 myAISContext->Display(theBox,Standard_False);
4212 for (TopExp_Explorer exp (aBox,TopAbs_FACE);exp.More();exp.Next()) {
4213 TopoDS_Face aCurrentFace = TopoDS::Face(exp.Current());
4215 //test the orientation of the current face
4216 TopAbs_Orientation orient = aCurrentFace.Orientation();
4218 //Recover the geometric plane
4219 TopLoc_Location location;
4220 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(aCurrentFace,location);
4222 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface);
4224 //Build an AIS_Shape with a new color
4225 Handle(AIS_Shape) theMovingFace = new AIS_Shape(aCurrentFace);
4226 Quantity_NameOfColor aCurrentColor = (Quantity_NameOfColor)j;
4227 myAISContext->SetColor(theMovingFace,aCurrentColor,Standard_False);
4228 myAISContext->SetMaterial(theMovingFace,Graphic3d_NOM_PLASTIC,Standard_False);
4229 //Find the normal vector of each face
4230 gp_Pln agpPlane = aPlane->Pln();
4231 gp_Ax1 norm = agpPlane.Axis();
4232 gp_Dir dir = norm.Direction();
4235 // new in 2.0 ... AIS_ConnectedInteractive wants a TopLoc_Location instead of a Geom_Transformation
4236 // TopLoc_Location aLocation;
4237 // Handle (AIS_ConnectedInteractive) theTransformedDisplay = new AIS_ConnectedInteractive();
4238 // theTransformedDisplay->Connect(theMovingFace,theMove);
4239 // theTransformedDisplay->Connect(theMovingFace, aLocation);
4240 // Handle (Geom_Transformation) theMove = new Geom_Transformation(aLocation->Transformation());
4242 // myAISContext->Display(theTransformedDisplay);
4244 TopLoc_Location aLocation;
4245 Handle (AIS_ConnectedInteractive) theTransformedDisplay = new AIS_ConnectedInteractive();
4246 theTransformedDisplay->Connect(theMovingFace, aLocation);
4249 // = myAISContext->Location(theMovingFace);
4250 Handle (Geom_Transformation) theMove = new Geom_Transformation(aLocation.Transformation());
4251 myAISContext->Display(theTransformedDisplay,Standard_False);
4255 for (Standard_Integer i=1;i<=30;i++) {
4257 //Build a transformation on the display
4258 // theMove->SetTranslation(move*i);
4260 // if (orient==TopAbs_FORWARD) theTransformedDisplay->SetTransformation(theMove);
4261 // else theTransformedDisplay->SetTransformation(theMove->Inverted());
4263 // myAISContext->Redisplay(theTransformedDisplay);
4266 theMove->SetTranslation(move*i);
4267 if (orient==TopAbs_FORWARD) myAISContext->SetLocation(theTransformedDisplay,TopLoc_Location(theMove->Trsf()));
4268 else myAISContext->SetLocation(theTransformedDisplay,TopLoc_Location(theMove->Inverted()->Trsf()));
4270 myAISContext->Redisplay(theTransformedDisplay,Standard_False);
4274 //myAISContext->Erase(theBox,Standard_True,Standard_False);
4275 myAISContext->Remove(theBox);
4279 TCollection_AsciiString Message ("\
4281 TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100,100,100); \n\
4283 for (TopExp_Explorer exp (aBox,TopAbs_FACE);exp.More();exp.Next()) { \n\
4284 TopoDS_Face aCurrentFace = TopoDS::Face(exp.Current()); \n\
4286 //Recover the geometric plane \n\
4287 TopLoc_Location location; \n\
4288 Handle (Geom_Surface) aGeometricSurface = BRep_Tool::Surface(aCurrentFace,location); \n\
4290 Handle (Geom_Plane) aPlane = Handle (Geom_Plane)::DownCast(aGeometricSurface); \n\
4293 PocessTextInDialog("Explode a shape in faces ", Message);
4297 /* =================================================================================
4298 ==================== A N A L Y S I S ========================================
4299 ================================================================================= */
4301 void CModelingDoc::OnValid()
4303 AIS_ListOfInteractive aList;
4304 myAISContext->DisplayedObjects(aList);
4305 AIS_ListIteratorOfListOfInteractive aListIterator;
4306 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4307 myAISContext->Remove(aListIterator.Value());
4310 TopoDS_Shape S = BRepPrimAPI_MakeBox(200., 300., 150.).Shape();
4311 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4312 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4313 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4314 myAISContext->Display(ais1,Standard_False);
4317 TCollection_AsciiString Message ("\
4319 TopoDS_Shape S = BRepPrimI_MakeBox(200.,300.,150.);\n\
4320 Standard_Boolean theShapeIsValid = BRepAlgo::IsValid(S);\n\
4321 if ( theShapeIsValid )\n\
4323 MessageBox(\"The Shape Is Valid !! \",\"Checking Shape\");\n\
4327 MessageBox(\"The Shape Is NOT Valid !! \",\"Checking Shape\");\n\
4330 PocessTextInDialog("Check a shape", Message);
4332 Standard_Boolean theShapeIsValid = BRepAlgo::IsValid(S);
4333 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, theShapeIsValid ? L"The Shape Is Valid !! " : L"The Shape Is NOT Valid !! ", L"Checking Shape", MB_OK);
4337 void CModelingDoc::OnLinear()
4339 AIS_ListOfInteractive aList;
4340 myAISContext->DisplayedObjects(aList);
4341 AIS_ListIteratorOfListOfInteractive aListIterator;
4342 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4343 myAISContext->Remove(aListIterator.Value());
4347 TColgp_Array1OfPnt Points1(1,4);
4348 Points1.SetValue(1,gp_Pnt(0,0,0));
4349 Points1.SetValue(2,gp_Pnt(2,1,0));
4350 Points1.SetValue(3,gp_Pnt(4,0,0));
4351 Points1.SetValue(4,gp_Pnt(6,2,0));
4352 GeomAPI_PointsToBSpline PTBS1(Points1);
4353 Handle(Geom_BSplineCurve) BSC1 = PTBS1.Curve();
4354 TopoDS_Edge S = BRepBuilderAPI_MakeEdge(BSC1).Edge();
4356 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4357 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4358 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4359 myAISContext->Display(ais1,Standard_False);
4363 GProp_GProps System;
4364 BRepGProp::LinearProperties(S,System);
4365 gp_Pnt G = System.CentreOfMass ();
4366 Standard_Real Length = System.Mass();
4367 gp_Mat I = System.MatrixOfInertia();
4369 TCollection_ExtendedString string("Length Of all the Edges =");
4370 TCollection_ExtendedString string1(Length);
4373 string += "\nCenterOfMass : \n X=";
4384 string += "Matrix of Inertia :\n ";
4413 TCollection_AsciiString Message ("\
4415 TColgp_Array1OfPnt Points1(1,4);\n\
4416 Points1.SetValue(1,gp_Pnt(0,0,0));\n\
4417 Points1.SetValue(2,gp_Pnt(2,1,0));\n\
4418 Points1.SetValue(3,gp_Pnt(4,0,0));\n\
4419 Points1.SetValue(4,gp_Pnt(6,2,0));\n\
4420 GeomAPI_PointsToBSpline PTBS1(Points1);\n\
4421 Handle(Geom_BSplineCurve) BSC1 = PTBS1.Curve();\n\
4422 TopoDS_Shape S = BRepBuilderAPI_MakeEdge(BSC1).Edge();\n\
4423 GProp_GProps System;\n\
4424 BRepGProp::LinearProperties(S,System);\n\
4425 gp_Pnt G = System.CentreOfMass ();\n\
4426 Standard_Real Length = System.Mass();\n\
4427 gp_Mat I = System.MatrixOfInertia();\n\
4429 PocessTextInDialog("Linear Properties", Message);
4430 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, string.ToWideString(), L"Linear Properties", MB_OK);
4433 void CModelingDoc::OnSurface()
4435 AIS_ListOfInteractive aList;
4436 myAISContext->DisplayedObjects(aList);
4437 AIS_ListIteratorOfListOfInteractive aListIterator;
4438 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4439 myAISContext->Remove(aListIterator.Value());
4442 TColgp_Array1OfPnt Pnts1(1,3);
4443 TColgp_Array1OfPnt Pnts2(1,3);
4444 TColgp_Array1OfPnt Pnts3(1,3);
4445 TColgp_Array1OfPnt Pnts4(1,3);
4447 Pnts1(1) = gp_Pnt(0,0,0);
4448 Pnts1(2) = gp_Pnt(5,0,0);
4449 Pnts1(3) = gp_Pnt(10,10,0);
4451 Pnts2(1) = gp_Pnt(10,10,0);
4452 Pnts2(2) = gp_Pnt(5,12,4);
4453 Pnts2(3) = gp_Pnt(0,15,10);
4455 Pnts3(1) = gp_Pnt(0,15,10);
4456 Pnts3(2) = gp_Pnt(-12,10,11);
4457 Pnts3(3) = gp_Pnt(-10,5,13);
4459 Pnts4(1) = gp_Pnt(-10,5,13);
4460 Pnts4(2) = gp_Pnt(-2,-2,2);
4461 Pnts4(3) = gp_Pnt(0,0,0);
4463 GeomAPI_PointsToBSpline PTBS1(Pnts1);
4464 GeomAPI_PointsToBSpline PTBS2(Pnts2);
4465 GeomAPI_PointsToBSpline PTBS3(Pnts3);
4466 GeomAPI_PointsToBSpline PTBS4(Pnts4);
4467 Handle(Geom_BSplineCurve) C1 = PTBS1.Curve();
4468 Handle(Geom_BSplineCurve) C2 = PTBS2.Curve();
4469 Handle(Geom_BSplineCurve) C3 = PTBS3.Curve();
4470 Handle(Geom_BSplineCurve) C4 = PTBS4.Curve();
4472 GeomFill_BSplineCurves fill;
4473 fill.Init(C1,C2,C3,C4,GeomFill_CoonsStyle);
4474 Handle(Geom_BSplineSurface) BSS = fill.Surface();
4476 TopoDS_Shape S = BRepBuilderAPI_MakeFace(BSS, Precision::Confusion()).Face();
4478 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4479 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4480 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4481 myAISContext->Display(ais1,Standard_False);
4485 GProp_GProps System;
4486 BRepGProp::SurfaceProperties(S,System);
4487 gp_Pnt G = System.CentreOfMass ();
4488 Standard_Real Area = System.Mass();
4489 gp_Mat I = System.MatrixOfInertia();
4491 TCollection_ExtendedString string("Area Of the Face =");
4492 TCollection_ExtendedString string1(Area);
4495 string += "\nCenterOfMass : \n X=";
4506 string += "Matrix of Inertia :\n ";
4535 TCollection_AsciiString Message ("\
4537 TopoDS_Shape S = BRepBuilderAPI_MakeFace(BSplineSurf).Face();\n\
4538 GProp_GProps System;\n\
4539 BRepGProp::SurfaceProperties(S,System);\n\
4540 gp_Pnt G = System.CentreOfMass ();\n\
4541 Standard_Real Area = System.Mass();\n\
4542 gp_Mat I = System.MatrixOfInertia();\n\
4544 PocessTextInDialog("Surface Properties", Message);
4545 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, string.ToWideString(), L"Surface Properties", MB_OK);
4549 void CModelingDoc::OnVolume()
4551 AIS_ListOfInteractive aList;
4552 myAISContext->DisplayedObjects(aList);
4553 AIS_ListIteratorOfListOfInteractive aListIterator;
4554 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4555 myAISContext->Remove(aListIterator.Value());
4559 TopoDS_Shape S = BRepPrimAPI_MakeWedge(60.,100.,80.,20.).Shape();
4560 Handle(AIS_Shape) ais1 = new AIS_Shape(S);
4561 myAISContext->SetColor(ais1,Quantity_NOC_GREEN,Standard_False);
4562 myAISContext->SetMaterial(ais1,Graphic3d_NOM_PLASTIC,Standard_False);
4563 myAISContext->Display(ais1,Standard_False);
4567 GProp_GProps System;
4568 BRepGProp::VolumeProperties(S,System);
4569 gp_Pnt G = System.CentreOfMass ();
4570 Standard_Real Volume = System.Mass();
4571 gp_Mat I = System.MatrixOfInertia();
4573 TCollection_ExtendedString string("Volume Of all the Shape =");
4574 TCollection_ExtendedString string1(Volume);
4577 string += "\nCenterOfMass : \n X=";
4588 string += "Matrix of Inertia :\n ";
4617 TCollection_AsciiString Message ("\
4619 TopoDS_Shape S = BRepBuilderAPI_MakeWedge(60.,100.,80.,20.);;\n\
4620 GProp_GProps System;\n\
4621 BRepGProp::VolumeProperties(S,System);\n\
4622 gp_Pnt G = System.CentreOfMass ();\n\
4623 Standard_Real Volume = System.Mass();\n\
4624 gp_Mat I = System.MatrixOfInertia();\n\
4626 PocessTextInDialog("Volume Properties", Message);
4627 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, string.ToWideString(), L"Volume Properties", MB_OK);
4631 void CModelingDoc::OnButtonFill()
4633 // TODO: Add your command handler code here
4634 myAISContext->InitSelected();
4635 if (myAISContext->MoreSelected()) {
4636 AIS1 = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive());
4637 myAISContext->Unhilight(AIS1);
4638 myAISContext->Activate(AIS1,2);
4639 myState = SELECT_EDGE_PLATE;
4640 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select hole contour edges and then press right mouse button"); }
4642 AIS_ListOfInteractive LI;
4643 myAISContext->DisplayedObjects(LI);
4645 if(OnFileImportBrep_WithInitDir (L"HoleFilling") == 1)
4647 myAISContext->DisplayedObjects(LI);
4648 myAISContext->SetSelected(LI.First());
4652 AfxMessageBox (L"Select a shape before!");
4656 void CModelingDoc::OnStopStop()
4658 // TODO: Add your command handler code here
4660 if (myState == SELECT_EDGE_PLATE ) {
4661 Standard_Integer nbedges = 0;
4662 for (myAISContext->InitSelected(); myAISContext->MoreSelected();
4663 myAISContext->NextSelected()) {
4667 Handle(GeomPlate_HArray1OfHCurveOnSurface) Fronts =
4668 new GeomPlate_HArray1OfHCurveOnSurface(1,nbedges);
4669 Handle(TColStd_HArray1OfInteger) Tang =
4670 new TColStd_HArray1OfInteger(1,nbedges);
4671 Handle(TColStd_HArray1OfInteger) NbPtsCur =
4672 new TColStd_HArray1OfInteger(1,nbedges);
4673 Standard_Integer i = 0;
4674 TopoDS_Shape S1 = AIS1->Shape();
4675 TopTools_IndexedDataMapOfShapeListOfShape M;
4676 TopExp::MapShapesAndAncestors(S1, TopAbs_EDGE, TopAbs_FACE, M);
4678 for (myAISContext->InitSelected(); myAISContext->MoreSelected();myAISContext->NextSelected()) {
4680 Tang->SetValue(i,1);
4681 NbPtsCur->SetValue(i,10);
4682 TopoDS_Edge E = TopoDS::Edge(myAISContext->SelectedShape());
4683 TopoDS_Face F = TopoDS::Face(M.FindFromKey(E).First());
4685 BRepAdaptor_Surface S(F);
4686 GeomAdaptor_Surface aGAS = S.Surface();
4687 Handle(GeomAdaptor_HSurface) aHGAS = new GeomAdaptor_HSurface(aGAS);
4689 Handle(BRepAdaptor_HCurve2d) C = new BRepAdaptor_HCurve2d();
4690 C->ChangeCurve2d().Initialize(E,F);
4692 Adaptor3d_CurveOnSurface ConS(C,aHGAS);
4694 Handle (Adaptor3d_HCurveOnSurface) HConS = new Adaptor3d_HCurveOnSurface(ConS);
4695 Fronts->SetValue(i,HConS);
4697 GeomPlate_BuildPlateSurface abuildplate(NbPtsCur,Fronts,Tang,3);
4698 abuildplate.Perform();
4699 if (!abuildplate.IsDone()){ // New in 2.0
4700 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : Build plate not valid!", L"CasCade Error", MB_ICONERROR);
4703 Handle(GeomPlate_Surface) aplate = abuildplate.Surface();
4705 GeomPlate_MakeApprox aMKS(aplate, Precision::Approximation(), 4, 7, 0.001, 1);
4706 Handle(Geom_BSplineSurface) support = aMKS.Surface();
4707 BRepBuilderAPI_MakeWire MW;
4708 TopTools_Array1OfShape tab(1,nbedges);
4709 for (i=1 ; i<=nbedges ; i++) {
4710 if (abuildplate.Sense()->Value(abuildplate.Order()->Value(i))==1) {
4711 BRepBuilderAPI_MakeEdge ME(abuildplate.Curves2d()->Value(abuildplate.Order()->Value(i)),
4713 Fronts->Value(abuildplate.Order()->Value(i))->LastParameter(),
4714 Fronts->Value(abuildplate.Order()->Value(i))->FirstParameter());
4715 TopoDS_Edge E = ME.Edge();
4716 BRepLib::BuildCurves3d(E);
4717 tab(abuildplate.Order()->Value(i)) = E;
4721 BRepBuilderAPI_MakeEdge ME(abuildplate.Curves2d()->Value(abuildplate.Order()->Value(i)),
4723 Fronts->Value(abuildplate.Order()->Value(i))->FirstParameter(),
4724 Fronts->Value(abuildplate.Order()->Value(i))->LastParameter());
4725 TopoDS_Edge E = ME.Edge();
4726 BRepLib::BuildCurves3d(E);
4727 tab(abuildplate.Order()->Value(i)) = E;
4730 for (i=1 ; i<=nbedges ; i++)
4731 MW.Add(TopoDS::Edge(tab(i)));
4737 catch(StdFail_NotDone)
4739 AfxMessageBox (L"Can't build wire!");
4744 AfxMessageBox (L"Wire is not closed!");
4746 //Standard_Failure::Raise("Wire is not closed");
4749 BRepBuilderAPI_MakeFace MF(support,W,Standard_True);
4752 BRepTopAdaptor_FClass2d clas2d(aface,Precision::Confusion());
4753 if (clas2d.PerformInfinitePoint() == TopAbs_IN) {
4755 BRepBuilderAPI_MakeFace MF1(support,W,Standard_True);
4758 if (!BRepAlgo::IsValid(aface))
4759 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : The plate face is not valid!", L"CasCade Error", MB_ICONERROR);
4761 Handle(AIS_Shape) anAISShape = new AIS_Shape(aface);
4762 myAISContext->SetColor(anAISShape,Quantity_NOC_AZURE);
4763 myAISContext->SetMaterial(anAISShape,Graphic3d_NOM_SILVER);
4764 myAISContext->SetDisplayMode(anAISShape,1);
4765 myAISContext->Display(anAISShape);
4769 void CModelingDoc::OnFillwithtang()
4771 static BOOL flag = 0;
4774 Handle(AIS_InteractiveObject) aObject;
4775 myAISContext ->InitSelected();
4776 if(myAISContext->MoreSelected())
4777 aObject = myAISContext->SelectedInteractive();
4778 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with second face");
4779 if(OnFileImportBrep_WithInitDir (L"TangentSurface") == 1){
4780 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
4781 AIS_ListOfInteractive aList;
4782 myAISContext->DisplayedObjects(aList);
4783 AIS_ListIteratorOfListOfInteractive aListIterator;
4784 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4785 myAISContext->Remove(aListIterator.Value());
4789 myAISContext->SetSelected(aObject);
4792 myAISContext->InitSelected();
4793 if (myAISContext->MoreSelected()) {
4794 Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive());
4796 THE_F1 = TopoDS::Face(ashape->Shape());
4798 catch(Standard_Failure){}
4799 if (THE_F1.IsNull())
4801 AfxMessageBox (L"Current object is not a face!\n\
4802 Please, select a face to continue\nthe creation of a tangent surface.");
4805 myAISContext->Activate(ashape,2);
4806 myState = SELECT_EDGE_PLATE_TGTES_1;
4808 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the first face");
4811 AIS_ListOfInteractive LI;
4812 myAISContext->DisplayedObjects(LI);
4814 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with first face");
4815 if(OnFileImportBrep_WithInitDir (L"TangentSurface") == 1){
4816 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
4817 AIS_ListOfInteractive aList;
4818 myAISContext->DisplayedObjects(aList);
4819 AIS_ListIteratorOfListOfInteractive aListIterator;
4820 for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
4821 myAISContext->Remove(aListIterator.Value());
4826 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
4827 myAISContext->DisplayedObjects(LI);
4828 myAISContext->SetSelected(LI.First());
4834 AfxMessageBox (L"Select a face before");
4838 void CModelingDoc::InputEvent(const Standard_Integer /*x*/,
4839 const Standard_Integer /*y*/,
4840 const Handle(V3d_View)& /*aView*/)
4842 myAISContext->Select();
4843 if (myState == SELECT_EDGE_PLATE_TGTES_1) {
4844 myAISContext->InitSelected();
4845 if (myAISContext->MoreSelected()) {
4846 THE_E1 = TopoDS::Edge(myAISContext->SelectedShape());
4847 myState = SELECT_EDGE_PLATE_TGTES_2;
4849 AIS_ListOfInteractive aLI;
4850 myAISContext->DisplayedObjects(aLI);
4851 if(aLI.Extent() == 2){
4852 myState = SELECT_EDGE_PLATE_TGTES_2;
4853 if (myAISContext->IsSelected(aLI.First()))
4854 myAISContext->SetSelected(aLI.Last());
4856 myAISContext->SetSelected(aLI.First());
4857 myAISContext->InitSelected();
4858 Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive());
4859 THE_F2 = TopoDS::Face(ashape->Shape());
4860 myAISContext->Activate(ashape,2);
4861 myState = SELECT_EDGE_PLATE_TGTES_3;
4862 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the second face");
4866 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select second face");
4867 AIS_ListOfInteractive LI;
4868 myAISContext->DisplayedObjects(LI);
4869 if(LI.Extent() == 1){
4870 if(OnFileImportBrep_WithInitDir (L"TangentSurface") == 1)
4875 AfxMessageBox (L"Select an edge on the face!");
4878 else if (myState == SELECT_EDGE_PLATE_TGTES_2) {
4879 myAISContext->InitSelected();
4880 if (myAISContext->MoreSelected()) {
4881 Handle(AIS_Shape) ashape = Handle(AIS_Shape)::DownCast(myAISContext->SelectedInteractive());
4882 THE_F2 = TopoDS::Face(ashape->Shape());
4883 myAISContext->Activate(ashape,2);
4884 myState = SELECT_EDGE_PLATE_TGTES_3;
4885 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select an edge on the second face");
4888 AfxMessageBox (L"Select the second face!");
4890 else if (myState == SELECT_EDGE_PLATE_TGTES_3) {
4891 myAISContext->InitSelected();
4892 if (myAISContext->MoreSelected()) {
4893 THE_E2 = TopoDS::Edge(myAISContext->SelectedShape());
4895 Standard_Integer i, nbPntsOnFaces=10;
4896 Standard_Real u,First, Last, Delta, Tol=0.001, TolProj;
4902 //get the pcurve, curve and surface
4903 BRepAdaptor_Curve Curve3d1(THE_E1), Curve3d2(THE_E2);
4904 BRepAdaptor_Curve2d Curve2d1(THE_E1,THE_F1), Curve2d2(THE_E2,THE_F2);
4905 BRepAdaptor_Surface Surf1(THE_F1), Surf2(THE_F2);
4907 //compute the average plane : initial surface
4908 Handle(TColgp_HArray1OfPnt) theTanPoints = new
4909 TColgp_HArray1OfPnt (1,2*nbPntsOnFaces );
4911 Delta = (Curve3d1.LastParameter()-Curve3d1.FirstParameter())/(nbPntsOnFaces-1);
4912 for (u=Curve3d1.FirstParameter(),i=1;i<=nbPntsOnFaces; i++,u+=Delta)
4913 theTanPoints->SetValue(i,Curve3d1.Value(u));
4915 Delta = (Curve3d2.LastParameter()-Curve3d2.FirstParameter())/(nbPntsOnFaces-1);
4916 for (u=Curve3d2.FirstParameter(),i=1;i<=nbPntsOnFaces; i++,u+=Delta)
4917 theTanPoints->SetValue(nbPntsOnFaces+i,Curve3d2.Value(u));
4919 //Building an initial plane
4920 GeomPlate_BuildAveragePlane aMkPlane (theTanPoints,int(Tol),1,1,1);
4921 Handle(Geom_Plane) aPlane = aMkPlane.Plane();
4922 gp_Pln aPln = aPlane->Pln();
4923 gp_XYZ aNormale = aPln.Axis().Direction().XYZ();
4924 gp_Trsf aTrsf; // to compute the U and V of the points
4925 aTrsf.SetTransformation(aPln.Position());
4927 aPlane->D1(0,0,P,W1,W2); // extract plane DU & DV
4929 // 1st surface tangencies constraints
4930 Delta = (Curve3d1.LastParameter()-Curve3d1.FirstParameter())/(nbPntsOnFaces-1);
4931 for (u=Curve3d1.FirstParameter(),i=1; i<=nbPntsOnFaces; i++,u+=Delta) {
4932 P = Curve3d1.Value(u).Transformed(aTrsf);
4933 gp_XY UV(P.X(),P.Y());
4934 aPlate.Load(Plate_PinpointConstraint(UV,aNormale*P.Z()));
4936 Surf1.D1(P2d.X(),P2d.Y(),P,V1,V2); // extract surface UV of the point
4937 aPlate.Load(Plate_GtoCConstraint(UV,
4938 Plate_D1(W1.XYZ(),W2.XYZ()),
4939 Plate_D1(V1.XYZ(),V2.XYZ())));
4942 Delta = (Curve3d2.LastParameter()-Curve3d2.FirstParameter())/(nbPntsOnFaces-1);
4943 for (u=Curve3d2.FirstParameter(),i=1; i<=nbPntsOnFaces; i++,u+=Delta) {
4944 P = Curve3d2.Value(u).Transformed(aTrsf);
4945 gp_XY UV(P.X(),P.Y());
4946 aPlate.Load(Plate_PinpointConstraint(UV,aNormale*P.Z()));
4949 Surf2.D1(P2d.X(),P2d.Y(),P,V1,V2);
4950 aPlate.Load(Plate_GtoCConstraint(UV,
4951 Plate_D1(W1.XYZ(),W2.XYZ()),
4952 Plate_D1(V1.XYZ()*-1,V2.XYZ()*-1)));
4955 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Select a file with passing points");
4956 //Some passing points
4957 CFileDialog dlg(TRUE,
4960 OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
4961 L"Points Files (*.pass)|*.pass; |All Files (*.*)|*.*||",
4964 CString initdir(((OCC_App*) AfxGetApp())->GetInitDataDir());
4965 initdir += L"\\Data\\TangentSurface";
4967 dlg.m_ofn.lpstrInitialDir = initdir;
4969 if (dlg.DoModal() == IDOK)
4971 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Building the tangent surface...");
4972 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
4973 CString filename = dlg.GetPathName();
4976 if (!fic.open(filename, ios::in))
4977 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : Unable to open file", L"CasCade Error", MB_ICONERROR);
4978 Standard_Real x,y,z;
4982 while (!in.fail()|| !in.eof()){
4983 if (in >> x && in >> y && in >> z){
4984 PP = gp_Pnt(x, y, z);
4985 P = PP.Transformed(aTrsf);
4986 aPlate.Load(Plate_PinpointConstraint(gp_XY(P.X(),P.Y()),
4988 BRepBuilderAPI_MakeVertex V(PP);
4989 B.Add(C,V.Vertex());
4993 Handle(AIS_Shape) anAISCompound = new AIS_Shape(C);
4994 myAISContext->Display(anAISCompound, Standard_False);
4998 SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
4999 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("Building the tangent surface...");
5001 Standard_Integer Order = 3; // constraints continuity + 2
5002 aPlate.SolveTI(Order,1.);
5003 if (!aPlate.IsDone()){
5004 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : Build plate not valid!", L"CasCade Error", MB_ICONERROR);
5007 //Plate Surface creation
5008 Handle(GeomPlate_Surface) aPlateSurface = new GeomPlate_Surface(aPlane,aPlate);
5009 //BSplineSurface approximation
5010 GeomPlate_MakeApprox aMkSurf(aPlateSurface,Tol,1,8,0.1,1);
5011 Handle(Geom_Surface) theSurface =aMkSurf.Surface();
5013 // Face building ...
5014 Handle(Geom2d_Curve)C1,C2,C3,C4;
5015 Handle(Geom_Curve)C;
5016 C = BRep_Tool::Curve(THE_E1,First,Last);
5018 C1 = GeomProjLib::Curve2d(C,First,Last,theSurface,TolProj);
5019 TopoDS_Edge Ed1 = BRepBuilderAPI_MakeEdge(C1,theSurface).Edge();
5021 C = BRep_Tool::Curve(THE_E2,First,Last);
5023 C3 = GeomProjLib::Curve2d(C,First,Last,theSurface,TolProj);
5024 TopoDS_Edge Ed3 = BRepBuilderAPI_MakeEdge(C3,theSurface).Edge();
5026 C2 = GCE2d_MakeSegment(C1->Value(C1->FirstParameter()),
5027 C3->Value(C3->FirstParameter())).Value();
5028 TopoDS_Edge Ed2 = BRepBuilderAPI_MakeEdge(C2,theSurface).Edge();
5029 C4 = GCE2d_MakeSegment(C1->Value(C1->LastParameter()),
5030 C3->Value(C3->LastParameter())).Value();
5031 TopoDS_Edge Ed4 = BRepBuilderAPI_MakeEdge(C4,theSurface).Edge();
5034 TopoDS_Wire theWire = BRepBuilderAPI_MakeWire(Ed1,Ed2,Ed3,Ed4);
5035 TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire);
5036 BRepLib::BuildCurves3d(theFace);
5037 if (!BRepAlgo::IsValid(theFace)){
5038 C2 = GCE2d_MakeSegment(C1->Value(C1->LastParameter()),
5039 C3->Value(C3->FirstParameter())).Value();
5040 Ed2 = BRepBuilderAPI_MakeEdge(C2,theSurface).Edge();
5041 C4 = GCE2d_MakeSegment(C3->Value(C3->LastParameter()),
5042 C1->Value(C1->FirstParameter())).Value();
5043 Ed4 = BRepBuilderAPI_MakeEdge(C4,theSurface).Edge();
5045 theWire = BRepBuilderAPI_MakeWire(Ed1,Ed2,Ed3,Ed4);
5046 theFace = BRepBuilderAPI_MakeFace(theWire);
5047 BRepLib::BuildCurves3d(theFace);
5048 if (!BRepAlgo::IsValid(theFace))
5049 MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : The plate surface is not valid!!!", L"CasCade Error", MB_ICONERROR);
5052 Handle(AIS_Shape) anAISShape=new AIS_Shape(theFace);
5053 myAISContext->SetColor(anAISShape,Quantity_NOC_BLUE1);
5054 myAISContext->SetMaterial(anAISShape,Graphic3d_NOM_SILVER);
5055 myAISContext->SetDisplayMode(anAISShape,1);
5056 myAISContext->Display(anAISShape);
5060 AfxMessageBox (L"Select an edge on the second face!");
5061 ((OCC_MainFrame*)AfxGetMainWnd())->SetStatusMessage("");
5066 void CModelingDoc::Popup(const Standard_Integer x,
5067 const Standard_Integer y ,
5068 const Handle(V3d_View)& aView)
5070 Standard_Integer PopupMenuNumber=0;
5071 myAISContext->InitSelected();
5072 if (myState == SELECT_EDGE_PLATE)
5074 else if (myAISContext->MoreSelected())
5078 VERIFY(menu.LoadMenu(IDR_Popup3D));
5079 CMenu* pPopup = menu.GetSubMenu(PopupMenuNumber);
5080 ASSERT(pPopup != NULL);
5082 if (PopupMenuNumber == 1) // more than 1 object.
5084 bool OneOrMoreInShading = false;
5085 for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ())
5086 if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true;
5087 if(!OneOrMoreInShading)
5088 pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
5092 POINT winCoord = { x , y };
5093 Handle(WNT_Window) aWNTWindow=
5094 Handle(WNT_Window)::DownCast(aView->Window());
5095 ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord);
5096 pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y ,