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>
35 #include <Graphic3d_ClipPlane.hxx>
40 static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
44 di << "Usage : " << a[0] << " result Shape1 Shape2" << "\n";
50 TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
51 TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
52 Handle(Geom_Surface) GSF1 = BRep_Tool::Surface(F1, L1);
53 Handle(Geom_Surface) GSF2 = BRep_Tool::Surface(F2, L2);
55 Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1));
56 if (!Inter.IsDone()) {
57 di << "Intersection not done" << "\n";
60 Standard_Integer nbsol = Inter.NbLines();
62 di << "The number of solutions is zero!" << "\n";
65 Handle(Geom_Curve) Sol = Inter.Line(1);
67 DBRep::Set(a[1], BRepBuilderAPI_MakeEdge(Sol));
69 } else di << "The first solution is Null!" << "\n";
75 #include<ViewerTest.hxx>
76 #include<AIS_InteractiveContext.hxx>
77 #include<AIS_Shape.hxx>
79 static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
83 di << "Usage : " << argv[0] << " shape" << "\n";
87 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
88 if(myAISContext.IsNull()) {
89 di << "use 'vinit' command before " << argv[0] << "\n";
93 TopoDS_Shape theShape = DBRep::Get(argv[1]);
95 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
96 myAISContext->Display( anAISShape, Standard_True );
97 myAISContext->OpenLocalContext();
98 myAISContext->ActivateStandardMode(TopAbs_FACE);
102 static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
106 di << "Usage : "<< argv[0] << " shape" << "\n";
112 TopoDS_Shape theShape = DBRep::Get(argv[1]);
114 // ViewerTest::GetAISContext();
115 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
116 if(myAISContext.IsNull()) {
117 di << "use 'vinit' command before " << argv[0] << "\n";
120 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
121 myAISContext->Display( anAISShape, Standard_True );
122 myAISContext->OpenLocalContext();
123 myAISContext->ActivateStandardMode(TopAbs_COMPOUND);
124 // myAISContext->ActivateStandardMode(TopAbs_SOLID);
126 // cout << "vfini" << endl;
130 #include<BRep_Builder.hxx>
131 #include<BRepTools_ShapeSet.hxx>
132 #include<BRepTools.hxx>
133 #include<BRepAdaptor_HSurface.hxx>
134 #include<TopOpeBRep_PointClassifier.hxx>
135 #include<Precision.hxx>
140 static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
145 // BUC60609 shape name
146 } else if ( argc == 5 ) {
147 // BUC60609 shape name U V
149 di << "Usage : "<< argv[0] << " shape name [U V]" << "\n";
153 TCollection_AsciiString aFilePath(argv[1]);
157 if (!fic.open(aFilePath.ToCString(),ios::in)) {
158 di << "Cannot open file for reading : " << aFilePath << "\n";
162 TopoDS_Shape theShape;
166 if( !strcmp(typ, "DBRep_DrawableShape") ){
168 BRepTools_ShapeSet S(B);
172 di << "Wrong entity type in " << aFilePath << "\n";
177 const TopoDS_Face &face = TopoDS::Face (theShape);
180 DBRep::Set(argv[2],face);
183 Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
185 BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
187 di << "The bounds of the trimmed face:" << "\n";
188 di << faceUMin << " <= U <= " << faceUMax << "\n";
189 di << faceVMin << " <= V <= " << faceVMax << "\n";
191 Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
193 TopOpeBRep_PointClassifier PClass;
195 di << "Now test the point classifier by inputting U,V values" << "\n";
196 di << "inside or outside the bounds displayed above" << "\n";
197 di << "Type stop to exit" << "\n";
199 // Please register this:
200 // ***********************************************
201 // Note also that for periodic surfaces such as nimpod_1.topo,
202 // the U/V values may be +- 2pi compared to the actual face bounds
203 // (because U,V is probably coming from a Geom package routine).
204 // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
205 // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
206 // *************************************************
209 uvSurf = gp_Pnt2d(0.14,5.1);
210 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
211 if(state == TopAbs_IN || state == TopAbs_ON){
212 di << "U=" << 0.14 << " V=" << 5.1 << " classified INSIDE" << "\n";
214 di << "U=" << 0.14 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
217 uvSurf = gp_Pnt2d(1.28,5.1);
218 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
219 if(state == TopAbs_IN || state == TopAbs_ON){
220 di << "U=" << 1.28 << " V=" << 5.1 << " classified INSIDE" << "\n";
222 di << "U=" << 1.28 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
225 uvSurf = gp_Pnt2d(Draw::Atof(argv[3]),Draw::Atof(argv[4]));
226 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
227 if(state == TopAbs_IN || state == TopAbs_ON){
228 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified INSIDE" << "\n";
230 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified OUTSIDE" << "\n";
238 void stringerror(int state)
240 printf("%s",((state&ios::eofbit) !=0)? " [eof]": "");
241 printf("%s",((state&ios::failbit)!=0)? " [fail]":"");
242 printf("%s",((state&ios::badbit) !=0)? " [bad]": "");
243 printf("%s\n",(state==ios::goodbit)? " [ok]": "");
248 //#include <strstream>
250 //#include <strstream.h>
256 #elif defined (HAVE_IOSTREAM_H)
257 #include <iostream.h>
258 #include <strstream.h>
260 #error "check config.h file or compilation options: either HAVE_IOSTREAM or HAVE_IOSTREAM_H should be defined"
262 static int UKI61075(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** /*argv*/) {
265 #ifndef USE_STL_STREAM
266 ostrstream stringout1(buffer1,sizeof(buffer1));
267 istrstream stringin1(buffer1,sizeof(buffer1));
269 ostringstream stringout1(buffer1);
270 istringstream stringin1(buffer1);
273 #ifndef USE_STL_STREAM
274 ostrstream stringout2(buffer2,sizeof(buffer2));
275 istrstream stringin2(buffer2,sizeof(buffer2));
277 ostringstream stringout2(buffer1);
278 istringstream stringin2(buffer1);
281 stringout1.precision(17);
282 stringout2.precision(17);
286 printf("Valeurs originales :\n\t%.17lg %.17lg\n",da,db);
288 stringout1<<da<<' '<<db<<"\n";
289 #ifndef USE_STL_STREAM
290 buffer1[stringout1.pcount()]='\0';
292 buffer1[stringout1.str().length()]= '\0' ;
295 printf("Valeurs ecrites dans le fichier :\n\t%s",buffer1);
299 printf("Valeurs relues :\n\t%.17lg %.17lg",da,db);
300 stringerror(stringin1.rdstate());
302 stringout2<<da<<' '<<db<<"\n";
303 #ifndef USE_STL_STREAM
304 buffer2[stringout2.pcount()]='\0';
306 buffer2[stringout2.str().length()]='\0';
309 printf("Valeurs reecrites :\n\t%s",buffer2);
313 printf("Valeurs relues a nouveau :\n\t%.17lg %.17lg",da,db);
314 stringerror(stringin2.rdstate());
320 #include<BRepAlgoAPI_Section.hxx>
321 #include<BRepAlgo_Section.hxx>
323 #include<Geom_Plane.hxx>
324 #include<DrawTrSurf.hxx>
326 //static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane]";
327 static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane] [BRepAlgoAPI/BRepAlgo = 1/0]";
329 static int BUC60585(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
332 // cerr << "Usage : " << argv[0] << St << endl;
335 if(argc < 2 || argc > 6) {
336 di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
339 Standard_Boolean IsBRepAlgoAPI = Standard_True;
341 Standard_Integer IsB = Draw::Atoi(argv[5]);
343 IsBRepAlgoAPI = Standard_False;
344 #if ! defined(BRepAlgo_def04)
345 // di << "Error: There is not BRepAlgo_Section class" << "\n";
353 if(!strcmp(argv[1],"trimsphere")) {
354 //////////////////////////////////////////
355 // Uncomment for trimmed sphere bug:
356 // filename = "trimsphere.topo";
357 N=gp_Dir( 0.0, -1.0, 0.0 );
358 //////////////////////////////////////////
359 } else if(!strcmp(argv[1],"sphere")) {
361 //////////////////////////////////////////
362 // Uncomment for untrimmed sphere bug:
364 // filename="sphere.topo";
365 N=gp_Dir( 0.0, -0.75103523489975432, -0.66026212668838646 );
367 //////////////////////////////////////////
369 di << "Usage : " << argv[0] << St << "\n";
374 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
375 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
377 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
380 Standard_Character *filename = new Standard_Character [strlen(DD)+17];
381 Sprintf(filename,"%s/%s.topo",DD,argv[1]);
385 if (!fic.open(filename,ios::in)) {
386 di << "Cannot open file for reading : " << filename << "\n";
394 BRepTools_ShapeSet S(B);
396 TopoDS_Shape theShape;
401 gp_Pnt O( 2036.25, -97.5, -1460.499755859375 );
402 gp_Dir A( 1.0, 0.0, 0.0 );
404 gp_Ax3 PLA( O, N, A );
407 // Perform the section
409 //#if ! defined(BRepAlgoAPI_def01)
410 // BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
412 // BRepAlgo_Section Sec( theShape, Pl, Standard_False);
419 // Sec.Approximation(Standard_True);
423 // cout << "Error performing intersection: not done." << endl;
430 di << "BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False)" <<"\n";
431 BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
434 di << "Error performing intersection: not done." << "\n";
440 di << "BRepAlgo_Section Sec( theShape, Pl, Standard_False)" <<"\n";
441 BRepAlgo_Section Sec( theShape, Pl, Standard_False);
444 di << "Error performing intersection: not done." << "\n";
451 }catch(Standard_Failure){
452 Handle(Standard_Failure) error = Standard_Failure::Caught();
453 di << "Error performing intersection: not done." << "\n";
458 if(argc>3) DBRep::Set(argv[3],theShape);
460 if(argc>2) DBRep::Set(argv[2],res);
463 Handle(Geom_Geometry) result;
464 Handle(Geom_Plane) C = new Geom_Plane(Pl);
466 DrawTrSurf::Set(argv[4],result);
469 di << "Done" << "\n";
476 #include<TopoDS_Compound.hxx>
478 static int BUC60547(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
480 di << "Usage : " << argv[0] << " name" << "\n";
484 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
485 if(myAISContext.IsNull()) {
486 di << "use 'vinit' command before " << argv[0] << "\n";
491 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
492 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
494 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
497 Standard_Character *Ch = new Standard_Character[strlen(argv[1])+3];
499 Standard_Character *FileName = new Standard_Character[strlen(DD)+13];
501 TopoDS_Shape free_1,free_2,free_3,free_4;
503 Sprintf(FileName,"%s/%s",DD,"buc60547a.brep");
504 BRepTools::Read(free_1,FileName,B);
505 Sprintf(FileName,"%s/%s",DD,"buc60547b.brep");
506 BRepTools::Read(free_2,FileName,B);
507 Sprintf(FileName,"%s/%s",DD,"buc60547c.brep");
508 BRepTools::Read(free_3,FileName,B);
509 Sprintf(FileName,"%s/%s",DD,"buc60547d.brep");
510 BRepTools::Read(free_4,FileName,B);
511 Sprintf(Ch,"%s_%i",argv[1],1);
512 DBRep::Set(Ch,free_1);
514 Sprintf(Ch,"%s_%i",argv[1],2);
515 DBRep::Set(Ch,free_2);
517 Sprintf(Ch,"%s_%i",argv[1],3);
518 DBRep::Set(Ch,free_3);
520 Sprintf(Ch,"%s_%i",argv[1],4);
521 DBRep::Set(Ch,free_4);
524 // Handle(AIS_Shape) S1 = new AIS_Shape(free_1);
525 // Handle(AIS_Shape) S2 = new AIS_Shape(free_2);
526 // Handle(AIS_Shape) S3 = new AIS_Shape(free_3);
527 // Handle(AIS_Shape) S4 = new AIS_Shape(free_4);
529 // Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
531 // myAISContext->Display(S1);
532 // myAISContext->Display(S2);
533 // myAISContext->Display(S3);
534 // myAISContext->Display(S4);
540 bui.MakeCompound(Com);
546 Sprintf(Ch,"%s_%c",argv[1],'c');
550 Handle(AIS_Shape) SC = new AIS_Shape(Com);
551 myAISContext->Display(SC); // nothing on the screen If I save the compound :
553 Sprintf(FileName,"%s/%s",DD,"free.brep");
555 BRepTools::Write(Com,FileName);
563 #include<BRepBuilderAPI_MakeVertex.hxx>
564 #include<TCollection_ExtendedString.hxx>
565 #include<AIS_LengthDimension.hxx>
567 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
570 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
571 if(myAIScontext.IsNull()) {
572 di << "use 'vinit' command before " << a[0] << "\n";
575 myAIScontext->EraseAll();
577 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
578 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
580 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
581 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
583 myAIScontext->Display(Ve1);
584 myAIScontext->Display(Ve2);
586 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
587 TCollection_ExtendedString Ext1("Dim1");
588 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln());
589 Dim1->SetCustomValue (Draw::Atof(a[2]));
591 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
592 anAspect->MakeArrows3d (Standard_False);
593 anAspect->MakeText3d (Standard_True);
594 anAspect->MakeTextShaded (Standard_True);
595 anAspect->TextAspect()->SetHeight (2.5);
596 anAspect->ArrowAspect()->SetLength (1.0);
597 Dim1->SetDimensionAspect (anAspect);
599 myAIScontext->SetDisplayMode(Dim1, Draw::Atoi(a[1]));
600 myAIScontext->Display(Dim1);
604 #include<TopoDS_Wire.hxx>
606 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
609 di << "Usage : BUC60652 fase" << "\n";
612 TopoDS_Shape shape = DBRep::Get( argv[1] );
613 TopoDS_Face face = TopoDS::Face( shape );
614 TopoDS_Wire ow = BRepTools::OuterWire( face );
615 DBRep::Set( "w", ow );
619 #include <BRepAlgo_BooleanOperations.hxx>
621 static Standard_Integer defNbPntMax = 30;
622 static Standard_Real defTol3d = 1.e-7;
623 static Standard_Real defTol2d = 1.e-7;
624 static Standard_Boolean defRelativeTol=Standard_True;
625 Standard_Integer NbPntMax = defNbPntMax;
626 Standard_Real Toler3d =defTol3d;
627 Standard_Real Toler2d = defTol2d;
628 Standard_Boolean RelativeTol= defRelativeTol;
629 // //== // ksection : operateur section appelant BRepAlgo_BooleanOperation
630 //== // ksection : operateur section appelant BRepAlgo_BooleanOperations
631 //=======================================================================
632 Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) {
634 di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol" << "\n";
644 TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL);
645 TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL);
646 if (s1.IsNull() || s2.IsNull()) return 1;
647 NbPntMax=Draw::Atoi(a[4]);
648 Toler3d=Draw::Atof(a[5]);
649 Toler2d=Draw::Atof(a[6]);
650 RelativeTol=Draw::Atoi(a[7]);
652 di << "BRepAlgo_BooleanOperations myalgo" << "\n";
653 BRepAlgo_BooleanOperations myalgo;
655 myalgo.Shapes(s1, s2);
656 myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d,RelativeTol);
657 TopoDS_Shape res; res = myalgo.Section();
658 DBRep::Set(a[1],res);
662 #include <Geom_Axis2Placement.hxx>
663 #include <AIS_Trihedron.hxx>
665 static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
668 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
669 if(myAISContext.IsNull()) {
670 di << "use 'vinit' command before " << a[0] << "\n";
674 Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY());
675 Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis);
678 aTrsf.SetTranslation(trans);
679 TopLoc_Location aLoc(aTrsf);
680 myAISContext->SetLocation(atri,aLoc);
681 myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
682 myAISContext->OpenLocalContext(Standard_False,
683 Standard_True,Standard_False,Standard_False);
684 myAISContext->Load(atri,3,Standard_True);
689 #include <TopoDS_Solid.hxx>
690 #include <BRepPrimAPI_MakeBox.hxx>
691 #include <BRepPrimAPI_MakeSphere.hxx>
693 #include <BRepAlgoAPI_Fuse.hxx>
694 #include <BRepAlgo_Fuse.hxx>
696 #include <V3d_View.hxx>
697 #include <gce_MakePln.hxx>
699 static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
702 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
703 if(myAISContext.IsNull()) {
704 di << "use 'vinit' command before " << a[0] << "\n";
707 TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid();
708 TopAbs_ShapeEnum theType = B1.ShapeType();
709 if ( theType == TopAbs_SOLID ) {
710 di << "It is a solid." << "\n";
712 di << "It is not solid." << "\n";
714 myAISContext->Display(new AIS_Shape(B1));
715 myAISContext->OpenLocalContext();
716 TopAbs_ShapeEnum amode = TopAbs_SOLID;
717 myAISContext->ActivateStandardMode(amode);
719 di.Eval("QAMoveTo 200 200");
720 di.Eval("QASelect 200 200");
721 myAISContext->InitSelected() ;
722 if ( myAISContext->MoreSelected() ) {
723 if (myAISContext->HasSelectedShape() ) {
724 di << "has selected shape : OK" << "\n";
726 di << "has selected shape : bugged - Faulty " << "\n";
732 static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
735 di << "Usage : " << argv[0] << " [1/0]" << "\n";
739 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
740 if(myAIScontext.IsNull()) {
741 di << "use 'vinit' command before " << argv[0] << "\n";
744 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
746 if((argc == 2) && (Draw::Atof(argv[1]) == 0))
747 myV3dView->SetAntialiasingOff();
749 myV3dView->SetAntialiasingOn();
755 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
757 //=======================================================================
758 //function : GetColorFromName
759 //purpose : get the Quantity_NameOfColor from a string
760 //=======================================================================
762 static Quantity_NameOfColor GetColorFromName( const char *name )
764 Quantity_NameOfColor ret = DEFAULT_COLOR;
766 Standard_Boolean Found = Standard_False;
767 Standard_CString colstring;
768 for(Standard_Integer i=0;i<=514 && !Found;i++)
770 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
771 if (!strcasecmp(name,colstring)) {
772 ret = (Quantity_NameOfColor)i;
773 Found = Standard_True;
780 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
783 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
784 if(myAISContext.IsNull()) {
785 di << "use 'vinit' command before " << argv[0] << "\n";
789 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
795 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
797 // Change the background color of the view with a predefined name Graphic3d_NOC_<name>
799 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
800 myV3dView -> Redraw();
806 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
807 // setcolor <object> <name>
808 // Change the object color with a predefined name
810 TopoDS_Shape aShape = DBRep::Get(argv[1]);
811 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
812 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
813 myAISContext->Display(myShape,Standard_True);
814 myAISContext->UpdateCurrentViewer();
820 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
822 // setcolor <r> <g> <b>
823 // Change the background color of the view with the color values <r>,<g>,<b>
824 // A color value must be defined in the space [0.,1.]
826 Standard_Real QuantityOfRed = Draw::Atoi(argv[1]);
827 Standard_Real QuantityOfGreen = Draw::Atoi(argv[2]);
828 Standard_Real QuantityOfBlue = Draw::Atoi(argv[3]);
829 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
836 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
838 // setcolor <object> <r> <g> <b>
839 // change the object color with RGB values.
842 Standard_Real QuantityOfRed = Draw::Atof(argv[2]);
843 Standard_Real QuantityOfGreen = Draw::Atof(argv[3]);
844 Standard_Real QuantityOfBlue = Draw::Atof(argv[4]);
846 TopoDS_Shape aShape = DBRep::Get(argv[1]);
847 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
848 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
849 myAISContext->Display(myShape,Standard_True);
850 myAISContext->UpdateCurrentViewer();
851 // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
852 // myShape->Redisplay();
859 static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
861 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
862 if(myAISContext.IsNull()) {
863 di << "use 'vinit' command before " << argv[0] << "\n";
868 di << "Usage : " << argv[0] << " 0/1" << "\n";
871 if(Draw::Atoi(argv[1]) == 0) {
872 myAISContext->CloseAllContexts();
873 BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.);
874 Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());
875 myAISContext->Display(aBox);
876 } else if(Draw::Atoi(argv[1]) == 1) {
877 myAISContext->CloseAllContexts();
878 myAISContext->OpenLocalContext();
879 myAISContext->ActivateStandardMode(TopAbs_EDGE);
880 } else if(Draw::Atoi(argv[1]) == 2) {
881 myAISContext->CloseAllContexts();
882 myAISContext->OpenLocalContext();
883 myAISContext->ActivateStandardMode(TopAbs_FACE);
885 di << "Usage : " << argv[0] << " 0/1" << "\n";
892 #include <BRepBndLib.hxx>
893 #include <Bnd_HArray1OfBox.hxx>
895 static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ )
898 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
900 BRepBndLib::Add(aShape , aMainBox );
902 Standard_Integer siMaxNbrBox = 6;
903 Bnd_BoundSortBox m_BoundSortBox;
904 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
905 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
909 // Bnd_Box __emptyBox; // Box is void !
910 // Handle_Bnd_HArray1OfBox __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
912 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
914 const TopoDS_Shape& aFace = aExplorer.Current();
916 BRepBndLib::Add( aFace, aBox );
917 m_BoundSortBox.Add( aBox, i );
918 // __aSetOfBox->SetValue( i, aBox );
920 // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
925 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
927 TCollection_AsciiString as1("");
928 TCollection_AsciiString as2('\0');
929 if(as1.ToCString() == NULL || as1.Length() != 0 || as1.ToCString()[0] != '\0')
930 di << "Error : the first string is not zero string : " << as1.ToCString() << "\n";
932 if(as2.ToCString() == NULL || as2.Length() != 0 || as2.ToCString()[0] != '\0')
933 di << "Error : the second string is not zero string : " << as2.ToCString() << "\n";
938 #include <UnitsAPI.hxx>
940 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
942 di <<"Program Test" << "\n";
943 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
944 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
949 #include <gp_Circ.hxx>
950 #include <Geom_Circle.hxx>
951 #include <GeomAPI.hxx>
952 #include <Geom2d_CartesianPoint.hxx>
953 #include <Geom2dGcc_QualifiedCurve.hxx>
954 #include <Geom2dGcc_Circ2d2TanRad.hxx>
955 #include <Geom2d_Circle.hxx>
956 #include <ProjLib.hxx>
958 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
960 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
961 if(aContext.IsNull()) {
962 di << "use 'vinit' command before " << argv[0] << "\n";
966 gp_Pnt pt3d(0, 20, 150);
967 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
968 gp_Circ circ(anAx2, 50.0);
969 Handle_Geom_Circle gcir = new Geom_Circle(circ);
970 Handle_Geom_Plane pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
971 Handle_Geom2d_Curve gcir1 = GeomAPI::To2d(gcir, pln->Pln());
972 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
973 Handle_AIS_Shape ais1 = new AIS_Shape(sh1);
974 aContext->SetColor(ais1, Quantity_NOC_INDIANRED);
975 aContext->Display(ais1);
976 DBRep::Set("sh0",sh1);
978 // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
979 thepoint = ProjLib::Project(pln->Pln(),pt3d);
980 Handle_Geom2d_CartesianPoint ThePoint = new Geom2d_CartesianPoint(thepoint);
981 Geom2dAdaptor_Curve acur1(gcir1) ;
982 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
983 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
984 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
985 Handle_Geom2d_Circle gccc;
986 if( cirtanrad.NbSolutions() ) {
987 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
988 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
989 gccc = new Geom2d_Circle(ccc);
990 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
991 Standard_Character aStr[5];
992 Sprintf(aStr,"sh%d",i);
994 Handle_AIS_Shape ais = new AIS_Shape(sh);
996 aContext->SetColor(ais, Quantity_NOC_GREEN);
998 aContext->SetColor(ais, Quantity_NOC_HOTPINK);
999 aContext->Display(ais);
1000 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
1001 gp_Pnt2d PntSol1, PntSol2;
1002 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
1003 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
1004 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
1005 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
1011 #include <TColgp_Array2OfPnt.hxx>
1012 #include <Geom_BezierSurface.hxx>
1013 #include <BRepBuilderAPI_MakeFace.hxx>
1014 #include <BRepBuilderAPI_MakeWire.hxx>
1015 #include <Geom_OffsetSurface.hxx>
1016 #include <BRepFilletAPI_MakeFillet2d.hxx>
1017 #include <GeomProjLib.hxx>
1018 #include <Geom_TrimmedCurve.hxx>
1020 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1024 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
1025 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
1026 Standard_Real f = 0.0, l = 0.0;
1027 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
1028 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
1029 GC = new Geom_TrimmedCurve(GC, f, l);
1030 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
1031 BRepBuilderAPI_MakeWire *myWire;
1032 myWire = new BRepBuilderAPI_MakeWire();
1033 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
1034 DBRep::Set(argv[1],myWire->Wire());
1038 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1039 if(aContext.IsNull()) {
1040 di << "use 'vinit' command before " << argv[0] << "\n";
1044 //step 1. creating a Bezier Surface and a patch
1048 Handle(AIS_Shape) ais1;
1049 Handle_AIS_Shape ais2;
1050 Handle(Geom_BezierSurface) BZ1;
1051 TColgp_Array2OfPnt array1(1,3,1,3);
1052 array1.SetValue(1,1,gp_Pnt(0,100,0));
1053 array1.SetValue(1,2,gp_Pnt(200,100,0));
1054 array1.SetValue(1,3,gp_Pnt(400,100,0));
1055 array1.SetValue(2,1,gp_Pnt(0,200,100));
1056 array1.SetValue(2,2,gp_Pnt(200,200,100));
1057 array1.SetValue(2,3,gp_Pnt(400,200,100));
1058 array1.SetValue(3,1,gp_Pnt(0,300,0));
1059 array1.SetValue(3,2,gp_Pnt(200,300,0));
1060 array1.SetValue(3,3,gp_Pnt(400,300,0));
1061 BZ1 = new Geom_BezierSurface(array1);
1062 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
1063 TopoDS_Face F1= bzf1.Face();
1064 ais1 = new AIS_Shape(F1);
1065 DBRep::Set("F1",F1);
1066 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
1067 aContext->Display(ais1);
1074 gp_Dir D(0, 0, 1.0f);
1075 BRepBuilderAPI_MakeWire mkw;
1076 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
1077 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
1078 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
1080 p1 = gp_Pnt(350., 150., 260.);
1081 p2 = gp_Pnt(350., 250., 260.);
1082 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
1084 p1 = gp_Pnt(350., 250., 260.);
1085 p2 = gp_Pnt(300., 250.0, 260.);
1086 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
1088 p1 = gp_Pnt(300., 250.0, 260.);
1089 p2 = gp_Pnt(200., 200.0, 260.);
1090 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
1092 p1 = gp_Pnt(200., 200.0, 260.);
1093 p2 = gp_Pnt(150., 200.0, 260.);
1094 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
1096 p1 = gp_Pnt(150., 200.0, 260.);
1097 p2 = gp_Pnt(150., 150.0, 260.);
1098 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
1100 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
1101 ais2 = new AIS_Shape( FP );
1102 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
1103 aContext->Display( ais2 );
1105 DBRep::Set("FP",FP);
1107 //step 2. offseting the surface.
1108 Handle_Geom_OffsetSurface offsurf;
1109 offsurf = new Geom_OffsetSurface(BZ1, -100);
1110 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
1111 TopoDS_Face F2= bzf2.Face();
1112 Handle_AIS_Shape ais22 = new AIS_Shape(F2);
1113 aContext->Display(ais22);
1114 DBRep::Set("F2",F2);
1116 //step 3. filleting the patch.
1117 //( I want to project wire of this patch on offseted surface above)
1118 BRepFilletAPI_MakeFillet2d fillet( FP );
1120 Ex.Init(FP, TopAbs_VERTEX);
1121 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
1122 fillet.AddFillet(v1, 20);
1123 di << "\n" << "Error is " << fillet.Status() << "\n";
1124 // printf("\nError is %d ", fillet.Status());
1126 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
1127 fillet.AddFillet(V2, 20);
1128 di << "\n" << "Error is " << fillet.Status() << "\n";
1129 // printf("\nError is %d ", fillet.Status());
1131 FP1 = fillet.Shape();
1132 ais2 = new AIS_Shape( FP1 );
1133 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
1134 aContext->Display( ais2 );
1136 DBRep::Set("FP1",FP1);
1138 //step 4. Projecting the wire of this patch on offsetted surface.
1139 // TopExp_Explorer Ex;
1140 BRepBuilderAPI_MakeWire *myWire;
1141 myWire = new BRepBuilderAPI_MakeWire();
1142 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
1144 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
1145 Standard_Real f = 0.0, l = 0.0;
1146 Handle_Geom_Curve newBSplin = BRep_Tool::Curve(e1, f, l);
1147 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
1148 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
1149 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
1151 Handle_AIS_Shape ais33 = new AIS_Shape( myWire->Wire() );
1152 aContext->Display(ais33);
1154 DBRep::Set("Wire",myWire->Wire());
1159 #include<GeomAPI_ExtremaCurveCurve.hxx>
1161 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1165 printf("Usage: %s edge1 edge2",argv[0]);
1169 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
1170 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
1172 Standard_Real fp , lp;
1174 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
1175 C2 = BRep_Tool::Curve(E2 , fp , lp);
1177 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
1179 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
1184 #include <BRepBuilderAPI_MakePolygon.hxx>
1185 #include <BRepOffsetAPI_ThruSections.hxx>
1187 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1190 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1193 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1195 Standard_Integer IsB = Draw::Atoi(argv[1]);
1197 IsBRepAlgoAPI = Standard_False;
1198 #if ! defined(BRepAlgo_def01)
1199 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1205 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
1206 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
1207 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
1208 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
1209 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
1211 for (int i=0;i<4;i++) {
1212 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
1213 bottompolygon1.Add(tmppnt);
1214 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
1215 toppolygon1.Add(tmppnt);
1216 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
1217 bottompolygon2.Add(tmppnt);
1218 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
1219 toppolygon2.Add(tmppnt);
1221 bottompolygon1.Close();
1222 DBRep::Set("B1",bottompolygon1.Shape());
1223 toppolygon1.Close();
1224 DBRep::Set("T1",toppolygon1.Shape());
1225 bottompolygon2.Close();
1226 DBRep::Set("B2",bottompolygon2.Shape());
1227 toppolygon2.Close();
1228 DBRep::Set("T2",toppolygon2.Shape());
1229 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
1230 loft1.AddWire(bottompolygon1.Wire());
1231 loft1.AddWire(toppolygon1.Wire());
1233 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
1234 loft2.AddWire(bottompolygon2.Wire());
1235 loft2.AddWire(toppolygon2.Wire());
1237 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
1239 DBRep::Set("TS1",loft1.Shape());
1240 DBRep::Set("TS2",loft2.Shape());
1242 //#if ! defined(BRepAlgoAPI_def01)
1243 // BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1245 // BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1247 if (IsBRepAlgoAPI) {
1248 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1249 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1250 DBRep::Set("F",result.Shape());
1252 di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1253 BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1254 DBRep::Set("F",result.Shape());
1257 // DBRep::Set("F",result.Shape());
1261 #include <Geom_RectangularTrimmedSurface.hxx>
1262 #include <GC_MakeTrimmedCone.hxx>
1264 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1266 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1267 if(aContext.IsNull()) {
1268 di << "use 'vinit' command before " << argv[0] << "\n";
1273 double R1=8, R2=16, angle;
1275 P1(0,0,20), P2(0,0,45);
1277 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
1278 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
1279 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
1280 aContext->Display(ais1);
1281 aContext->SetColor(ais1, Quantity_NOC_BLUE1);
1283 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
1284 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
1285 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
1286 aContext->Display(ais2);
1287 aContext->SetColor(ais2, Quantity_NOC_RED);
1291 //==========================================================================
1292 //function : CoordLoad
1293 // chargement d une face dans l explorer.
1294 //==========================================================================
1295 static Standard_Integer coordload (Draw_Interpretor& theDi,
1296 Standard_Integer theArgsNb,
1297 const char** theArgVec)
1304 std::ifstream aFile (theArgVec[2], ios::in);
1307 theDi << "unable to open " << theArgVec[2] << " for input\n";
1312 memset (aLine, 0, 40);
1313 aFile.getline (aLine, 80);
1315 gp_Pnt aPnt (0.0, 0.0, 0.0);
1317 aPnt.SetY (Draw::Atof (&aLine[20]));
1319 aPnt.SetX (Draw::Atof (aLine));
1320 TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt);
1321 BRepBuilderAPI_MakeWire aMakeWire;
1324 memset (aLine, 0, 40);
1325 aFile.getline (aLine, 80);
1332 aPnt.SetY (Draw::Atof (&aLine[20]));
1334 aPnt.SetX (Draw::Atof (aLine));
1335 TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt);
1336 aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2));
1341 if (!aMakeWire.IsDone())
1343 DBRep::Set (theArgVec[1], TopoDS_Face());
1347 BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire());
1348 DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face());
1352 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
1353 Standard_Integer /*nb*/,
1354 const char ** /*arg*/)
1356 TCollection_ExtendedString aString(1024*1024, 'A');
1360 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
1361 Standard_Integer argc,
1364 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1365 if(aContext.IsNull()) {
1366 di << "use 'vinit' command before " << argv[0] << "\n";
1369 if((argc != 2) && (argc != 3)) {
1370 di<< "usage : " << argv[0] << " shape [mode==1]" << "\n";
1373 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1374 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
1375 // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
1376 anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
1377 aContext->Display(anIO);
1381 //=======================================================================
1382 //function : buc60773
1384 //=======================================================================
1386 #include<TCollection_HAsciiString.hxx>
1388 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
1390 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
1391 Standard_CString aStr = hAscii->ToCString();
1392 TCollection_AsciiString aAscii(aStr);
1397 #include<BRepPrimAPI_MakeCylinder.hxx>
1398 #include<BRepPrimAPI_MakeCone.hxx>
1400 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1404 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1407 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1409 Standard_Integer IsB = Draw::Atoi(argv[1]);
1411 IsBRepAlgoAPI = Standard_False;
1412 #if ! defined(BRepAlgo_def01)
1413 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1419 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
1421 Standard_Real x11 = 36.085182;
1422 Standard_Real y11 = 20.0;
1423 Standard_Real z11 = 8.431413;
1424 Standard_Real x12 = 88.04671;
1425 Standard_Real y12 = 20.0;
1426 Standard_Real z12 = 38.931416;
1427 Standard_Real radius = 10.0;
1429 gp_Pnt base1(x11, y11, z11);
1430 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
1431 gp_Ax2 axis1(base1, vect1);
1432 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
1433 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
1435 TopoDS_Shape SCyl = cylinder.Shape();
1436 DBRep::Set("cyl", SCyl);
1439 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
1440 Standard_Real x21 = 70.7262;
1441 Standard_Real y21 = 20.0;
1442 Standard_Real z21 = 28.431412;
1443 Standard_Real x22 = 105.36722;
1444 Standard_Real y22 = 20.0;
1445 Standard_Real z22 = 48.431416;
1446 Standard_Real radius1 = 6.0;
1447 Standard_Real radius2 = 3.0;
1449 gp_Pnt base2(x21, y21, z21);
1450 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
1451 gp_Ax2 axis2(base2, vect2);
1452 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
1453 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1455 TopoDS_Shape SCon = cone.Shape();
1456 DBRep::Set("con", SCon);
1458 //#if ! defined(BRepAlgoAPI_def01)
1459 // BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1461 // BRepAlgo_Fuse SFuse(SCyl, SCon);
1464 // if(! SFuse.IsDone() )
1465 // cout<<"Error: Boolean fuse operation failed !"<<endl;
1467 // TopoDS_Shape fuse = SFuse.Shape();
1470 if (IsBRepAlgoAPI) {
1471 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n";
1472 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1473 if(! SFuse.IsDone() )
1474 di<<"Error: Boolean fuse operation failed !"<<"\n";
1475 fuse = SFuse.Shape();
1477 di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n";
1478 BRepAlgo_Fuse SFuse(SCyl, SCon);
1479 if(! SFuse.IsDone() )
1480 di<<"Error: Boolean fuse operation failed !"<<"\n";
1481 fuse = SFuse.Shape();
1484 DBRep::Set("fus", fuse);
1489 #include <Dico_DictionaryOfInteger.hxx>
1490 #include <TColStd_HSequenceOfAsciiString.hxx>
1491 #include <TopExp.hxx>
1492 #include <TopoDS_Iterator.hxx>
1494 //---------------------------------------------------------------------------------------
1496 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1499 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1502 di<<"Invalid input shape"<<"\n";
1505 Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
1506 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1507 Standard_CString aString;
1508 Standard_Integer i=1,j=1,l=1,aa=1;
1509 TopExp_Explorer expl;
1510 Standard_Real f3d,l3d;
1511 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1514 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1515 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1516 aString = aSurface->DynamicType()->Name();
1518 if(aDico->GetItem(aString,aa) != 0)
1520 aDico->GetItem(aString,aa);
1521 aDico->SetItem(aString,aa+1);
1523 aDico->SetItem(aString,1);
1524 aSequence->Append(aString);
1530 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1532 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1533 TopoDS_Iterator anIt(aFace);
1534 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1535 TopoDS_Iterator it (aWire);
1536 for (; it.More(); it.Next()) {
1537 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1538 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1539 aString = aCurve2d->DynamicType()->Name();
1540 if(aDico->GetItem(aString,aa) != 0)
1542 aDico->GetItem(aString,aa);
1543 aDico->SetItem(aString,aa+1);
1545 aDico->SetItem(aString,1);
1546 aSequence->Append(aString);
1553 TopExp_Explorer exp;
1554 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
1556 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1557 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1558 if(aCurve3d.IsNull())
1563 aString = aCurve3d->DynamicType()->Name();
1564 if(aDico->GetItem(aString,aa) != 0)
1566 aDico->GetItem(aString,aa);
1567 aDico->SetItem(aString,aa+1);
1569 aDico->SetItem(aString,1);
1570 aSequence->Append(aString);
1580 aDico->GetItem(aSequence->Value(j),aa);
1581 di<<aa<<" -- "<<aSequence->Value(j).ToCString()<<"\n";
1585 di<<"Degenerated edges :"<<"\n";
1586 di<<l<<" -- "<<"Degenerated edges "<<"\n";
1592 #include <BRepBuilderAPI_Transform.hxx>
1594 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1597 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1600 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1602 Standard_Integer IsB = Draw::Atoi(argv[1]);
1604 IsBRepAlgoAPI = Standard_False;
1605 #if ! defined(BRepAlgo_def01)
1606 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1612 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1613 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1614 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1616 TopoDS_Shape sh1 = cyl.Shape();
1617 DBRep::Set("sh1",sh1);
1618 gp_Trsf trsf1, trsf2;
1619 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1620 gp_Pnt(0.000000,700.000000,-95.000000));
1621 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1622 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1623 BRepBuilderAPI_Transform trans1(sh1, trsf1);
1624 TopoDS_Shape sh2 = trans1.Shape();
1625 DBRep::Set("sh2",sh2);
1627 //#if ! defined(BRepAlgoAPI_def01)
1628 // BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1630 // BRepAlgo_Fuse fuse1(sh1, sh2);
1633 // TopoDS_Shape fsh1 = fuse1.Shape();
1636 if (IsBRepAlgoAPI) {
1637 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n";
1638 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1639 fsh1 = fuse1.Shape();
1641 di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n";
1642 BRepAlgo_Fuse fuse1(sh1, sh2);
1643 fsh1 = fuse1.Shape();
1646 DBRep::Set("fsh1",fsh1);
1647 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1648 TopoDS_Shape sh3 = trans2.Shape();
1649 DBRep::Set("sh3",sh3);
1651 //#if ! defined(BRepAlgoAPI_def01)
1652 // BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1654 // BRepAlgo_Fuse fuse2(fsh1,sh3);
1657 // TopoDS_Shape fsh2 = fuse2.Shape();
1660 if (IsBRepAlgoAPI) {
1661 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n";
1662 BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1663 fsh2 = fuse2.Shape();
1665 di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n";
1666 BRepAlgo_Fuse fuse2(fsh1,sh3);
1667 fsh2 = fuse2.Shape();
1670 DBRep::Set("fsh2",fsh2);
1671 Handle_AIS_Shape aisp1 = new AIS_Shape(fsh2);
1672 // aContext->Display(aisp1);
1676 #include <ShapeBuild_Edge.hxx>
1678 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1680 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1681 ShapeBuild_Edge().BuildCurve3d(e);
1687 #include<TDF_Label.hxx>
1688 #include<TDataStd_TreeNode.hxx>
1690 #include<DDocStd.hxx>
1694 #include<TDocStd_Modified.hxx>
1695 #include<TDF_ListIteratorOfDeltaList.hxx>
1696 #include<TDocStd_Document.hxx>
1697 #include<TDocStd_Application.hxx>
1698 #include<TDF_Delta.hxx>
1699 #include<TDataXtd_Constraint.hxx>
1700 #include<TPrsStd_AISPresentation.hxx>
1701 #include<TPrsStd_AISViewer.hxx>
1702 #include<TNaming_Builder.hxx>
1703 #include<TNaming_Naming.hxx>
1704 #include<TNaming_NamedShape.hxx>
1706 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1708 di << "Usage : " << argv[0] << " D" << "\n";
1713 Handle(TDF_Data) DF;
1714 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1717 Handle(TDataStd_TreeNode) TN1,TN2;
1719 DDF::AddLabel(DF,"0:2",L1);
1720 TN1 = TDataStd_TreeNode::Set(L1);
1722 DDF::AddLabel(DF,"0:3",L2);
1723 TN2 = TDataStd_TreeNode::Set(L2);
1726 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1727 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1733 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1735 di << "Usage : " << argv[0] << " D" << "\n";
1740 Handle(TDF_Data) DF;
1741 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1744 DDF::FindLabel(DF,"0:1",L,Standard_False);
1745 Handle(TDocStd_Modified) MDF;
1746 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1747 MDF = new TDocStd_Modified();
1748 L.Root().AddAttribute(MDF);
1751 di<<!MDF->IsEmpty();
1755 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1757 di << "Usage : " << argv[0] << " D Label" << "\n";
1762 Handle(TDF_Data) DF;
1763 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1766 DDF::FindLabel(DF,argv[2],L,Standard_False);
1768 TDocStd_Modified::Add(L);
1774 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1776 di << "Usage : " << argv[0] << " D" << "\n";
1782 Handle(TDF_Data) aDF;
1783 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1785 Handle(TDocStd_Document) aDocument;
1786 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1789 Handle(TDataStd_TreeNode) TN;
1791 aDocument->NewCommand();
1792 DDF::AddLabel(aDF,"0:2",L);
1793 TN = TDataStd_TreeNode::Set(L);
1795 aDocument->NewCommand();
1796 DDF::AddLabel(aDF,"0:3",L);
1797 TN = TDataStd_TreeNode::Set(L);
1799 aDocument->NewCommand();
1800 DDF::AddLabel(aDF,"0:4",L);
1801 TN = TDataStd_TreeNode::Set(L);
1802 aDocument->NewCommand();
1804 TDF_DeltaList Us,Rs;
1805 Us = aDocument->GetUndos();
1806 Rs = aDocument->GetUndos();
1809 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1811 TDF_ListIteratorOfDeltaList IDL;
1812 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1813 Handle(TDF_Delta) D = IDL.Value();
1814 TCollection_ExtendedString S(Names[i-1]);
1816 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1822 Us = aDocument->GetUndos();
1823 Rs = aDocument->GetRedos();
1825 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1826 Handle(TDF_Delta) D = IDL.Value();
1827 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1830 TCollection_ExtendedString n2name ("n2");
1831 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1832 Handle(TDF_Delta) D = IDL.Value();
1833 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1844 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1846 di << "Usage : " << argv[0] << " D Shape" << "\n";
1851 Handle(TDF_Data) aDF;
1852 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1854 TopoDS_Shape s = DBRep::Get(argv[2]);
1855 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1857 DDF::AddLabel(aDF, "0:2", L);
1858 TNaming_Builder SI (L);
1861 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1865 // if (!NS->IsEmpty()) {di<<3;return 0;}
1866 if (NS->IsEmpty()) {di<<4;return 0;}
1871 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1873 di << "Usage : " << argv[0] << " D Shape" << "\n";
1878 Handle(TDF_Data) aDF;
1879 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1881 TopoDS_Shape s = DBRep::Get(argv[2]);
1882 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1884 DDF::AddLabel(aDF, "0:2", L);
1885 TNaming_Builder SI (L);
1888 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1892 if (NS->IsEmpty()) {di<<4;return 0;}
1897 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1899 TCollection_ExtendedString path (argv[1]);
1900 Handle(TDocStd_Application) A;
1901 if (!DDocStd::Find(A)) {di<<1;return 0;}
1902 Handle(TDocStd_Document) D;
1903 Standard_Integer insession = A->IsInSession(path);
1904 if (insession > 0) {
1905 di <<"document " << insession << " is already in session" << "\n";
1909 PCDM_ReaderStatus Result = A->Open(path,D);
1910 if(Result==PCDM_RS_OK){
1919 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1921 di << "Usage : " << argv[0] << " D" << "\n";
1926 Handle(TDF_Data) aDF;
1927 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1930 DDF::AddLabel(aDF, "0:2", L);
1932 Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation;
1934 AISP->Set(L,TDataXtd_Constraint::GetID());
1936 if (AISP->HasOwnMode()) {di<<3;return 0;}
1938 Standard_Integer Mode = AISP->Mode();
1939 if (Mode!=3) {di<<4;return 0;}
1940 if (!AISP->HasOwnMode()) {di<<5;return 0;}
1942 if (AISP->HasOwnMode()) {di<<6;return 0;}
1947 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1949 di << "Usage : " << argv[0] << " D" << "\n";
1954 Handle(TDF_Data) aDF;
1955 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1958 DDF::AddLabel(aDF, "0:2", L);
1962 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1963 // Handle(TNaming_Name) NN = new TNaming_Name;
1966 NN.Type(TNaming_IDENTITY);
1968 Standard_Boolean Res = NN.Solve(L,LM);
1970 if (Res!=Standard_False) {di<<3;return 0;}
1975 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1977 di << "Usage : " << argv[0] << " D" << "\n";
1983 Handle(TDocStd_Document) aDocument;
1984 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
1986 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
1987 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
1993 //=======================================================================
1994 //function : AISWidth
1995 //purpose : AISWidth (DOC,entry,[width])
1996 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
1997 //=======================================================================
1999 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2002 Handle(TDocStd_Document) D;
2003 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
2005 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
2007 Handle(TPrsStd_AISViewer) viewer;
2008 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
2010 Handle(TPrsStd_AISPresentation) prs;
2011 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2013 prs->SetWidth(Draw::Atof(argv[3]));
2014 TPrsStd_AISViewer::Update(L);
2017 if (prs->HasOwnWidth()){
2018 // cout << "Width = " << prs->Width() << endl;
2022 di << "AISWidth: Warning : Width wasn't set" << "\n";
2029 di << "AISWidth : Error" << "\n";
2034 //=======================================================================
2035 //function : BUC60921 ( & BUC60954 )
2036 //purpose : Test memory allocation of OCAF in Undo/Redo operations
2037 //=======================================================================
2039 static Standard_Integer BUC60921 (Draw_Interpretor& di,
2040 Standard_Integer nb,
2044 Handle(TDocStd_Document) D;
2045 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
2047 DDF::AddLabel(D->GetData(),arg[2],L);
2051 BRepTools::Read ( S, arg[3], B );
2053 TNaming_Builder tnBuild(L);
2054 tnBuild.Generated(S);
2055 // di << "File " << arg[3] << " added";
2059 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
2064 #include<IGESControl_Reader.hxx>
2065 #include<BRepPrimAPI_MakeHalfSpace.hxx>
2067 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
2071 // cerr << "Usage : " << a[0] << " file.igs" << endl;
2074 if(argc < 2 || argc > 3) {
2075 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2078 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2080 Standard_Integer IsB = Draw::Atoi(a[2]);
2082 IsBRepAlgoAPI = Standard_False;
2083 #if ! defined(BRepAlgo_def01)
2084 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
2090 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
2092 if(myContext.IsNull()) {
2093 di << "use 'vinit' command before " << a[0] << "\n";
2097 // IGESControlStd_Reader reader;
2098 IGESControl_Reader reader;
2099 reader.ReadFile(a[1]);
2100 reader.TransferRoots();
2101 TopoDS_Shape shape = reader.OneShape();
2102 printf("\n iges1 shape type = %d", shape.ShapeType() );
2103 TopTools_IndexedMapOfShape list;
2104 TopExp::MapShapes(shape, TopAbs_FACE, list);
2105 printf("\n No. of faces = %d", list.Extent());
2108 BRep_Builder builder;
2109 builder.MakeShell(shell);
2110 for(int i=1;i<=list.Extent(); i++) {
2111 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
2112 builder.Add(shell, face);
2115 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
2116 TopoDS_Solid sol = half.Solid();
2117 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
2118 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
2119 TopoDS_Shape sh = cyl.Shape();
2121 //#if ! defined(BRepAlgoAPI_def01)
2122 // BRepAlgoAPI_Fuse fuse(sol, sh);
2124 // BRepAlgo_Fuse fuse(sol, sh);
2127 // sh = fuse.Shape();
2129 if (IsBRepAlgoAPI) {
2130 di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n";
2131 BRepAlgoAPI_Fuse fuse(sol, sh);
2134 di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n";
2135 BRepAlgo_Fuse fuse(sol, sh);
2139 Handle(AIS_Shape) res = new AIS_Shape(sh);
2140 myContext->Display( res );
2144 void QABugs::Commands_3(Draw_Interpretor& theCommands) {
2145 const char *group = "QABugs";
2147 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
2148 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
2149 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
2150 theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group);
2152 theCommands.Add("UKI61075","UKI61075",__FILE__,UKI61075,group);
2154 theCommands.Add("BUC60585",St,__FILE__,BUC60585,group);
2155 theCommands.Add("BUC60547","BUC60547 name",__FILE__,BUC60547,group);
2156 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
2157 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
2158 theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2159 theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2160 theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2161 theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2162 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
2164 theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
2165 theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
2166 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
2167 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
2169 theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
2170 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
2171 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
2172 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
2173 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
2174 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
2176 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
2178 theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
2180 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
2182 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
2184 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
2185 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
2186 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
2187 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
2189 theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
2191 theCommands.Add("statface","statface face",__FILE__,statface,group);
2193 theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
2195 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
2197 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
2198 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
2199 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
2200 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
2201 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
2202 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
2203 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
2204 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
2205 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
2206 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
2207 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
2208 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
2210 theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );