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