1 // Created on: 2002-05-28
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
19 #include <Draw_Interpretor.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <AIS_InteractiveContext.hxx>
23 #include <ViewerTest.hxx>
24 #include <AIS_Shape.hxx>
25 #include <TopoDS_Shape.hxx>
27 #include <BRepBuilderAPI_MakePolygon.hxx>
28 #include <TopoDS_Face.hxx>
29 #include <BRepBuilderAPI_MakeFace.hxx>
33 #include <BRepPrimAPI_MakeRevol.hxx>
35 #include <BRepAlgoAPI_Fuse.hxx>
37 #include <GProp_GProps.hxx>
38 #include <BRepGProp.hxx>
39 #include <TopExp_Explorer.hxx>
41 #include <BRepMesh_IncrementalMesh.hxx>
42 #include <BRep_Tool.hxx>
43 #include <Poly_Triangulation.hxx>
45 #include <ChFi3d_FilletShape.hxx>
46 #include <BRepFilletAPI_MakeFillet.hxx>
47 #include <Standard_ErrorHandler.hxx>
48 #include <Geom_TrimmedCurve.hxx>
49 #include <Geom_BSplineSurface.hxx>
51 #include <ShapeUpgrade_UnifySameDomain.hxx>
53 static Standard_Integer OCC426 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
56 di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 shape7\n";
60 BRepBuilderAPI_MakePolygon W1;
61 W1.Add(gp_Pnt(10, 0, 0));
62 W1.Add(gp_Pnt(20, 0, 0));
63 W1.Add(gp_Pnt(20, 0, 10));
64 W1.Add(gp_Pnt(10, 0, 10));
65 W1.Add(gp_Pnt(10, 0, 0));
67 Standard_Boolean OnlyPlane1 = Standard_False;
68 TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), OnlyPlane1);
73 Standard_Real angle1 = 360 * (M_PI / 180.0);
74 TopoDS_Shape rs1 = BRepPrimAPI_MakeRevol(F1, A1, angle1);
76 BRepBuilderAPI_MakePolygon W2;
77 Standard_Real f1 = 7.0710678118654752440;
78 Standard_Real f2 = 14.1421356237309504880;
79 W2.Add(gp_Pnt(f1, f1, 10));
80 W2.Add(gp_Pnt(f2, f2, 10));
81 W2.Add(gp_Pnt(f2, f2, 20));
82 W2.Add(gp_Pnt(f1, f1, 20));
83 W2.Add(gp_Pnt(f1, f1, 10));
85 Standard_Boolean OnlyPlane2 = Standard_False;
86 TopoDS_Face F2 = BRepBuilderAPI_MakeFace(W2.Wire(), OnlyPlane2);
91 Standard_Real angle2 = 270 * (M_PI / 180.0);
92 TopoDS_Shape rs2 = BRepPrimAPI_MakeRevol(F2, A2, angle2);
94 BRepBuilderAPI_MakePolygon W3;
95 W3.Add(gp_Pnt(10, 0, 20));
96 W3.Add(gp_Pnt(20, 0, 20));
97 W3.Add(gp_Pnt(20, 0, 30));
98 W3.Add(gp_Pnt(10, 0, 30));
99 W3.Add(gp_Pnt(10, 0, 20));
101 Standard_Boolean OnlyPlane3 = Standard_False;
102 TopoDS_Face F3 = BRepBuilderAPI_MakeFace(W3.Wire(), OnlyPlane3);
107 Standard_Real angle3 = 360 * (M_PI / 180.0);
108 TopoDS_Shape rs3 = BRepPrimAPI_MakeRevol(F3, A3, angle3);
110 di << "fuse32 = BRepAlgoAPI_Fuse(rs3, rs2)\n";
111 di << "fuse321 = BRepAlgoAPI_Fuse(fuse32, rs1)\n";
112 TopoDS_Shape fuse32 = BRepAlgoAPI_Fuse(rs3, rs2).Shape();
113 TopoDS_Shape fuse321 = BRepAlgoAPI_Fuse(fuse32, rs1).Shape();
115 // unify the faces of the Fuse result
116 ShapeUpgrade_UnifySameDomain anUnify(fuse321, Standard_True, Standard_True, Standard_True);
118 const TopoDS_Shape& aFuseUnif = anUnify.Shape();
120 //Give the mass claculation of the shpae "aFuseUnif"
122 BRepGProp::VolumeProperties(aFuseUnif, G);
124 di<<"Mass: "<<G.Mass()<<"\n\n";
126 di << "Trianglating Faces .....\n";
127 TopExp_Explorer ExpFace;
129 for (ExpFace.Init (aFuseUnif,TopAbs_FACE); ExpFace.More(); ExpFace.Next())
131 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
132 TopologicalFace.Orientation (TopAbs_FORWARD) ;
133 BRepMesh_IncrementalMesh IM(TopologicalFace, 1);
135 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(TopologicalFace, loc);
138 di << "Triangulation FAILED for this face\n";
141 di << "No of Triangles = " << facing->NbTriangles() << "\n";
143 di<<"Triangulation of all Faces Completed. \n\n";
145 TopTools_IndexedDataMapOfShapeListOfShape edgemap;
146 TopExp::MapShapesAndAncestors(aFuseUnif, TopAbs_EDGE, TopAbs_SOLID, edgemap);
147 di << "No. of Edges: " << edgemap.Extent() << "\n";
148 ChFi3d_FilletShape FShape = ChFi3d_Rational;
149 BRepFilletAPI_MakeFillet blend(aFuseUnif,FShape);
150 di << "Adding Edges ..... \n";
151 for(int i = 1; i <= edgemap.Extent(); i++)
153 // std::cout << "Adding Edge : " << i << std::endl;
154 TopoDS_Edge edg = TopoDS::Edge( edgemap.FindKey(i) );
155 if(!edg.IsNull()) blend.Add(1, edg);
157 di << "All Edges added ! Now Building the Blend ... \n";
161 //DBRep::Set ( argv[1], fuse321 );
162 DBRep::Set ( argv[1], blend );
163 DBRep::Set ( argv[2], rs1 );
164 DBRep::Set ( argv[3], rs2 );
165 DBRep::Set ( argv[4], rs3 );
166 DBRep::Set ( argv[5], fuse32 );
167 DBRep::Set ( argv[6], fuse321 );
168 DBRep::Set ( argv[7], aFuseUnif );
173 #include <Geom_SurfaceOfRevolution.hxx>
174 //=======================================================================
175 //function : isPeriodic
177 //=======================================================================
178 static Standard_Integer isPeriodic(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
183 // 1. Verify amount of arguments of the command
184 if (argc < 2) { di << "isperiodic FAULTY. Use : isperiodic surfaceOfRevolution"; return 0;}
185 // 2. Retrieve surface
186 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
187 if(aSurf.IsNull()) {di << "isperiodic FAULTY. argument of command is not a surface"; return 0;}
188 Handle(Geom_SurfaceOfRevolution) aRevolSurf = Handle(Geom_SurfaceOfRevolution)::DownCast(aSurf);
189 if(aRevolSurf.IsNull()) {di << "isperiodic FAULTY. argument of command is not a surface of revolution"; return 0;}
190 // 3. Verify whether entry surface is u-periodic and v-periodic
191 if(aRevolSurf->IsUPeriodic()) {di << "Surface is u-periodic \n";} else {di << "Surface is not u-periodic \n";}
192 if(aRevolSurf->IsVPeriodic()) {di << "Surface is v-periodic \n";} else {di << "Surface is not v-periodic \n";}
194 catch (Standard_Failure const&) {di << "isperiodic Exception \n" ;return 0;}
199 #include <Precision.hxx>
200 #include <Extrema_ExtPS.hxx>
201 #include <GeomAdaptor_Surface.hxx>
202 //=======================================================================
205 //=======================================================================
206 static Standard_Integer OCC486(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
211 if (argc < 2) { di << "OCC486 FAULTY. Use : OCC486 surf x y z du dv"; return 1;}
213 Standard_Real du = 0;
214 Standard_Real dv = 0;
216 Handle(Geom_Surface) GS;
217 GS = DrawTrSurf::GetSurface(argv[1]);
218 if (GS.IsNull()) { di << "OCC486 FAULTY. Null surface /n";return 1;}
219 gp_Pnt P3D( Draw::Atof(argv[2]),Draw::Atof(argv[3]),Draw::Atof(argv[4]) );
221 Standard_Real Tol = Precision::PConfusion();
222 Extrema_ExtPS myExtPS;
223 if (argc > 5) du = Draw::Atof(argv[5]);
224 if (argc > 6) dv = Draw::Atof(argv[6]);
226 Standard_Real uf, ul, vf, vl;
227 GS->Bounds(uf, ul, vf, vl);
229 GeomAdaptor_Surface aSurf(GS);
230 myExtPS.Initialize (aSurf, uf-du, ul+du, vf-dv, vl+dv, Tol, Tol );
231 myExtPS.Perform ( P3D );
232 Standard_Integer nPSurf = ( myExtPS.IsDone() ? myExtPS.NbExt() : 0 );
236 //Standard_Real distMin = myExtPS.Value ( 1 );
237 Standard_Real distMin = myExtPS.SquareDistance ( 1 );
238 Standard_Integer indMin=1;
239 for (Standard_Integer sol = 2; sol <= nPSurf ; sol++)
241 //Standard_Real dist = myExtPS.Value(sol);
242 Standard_Real dist = myExtPS.SquareDistance(sol);
243 if ( distMin > dist )
249 distMin = sqrt(distMin);
251 myExtPS.Point(indMin).Parameter ( S, T );
252 gp_Pnt aCheckPnt = aSurf.Value( S, T );
253 Standard_Real aCheckDist = P3D.Distance(aCheckPnt);
254 di << "Solution is : U = "<< S << "\t V = "<< T << "\n";
255 di << "Solution is : X = "<< aCheckPnt.X() << "\t Y = "<< aCheckPnt.Y() << "\t Z = "<< aCheckPnt.Z() << "\n";
256 di << "ExtremaDistance = " << distMin << "\n";
257 di << "CheckDistance = " << aCheckDist << "\n";
259 if(fabs(distMin - aCheckDist) < Precision::Confusion()) return 0;
264 catch (Standard_Failure const&) {di << "OCC486 Exception \n" ;return 1;}
267 #include <GC_MakeArcOfCircle.hxx>
268 #include <BRepBuilderAPI_MakeEdge.hxx>
269 #include <BRepBuilderAPI_MakeWire.hxx>
270 #include <TopoDS_Wire.hxx>
271 #include <BRepBuilderAPI_MakeFace.hxx>
272 #include <Geom_Plane.hxx>
273 #include <gp_Pln.hxx>
274 #include <BRepPrimAPI_MakePrism.hxx>
275 #include <BRepOffsetAPI_DraftAngle.hxx>
276 //=======================================================================
279 //=======================================================================
280 static Standard_Integer OCC712 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
282 di << "Usage : " << argv[0] << " draftAngle slabThick\n";
285 //NOTE: Case:1 - draftAngle = 15, slabThick = 30 --> Fails
286 // Case:2 draftAngle = 10, slabThick = 30 --> Ok
287 // Case:3 draftAngle = 10, slabThick = 40 --> Ok
289 // --------------------------------------------------
290 Standard_Real draftAngle = Draw::Atof(argv[1]);
291 Standard_Real slabThick = Draw::Atof(argv[2]);
293 Standard_Real f1 = 75;
294 Standard_Real f2 = 35;
296 gp_Pnt p1(-f2, f2, 0);
297 gp_Pnt p2( 0, f1, 0);
298 gp_Pnt p3( f2, f2, 0);
299 gp_Pnt p4( f1, 0, 0);
300 gp_Pnt p5( f2, -f2, 0);
301 gp_Pnt p6( 0, -f1, 0);
302 gp_Pnt p7(-f2, -f2, 0);
303 gp_Pnt p8(-f1, 0, 0);
305 GC_MakeArcOfCircle arc1(p1, p2, p3);
306 GC_MakeArcOfCircle arc2(p3, p4, p5);
307 GC_MakeArcOfCircle arc3(p5, p6, p7);
308 GC_MakeArcOfCircle arc4(p7, p8, p1);
310 TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(arc1.Value());
311 TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(arc2.Value());
312 TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(arc3.Value());
313 TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(arc4.Value());
315 BRepBuilderAPI_MakeWire MW;
323 di << "my Wire not done\n";
326 TopoDS_Wire W = MW.Wire();
328 TopoDS_Face F = BRepBuilderAPI_MakeFace(W);
331 di << " Error in Face creation \n";
335 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
336 Handle (Geom_Plane) P = Handle(Geom_Plane)::DownCast(surf);
337 gp_Pln slabPln = P->Pln();
342 gp_Dir slabDir(0, 0, 1);
343 gp_Vec slabVect(slabDir);
344 slabVect *= slabThick;
346 BRepPrimAPI_MakePrism slab(F, slabVect, Standard_True);
347 if ( ! slab.IsDone() )
349 di << " Error in Slab creation \n";
353 TopoDS_Shape slabShape = slab.Shape();
354 if (fabs(draftAngle) > 0.01)
356 Standard_Real angle = draftAngle*(M_PI / 180.0);
357 BRepOffsetAPI_DraftAngle draftSlab(slabShape);
359 TopoDS_Shape fShape = slab.FirstShape();
360 TopoDS_Shape lShape = slab.LastShape();
363 for(ex.Init(slabShape, TopAbs_FACE); ex.More(); ex.Next())
365 TopoDS_Face aFace = TopoDS::Face(ex.Current());
366 if(aFace.IsSame(fShape) || aFace.IsSame(lShape)) continue;
367 draftSlab.Add(aFace, slabDir, angle, slabPln);
368 if (!draftSlab.AddDone())
370 di << " Error in Add \n";
375 di << "All Faces added. Building... \n"; //std::cout.flush();
377 di << "Build done...\n"; //std::cout.flush();
378 if (!draftSlab.IsDone()) //--------------> STEP:1
380 di << " Error in Build \n";
383 slabShape = draftSlab.Shape();
384 DBRep::Set(argv[1], slabShape);
387 catch ( Standard_Failure const& ) //--------------------> STEP:2
389 di << " Error in Draft Slab \n";
395 //=======================================================================
396 // performTriangulation
397 //=======================================================================
399 Standard_Integer performTriangulation (TopoDS_Shape aShape, Draw_Interpretor& di)
401 int failed=0, total=0;
402 TopExp_Explorer ExpFace;
403 Handle(Poly_Triangulation) facing;
405 for (ExpFace.Init(aShape,TopAbs_FACE); ExpFace.More(); ExpFace.Next())
408 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
409 TopologicalFace.Orientation (TopAbs_FORWARD) ;
410 BRepMesh_IncrementalMesh IM(TopologicalFace, 1);
412 facing = BRep_Tool::Triangulation(TopologicalFace, loc);
413 di << "Face " << total << " - ";
417 di << "******************** FAILED during Triangulation \n";
421 di << facing->NbTriangles() << " Triangles\n";
424 di<<"Triangulation of all Faces Completed: \n\n";
425 if (failed == 0) return 1;
426 di<<"***************************************************\n";
427 di<<"******* ********\n";
428 di<<"***** Triangulation FAILED for " << failed << " of " << total << " Faces ******\n";
429 di<<"******* ********\n";
430 di<<"***************************************************\n";
434 #include <BRepPrimAPI_MakeCylinder.hxx>
435 #include <BRepPrimAPI_MakeCone.hxx>
436 #include <BRepAlgoAPI_Cut.hxx>
437 //=======================================================================
438 //function : OCC822_1
440 //=======================================================================
441 static Standard_Integer OCC822_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
444 di << "Usage : " << argv[0] << " name1 name2 result\n";
454 BRepPrimAPI_MakeCylinder cylMakerIn(A1, 40, 110);
455 BRepPrimAPI_MakeCylinder cylMakerOut(A1, 50, 100);
456 TopoDS_Shape cylIn = cylMakerIn.Shape();
457 TopoDS_Shape cylOut = cylMakerOut.Shape();
463 BRepPrimAPI_MakeCone conMakerIn(A2, 40, 60, 110);
464 BRepPrimAPI_MakeCone conMakerOut(A2, 50, 70, 100);
465 TopoDS_Shape conIn = conMakerIn.Shape();
466 TopoDS_Shape conOut = conMakerOut.Shape();
468 di << "All primitives created..... Creating Boolean\n";
474 di << "theIn = BRepAlgoAPI_Fuse(cylIn, conIn)\n";
475 di << "theOut = BRepAlgoAPI_Fuse(cylOut, conOut)\n";
476 di << "theRes = BRepAlgoAPI_Cut(theOut, theIn)\n";
477 TopoDS_Shape theIn = BRepAlgoAPI_Fuse(cylIn, conIn).Shape();
478 TopoDS_Shape theOut = BRepAlgoAPI_Fuse(cylOut, conOut).Shape();
479 TopoDS_Shape theRes = BRepAlgoAPI_Cut(theOut, theIn).Shape();
481 if (index < argc) DBRep::Set(argv[index++], theIn);
482 if (index < argc) DBRep::Set(argv[index++], theOut);
483 if (index < argc) DBRep::Set(argv[index++], theRes);
484 di << "Booleans Created ! Triangulating !\n";
486 performTriangulation(theRes, di);
488 catch ( Standard_Failure const& )
490 di << "*********************************************************\n";
491 di << "***** ******\n";
492 di << "***** Standard_Failure : Exception in Shoe Function *****\n";
493 di << "***** ******\n";
494 di << "*********************************************************\n";
501 #include <BRepPrimAPI_MakeBox.hxx>
502 #include <BRepPrimAPI_MakeSphere.hxx>
504 //=======================================================================
506 //=======================================================================
508 static Standard_Integer OCC822_2 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
511 di << "Usage : " << argv[0] << " name1 name2 result\n";
517 gp_Dir xDir(1, 0, 0);
518 gp_Dir zDir(0, 0, 1);
519 gp_Pnt cen1(0, 0, 0);
520 gp_Ax2 cor1(cen1, zDir, xDir);
521 BRepPrimAPI_MakeBox boxMaker(cor1, 100, 100, 100);
522 TopoDS_Shape box = boxMaker.Shape();
523 if (index < argc) DBRep::Set(argv[index++], box);
525 BRepPrimAPI_MakeSphere sphereMaker(gp_Pnt(100.0, 50.0, 50.0), 25.0);
526 TopoDS_Shape sph = sphereMaker.Shape();
527 if (index < argc) DBRep::Set(argv[index++], sph);
529 di << "All primitives created..... Creating Cut Objects\n";
535 di << "fuse = BRepAlgoAPI_Fuse(box, sph)\n";
536 TopoDS_Shape fuse = BRepAlgoAPI_Fuse(box, sph).Shape();
538 if (index < argc) DBRep::Set(argv[index++], fuse);
539 di << "Object Created ! Now Triangulating !";
541 performTriangulation(fuse, di);
543 catch ( Standard_Failure const& )
545 di << "*********************************************************\n";
546 di << "***** ******\n";
547 di << "***** Standard_Failure : Exception in HSP Function ******\n";
548 di << "***** ******\n";
549 di << "*********************************************************\n";
556 //=======================================================================
558 //=======================================================================
560 static Standard_Integer OCC823 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
563 di << "Usage : " << argv[0] << " name1 name2 result\n";
568 Standard_Real size = 0.001;
570 gp_Pnt P1(40, 50, 0);
571 gp_Dir D1(100, 0, 0);
573 BRepPrimAPI_MakeCylinder mkCyl1(A1, 20, 100);
574 TopoDS_Shape cyl1 = mkCyl1.Shape();
575 if (index < argc) DBRep::Set(argv[index++], cyl1);
577 gp_Pnt P2(100, 50, size);
578 gp_Dir D2(0, size, 80);
580 BRepPrimAPI_MakeCylinder mkCyl2(A2, 20, 80);
581 TopoDS_Shape cyl2 = mkCyl2.Shape();
582 if (index < argc) DBRep::Set(argv[index++], cyl2);
584 di << "All primitives created..... Creating Boolean\n";
590 di << "fuse = BRepAlgoAPI_Fuse(cyl2, cyl1)\n";
591 TopoDS_Shape fuse = BRepAlgoAPI_Fuse(cyl2, cyl1).Shape();
593 if (index < argc) DBRep::Set(argv[index++], fuse);
594 di << "Fuse Created ! Triangulating !\n";
596 performTriangulation(fuse, di);
598 catch (Standard_Failure const&)
600 di << "*********************************************************\n";
601 di << "***** ******\n";
602 di << "***** Standard_Failure : Exception in TEE Function ******\n";
603 di << "***** ******\n";
604 di << "*********************************************************\n";
610 //=======================================================================
612 //=======================================================================
614 static Standard_Integer OCC824 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
617 di << "Usage : " << argv[0] << " name1 name2 result\n";
623 gp_Pnt P1(100, 0, 0);
626 BRepPrimAPI_MakeCylinder mkCyl(A1, 20, 100);
627 TopoDS_Shape cyl = mkCyl.Shape();
628 if (index < argc) DBRep::Set(argv[index++], cyl);
630 BRepPrimAPI_MakeSphere sphere(P1, 20.0);
631 TopoDS_Shape sph = sphere.Shape();
632 if (index < argc) DBRep::Set(argv[index++], sph);
634 di << "All primitives created..... Creating Boolean\n";
640 di << "fuse = BRepAlgoAPI_Fuse(cyl, sph)\n";
641 TopoDS_Shape fuse = BRepAlgoAPI_Fuse(cyl, sph).Shape();
643 di << "Fuse Created ! Triangulating !\n";
644 if (index < argc) DBRep::Set(argv[index++], fuse);
646 performTriangulation(fuse, di);
648 catch (Standard_Failure const&)
650 di << "*********************************************************\n";
651 di << "***** ******\n";
652 di << "***** Standard_Failure : Exception in YOU Function ******\n";
653 di << "***** ******\n";
654 di << "*********************************************************\n";
660 #include <TColgp_Array2OfPnt.hxx>
661 #include <GeomConvert.hxx>
662 #include <Geom_BezierSurface.hxx>
663 #include <BRepPrimAPI_MakeHalfSpace.hxx>
665 //=======================================================================
667 //=======================================================================
669 static Standard_Integer OCC825 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
672 di << "Usage : " << argv[0] << " name1 name2 name3 result1 result2\n";
678 Standard_Real size = 50;
679 TColgp_Array2OfPnt poles(1, 2, 1, 2);
681 poles(1, 1).SetCoord(-size, 0, -size);
682 poles(1, 2).SetCoord(-size, 0, size);
683 poles(2, 1).SetCoord( size, 0, -size);
684 poles(2, 2).SetCoord( size, 0, size);
686 Handle(Geom_BezierSurface) BezSurf = new Geom_BezierSurface(poles);
687 Handle(Geom_BSplineSurface) BSpSurf = GeomConvert::SurfaceToBSplineSurface(BezSurf);
688 BRepBuilderAPI_MakeFace faceMaker(BSpSurf, Precision::Confusion());
689 TopoDS_Face face = faceMaker.Face();
691 gp_Pnt pnt(0, size, 0);
692 BRepPrimAPI_MakeHalfSpace *hSpace = new BRepPrimAPI_MakeHalfSpace(face,pnt);
693 TopoDS_Shape hsp = hSpace->Solid();
694 if (index < argc) DBRep::Set(argv[index++], hsp);
696 BRepPrimAPI_MakeSphere sphere1(gp_Pnt(0.0, 0.0, 0.0), 25.0);
697 TopoDS_Shape sph1 = sphere1.Shape();
698 if (index < argc) DBRep::Set(argv[index++], sph1);
700 BRepPrimAPI_MakeSphere sphere2(gp_Pnt(0.0, 0.00001, 0.0), 25.0);
701 TopoDS_Shape sph2 = sphere2.Shape();
702 if (index < argc) DBRep::Set(argv[index++], sph2);
704 di << "All primitives created..... Creating Cut Objects\n";
710 di << "cut1 = BRepAlgoAPI_Cut(sph1, hsp)\n";
711 TopoDS_Shape cut1 = BRepAlgoAPI_Cut(sph1, hsp).Shape();
713 if (index < argc) DBRep::Set(argv[index++], cut1);
714 di << "CUT 1 Created ! " ;
717 di << "cut2 = BRepAlgoAPI_Cut(sph2, hsp)\n";
718 TopoDS_Shape cut2 = BRepAlgoAPI_Cut(sph2, hsp).Shape();
720 if (index < argc) DBRep::Set(argv[index++], cut2);
721 di << "CUT 2 Created !\n\n";
724 BRepGProp::VolumeProperties(cut1, G);
725 di << "CUT 1 Mass = " << G.Mass() << "\n\n";
726 BRepGProp::VolumeProperties(cut2, G);
727 di << "CUT 2 Mass = " << G.Mass() << "\n\n";
729 di << "Trianglating Faces of CUT 1 .....\n";
730 performTriangulation(cut1, di);
732 di << "Trianglating Faces of CUT 2 .....\n";
733 performTriangulation(cut2, di);
735 catch (Standard_Failure const&)
737 di << "*********************************************************\n";
738 di << "***** ******\n";
739 di << "***** Standard_Failure : Exception in HSP Function ******\n";
740 di << "***** ******\n";
741 di << "*********************************************************\n";
745 di << "*************************************************************\n";
746 di << " CUT 1 and CUT 2 gives entirely different results during\n";
747 di << " mass computation and face triangulation, eventhough the\n";
748 di << " two spheres are located more or less at the same position.\n";
749 di << "*************************************************************\n";
754 //=======================================================================
756 //=======================================================================
758 static Standard_Integer OCC826 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
761 di << "Usage : " << argv[0] << " name1 name2 result\n";
767 Standard_Real x1 = 181.82808;
768 Standard_Real x2 = 202.39390;
769 Standard_Real y1 = 31.011970;
770 Standard_Real y2 = 123.06856;
772 BRepBuilderAPI_MakePolygon W1;
773 W1.Add(gp_Pnt(x1, y1, 0));
774 W1.Add(gp_Pnt(x2, y1, 0));
775 W1.Add(gp_Pnt(x2, y2, 0));
776 W1.Add(gp_Pnt(x1, y2, 0));
777 W1.Add(gp_Pnt(x1, y1, 0));
779 Standard_Boolean myFalse = Standard_False;
780 TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), myFalse);
785 Standard_Real angle1 = 360 * (M_PI / 180.0);
786 TopoDS_Shape rev = BRepPrimAPI_MakeRevol(F1, A1, angle1);
787 if (index < argc) DBRep::Set(argv[index++], rev);
789 BRepPrimAPI_MakeSphere sphere(gp_Pnt(166.373, 77.0402, 96.0555), 23.218586);
790 TopoDS_Shape sph = sphere.Shape();
791 if (index < argc) DBRep::Set(argv[index++], sph);
793 di << "All primitives created..... Creating Boolean\n";
799 di << "fuse = BRepAlgoAPI_Fuse(rev, sph)\n";
800 TopoDS_Shape fuse = BRepAlgoAPI_Fuse(rev, sph).Shape();
802 if (index < argc) DBRep::Set(argv[index++], fuse);
803 di << "Fuse Created ! Triangulating !\n";
804 performTriangulation(fuse, di);
806 catch (Standard_Failure const&)
808 di << "*********************************************************\n";
809 di << "***** ******\n";
810 di << "***** Standard_Failure : Exception in SPH Function ******\n";
811 di << "***** ******\n";
812 di << "*********************************************************\n";
818 #include <BRepPrimAPI_MakeTorus.hxx>
819 //=======================================================================
821 //=======================================================================
823 static Standard_Integer OCC827 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
826 di << "Usage : " << argv[0] << " name1 name2 name3 result1 result2\n";
832 BRepBuilderAPI_MakePolygon W1;
833 W1.Add(gp_Pnt(10, 0, 0));
834 W1.Add(gp_Pnt(20, 0, 0));
835 W1.Add(gp_Pnt(20, 0, 50));
836 W1.Add(gp_Pnt(10, 0, 50));
837 W1.Add(gp_Pnt(10, 0, 0));
839 Standard_Boolean myFalse = Standard_False;
840 TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), myFalse);
845 Standard_Real angle1 = 360 * (M_PI / 180.0);
846 TopoDS_Shape rev = BRepPrimAPI_MakeRevol(F1, A1, angle1);
847 if (index < argc) DBRep::Set(argv[index++], rev);
852 Standard_Real majRad = 15;
853 Standard_Real minRad = 5;
854 BRepPrimAPI_MakeTorus Torus1(A2, majRad, minRad);
855 TopoDS_Shape tor1 = Torus1.Shape();
856 if (index < argc) DBRep::Set(argv[index++], tor1);
861 BRepPrimAPI_MakeTorus Torus2(A3, majRad, minRad);
862 TopoDS_Shape tor2 = Torus2.Shape();
863 if (index < argc) DBRep::Set(argv[index++], tor2);
865 di << "All primitives created..... Creating Boolean\n";
871 di << "Fuse1 = BRepAlgoAPI_Fuse(tor1, rev)\n";
872 TopoDS_Shape fuse1 = BRepAlgoAPI_Fuse(tor1, rev).Shape();
874 if (index < argc) DBRep::Set(argv[index++], fuse1);
875 di << "Fuse1 Created ! Creating Fuse 2\n";
877 di << "Fuse2 = BRepAlgoAPI_Fuse(tor2, fuse1)\n";
878 TopoDS_Shape fuse2 = BRepAlgoAPI_Fuse(tor2, fuse1).Shape();
880 if (index < argc) DBRep::Set(argv[index++], fuse2);
881 di << "Fuse2 Created ! Triangulating !\n";
883 performTriangulation(fuse2, di);
885 catch (Standard_Failure const&)
887 di << "*********************************************************\n";
888 di << "***** ******\n";
889 di << "***** Standard_Failure : Exception in REV Function ******\n";
890 di << "***** ******\n";
891 di << "*********************************************************\n";
897 //=======================================================================
899 //=======================================================================
901 int performBlend (TopoDS_Shape aShape, Standard_Real rad, TopoDS_Shape& bShape, Draw_Interpretor& di)
903 Standard_Integer status = 0;
904 TopoDS_Shape newShape;
905 TopTools_IndexedDataMapOfShapeListOfShape edgemap;
906 TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_SOLID,edgemap);
907 di << "Blending All Edges: No. of Edges: " << edgemap.Extent() << "\n";
908 ChFi3d_FilletShape FShape = ChFi3d_Rational;
909 BRepFilletAPI_MakeFillet blend(aShape,FShape);
910 for(int i = 1; i <= edgemap.Extent(); i++)
912 TopoDS_Edge edg = TopoDS::Edge( edgemap.FindKey(i) );
913 if(!edg.IsNull()) blend.Add(rad, edg);
920 if(!blend.HasResult() || blend.Shape().IsNull()) {
924 catch ( Standard_Failure const& )
929 di<<"*******************************************************\n";
930 di<<"****** *******\n";
931 di<<"****** Blending Failed (Radius = " << rad << ") *******\n";
932 di<<"****** *******\n";
933 di<<"*******************************************************\n";
936 di<<"Blending successfully performed on all Edges: \n\n";
938 bShape = blend.Shape();
942 #include <GC_MakeSegment.hxx>
943 //=======================================================================
945 //=======================================================================
947 static Standard_Integer OCC828 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
950 di << "Usage : " << argv[0] << " shape\n";
954 Standard_Real slabThick = 111;
956 gp_Pnt p11(-27.598139, -7.0408573, 0.0);
957 gp_Pnt p12(-28.483755, -17.487625, 0.0);
958 gp_Pnt p13(-19.555504, -22.983587, 0.0);
959 GC_MakeArcOfCircle arc1(p11, p12, p13);
961 gp_Pnt p21(12.125083, -22.983587, 0.0);
962 gp_Pnt p22(21.1572, -17.27554, 0.0);
963 gp_Pnt p23(19.878168, -6.6677585, 0.0);
964 GC_MakeArcOfCircle arc2(p21, p22, p23);
966 gp_Pnt p31(3.265825, 13.724955, 0.0);
967 gp_Pnt p32(-4.7233953, 17.406338, 0.0);
968 gp_Pnt p33(-12.529893, 13.351856, 0.0);
969 GC_MakeArcOfCircle arc3(p31, p32, p33);
971 GC_MakeSegment ln1(p13, p21);
972 GC_MakeSegment ln2(p23, p31);
973 GC_MakeSegment ln3(p33, p11);
975 TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(arc1.Value());
976 TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(arc2.Value());
977 TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(arc3.Value());
979 TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(ln1.Value());
980 TopoDS_Edge e5 = BRepBuilderAPI_MakeEdge(ln2.Value());
981 TopoDS_Edge e6 = BRepBuilderAPI_MakeEdge(ln3.Value());
983 BRepBuilderAPI_MakeWire MW;
993 di << "my Wire not done\n";
997 TopoDS_Wire W = MW.Wire();
998 TopoDS_Face F = BRepBuilderAPI_MakeFace(W);
1001 di << " Error in Face creation \n";
1008 gp_Dir slabDir(0, 0, 1);
1009 gp_Vec slabVect(slabDir);
1010 slabVect *= slabThick;
1012 BRepPrimAPI_MakePrism slab(F, slabVect, Standard_True);
1013 if ( ! slab.IsDone() )
1015 di << " Error in Slab creation \n";
1018 if (index < argc) DBRep::Set(argv[index++], slab.Shape());
1020 // std::cout << "Slab Successfully Created ! Now Blending ..." << std::endl;
1021 // TopoDS_Shape aShape;
1022 // int ret = performBlend(slab.Shape(), radius, aShape);
1023 // if (ret) return 1;
1024 // if (index < argc) DBRep::Set(argv[index++], aShape);
1026 // std::cout << "Blending Successfully Done ! Now Triangulating ..." << std::endl;
1027 // performTriangulation(aShape);
1029 catch ( Standard_Failure const& )
1031 di << " Error in Draft Slab \n";
1037 void QABugs::Commands_10(Draw_Interpretor& theCommands) {
1038 const char *group = "QABugs";
1040 theCommands.Add ("OCC426", "OCC426 shape1 shape2 shape3 shape4 shape5 shape6 shape7", __FILE__, OCC426, group);
1042 theCommands.Add("isperiodic", "Use : isperiodic surfaceOfRevolution", __FILE__, isPeriodic, group);
1043 theCommands.Add("OCC486", "Use : OCC486 surf x y z du dv ", __FILE__, OCC486, group);
1044 theCommands.Add("OCC712", "OCC712 draftAngle slabThick", __FILE__, OCC712, group);
1045 theCommands.Add("OCC822_1", "OCC822_1 name1 name2 result", __FILE__,OCC822_1, group);
1046 theCommands.Add("OCC822_2", "OCC822_2 name1 name2 result", __FILE__,OCC822_2, group);
1047 theCommands.Add("OCC823", "OCC823 name1 name2 result", __FILE__,OCC823, group);
1048 theCommands.Add("OCC824", "OCC824 name1 name2 result", __FILE__,OCC824, group);
1049 theCommands.Add("OCC825", "OCC825 name1 name2 name3 name4 name5", __FILE__,OCC825, group);
1050 theCommands.Add("OCC826", "OCC826 name1 name2 result", __FILE__,OCC826, group);
1051 theCommands.Add("OCC827", "OCC827 name1 name2 name3 result1 result2", __FILE__,OCC827, group);
1052 theCommands.Add("OCC828", "OCC828 redius shape result ", __FILE__,OCC828, group);