2 // Created: Tue May 28 17:13:48 2002
9 #include <Draw_Interpretor.hxx>
11 #include <DrawTrSurf.hxx>
12 #include <AIS_InteractiveContext.hxx>
13 #include <ViewerTest.hxx>
14 #include <AIS_Shape.hxx>
15 #include <TopoDS_Shape.hxx>
17 #include <BRepBuilderAPI_MakePolygon.hxx>
18 #include <TopoDS_Face.hxx>
19 #include <BRepBuilderAPI_MakeFace.hxx>
23 #include <BRepPrimAPI_MakeRevol.hxx>
25 #include <BRepAlgoAPI_Fuse.hxx>
26 #include <BRepAlgo_Fuse.hxx>
28 #include <GProp_GProps.hxx>
29 #include <BRepGProp.hxx>
30 #include <TopExp_Explorer.hxx>
32 #include <BRepMesh_IncrementalMesh.hxx>
33 #include <BRep_Tool.hxx>
34 #include <Poly_Triangulation.hxx>
36 #include <ChFi3d_FilletShape.hxx>
37 #include <BRepFilletAPI_MakeFillet.hxx>
38 #include <Standard_ErrorHandler.hxx>
40 static Standard_Integer OCC426 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
42 if(argc < 7 || argc > 8) {
43 di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
46 Standard_Boolean IsBRepAlgoAPI = Standard_True;
48 Standard_Integer IsB = atoi(argv[7]);
50 IsBRepAlgoAPI = Standard_False;
51 #if ! defined(BRepAlgo_def01)
52 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
58 BRepBuilderAPI_MakePolygon W1;
59 W1.Add(gp_Pnt(10, 0, 0));
60 W1.Add(gp_Pnt(20, 0, 0));
61 W1.Add(gp_Pnt(20, 0, 10));
62 W1.Add(gp_Pnt(10, 0, 10));
63 W1.Add(gp_Pnt(10, 0, 0));
65 Standard_Boolean OnlyPlane1 = Standard_False;
66 TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), OnlyPlane1);
71 Standard_Real angle1 = 360 * PI180;
72 TopoDS_Shape rs1 = BRepPrimAPI_MakeRevol(F1, A1, angle1);
74 BRepBuilderAPI_MakePolygon W2;
75 Standard_Real f1 = 7.0710678118654752440;
76 Standard_Real f2 = 14.1421356237309504880;
77 W2.Add(gp_Pnt(f1, f1, 10));
78 W2.Add(gp_Pnt(f2, f2, 10));
79 W2.Add(gp_Pnt(f2, f2, 20));
80 W2.Add(gp_Pnt(f1, f1, 20));
81 W2.Add(gp_Pnt(f1, f1, 10));
83 Standard_Boolean OnlyPlane2 = Standard_False;
84 TopoDS_Face F2 = BRepBuilderAPI_MakeFace(W2.Wire(), OnlyPlane2);
89 Standard_Real angle2 = 270 * PI180;
90 TopoDS_Shape rs2 = BRepPrimAPI_MakeRevol(F2, A2, angle2);
92 BRepBuilderAPI_MakePolygon W3;
93 W3.Add(gp_Pnt(10, 0, 20));
94 W3.Add(gp_Pnt(20, 0, 20));
95 W3.Add(gp_Pnt(20, 0, 30));
96 W3.Add(gp_Pnt(10, 0, 30));
97 W3.Add(gp_Pnt(10, 0, 20));
99 Standard_Boolean OnlyPlane3 = Standard_False;
100 TopoDS_Face F3 = BRepBuilderAPI_MakeFace(W3.Wire(), OnlyPlane3);
105 Standard_Real angle3 = 360 * PI180;
106 TopoDS_Shape rs3 = BRepPrimAPI_MakeRevol(F3, A3, angle3);
108 TopoDS_Shape fuse32, fuse321;
110 di << "fuse32 = BRepAlgoAPI_Fuse(rs3, rs2)" <<"\n";
111 di << "fuse321 = BRepAlgoAPI_Fuse(fuse32, rs1)" <<"\n";
112 fuse32 = BRepAlgoAPI_Fuse(rs3, rs2);
113 fuse321 = BRepAlgoAPI_Fuse(fuse32, rs1);
115 di << "fuse32 = BRepAlgo_Fuse(rs3, rs2)" <<"\n";
116 di << "fuse321 = BRepAlgo_Fuse(fuse32, rs1)" <<"\n";
117 fuse32 = BRepAlgo_Fuse(rs3, rs2);
118 fuse321 = BRepAlgo_Fuse(fuse32, rs1);
121 //Give the mass claculation of the shpae "fuse321"
123 BRepGProp::VolumeProperties(fuse321, G);
125 di<<"Mass: "<<G.Mass()<<"\n"<<"\n";
127 di << "Trianglating Faces ....." <<"\n";
128 TopExp_Explorer ExpFace;
130 for (ExpFace.Init (fuse321,TopAbs_FACE); ExpFace.More(); ExpFace.Next())
132 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
133 TopologicalFace.Orientation (TopAbs_FORWARD) ;
134 BRepMesh_IncrementalMesh IM(TopologicalFace, 1);
136 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(TopologicalFace, loc);
139 di << "Triangulation FAILED for this face" << "\n";
142 di << "No of Triangles = " << facing->NbTriangles() << "\n";
144 di<<"Triangulation of all Faces Completed. "<< "\n" << "\n";
146 TopTools_IndexedDataMapOfShapeListOfShape edgemap;
147 TopExp::MapShapesAndAncestors(fuse321, TopAbs_EDGE, TopAbs_SOLID, edgemap);
148 di << "No. of Edges: " << edgemap.Extent() << "\n";
149 ChFi3d_FilletShape FShape = ChFi3d_Rational;
150 BRepFilletAPI_MakeFillet blend(fuse321,FShape);
151 di << "Adding Edges ..... " << "\n";
152 for(int i = 1; i <= edgemap.Extent(); i++)
154 // cout << "Adding Edge : " << i << endl;
155 TopoDS_Edge edg = TopoDS::Edge( edgemap.FindKey(i) );
156 if(!edg.IsNull()) blend.Add(1, edg);
158 di << "All Edges added ! Now Building the Blend ... " << "\n";
162 //DBRep::Set ( argv[1], fuse321 );
163 DBRep::Set ( argv[1], blend );
164 DBRep::Set ( argv[2], rs1 );
165 DBRep::Set ( argv[3], rs2 );
166 DBRep::Set ( argv[4], rs3 );
167 DBRep::Set ( argv[5], fuse32 );
168 DBRep::Set ( argv[6], fuse321 );
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) {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( atof(argv[2]),atof(argv[3]),atof(argv[4]) );
221 Standard_Real Tol = Precision::PConfusion();
222 Extrema_ExtPS myExtPS;
223 if (argc > 5) du = atof(argv[5]);
224 if (argc > 6) dv = 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 );
237 //Standard_Real distMin = myExtPS.Value ( 1 );
238 Standard_Real distMin = myExtPS.SquareDistance ( 1 );
239 Standard_Integer indMin=1;
240 for (Standard_Integer sol = 2; sol <= nPSurf ; sol++)
242 //Standard_Real dist = myExtPS.Value(sol);
243 Standard_Real dist = myExtPS.SquareDistance(sol);
244 if ( distMin > dist )
251 distMin = sqrt(distMin);
253 myExtPS.Point(indMin).Parameter ( S, T );
254 gp_Pnt aCheckPnt = aSurf.Value( S, T );
255 Standard_Real aCheckDist = P3D.Distance(aCheckPnt);
256 di << "Solution is : U = "<< S << "\t V = "<< T << "\n";
257 di << "Solution is : X = "<< aCheckPnt.X() << "\t Y = "<< aCheckPnt.Y() << "\t Z = "<< aCheckPnt.Z() << "\n";
258 di << "ExtremaDistance = " << distMin << "\n";
259 di << "CheckDistance = " << aCheckDist << "\n";
261 if(fabs(distMin - aCheckDist) < Precision::Confusion()) return 0;
266 catch (Standard_Failure) {di << "OCC486 Exception \n" ;return 1;}
271 #include <GC_MakeArcOfCircle.hxx>
272 #include <BRepBuilderAPI_MakeEdge.hxx>
273 #include <BRepBuilderAPI_MakeWire.hxx>
274 #include <TopoDS_Wire.hxx>
275 #include <BRepBuilderAPI_MakeFace.hxx>
276 #include <Geom_Plane.hxx>
277 #include <gp_Pln.hxx>
278 #include <BRepPrimAPI_MakePrism.hxx>
279 #include <BRepOffsetAPI_DraftAngle.hxx>
280 //=======================================================================
283 //=======================================================================
284 static Standard_Integer OCC712 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
286 di << "Usage : " << argv[0] << " draftAngle slabThick" << "\n";
289 //NOTE: Case:1 - draftAngle = 15, slabThick = 30 --> Fails
290 // Case:2 draftAngle = 10, slabThick = 30 --> Ok
291 // Case:3 draftAngle = 10, slabThick = 40 --> Ok
293 // --------------------------------------------------
294 Standard_Real draftAngle = atof(argv[1]);
295 Standard_Real slabThick = atof(argv[2]);
297 Standard_Real f1 = 75;
298 Standard_Real f2 = 35;
300 gp_Pnt p1(-f2, f2, 0);
301 gp_Pnt p2( 0, f1, 0);
302 gp_Pnt p3( f2, f2, 0);
303 gp_Pnt p4( f1, 0, 0);
304 gp_Pnt p5( f2, -f2, 0);
305 gp_Pnt p6( 0, -f1, 0);
306 gp_Pnt p7(-f2, -f2, 0);
307 gp_Pnt p8(-f1, 0, 0);
309 GC_MakeArcOfCircle arc1(p1, p2, p3);
310 GC_MakeArcOfCircle arc2(p3, p4, p5);
311 GC_MakeArcOfCircle arc3(p5, p6, p7);
312 GC_MakeArcOfCircle arc4(p7, p8, p1);
314 TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(arc1.Value());
315 TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(arc2.Value());
316 TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(arc3.Value());
317 TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(arc4.Value());
319 BRepBuilderAPI_MakeWire MW;
327 di << "my Wire not done" << "\n";
330 TopoDS_Wire W = MW.Wire();
332 TopoDS_Face F = BRepBuilderAPI_MakeFace(W);
335 di << " Error in Face creation " << "\n";
339 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
340 Handle (Geom_Plane) P = Handle(Geom_Plane)::DownCast(surf);
341 gp_Pln slabPln = P->Pln();
346 gp_Dir slabDir(0, 0, 1);
347 gp_Vec slabVect(slabDir);
348 slabVect *= slabThick;
350 BRepPrimAPI_MakePrism slab(F, slabVect, Standard_True);
351 if ( ! slab.IsDone() )
353 di << " Error in Slab creation " << "\n";
357 TopoDS_Shape slabShape = slab.Shape();
358 if (fabs(draftAngle) > 0.01)
360 Standard_Real angle = draftAngle*PI180;
361 BRepOffsetAPI_DraftAngle draftSlab(slabShape);
363 TopoDS_Shape fShape = slab.FirstShape();
364 TopoDS_Shape lShape = slab.LastShape();
367 for(ex.Init(slabShape, TopAbs_FACE); ex.More(); ex.Next())
369 TopoDS_Face aFace = TopoDS::Face(ex.Current());
370 if(aFace.IsSame(fShape) || aFace.IsSame(lShape)) continue;
371 draftSlab.Add(aFace, slabDir, angle, slabPln);
372 if (!draftSlab.AddDone())
374 di << " Error in Add " << "\n";
379 di << "All Faces added. Building... " << "\n"; //cout.flush();
381 di << "Build done..." << "\n"; //cout.flush();
382 if (!draftSlab.IsDone()) //--------------> STEP:1
384 di << " Error in Build " << "\n";
387 slabShape = draftSlab.Shape();
388 DBRep::Set(argv[1], slabShape);
391 catch ( Standard_Failure ) //--------------------> STEP:2
393 di << " Error in Draft Slab " << "\n";
399 //=======================================================================
400 // performTriangulation
401 //=======================================================================
403 Standard_Integer performTriangulation (TopoDS_Shape aShape, Draw_Interpretor& di)
405 int failed=0, total=0;
406 TopExp_Explorer ExpFace;
407 Handle(Poly_Triangulation) facing;
409 for (ExpFace.Init(aShape,TopAbs_FACE); ExpFace.More(); ExpFace.Next())
412 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
413 TopologicalFace.Orientation (TopAbs_FORWARD) ;
414 BRepMesh_IncrementalMesh IM(TopologicalFace, 1);
416 facing = BRep_Tool::Triangulation(TopologicalFace, loc);
417 di << "Face " << total << " - ";
421 di << "******************** FAILED during Triangulation " << "\n";
425 di << facing->NbTriangles() << " Triangles" <<"\n";
428 di<<"Triangulation of all Faces Completed: "<<"\n"<<"\n";
429 if (failed == 0) return 1;
430 di<<"***************************************************"<<"\n";
431 di<<"******* ********"<<"\n";
432 di<<"***** Triangulation FAILED for " << failed << " of " << total << " Faces ******"<<"\n";
433 di<<"******* ********"<<"\n";
434 di<<"***************************************************"<<"\n";
438 #include <BRepPrimAPI_MakeCylinder.hxx>
439 #include <BRepPrimAPI_MakeCone.hxx>
440 #include <BRepAlgoAPI_Cut.hxx>
441 #include <BRepAlgo_Cut.hxx>
442 //=======================================================================
443 //function : OCC822_1
445 //=======================================================================
446 static Standard_Integer OCC822_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
448 if(argc < 4 || argc > 5) {
449 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
452 Standard_Boolean IsBRepAlgoAPI = Standard_True;
454 Standard_Integer IsB = atoi(argv[4]);
456 IsBRepAlgoAPI = Standard_False;
457 #if ! defined(BRepAlgo_def01)
458 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
461 #if ! defined(BRepAlgo_def02)
462 // di << "Error: There is not BRepAlgo_Cut class" << "\n";
474 BRepPrimAPI_MakeCylinder cylMakerIn(A1, 40, 110);
475 BRepPrimAPI_MakeCylinder cylMakerOut(A1, 50, 100);
476 TopoDS_Shape cylIn = cylMakerIn.Shape();
477 TopoDS_Shape cylOut = cylMakerOut.Shape();
483 BRepPrimAPI_MakeCone conMakerIn(A2, 40, 60, 110);
484 BRepPrimAPI_MakeCone conMakerOut(A2, 50, 70, 100);
485 TopoDS_Shape conIn = conMakerIn.Shape();
486 TopoDS_Shape conOut = conMakerOut.Shape();
488 di << "All primitives created..... Creating Boolean" << "\n";
490 TopoDS_Shape theIn, theOut, theRes;
495 di << "theIn = BRepAlgoAPI_Fuse(cylIn, conIn)" <<"\n";
496 di << "theOut = BRepAlgoAPI_Fuse(cylOut, conOut)" <<"\n";
497 di << "theRes = BRepAlgoAPI_Cut(theOut, theIn)" <<"\n";
498 theIn = BRepAlgoAPI_Fuse(cylIn, conIn);
499 theOut = BRepAlgoAPI_Fuse(cylOut, conOut);
500 theRes = BRepAlgoAPI_Cut(theOut, theIn);
502 di << "theIn = BRepAlgo_Fuse(cylIn, conIn)" <<"\n";
503 di << "theOut = BRepAlgo_Fuse(cylOut, conOut)" <<"\n";
504 theIn = BRepAlgo_Fuse(cylIn, conIn);
505 theOut = BRepAlgo_Fuse(cylOut, conOut);
506 di << "theRes = BRepAlgo_Cut(theOut, theIn)" <<"\n";
507 theRes = BRepAlgo_Cut(theOut, theIn);
510 if (index < argc) DBRep::Set(argv[index++], theIn);
511 if (index < argc) DBRep::Set(argv[index++], theOut);
512 if (index < argc) DBRep::Set(argv[index++], theRes);
513 di << "Booleans Created ! Triangulating !" <<"\n";
515 performTriangulation(theRes, di);
517 catch ( Standard_Failure )
519 di<<"*********************************************************"<<"\n";
520 di<<"***** ******"<<"\n";
521 di<<"***** Standard_Failure : Exception in Shoe Function *****"<<"\n";
522 di<<"***** ******"<<"\n";
523 di<<"*********************************************************"<<"\n";
530 #include <BRepPrimAPI_MakeBox.hxx>
531 #include <BRepPrimAPI_MakeSphere.hxx>
532 //=======================================================================
534 //=======================================================================
536 static Standard_Integer OCC822_2 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
538 if(argc < 4 || argc > 5) {
539 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
542 Standard_Boolean IsBRepAlgoAPI = Standard_True;
544 Standard_Integer IsB = atoi(argv[4]);
546 IsBRepAlgoAPI = Standard_False;
547 #if ! defined(BRepAlgo_def01)
548 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
556 gp_Dir xDir(1, 0, 0);
557 gp_Dir zDir(0, 0, 1);
558 gp_Pnt cen1(0, 0, 0);
559 gp_Ax2 cor1(cen1, zDir, xDir);
560 BRepPrimAPI_MakeBox boxMaker(cor1, 100, 100, 100);
561 TopoDS_Shape box = boxMaker.Shape();
562 if (index < argc) DBRep::Set(argv[index++], box);
564 BRepPrimAPI_MakeSphere sphereMaker(gp_Pnt(100.0, 50.0, 50.0), 25.0);
565 TopoDS_Shape sph = sphereMaker.Shape();
566 if (index < argc) DBRep::Set(argv[index++], sph);
568 di << "All primitives created..... Creating Cut Objects" << "\n";
575 di << "fuse = BRepAlgoAPI_Fuse(box, sph)" <<"\n";
576 fuse = BRepAlgoAPI_Fuse(box, sph);
578 di << "fuse = BRepAlgo_Fuse(box, sph)" <<"\n";
579 fuse = BRepAlgo_Fuse(box, sph);
581 if (index < argc) DBRep::Set(argv[index++], fuse);
582 di << "Object Created ! Now Triangulating !" ;
584 performTriangulation(fuse, di);
586 catch ( Standard_Failure )
588 di<<"*********************************************************"<<"\n";
589 di<<"***** ******"<<"\n";
590 di<<"***** Standard_Failure : Exception in HSP Function ******"<<"\n";
591 di<<"***** ******"<<"\n";
592 di<<"*********************************************************"<<"\n";
599 //=======================================================================
601 //=======================================================================
603 static Standard_Integer OCC823 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
605 if(argc < 4 || argc > 5) {
606 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
609 Standard_Boolean IsBRepAlgoAPI = Standard_True;
611 Standard_Integer IsB = atoi(argv[4]);
613 IsBRepAlgoAPI = Standard_False;
614 #if ! defined(BRepAlgo_def01)
615 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
621 Standard_Real size = 0.001;
623 gp_Pnt P1(40, 50, 0);
624 gp_Dir D1(100, 0, 0);
626 BRepPrimAPI_MakeCylinder mkCyl1(A1, 20, 100);
627 TopoDS_Shape cyl1 = mkCyl1.Shape();
628 if (index < argc) DBRep::Set(argv[index++], cyl1);
630 gp_Pnt P2(100, 50, size);
631 gp_Dir D2(0, size, 80);
633 BRepPrimAPI_MakeCylinder mkCyl2(A2, 20, 80);
634 TopoDS_Shape cyl2 = mkCyl2.Shape();
635 if (index < argc) DBRep::Set(argv[index++], cyl2);
637 di << "All primitives created..... Creating Boolean" << "\n";
644 di << "fuse = BRepAlgoAPI_Fuse(cyl2, cyl1)" <<"\n";
645 fuse = BRepAlgoAPI_Fuse(cyl2, cyl1);
647 di << "fuse = BRepAlgo_Fuse(cyl2, cyl1)" <<"\n";
648 fuse = BRepAlgo_Fuse(cyl2, cyl1);
650 if (index < argc) DBRep::Set(argv[index++], fuse);
651 di << "Fuse Created ! Triangulating !" <<"\n";
653 performTriangulation(fuse, di);
655 catch ( Standard_Failure )
657 di<<"*********************************************************"<<"\n";
658 di<<"***** ******"<<"\n";
659 di<<"***** Standard_Failure : Exception in TEE Function ******"<<"\n";
660 di<<"***** ******"<<"\n";
661 di<<"*********************************************************"<<"\n";
667 //=======================================================================
669 //=======================================================================
671 static Standard_Integer OCC824 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
673 if(argc < 4 || argc > 5) {
674 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
677 Standard_Boolean IsBRepAlgoAPI = Standard_True;
679 Standard_Integer IsB = atoi(argv[4]);
681 IsBRepAlgoAPI = Standard_False;
682 #if ! defined(BRepAlgo_def01)
683 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
690 gp_Pnt P1(100, 0, 0);
693 BRepPrimAPI_MakeCylinder mkCyl(A1, 20, 100);
694 TopoDS_Shape cyl = mkCyl.Shape();
695 if (index < argc) DBRep::Set(argv[index++], cyl);
697 BRepPrimAPI_MakeSphere sphere(P1, 20.0);
698 TopoDS_Shape sph = sphere.Shape();
699 if (index < argc) DBRep::Set(argv[index++], sph);
701 di << "All primitives created..... Creating Boolean" << "\n";
708 di << "fuse = BRepAlgoAPI_Fuse(cyl, sph)" <<"\n";
709 fuse = BRepAlgoAPI_Fuse(cyl, sph);
711 di << "fuse = BRepAlgo_Fuse(cyl, sph)" <<"\n";
712 fuse = BRepAlgo_Fuse(cyl, sph);
714 di << "Fuse Created ! Triangulating !" <<"\n";
715 if (index < argc) DBRep::Set(argv[index++], fuse);
717 performTriangulation(fuse, di);
719 catch ( Standard_Failure )
721 di<<"*********************************************************"<<"\n";
722 di<<"***** ******"<<"\n";
723 di<<"***** Standard_Failure : Exception in YOU Function ******"<<"\n";
724 di<<"***** ******"<<"\n";
725 di<<"*********************************************************"<<"\n";
731 #include <TColgp_Array2OfPnt.hxx>
732 #include <GeomConvert.hxx>
733 #include <Geom_BezierSurface.hxx>
734 #include <BRepPrimAPI_MakeHalfSpace.hxx>
736 //=======================================================================
738 //=======================================================================
740 static Standard_Integer OCC825 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
742 if(argc < 6 || argc > 7) {
743 di << "Usage : " << argv[0] << " name1 name2 name3 result1 result2 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
746 Standard_Boolean IsBRepAlgoAPI = Standard_True;
748 Standard_Integer IsB = atoi(argv[6]);
750 IsBRepAlgoAPI = Standard_False;
751 #if ! defined(BRepAlgo_def02)
752 // di << "Error: There is not BRepAlgo_Cut class" << "\n";
759 Standard_Real size = 50;
760 TColgp_Array2OfPnt poles(1, 2, 1, 2);
762 poles(1, 1).SetCoord(-size, 0, -size);
763 poles(1, 2).SetCoord(-size, 0, size);
764 poles(2, 1).SetCoord( size, 0, -size);
765 poles(2, 2).SetCoord( size, 0, size);
767 Handle(Geom_BezierSurface) BezSurf = new Geom_BezierSurface(poles);
768 Handle(Geom_BSplineSurface) BSpSurf = GeomConvert::SurfaceToBSplineSurface(BezSurf);
769 BRepBuilderAPI_MakeFace faceMaker(BSpSurf);
770 TopoDS_Face face = faceMaker.Face();
772 gp_Pnt pnt(0, size, 0);
773 BRepPrimAPI_MakeHalfSpace *hSpace = new BRepPrimAPI_MakeHalfSpace(face,pnt);
774 TopoDS_Shape hsp = hSpace->Solid();
775 if (index < argc) DBRep::Set(argv[index++], hsp);
777 BRepPrimAPI_MakeSphere sphere1(gp_Pnt(0.0, 0.0, 0.0), 25.0);
778 TopoDS_Shape sph1 = sphere1.Shape();
779 if (index < argc) DBRep::Set(argv[index++], sph1);
781 BRepPrimAPI_MakeSphere sphere2(gp_Pnt(0.0, 0.00001, 0.0), 25.0);
782 TopoDS_Shape sph2 = sphere2.Shape();
783 if (index < argc) DBRep::Set(argv[index++], sph2);
785 di << "All primitives created..... Creating Cut Objects" << "\n";
787 TopoDS_Shape cut1, cut2;
792 di << "cut1 = BRepAlgoAPI_Cut(sph1, hsp)" << "\n";
793 cut1 = BRepAlgoAPI_Cut(sph1, hsp);
795 di << "cut1 = BRepAlgo_Cut(sph1, hsp)" << "\n";
796 cut1 = BRepAlgo_Cut(sph1, hsp);
798 if (index < argc) DBRep::Set(argv[index++], cut1);
799 di << "CUT 1 Created ! " ;
802 di << "cut2 = BRepAlgoAPI_Cut(sph2, hsp)" << "\n";
803 cut2 = BRepAlgoAPI_Cut(sph2, hsp);
805 di << "cut2 = BRepAlgo_Cut(sph2, hsp)" << "\n";
806 cut2 = BRepAlgo_Cut(sph2, hsp);
808 if (index < argc) DBRep::Set(argv[index++], cut2);
809 di << "CUT 2 Created !" << "\n" << "\n";
812 BRepGProp::VolumeProperties(cut1, G);
813 di<<"CUT 1 Mass = "<<G.Mass()<< "\n" << "\n";
814 BRepGProp::VolumeProperties(cut2, G);
815 di<<"CUT 2 Mass = "<<G.Mass()<< "\n" << "\n";
817 di << "Trianglating Faces of CUT 1 ....." << "\n";
818 performTriangulation(cut1, di);
820 di << "Trianglating Faces of CUT 2 ....." << "\n";
821 performTriangulation(cut2, di);
823 catch ( Standard_Failure )
825 di<<"*********************************************************"<< "\n";
826 di<<"***** ******"<< "\n";
827 di<<"***** Standard_Failure : Exception in HSP Function ******"<< "\n";
828 di<<"***** ******"<< "\n";
829 di<<"*********************************************************"<< "\n";
833 di<<"*************************************************************"<< "\n";
834 di<<" CUT 1 and CUT 2 gives entirely different results during"<< "\n";
835 di<<" mass computation and face triangulation, eventhough the"<< "\n";
836 di<<" two spheres are located more or less at the same position."<< "\n";
837 di<<"*************************************************************"<< "\n";
842 //=======================================================================
844 //=======================================================================
846 static Standard_Integer OCC826 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
848 if(argc < 4 || argc > 5) {
849 di << "Usage : " << argv[0] << " name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
852 Standard_Boolean IsBRepAlgoAPI = Standard_True;
854 Standard_Integer IsB = atoi(argv[4]);
856 IsBRepAlgoAPI = Standard_False;
857 #if ! defined(BRepAlgo_def01)
858 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
865 Standard_Real x1 = 181.82808;
866 Standard_Real x2 = 202.39390;
867 Standard_Real y1 = 31.011970;
868 Standard_Real y2 = 123.06856;
870 BRepBuilderAPI_MakePolygon W1;
871 W1.Add(gp_Pnt(x1, y1, 0));
872 W1.Add(gp_Pnt(x2, y1, 0));
873 W1.Add(gp_Pnt(x2, y2, 0));
874 W1.Add(gp_Pnt(x1, y2, 0));
875 W1.Add(gp_Pnt(x1, y1, 0));
877 Standard_Boolean myFalse = Standard_False;
878 TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), myFalse);
883 Standard_Real angle1 = 360 * PI180;
884 TopoDS_Shape rev = BRepPrimAPI_MakeRevol(F1, A1, angle1);
885 if (index < argc) DBRep::Set(argv[index++], rev);
887 BRepPrimAPI_MakeSphere sphere(gp_Pnt(166.373, 77.0402, 96.0555), 23.218586);
888 TopoDS_Shape sph = sphere.Shape();
889 if (index < argc) DBRep::Set(argv[index++], sph);
891 di << "All primitives created..... Creating Boolean" << "\n";
898 di << "fuse = BRepAlgoAPI_Fuse(rev, sph)" << "\n";
899 fuse = BRepAlgoAPI_Fuse(rev, sph);
901 di << "fuse = BRepAlgo_Fuse(rev, sph)" << "\n";
902 fuse = BRepAlgo_Fuse(rev, sph);
904 if (index < argc) DBRep::Set(argv[index++], fuse);
905 di << "Fuse Created ! Triangulating !" << "\n";
906 performTriangulation(fuse, di);
908 catch ( Standard_Failure )
910 di<<"*********************************************************"<< "\n";
911 di<<"***** ******"<< "\n";
912 di<<"***** Standard_Failure : Exception in SPH Function ******"<< "\n";
913 di<<"***** ******"<< "\n";
914 di<<"*********************************************************"<< "\n";
920 #include <BRepPrimAPI_MakeTorus.hxx>
921 //=======================================================================
923 //=======================================================================
925 static Standard_Integer OCC827 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
927 if(argc < 6 || argc > 7) {
928 di << "Usage : " << argv[0] << " name1 name2 name3 result1 result2 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
931 Standard_Boolean IsBRepAlgoAPI = Standard_True;
933 Standard_Integer IsB = atoi(argv[6]);
935 IsBRepAlgoAPI = Standard_False;
936 #if ! defined(BRepAlgo_def01)
937 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
944 BRepBuilderAPI_MakePolygon W1;
945 W1.Add(gp_Pnt(10, 0, 0));
946 W1.Add(gp_Pnt(20, 0, 0));
947 W1.Add(gp_Pnt(20, 0, 50));
948 W1.Add(gp_Pnt(10, 0, 50));
949 W1.Add(gp_Pnt(10, 0, 0));
951 Standard_Boolean myFalse = Standard_False;
952 TopoDS_Face F1 = BRepBuilderAPI_MakeFace(W1.Wire(), myFalse);
957 Standard_Real angle1 = 360 * PI180;
958 TopoDS_Shape rev = BRepPrimAPI_MakeRevol(F1, A1, angle1);
959 if (index < argc) DBRep::Set(argv[index++], rev);
964 Standard_Real majRad = 15;
965 Standard_Real minRad = 5;
966 BRepPrimAPI_MakeTorus Torus1(A2, majRad, minRad);
967 TopoDS_Shape tor1 = Torus1.Shape();
968 if (index < argc) DBRep::Set(argv[index++], tor1);
973 BRepPrimAPI_MakeTorus Torus2(A3, majRad, minRad);
974 TopoDS_Shape tor2 = Torus2.Shape();
975 if (index < argc) DBRep::Set(argv[index++], tor2);
977 di << "All primitives created..... Creating Boolean" << "\n";
979 TopoDS_Shape fuse1, fuse2;
984 di << "Fuse1 = BRepAlgoAPI_Fuse(tor1, rev)" << "\n";
985 fuse1 = BRepAlgoAPI_Fuse(tor1, rev);
987 di << "Fuse1 = BRepAlgo_Fuse(tor1, rev)" << "\n";
988 fuse1 = BRepAlgo_Fuse(tor1, rev);
990 if (index < argc) DBRep::Set(argv[index++], fuse1);
991 di << "Fuse1 Created ! Creating Fuse 2" << "\n";
993 di << "Fuse2 = BRepAlgoAPI_Fuse(tor2, fuse1)" << "\n";
994 fuse2 = BRepAlgoAPI_Fuse(tor2, fuse1);
996 di << "Fuse2 = BRepAlgo_Fuse(tor2, fuse1)" << "\n";
997 fuse2 = BRepAlgo_Fuse(tor2, fuse1);
999 if (index < argc) DBRep::Set(argv[index++], fuse2);
1000 di << "Fuse2 Created ! Triangulating !" << "\n";
1002 performTriangulation(fuse2, di);
1004 catch ( Standard_Failure )
1006 di<<"*********************************************************"<< "\n";
1007 di<<"***** ******"<< "\n";
1008 di<<"***** Standard_Failure : Exception in REV Function ******"<< "\n";
1009 di<<"***** ******"<< "\n";
1010 di<<"*********************************************************"<< "\n";
1016 //=======================================================================
1018 //=======================================================================
1020 int performBlend (TopoDS_Shape aShape, Standard_Real rad, TopoDS_Shape& bShape, Draw_Interpretor& di)
1022 Standard_Integer status = 0;
1023 TopoDS_Shape newShape;
1024 TopTools_IndexedDataMapOfShapeListOfShape edgemap;
1025 TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_SOLID,edgemap);
1026 di << "Blending All Edges: No. of Edges: " << edgemap.Extent() << "\n";
1027 ChFi3d_FilletShape FShape = ChFi3d_Rational;
1028 BRepFilletAPI_MakeFillet blend(aShape,FShape);
1029 for(int i = 1; i <= edgemap.Extent(); i++)
1031 TopoDS_Edge edg = TopoDS::Edge( edgemap.FindKey(i) );
1032 if(!edg.IsNull()) blend.Add(rad, edg);
1039 if(!blend.HasResult() || blend.Shape().IsNull()) {
1043 catch ( Standard_Failure )
1048 di<<"*******************************************************"<< "\n";
1049 di<<"****** *******"<< "\n";
1050 di<<"****** Blending Failed (Radius = " << rad << ") *******"<< "\n";
1051 di<<"****** *******"<< "\n";
1052 di<<"*******************************************************"<< "\n";
1055 di<<"Blending successfully performed on all Edges: "<< "\n" << "\n";
1057 bShape = blend.Shape();
1061 #include <GC_MakeSegment.hxx>
1062 //=======================================================================
1064 //=======================================================================
1066 static Standard_Integer OCC828 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv)
1069 di << "Usage : " << argv[0] << " shape" << "\n";
1073 Standard_Real slabThick = 111;
1075 gp_Pnt p11(-27.598139, -7.0408573, 0.0);
1076 gp_Pnt p12(-28.483755, -17.487625, 0.0);
1077 gp_Pnt p13(-19.555504, -22.983587, 0.0);
1078 GC_MakeArcOfCircle arc1(p11, p12, p13);
1080 gp_Pnt p21(12.125083, -22.983587, 0.0);
1081 gp_Pnt p22(21.1572, -17.27554, 0.0);
1082 gp_Pnt p23(19.878168, -6.6677585, 0.0);
1083 GC_MakeArcOfCircle arc2(p21, p22, p23);
1085 gp_Pnt p31(3.265825, 13.724955, 0.0);
1086 gp_Pnt p32(-4.7233953, 17.406338, 0.0);
1087 gp_Pnt p33(-12.529893, 13.351856, 0.0);
1088 GC_MakeArcOfCircle arc3(p31, p32, p33);
1090 GC_MakeSegment ln1(p13, p21);
1091 GC_MakeSegment ln2(p23, p31);
1092 GC_MakeSegment ln3(p33, p11);
1094 TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(arc1.Value());
1095 TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(arc2.Value());
1096 TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(arc3.Value());
1098 TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(ln1.Value());
1099 TopoDS_Edge e5 = BRepBuilderAPI_MakeEdge(ln2.Value());
1100 TopoDS_Edge e6 = BRepBuilderAPI_MakeEdge(ln3.Value());
1102 BRepBuilderAPI_MakeWire MW;
1112 di << "my Wire not done" << "\n";
1116 TopoDS_Wire W = MW.Wire();
1117 TopoDS_Face F = BRepBuilderAPI_MakeFace(W);
1120 di << " Error in Face creation " << "\n";
1127 gp_Dir slabDir(0, 0, 1);
1128 gp_Vec slabVect(slabDir);
1129 slabVect *= slabThick;
1131 BRepPrimAPI_MakePrism slab(F, slabVect, Standard_True);
1132 if ( ! slab.IsDone() )
1134 di << " Error in Slab creation " << "\n";
1137 if (index < argc) DBRep::Set(argv[index++], slab.Shape());
1139 // cout << "Slab Successfully Created ! Now Blending ..." << endl;
1140 // TopoDS_Shape aShape;
1141 // int ret = performBlend(slab.Shape(), radius, aShape);
1142 // if (ret) return 1;
1143 // if (index < argc) DBRep::Set(argv[index++], aShape);
1145 // cout << "Blending Successfully Done ! Now Triangulating ..." << endl;
1146 // performTriangulation(aShape);
1148 catch ( Standard_Failure )
1150 di << " Error in Draft Slab " << "\n";
1156 void QANIC::Commands(Draw_Interpretor& theCommands) {
1157 char *group = "QANIC";
1159 theCommands.Add ("OCC426", "OCC426 shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC426, group);
1161 theCommands.Add("isperiodic", "Use : isperiodic surfaceOfRevolution", __FILE__, isPeriodic, group);
1162 theCommands.Add("OCC486", "Use : OCC486 surf x y z du dv ", __FILE__, OCC486, group);
1163 theCommands.Add("OCC712", "OCC712 draftAngle slabThick", __FILE__, OCC712, group);
1164 theCommands.Add("OCC822_1", "OCC822_1 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC822_1, group);
1165 theCommands.Add("OCC822_2", "OCC822_2 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC822_2, group);
1166 theCommands.Add("OCC823", "OCC823 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC823, group);
1167 theCommands.Add("OCC824", "OCC824 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC824, group);
1168 theCommands.Add("OCC825", "OCC825 name1 name2 name3 name4 name5 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC825, group);
1169 theCommands.Add("OCC826", "OCC826 name1 name2 result [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC826, group);
1170 theCommands.Add("OCC827", "OCC827 name1 name2 name3 result1 result2 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__,OCC827, group);
1171 theCommands.Add("OCC828", "OCC828 redius shape result ", __FILE__,OCC828, group);