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