0023035: TKOpenGl redesign regression caused by destruction of global OpenGl_Display...
[occt.git] / src / QANIC / QANIC.cxx
CommitLineData
b311480e 1// Created on: 2002-05-28
2// Created by: QA Admin
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21
22#include <QANIC.hxx>
23
24#include <Draw_Interpretor.hxx>
25#include <DBRep.hxx>
26#include <DrawTrSurf.hxx>
27#include <AIS_InteractiveContext.hxx>
28#include <ViewerTest.hxx>
29#include <AIS_Shape.hxx>
30#include <TopoDS_Shape.hxx>
31
32#include <BRepBuilderAPI_MakePolygon.hxx>
33#include <TopoDS_Face.hxx>
34#include <BRepBuilderAPI_MakeFace.hxx>
35#include <gp_Pnt.hxx>
36#include <gp_Dir.hxx>
37#include <gp_Ax1.hxx>
38#include <BRepPrimAPI_MakeRevol.hxx>
39
40#include <BRepAlgoAPI_Fuse.hxx>
41#include <BRepAlgo_Fuse.hxx>
42
43#include <GProp_GProps.hxx>
44#include <BRepGProp.hxx>
45#include <TopExp_Explorer.hxx>
46#include <TopoDS.hxx>
47#include <BRepMesh_IncrementalMesh.hxx>
48#include <BRep_Tool.hxx>
49#include <Poly_Triangulation.hxx>
50#include <TopExp.hxx>
51#include <ChFi3d_FilletShape.hxx>
52#include <BRepFilletAPI_MakeFillet.hxx>
53#include <Standard_ErrorHandler.hxx>
54
55static Standard_Integer OCC426 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
56{
57 if(argc < 7 || argc > 8) {
58 di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
59 return 1;
60 }
61 Standard_Boolean IsBRepAlgoAPI = Standard_True;
62 if (argc == 8) {
63 Standard_Integer IsB = atoi(argv[7]);
64 if (IsB != 1) {
65 IsBRepAlgoAPI = Standard_False;
66#if ! defined(BRepAlgo_def01)
67// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
68// return 1;
69#endif
70 }
71 }
72
73 BRepBuilderAPI_MakePolygon W1;
74 W1.Add(gp_Pnt(10, 0, 0));
75 W1.Add(gp_Pnt(20, 0, 0));
76 W1.Add(gp_Pnt(20, 0, 10));
77 W1.Add(gp_Pnt(10, 0, 10));
78 W1.Add(gp_Pnt(10, 0, 0));
79
80 Standard_Boolean OnlyPlane1 = Standard_False;
81 TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), OnlyPlane1);
82
83 gp_Pnt P1(0, 0, 0);
84 gp_Dir D1(0, 0, 30);
85 gp_Ax1 A1(P1,D1);
c6541a0c 86 Standard_Real angle1 = 360 * (M_PI / 180.0);
7fd59977 87 TopoDS_Shape rs1 = BRepPrimAPI_MakeRevol(F1, A1, angle1);
88
89 BRepBuilderAPI_MakePolygon W2;
90 Standard_Real f1 = 7.0710678118654752440;
91 Standard_Real f2 = 14.1421356237309504880;
92 W2.Add(gp_Pnt(f1, f1, 10));
93 W2.Add(gp_Pnt(f2, f2, 10));
94 W2.Add(gp_Pnt(f2, f2, 20));
95 W2.Add(gp_Pnt(f1, f1, 20));
96 W2.Add(gp_Pnt(f1, f1, 10));
97
98 Standard_Boolean OnlyPlane2 = Standard_False;
99 TopoDS_Face F2 = BRepBuilderAPI_MakeFace(W2.Wire(), OnlyPlane2);
100
101 gp_Pnt P2(0, 0, 0);
102 gp_Dir D2(0, 0, 30);
103 gp_Ax1 A2(P2,D2);
c6541a0c 104 Standard_Real angle2 = 270 * (M_PI / 180.0);
7fd59977 105 TopoDS_Shape rs2 = BRepPrimAPI_MakeRevol(F2, A2, angle2);
106
107 BRepBuilderAPI_MakePolygon W3;
108 W3.Add(gp_Pnt(10, 0, 20));
109 W3.Add(gp_Pnt(20, 0, 20));
110 W3.Add(gp_Pnt(20, 0, 30));
111 W3.Add(gp_Pnt(10, 0, 30));
112 W3.Add(gp_Pnt(10, 0, 20));
113
114 Standard_Boolean OnlyPlane3 = Standard_False;
115 TopoDS_Face F3 = BRepBuilderAPI_MakeFace(W3.Wire(), OnlyPlane3);
116
117 gp_Pnt P3(0, 0, 0);
118 gp_Dir D3(0, 0, 30);
119 gp_Ax1 A3(P3,D3);
c6541a0c 120 Standard_Real angle3 = 360 * (M_PI / 180.0);
7fd59977 121 TopoDS_Shape rs3 = BRepPrimAPI_MakeRevol(F3, A3, angle3);
122
123 TopoDS_Shape fuse32, fuse321;
124 if (IsBRepAlgoAPI) {
125 di << "fuse32 = BRepAlgoAPI_Fuse(rs3, rs2)" <<"\n";
126 di << "fuse321 = BRepAlgoAPI_Fuse(fuse32, rs1)" <<"\n";
127 fuse32 = BRepAlgoAPI_Fuse(rs3, rs2);
128 fuse321 = BRepAlgoAPI_Fuse(fuse32, rs1);
129 } else {
130 di << "fuse32 = BRepAlgo_Fuse(rs3, rs2)" <<"\n";
131 di << "fuse321 = BRepAlgo_Fuse(fuse32, rs1)" <<"\n";
132 fuse32 = BRepAlgo_Fuse(rs3, rs2);
133 fuse321 = BRepAlgo_Fuse(fuse32, rs1);
134 }
135
136 //Give the mass claculation of the shpae "fuse321"
137 GProp_GProps G;
138 BRepGProp::VolumeProperties(fuse321, G);
139 di<<" "<<"\n";
140 di<<"Mass: "<<G.Mass()<<"\n"<<"\n";
141
142 di << "Trianglating Faces ....." <<"\n";
143 TopExp_Explorer ExpFace;
144
145 for (ExpFace.Init (fuse321,TopAbs_FACE); ExpFace.More(); ExpFace.Next())
146 {
147 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
148 TopologicalFace.Orientation (TopAbs_FORWARD) ;
149 BRepMesh_IncrementalMesh IM(TopologicalFace, 1);
150 TopLoc_Location loc;
151 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(TopologicalFace, loc);
152 if (facing.IsNull())
153 {
154 di << "Triangulation FAILED for this face" << "\n";
155 continue;
156 }
157 di << "No of Triangles = " << facing->NbTriangles() << "\n";
158 }
159 di<<"Triangulation of all Faces Completed. "<< "\n" << "\n";
160
161 TopTools_IndexedDataMapOfShapeListOfShape edgemap;
162 TopExp::MapShapesAndAncestors(fuse321, TopAbs_EDGE, TopAbs_SOLID, edgemap);
163 di << "No. of Edges: " << edgemap.Extent() << "\n";
164 ChFi3d_FilletShape FShape = ChFi3d_Rational;
165 BRepFilletAPI_MakeFillet blend(fuse321,FShape);
166 di << "Adding Edges ..... " << "\n";
167 for(int i = 1; i <= edgemap.Extent(); i++)
168 {
169 // cout << "Adding Edge : " << i << endl;
170 TopoDS_Edge edg = TopoDS::Edge( edgemap.FindKey(i) );
171 if(!edg.IsNull()) blend.Add(1, edg);
172 }
173 di << "All Edges added ! Now Building the Blend ... " << "\n";
174 di<<" "<<"\n";
175 blend.Build();
176
177 //DBRep::Set ( argv[1], fuse321 );
178 DBRep::Set ( argv[1], blend );
179 DBRep::Set ( argv[2], rs1 );
180 DBRep::Set ( argv[3], rs2 );
181 DBRep::Set ( argv[4], rs3 );
182 DBRep::Set ( argv[5], fuse32 );
183 DBRep::Set ( argv[6], fuse321 );
184
185 return 0;
186}
187
188#include <Geom_SurfaceOfRevolution.hxx>
189//=======================================================================
190//function : isPeriodic
191//purpose :
192//=======================================================================
193static Standard_Integer isPeriodic(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
194{
195 try
196 {
197 OCC_CATCH_SIGNALS
198 // 1. Verify amount of arguments of the command
199 if (argc < 2) { di << "isperiodic FAULTY. Use : isperiodic surfaceOfRevolution"; return 0;}
200 // 2. Retrieve surface
201 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
202 if(aSurf.IsNull()) {di << "isperiodic FAULTY. argument of command is not a surface"; return 0;}
203 Handle(Geom_SurfaceOfRevolution) aRevolSurf = Handle(Geom_SurfaceOfRevolution)::DownCast(aSurf);
204 if(aRevolSurf.IsNull()) {di << "isperiodic FAULTY. argument of command is not a surface of revolution"; return 0;}
205 // 3. Verify whether entry surface is u-periodic and v-periodic
206 if(aRevolSurf->IsUPeriodic()) {di << "Surface is u-periodic \n";} else {di << "Surface is not u-periodic \n";}
207 if(aRevolSurf->IsVPeriodic()) {di << "Surface is v-periodic \n";} else {di << "Surface is not v-periodic \n";}
208 }
209 catch (Standard_Failure) {di << "isperiodic Exception \n" ;return 0;}
210
211 return 0;
212}
213
214#include <Precision.hxx>
215#include <Extrema_ExtPS.hxx>
216#include <GeomAdaptor_Surface.hxx>
217//=======================================================================
218//function : OCC486
219//purpose :
220//=======================================================================
221static Standard_Integer OCC486(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
222{
223 try
224 {
225 OCC_CATCH_SIGNALS
226 if (argc < 2) { di << "OCC486 FAULTY. Use : OCC486 surf x y z du dv"; return 1;}
227
228 Standard_Real du = 0;
229 Standard_Real dv = 0;
230
231 Handle(Geom_Surface) GS;
232 GS = DrawTrSurf::GetSurface(argv[1]);
233 if (GS.IsNull()) { di << "OCC486 FAULTY. Null surface /n";return 1;}
234 gp_Pnt P3D( atof(argv[2]),atof(argv[3]),atof(argv[4]) );
235
236 Standard_Real Tol = Precision::PConfusion();
237 Extrema_ExtPS myExtPS;
238 if (argc > 5) du = atof(argv[5]);
239 if (argc > 6) dv = atof(argv[6]);
240
241 Standard_Real uf, ul, vf, vl;
242 GS->Bounds(uf, ul, vf, vl);
243
244 GeomAdaptor_Surface aSurf(GS);
245 myExtPS.Initialize (aSurf, uf-du, ul+du, vf-dv, vl+dv, Tol, Tol );
246 myExtPS.Perform ( P3D );
247 Standard_Integer nPSurf = ( myExtPS.IsDone() ? myExtPS.NbExt() : 0 );
248
249 if ( nPSurf > 0 )
250 {
251
252 //Standard_Real distMin = myExtPS.Value ( 1 );
253 Standard_Real distMin = myExtPS.SquareDistance ( 1 );
254 Standard_Integer indMin=1;
255 for (Standard_Integer sol = 2; sol <= nPSurf ; sol++)
256 {
257 //Standard_Real dist = myExtPS.Value(sol);
258 Standard_Real dist = myExtPS.SquareDistance(sol);
259 if ( distMin > dist )
260 {
261 distMin = dist;
262 indMin = sol;
263 }
264 }
265//
266 distMin = sqrt(distMin);
267 Standard_Real S, T;
268 myExtPS.Point(indMin).Parameter ( S, T );
269 gp_Pnt aCheckPnt = aSurf.Value( S, T );
270 Standard_Real aCheckDist = P3D.Distance(aCheckPnt);
271 di << "Solution is : U = "<< S << "\t V = "<< T << "\n";
272 di << "Solution is : X = "<< aCheckPnt.X() << "\t Y = "<< aCheckPnt.Y() << "\t Z = "<< aCheckPnt.Z() << "\n";
273 di << "ExtremaDistance = " << distMin << "\n";
274 di << "CheckDistance = " << aCheckDist << "\n";
275
276 if(fabs(distMin - aCheckDist) < Precision::Confusion()) return 0;
277 else return 1;
278 }
279 else return 1;
280 }
281 catch (Standard_Failure) {di << "OCC486 Exception \n" ;return 1;}
282
283 return 0;
284}
285
286#include <GC_MakeArcOfCircle.hxx>
287#include <BRepBuilderAPI_MakeEdge.hxx>
288#include <BRepBuilderAPI_MakeWire.hxx>
289#include <TopoDS_Wire.hxx>
290#include <BRepBuilderAPI_MakeFace.hxx>
291#include <Geom_Plane.hxx>
292#include <gp_Pln.hxx>
293#include <BRepPrimAPI_MakePrism.hxx>
294#include <BRepOffsetAPI_DraftAngle.hxx>
295//=======================================================================
296//function : OCC712
297//purpose :
298//=======================================================================
299static Standard_Integer OCC712 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
300 if (argc != 3) {
301 di << "Usage : " << argv[0] << " draftAngle slabThick" << "\n";
302 return 1;
303 }
304 //NOTE: Case:1 - draftAngle = 15, slabThick = 30 --> Fails
305 // Case:2 draftAngle = 10, slabThick = 30 --> Ok
306 // Case:3 draftAngle = 10, slabThick = 40 --> Ok
307 //
308 // --------------------------------------------------
309 Standard_Real draftAngle = atof(argv[1]);
310 Standard_Real slabThick = atof(argv[2]);
311
312 Standard_Real f1 = 75;
313 Standard_Real f2 = 35;
314
315 gp_Pnt p1(-f2, f2, 0);
316 gp_Pnt p2( 0, f1, 0);
317 gp_Pnt p3( f2, f2, 0);
318 gp_Pnt p4( f1, 0, 0);
319 gp_Pnt p5( f2, -f2, 0);
320 gp_Pnt p6( 0, -f1, 0);
321 gp_Pnt p7(-f2, -f2, 0);
322 gp_Pnt p8(-f1, 0, 0);
323
324 GC_MakeArcOfCircle arc1(p1, p2, p3);
325 GC_MakeArcOfCircle arc2(p3, p4, p5);
326 GC_MakeArcOfCircle arc3(p5, p6, p7);
327 GC_MakeArcOfCircle arc4(p7, p8, p1);
328
329 TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(arc1.Value());
330 TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(arc2.Value());
331 TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(arc3.Value());
332 TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(arc4.Value());
333
334 BRepBuilderAPI_MakeWire MW;
335 MW.Add(e1);
336 MW.Add(e2);
337 MW.Add(e3);
338 MW.Add(e4);
339
340 if (!MW.IsDone())
341 {
342 di << "my Wire not done" << "\n";
343 return 1;
344 }
345 TopoDS_Wire W = MW.Wire();
346
347 TopoDS_Face F = BRepBuilderAPI_MakeFace(W);
348 if ( F.IsNull())
349 {
350 di << " Error in Face creation " << "\n";
351 return 1;
352 }
353
354 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
355 Handle (Geom_Plane) P = Handle(Geom_Plane)::DownCast(surf);
356 gp_Pln slabPln = P->Pln();
357
358 try
359 {
360 OCC_CATCH_SIGNALS
361 gp_Dir slabDir(0, 0, 1);
362 gp_Vec slabVect(slabDir);
363 slabVect *= slabThick;
364
365 BRepPrimAPI_MakePrism slab(F, slabVect, Standard_True);
366 if ( ! slab.IsDone() )
367 {
368 di << " Error in Slab creation " << "\n";
369 return 1;
370 }
371
372 TopoDS_Shape slabShape = slab.Shape();
373 if (fabs(draftAngle) > 0.01)
374 {
c6541a0c 375 Standard_Real angle = draftAngle*(M_PI / 180.0);
7fd59977 376 BRepOffsetAPI_DraftAngle draftSlab(slabShape);
377
378 TopoDS_Shape fShape = slab.FirstShape();
379 TopoDS_Shape lShape = slab.LastShape();
380
381 TopExp_Explorer ex;
382 for(ex.Init(slabShape, TopAbs_FACE); ex.More(); ex.Next())
383 {
384 TopoDS_Face aFace = TopoDS::Face(ex.Current());
385 if(aFace.IsSame(fShape) || aFace.IsSame(lShape)) continue;
386 draftSlab.Add(aFace, slabDir, angle, slabPln);
387 if (!draftSlab.AddDone())
388 {
389 di << " Error in Add " << "\n";
390 return 1;
391 }
392 }
393
394 di << "All Faces added. Building... " << "\n"; //cout.flush();
395 draftSlab.Build();
396 di << "Build done..." << "\n"; //cout.flush();
397 if (!draftSlab.IsDone()) //--------------> STEP:1
398 {
399 di << " Error in Build " << "\n";
400 return 1;
401 }
402 slabShape = draftSlab.Shape();
403 DBRep::Set(argv[1], slabShape);
404 }
405 }
406 catch ( Standard_Failure ) //--------------------> STEP:2
407 {
408 di << " Error in Draft Slab " << "\n";
409 return 1;
410 }
411 return 0;
412}
413
414//=======================================================================
415// performTriangulation
416//=======================================================================
417
418Standard_Integer performTriangulation (TopoDS_Shape aShape, Draw_Interpretor& di)
419{
420 int failed=0, total=0;
421 TopExp_Explorer ExpFace;
422 Handle(Poly_Triangulation) facing;
423
424 for (ExpFace.Init(aShape,TopAbs_FACE); ExpFace.More(); ExpFace.Next())
425 {
426 total++;
427 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
428 TopologicalFace.Orientation (TopAbs_FORWARD) ;
429 BRepMesh_IncrementalMesh IM(TopologicalFace, 1);
430 TopLoc_Location loc;
431 facing = BRep_Tool::Triangulation(TopologicalFace, loc);
432 di << "Face " << total << " - ";
433 if (facing.IsNull())
434 {
435 failed++;
436 di << "******************** FAILED during Triangulation " << "\n";
437 }
438 else
439 {
440 di << facing->NbTriangles() << " Triangles" <<"\n";
441 }
442 }
443 di<<"Triangulation of all Faces Completed: "<<"\n"<<"\n";
444 if (failed == 0) return 1;
445 di<<"***************************************************"<<"\n";
446 di<<"******* ********"<<"\n";
447 di<<"***** Triangulation FAILED for " << failed << " of " << total << " Faces ******"<<"\n";
448 di<<"******* ********"<<"\n";
449 di<<"***************************************************"<<"\n";
450 return 0;
451}
452
453#include <BRepPrimAPI_MakeCylinder.hxx>
454#include <BRepPrimAPI_MakeCone.hxx>
455#include <BRepAlgoAPI_Cut.hxx>
456#include <BRepAlgo_Cut.hxx>
457//=======================================================================
458//function : OCC822_1
459//purpose :
460//=======================================================================
461static Standard_Integer OCC822_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
462
463 if(argc < 4 || argc > 5) {
464 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
465 return 1;
466 }
467 Standard_Boolean IsBRepAlgoAPI = Standard_True;
468 if (argc == 5) {
469 Standard_Integer IsB = atoi(argv[4]);
470 if (IsB != 1) {
471 IsBRepAlgoAPI = Standard_False;
472#if ! defined(BRepAlgo_def01)
473// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
474// return 1;
475#endif
476#if ! defined(BRepAlgo_def02)
477// di << "Error: There is not BRepAlgo_Cut class" << "\n";
478// return 1;
479#endif
480 }
481 }
482
483 int index = 1;
484
485 gp_Pnt P1(0, 0, 0);
486 gp_Dir D1(0, 0, 1);
487 gp_Ax2 A1(P1,D1);
488
489 BRepPrimAPI_MakeCylinder cylMakerIn(A1, 40, 110);
490 BRepPrimAPI_MakeCylinder cylMakerOut(A1, 50, 100);
491 TopoDS_Shape cylIn = cylMakerIn.Shape();
492 TopoDS_Shape cylOut = cylMakerOut.Shape();
493
494 gp_Pnt P2(0, 0, 0);
495 gp_Dir D2(0, 0, -1);
496 gp_Ax2 A2(P2,D2);
497
498 BRepPrimAPI_MakeCone conMakerIn(A2, 40, 60, 110);
499 BRepPrimAPI_MakeCone conMakerOut(A2, 50, 70, 100);
500 TopoDS_Shape conIn = conMakerIn.Shape();
501 TopoDS_Shape conOut = conMakerOut.Shape();
502
503 di << "All primitives created..... Creating Boolean" << "\n";
504
505 TopoDS_Shape theIn, theOut, theRes;
506 try
507 {
508 OCC_CATCH_SIGNALS
509 if (IsBRepAlgoAPI) {
510 di << "theIn = BRepAlgoAPI_Fuse(cylIn, conIn)" <<"\n";
511 di << "theOut = BRepAlgoAPI_Fuse(cylOut, conOut)" <<"\n";
512 di << "theRes = BRepAlgoAPI_Cut(theOut, theIn)" <<"\n";
513 theIn = BRepAlgoAPI_Fuse(cylIn, conIn);
514 theOut = BRepAlgoAPI_Fuse(cylOut, conOut);
515 theRes = BRepAlgoAPI_Cut(theOut, theIn);
516 } else {
517 di << "theIn = BRepAlgo_Fuse(cylIn, conIn)" <<"\n";
518 di << "theOut = BRepAlgo_Fuse(cylOut, conOut)" <<"\n";
519 theIn = BRepAlgo_Fuse(cylIn, conIn);
520 theOut = BRepAlgo_Fuse(cylOut, conOut);
521 di << "theRes = BRepAlgo_Cut(theOut, theIn)" <<"\n";
522 theRes = BRepAlgo_Cut(theOut, theIn);
523 }
524
525 if (index < argc) DBRep::Set(argv[index++], theIn);
526 if (index < argc) DBRep::Set(argv[index++], theOut);
527 if (index < argc) DBRep::Set(argv[index++], theRes);
528 di << "Booleans Created ! Triangulating !" <<"\n";
529
530 performTriangulation(theRes, di);
531 }
532 catch ( Standard_Failure )
533 {
534 di<<"*********************************************************"<<"\n";
535 di<<"***** ******"<<"\n";
536 di<<"***** Standard_Failure : Exception in Shoe Function *****"<<"\n";
537 di<<"***** ******"<<"\n";
538 di<<"*********************************************************"<<"\n";
539 return 1;
540 }
541 return 0;
542
543}
544
545#include <BRepPrimAPI_MakeBox.hxx>
546#include <BRepPrimAPI_MakeSphere.hxx>
547//=======================================================================
548// OCC822_2
549//=======================================================================
550
551static Standard_Integer OCC822_2 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
552{
553 if(argc < 4 || argc > 5) {
554 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
555 return 1;
556 }
557 Standard_Boolean IsBRepAlgoAPI = Standard_True;
558 if (argc == 5) {
559 Standard_Integer IsB = atoi(argv[4]);
560 if (IsB != 1) {
561 IsBRepAlgoAPI = Standard_False;
562#if ! defined(BRepAlgo_def01)
563// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
564// return 1;
565#endif
566 }
567 }
568
569 int index = 1;
570
571 gp_Dir xDir(1, 0, 0);
572 gp_Dir zDir(0, 0, 1);
573 gp_Pnt cen1(0, 0, 0);
574 gp_Ax2 cor1(cen1, zDir, xDir);
575 BRepPrimAPI_MakeBox boxMaker(cor1, 100, 100, 100);
576 TopoDS_Shape box = boxMaker.Shape();
577 if (index < argc) DBRep::Set(argv[index++], box);
578
579 BRepPrimAPI_MakeSphere sphereMaker(gp_Pnt(100.0, 50.0, 50.0), 25.0);
580 TopoDS_Shape sph = sphereMaker.Shape();
581 if (index < argc) DBRep::Set(argv[index++], sph);
582
583 di << "All primitives created..... Creating Cut Objects" << "\n";
584
585 TopoDS_Shape fuse;
586 try
587 {
588 OCC_CATCH_SIGNALS
589 if (IsBRepAlgoAPI) {
590 di << "fuse = BRepAlgoAPI_Fuse(box, sph)" <<"\n";
591 fuse = BRepAlgoAPI_Fuse(box, sph);
592 } else {
593 di << "fuse = BRepAlgo_Fuse(box, sph)" <<"\n";
594 fuse = BRepAlgo_Fuse(box, sph);
595 }
596 if (index < argc) DBRep::Set(argv[index++], fuse);
597 di << "Object Created ! Now Triangulating !" ;
598
599 performTriangulation(fuse, di);
600 }
601 catch ( Standard_Failure )
602 {
603 di<<"*********************************************************"<<"\n";
604 di<<"***** ******"<<"\n";
605 di<<"***** Standard_Failure : Exception in HSP Function ******"<<"\n";
606 di<<"***** ******"<<"\n";
607 di<<"*********************************************************"<<"\n";
608 return 1;
609 }
610
611 return 0;
612}
613
614//=======================================================================
615// OCC823
616//=======================================================================
617
618static Standard_Integer OCC823 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
619{
620 if(argc < 4 || argc > 5) {
621 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
622 return 1;
623 }
624 Standard_Boolean IsBRepAlgoAPI = Standard_True;
625 if (argc == 5) {
626 Standard_Integer IsB = atoi(argv[4]);
627 if (IsB != 1) {
628 IsBRepAlgoAPI = Standard_False;
629#if ! defined(BRepAlgo_def01)
630// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
631// return 1;
632#endif
633 }
634 }
635 int index = 1;
636 Standard_Real size = 0.001;
637
638 gp_Pnt P1(40, 50, 0);
639 gp_Dir D1(100, 0, 0);
640 gp_Ax2 A1(P1,D1);
641 BRepPrimAPI_MakeCylinder mkCyl1(A1, 20, 100);
642 TopoDS_Shape cyl1 = mkCyl1.Shape();
643 if (index < argc) DBRep::Set(argv[index++], cyl1);
644
645 gp_Pnt P2(100, 50, size);
646 gp_Dir D2(0, size, 80);
647 gp_Ax2 A2(P2,D2);
648 BRepPrimAPI_MakeCylinder mkCyl2(A2, 20, 80);
649 TopoDS_Shape cyl2 = mkCyl2.Shape();
650 if (index < argc) DBRep::Set(argv[index++], cyl2);
651
652 di << "All primitives created..... Creating Boolean" << "\n";
653
654 TopoDS_Shape fuse;
655 try
656 {
657 OCC_CATCH_SIGNALS
658 if (IsBRepAlgoAPI) {
659 di << "fuse = BRepAlgoAPI_Fuse(cyl2, cyl1)" <<"\n";
660 fuse = BRepAlgoAPI_Fuse(cyl2, cyl1);
661 } else {
662 di << "fuse = BRepAlgo_Fuse(cyl2, cyl1)" <<"\n";
663 fuse = BRepAlgo_Fuse(cyl2, cyl1);
664 }
665 if (index < argc) DBRep::Set(argv[index++], fuse);
666 di << "Fuse Created ! Triangulating !" <<"\n";
667
668 performTriangulation(fuse, di);
669 }
670 catch ( Standard_Failure )
671 {
672 di<<"*********************************************************"<<"\n";
673 di<<"***** ******"<<"\n";
674 di<<"***** Standard_Failure : Exception in TEE Function ******"<<"\n";
675 di<<"***** ******"<<"\n";
676 di<<"*********************************************************"<<"\n";
677 return 1;
678 }
679 return 0;
680}
681
682//=======================================================================
683// OCC824
684//=======================================================================
685
686static Standard_Integer OCC824 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
687{
688 if(argc < 4 || argc > 5) {
689 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
690 return 1;
691 }
692 Standard_Boolean IsBRepAlgoAPI = Standard_True;
693 if (argc == 5) {
694 Standard_Integer IsB = atoi(argv[4]);
695 if (IsB != 1) {
696 IsBRepAlgoAPI = Standard_False;
697#if ! defined(BRepAlgo_def01)
698// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
699// return 1;
700#endif
701 }
702 }
703 int index = 1;
704
705 gp_Pnt P1(100, 0, 0);
706 gp_Dir D1(-1, 0, 0);
707 gp_Ax2 A1(P1,D1);
708 BRepPrimAPI_MakeCylinder mkCyl(A1, 20, 100);
709 TopoDS_Shape cyl = mkCyl.Shape();
710 if (index < argc) DBRep::Set(argv[index++], cyl);
711
712 BRepPrimAPI_MakeSphere sphere(P1, 20.0);
713 TopoDS_Shape sph = sphere.Shape();
714 if (index < argc) DBRep::Set(argv[index++], sph);
715
716 di << "All primitives created..... Creating Boolean" << "\n";
717
718 TopoDS_Shape fuse;
719 try
720 {
721 OCC_CATCH_SIGNALS
722 if (IsBRepAlgoAPI) {
723 di << "fuse = BRepAlgoAPI_Fuse(cyl, sph)" <<"\n";
724 fuse = BRepAlgoAPI_Fuse(cyl, sph);
725 } else {
726 di << "fuse = BRepAlgo_Fuse(cyl, sph)" <<"\n";
727 fuse = BRepAlgo_Fuse(cyl, sph);
728 }
729 di << "Fuse Created ! Triangulating !" <<"\n";
730 if (index < argc) DBRep::Set(argv[index++], fuse);
731
732 performTriangulation(fuse, di);
733 }
734 catch ( Standard_Failure )
735 {
736 di<<"*********************************************************"<<"\n";
737 di<<"***** ******"<<"\n";
738 di<<"***** Standard_Failure : Exception in YOU Function ******"<<"\n";
739 di<<"***** ******"<<"\n";
740 di<<"*********************************************************"<<"\n";
741 return 1;
742 }
743 return 0;
744}
745
746#include <TColgp_Array2OfPnt.hxx>
747#include <GeomConvert.hxx>
748#include <Geom_BezierSurface.hxx>
749#include <BRepPrimAPI_MakeHalfSpace.hxx>
750
751//=======================================================================
752// OCC825
753//=======================================================================
754
755static Standard_Integer OCC825 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
756{
757 if(argc < 6 || argc > 7) {
758 di << "Usage : " << argv[0] << " name1 name2 name3 result1 result2 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
759 return 1;
760 }
761 Standard_Boolean IsBRepAlgoAPI = Standard_True;
762 if (argc == 7) {
763 Standard_Integer IsB = atoi(argv[6]);
764 if (IsB != 1) {
765 IsBRepAlgoAPI = Standard_False;
766#if ! defined(BRepAlgo_def02)
767// di << "Error: There is not BRepAlgo_Cut class" << "\n";
768// return 1;
769#endif
770 }
771 }
772 int index = 1;
773
774 Standard_Real size = 50;
775 TColgp_Array2OfPnt poles(1, 2, 1, 2);
776
777 poles(1, 1).SetCoord(-size, 0, -size);
778 poles(1, 2).SetCoord(-size, 0, size);
779 poles(2, 1).SetCoord( size, 0, -size);
780 poles(2, 2).SetCoord( size, 0, size);
781
782 Handle(Geom_BezierSurface) BezSurf = new Geom_BezierSurface(poles);
783 Handle(Geom_BSplineSurface) BSpSurf = GeomConvert::SurfaceToBSplineSurface(BezSurf);
1c72dff6 784 BRepBuilderAPI_MakeFace faceMaker(BSpSurf, Precision::Confusion());
7fd59977 785 TopoDS_Face face = faceMaker.Face();
786
787 gp_Pnt pnt(0, size, 0);
788 BRepPrimAPI_MakeHalfSpace *hSpace = new BRepPrimAPI_MakeHalfSpace(face,pnt);
789 TopoDS_Shape hsp = hSpace->Solid();
790 if (index < argc) DBRep::Set(argv[index++], hsp);
791
792 BRepPrimAPI_MakeSphere sphere1(gp_Pnt(0.0, 0.0, 0.0), 25.0);
793 TopoDS_Shape sph1 = sphere1.Shape();
794 if (index < argc) DBRep::Set(argv[index++], sph1);
795
796 BRepPrimAPI_MakeSphere sphere2(gp_Pnt(0.0, 0.00001, 0.0), 25.0);
797 TopoDS_Shape sph2 = sphere2.Shape();
798 if (index < argc) DBRep::Set(argv[index++], sph2);
799
800 di << "All primitives created..... Creating Cut Objects" << "\n";
801
802 TopoDS_Shape cut1, cut2;
803 try
804 {
805 OCC_CATCH_SIGNALS
806 if (IsBRepAlgoAPI) {
807 di << "cut1 = BRepAlgoAPI_Cut(sph1, hsp)" << "\n";
808 cut1 = BRepAlgoAPI_Cut(sph1, hsp);
809 } else {
810 di << "cut1 = BRepAlgo_Cut(sph1, hsp)" << "\n";
811 cut1 = BRepAlgo_Cut(sph1, hsp);
812 }
813 if (index < argc) DBRep::Set(argv[index++], cut1);
814 di << "CUT 1 Created ! " ;
815
816 if (IsBRepAlgoAPI) {
817 di << "cut2 = BRepAlgoAPI_Cut(sph2, hsp)" << "\n";
818 cut2 = BRepAlgoAPI_Cut(sph2, hsp);
819 } else {
820 di << "cut2 = BRepAlgo_Cut(sph2, hsp)" << "\n";
821 cut2 = BRepAlgo_Cut(sph2, hsp);
822 }
823 if (index < argc) DBRep::Set(argv[index++], cut2);
824 di << "CUT 2 Created !" << "\n" << "\n";
825
826 GProp_GProps G;
827 BRepGProp::VolumeProperties(cut1, G);
828 di<<"CUT 1 Mass = "<<G.Mass()<< "\n" << "\n";
829 BRepGProp::VolumeProperties(cut2, G);
830 di<<"CUT 2 Mass = "<<G.Mass()<< "\n" << "\n";
831
832 di << "Trianglating Faces of CUT 1 ....." << "\n";
833 performTriangulation(cut1, di);
834
835 di << "Trianglating Faces of CUT 2 ....." << "\n";
836 performTriangulation(cut2, di);
837 }
838 catch ( Standard_Failure )
839 {
840 di<<"*********************************************************"<< "\n";
841 di<<"***** ******"<< "\n";
842 di<<"***** Standard_Failure : Exception in HSP Function ******"<< "\n";
843 di<<"***** ******"<< "\n";
844 di<<"*********************************************************"<< "\n";
845 return 1;
846 }
847
848 di<<"*************************************************************"<< "\n";
849 di<<" CUT 1 and CUT 2 gives entirely different results during"<< "\n";
850 di<<" mass computation and face triangulation, eventhough the"<< "\n";
851 di<<" two spheres are located more or less at the same position."<< "\n";
852 di<<"*************************************************************"<< "\n";
853
854 return 0;
855}
856
857//=======================================================================
858// OCC826
859//=======================================================================
860
861static Standard_Integer OCC826 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
862{
863 if(argc < 4 || argc > 5) {
864 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
865 return 1;
866 }
867 Standard_Boolean IsBRepAlgoAPI = Standard_True;
868 if (argc == 5) {
869 Standard_Integer IsB = atoi(argv[4]);
870 if (IsB != 1) {
871 IsBRepAlgoAPI = Standard_False;
872#if ! defined(BRepAlgo_def01)
873// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
874// return 1;
875#endif
876 }
877 }
878 int index = 1;
879
880 Standard_Real x1 = 181.82808;
881 Standard_Real x2 = 202.39390;
882 Standard_Real y1 = 31.011970;
883 Standard_Real y2 = 123.06856;
884
885 BRepBuilderAPI_MakePolygon W1;
886 W1.Add(gp_Pnt(x1, y1, 0));
887 W1.Add(gp_Pnt(x2, y1, 0));
888 W1.Add(gp_Pnt(x2, y2, 0));
889 W1.Add(gp_Pnt(x1, y2, 0));
890 W1.Add(gp_Pnt(x1, y1, 0));
891
892 Standard_Boolean myFalse = Standard_False;
893 TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), myFalse);
894
895 gp_Pnt P1(0, 0, 0);
896 gp_Dir D1(0, 30, 0);
897 gp_Ax1 A1(P1,D1);
c6541a0c 898 Standard_Real angle1 = 360 * (M_PI / 180.0);
7fd59977 899 TopoDS_Shape rev = BRepPrimAPI_MakeRevol(F1, A1, angle1);
900 if (index < argc) DBRep::Set(argv[index++], rev);
901
902 BRepPrimAPI_MakeSphere sphere(gp_Pnt(166.373, 77.0402, 96.0555), 23.218586);
903 TopoDS_Shape sph = sphere.Shape();
904 if (index < argc) DBRep::Set(argv[index++], sph);
905
906 di << "All primitives created..... Creating Boolean" << "\n";
907
908 TopoDS_Shape fuse;
909 try
910 {
911 OCC_CATCH_SIGNALS
912 if (IsBRepAlgoAPI) {
913 di << "fuse = BRepAlgoAPI_Fuse(rev, sph)" << "\n";
914 fuse = BRepAlgoAPI_Fuse(rev, sph);
915 } else {
916 di << "fuse = BRepAlgo_Fuse(rev, sph)" << "\n";
917 fuse = BRepAlgo_Fuse(rev, sph);
918 }
919 if (index < argc) DBRep::Set(argv[index++], fuse);
920 di << "Fuse Created ! Triangulating !" << "\n";
921 performTriangulation(fuse, di);
922 }
923 catch ( Standard_Failure )
924 {
925 di<<"*********************************************************"<< "\n";
926 di<<"***** ******"<< "\n";
927 di<<"***** Standard_Failure : Exception in SPH Function ******"<< "\n";
928 di<<"***** ******"<< "\n";
929 di<<"*********************************************************"<< "\n";
930 return 1;
931 }
932 return 0;
933}
934
935#include <BRepPrimAPI_MakeTorus.hxx>
936//=======================================================================
937// OCC827
938//=======================================================================
939
940static Standard_Integer OCC827 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
941{
942 if(argc < 6 || argc > 7) {
943 di << "Usage : " << argv[0] << " name1 name2 name3 result1 result2 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
944 return 1;
945 }
946 Standard_Boolean IsBRepAlgoAPI = Standard_True;
947 if (argc == 7) {
948 Standard_Integer IsB = atoi(argv[6]);
949 if (IsB != 1) {
950 IsBRepAlgoAPI = Standard_False;
951#if ! defined(BRepAlgo_def01)
952// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
953// return 1;
954#endif
955 }
956 }
957 int index = 1;
958
959 BRepBuilderAPI_MakePolygon W1;
960 W1.Add(gp_Pnt(10, 0, 0));
961 W1.Add(gp_Pnt(20, 0, 0));
962 W1.Add(gp_Pnt(20, 0, 50));
963 W1.Add(gp_Pnt(10, 0, 50));
964 W1.Add(gp_Pnt(10, 0, 0));
965
966 Standard_Boolean myFalse = Standard_False;
967 TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), myFalse);
968
969 gp_Pnt P1(0, 0, 0);
970 gp_Dir D1(0, 0, 30);
971 gp_Ax1 A1(P1,D1);
c6541a0c 972 Standard_Real angle1 = 360 * (M_PI / 180.0);
7fd59977 973 TopoDS_Shape rev = BRepPrimAPI_MakeRevol(F1, A1, angle1);
974 if (index < argc) DBRep::Set(argv[index++], rev);
975
976 gp_Pnt P2(0, 0, 50);
977 gp_Dir D2(0, 0, 30);
978 gp_Ax2 A2(P2,D2);
979 Standard_Real majRad = 15;
980 Standard_Real minRad = 5;
981 BRepPrimAPI_MakeTorus Torus1(A2, majRad, minRad);
982 TopoDS_Shape tor1 = Torus1.Shape();
983 if (index < argc) DBRep::Set(argv[index++], tor1);
984
985 gp_Pnt P3(0, 0, 10);
986 gp_Dir D3(0, 0, 30);
987 gp_Ax2 A3(P3,D3);
988 BRepPrimAPI_MakeTorus Torus2(A3, majRad, minRad);
989 TopoDS_Shape tor2 = Torus2.Shape();
990 if (index < argc) DBRep::Set(argv[index++], tor2);
991
992 di << "All primitives created..... Creating Boolean" << "\n";
993
994 TopoDS_Shape fuse1, fuse2;
995 try
996 {
997 OCC_CATCH_SIGNALS
998 if (IsBRepAlgoAPI) {
999 di << "Fuse1 = BRepAlgoAPI_Fuse(tor1, rev)" << "\n";
1000 fuse1 = BRepAlgoAPI_Fuse(tor1, rev);
1001 } else {
1002 di << "Fuse1 = BRepAlgo_Fuse(tor1, rev)" << "\n";
1003 fuse1 = BRepAlgo_Fuse(tor1, rev);
1004 }
1005 if (index < argc) DBRep::Set(argv[index++], fuse1);
1006 di << "Fuse1 Created ! Creating Fuse 2" << "\n";
1007 if (IsBRepAlgoAPI) {
1008 di << "Fuse2 = BRepAlgoAPI_Fuse(tor2, fuse1)" << "\n";
1009 fuse2 = BRepAlgoAPI_Fuse(tor2, fuse1);
1010 } else {
1011 di << "Fuse2 = BRepAlgo_Fuse(tor2, fuse1)" << "\n";
1012 fuse2 = BRepAlgo_Fuse(tor2, fuse1);
1013 }
1014 if (index < argc) DBRep::Set(argv[index++], fuse2);
1015 di << "Fuse2 Created ! Triangulating !" << "\n";
1016
1017 performTriangulation(fuse2, di);
1018 }
1019 catch ( Standard_Failure )
1020 {
1021 di<<"*********************************************************"<< "\n";
1022 di<<"***** ******"<< "\n";
1023 di<<"***** Standard_Failure : Exception in REV Function ******"<< "\n";
1024 di<<"***** ******"<< "\n";
1025 di<<"*********************************************************"<< "\n";
1026 return 1;
1027 }
1028 return 0;
1029}
1030
1031//=======================================================================
1032// performBlend
1033//=======================================================================
1034
1035int performBlend (TopoDS_Shape aShape, Standard_Real rad, TopoDS_Shape& bShape, Draw_Interpretor& di)
1036{
1037 Standard_Integer status = 0;
1038 TopoDS_Shape newShape;
1039 TopTools_IndexedDataMapOfShapeListOfShape edgemap;
1040 TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_SOLID,edgemap);
1041 di << "Blending All Edges: No. of Edges: " << edgemap.Extent() << "\n";
1042 ChFi3d_FilletShape FShape = ChFi3d_Rational;
1043 BRepFilletAPI_MakeFillet blend(aShape,FShape);
1044 for(int i = 1; i <= edgemap.Extent(); i++)
1045 {
1046 TopoDS_Edge edg = TopoDS::Edge( edgemap.FindKey(i) );
1047 if(!edg.IsNull()) blend.Add(rad, edg);
1048 }
1049
1050 try
1051 {
1052 OCC_CATCH_SIGNALS
1053 blend.Build();
1054 if(!blend.HasResult() || blend.Shape().IsNull()) {
1055 status = 1;
1056 }
1057 }
1058 catch ( Standard_Failure )
1059 {
1060 status = 1;
1061 }
1062 if(status) {
1063 di<<"*******************************************************"<< "\n";
1064 di<<"****** *******"<< "\n";
1065 di<<"****** Blending Failed (Radius = " << rad << ") *******"<< "\n";
1066 di<<"****** *******"<< "\n";
1067 di<<"*******************************************************"<< "\n";
1068 return 1;
1069 } else {
1070 di<<"Blending successfully performed on all Edges: "<< "\n" << "\n";
1071 }
1072 bShape = blend.Shape();
1073 return 0;
1074}
1075
1076#include <GC_MakeSegment.hxx>
1077//=======================================================================
1078// OCC828
1079//=======================================================================
1080
1081static Standard_Integer OCC828 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
1082{
1083 if(argc != 2) {
1084 di << "Usage : " << argv[0] << " shape" << "\n";
1085 }
1086 int index = 1;
1087
1088 Standard_Real slabThick = 111;
1089
1090 gp_Pnt p11(-27.598139, -7.0408573, 0.0);
1091 gp_Pnt p12(-28.483755, -17.487625, 0.0);
1092 gp_Pnt p13(-19.555504, -22.983587, 0.0);
1093 GC_MakeArcOfCircle arc1(p11, p12, p13);
1094
1095 gp_Pnt p21(12.125083, -22.983587, 0.0);
1096 gp_Pnt p22(21.1572, -17.27554, 0.0);
1097 gp_Pnt p23(19.878168, -6.6677585, 0.0);
1098 GC_MakeArcOfCircle arc2(p21, p22, p23);
1099
1100 gp_Pnt p31(3.265825, 13.724955, 0.0);
1101 gp_Pnt p32(-4.7233953, 17.406338, 0.0);
1102 gp_Pnt p33(-12.529893, 13.351856, 0.0);
1103 GC_MakeArcOfCircle arc3(p31, p32, p33);
1104
1105 GC_MakeSegment ln1(p13, p21);
1106 GC_MakeSegment ln2(p23, p31);
1107 GC_MakeSegment ln3(p33, p11);
1108
1109 TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(arc1.Value());
1110 TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(arc2.Value());
1111 TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(arc3.Value());
1112
1113 TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(ln1.Value());
1114 TopoDS_Edge e5 = BRepBuilderAPI_MakeEdge(ln2.Value());
1115 TopoDS_Edge e6 = BRepBuilderAPI_MakeEdge(ln3.Value());
1116
1117 BRepBuilderAPI_MakeWire MW;
1118 MW.Add(e1);
1119 MW.Add(e4);
1120 MW.Add(e2);
1121 MW.Add(e5);
1122 MW.Add(e3);
1123 MW.Add(e6);
1124
1125 if (!MW.IsDone())
1126 {
1127 di << "my Wire not done" << "\n";
1128 return 1;
1129 }
1130
1131 TopoDS_Wire W = MW.Wire();
1132 TopoDS_Face F = BRepBuilderAPI_MakeFace(W);
1133 if ( F.IsNull())
1134 {
1135 di << " Error in Face creation " << "\n";
1136 return 1;
1137 }
1138
1139 try
1140 {
1141 OCC_CATCH_SIGNALS
1142 gp_Dir slabDir(0, 0, 1);
1143 gp_Vec slabVect(slabDir);
1144 slabVect *= slabThick;
1145
1146 BRepPrimAPI_MakePrism slab(F, slabVect, Standard_True);
1147 if ( ! slab.IsDone() )
1148 {
1149 di << " Error in Slab creation " << "\n";
1150 return 1;
1151 }
1152 if (index < argc) DBRep::Set(argv[index++], slab.Shape());
1153
1154// cout << "Slab Successfully Created ! Now Blending ..." << endl;
1155// TopoDS_Shape aShape;
1156// int ret = performBlend(slab.Shape(), radius, aShape);
1157// if (ret) return 1;
1158// if (index < argc) DBRep::Set(argv[index++], aShape);
1159
1160// cout << "Blending Successfully Done ! Now Triangulating ..." << endl;
1161// performTriangulation(aShape);
1162 }
1163 catch ( Standard_Failure )
1164 {
1165 di << " Error in Draft Slab " << "\n";
1166 return 1;
1167 }
1168 return 0;
1169}
1170
1171void QANIC::Commands(Draw_Interpretor& theCommands) {
1172 char *group = "QANIC";
1173
1174 theCommands.Add ("OCC426", "OCC426 shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC426, group);
1175
1176 theCommands.Add("isperiodic", "Use : isperiodic surfaceOfRevolution", __FILE__, isPeriodic, group);
1177 theCommands.Add("OCC486", "Use : OCC486 surf x y z du dv ", __FILE__, OCC486, group);
1178 theCommands.Add("OCC712", "OCC712 draftAngle slabThick", __FILE__, OCC712, group);
1179 theCommands.Add("OCC822_1", "OCC822_1 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC822_1, group);
1180 theCommands.Add("OCC822_2", "OCC822_2 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC822_2, group);
1181 theCommands.Add("OCC823", "OCC823 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC823, group);
1182 theCommands.Add("OCC824", "OCC824 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC824, group);
1183 theCommands.Add("OCC825", "OCC825 name1 name2 name3 name4 name5 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC825, group);
1184 theCommands.Add("OCC826", "OCC826 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC826, group);
1185 theCommands.Add("OCC827", "OCC827 name1 name2 name3 result1 result2 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC827, group);
1186 theCommands.Add("OCC828", "OCC828 redius shape result ", __FILE__,OCC828, group);
1187
1188 return;
1189}