1 // Created on: 2002-06-17
2 // Created by: QA Admin
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
25 #include<Draw_Interpretor.hxx>
26 #include<TopLoc_Location.hxx>
27 #include<TopoDS_Face.hxx>
30 #include<Geom_Surface.hxx>
31 #include<BRep_Tool.hxx>
32 #include<GeomInt_IntSS.hxx>
33 #include<BRepBuilderAPI_MakeEdge.hxx>
34 #include <Standard_ErrorHandler.hxx>
37 static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
41 di << "Usage : " << a[0] << " result Shape1 Shape2" << "\n";
47 TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
48 TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
49 Handle(Geom_Surface) GSF1 = BRep_Tool::Surface(F1, L1);
50 Handle(Geom_Surface) GSF2 = BRep_Tool::Surface(F2, L2);
52 Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1));
53 if (!Inter.IsDone()) {
54 di << "Intersection not done" << "\n";
57 Standard_Integer nbsol = Inter.NbLines();
59 di << "The number of solutions is zero!" << "\n";
62 Handle(Geom_Curve) Sol = Inter.Line(1);
64 DBRep::Set(a[1], BRepBuilderAPI_MakeEdge(Sol));
66 } else di << "The first solution is Null!" << "\n";
72 #include<ViewerTest.hxx>
73 #include<AIS_InteractiveContext.hxx>
74 #include<AIS_Shape.hxx>
76 static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
80 di << "Usage : " << argv[0] << " shape" << "\n";
84 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
85 if(myAISContext.IsNull()) {
86 di << "use 'vinit' command before " << argv[0] << "\n";
90 TopoDS_Shape theShape = DBRep::Get(argv[1]);
92 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
93 myAISContext->Display( anAISShape, Standard_True );
94 myAISContext->OpenLocalContext();
95 myAISContext->ActivateStandardMode(TopAbs_FACE);
99 static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
103 di << "Usage : "<< argv[0] << " shape" << "\n";
109 TopoDS_Shape theShape = DBRep::Get(argv[1]);
111 // ViewerTest::GetAISContext();
112 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
113 if(myAISContext.IsNull()) {
114 di << "use 'vinit' command before " << argv[0] << "\n";
117 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
118 myAISContext->Display( anAISShape, Standard_True );
119 myAISContext->OpenLocalContext();
120 myAISContext->ActivateStandardMode(TopAbs_COMPOUND);
121 // myAISContext->ActivateStandardMode(TopAbs_SOLID);
123 // cout << "vfini" << endl;
127 #include<BRep_Builder.hxx>
128 #include<BRepTools_ShapeSet.hxx>
129 #include<BRepTools.hxx>
130 #include<BRepAdaptor_HSurface.hxx>
131 #include<TopOpeBRep_PointClassifier.hxx>
132 #include<Precision.hxx>
137 static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
142 // BUC60609 shape name
143 } else if ( argc == 5 ) {
144 // BUC60609 shape name U V
146 di << "Usage : "<< argv[0] << " shape name [U V]" << "\n";
150 TCollection_AsciiString aFilePath(argv[1]);
154 if (!fic.open(aFilePath.ToCString(),ios::in)) {
155 di << "Cannot open file for reading : " << aFilePath << "\n";
159 TopoDS_Shape theShape;
163 if( !strcmp(typ, "DBRep_DrawableShape") ){
165 BRepTools_ShapeSet S(B);
169 di << "Wrong entity type in " << aFilePath << "\n";
174 const TopoDS_Face &face = TopoDS::Face (theShape);
177 DBRep::Set(argv[2],face);
180 Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
182 BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
184 di << "The bounds of the trimmed face:" << "\n";
185 di << faceUMin << " <= U <= " << faceUMax << "\n";
186 di << faceVMin << " <= V <= " << faceVMax << "\n";
188 Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
190 TopOpeBRep_PointClassifier PClass;
192 di << "Now test the point classifier by inputting U,V values" << "\n";
193 di << "inside or outside the bounds displayed above" << "\n";
194 di << "Type stop to exit" << "\n";
196 // Please register this:
197 // ***********************************************
198 // Note also that for periodic surfaces such as nimpod_1.topo,
199 // the U/V values may be +- 2pi compared to the actual face bounds
200 // (because U,V is probably coming from a Geom package routine).
201 // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
202 // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
203 // *************************************************
206 uvSurf = gp_Pnt2d(0.14,5.1);
207 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
208 if(state == TopAbs_IN || state == TopAbs_ON){
209 di << "U=" << 0.14 << " V=" << 5.1 << " classified INSIDE" << "\n";
211 di << "U=" << 0.14 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
214 uvSurf = gp_Pnt2d(1.28,5.1);
215 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
216 if(state == TopAbs_IN || state == TopAbs_ON){
217 di << "U=" << 1.28 << " V=" << 5.1 << " classified INSIDE" << "\n";
219 di << "U=" << 1.28 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
222 uvSurf = gp_Pnt2d(atof(argv[3]),atof(argv[4]));
223 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
224 if(state == TopAbs_IN || state == TopAbs_ON){
225 di << "U=" << atof(argv[3]) << " V=" << atof(argv[4]) << " classified INSIDE" << "\n";
227 di << "U=" << atof(argv[3]) << " V=" << atof(argv[4]) << " classified OUTSIDE" << "\n";
235 void stringerror(int state)
237 printf("%s",((state&ios::eofbit) !=0)? " [eof]": "");
238 printf("%s",((state&ios::failbit)!=0)? " [fail]":"");
239 printf("%s",((state&ios::badbit) !=0)? " [bad]": "");
240 printf("%s\n",(state==ios::goodbit)? " [ok]": "");
245 //#include <strstream>
247 //#include <strstream.h>
253 #elif defined (HAVE_IOSTREAM_H)
254 #include <iostream.h>
255 #include <strstream.h>
257 #error "check config.h file or compilation options: either HAVE_IOSTREAM or HAVE_IOSTREAM_H should be defined"
259 static int UKI61075(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** /*argv*/) {
262 #ifndef USE_STL_STREAM
263 ostrstream stringout1(buffer1,sizeof(buffer1));
264 istrstream stringin1(buffer1,sizeof(buffer1));
266 ostringstream stringout1(buffer1);
267 istringstream stringin1(buffer1);
270 #ifndef USE_STL_STREAM
271 ostrstream stringout2(buffer2,sizeof(buffer2));
272 istrstream stringin2(buffer2,sizeof(buffer2));
274 ostringstream stringout2(buffer1);
275 istringstream stringin2(buffer1);
278 stringout1.precision(17);
279 stringout2.precision(17);
283 printf("Valeurs originales :\n\t%.17lg %.17lg\n",da,db);
285 stringout1<<da<<' '<<db<<"\n";
286 #ifndef USE_STL_STREAM
287 buffer1[stringout1.pcount()]='\0';
289 buffer1[stringout1.str().length()]= '\0' ;
292 printf("Valeurs ecrites dans le fichier :\n\t%s",buffer1);
296 printf("Valeurs relues :\n\t%.17lg %.17lg",da,db);
297 stringerror(stringin1.rdstate());
299 stringout2<<da<<' '<<db<<"\n";
300 #ifndef USE_STL_STREAM
301 buffer2[stringout2.pcount()]='\0';
303 buffer2[stringout2.str().length()]='\0';
306 printf("Valeurs reecrites :\n\t%s",buffer2);
310 printf("Valeurs relues a nouveau :\n\t%.17lg %.17lg",da,db);
311 stringerror(stringin2.rdstate());
317 #include<BRepAlgoAPI_Section.hxx>
318 #include<BRepAlgo_Section.hxx>
320 #include<Geom_Plane.hxx>
321 #include<DrawTrSurf.hxx>
323 //static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane]";
324 static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane] [BRepAlgoAPI/BRepAlgo = 1/0]";
326 static int BUC60585(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
329 // cerr << "Usage : " << argv[0] << St << endl;
332 if(argc < 2 || argc > 6) {
333 di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
336 Standard_Boolean IsBRepAlgoAPI = Standard_True;
338 Standard_Integer IsB = atoi(argv[5]);
340 IsBRepAlgoAPI = Standard_False;
341 #if ! defined(BRepAlgo_def04)
342 // di << "Error: There is not BRepAlgo_Section class" << "\n";
350 if(!strcmp(argv[1],"trimsphere")) {
351 //////////////////////////////////////////
352 // Uncomment for trimmed sphere bug:
353 // filename = "trimsphere.topo";
354 N=gp_Dir( 0.0, -1.0, 0.0 );
355 //////////////////////////////////////////
356 } else if(!strcmp(argv[1],"sphere")) {
358 //////////////////////////////////////////
359 // Uncomment for untrimmed sphere bug:
361 // filename="sphere.topo";
362 N=gp_Dir( 0.0, -0.75103523489975432, -0.66026212668838646 );
364 //////////////////////////////////////////
366 di << "Usage : " << argv[0] << St << "\n";
371 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
372 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
374 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
377 Standard_Character *filename = new Standard_Character [strlen(DD)+17];
378 sprintf(filename,"%s/%s.topo",DD,argv[1]);
382 if (!fic.open(filename,ios::in)) {
383 di << "Cannot open file for reading : " << filename << "\n";
391 BRepTools_ShapeSet S(B);
393 TopoDS_Shape theShape;
398 gp_Pnt O( 2036.25, -97.5, -1460.499755859375 );
399 gp_Dir A( 1.0, 0.0, 0.0 );
401 gp_Ax3 PLA( O, N, A );
404 // Perform the section
406 //#if ! defined(BRepAlgoAPI_def01)
407 // BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
409 // BRepAlgo_Section Sec( theShape, Pl, Standard_False);
416 // Sec.Approximation(Standard_True);
420 // cout << "Error performing intersection: not done." << endl;
427 di << "BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False)" <<"\n";
428 BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
431 di << "Error performing intersection: not done." << "\n";
437 di << "BRepAlgo_Section Sec( theShape, Pl, Standard_False)" <<"\n";
438 BRepAlgo_Section Sec( theShape, Pl, Standard_False);
441 di << "Error performing intersection: not done." << "\n";
448 }catch(Standard_Failure){
449 Handle(Standard_Failure) error = Standard_Failure::Caught();
450 di << "Error performing intersection: not done." << "\n";
455 if(argc>3) DBRep::Set(argv[3],theShape);
457 if(argc>2) DBRep::Set(argv[2],res);
460 Handle(Geom_Geometry) result;
461 Handle(Geom_Plane) C = new Geom_Plane(Pl);
463 DrawTrSurf::Set(argv[4],result);
466 di << "Done" << "\n";
473 #include<TopoDS_Compound.hxx>
475 static int BUC60547(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
477 di << "Usage : " << argv[0] << " name" << "\n";
481 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
482 if(myAISContext.IsNull()) {
483 di << "use 'vinit' command before " << argv[0] << "\n";
488 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
489 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
491 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
494 Standard_Character *Ch = new Standard_Character[strlen(argv[1])+3];
496 Standard_Character *FileName = new Standard_Character[strlen(DD)+13];
498 TopoDS_Shape free_1,free_2,free_3,free_4;
500 sprintf(FileName,"%s/%s",DD,"buc60547a.brep");
501 BRepTools::Read(free_1,FileName,B);
502 sprintf(FileName,"%s/%s",DD,"buc60547b.brep");
503 BRepTools::Read(free_2,FileName,B);
504 sprintf(FileName,"%s/%s",DD,"buc60547c.brep");
505 BRepTools::Read(free_3,FileName,B);
506 sprintf(FileName,"%s/%s",DD,"buc60547d.brep");
507 BRepTools::Read(free_4,FileName,B);
508 sprintf(Ch,"%s_%i",argv[1],1);
509 DBRep::Set(Ch,free_1);
511 sprintf(Ch,"%s_%i",argv[1],2);
512 DBRep::Set(Ch,free_2);
514 sprintf(Ch,"%s_%i",argv[1],3);
515 DBRep::Set(Ch,free_3);
517 sprintf(Ch,"%s_%i",argv[1],4);
518 DBRep::Set(Ch,free_4);
521 // Handle(AIS_Shape) S1 = new AIS_Shape(free_1);
522 // Handle(AIS_Shape) S2 = new AIS_Shape(free_2);
523 // Handle(AIS_Shape) S3 = new AIS_Shape(free_3);
524 // Handle(AIS_Shape) S4 = new AIS_Shape(free_4);
526 // Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
528 // myAISContext->Display(S1);
529 // myAISContext->Display(S2);
530 // myAISContext->Display(S3);
531 // myAISContext->Display(S4);
537 bui.MakeCompound(Com);
543 sprintf(Ch,"%s_%c",argv[1],'c');
547 Handle(AIS_Shape) SC = new AIS_Shape(Com);
548 myAISContext->Display(SC); // nothing on the screen If I save the compound :
550 sprintf(FileName,"%s/%s",DD,"free.brep");
552 BRepTools::Write(Com,FileName);
560 #include<BRepBuilderAPI_MakeVertex.hxx>
561 #include<TCollection_ExtendedString.hxx>
562 #include<AIS_LengthDimension.hxx>
564 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
567 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
568 if(myAIScontext.IsNull()) {
569 di << "use 'vinit' command before " << a[0] << "\n";
572 myAIScontext->EraseAll();
574 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
575 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
577 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
578 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
580 myAIScontext->Display(Ve1);
581 myAIScontext->Display(Ve2);
583 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
584 TCollection_ExtendedString Ext1("Dim1");
585 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1,atof(a[2]),Ext1);
587 myAIScontext->SetDisplayMode(Dim1, atoi(a[1]));
588 myAIScontext->Display(Dim1);
592 #include<TopoDS_Wire.hxx>
594 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
597 di << "Usage : BUC60652 fase" << "\n";
600 TopoDS_Shape shape = DBRep::Get( argv[1] );
601 TopoDS_Face face = TopoDS::Face( shape );
602 TopoDS_Wire ow = BRepTools::OuterWire( face );
603 DBRep::Set( "w", ow );
607 #include <BRepAlgo_BooleanOperations.hxx>
609 static Standard_Integer defNbPntMax = 30;
610 static Standard_Real defTol3d = 1.e-7;
611 static Standard_Real defTol2d = 1.e-7;
612 static Standard_Boolean defRelativeTol=Standard_True;
613 Standard_Integer NbPntMax = defNbPntMax;
614 Standard_Real Toler3d =defTol3d;
615 Standard_Real Toler2d = defTol2d;
616 Standard_Boolean RelativeTol= defRelativeTol;
617 // //== // ksection : operateur section appelant BRepAlgo_BooleanOperation
618 //== // ksection : operateur section appelant BRepAlgo_BooleanOperations
619 //=======================================================================
620 Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) {
622 di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol" << "\n";
632 TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL);
633 TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL);
634 if (s1.IsNull() || s2.IsNull()) return 1;
638 RelativeTol=atoi(a[7]);
640 di << "BRepAlgo_BooleanOperations myalgo" << "\n";
641 BRepAlgo_BooleanOperations myalgo;
643 myalgo.Shapes(s1, s2);
644 myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d,RelativeTol);
645 TopoDS_Shape res; res = myalgo.Section();
646 DBRep::Set(a[1],res);
650 #include <Geom_Axis2Placement.hxx>
651 #include <AIS_Trihedron.hxx>
653 static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
656 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
657 if(myAISContext.IsNull()) {
658 di << "use 'vinit' command before " << a[0] << "\n";
662 Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY());
663 Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis);
666 aTrsf.SetTranslation(trans);
667 TopLoc_Location aLoc(aTrsf);
668 myAISContext->SetLocation(atri,aLoc);
669 myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
670 myAISContext->OpenLocalContext(Standard_False,
671 Standard_True,Standard_False,Standard_False);
672 myAISContext->Load(atri,3,Standard_True);
677 #include <TopoDS_Solid.hxx>
678 #include <BRepPrimAPI_MakeBox.hxx>
679 #include <BRepPrimAPI_MakeSphere.hxx>
681 #include <BRepAlgoAPI_Fuse.hxx>
682 #include <BRepAlgo_Fuse.hxx>
684 #include <V3d_Plane.hxx>
685 #include <V3d_View.hxx>
686 #include <gce_MakePln.hxx>
688 static Standard_Integer BUC60698(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
691 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
694 Standard_Boolean IsBRepAlgoAPI = Standard_True;
696 Standard_Integer IsB = atoi(a[1]);
698 IsBRepAlgoAPI = Standard_False;
699 #if ! defined(BRepAlgo_def01)
700 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
706 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
707 if(myAISContext.IsNull()) {
708 di << "use 'vinit' command before " << a[0] << "\n";
711 TopoDS_Solid box = BRepPrimAPI_MakeBox(1,1,1).Solid();
712 TopoDS_Shape sphere = BRepPrimAPI_MakeSphere(gp_Pnt(0.5,0.5,0.5),0.6).Shape();
714 //#if ! defined(BRepAlgoAPI_def01)
715 // TopoDS_Shape fuse = BRepAlgoAPI_Fuse(box,sphere).Shape();
717 // TopoDS_Shape fuse = BRepAlgo_Fuse(box,sphere).Shape();
722 di << "fuse = BRepAlgoAPI_Fuse(box,sphere).Shape()" <<"\n";
723 fuse = BRepAlgoAPI_Fuse(box,sphere).Shape();
725 di << "fuse = BRepAlgo_Fuse(box,sphere).Shape()" <<"\n";
726 fuse = BRepAlgo_Fuse(box,sphere).Shape();
729 Handle_AIS_Shape theAISShape = new AIS_Shape(fuse);
730 myAISContext->Display(theAISShape);
732 gp_Pln thegpPln = gce_MakePln(gp_Pnt(0.5,0.5,0.5),gp_Dir(0,0,1));
733 Standard_Real A,B,C,D;
734 thegpPln.Coefficients(A,B,C,D);
735 Handle_V3d_Plane thePlane = new V3d_Plane(A,B,C,D);
736 myAISContext->CurrentViewer()->AddPlane (thePlane); // add to defined planes list
737 for (myAISContext->CurrentViewer()->InitActiveViews();
738 myAISContext->CurrentViewer()->MoreActiveViews ();
739 myAISContext->CurrentViewer()->NextActiveViews ()) {
742 myAISContext->CurrentViewer()->ActiveView()->SetPlaneOn(thePlane);
744 catch(Standard_Failure) {
745 di << "SetPlaneOn catched 1" << "\n";
749 di << "SetPlaneOn catched 1" << "\n";
753 for (myAISContext->CurrentViewer()->InitDefinedViews();
754 myAISContext->CurrentViewer()->MoreDefinedViews ();
755 myAISContext->CurrentViewer()->NextDefinedViews ()) {
758 myAISContext->CurrentViewer()->DefinedView()->SetPlaneOn(thePlane);
760 catch(Standard_Failure) {
761 di << "SetPlaneOn catched 1" << "\n";
765 di << "SetPlaneOn catched 2" << "\n";
769 myAISContext->UpdateCurrentViewer();
770 myAISContext->OpenLocalContext();
771 myAISContext->ActivateStandardMode(TopAbs_FACE);
775 static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
778 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
779 if(myAISContext.IsNull()) {
780 di << "use 'vinit' command before " << a[0] << "\n";
783 TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid();
784 TopAbs_ShapeEnum theType = B1.ShapeType();
785 if ( theType == TopAbs_SOLID ) {
786 di << "It is a solid." << "\n";
788 di << "It is not solid." << "\n";
790 myAISContext->Display(new AIS_Shape(B1));
791 myAISContext->OpenLocalContext();
792 TopAbs_ShapeEnum amode = TopAbs_SOLID;
793 myAISContext->ActivateStandardMode(amode);
795 di.Eval("QAMoveTo 200 200");
796 di.Eval("QASelect 200 200");
797 myAISContext->InitSelected() ;
798 if ( myAISContext->MoreSelected() ) {
799 if (myAISContext->HasSelectedShape() ) {
800 di << "has selected shape : OK" << "\n";
802 di << "has selected shape : bugged - Faulty " << "\n";
808 static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
811 di << "Usage : " << argv[0] << " [1/0]" << "\n";
815 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
816 if(myAIScontext.IsNull()) {
817 di << "use 'vinit' command before " << argv[0] << "\n";
820 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
822 if((argc == 2) && (atof(argv[1]) == 0))
823 myV3dView->SetAntialiasingOff();
825 myV3dView->SetAntialiasingOn();
831 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
833 //=======================================================================
834 //function : GetColorFromName
835 //purpose : get the Quantity_NameOfColor from a string
836 //=======================================================================
838 static Quantity_NameOfColor GetColorFromName( const char *name )
840 Quantity_NameOfColor ret = DEFAULT_COLOR;
842 Standard_Boolean Found = Standard_False;
843 Standard_CString colstring;
844 for(Standard_Integer i=0;i<=514 && !Found;i++)
846 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
847 if (!strcasecmp(name,colstring)) {
848 ret = (Quantity_NameOfColor)i;
849 Found = Standard_True;
856 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
859 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
860 if(myAISContext.IsNull()) {
861 di << "use 'vinit' command before " << argv[0] << "\n";
865 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
871 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
873 // Change the background color of the view with a predefined name Graphic3d_NOC_<name>
875 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
876 myV3dView -> Redraw();
882 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
883 // setcolor <object> <name>
884 // Change the object color with a predefined name
886 TopoDS_Shape aShape = DBRep::Get(argv[1]);
887 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
888 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
889 myAISContext->Display(myShape,Standard_True);
890 myAISContext->UpdateCurrentViewer();
896 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
898 // setcolor <r> <g> <b>
899 // Change the background color of the view with the color values <r>,<g>,<b>
900 // A color value must be defined in the space [0.,1.]
902 Standard_Real QuantityOfRed = atoi(argv[1]);
903 Standard_Real QuantityOfGreen = atoi(argv[2]);
904 Standard_Real QuantityOfBlue = atoi(argv[3]);
905 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
912 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
914 // setcolor <object> <r> <g> <b>
915 // change the object color with RGB values.
918 Standard_Real QuantityOfRed = atof(argv[2]);
919 Standard_Real QuantityOfGreen = atof(argv[3]);
920 Standard_Real QuantityOfBlue = atof(argv[4]);
922 TopoDS_Shape aShape = DBRep::Get(argv[1]);
923 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
924 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
925 myAISContext->Display(myShape,Standard_True);
926 myAISContext->UpdateCurrentViewer();
927 // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
928 // myShape->Redisplay();
935 static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
937 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
938 if(myAISContext.IsNull()) {
939 di << "use 'vinit' command before " << argv[0] << "\n";
944 di << "Usage : " << argv[0] << " 0/1" << "\n";
947 if(atoi(argv[1]) == 0) {
948 myAISContext->CloseAllContexts();
949 BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.);
950 Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());
951 myAISContext->Display(aBox);
952 } else if(atoi(argv[1]) == 1) {
953 myAISContext->CloseAllContexts();
954 myAISContext->OpenLocalContext();
955 myAISContext->ActivateStandardMode(TopAbs_EDGE);
956 } else if(atoi(argv[1]) == 2) {
957 myAISContext->CloseAllContexts();
958 myAISContext->OpenLocalContext();
959 myAISContext->ActivateStandardMode(TopAbs_FACE);
961 di << "Usage : " << argv[0] << " 0/1" << "\n";
968 #include <BRepBndLib.hxx>
969 #include <Bnd_HArray1OfBox.hxx>
971 static Standard_Integer BUC60729 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** /*argv*/ )
974 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
976 BRepBndLib::Add(aShape , aMainBox );
978 Standard_Integer siMaxNbrBox = 6;
979 Bnd_BoundSortBox m_BoundSortBox;
980 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
981 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
985 // Bnd_Box __emptyBox; // Box is void !
986 // Handle_Bnd_HArray1OfBox __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
988 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
990 const TopoDS_Shape& aFace = aExplorer.Current();
992 BRepBndLib::Add( aFace, aBox );
993 m_BoundSortBox.Add( aBox, i );
994 // __aSetOfBox->SetValue( i, aBox );
996 // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
1001 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
1003 TCollection_AsciiString as1("");
1004 TCollection_AsciiString as2('\0');
1005 if((as1.ToCString()!=NULL) || (as1.ToCString() != ""))
1006 di << "Faulty : the first string is not zero string : " << as1.ToCString() << "\n";
1008 if((as2.ToCString()!=NULL) || (as2.ToCString() != ""))
1009 di << "Faulty : the second string is not zero string : " << as2.ToCString() << "\n";
1014 #include <UnitsAPI.hxx>
1016 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
1018 di <<"Program Test" << "\n";
1019 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
1020 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
1025 #include <gp_Circ.hxx>
1026 #include <Geom_Circle.hxx>
1027 #include <GeomAPI.hxx>
1028 #include <Geom2d_CartesianPoint.hxx>
1029 #include <Geom2dGcc_QualifiedCurve.hxx>
1030 #include <Geom2dGcc_Circ2d2TanRad.hxx>
1031 #include <Geom2d_Circle.hxx>
1032 #include <ProjLib.hxx>
1034 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1036 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1037 if(aContext.IsNull()) {
1038 di << "use 'vinit' command before " << argv[0] << "\n";
1042 gp_Pnt pt3d(0, 20, 150);
1043 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
1044 gp_Circ circ(anAx2, 50.0);
1045 Handle_Geom_Circle gcir = new Geom_Circle(circ);
1046 Handle_Geom_Plane pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
1047 Handle_Geom2d_Curve gcir1 = GeomAPI::To2d(gcir, pln->Pln());
1048 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
1049 Handle_AIS_Shape ais1 = new AIS_Shape(sh1);
1050 aContext->SetColor(ais1, Quantity_NOC_INDIANRED);
1051 aContext->Display(ais1);
1052 DBRep::Set("sh0",sh1);
1054 // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
1055 thepoint = ProjLib::Project(pln->Pln(),pt3d);
1056 Handle_Geom2d_CartesianPoint ThePoint = new Geom2d_CartesianPoint(thepoint);
1057 Geom2dAdaptor_Curve acur1(gcir1) ;
1058 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
1059 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
1060 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
1061 Handle_Geom2d_Circle gccc;
1062 if( cirtanrad.NbSolutions() ) {
1063 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
1064 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
1065 gccc = new Geom2d_Circle(ccc);
1066 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
1067 Standard_Character aStr[5];
1068 sprintf(aStr,"sh%d",i);
1069 DBRep::Set(aStr,sh);
1070 Handle_AIS_Shape ais = new AIS_Shape(sh);
1072 aContext->SetColor(ais, Quantity_NOC_GREEN);
1074 aContext->SetColor(ais, Quantity_NOC_HOTPINK);
1075 aContext->Display(ais);
1076 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
1077 gp_Pnt2d PntSol1, PntSol2;
1078 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
1079 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
1080 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
1081 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
1087 #include <TColgp_Array2OfPnt.hxx>
1088 #include <Geom_BezierSurface.hxx>
1089 #include <BRepBuilderAPI_MakeFace.hxx>
1090 #include <BRepBuilderAPI_MakeWire.hxx>
1091 #include <Geom_OffsetSurface.hxx>
1092 #include <BRepFilletAPI_MakeFillet2d.hxx>
1093 #include <GeomProjLib.hxx>
1094 #include <Geom_TrimmedCurve.hxx>
1096 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1100 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
1101 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
1102 Standard_Real f = 0.0, l = 0.0;
1103 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
1104 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
1105 GC = new Geom_TrimmedCurve(GC, f, l);
1106 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
1107 BRepBuilderAPI_MakeWire *myWire;
1108 myWire = new BRepBuilderAPI_MakeWire();
1109 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
1110 DBRep::Set(argv[1],myWire->Wire());
1114 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1115 if(aContext.IsNull()) {
1116 di << "use 'vinit' command before " << argv[0] << "\n";
1120 //step 1. creating a Bezier Surface and a patch
1124 Handle(AIS_Shape) ais1;
1125 Handle_AIS_Shape ais2;
1126 Handle(Geom_BezierSurface) BZ1;
1127 TColgp_Array2OfPnt array1(1,3,1,3);
1128 array1.SetValue(1,1,gp_Pnt(0,100,0));
1129 array1.SetValue(1,2,gp_Pnt(200,100,0));
1130 array1.SetValue(1,3,gp_Pnt(400,100,0));
1131 array1.SetValue(2,1,gp_Pnt(0,200,100));
1132 array1.SetValue(2,2,gp_Pnt(200,200,100));
1133 array1.SetValue(2,3,gp_Pnt(400,200,100));
1134 array1.SetValue(3,1,gp_Pnt(0,300,0));
1135 array1.SetValue(3,2,gp_Pnt(200,300,0));
1136 array1.SetValue(3,3,gp_Pnt(400,300,0));
1137 BZ1 = new Geom_BezierSurface(array1);
1138 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
1139 TopoDS_Face F1= bzf1.Face();
1140 ais1 = new AIS_Shape(F1);
1141 DBRep::Set("F1",F1);
1142 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
1143 aContext->Display(ais1);
1150 gp_Dir D(0, 0, 1.0f);
1151 BRepBuilderAPI_MakeWire mkw;
1152 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
1153 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
1154 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
1156 p1 = gp_Pnt(350., 150., 260.);
1157 p2 = gp_Pnt(350., 250., 260.);
1158 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
1160 p1 = gp_Pnt(350., 250., 260.);
1161 p2 = gp_Pnt(300., 250.0, 260.);
1162 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
1164 p1 = gp_Pnt(300., 250.0, 260.);
1165 p2 = gp_Pnt(200., 200.0, 260.);
1166 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
1168 p1 = gp_Pnt(200., 200.0, 260.);
1169 p2 = gp_Pnt(150., 200.0, 260.);
1170 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
1172 p1 = gp_Pnt(150., 200.0, 260.);
1173 p2 = gp_Pnt(150., 150.0, 260.);
1174 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
1176 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
1177 ais2 = new AIS_Shape( FP );
1178 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
1179 aContext->Display( ais2 );
1181 DBRep::Set("FP",FP);
1183 //step 2. offseting the surface.
1184 Handle_Geom_OffsetSurface offsurf;
1185 offsurf = new Geom_OffsetSurface(BZ1, -100);
1186 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
1187 TopoDS_Face F2= bzf2.Face();
1188 Handle_AIS_Shape ais22 = new AIS_Shape(F2);
1189 aContext->Display(ais22);
1190 DBRep::Set("F2",F2);
1192 //step 3. filleting the patch.
1193 //( I want to project wire of this patch on offseted surface above)
1194 BRepFilletAPI_MakeFillet2d fillet( FP );
1196 Ex.Init(FP, TopAbs_VERTEX);
1197 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
1198 fillet.AddFillet(v1, 20);
1199 di << "\n" << "Error is " << fillet.Status() << "\n";
1200 // printf("\nError is %d ", fillet.Status());
1202 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
1203 fillet.AddFillet(V2, 20);
1204 di << "\n" << "Error is " << fillet.Status() << "\n";
1205 // printf("\nError is %d ", fillet.Status());
1207 FP1 = fillet.Shape();
1208 ais2 = new AIS_Shape( FP1 );
1209 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
1210 aContext->Display( ais2 );
1212 DBRep::Set("FP1",FP1);
1214 //step 4. Projecting the wire of this patch on offsetted surface.
1215 // TopExp_Explorer Ex;
1216 BRepBuilderAPI_MakeWire *myWire;
1217 myWire = new BRepBuilderAPI_MakeWire();
1218 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
1220 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
1221 Standard_Real f = 0.0, l = 0.0;
1222 Handle_Geom_Curve newBSplin = BRep_Tool::Curve(e1, f, l);
1223 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
1224 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
1225 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
1227 Handle_AIS_Shape ais33 = new AIS_Shape( myWire->Wire() );
1228 aContext->Display(ais33);
1230 DBRep::Set("Wire",myWire->Wire());
1235 #include<GeomAPI_ExtremaCurveCurve.hxx>
1237 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1241 printf("Usage: %s edge1 edge2",argv[0]);
1245 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
1246 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
1248 Standard_Real fp , lp;
1250 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
1251 C2 = BRep_Tool::Curve(E2 , fp , lp);
1253 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
1255 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
1260 #include <BRepBuilderAPI_MakePolygon.hxx>
1261 #include <BRepOffsetAPI_ThruSections.hxx>
1263 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1266 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1269 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1271 Standard_Integer IsB = atoi(argv[1]);
1273 IsBRepAlgoAPI = Standard_False;
1274 #if ! defined(BRepAlgo_def01)
1275 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1281 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
1282 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
1283 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
1284 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
1285 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
1287 for (int i=0;i<4;i++) {
1288 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
1289 bottompolygon1.Add(tmppnt);
1290 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
1291 toppolygon1.Add(tmppnt);
1292 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
1293 bottompolygon2.Add(tmppnt);
1294 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
1295 toppolygon2.Add(tmppnt);
1297 bottompolygon1.Close();
1298 DBRep::Set("B1",bottompolygon1.Shape());
1299 toppolygon1.Close();
1300 DBRep::Set("T1",toppolygon1.Shape());
1301 bottompolygon2.Close();
1302 DBRep::Set("B2",bottompolygon2.Shape());
1303 toppolygon2.Close();
1304 DBRep::Set("T2",toppolygon2.Shape());
1305 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
1306 loft1.AddWire(bottompolygon1.Wire());
1307 loft1.AddWire(toppolygon1.Wire());
1309 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
1310 loft2.AddWire(bottompolygon2.Wire());
1311 loft2.AddWire(toppolygon2.Wire());
1313 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
1315 DBRep::Set("TS1",loft1.Shape());
1316 DBRep::Set("TS2",loft2.Shape());
1318 //#if ! defined(BRepAlgoAPI_def01)
1319 // BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1321 // BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1323 if (IsBRepAlgoAPI) {
1324 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1325 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1326 DBRep::Set("F",result.Shape());
1328 di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1329 BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1330 DBRep::Set("F",result.Shape());
1333 // DBRep::Set("F",result.Shape());
1337 #include <Geom_RectangularTrimmedSurface.hxx>
1338 #include <GC_MakeTrimmedCone.hxx>
1340 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1342 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1343 if(aContext.IsNull()) {
1344 di << "use 'vinit' command before " << argv[0] << "\n";
1349 double R1=8, R2=16, H1=20, H2=40, angle;
1351 P1(0,0,20), P2(0,0,45);
1353 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
1354 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
1355 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
1356 aContext->Display(ais1);
1357 aContext->SetColor(ais1, Quantity_NOC_BLUE1);
1359 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
1360 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
1361 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
1362 aContext->Display(ais2);
1363 aContext->SetColor(ais2, Quantity_NOC_RED);
1367 //#include <fstream.h>
1370 #elif defined (HAVE_FSTREAM_H)
1371 # include <fstream.h>
1373 //#include <Standard_Stream.hxx>
1374 //==========================================================================
1375 //function : CoordLoad
1376 // chargement d une face dans l explorer.
1377 //==========================================================================
1378 static Standard_Integer coordload (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1383 TopoDS_Vertex V1,V2;
1388 if (argc < 3) return 1;
1390 ifstream file(argv[2], ios::in);
1393 di<<"unable to open "<<argv[2]<<" for input"<<"\n";
1396 BRepBuilderAPI_MakeWire WB;
1398 file.getline(line,80);
1399 for(int i=0;i<30;i++) X[i]=Y[i]=0;
1400 fr = sscanf(line,"%20c%20c",&X,&Y);
1401 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1405 file.getline(line,80);
1407 for(int i=0;i<30;i++) X[i]=Y[i]=0;
1408 fr = sscanf(line,"%20c%20c",&X,&Y);
1409 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1410 Edge = BRepBuilderAPI_MakeEdge(V1,V2);
1416 if (WB.IsDone()) Wire = WB.Wire();
1417 Face = BRepBuilderAPI_MakeFace(Wire);
1419 DBRep::Set (argv[1],Face);
1423 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
1424 Standard_Integer /*nb*/,
1425 const char ** /*arg*/)
1427 TCollection_ExtendedString aString(1024*1024, 'A');
1431 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
1432 Standard_Integer argc,
1435 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1436 if(aContext.IsNull()) {
1437 di << "use 'vinit' command before " << argv[0] << "\n";
1440 if((argc != 2) && (argc != 3)) {
1441 di<< "usage : " << argv[0] << " shape [mode==1]" << "\n";
1444 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1445 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
1446 // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
1447 anIO->SetHilightMode((argc == 3) ? atoi(argv[2]) : 1);
1448 aContext->Display(anIO);
1452 //=======================================================================
1453 //function : buc60773
1455 //=======================================================================
1457 #include<TCollection_HAsciiString.hxx>
1459 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
1461 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
1462 Standard_CString aStr = hAscii->ToCString();
1463 TCollection_AsciiString aAscii(aStr);
1468 #include<BRepPrimAPI_MakeCylinder.hxx>
1469 #include<BRepPrimAPI_MakeCone.hxx>
1471 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1475 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1478 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1480 Standard_Integer IsB = atoi(argv[1]);
1482 IsBRepAlgoAPI = Standard_False;
1483 #if ! defined(BRepAlgo_def01)
1484 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1490 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
1492 Standard_Real x11 = 36.085182;
1493 Standard_Real y11 = 20.0;
1494 Standard_Real z11 = 8.431413;
1495 Standard_Real x12 = 88.04671;
1496 Standard_Real y12 = 20.0;
1497 Standard_Real z12 = 38.931416;
1498 Standard_Real radius = 10.0;
1500 gp_Pnt base1(x11, y11, z11);
1501 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
1502 gp_Ax2 axis1(base1, vect1);
1503 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
1504 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
1506 TopoDS_Shape SCyl = cylinder.Shape();
1507 DBRep::Set("cyl", SCyl);
1510 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
1511 Standard_Real x21 = 70.7262;
1512 Standard_Real y21 = 20.0;
1513 Standard_Real z21 = 28.431412;
1514 Standard_Real x22 = 105.36722;
1515 Standard_Real y22 = 20.0;
1516 Standard_Real z22 = 48.431416;
1517 Standard_Real radius1 = 6.0;
1518 Standard_Real radius2 = 3.0;
1520 gp_Pnt base2(x21, y21, z21);
1521 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
1522 gp_Ax2 axis2(base2, vect2);
1523 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
1524 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1526 TopoDS_Shape SCon = cone.Shape();
1527 DBRep::Set("con", SCon);
1529 //#if ! defined(BRepAlgoAPI_def01)
1530 // BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1532 // BRepAlgo_Fuse SFuse(SCyl, SCon);
1535 // if(! SFuse.IsDone() )
1536 // cout<<"Error: Boolean fuse operation failed !"<<endl;
1538 // TopoDS_Shape fuse = SFuse.Shape();
1541 if (IsBRepAlgoAPI) {
1542 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n";
1543 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1544 if(! SFuse.IsDone() )
1545 di<<"Error: Boolean fuse operation failed !"<<"\n";
1546 fuse = SFuse.Shape();
1548 di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n";
1549 BRepAlgo_Fuse SFuse(SCyl, SCon);
1550 if(! SFuse.IsDone() )
1551 di<<"Error: Boolean fuse operation failed !"<<"\n";
1552 fuse = SFuse.Shape();
1555 DBRep::Set("fus", fuse);
1560 #include <Dico_DictionaryOfInteger.hxx>
1561 #include <TColStd_HSequenceOfAsciiString.hxx>
1562 #include <TopExp.hxx>
1563 #include <TopoDS_Iterator.hxx>
1565 //---------------------------------------------------------------------------------------
1567 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1570 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1573 di<<"Invalid input shape"<<"\n";
1576 Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
1577 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1578 Standard_CString aString;
1579 Standard_Integer i=1,j=1,k=1,l=1,aa=1;
1580 TopExp_Explorer expl;
1581 Standard_Real f3d,l3d;
1582 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1585 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1586 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1587 aString = aSurface->DynamicType()->Name();
1589 if(aDico->GetItem(aString,aa) != 0)
1591 aDico->GetItem(aString,aa);
1592 aDico->SetItem(aString,aa+1);
1594 aDico->SetItem(aString,1);
1595 aSequence->Append(aString);
1601 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1603 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1604 TopoDS_Iterator anIt(aFace);
1605 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1606 TopoDS_Iterator it (aWire);
1607 for (; it.More(); it.Next()) {
1608 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1609 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1610 aString = aCurve2d->DynamicType()->Name();
1611 if(aDico->GetItem(aString,aa) != 0)
1613 aDico->GetItem(aString,aa);
1614 aDico->SetItem(aString,aa+1);
1616 aDico->SetItem(aString,1);
1617 aSequence->Append(aString);
1624 TopExp_Explorer exp;
1625 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
1627 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1628 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1629 if(aCurve3d.IsNull())
1634 aString = aCurve3d->DynamicType()->Name();
1635 if(aDico->GetItem(aString,aa) != 0)
1637 aDico->GetItem(aString,aa);
1638 aDico->SetItem(aString,aa+1);
1640 aDico->SetItem(aString,1);
1641 aSequence->Append(aString);
1651 aDico->GetItem(aSequence->Value(j),aa);
1652 di<<aa<<" -- "<<aSequence->Value(j).ToCString()<<"\n";
1656 di<<"Degenerated edges :"<<"\n";
1657 di<<l<<" -- "<<"Degenerated edges "<<"\n";
1663 #include <BRepBuilderAPI_Transform.hxx>
1665 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1668 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1671 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1673 Standard_Integer IsB = atoi(argv[1]);
1675 IsBRepAlgoAPI = Standard_False;
1676 #if ! defined(BRepAlgo_def01)
1677 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1683 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1684 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1685 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1687 TopoDS_Shape sh1 = cyl.Shape();
1688 DBRep::Set("sh1",sh1);
1689 gp_Trsf trsf1, trsf2;
1690 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1691 gp_Pnt(0.000000,700.000000,-95.000000));
1692 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1693 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1694 BRepBuilderAPI_Transform trans1(sh1, trsf1);
1695 TopoDS_Shape sh2 = trans1.Shape();
1696 DBRep::Set("sh2",sh2);
1698 //#if ! defined(BRepAlgoAPI_def01)
1699 // BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1701 // BRepAlgo_Fuse fuse1(sh1, sh2);
1704 // TopoDS_Shape fsh1 = fuse1.Shape();
1707 if (IsBRepAlgoAPI) {
1708 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n";
1709 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1710 fsh1 = fuse1.Shape();
1712 di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n";
1713 BRepAlgo_Fuse fuse1(sh1, sh2);
1714 fsh1 = fuse1.Shape();
1717 DBRep::Set("fsh1",fsh1);
1718 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1719 TopoDS_Shape sh3 = trans2.Shape();
1720 DBRep::Set("sh3",sh3);
1722 //#if ! defined(BRepAlgoAPI_def01)
1723 // BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1725 // BRepAlgo_Fuse fuse2(fsh1,sh3);
1728 // TopoDS_Shape fsh2 = fuse2.Shape();
1731 if (IsBRepAlgoAPI) {
1732 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n";
1733 BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1734 fsh2 = fuse2.Shape();
1736 di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n";
1737 BRepAlgo_Fuse fuse2(fsh1,sh3);
1738 fsh2 = fuse2.Shape();
1741 DBRep::Set("fsh2",fsh2);
1742 Handle_AIS_Shape aisp1 = new AIS_Shape(fsh2);
1743 // aContext->Display(aisp1);
1747 #include <ShapeBuild_Edge.hxx>
1749 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1751 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1752 ShapeBuild_Edge().BuildCurve3d(e);
1758 #include<TDF_Label.hxx>
1759 #include<TDataStd_TreeNode.hxx>
1761 #include<DDocStd.hxx>
1765 #include<TDocStd_Modified.hxx>
1766 #include<TDF_ListIteratorOfDeltaList.hxx>
1767 #include<TDocStd_Document.hxx>
1768 #include<TDocStd_Application.hxx>
1769 #include<TDF_Delta.hxx>
1770 #include<TDataXtd_Constraint.hxx>
1771 #include<TPrsStd_AISPresentation.hxx>
1772 #include<TPrsStd_AISViewer.hxx>
1773 #include<TNaming_Builder.hxx>
1774 #include<TNaming_Naming.hxx>
1775 #include<TNaming_NamedShape.hxx>
1777 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1779 di << "Usage : " << argv[0] << " D" << "\n";
1784 Handle(TDF_Data) DF;
1785 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1788 Handle(TDataStd_TreeNode) TN1,TN2;
1790 DDF::AddLabel(DF,"0:2",L1);
1791 TN1 = TDataStd_TreeNode::Set(L1);
1793 DDF::AddLabel(DF,"0:3",L2);
1794 TN2 = TDataStd_TreeNode::Set(L2);
1797 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1798 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1804 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1806 di << "Usage : " << argv[0] << " D" << "\n";
1811 Handle(TDF_Data) DF;
1812 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1815 DDF::FindLabel(DF,"0:1",L,Standard_False);
1816 Handle(TDocStd_Modified) MDF;
1817 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1818 MDF = new TDocStd_Modified();
1819 L.Root().AddAttribute(MDF);
1822 di<<!MDF->IsEmpty();
1826 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1828 di << "Usage : " << argv[0] << " D Label" << "\n";
1833 Handle(TDF_Data) DF;
1834 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1837 DDF::FindLabel(DF,argv[2],L,Standard_False);
1839 TDocStd_Modified::Add(L);
1845 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1847 di << "Usage : " << argv[0] << " D" << "\n";
1853 Handle(TDF_Data) aDF;
1854 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1856 Handle(TDocStd_Document) aDocument;
1857 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1860 Handle(TDataStd_TreeNode) TN;
1862 aDocument->NewCommand();
1863 DDF::AddLabel(aDF,"0:2",L);
1864 TN = TDataStd_TreeNode::Set(L);
1866 aDocument->NewCommand();
1867 DDF::AddLabel(aDF,"0:3",L);
1868 TN = TDataStd_TreeNode::Set(L);
1870 aDocument->NewCommand();
1871 DDF::AddLabel(aDF,"0:4",L);
1872 TN = TDataStd_TreeNode::Set(L);
1873 aDocument->NewCommand();
1875 TDF_DeltaList Us,Rs;
1876 Us = aDocument->GetUndos();
1877 Rs = aDocument->GetUndos();
1880 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1882 TDF_ListIteratorOfDeltaList IDL;
1883 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1884 Handle(TDF_Delta) D = IDL.Value();
1885 TCollection_ExtendedString S(Names[i-1]);
1887 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1893 Us = aDocument->GetUndos();
1894 Rs = aDocument->GetRedos();
1896 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1897 Handle(TDF_Delta) D = IDL.Value();
1898 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1901 TCollection_ExtendedString n2name ("n2");
1902 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1903 Handle(TDF_Delta) D = IDL.Value();
1904 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1915 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1917 di << "Usage : " << argv[0] << " D Shape" << "\n";
1922 Handle(TDF_Data) aDF;
1923 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1925 TopoDS_Shape s = DBRep::Get(argv[2]);
1926 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1928 DDF::AddLabel(aDF, "0:2", L);
1929 TNaming_Builder SI (L);
1932 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1936 // if (!NS->IsEmpty()) {di<<3;return 0;}
1937 if (NS->IsEmpty()) {di<<4;return 0;}
1942 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1944 di << "Usage : " << argv[0] << " D Shape" << "\n";
1949 Handle(TDF_Data) aDF;
1950 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1952 TopoDS_Shape s = DBRep::Get(argv[2]);
1953 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1955 DDF::AddLabel(aDF, "0:2", L);
1956 TNaming_Builder SI (L);
1959 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1963 if (NS->IsEmpty()) {di<<4;return 0;}
1968 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1970 TCollection_ExtendedString path (argv[1]);
1971 Handle(TDocStd_Application) A;
1972 if (!DDocStd::Find(A)) {di<<1;return 0;}
1973 Handle(TDocStd_Document) D;
1974 Standard_Integer insession = A->IsInSession(path);
1975 if (insession > 0) {
1976 di <<"document " << insession << " is already in session" << "\n";
1980 PCDM_ReaderStatus Result = A->Open(path,D);
1981 if(Result==PCDM_RS_OK){
1990 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1992 di << "Usage : " << argv[0] << " D" << "\n";
1997 Handle(TDF_Data) aDF;
1998 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2001 DDF::AddLabel(aDF, "0:2", L);
2003 Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation;
2005 AISP->Set(L,TDataXtd_Constraint::GetID());
2007 if (AISP->HasOwnMode()) {di<<3;return 0;}
2009 Standard_Integer Mode = AISP->Mode();
2010 if (Mode!=3) {di<<4;return 0;}
2011 if (!AISP->HasOwnMode()) {di<<5;return 0;}
2013 if (AISP->HasOwnMode()) {di<<6;return 0;}
2018 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2020 di << "Usage : " << argv[0] << " D" << "\n";
2025 Handle(TDF_Data) aDF;
2026 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2029 DDF::AddLabel(aDF, "0:2", L);
2033 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
2034 // Handle(TNaming_Name) NN = new TNaming_Name;
2037 NN.Type(TNaming_IDENTITY);
2039 Standard_Boolean Res = NN.Solve(L,LM);
2041 if (Res!=Standard_False) {di<<3;return 0;}
2046 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2048 di << "Usage : " << argv[0] << " D" << "\n";
2054 Handle(TDocStd_Document) aDocument;
2055 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
2057 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
2058 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
2064 //=======================================================================
2065 //function : AISWidth
2066 //purpose : AISWidth (DOC,entry,[width])
2067 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
2068 //=======================================================================
2070 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2073 Handle(TDocStd_Document) D;
2074 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
2076 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
2078 Handle(TPrsStd_AISViewer) viewer;
2079 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
2081 Handle(TPrsStd_AISPresentation) prs;
2082 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2084 prs->SetWidth(atof(argv[3]));
2085 TPrsStd_AISViewer::Update(L);
2088 if (prs->HasOwnWidth()){
2089 // cout << "Width = " << prs->Width() << endl;
2093 di << "AISWidth: Warning : Width wasn't set" << "\n";
2100 di << "AISWidth : Error" << "\n";
2105 //=======================================================================
2106 //function : BUC60921 ( & BUC60954 )
2107 //purpose : Test memory allocation of OCAF in Undo/Redo operations
2108 //=======================================================================
2110 static Standard_Integer BUC60921 (Draw_Interpretor& di,
2111 Standard_Integer nb,
2115 Handle(TDocStd_Document) D;
2116 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
2118 DDF::AddLabel(D->GetData(),arg[2],L);
2122 BRepTools::Read ( S, arg[3], B );
2124 TNaming_Builder tnBuild(L);
2125 tnBuild.Generated(S);
2126 // di << "File " << arg[3] << " added";
2130 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
2135 #include<IGESControl_Reader.hxx>
2136 #include<BRepPrimAPI_MakeHalfSpace.hxx>
2138 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
2142 // cerr << "Usage : " << a[0] << " file.igs" << endl;
2145 if(argc < 2 || argc > 3) {
2146 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2149 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2151 Standard_Integer IsB = atoi(a[2]);
2153 IsBRepAlgoAPI = Standard_False;
2154 #if ! defined(BRepAlgo_def01)
2155 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
2161 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
2163 if(myContext.IsNull()) {
2164 di << "use 'vinit' command before " << a[0] << "\n";
2168 // IGESControlStd_Reader reader;
2169 IGESControl_Reader reader;
2170 reader.ReadFile(a[1]);
2171 reader.TransferRoots();
2172 TopoDS_Shape shape = reader.OneShape();
2173 printf("\n iges1 shape type = %d", shape.ShapeType() );
2174 TopTools_IndexedMapOfShape list;
2175 TopExp::MapShapes(shape, TopAbs_FACE, list);
2176 printf("\n No. of faces = %d", list.Extent());
2179 BRep_Builder builder;
2180 builder.MakeShell(shell);
2181 for(int i=1;i<=list.Extent(); i++) {
2182 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
2183 builder.Add(shell, face);
2186 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
2187 TopoDS_Solid sol = half.Solid();
2188 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
2189 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
2190 TopoDS_Shape sh = cyl.Shape();
2192 //#if ! defined(BRepAlgoAPI_def01)
2193 // BRepAlgoAPI_Fuse fuse(sol, sh);
2195 // BRepAlgo_Fuse fuse(sol, sh);
2198 // sh = fuse.Shape();
2200 if (IsBRepAlgoAPI) {
2201 di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n";
2202 BRepAlgoAPI_Fuse fuse(sol, sh);
2205 di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n";
2206 BRepAlgo_Fuse fuse(sol, sh);
2210 Handle(AIS_Shape) res = new AIS_Shape(sh);
2211 myContext->Display( res );
2215 void QABugs::Commands_3(Draw_Interpretor& theCommands) {
2216 const char *group = "QABugs";
2218 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
2219 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
2220 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
2221 theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group);
2223 theCommands.Add("UKI61075","UKI61075",__FILE__,UKI61075,group);
2225 theCommands.Add("BUC60585",St,__FILE__,BUC60585,group);
2226 theCommands.Add("BUC60547","BUC60547 name",__FILE__,BUC60547,group);
2227 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
2228 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
2229 theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2230 theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2231 theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2232 theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2233 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
2235 theCommands.Add("BUC60698","BUC60698 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60698,group);
2237 theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
2238 theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
2239 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
2240 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
2242 theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
2243 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
2244 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
2245 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
2246 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
2247 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
2249 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
2251 theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
2253 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
2255 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
2257 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
2258 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
2259 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
2260 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
2262 theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
2264 theCommands.Add("statface","statface face",__FILE__,statface,group);
2266 theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
2268 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
2270 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
2271 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
2272 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
2273 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
2274 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
2275 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
2276 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
2277 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
2278 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
2279 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
2280 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
2281 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
2283 theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );