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) {
144 printf("Usage: %s draw_format_face\n [name] [interactive (0|1)]",argv[0]);
149 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
150 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
152 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
155 Standard_Character *file1 = new Standard_Character [strlen(DD)+strlen(argv[1])+2];
156 sprintf(file1,"%s/%s",DD,argv[1]);
160 if (!fic.open(file1,ios::in)) {
161 di << "Cannot open file for reading : " << file1 << "\n";
166 TopoDS_Shape theShape;
170 if( !strcmp(typ, "DBRep_DrawableShape") ){
172 BRepTools_ShapeSet S(B);
176 di << "Wrong entity type in " << file1 << "\n";
182 const TopoDS_Face &face = TopoDS::Face (theShape);
185 DBRep::Set(argv[2],face);
188 Standard_Boolean inter=Standard_False ;
191 inter= (atof(argv[3]) == 0) ? Standard_False : Standard_True ;
194 Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
196 BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
198 di << "The bounds of the trimmed face:" << "\n";
199 di << faceUMin << " <= U <= " << faceUMax << "\n";
200 di << faceVMin << " <= V <= " << faceVMax << "\n";
202 Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
204 TopOpeBRep_PointClassifier PClass;
206 di << "Now test the point classifier by inputting U,V values" << "\n";
207 di << "inside or outside the bounds displayed above" << "\n";
208 di << "Type stop to exit" << "\n";
210 // Please register this:
211 // ***********************************************
212 // Note also that for periodic surfaces such as nimpod_1.topo,
213 // the U/V values may be +- 2pi compared to the actual face bounds
214 // (because U,V is probably coming from a Geom package routine).
215 // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
216 // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
217 // *************************************************
218 if(inter && (argc != 6)) {
220 di << "Input U: " << "\n";
226 di << "Input V: " << "\n";
233 uvSurf = gp_Pnt2d(U, V);
235 //gp_Pnt2d uvSurf(0.14,5.1); // outside!!!
236 //gp_Pnt2d uvSurf2(1.28,5.1); // inside
238 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
239 if(state == TopAbs_IN || state == TopAbs_ON){
240 di << "U=" << U << " V=" << V << " classified INSIDE" << "\n";
242 di << "U=" << U << " V=" << V << " classified OUTSIDE" << "\n";
247 uvSurf = gp_Pnt2d(0.14,5.1);
248 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
249 if(state == TopAbs_IN || state == TopAbs_ON){
250 di << "U=" << 0.14 << " V=" << 5.1 << " classified INSIDE" << "\n";
252 di << "U=" << 0.14 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
255 uvSurf = gp_Pnt2d(1.28,5.1);
256 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
257 if(state == TopAbs_IN || state == TopAbs_ON){
258 di << "U=" << 1.28 << " V=" << 5.1 << " classified INSIDE" << "\n";
260 di << "U=" << 1.28 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
263 uvSurf = gp_Pnt2d(atof(argv[4]),atof(argv[5]));
264 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
265 if(state == TopAbs_IN || state == TopAbs_ON){
266 di << "U=" << atof(argv[4]) << " V=" << atof(argv[5]) << " classified INSIDE" << "\n";
268 di << "U=" << atof(argv[4]) << " V=" << atof(argv[5]) << " classified OUTSIDE" << "\n";
276 void stringerror(int state)
278 printf("%s",((state&ios::eofbit) !=0)? " [eof]": "");
279 printf("%s",((state&ios::failbit)!=0)? " [fail]":"");
280 printf("%s",((state&ios::badbit) !=0)? " [bad]": "");
281 printf("%s\n",(state==ios::goodbit)? " [ok]": "");
286 //#include <strstream>
288 //#include <strstream.h>
294 #elif defined (HAVE_IOSTREAM_H)
295 #include <iostream.h>
296 #include <strstream.h>
298 #error "check config.h file or compilation options: either HAVE_IOSTREAM or HAVE_IOSTREAM_H should be defined"
300 static int UKI61075(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** /*argv*/) {
303 #ifndef USE_STL_STREAM
304 ostrstream stringout1(buffer1,sizeof(buffer1));
305 istrstream stringin1(buffer1,sizeof(buffer1));
307 ostringstream stringout1(buffer1);
308 istringstream stringin1(buffer1);
311 #ifndef USE_STL_STREAM
312 ostrstream stringout2(buffer2,sizeof(buffer2));
313 istrstream stringin2(buffer2,sizeof(buffer2));
315 ostringstream stringout2(buffer1);
316 istringstream stringin2(buffer1);
319 stringout1.precision(17);
320 stringout2.precision(17);
324 printf("Valeurs originales :\n\t%.17lg %.17lg\n",da,db);
326 stringout1<<da<<' '<<db<<"\n";
327 #ifndef USE_STL_STREAM
328 buffer1[stringout1.pcount()]='\0';
330 buffer1[stringout1.str().length()]= '\0' ;
333 printf("Valeurs ecrites dans le fichier :\n\t%s",buffer1);
337 printf("Valeurs relues :\n\t%.17lg %.17lg",da,db);
338 stringerror(stringin1.rdstate());
340 stringout2<<da<<' '<<db<<"\n";
341 #ifndef USE_STL_STREAM
342 buffer2[stringout2.pcount()]='\0';
344 buffer2[stringout2.str().length()]='\0';
347 printf("Valeurs reecrites :\n\t%s",buffer2);
351 printf("Valeurs relues a nouveau :\n\t%.17lg %.17lg",da,db);
352 stringerror(stringin2.rdstate());
358 #include<BRepAlgoAPI_Section.hxx>
359 #include<BRepAlgo_Section.hxx>
361 #include<Geom_Plane.hxx>
362 #include<DrawTrSurf.hxx>
364 //static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane]";
365 static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane] [BRepAlgoAPI/BRepAlgo = 1/0]";
367 static int BUC60585(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
370 // cerr << "Usage : " << argv[0] << St << endl;
373 if(argc < 2 || argc > 6) {
374 di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
377 Standard_Boolean IsBRepAlgoAPI = Standard_True;
379 Standard_Integer IsB = atoi(argv[5]);
381 IsBRepAlgoAPI = Standard_False;
382 #if ! defined(BRepAlgo_def04)
383 // di << "Error: There is not BRepAlgo_Section class" << "\n";
391 if(!strcmp(argv[1],"trimsphere")) {
392 //////////////////////////////////////////
393 // Uncomment for trimmed sphere bug:
394 // filename = "trimsphere.topo";
395 N=gp_Dir( 0.0, -1.0, 0.0 );
396 //////////////////////////////////////////
397 } else if(!strcmp(argv[1],"sphere")) {
399 //////////////////////////////////////////
400 // Uncomment for untrimmed sphere bug:
402 // filename="sphere.topo";
403 N=gp_Dir( 0.0, -0.75103523489975432, -0.66026212668838646 );
405 //////////////////////////////////////////
407 di << "Usage : " << argv[0] << St << "\n";
412 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
413 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
415 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
418 Standard_Character *filename = new Standard_Character [strlen(DD)+17];
419 sprintf(filename,"%s/%s.topo",DD,argv[1]);
423 if (!fic.open(filename,ios::in)) {
424 di << "Cannot open file for reading : " << filename << "\n";
432 BRepTools_ShapeSet S(B);
434 TopoDS_Shape theShape;
439 gp_Pnt O( 2036.25, -97.5, -1460.499755859375 );
440 gp_Dir A( 1.0, 0.0, 0.0 );
442 gp_Ax3 PLA( O, N, A );
445 // Perform the section
447 //#if ! defined(BRepAlgoAPI_def01)
448 // BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
450 // BRepAlgo_Section Sec( theShape, Pl, Standard_False);
457 // Sec.Approximation(Standard_True);
461 // cout << "Error performing intersection: not done." << endl;
468 di << "BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False)" <<"\n";
469 BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
472 di << "Error performing intersection: not done." << "\n";
478 di << "BRepAlgo_Section Sec( theShape, Pl, Standard_False)" <<"\n";
479 BRepAlgo_Section Sec( theShape, Pl, Standard_False);
482 di << "Error performing intersection: not done." << "\n";
489 }catch(Standard_Failure){
490 Handle(Standard_Failure) error = Standard_Failure::Caught();
491 di << "Error performing intersection: not done." << "\n";
496 if(argc>3) DBRep::Set(argv[3],theShape);
498 if(argc>2) DBRep::Set(argv[2],res);
501 Handle(Geom_Geometry) result;
502 Handle(Geom_Plane) C = new Geom_Plane(Pl);
504 DrawTrSurf::Set(argv[4],result);
507 di << "Done" << "\n";
514 #include<TopoDS_Compound.hxx>
516 static int BUC60547(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
518 di << "Usage : " << argv[0] << " name" << "\n";
522 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
523 if(myAISContext.IsNull()) {
524 di << "use 'vinit' command before " << argv[0] << "\n";
529 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
530 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
532 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
535 Standard_Character *Ch = new Standard_Character[strlen(argv[1])+3];
537 Standard_Character *FileName = new Standard_Character[strlen(DD)+13];
539 TopoDS_Shape free_1,free_2,free_3,free_4;
541 sprintf(FileName,"%s/%s",DD,"buc60547a.brep");
542 BRepTools::Read(free_1,FileName,B);
543 sprintf(FileName,"%s/%s",DD,"buc60547b.brep");
544 BRepTools::Read(free_2,FileName,B);
545 sprintf(FileName,"%s/%s",DD,"buc60547c.brep");
546 BRepTools::Read(free_3,FileName,B);
547 sprintf(FileName,"%s/%s",DD,"buc60547d.brep");
548 BRepTools::Read(free_4,FileName,B);
549 sprintf(Ch,"%s_%i",argv[1],1);
550 DBRep::Set(Ch,free_1);
552 sprintf(Ch,"%s_%i",argv[1],2);
553 DBRep::Set(Ch,free_2);
555 sprintf(Ch,"%s_%i",argv[1],3);
556 DBRep::Set(Ch,free_3);
558 sprintf(Ch,"%s_%i",argv[1],4);
559 DBRep::Set(Ch,free_4);
562 // Handle(AIS_Shape) S1 = new AIS_Shape(free_1);
563 // Handle(AIS_Shape) S2 = new AIS_Shape(free_2);
564 // Handle(AIS_Shape) S3 = new AIS_Shape(free_3);
565 // Handle(AIS_Shape) S4 = new AIS_Shape(free_4);
567 // Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
569 // myAISContext->Display(S1);
570 // myAISContext->Display(S2);
571 // myAISContext->Display(S3);
572 // myAISContext->Display(S4);
578 bui.MakeCompound(Com);
584 sprintf(Ch,"%s_%c",argv[1],'c');
588 Handle(AIS_Shape) SC = new AIS_Shape(Com);
589 myAISContext->Display(SC); // nothing on the screen If I save the compound :
591 sprintf(FileName,"%s/%s",DD,"free.brep");
593 BRepTools::Write(Com,FileName);
601 #include<BRepBuilderAPI_MakeVertex.hxx>
602 #include<TCollection_ExtendedString.hxx>
603 #include<AIS_LengthDimension.hxx>
605 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
608 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
609 if(myAIScontext.IsNull()) {
610 di << "use 'vinit' command before " << a[0] << "\n";
613 myAIScontext->EraseAll();
615 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
616 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
618 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
619 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
621 myAIScontext->Display(Ve1);
622 myAIScontext->Display(Ve2);
624 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
625 TCollection_ExtendedString Ext1("Dim1");
626 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1,atof(a[2]),Ext1);
628 myAIScontext->SetDisplayMode(Dim1, atof(a[1]));
629 myAIScontext->Display(Dim1);
633 #include<TopoDS_Wire.hxx>
635 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
638 di << "Usage : BUC60652 fase" << "\n";
641 TopoDS_Shape shape = DBRep::Get( argv[1] );
642 TopoDS_Face face = TopoDS::Face( shape );
643 TopoDS_Wire ow = BRepTools::OuterWire( face );
644 DBRep::Set( "w", ow );
648 #include <BRepAlgo_BooleanOperations.hxx>
650 static Standard_Integer defNbPntMax = 30;
651 static Standard_Real defTol3d = 1.e-7;
652 static Standard_Real defTol2d = 1.e-7;
653 static Standard_Boolean defRelativeTol=Standard_True;
654 Standard_Integer NbPntMax = defNbPntMax;
655 Standard_Real Toler3d =defTol3d;
656 Standard_Real Toler2d = defTol2d;
657 Standard_Boolean RelativeTol= defRelativeTol;
658 // //== // ksection : operateur section appelant BRepAlgo_BooleanOperation
659 //== // ksection : operateur section appelant BRepAlgo_BooleanOperations
660 //=======================================================================
661 Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) {
663 di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol" << "\n";
673 TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL);
674 TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL);
675 if (s1.IsNull() || s2.IsNull()) return 1;
679 RelativeTol=atoi(a[7]);
681 di << "BRepAlgo_BooleanOperations myalgo" << "\n";
682 BRepAlgo_BooleanOperations myalgo;
684 myalgo.Shapes(s1, s2);
685 myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d,RelativeTol);
686 TopoDS_Shape res; res = myalgo.Section();
687 DBRep::Set(a[1],res);
691 #include <Geom_Axis2Placement.hxx>
692 #include <AIS_Trihedron.hxx>
694 static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
697 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
698 if(myAISContext.IsNull()) {
699 di << "use 'vinit' command before " << a[0] << "\n";
703 Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY());
704 Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis);
707 aTrsf.SetTranslation(trans);
708 TopLoc_Location aLoc(aTrsf);
709 myAISContext->SetLocation(atri,aLoc);
710 myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
711 myAISContext->OpenLocalContext(Standard_False,
712 Standard_True,Standard_False,Standard_False);
713 myAISContext->Load(atri,3,Standard_True);
718 #include <TopoDS_Solid.hxx>
719 #include <BRepPrimAPI_MakeBox.hxx>
720 #include <BRepPrimAPI_MakeSphere.hxx>
722 #include <BRepAlgoAPI_Fuse.hxx>
723 #include <BRepAlgo_Fuse.hxx>
725 #include <V3d_Plane.hxx>
726 #include <V3d_View.hxx>
727 #include <gce_MakePln.hxx>
729 static Standard_Integer BUC60698(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
732 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
735 Standard_Boolean IsBRepAlgoAPI = Standard_True;
737 Standard_Integer IsB = atoi(a[1]);
739 IsBRepAlgoAPI = Standard_False;
740 #if ! defined(BRepAlgo_def01)
741 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
747 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
748 if(myAISContext.IsNull()) {
749 di << "use 'vinit' command before " << a[0] << "\n";
752 TopoDS_Solid box = BRepPrimAPI_MakeBox(1,1,1).Solid();
753 TopoDS_Shape sphere = BRepPrimAPI_MakeSphere(gp_Pnt(0.5,0.5,0.5),0.6).Shape();
755 //#if ! defined(BRepAlgoAPI_def01)
756 // TopoDS_Shape fuse = BRepAlgoAPI_Fuse(box,sphere).Shape();
758 // TopoDS_Shape fuse = BRepAlgo_Fuse(box,sphere).Shape();
763 di << "fuse = BRepAlgoAPI_Fuse(box,sphere).Shape()" <<"\n";
764 fuse = BRepAlgoAPI_Fuse(box,sphere).Shape();
766 di << "fuse = BRepAlgo_Fuse(box,sphere).Shape()" <<"\n";
767 fuse = BRepAlgo_Fuse(box,sphere).Shape();
770 Handle_AIS_Shape theAISShape = new AIS_Shape(fuse);
771 myAISContext->Display(theAISShape);
773 gp_Pln thegpPln = gce_MakePln(gp_Pnt(0.5,0.5,0.5),gp_Dir(0,0,1));
774 Standard_Real A,B,C,D;
775 thegpPln.Coefficients(A,B,C,D);
776 Handle_V3d_Plane thePlane = new V3d_Plane(A,B,C,D);
777 myAISContext->CurrentViewer()->AddPlane (thePlane); // add to defined planes list
778 for (myAISContext->CurrentViewer()->InitActiveViews();
779 myAISContext->CurrentViewer()->MoreActiveViews ();
780 myAISContext->CurrentViewer()->NextActiveViews ()) {
783 myAISContext->CurrentViewer()->ActiveView()->SetPlaneOn(thePlane);
785 catch(Standard_Failure) {
786 di << "SetPlaneOn catched 1" << "\n";
790 di << "SetPlaneOn catched 1" << "\n";
794 for (myAISContext->CurrentViewer()->InitDefinedViews();
795 myAISContext->CurrentViewer()->MoreDefinedViews ();
796 myAISContext->CurrentViewer()->NextDefinedViews ()) {
799 myAISContext->CurrentViewer()->DefinedView()->SetPlaneOn(thePlane);
801 catch(Standard_Failure) {
802 di << "SetPlaneOn catched 1" << "\n";
806 di << "SetPlaneOn catched 2" << "\n";
810 myAISContext->UpdateCurrentViewer();
811 myAISContext->OpenLocalContext();
812 myAISContext->ActivateStandardMode(TopAbs_FACE);
816 static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
819 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
820 if(myAISContext.IsNull()) {
821 di << "use 'vinit' command before " << a[0] << "\n";
824 TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid();
825 TopAbs_ShapeEnum theType = B1.ShapeType();
826 if ( theType == TopAbs_SOLID ) {
827 di << "It is a solid." << "\n";
829 di << "It is not solid." << "\n";
831 myAISContext->Display(new AIS_Shape(B1));
832 myAISContext->OpenLocalContext();
833 TopAbs_ShapeEnum amode = TopAbs_SOLID;
834 myAISContext->ActivateStandardMode(amode);
836 di.Eval("QAMoveTo 200 200");
837 di.Eval("QASelect 200 200");
838 myAISContext->InitSelected() ;
839 if ( myAISContext->MoreSelected() ) {
840 if (myAISContext->HasSelectedShape() ) {
841 di << "has selected shape : OK" << "\n";
843 di << "has selected shape : bugged - Faulty " << "\n";
849 static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
852 di << "Usage : " << argv[0] << " [1/0]" << "\n";
856 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
857 if(myAIScontext.IsNull()) {
858 di << "use 'vinit' command before " << argv[0] << "\n";
861 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
863 if((argc == 2) && (atof(argv[1]) == 0))
864 myV3dView->SetAntialiasingOff();
866 myV3dView->SetAntialiasingOn();
872 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
874 //=======================================================================
875 //function : GetColorFromName
876 //purpose : get the Quantity_NameOfColor from a string
877 //=======================================================================
879 static Quantity_NameOfColor GetColorFromName( const char *name )
881 Quantity_NameOfColor ret = DEFAULT_COLOR;
883 Standard_Boolean Found = Standard_False;
884 Standard_CString colstring;
885 for(Standard_Integer i=0;i<=514 && !Found;i++)
887 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
888 if (!strcasecmp(name,colstring)) {
889 ret = (Quantity_NameOfColor)i;
890 Found = Standard_True;
897 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
900 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
901 if(myAISContext.IsNull()) {
902 di << "use 'vinit' command before " << argv[0] << "\n";
906 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
912 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
914 // Change the background color of the view with a predefined name Graphic3d_NOC_<name>
916 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
917 myV3dView -> Redraw();
923 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
924 // setcolor <object> <name>
925 // Change the object color with a predefined name
927 TopoDS_Shape aShape = DBRep::Get(argv[1]);
928 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
929 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
930 myAISContext->Display(myShape,Standard_True);
931 myAISContext->UpdateCurrentViewer();
937 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
939 // setcolor <r> <g> <b>
940 // Change the background color of the view with the color values <r>,<g>,<b>
941 // A color value must be defined in the space [0.,1.]
943 Standard_Real QuantityOfRed = atoi(argv[1]);
944 Standard_Real QuantityOfGreen = atoi(argv[2]);
945 Standard_Real QuantityOfBlue = atoi(argv[3]);
946 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
953 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
955 // setcolor <object> <r> <g> <b>
956 // change the object color with RGB values.
959 Standard_Real QuantityOfRed = atof(argv[2]);
960 Standard_Real QuantityOfGreen = atof(argv[3]);
961 Standard_Real QuantityOfBlue = atof(argv[4]);
963 TopoDS_Shape aShape = DBRep::Get(argv[1]);
964 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
965 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
966 myAISContext->Display(myShape,Standard_True);
967 myAISContext->UpdateCurrentViewer();
968 // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
969 // myShape->Redisplay();
976 static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
978 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
979 if(myAISContext.IsNull()) {
980 di << "use 'vinit' command before " << argv[0] << "\n";
985 di << "Usage : " << argv[0] << " 0/1" << "\n";
988 if(atoi(argv[1]) == 0) {
989 myAISContext->CloseAllContexts();
990 BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.);
991 Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());
992 myAISContext->Display(aBox);
993 } else if(atoi(argv[1]) == 1) {
994 myAISContext->CloseAllContexts();
995 myAISContext->OpenLocalContext();
996 myAISContext->ActivateStandardMode(TopAbs_EDGE);
997 } else if(atoi(argv[1]) == 2) {
998 myAISContext->CloseAllContexts();
999 myAISContext->OpenLocalContext();
1000 myAISContext->ActivateStandardMode(TopAbs_FACE);
1002 di << "Usage : " << argv[0] << " 0/1" << "\n";
1009 #include <BRepBndLib.hxx>
1010 #include <Bnd_HArray1OfBox.hxx>
1012 static Standard_Integer BUC60729 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** /*argv*/ )
1015 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
1017 BRepBndLib::Add(aShape , aMainBox );
1019 Standard_Integer siMaxNbrBox = 6;
1020 Bnd_BoundSortBox m_BoundSortBox;
1021 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
1022 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
1026 // Bnd_Box __emptyBox; // Box is void !
1027 // Handle_Bnd_HArray1OfBox __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
1029 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
1031 const TopoDS_Shape& aFace = aExplorer.Current();
1033 BRepBndLib::Add( aFace, aBox );
1034 m_BoundSortBox.Add( aBox, i );
1035 // __aSetOfBox->SetValue( i, aBox );
1037 // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
1042 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
1044 TCollection_AsciiString as1("");
1045 TCollection_AsciiString as2('\0');
1046 if((as1.ToCString()!=NULL) || (as1.ToCString() != ""))
1047 di << "Faulty : the first string is not zero string : " << as1.ToCString() << "\n";
1049 if((as2.ToCString()!=NULL) || (as2.ToCString() != ""))
1050 di << "Faulty : the second string is not zero string : " << as2.ToCString() << "\n";
1055 #include <UnitsAPI.hxx>
1057 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
1059 di <<"Program Test" << "\n";
1060 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
1061 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
1066 #include <gp_Circ.hxx>
1067 #include <Geom_Circle.hxx>
1068 #include <GeomAPI.hxx>
1069 #include <Geom2d_CartesianPoint.hxx>
1070 #include <Geom2dGcc_QualifiedCurve.hxx>
1071 #include <Geom2dGcc_Circ2d2TanRad.hxx>
1072 #include <Geom2d_Circle.hxx>
1073 #include <ProjLib.hxx>
1075 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1077 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1078 if(aContext.IsNull()) {
1079 di << "use 'vinit' command before " << argv[0] << "\n";
1083 gp_Pnt pt3d(0, 20, 150);
1084 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
1085 gp_Circ circ(anAx2, 50.0);
1086 Handle_Geom_Circle gcir = new Geom_Circle(circ);
1087 Handle_Geom_Plane pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
1088 Handle_Geom2d_Curve gcir1 = GeomAPI::To2d(gcir, pln->Pln());
1089 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
1090 Handle_AIS_Shape ais1 = new AIS_Shape(sh1);
1091 aContext->SetColor(ais1, Quantity_NOC_INDIANRED);
1092 aContext->Display(ais1);
1093 DBRep::Set("sh0",sh1);
1095 // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
1096 thepoint = ProjLib::Project(pln->Pln(),pt3d);
1097 Handle_Geom2d_CartesianPoint ThePoint = new Geom2d_CartesianPoint(thepoint);
1098 Geom2dAdaptor_Curve acur1(gcir1) ;
1099 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
1100 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
1101 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
1102 Handle_Geom2d_Circle gccc;
1103 if( cirtanrad.NbSolutions() ) {
1104 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
1105 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
1106 gccc = new Geom2d_Circle(ccc);
1107 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
1108 Standard_Character aStr[5];
1109 sprintf(aStr,"sh%d",i);
1110 DBRep::Set(aStr,sh);
1111 Handle_AIS_Shape ais = new AIS_Shape(sh);
1113 aContext->SetColor(ais, Quantity_NOC_GREEN);
1115 aContext->SetColor(ais, Quantity_NOC_HOTPINK);
1116 aContext->Display(ais);
1117 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
1118 gp_Pnt2d PntSol1, PntSol2;
1119 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
1120 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
1121 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
1122 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
1128 #include <TColgp_Array2OfPnt.hxx>
1129 #include <Geom_BezierSurface.hxx>
1130 #include <BRepBuilderAPI_MakeFace.hxx>
1131 #include <BRepBuilderAPI_MakeWire.hxx>
1132 #include <Geom_OffsetSurface.hxx>
1133 #include <BRepFilletAPI_MakeFillet2d.hxx>
1134 #include <GeomProjLib.hxx>
1135 #include <Geom_TrimmedCurve.hxx>
1137 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1141 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
1142 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
1143 Standard_Real f = 0.0, l = 0.0;
1144 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
1145 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
1146 GC = new Geom_TrimmedCurve(GC, f, l);
1147 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
1148 BRepBuilderAPI_MakeWire *myWire;
1149 myWire = new BRepBuilderAPI_MakeWire();
1150 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
1151 DBRep::Set(argv[1],myWire->Wire());
1155 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1156 if(aContext.IsNull()) {
1157 di << "use 'vinit' command before " << argv[0] << "\n";
1161 //step 1. creating a Bezier Surface and a patch
1165 Handle(AIS_Shape) ais1;
1166 Handle_AIS_Shape ais2;
1167 Handle(Geom_BezierSurface) BZ1;
1168 TColgp_Array2OfPnt array1(1,3,1,3);
1169 array1.SetValue(1,1,gp_Pnt(0,100,0));
1170 array1.SetValue(1,2,gp_Pnt(200,100,0));
1171 array1.SetValue(1,3,gp_Pnt(400,100,0));
1172 array1.SetValue(2,1,gp_Pnt(0,200,100));
1173 array1.SetValue(2,2,gp_Pnt(200,200,100));
1174 array1.SetValue(2,3,gp_Pnt(400,200,100));
1175 array1.SetValue(3,1,gp_Pnt(0,300,0));
1176 array1.SetValue(3,2,gp_Pnt(200,300,0));
1177 array1.SetValue(3,3,gp_Pnt(400,300,0));
1178 BZ1 = new Geom_BezierSurface(array1);
1179 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
1180 TopoDS_Face F1= bzf1.Face();
1181 ais1 = new AIS_Shape(F1);
1182 DBRep::Set("F1",F1);
1183 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
1184 aContext->Display(ais1);
1191 gp_Dir D(0, 0, 1.0f);
1192 BRepBuilderAPI_MakeWire mkw;
1193 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
1194 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
1195 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
1197 p1 = gp_Pnt(350., 150., 260.);
1198 p2 = gp_Pnt(350., 250., 260.);
1199 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
1201 p1 = gp_Pnt(350., 250., 260.);
1202 p2 = gp_Pnt(300., 250.0, 260.);
1203 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
1205 p1 = gp_Pnt(300., 250.0, 260.);
1206 p2 = gp_Pnt(200., 200.0, 260.);
1207 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
1209 p1 = gp_Pnt(200., 200.0, 260.);
1210 p2 = gp_Pnt(150., 200.0, 260.);
1211 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
1213 p1 = gp_Pnt(150., 200.0, 260.);
1214 p2 = gp_Pnt(150., 150.0, 260.);
1215 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
1217 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
1218 ais2 = new AIS_Shape( FP );
1219 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
1220 aContext->Display( ais2 );
1222 DBRep::Set("FP",FP);
1224 //step 2. offseting the surface.
1225 Handle_Geom_OffsetSurface offsurf;
1226 offsurf = new Geom_OffsetSurface(BZ1, -100);
1227 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
1228 TopoDS_Face F2= bzf2.Face();
1229 Handle_AIS_Shape ais22 = new AIS_Shape(F2);
1230 aContext->Display(ais22);
1231 DBRep::Set("F2",F2);
1233 //step 3. filleting the patch.
1234 //( I want to project wire of this patch on offseted surface above)
1235 BRepFilletAPI_MakeFillet2d fillet( FP );
1237 Ex.Init(FP, TopAbs_VERTEX);
1238 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
1239 fillet.AddFillet(v1, 20);
1240 printf("\nError is %d ", fillet.Status());
1242 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
1243 fillet.AddFillet(V2, 20);
1244 printf("\nError is %d ", fillet.Status());
1246 FP1 = fillet.Shape();
1247 ais2 = new AIS_Shape( FP1 );
1248 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
1249 aContext->Display( ais2 );
1251 DBRep::Set("FP1",FP1);
1253 //step 4. Projecting the wire of this patch on offsetted surface.
1254 // TopExp_Explorer Ex;
1255 BRepBuilderAPI_MakeWire *myWire;
1256 myWire = new BRepBuilderAPI_MakeWire();
1257 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
1259 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
1260 Standard_Real f = 0.0, l = 0.0;
1261 Handle_Geom_Curve newBSplin = BRep_Tool::Curve(e1, f, l);
1262 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
1263 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
1264 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
1266 Handle_AIS_Shape ais33 = new AIS_Shape( myWire->Wire() );
1267 aContext->Display(ais33);
1269 DBRep::Set("Wire",myWire->Wire());
1274 #include<GeomAPI_ExtremaCurveCurve.hxx>
1276 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1280 printf("Usage: %s edge1 edge2",argv[0]);
1284 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
1285 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
1287 Standard_Real fp , lp;
1289 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
1290 C2 = BRep_Tool::Curve(E2 , fp , lp);
1292 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
1294 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
1299 #include <BRepBuilderAPI_MakePolygon.hxx>
1300 #include <BRepOffsetAPI_ThruSections.hxx>
1302 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1305 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1308 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1310 Standard_Integer IsB = atoi(argv[1]);
1312 IsBRepAlgoAPI = Standard_False;
1313 #if ! defined(BRepAlgo_def01)
1314 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1320 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
1321 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
1322 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
1323 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
1324 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
1326 for (int i=0;i<4;i++) {
1327 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
1328 bottompolygon1.Add(tmppnt);
1329 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
1330 toppolygon1.Add(tmppnt);
1331 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
1332 bottompolygon2.Add(tmppnt);
1333 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
1334 toppolygon2.Add(tmppnt);
1336 bottompolygon1.Close();
1337 DBRep::Set("B1",bottompolygon1.Shape());
1338 toppolygon1.Close();
1339 DBRep::Set("T1",toppolygon1.Shape());
1340 bottompolygon2.Close();
1341 DBRep::Set("B2",bottompolygon2.Shape());
1342 toppolygon2.Close();
1343 DBRep::Set("T2",toppolygon2.Shape());
1344 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
1345 loft1.AddWire(bottompolygon1.Wire());
1346 loft1.AddWire(toppolygon1.Wire());
1348 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
1349 loft2.AddWire(bottompolygon2.Wire());
1350 loft2.AddWire(toppolygon2.Wire());
1352 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
1354 DBRep::Set("TS1",loft1.Shape());
1355 DBRep::Set("TS2",loft2.Shape());
1357 //#if ! defined(BRepAlgoAPI_def01)
1358 // BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1360 // BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1362 if (IsBRepAlgoAPI) {
1363 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1364 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1365 DBRep::Set("F",result.Shape());
1367 di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1368 BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1369 DBRep::Set("F",result.Shape());
1372 // DBRep::Set("F",result.Shape());
1376 #include <Geom_RectangularTrimmedSurface.hxx>
1377 #include <GC_MakeTrimmedCone.hxx>
1379 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1381 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1382 if(aContext.IsNull()) {
1383 di << "use 'vinit' command before " << argv[0] << "\n";
1388 double R1=8, R2=16, H1=20, H2=40, angle;
1390 P1(0,0,20), P2(0,0,45);
1392 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
1393 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
1394 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
1395 aContext->Display(ais1);
1396 aContext->SetColor(ais1, Quantity_NOC_BLUE1);
1398 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
1399 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
1400 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
1401 aContext->Display(ais2);
1402 aContext->SetColor(ais2, Quantity_NOC_RED);
1407 //#include <fstream.h>
1410 #elif defined (HAVE_FSTREAM_H)
1411 # include <fstream.h>
1413 //#include <Standard_Stream.hxx>
1414 //==========================================================================
1415 //function : CoordLoad
1416 // chargement d une face dans l explorer.
1417 //==========================================================================
1418 static Standard_Integer coordload (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1423 TopoDS_Vertex V1,V2;
1428 if (argc < 3) return 1;
1430 ifstream file(argv[2], ios::in);
1433 di<<"unable to open "<<argv[2]<<" for input"<<"\n";
1436 BRepBuilderAPI_MakeWire WB;
1438 file.getline(line,80);
1439 for(int i=0;i<30;i++) X[i]=Y[i]=0;
1440 fr = sscanf(line,"%20c%20c",&X,&Y);
1441 V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1445 file.getline(line,80);
1447 for(int i=0;i<30;i++) X[i]=Y[i]=0;
1448 fr = sscanf(line,"%20c%20c",&X,&Y);
1449 V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1450 Edge = BRepBuilderAPI_MakeEdge(V1,V2);
1456 if (WB.IsDone()) Wire = WB.Wire();
1457 Face = BRepBuilderAPI_MakeFace(Wire);
1459 DBRep::Set (argv[1],Face);
1464 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
1465 Standard_Integer /*nb*/,
1466 const char ** /*arg*/)
1468 TCollection_ExtendedString aString(1024*1024, 'A');
1472 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
1473 Standard_Integer argc,
1476 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1477 if(aContext.IsNull()) {
1478 di << "use 'vinit' command before " << argv[0] << "\n";
1481 if((argc != 2) && (argc != 3)) {
1482 di<< "usage : " << argv[0] << " shape [mode==1]" << "\n";
1485 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1486 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
1487 // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
1488 anIO->SetHilightMode((argc == 3) ? atoi(argv[2]) : 1);
1489 aContext->Display(anIO);
1493 //=======================================================================
1494 //function : buc60773
1496 //=======================================================================
1498 #include<TCollection_HAsciiString.hxx>
1500 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
1502 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
1503 Standard_CString aStr = hAscii->ToCString();
1504 TCollection_AsciiString aAscii(aStr);
1509 #include<BRepPrimAPI_MakeCylinder.hxx>
1510 #include<BRepPrimAPI_MakeCone.hxx>
1512 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1516 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1519 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1521 Standard_Integer IsB = atoi(argv[1]);
1523 IsBRepAlgoAPI = Standard_False;
1524 #if ! defined(BRepAlgo_def01)
1525 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1531 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
1533 Standard_Real x11 = 36.085182;
1534 Standard_Real y11 = 20.0;
1535 Standard_Real z11 = 8.431413;
1536 Standard_Real x12 = 88.04671;
1537 Standard_Real y12 = 20.0;
1538 Standard_Real z12 = 38.931416;
1539 Standard_Real radius = 10.0;
1541 gp_Pnt base1(x11, y11, z11);
1542 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
1543 gp_Ax2 axis1(base1, vect1);
1544 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
1545 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
1547 TopoDS_Shape SCyl = cylinder.Shape();
1548 DBRep::Set("cyl", SCyl);
1551 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
1552 Standard_Real x21 = 70.7262;
1553 Standard_Real y21 = 20.0;
1554 Standard_Real z21 = 28.431412;
1555 Standard_Real x22 = 105.36722;
1556 Standard_Real y22 = 20.0;
1557 Standard_Real z22 = 48.431416;
1558 Standard_Real radius1 = 6.0;
1559 Standard_Real radius2 = 3.0;
1561 gp_Pnt base2(x21, y21, z21);
1562 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
1563 gp_Ax2 axis2(base2, vect2);
1564 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
1565 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1567 TopoDS_Shape SCon = cone.Shape();
1568 DBRep::Set("con", SCon);
1570 //#if ! defined(BRepAlgoAPI_def01)
1571 // BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1573 // BRepAlgo_Fuse SFuse(SCyl, SCon);
1576 // if(! SFuse.IsDone() )
1577 // cout<<"Error: Boolean fuse operation failed !"<<endl;
1579 // TopoDS_Shape fuse = SFuse.Shape();
1582 if (IsBRepAlgoAPI) {
1583 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n";
1584 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1585 if(! SFuse.IsDone() )
1586 di<<"Error: Boolean fuse operation failed !"<<"\n";
1587 fuse = SFuse.Shape();
1589 di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n";
1590 BRepAlgo_Fuse SFuse(SCyl, SCon);
1591 if(! SFuse.IsDone() )
1592 di<<"Error: Boolean fuse operation failed !"<<"\n";
1593 fuse = SFuse.Shape();
1596 DBRep::Set("fus", fuse);
1601 #include <Dico_DictionaryOfInteger.hxx>
1602 #include <TColStd_HSequenceOfAsciiString.hxx>
1603 #include <TopExp.hxx>
1604 #include <TopoDS_Iterator.hxx>
1606 //---------------------------------------------------------------------------------------
1608 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1611 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1614 di<<"Invalid input shape"<<"\n";
1617 Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
1618 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1619 Standard_CString aString;
1620 Standard_Integer i=1,j=1,k=1,l=1,aa=1;
1621 TopExp_Explorer expl;
1622 Standard_Real f3d,l3d;
1623 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1626 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1627 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1628 aString = aSurface->DynamicType()->Name();
1630 if(aDico->GetItem(aString,aa) != 0)
1632 aDico->GetItem(aString,aa);
1633 aDico->SetItem(aString,aa+1);
1635 aDico->SetItem(aString,1);
1636 aSequence->Append(aString);
1642 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1644 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1645 TopoDS_Iterator anIt(aFace);
1646 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1647 TopoDS_Iterator it (aWire);
1648 for (; it.More(); it.Next()) {
1649 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1650 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1651 aString = aCurve2d->DynamicType()->Name();
1652 if(aDico->GetItem(aString,aa) != 0)
1654 aDico->GetItem(aString,aa);
1655 aDico->SetItem(aString,aa+1);
1657 aDico->SetItem(aString,1);
1658 aSequence->Append(aString);
1665 TopExp_Explorer exp;
1666 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
1668 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1669 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1670 if(aCurve3d.IsNull())
1675 aString = aCurve3d->DynamicType()->Name();
1676 if(aDico->GetItem(aString,aa) != 0)
1678 aDico->GetItem(aString,aa);
1679 aDico->SetItem(aString,aa+1);
1681 aDico->SetItem(aString,1);
1682 aSequence->Append(aString);
1692 aDico->GetItem(aSequence->Value(j),aa);
1693 di<<aa<<" -- "<<aSequence->Value(j).ToCString()<<"\n";
1697 di<<"Degenerated edges :"<<"\n";
1698 di<<l<<" -- "<<"Degenerated edges "<<"\n";
1704 #include <BRepBuilderAPI_Transform.hxx>
1706 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1709 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1712 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1714 Standard_Integer IsB = atoi(argv[1]);
1716 IsBRepAlgoAPI = Standard_False;
1717 #if ! defined(BRepAlgo_def01)
1718 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1724 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1725 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1726 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1728 TopoDS_Shape sh1 = cyl.Shape();
1729 DBRep::Set("sh1",sh1);
1730 gp_Trsf trsf1, trsf2;
1731 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1732 gp_Pnt(0.000000,700.000000,-95.000000));
1733 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1734 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1735 BRepBuilderAPI_Transform trans1(sh1, trsf1);
1736 TopoDS_Shape sh2 = trans1.Shape();
1737 DBRep::Set("sh2",sh2);
1739 //#if ! defined(BRepAlgoAPI_def01)
1740 // BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1742 // BRepAlgo_Fuse fuse1(sh1, sh2);
1745 // TopoDS_Shape fsh1 = fuse1.Shape();
1748 if (IsBRepAlgoAPI) {
1749 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n";
1750 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1751 fsh1 = fuse1.Shape();
1753 di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n";
1754 BRepAlgo_Fuse fuse1(sh1, sh2);
1755 fsh1 = fuse1.Shape();
1758 DBRep::Set("fsh1",fsh1);
1759 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1760 TopoDS_Shape sh3 = trans2.Shape();
1761 DBRep::Set("sh3",sh3);
1763 //#if ! defined(BRepAlgoAPI_def01)
1764 // BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1766 // BRepAlgo_Fuse fuse2(fsh1,sh3);
1769 // TopoDS_Shape fsh2 = fuse2.Shape();
1772 if (IsBRepAlgoAPI) {
1773 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n";
1774 BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1775 fsh2 = fuse2.Shape();
1777 di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n";
1778 BRepAlgo_Fuse fuse2(fsh1,sh3);
1779 fsh2 = fuse2.Shape();
1782 DBRep::Set("fsh2",fsh2);
1783 Handle_AIS_Shape aisp1 = new AIS_Shape(fsh2);
1784 // aContext->Display(aisp1);
1788 #include <ShapeBuild_Edge.hxx>
1790 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1792 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1793 ShapeBuild_Edge().BuildCurve3d(e);
1799 #include<TDF_Label.hxx>
1800 #include<TDataStd_TreeNode.hxx>
1802 #include<DDocStd.hxx>
1806 #include<TDocStd_Modified.hxx>
1807 #include<TDF_ListIteratorOfDeltaList.hxx>
1808 #include<TDocStd_Document.hxx>
1809 #include<TDocStd_Application.hxx>
1810 #include<TDF_Delta.hxx>
1811 #include<TDataXtd_Constraint.hxx>
1812 #include<TPrsStd_AISPresentation.hxx>
1813 #include<TPrsStd_AISViewer.hxx>
1814 #include<TNaming_Builder.hxx>
1815 #include<TNaming_Naming.hxx>
1816 #include<TNaming_NamedShape.hxx>
1818 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1820 di << "Usage : " << argv[0] << " D" << "\n";
1825 Handle(TDF_Data) DF;
1826 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1829 Handle(TDataStd_TreeNode) TN1,TN2;
1831 DDF::AddLabel(DF,"0:2",L1);
1832 TN1 = TDataStd_TreeNode::Set(L1);
1834 DDF::AddLabel(DF,"0:3",L2);
1835 TN2 = TDataStd_TreeNode::Set(L2);
1838 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1839 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1845 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1847 di << "Usage : " << argv[0] << " D" << "\n";
1852 Handle(TDF_Data) DF;
1853 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1856 DDF::FindLabel(DF,"0:1",L,Standard_False);
1857 Handle(TDocStd_Modified) MDF;
1858 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1859 MDF = new TDocStd_Modified();
1860 L.Root().AddAttribute(MDF);
1863 di<<!MDF->IsEmpty();
1867 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1869 di << "Usage : " << argv[0] << " D Label" << "\n";
1874 Handle(TDF_Data) DF;
1875 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1878 DDF::FindLabel(DF,argv[2],L,Standard_False);
1880 TDocStd_Modified::Add(L);
1886 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1888 di << "Usage : " << argv[0] << " D" << "\n";
1894 Handle(TDF_Data) aDF;
1895 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1897 Handle(TDocStd_Document) aDocument;
1898 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1901 Handle(TDataStd_TreeNode) TN;
1903 aDocument->NewCommand();
1904 DDF::AddLabel(aDF,"0:2",L);
1905 TN = TDataStd_TreeNode::Set(L);
1907 aDocument->NewCommand();
1908 DDF::AddLabel(aDF,"0:3",L);
1909 TN = TDataStd_TreeNode::Set(L);
1911 aDocument->NewCommand();
1912 DDF::AddLabel(aDF,"0:4",L);
1913 TN = TDataStd_TreeNode::Set(L);
1914 aDocument->NewCommand();
1916 TDF_DeltaList Us,Rs;
1917 Us = aDocument->GetUndos();
1918 Rs = aDocument->GetUndos();
1921 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1923 TDF_ListIteratorOfDeltaList IDL;
1924 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1925 Handle(TDF_Delta) D = IDL.Value();
1926 TCollection_ExtendedString S(Names[i-1]);
1928 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1934 Us = aDocument->GetUndos();
1935 Rs = aDocument->GetRedos();
1937 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1938 Handle(TDF_Delta) D = IDL.Value();
1939 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1942 TCollection_ExtendedString n2name ("n2");
1943 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1944 Handle(TDF_Delta) D = IDL.Value();
1945 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1956 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1958 di << "Usage : " << argv[0] << " D Shape" << "\n";
1963 Handle(TDF_Data) aDF;
1964 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1966 TopoDS_Shape s = DBRep::Get(argv[2]);
1967 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1969 DDF::AddLabel(aDF, "0:2", L);
1970 TNaming_Builder SI (L);
1973 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1977 // if (!NS->IsEmpty()) {di<<3;return 0;}
1978 if (NS->IsEmpty()) {di<<4;return 0;}
1983 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1985 di << "Usage : " << argv[0] << " D Shape" << "\n";
1990 Handle(TDF_Data) aDF;
1991 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1993 TopoDS_Shape s = DBRep::Get(argv[2]);
1994 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1996 DDF::AddLabel(aDF, "0:2", L);
1997 TNaming_Builder SI (L);
2000 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
2004 if (NS->IsEmpty()) {di<<4;return 0;}
2009 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2011 TCollection_ExtendedString path (argv[1]);
2012 Handle(TDocStd_Application) A;
2013 if (!DDocStd::Find(A)) {di<<1;return 0;}
2014 Handle(TDocStd_Document) D;
2015 Standard_Integer insession = A->IsInSession(path);
2016 if (insession > 0) {
2017 di <<"document " << insession << " is already in session" << "\n";
2021 PCDM_ReaderStatus Result = A->Open(path,D);
2022 if(Result==PCDM_RS_OK){
2031 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2033 di << "Usage : " << argv[0] << " D" << "\n";
2038 Handle(TDF_Data) aDF;
2039 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2042 DDF::AddLabel(aDF, "0:2", L);
2044 Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation;
2046 AISP->Set(L,TDataXtd_Constraint::GetID());
2048 if (AISP->HasOwnMode()) {di<<3;return 0;}
2050 Standard_Integer Mode = AISP->Mode();
2051 if (Mode!=3) {di<<4;return 0;}
2052 if (!AISP->HasOwnMode()) {di<<5;return 0;}
2054 if (AISP->HasOwnMode()) {di<<6;return 0;}
2059 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2061 di << "Usage : " << argv[0] << " D" << "\n";
2066 Handle(TDF_Data) aDF;
2067 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2070 DDF::AddLabel(aDF, "0:2", L);
2074 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
2075 // Handle(TNaming_Name) NN = new TNaming_Name;
2078 NN.Type(TNaming_IDENTITY);
2080 Standard_Boolean Res = NN.Solve(L,LM);
2082 if (Res!=Standard_False) {di<<3;return 0;}
2087 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2089 di << "Usage : " << argv[0] << " D" << "\n";
2095 Handle(TDocStd_Document) aDocument;
2096 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
2098 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
2099 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
2105 //=======================================================================
2106 //function : AISWidth
2107 //purpose : AISWidth (DOC,entry,[width])
2108 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
2109 //=======================================================================
2111 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2114 Handle(TDocStd_Document) D;
2115 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
2117 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
2119 Handle(TPrsStd_AISViewer) viewer;
2120 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
2122 Handle(TPrsStd_AISPresentation) prs;
2123 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2125 prs->SetWidth(atof(argv[3]));
2126 TPrsStd_AISViewer::Update(L);
2129 if (prs->HasOwnWidth()){
2130 // cout << "Width = " << prs->Width() << endl;
2134 di << "AISWidth: Warning : Width wasn't set" << "\n";
2141 di << "AISWidth : Error" << "\n";
2146 //=======================================================================
2147 //function : BUC60921 ( & BUC60954 )
2148 //purpose : Test memory allocation of OCAF in Undo/Redo operations
2149 //=======================================================================
2151 static Standard_Integer BUC60921 (Draw_Interpretor& di,
2152 Standard_Integer nb,
2156 Handle(TDocStd_Document) D;
2157 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
2159 DDF::AddLabel(D->GetData(),arg[2],L);
2163 BRepTools::Read ( S, arg[3], B );
2165 TNaming_Builder tnBuild(L);
2166 tnBuild.Generated(S);
2167 // di << "File " << arg[3] << " added";
2171 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
2176 #include<IGESControl_Reader.hxx>
2177 #include<BRepPrimAPI_MakeHalfSpace.hxx>
2179 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
2183 // cerr << "Usage : " << a[0] << " file.igs" << endl;
2186 if(argc < 2 || argc > 3) {
2187 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2190 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2192 Standard_Integer IsB = atoi(a[2]);
2194 IsBRepAlgoAPI = Standard_False;
2195 #if ! defined(BRepAlgo_def01)
2196 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
2202 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
2204 if(myContext.IsNull()) {
2205 di << "use 'vinit' command before " << a[0] << "\n";
2209 // IGESControlStd_Reader reader;
2210 IGESControl_Reader reader;
2211 reader.ReadFile(a[1]);
2212 reader.TransferRoots();
2213 TopoDS_Shape shape = reader.OneShape();
2214 printf("\n iges1 shape type = %d", shape.ShapeType() );
2215 TopTools_IndexedMapOfShape list;
2216 TopExp::MapShapes(shape, TopAbs_FACE, list);
2217 printf("\n No. of faces = %d", list.Extent());
2220 BRep_Builder builder;
2221 builder.MakeShell(shell);
2222 for(int i=1;i<=list.Extent(); i++) {
2223 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
2224 builder.Add(shell, face);
2227 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
2228 TopoDS_Solid sol = half.Solid();
2229 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
2230 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
2231 TopoDS_Shape sh = cyl.Shape();
2233 //#if ! defined(BRepAlgoAPI_def01)
2234 // BRepAlgoAPI_Fuse fuse(sol, sh);
2236 // BRepAlgo_Fuse fuse(sol, sh);
2239 // sh = fuse.Shape();
2241 if (IsBRepAlgoAPI) {
2242 di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n";
2243 BRepAlgoAPI_Fuse fuse(sol, sh);
2246 di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n";
2247 BRepAlgo_Fuse fuse(sol, sh);
2251 Handle(AIS_Shape) res = new AIS_Shape(sh);
2252 myContext->Display( res );
2256 void QABUC::Commands(Draw_Interpretor& theCommands) {
2257 const char *group = "QABUC";
2259 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
2260 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
2261 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
2262 theCommands.Add("BUC60609","BUC60609 shape [name] [interactive (0|1)]",__FILE__,BUC60609,group);
2264 theCommands.Add("UKI61075","UKI61075",__FILE__,UKI61075,group);
2266 theCommands.Add("BUC60585",St,__FILE__,BUC60585,group);
2267 theCommands.Add("BUC60547","BUC60547 name",__FILE__,BUC60547,group);
2268 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
2269 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
2270 theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2271 theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2272 theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2273 theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2274 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
2276 theCommands.Add("BUC60698","BUC60698 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60698,group);
2278 theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
2279 theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
2280 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
2281 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
2283 theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
2284 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
2285 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
2286 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
2287 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
2288 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
2290 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
2292 theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
2294 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
2297 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
2300 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
2301 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
2302 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
2303 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
2305 theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
2307 theCommands.Add("statface","statface face",__FILE__,statface,group);
2309 theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
2311 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
2313 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
2314 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
2315 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
2316 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
2317 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
2318 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
2319 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
2320 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
2321 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
2322 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
2323 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
2324 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
2326 theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );