2 // Created: Mon Jun 17 10:49:11 2002
10 #include<Draw_Interpretor.hxx>
11 #include<TopLoc_Location.hxx>
12 #include<TopoDS_Face.hxx>
15 #include<Geom_Surface.hxx>
16 #include<BRep_Tool.hxx>
17 #include<GeomInt_IntSS.hxx>
18 #include<BRepBuilderAPI_MakeEdge.hxx>
19 #include <Standard_ErrorHandler.hxx>
22 static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
26 di << "Usage : " << a[0] << " result Shape1 Shape2" << "\n";
32 TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
33 TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
34 Handle(Geom_Surface) GSF1 = BRep_Tool::Surface(F1, L1);
35 Handle(Geom_Surface) GSF2 = BRep_Tool::Surface(F2, L2);
37 Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1));
38 if (!Inter.IsDone()) {
39 di << "Intersection not done" << "\n";
42 Standard_Integer nbsol = Inter.NbLines();
44 di << "The number of solutions is zero!" << "\n";
47 Handle(Geom_Curve) Sol = Inter.Line(1);
49 DBRep::Set(a[1], BRepBuilderAPI_MakeEdge(Sol));
51 } else di << "The first solution is Null!" << "\n";
57 #include<ViewerTest.hxx>
58 #include<AIS_InteractiveContext.hxx>
59 #include<AIS_Shape.hxx>
61 static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
65 di << "Usage : " << argv[0] << " shape" << "\n";
69 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
70 if(myAISContext.IsNull()) {
71 di << "use 'vinit' command before " << argv[0] << "\n";
75 TopoDS_Shape theShape = DBRep::Get(argv[1]);
77 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
78 myAISContext->Display( anAISShape, Standard_True );
79 myAISContext->OpenLocalContext();
80 myAISContext->ActivateStandardMode(TopAbs_FACE);
84 static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
88 di << "Usage : "<< argv[0] << " shape" << "\n";
94 TopoDS_Shape theShape = DBRep::Get(argv[1]);
96 // ViewerTest::GetAISContext();
97 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
98 if(myAISContext.IsNull()) {
99 di << "use 'vinit' command before " << argv[0] << "\n";
102 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
103 myAISContext->Display( anAISShape, Standard_True );
104 myAISContext->OpenLocalContext();
105 myAISContext->ActivateStandardMode(TopAbs_COMPOUND);
106 // myAISContext->ActivateStandardMode(TopAbs_SOLID);
108 // cout << "vfini" << endl;
112 #include<BRep_Builder.hxx>
113 #include<BRepTools_ShapeSet.hxx>
114 #include<BRepTools.hxx>
115 #include<BRepAdaptor_HSurface.hxx>
116 #include<TopOpeBRep_PointClassifier.hxx>
117 #include<Precision.hxx>
122 static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
129 printf("Usage: %s draw_format_face\n [name] [interactive (0|1)]",argv[0]);
134 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
135 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
137 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
140 Standard_Character *file1 = new Standard_Character [strlen(DD)+strlen(argv[1])+2];
141 sprintf(file1,"%s/%s",DD,argv[1]);
145 if (!fic.open(file1,ios::in)) {
146 di << "Cannot open file for reading : " << file1 << "\n";
151 TopoDS_Shape theShape;
155 if( !strcmp(typ, "DBRep_DrawableShape") ){
157 BRepTools_ShapeSet S(B);
161 di << "Wrong entity type in " << file1 << "\n";
167 const TopoDS_Face &face = TopoDS::Face (theShape);
170 DBRep::Set(argv[2],face);
173 Standard_Boolean inter=Standard_False ;
176 inter= (atof(argv[3]) == 0) ? Standard_False : Standard_True ;
179 Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
181 BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
183 di << "The bounds of the trimmed face:" << "\n";
184 di << faceUMin << " <= U <= " << faceUMax << "\n";
185 di << faceVMin << " <= V <= " << faceVMax << "\n";
187 Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
189 TopOpeBRep_PointClassifier PClass;
191 di << "Now test the point classifier by inputting U,V values" << "\n";
192 di << "inside or outside the bounds displayed above" << "\n";
193 di << "Type stop to exit" << "\n";
195 // Please register this:
196 // ***********************************************
197 // Note also that for periodic surfaces such as nimpod_1.topo,
198 // the U/V values may be +- 2pi compared to the actual face bounds
199 // (because U,V is probably coming from a Geom package routine).
200 // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
201 // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
202 // *************************************************
203 if(inter && (argc != 6)) {
205 di << "Input U: " << "\n";
211 di << "Input V: " << "\n";
218 uvSurf = gp_Pnt2d(U, V);
220 //gp_Pnt2d uvSurf(0.14,5.1); // outside!!!
221 //gp_Pnt2d uvSurf2(1.28,5.1); // inside
223 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
224 if(state == TopAbs_IN || state == TopAbs_ON){
225 di << "U=" << U << " V=" << V << " classified INSIDE" << "\n";
227 di << "U=" << U << " V=" << V << " classified OUTSIDE" << "\n";
232 uvSurf = gp_Pnt2d(0.14,5.1);
233 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
234 if(state == TopAbs_IN || state == TopAbs_ON){
235 di << "U=" << 0.14 << " V=" << 5.1 << " classified INSIDE" << "\n";
237 di << "U=" << 0.14 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
240 uvSurf = gp_Pnt2d(1.28,5.1);
241 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
242 if(state == TopAbs_IN || state == TopAbs_ON){
243 di << "U=" << 1.28 << " V=" << 5.1 << " classified INSIDE" << "\n";
245 di << "U=" << 1.28 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
248 uvSurf = gp_Pnt2d(atof(argv[4]),atof(argv[5]));
249 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
250 if(state == TopAbs_IN || state == TopAbs_ON){
251 di << "U=" << atof(argv[4]) << " V=" << atof(argv[5]) << " classified INSIDE" << "\n";
253 di << "U=" << atof(argv[4]) << " V=" << atof(argv[5]) << " classified OUTSIDE" << "\n";
261 void stringerror(int state)
263 printf("%s",((state&ios::eofbit) !=0)? " [eof]": "");
264 printf("%s",((state&ios::failbit)!=0)? " [fail]":"");
265 printf("%s",((state&ios::badbit) !=0)? " [bad]": "");
266 printf("%s\n",(state==ios::goodbit)? " [ok]": "");
271 //#include <strstream>
273 //#include <strstream.h>
279 #elif defined (HAVE_IOSTREAM_H)
280 #include <iostream.h>
281 #include <strstream.h>
283 #error "check config.h file or compilation options: either HAVE_IOSTREAM or HAVE_IOSTREAM_H should be defined"
285 static int UKI61075(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** /*argv*/) {
288 #ifndef USE_STL_STREAM
289 ostrstream stringout1(buffer1,sizeof(buffer1));
290 istrstream stringin1(buffer1,sizeof(buffer1));
292 ostringstream stringout1(buffer1);
293 istringstream stringin1(buffer1);
296 #ifndef USE_STL_STREAM
297 ostrstream stringout2(buffer2,sizeof(buffer2));
298 istrstream stringin2(buffer2,sizeof(buffer2));
300 ostringstream stringout2(buffer1);
301 istringstream stringin2(buffer1);
304 stringout1.precision(17);
305 stringout2.precision(17);
309 printf("Valeurs originales :\n\t%.17lg %.17lg\n",da,db);
311 stringout1<<da<<' '<<db<<"\n";
312 #ifndef USE_STL_STREAM
313 buffer1[stringout1.pcount()]='\0';
315 buffer1[stringout1.str().length()]= '\0' ;
318 printf("Valeurs ecrites dans le fichier :\n\t%s",buffer1);
322 printf("Valeurs relues :\n\t%.17lg %.17lg",da,db);
323 stringerror(stringin1.rdstate());
325 stringout2<<da<<' '<<db<<"\n";
326 #ifndef USE_STL_STREAM
327 buffer2[stringout2.pcount()]='\0';
329 buffer2[stringout2.str().length()]='\0';
332 printf("Valeurs reecrites :\n\t%s",buffer2);
336 printf("Valeurs relues a nouveau :\n\t%.17lg %.17lg",da,db);
337 stringerror(stringin2.rdstate());
343 #include<BRepAlgoAPI_Section.hxx>
344 #include<BRepAlgo_Section.hxx>
346 #include<Geom_Plane.hxx>
347 #include<DrawTrSurf.hxx>
349 //static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane]";
350 static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane] [BRepAlgoAPI/BRepAlgo = 1/0]";
352 static int BUC60585(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
355 // cerr << "Usage : " << argv[0] << St << endl;
358 if(argc < 2 || argc > 6) {
359 di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
362 Standard_Boolean IsBRepAlgoAPI = Standard_True;
364 Standard_Integer IsB = atoi(argv[5]);
366 IsBRepAlgoAPI = Standard_False;
367 #if ! defined(BRepAlgo_def04)
368 // di << "Error: There is not BRepAlgo_Section class" << "\n";
376 if(!strcmp(argv[1],"trimsphere")) {
377 //////////////////////////////////////////
378 // Uncomment for trimmed sphere bug:
379 // filename = "trimsphere.topo";
380 N=gp_Dir( 0.0, -1.0, 0.0 );
381 //////////////////////////////////////////
382 } else if(!strcmp(argv[1],"sphere")) {
384 //////////////////////////////////////////
385 // Uncomment for untrimmed sphere bug:
387 // filename="sphere.topo";
388 N=gp_Dir( 0.0, -0.75103523489975432, -0.66026212668838646 );
390 //////////////////////////////////////////
392 di << "Usage : " << argv[0] << St << "\n";
397 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
398 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
400 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
403 Standard_Character *filename = new Standard_Character [strlen(DD)+17];
404 sprintf(filename,"%s/%s.topo",DD,argv[1]);
408 if (!fic.open(filename,ios::in)) {
409 di << "Cannot open file for reading : " << filename << "\n";
417 BRepTools_ShapeSet S(B);
419 TopoDS_Shape theShape;
424 gp_Pnt O( 2036.25, -97.5, -1460.499755859375 );
425 gp_Dir A( 1.0, 0.0, 0.0 );
427 gp_Ax3 PLA( O, N, A );
430 // Perform the section
432 //#if ! defined(BRepAlgoAPI_def01)
433 // BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
435 // BRepAlgo_Section Sec( theShape, Pl, Standard_False);
442 // Sec.Approximation(Standard_True);
446 // cout << "Error performing intersection: not done." << endl;
453 di << "BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False)" <<"\n";
454 BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
457 di << "Error performing intersection: not done." << "\n";
463 di << "BRepAlgo_Section Sec( theShape, Pl, Standard_False)" <<"\n";
464 BRepAlgo_Section Sec( theShape, Pl, Standard_False);
467 di << "Error performing intersection: not done." << "\n";
474 }catch(Standard_Failure){
475 Handle(Standard_Failure) error = Standard_Failure::Caught();
476 di << "Error performing intersection: not done." << "\n";
481 if(argc>3) DBRep::Set(argv[3],theShape);
483 if(argc>2) DBRep::Set(argv[2],res);
486 Handle(Geom_Geometry) result;
487 Handle(Geom_Plane) C = new Geom_Plane(Pl);
489 DrawTrSurf::Set(argv[4],result);
492 di << "Done" << "\n";
499 #include<TopoDS_Compound.hxx>
501 static int BUC60547(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
503 di << "Usage : " << argv[0] << " name" << "\n";
507 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
508 if(myAISContext.IsNull()) {
509 di << "use 'vinit' command before " << argv[0] << "\n";
514 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
515 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
517 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
520 Standard_Character *Ch = new Standard_Character[strlen(argv[1])+3];
522 Standard_Character *FileName = new Standard_Character[strlen(DD)+13];
524 TopoDS_Shape free_1,free_2,free_3,free_4;
526 sprintf(FileName,"%s/%s",DD,"buc60547a.brep");
527 BRepTools::Read(free_1,FileName,B);
528 sprintf(FileName,"%s/%s",DD,"buc60547b.brep");
529 BRepTools::Read(free_2,FileName,B);
530 sprintf(FileName,"%s/%s",DD,"buc60547c.brep");
531 BRepTools::Read(free_3,FileName,B);
532 sprintf(FileName,"%s/%s",DD,"buc60547d.brep");
533 BRepTools::Read(free_4,FileName,B);
534 sprintf(Ch,"%s_%i",argv[1],1);
535 DBRep::Set(Ch,free_1);
537 sprintf(Ch,"%s_%i",argv[1],2);
538 DBRep::Set(Ch,free_2);
540 sprintf(Ch,"%s_%i",argv[1],3);
541 DBRep::Set(Ch,free_3);
543 sprintf(Ch,"%s_%i",argv[1],4);
544 DBRep::Set(Ch,free_4);
547 // Handle(AIS_Shape) S1 = new AIS_Shape(free_1);
548 // Handle(AIS_Shape) S2 = new AIS_Shape(free_2);
549 // Handle(AIS_Shape) S3 = new AIS_Shape(free_3);
550 // Handle(AIS_Shape) S4 = new AIS_Shape(free_4);
552 // Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
554 // myAISContext->Display(S1);
555 // myAISContext->Display(S2);
556 // myAISContext->Display(S3);
557 // myAISContext->Display(S4);
563 bui.MakeCompound(Com);
569 sprintf(Ch,"%s_%c",argv[1],'c');
573 Handle(AIS_Shape) SC = new AIS_Shape(Com);
574 myAISContext->Display(SC); // nothing on the screen If I save the compound :
576 sprintf(FileName,"%s/%s",DD,"free.brep");
578 BRepTools::Write(Com,FileName);
586 #include<BRepBuilderAPI_MakeVertex.hxx>
587 #include<TCollection_ExtendedString.hxx>
588 #include<AIS_LengthDimension.hxx>
590 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
593 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
594 if(myAIScontext.IsNull()) {
595 di << "use 'vinit' command before " << a[0] << "\n";
598 myAIScontext->EraseAll();
600 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
601 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
603 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
604 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
606 myAIScontext->Display(Ve1);
607 myAIScontext->Display(Ve2);
609 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
610 TCollection_ExtendedString Ext1("Dim1");
611 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1,atof(a[2]),Ext1);
613 myAIScontext->SetDisplayMode(Dim1, atof(a[1]));
614 myAIScontext->Display(Dim1);
618 #include<TopoDS_Wire.hxx>
620 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
623 di << "Usage : BUC60652 fase" << "\n";
626 TopoDS_Shape shape = DBRep::Get( argv[1] );
627 TopoDS_Face face = TopoDS::Face( shape );
628 TopoDS_Wire ow = BRepTools::OuterWire( face );
629 DBRep::Set( "w", ow );
633 #include <BRepAlgo_BooleanOperations.hxx>
635 static Standard_Integer defNbPntMax = 30;
636 static Standard_Real defTol3d = 1.e-7;
637 static Standard_Real defTol2d = 1.e-7;
638 static Standard_Boolean defRelativeTol=Standard_True;
639 Standard_Integer NbPntMax = defNbPntMax;
640 Standard_Real Toler3d =defTol3d;
641 Standard_Real Toler2d = defTol2d;
642 Standard_Boolean RelativeTol= defRelativeTol;
643 // //== // ksection : operateur section appelant BRepAlgo_BooleanOperation
644 //== // ksection : operateur section appelant BRepAlgo_BooleanOperations
645 //=======================================================================
646 Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) {
648 di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol" << "\n";
658 TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL);
659 TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL);
660 if (s1.IsNull() || s2.IsNull()) return 1;
664 RelativeTol=atoi(a[7]);
666 di << "BRepAlgo_BooleanOperations myalgo" << "\n";
667 BRepAlgo_BooleanOperations myalgo;
669 myalgo.Shapes(s1, s2);
670 myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d,RelativeTol);
671 TopoDS_Shape res; res = myalgo.Section();
672 DBRep::Set(a[1],res);
676 #include <Geom_Axis2Placement.hxx>
677 #include <AIS_Trihedron.hxx>
679 static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
682 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
683 if(myAISContext.IsNull()) {
684 di << "use 'vinit' command before " << a[0] << "\n";
688 Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY());
689 Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis);
692 aTrsf.SetTranslation(trans);
693 TopLoc_Location aLoc(aTrsf);
694 myAISContext->SetLocation(atri,aLoc);
695 myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
696 myAISContext->OpenLocalContext(Standard_False,
697 Standard_True,Standard_False,Standard_False);
698 myAISContext->Load(atri,3,Standard_True);
703 #include <TopoDS_Solid.hxx>
704 #include <BRepPrimAPI_MakeBox.hxx>
705 #include <BRepPrimAPI_MakeSphere.hxx>
707 #include <BRepAlgoAPI_Fuse.hxx>
708 #include <BRepAlgo_Fuse.hxx>
710 #include <V3d_Plane.hxx>
711 #include <V3d_View.hxx>
712 #include <gce_MakePln.hxx>
714 static Standard_Integer BUC60698(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
717 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
720 Standard_Boolean IsBRepAlgoAPI = Standard_True;
722 Standard_Integer IsB = atoi(a[1]);
724 IsBRepAlgoAPI = Standard_False;
725 #if ! defined(BRepAlgo_def01)
726 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
732 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
733 if(myAISContext.IsNull()) {
734 di << "use 'vinit' command before " << a[0] << "\n";
737 TopoDS_Solid box = BRepPrimAPI_MakeBox(1,1,1).Solid();
738 TopoDS_Shape sphere = BRepPrimAPI_MakeSphere(gp_Pnt(0.5,0.5,0.5),0.6).Shape();
740 //#if ! defined(BRepAlgoAPI_def01)
741 // TopoDS_Shape fuse = BRepAlgoAPI_Fuse(box,sphere).Shape();
743 // TopoDS_Shape fuse = BRepAlgo_Fuse(box,sphere).Shape();
748 di << "fuse = BRepAlgoAPI_Fuse(box,sphere).Shape()" <<"\n";
749 fuse = BRepAlgoAPI_Fuse(box,sphere).Shape();
751 di << "fuse = BRepAlgo_Fuse(box,sphere).Shape()" <<"\n";
752 fuse = BRepAlgo_Fuse(box,sphere).Shape();
755 Handle_AIS_Shape theAISShape = new AIS_Shape(fuse);
756 myAISContext->Display(theAISShape);
758 gp_Pln thegpPln = gce_MakePln(gp_Pnt(0.5,0.5,0.5),gp_Dir(0,0,1));
759 Standard_Real A,B,C,D;
760 thegpPln.Coefficients(A,B,C,D);
761 Handle_V3d_Plane thePlane = new V3d_Plane(myAISContext->CurrentViewer(),A,B,C,D);
762 for (myAISContext->CurrentViewer()->InitActiveViews();
763 myAISContext->CurrentViewer()->MoreActiveViews ();
764 myAISContext->CurrentViewer()->NextActiveViews ()) {
767 myAISContext->CurrentViewer()->ActiveView()->SetPlaneOn(thePlane);
769 catch(Standard_Failure) {
770 di << "SetPlaneOn catched 1" << "\n";
774 di << "SetPlaneOn catched 1" << "\n";
778 for (myAISContext->CurrentViewer()->InitDefinedViews();
779 myAISContext->CurrentViewer()->MoreDefinedViews ();
780 myAISContext->CurrentViewer()->NextDefinedViews ()) {
783 myAISContext->CurrentViewer()->DefinedView()->SetPlaneOn(thePlane);
785 catch(Standard_Failure) {
786 di << "SetPlaneOn catched 1" << "\n";
790 di << "SetPlaneOn catched 2" << "\n";
794 myAISContext->UpdateCurrentViewer();
795 myAISContext->OpenLocalContext();
796 myAISContext->ActivateStandardMode(TopAbs_FACE);
800 static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
803 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
804 if(myAISContext.IsNull()) {
805 di << "use 'vinit' command before " << a[0] << "\n";
808 TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid();
809 TopAbs_ShapeEnum theType = B1.ShapeType();
810 if ( theType == TopAbs_SOLID ) {
811 di << "It is a solid." << "\n";
813 di << "It is not solid." << "\n";
815 myAISContext->Display(new AIS_Shape(B1));
816 myAISContext->OpenLocalContext();
817 TopAbs_ShapeEnum amode = TopAbs_SOLID;
818 myAISContext->ActivateStandardMode(amode);
820 di.Eval("QAMoveTo 200 200");
821 di.Eval("QASelect 200 200");
822 myAISContext->InitSelected() ;
823 if ( myAISContext->MoreSelected() ) {
824 if (myAISContext->HasSelectedShape() ) {
825 di << "has selected shape : OK" << "\n";
827 di << "has selected shape : bugged - Faulty " << "\n";
833 static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
836 di << "Usage : " << argv[0] << " [1/0]" << "\n";
840 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
841 if(myAIScontext.IsNull()) {
842 di << "use 'vinit' command before " << argv[0] << "\n";
845 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
847 if((argc == 2) && (atof(argv[1]) == 0))
848 myV3dView->SetAntialiasingOff();
850 myV3dView->SetAntialiasingOn();
856 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
858 //=======================================================================
859 //function : GetColorFromName
860 //purpose : get the Quantity_NameOfColor from a string
861 //=======================================================================
863 static Quantity_NameOfColor GetColorFromName( const char *name )
865 Quantity_NameOfColor ret = DEFAULT_COLOR;
867 Standard_Boolean Found = Standard_False;
868 Standard_CString colstring;
869 for(Standard_Integer i=0;i<=514 && !Found;i++)
871 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
872 if (!strcasecmp(name,colstring)) {
873 ret = (Quantity_NameOfColor)i;
874 Found = Standard_True;
881 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
884 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
885 if(myAISContext.IsNull()) {
886 di << "use 'vinit' command before " << argv[0] << "\n";
890 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
896 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
898 // Change the background color of the view with a predefined name Graphic3d_NOC_<name>
900 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
901 myV3dView -> Redraw();
907 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
908 // setcolor <object> <name>
909 // Change the object color with a predefined name
911 TopoDS_Shape aShape = DBRep::Get(argv[1]);
912 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
913 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
914 myAISContext->Display(myShape,Standard_True);
915 myAISContext->UpdateCurrentViewer();
921 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
923 // setcolor <r> <g> <b>
924 // Change the background color of the view with the color values <r>,<g>,<b>
925 // A color value must be defined in the space [0.,1.]
927 Standard_Real QuantityOfRed = atoi(argv[1]);
928 Standard_Real QuantityOfGreen = atoi(argv[2]);
929 Standard_Real QuantityOfBlue = atoi(argv[3]);
930 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
937 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
939 // setcolor <object> <r> <g> <b>
940 // change the object color with RGB values.
943 Standard_Real QuantityOfRed = atof(argv[2]);
944 Standard_Real QuantityOfGreen = atof(argv[3]);
945 Standard_Real QuantityOfBlue = atof(argv[4]);
947 TopoDS_Shape aShape = DBRep::Get(argv[1]);
948 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
949 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
950 myAISContext->Display(myShape,Standard_True);
951 myAISContext->UpdateCurrentViewer();
952 // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
953 // myShape->Redisplay();
960 static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
962 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
963 if(myAISContext.IsNull()) {
964 di << "use 'vinit' command before " << argv[0] << "\n";
969 di << "Usage : " << argv[0] << " 0/1" << "\n";
972 if(atoi(argv[1]) == 0) {
973 myAISContext->CloseAllContexts();
974 BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.);
975 Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());
976 myAISContext->Display(aBox);
977 } else if(atoi(argv[1]) == 1) {
978 myAISContext->CloseAllContexts();
979 myAISContext->OpenLocalContext();
980 myAISContext->ActivateStandardMode(TopAbs_EDGE);
981 } else if(atoi(argv[1]) == 2) {
982 myAISContext->CloseAllContexts();
983 myAISContext->OpenLocalContext();
984 myAISContext->ActivateStandardMode(TopAbs_FACE);
986 di << "Usage : " << argv[0] << " 0/1" << "\n";
993 #include <BRepBndLib.hxx>
994 #include <Bnd_HArray1OfBox.hxx>
996 static Standard_Integer BUC60729 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** /*argv*/ )
999 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
1001 BRepBndLib::Add(aShape , aMainBox );
1003 Standard_Integer siMaxNbrBox = 6;
1004 Bnd_BoundSortBox m_BoundSortBox;
1005 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
1006 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
1010 // Bnd_Box __emptyBox; // Box is void !
1011 // Handle_Bnd_HArray1OfBox __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
1013 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
1015 const TopoDS_Shape& aFace = aExplorer.Current();
1017 BRepBndLib::Add( aFace, aBox );
1018 m_BoundSortBox.Add( aBox, i );
1019 // __aSetOfBox->SetValue( i, aBox );
1021 // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
1026 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
1028 TCollection_AsciiString as1("");
1029 TCollection_AsciiString as2('\0');
1030 if((as1.ToCString()!=NULL) || (as1.ToCString() != ""))
1031 di << "Faulty : the first string is not zero string : " << as1.ToCString() << "\n";
1033 if((as2.ToCString()!=NULL) || (as2.ToCString() != ""))
1034 di << "Faulty : the second string is not zero string : " << as2.ToCString() << "\n";
1039 #include <UnitsAPI.hxx>
1041 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
1043 di <<"Program Test" << "\n";
1044 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
1045 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
1050 #include <gp_Circ.hxx>
1051 #include <Geom_Circle.hxx>
1052 #include <GeomAPI.hxx>
1053 #include <Geom2d_CartesianPoint.hxx>
1054 #include <Geom2dGcc_QualifiedCurve.hxx>
1055 #include <Geom2dGcc_Circ2d2TanRad.hxx>
1056 #include <Geom2d_Circle.hxx>
1057 #include <ProjLib.hxx>
1059 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1061 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1062 if(aContext.IsNull()) {
1063 di << "use 'vinit' command before " << argv[0] << "\n";
1067 gp_Pnt pt3d(0, 20, 150);
1068 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
1069 gp_Circ circ(anAx2, 50.0);
1070 Handle_Geom_Circle gcir = new Geom_Circle(circ);
1071 Handle_Geom_Plane pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
1072 Handle_Geom2d_Curve gcir1 = GeomAPI::To2d(gcir, pln->Pln());
1073 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
1074 Handle_AIS_Shape ais1 = new AIS_Shape(sh1);
1075 aContext->SetColor(ais1, Quantity_NOC_INDIANRED);
1076 aContext->Display(ais1);
1077 DBRep::Set("sh0",sh1);
1079 // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
1080 thepoint = ProjLib::Project(pln->Pln(),pt3d);
1081 Handle_Geom2d_CartesianPoint ThePoint = new Geom2d_CartesianPoint(thepoint);
1082 Geom2dAdaptor_Curve acur1(gcir1) ;
1083 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
1084 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
1085 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
1086 Handle_Geom2d_Circle gccc;
1087 if( cirtanrad.NbSolutions() ) {
1088 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
1089 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
1090 gccc = new Geom2d_Circle(ccc);
1091 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
1092 Standard_Character aStr[5];
1093 sprintf(aStr,"sh%d",i);
1094 DBRep::Set(aStr,sh);
1095 Handle_AIS_Shape ais = new AIS_Shape(sh);
1097 aContext->SetColor(ais, Quantity_NOC_GREEN);
1099 aContext->SetColor(ais, Quantity_NOC_HOTPINK);
1100 aContext->Display(ais);
1101 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
1102 gp_Pnt2d PntSol1, PntSol2;
1103 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
1104 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
1105 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
1106 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
1112 #include <TColgp_Array2OfPnt.hxx>
1113 #include <Geom_BezierSurface.hxx>
1114 #include <BRepBuilderAPI_MakeFace.hxx>
1115 #include <BRepBuilderAPI_MakeWire.hxx>
1116 #include <Geom_OffsetSurface.hxx>
1117 #include <BRepFilletAPI_MakeFillet2d.hxx>
1118 #include <GeomProjLib.hxx>
1119 #include <Geom_TrimmedCurve.hxx>
1121 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1125 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
1126 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
1127 Standard_Real f = 0.0, l = 0.0;
1128 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
1129 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
1130 GC = new Geom_TrimmedCurve(GC, f, l);
1131 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
1132 BRepBuilderAPI_MakeWire *myWire;
1133 myWire = new BRepBuilderAPI_MakeWire();
1134 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
1135 DBRep::Set(argv[1],myWire->Wire());
1139 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1140 if(aContext.IsNull()) {
1141 di << "use 'vinit' command before " << argv[0] << "\n";
1145 //step 1. creating a Bezier Surface and a patch
1149 Handle(AIS_Shape) ais1;
1150 Handle_AIS_Shape ais2;
1151 Handle(Geom_BezierSurface) BZ1;
1152 TColgp_Array2OfPnt array1(1,3,1,3);
1153 array1.SetValue(1,1,gp_Pnt(0,100,0));
1154 array1.SetValue(1,2,gp_Pnt(200,100,0));
1155 array1.SetValue(1,3,gp_Pnt(400,100,0));
1156 array1.SetValue(2,1,gp_Pnt(0,200,100));
1157 array1.SetValue(2,2,gp_Pnt(200,200,100));
1158 array1.SetValue(2,3,gp_Pnt(400,200,100));
1159 array1.SetValue(3,1,gp_Pnt(0,300,0));
1160 array1.SetValue(3,2,gp_Pnt(200,300,0));
1161 array1.SetValue(3,3,gp_Pnt(400,300,0));
1162 BZ1 = new Geom_BezierSurface(array1);
1163 BRepBuilderAPI_MakeFace bzf1( BZ1 );
1164 TopoDS_Face F1= bzf1.Face();
1165 ais1 = new AIS_Shape(F1);
1166 DBRep::Set("F1",F1);
1167 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
1168 aContext->Display(ais1);
1175 gp_Dir D(0, 0, 1.0f);
1176 BRepBuilderAPI_MakeWire mkw;
1177 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
1178 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
1179 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
1181 p1 = gp_Pnt(350., 150., 260.);
1182 p2 = gp_Pnt(350., 250., 260.);
1183 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
1185 p1 = gp_Pnt(350., 250., 260.);
1186 p2 = gp_Pnt(300., 250.0, 260.);
1187 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
1189 p1 = gp_Pnt(300., 250.0, 260.);
1190 p2 = gp_Pnt(200., 200.0, 260.);
1191 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
1193 p1 = gp_Pnt(200., 200.0, 260.);
1194 p2 = gp_Pnt(150., 200.0, 260.);
1195 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
1197 p1 = gp_Pnt(150., 200.0, 260.);
1198 p2 = gp_Pnt(150., 150.0, 260.);
1199 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
1201 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
1202 ais2 = new AIS_Shape( FP );
1203 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
1204 aContext->Display( ais2 );
1206 DBRep::Set("FP",FP);
1208 //step 2. offseting the surface.
1209 Handle_Geom_OffsetSurface offsurf;
1210 offsurf = new Geom_OffsetSurface(BZ1, -100);
1211 BRepBuilderAPI_MakeFace bzf2( offsurf );
1212 TopoDS_Face F2= bzf2.Face();
1213 Handle_AIS_Shape ais22 = new AIS_Shape(F2);
1214 aContext->Display(ais22);
1215 DBRep::Set("F2",F2);
1217 //step 3. filleting the patch.
1218 //( I want to project wire of this patch on offseted surface above)
1219 BRepFilletAPI_MakeFillet2d fillet( FP );
1221 Ex.Init(FP, TopAbs_VERTEX);
1222 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
1223 fillet.AddFillet(v1, 20);
1224 printf("\nError is %d ", fillet.Status());
1226 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
1227 fillet.AddFillet(V2, 20);
1228 printf("\nError is %d ", fillet.Status());
1230 FP1 = fillet.Shape();
1231 ais2 = new AIS_Shape( FP1 );
1232 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
1233 aContext->Display( ais2 );
1235 DBRep::Set("FP1",FP1);
1237 //step 4. Projecting the wire of this patch on offsetted surface.
1238 // TopExp_Explorer Ex;
1239 BRepBuilderAPI_MakeWire *myWire;
1240 myWire = new BRepBuilderAPI_MakeWire();
1241 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
1243 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
1244 Standard_Real f = 0.0, l = 0.0;
1245 Handle_Geom_Curve newBSplin = BRep_Tool::Curve(e1, f, l);
1246 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
1247 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
1248 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
1250 Handle_AIS_Shape ais33 = new AIS_Shape( myWire->Wire() );
1251 aContext->Display(ais33);
1253 DBRep::Set("Wire",myWire->Wire());
1258 #include<GeomAPI_ExtremaCurveCurve.hxx>
1260 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1264 printf("Usage: %s edge1 edge2",argv[0]);
1268 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
1269 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
1271 Standard_Real fp , lp;
1273 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
1274 C2 = BRep_Tool::Curve(E2 , fp , lp);
1276 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
1278 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
1283 #include <BRepBuilderAPI_MakePolygon.hxx>
1284 #include <BRepOffsetAPI_ThruSections.hxx>
1286 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1289 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1292 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1294 Standard_Integer IsB = atoi(argv[1]);
1296 IsBRepAlgoAPI = Standard_False;
1297 #if ! defined(BRepAlgo_def01)
1298 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1304 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
1305 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
1306 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
1307 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
1308 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
1310 for (int i=0;i<4;i++) {
1311 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
1312 bottompolygon1.Add(tmppnt);
1313 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
1314 toppolygon1.Add(tmppnt);
1315 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
1316 bottompolygon2.Add(tmppnt);
1317 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
1318 toppolygon2.Add(tmppnt);
1320 bottompolygon1.Close();
1321 DBRep::Set("B1",bottompolygon1.Shape());
1322 toppolygon1.Close();
1323 DBRep::Set("T1",toppolygon1.Shape());
1324 bottompolygon2.Close();
1325 DBRep::Set("B2",bottompolygon2.Shape());
1326 toppolygon2.Close();
1327 DBRep::Set("T2",toppolygon2.Shape());
1328 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
1329 loft1.AddWire(bottompolygon1.Wire());
1330 loft1.AddWire(toppolygon1.Wire());
1332 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
1333 loft2.AddWire(bottompolygon2.Wire());
1334 loft2.AddWire(toppolygon2.Wire());
1336 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
1338 DBRep::Set("TS1",loft1.Shape());
1339 DBRep::Set("TS2",loft2.Shape());
1341 //#if ! defined(BRepAlgoAPI_def01)
1342 // BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1344 // BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1346 if (IsBRepAlgoAPI) {
1347 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1348 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1349 DBRep::Set("F",result.Shape());
1351 di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1352 BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1353 DBRep::Set("F",result.Shape());
1356 // DBRep::Set("F",result.Shape());
1360 #include <Geom_RectangularTrimmedSurface.hxx>
1361 #include <GC_MakeTrimmedCone.hxx>
1363 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1365 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1366 if(aContext.IsNull()) {
1367 di << "use 'vinit' command before " << argv[0] << "\n";
1372 double R1=8, R2=16, H1=20, H2=40, angle;
1374 P1(0,0,20), P2(0,0,45);
1376 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
1377 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S).Shape();
1378 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
1379 aContext->Display(ais1);
1380 aContext->SetColor(ais1, Quantity_NOC_BLUE1);
1382 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
1383 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2).Shape();
1384 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
1385 aContext->Display(ais2);
1386 aContext->SetColor(ais2, Quantity_NOC_RED);
1391 //#include <fstream.h>
1394 #elif defined (HAVE_FSTREAM_H)
1395 # include <fstream.h>
1397 //#include <Standard_Stream.hxx>
1398 //==========================================================================
1399 //function : CoordLoad
1400 // chargement d une face dans l explorer.
1401 //==========================================================================
1402 static Standard_Integer coordload (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1407 TopoDS_Vertex V1,V2;
1412 if (argc < 3) return 1;
1414 ifstream file(argv[2], ios::in);
1417 di<<"unable to open "<<argv[2]<<" for input"<<"\n";
1420 BRepBuilderAPI_MakeWire WB;
1422 file.getline(line,80);
1423 for(int i=0;i<30;i++) X[i]=Y[i]=0;
1424 fr = sscanf(line,"%20c%20c",&X,&Y);
1425 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1429 file.getline(line,80);
1431 for(int i=0;i<30;i++) X[i]=Y[i]=0;
1432 fr = sscanf(line,"%20c%20c",&X,&Y);
1433 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1434 Edge = BRepBuilderAPI_MakeEdge(V1,V2);
1440 if (WB.IsDone()) Wire = WB.Wire();
1441 Face = BRepBuilderAPI_MakeFace(Wire);
1443 DBRep::Set (argv[1],Face);
1448 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
1449 Standard_Integer /*nb*/,
1450 const char ** /*arg*/)
1452 TCollection_ExtendedString aString(1024*1024, 'A');
1456 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
1457 Standard_Integer argc,
1460 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1461 if(aContext.IsNull()) {
1462 di << "use 'vinit' command before " << argv[0] << "\n";
1465 if((argc != 2) && (argc != 3)) {
1466 di<< "usage : " << argv[0] << " shape [mode==1]" << "\n";
1469 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1470 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
1471 // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
1472 anIO->SetHilightMode((argc == 3) ? atoi(argv[2]) : 1);
1473 aContext->Display(anIO);
1477 //=======================================================================
1478 //function : buc60773
1480 //=======================================================================
1482 #include<TCollection_HAsciiString.hxx>
1484 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
1486 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
1487 Standard_CString aStr = hAscii->ToCString();
1488 TCollection_AsciiString aAscii(aStr);
1493 #include<BRepPrimAPI_MakeCylinder.hxx>
1494 #include<BRepPrimAPI_MakeCone.hxx>
1496 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1500 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1503 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1505 Standard_Integer IsB = atoi(argv[1]);
1507 IsBRepAlgoAPI = Standard_False;
1508 #if ! defined(BRepAlgo_def01)
1509 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1515 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
1517 Standard_Real x11 = 36.085182;
1518 Standard_Real y11 = 20.0;
1519 Standard_Real z11 = 8.431413;
1520 Standard_Real x12 = 88.04671;
1521 Standard_Real y12 = 20.0;
1522 Standard_Real z12 = 38.931416;
1523 Standard_Real radius = 10.0;
1525 gp_Pnt base1(x11, y11, z11);
1526 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
1527 gp_Ax2 axis1(base1, vect1);
1528 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
1529 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
1531 TopoDS_Shape SCyl = cylinder.Shape();
1532 DBRep::Set("cyl", SCyl);
1535 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
1536 Standard_Real x21 = 70.7262;
1537 Standard_Real y21 = 20.0;
1538 Standard_Real z21 = 28.431412;
1539 Standard_Real x22 = 105.36722;
1540 Standard_Real y22 = 20.0;
1541 Standard_Real z22 = 48.431416;
1542 Standard_Real radius1 = 6.0;
1543 Standard_Real radius2 = 3.0;
1545 gp_Pnt base2(x21, y21, z21);
1546 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
1547 gp_Ax2 axis2(base2, vect2);
1548 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
1549 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1551 TopoDS_Shape SCon = cone.Shape();
1552 DBRep::Set("con", SCon);
1554 //#if ! defined(BRepAlgoAPI_def01)
1555 // BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1557 // BRepAlgo_Fuse SFuse(SCyl, SCon);
1560 // if(! SFuse.IsDone() )
1561 // cout<<"Error: Boolean fuse operation failed !"<<endl;
1563 // TopoDS_Shape fuse = SFuse.Shape();
1566 if (IsBRepAlgoAPI) {
1567 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n";
1568 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1569 if(! SFuse.IsDone() )
1570 di<<"Error: Boolean fuse operation failed !"<<"\n";
1571 fuse = SFuse.Shape();
1573 di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n";
1574 BRepAlgo_Fuse SFuse(SCyl, SCon);
1575 if(! SFuse.IsDone() )
1576 di<<"Error: Boolean fuse operation failed !"<<"\n";
1577 fuse = SFuse.Shape();
1580 DBRep::Set("fus", fuse);
1585 #include <Dico_DictionaryOfInteger.hxx>
1586 #include <TColStd_HSequenceOfAsciiString.hxx>
1587 #include <TopExp.hxx>
1588 #include <TopoDS_Iterator.hxx>
1590 //---------------------------------------------------------------------------------------
1592 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1595 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1598 di<<"Invalid input shape"<<"\n";
1601 Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
1602 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1603 Standard_CString aString;
1604 Standard_Integer i=1,j=1,k=1,l=1,aa=1;
1605 TopExp_Explorer expl;
1606 Standard_Real f3d,l3d;
1607 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1610 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1611 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1612 aString = aSurface->DynamicType()->Name();
1614 if(aDico->GetItem(aString,aa) != 0)
1616 aDico->GetItem(aString,aa);
1617 aDico->SetItem(aString,aa+1);
1619 aDico->SetItem(aString,1);
1620 aSequence->Append(aString);
1626 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1628 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1629 TopoDS_Iterator anIt(aFace);
1630 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1631 TopoDS_Iterator it (aWire);
1632 for (; it.More(); it.Next()) {
1633 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1634 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1635 aString = aCurve2d->DynamicType()->Name();
1636 if(aDico->GetItem(aString,aa) != 0)
1638 aDico->GetItem(aString,aa);
1639 aDico->SetItem(aString,aa+1);
1641 aDico->SetItem(aString,1);
1642 aSequence->Append(aString);
1649 TopExp_Explorer exp;
1650 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
1652 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1653 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1654 if(aCurve3d.IsNull())
1659 aString = aCurve3d->DynamicType()->Name();
1660 if(aDico->GetItem(aString,aa) != 0)
1662 aDico->GetItem(aString,aa);
1663 aDico->SetItem(aString,aa+1);
1665 aDico->SetItem(aString,1);
1666 aSequence->Append(aString);
1676 aDico->GetItem(aSequence->Value(j),aa);
1677 di<<aa<<" -- "<<aSequence->Value(j).ToCString()<<"\n";
1681 di<<"Degenerated edges :"<<"\n";
1682 di<<l<<" -- "<<"Degenerated edges "<<"\n";
1688 #include <BRepBuilderAPI_Transform.hxx>
1690 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1693 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1696 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1698 Standard_Integer IsB = atoi(argv[1]);
1700 IsBRepAlgoAPI = Standard_False;
1701 #if ! defined(BRepAlgo_def01)
1702 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1708 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1709 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1710 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1712 TopoDS_Shape sh1 = cyl.Shape();
1713 DBRep::Set("sh1",sh1);
1714 gp_Trsf trsf1, trsf2;
1715 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1716 gp_Pnt(0.000000,700.000000,-95.000000));
1717 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1718 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1719 BRepBuilderAPI_Transform trans1(sh1, trsf1);
1720 TopoDS_Shape sh2 = trans1.Shape();
1721 DBRep::Set("sh2",sh2);
1723 //#if ! defined(BRepAlgoAPI_def01)
1724 // BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1726 // BRepAlgo_Fuse fuse1(sh1, sh2);
1729 // TopoDS_Shape fsh1 = fuse1.Shape();
1732 if (IsBRepAlgoAPI) {
1733 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n";
1734 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1735 fsh1 = fuse1.Shape();
1737 di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n";
1738 BRepAlgo_Fuse fuse1(sh1, sh2);
1739 fsh1 = fuse1.Shape();
1742 DBRep::Set("fsh1",fsh1);
1743 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1744 TopoDS_Shape sh3 = trans2.Shape();
1745 DBRep::Set("sh3",sh3);
1747 //#if ! defined(BRepAlgoAPI_def01)
1748 // BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1750 // BRepAlgo_Fuse fuse2(fsh1,sh3);
1753 // TopoDS_Shape fsh2 = fuse2.Shape();
1756 if (IsBRepAlgoAPI) {
1757 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n";
1758 BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1759 fsh2 = fuse2.Shape();
1761 di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n";
1762 BRepAlgo_Fuse fuse2(fsh1,sh3);
1763 fsh2 = fuse2.Shape();
1766 DBRep::Set("fsh2",fsh2);
1767 Handle_AIS_Shape aisp1 = new AIS_Shape(fsh2);
1768 // aContext->Display(aisp1);
1772 #include <ShapeBuild_Edge.hxx>
1774 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1776 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1777 ShapeBuild_Edge().BuildCurve3d(e);
1783 #include<TDF_Label.hxx>
1784 #include<TDataStd_TreeNode.hxx>
1786 #include<DDocStd.hxx>
1790 #include<TDocStd_Modified.hxx>
1791 #include<TDF_ListIteratorOfDeltaList.hxx>
1792 #include<TDocStd_Document.hxx>
1793 #include<TDocStd_Application.hxx>
1794 #include<TDF_Delta.hxx>
1795 #include<TDataXtd_Constraint.hxx>
1796 #include<TPrsStd_AISPresentation.hxx>
1797 #include<TPrsStd_AISViewer.hxx>
1798 #include<TNaming_Builder.hxx>
1799 #include<TNaming_Naming.hxx>
1800 #include<TNaming_NamedShape.hxx>
1802 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1804 di << "Usage : " << argv[0] << " D" << "\n";
1809 Handle(TDF_Data) DF;
1810 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1813 Handle(TDataStd_TreeNode) TN1,TN2;
1815 DDF::AddLabel(DF,"0:2",L1);
1816 TN1 = TDataStd_TreeNode::Set(L1);
1818 DDF::AddLabel(DF,"0:3",L2);
1819 TN2 = TDataStd_TreeNode::Set(L2);
1822 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1823 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1829 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1831 di << "Usage : " << argv[0] << " D" << "\n";
1836 Handle(TDF_Data) DF;
1837 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1840 DDF::FindLabel(DF,"0:1",L,Standard_False);
1841 Handle(TDocStd_Modified) MDF;
1842 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1843 MDF = new TDocStd_Modified();
1844 L.Root().AddAttribute(MDF);
1847 di<<!MDF->IsEmpty();
1851 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1853 di << "Usage : " << argv[0] << " D Label" << "\n";
1858 Handle(TDF_Data) DF;
1859 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1862 DDF::FindLabel(DF,argv[2],L,Standard_False);
1864 TDocStd_Modified::Add(L);
1870 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1872 di << "Usage : " << argv[0] << " D" << "\n";
1878 Handle(TDF_Data) aDF;
1879 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1881 Handle(TDocStd_Document) aDocument;
1882 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1885 Handle(TDataStd_TreeNode) TN;
1887 aDocument->NewCommand();
1888 DDF::AddLabel(aDF,"0:2",L);
1889 TN = TDataStd_TreeNode::Set(L);
1891 aDocument->NewCommand();
1892 DDF::AddLabel(aDF,"0:3",L);
1893 TN = TDataStd_TreeNode::Set(L);
1895 aDocument->NewCommand();
1896 DDF::AddLabel(aDF,"0:4",L);
1897 TN = TDataStd_TreeNode::Set(L);
1898 aDocument->NewCommand();
1900 TDF_DeltaList Us,Rs;
1901 Us = aDocument->GetUndos();
1902 Rs = aDocument->GetUndos();
1905 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1907 TDF_ListIteratorOfDeltaList IDL;
1908 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1909 Handle(TDF_Delta) D = IDL.Value();
1910 TCollection_ExtendedString S(Names[i-1]);
1912 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1918 Us = aDocument->GetUndos();
1919 Rs = aDocument->GetRedos();
1921 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1922 Handle(TDF_Delta) D = IDL.Value();
1923 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1926 TCollection_ExtendedString n2name ("n2");
1927 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1928 Handle(TDF_Delta) D = IDL.Value();
1929 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1940 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1942 di << "Usage : " << argv[0] << " D Shape" << "\n";
1947 Handle(TDF_Data) aDF;
1948 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1950 TopoDS_Shape s = DBRep::Get(argv[2]);
1951 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1953 DDF::AddLabel(aDF, "0:2", L);
1954 TNaming_Builder SI (L);
1957 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1961 // if (!NS->IsEmpty()) {di<<3;return 0;}
1962 if (NS->IsEmpty()) {di<<4;return 0;}
1967 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1969 di << "Usage : " << argv[0] << " D Shape" << "\n";
1974 Handle(TDF_Data) aDF;
1975 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1977 TopoDS_Shape s = DBRep::Get(argv[2]);
1978 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1980 DDF::AddLabel(aDF, "0:2", L);
1981 TNaming_Builder SI (L);
1984 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1988 if (NS->IsEmpty()) {di<<4;return 0;}
1993 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1995 TCollection_ExtendedString path (argv[1]);
1996 Handle(TDocStd_Application) A;
1997 if (!DDocStd::Find(A)) {di<<1;return 0;}
1998 Handle(TDocStd_Document) D;
1999 Standard_Integer insession = A->IsInSession(path);
2000 if (insession > 0) {
2001 di <<"document " << insession << " is already in session" << "\n";
2005 CDF_RetrievableStatus Result = A->Open(path,D);
2006 if(Result==CDF_RS_OK){
2015 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2017 di << "Usage : " << argv[0] << " D" << "\n";
2022 Handle(TDF_Data) aDF;
2023 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2026 DDF::AddLabel(aDF, "0:2", L);
2028 Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation;
2030 AISP->Set(L,TDataXtd_Constraint::GetID());
2032 if (AISP->HasOwnMode()) {di<<3;return 0;}
2034 Standard_Integer Mode = AISP->Mode();
2035 if (Mode!=3) {di<<4;return 0;}
2036 if (!AISP->HasOwnMode()) {di<<5;return 0;}
2038 if (AISP->HasOwnMode()) {di<<6;return 0;}
2043 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2045 di << "Usage : " << argv[0] << " D" << "\n";
2050 Handle(TDF_Data) aDF;
2051 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2054 DDF::AddLabel(aDF, "0:2", L);
2058 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
2059 // Handle(TNaming_Name) NN = new TNaming_Name;
2062 NN.Type(TNaming_IDENTITY);
2064 Standard_Boolean Res = NN.Solve(L,LM);
2066 if (Res!=Standard_False) {di<<3;return 0;}
2071 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2073 di << "Usage : " << argv[0] << " D" << "\n";
2079 Handle(TDocStd_Document) aDocument;
2080 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
2082 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
2083 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
2089 //=======================================================================
2090 //function : AISWidth
2091 //purpose : AISWidth (DOC,entry,[width])
2092 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
2093 //=======================================================================
2095 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2098 Handle(TDocStd_Document) D;
2099 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
2101 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
2103 Handle(TPrsStd_AISViewer) viewer;
2104 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
2106 Handle(TPrsStd_AISPresentation) prs;
2107 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2109 prs->SetWidth(atof(argv[3]));
2110 TPrsStd_AISViewer::Update(L);
2113 if (prs->HasOwnWidth()){
2114 // cout << "Width = " << prs->Width() << endl;
2118 di << "AISWidth: Warning : Width wasn't set" << "\n";
2125 di << "AISWidth : Error" << "\n";
2130 //=======================================================================
2131 //function : BUC60921 ( & BUC60954 )
2132 //purpose : Test memory allocation of OCAF in Undo/Redo operations
2133 //=======================================================================
2135 static Standard_Integer BUC60921 (Draw_Interpretor& di,
2136 Standard_Integer nb,
2140 Handle(TDocStd_Document) D;
2141 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
2143 DDF::AddLabel(D->GetData(),arg[2],L);
2147 BRepTools::Read ( S, arg[3], B );
2149 TNaming_Builder tnBuild(L);
2150 tnBuild.Generated(S);
2151 // di << "File " << arg[3] << " added";
2155 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
2160 #include<IGESControl_Reader.hxx>
2161 #include<BRepPrimAPI_MakeHalfSpace.hxx>
2163 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
2167 // cerr << "Usage : " << a[0] << " file.igs" << endl;
2170 if(argc < 2 || argc > 3) {
2171 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2174 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2176 Standard_Integer IsB = atoi(a[2]);
2178 IsBRepAlgoAPI = Standard_False;
2179 #if ! defined(BRepAlgo_def01)
2180 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
2186 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
2188 if(myContext.IsNull()) {
2189 di << "use 'vinit' command before " << a[0] << "\n";
2193 // IGESControlStd_Reader reader;
2194 IGESControl_Reader reader;
2195 reader.ReadFile(a[1]);
2196 reader.TransferRoots();
2197 TopoDS_Shape shape = reader.OneShape();
2198 printf("\n iges1 shape type = %d", shape.ShapeType() );
2199 TopTools_IndexedMapOfShape list;
2200 TopExp::MapShapes(shape, TopAbs_FACE, list);
2201 printf("\n No. of faces = %d", list.Extent());
2204 BRep_Builder builder;
2205 builder.MakeShell(shell);
2206 for(int i=1;i<=list.Extent(); i++) {
2207 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
2208 builder.Add(shell, face);
2211 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
2212 TopoDS_Solid sol = half.Solid();
2213 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
2214 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
2215 TopoDS_Shape sh = cyl.Shape();
2217 //#if ! defined(BRepAlgoAPI_def01)
2218 // BRepAlgoAPI_Fuse fuse(sol, sh);
2220 // BRepAlgo_Fuse fuse(sol, sh);
2223 // sh = fuse.Shape();
2225 if (IsBRepAlgoAPI) {
2226 di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n";
2227 BRepAlgoAPI_Fuse fuse(sol, sh);
2230 di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n";
2231 BRepAlgo_Fuse fuse(sol, sh);
2235 Handle(AIS_Shape) res = new AIS_Shape(sh);
2236 myContext->Display( res );
2240 void QABUC::Commands(Draw_Interpretor& theCommands) {
2241 const char *group = "QABUC";
2243 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
2244 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
2245 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
2246 theCommands.Add("BUC60609","BUC60609 shape [name] [interactive (0|1)]",__FILE__,BUC60609,group);
2248 theCommands.Add("UKI61075","UKI61075",__FILE__,UKI61075,group);
2250 theCommands.Add("BUC60585",St,__FILE__,BUC60585,group);
2251 theCommands.Add("BUC60547","BUC60547 name",__FILE__,BUC60547,group);
2252 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
2253 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
2254 theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2255 theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2256 theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2257 theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2258 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
2260 theCommands.Add("BUC60698","BUC60698 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60698,group);
2262 theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
2263 theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
2264 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
2265 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
2267 theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
2268 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
2269 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
2270 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
2271 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
2272 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
2274 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
2276 theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
2278 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
2281 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
2284 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
2285 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
2286 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
2287 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
2289 theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
2291 theCommands.Add("statface","statface face",__FILE__,statface,group);
2293 theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
2295 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
2297 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
2298 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
2299 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
2300 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
2301 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
2302 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
2303 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
2304 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
2305 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
2306 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
2307 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
2308 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
2310 theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );