1 // Created on: 2002-06-17
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
18 #include <Draw_Interpretor.hxx>
19 #include <TopLoc_Location.hxx>
20 #include <TopoDS_Face.hxx>
23 #include <Geom_Surface.hxx>
24 #include <BRep_Tool.hxx>
25 #include <GeomInt_IntSS.hxx>
26 #include <BRepBuilderAPI_MakeEdge.hxx>
27 #include <Standard_ErrorHandler.hxx>
28 #include <Graphic3d_ClipPlane.hxx>
32 static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
36 di << "Usage : " << a[0] << " result Shape1 Shape2\n";
42 TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
43 TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
44 Handle(Geom_Surface) GSF1 = BRep_Tool::Surface(F1, L1);
45 Handle(Geom_Surface) GSF2 = BRep_Tool::Surface(F2, L2);
47 Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1));
48 if (!Inter.IsDone()) {
49 di << "Intersection not done\n";
52 Standard_Integer nbsol = Inter.NbLines();
54 di << "The number of solutions is zero!" << "\n";
57 Handle(Geom_Curve) Sol = Inter.Line(1);
59 DBRep::Set(a[1], BRepBuilderAPI_MakeEdge(Sol));
61 } else di << "The first solution is Null!" << "\n";
67 #include<ViewerTest.hxx>
68 #include<AIS_InteractiveContext.hxx>
69 #include<AIS_Shape.hxx>
71 static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
75 di << "Usage : " << argv[0] << " shape\n";
79 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
80 if(myAISContext.IsNull()) {
81 di << "use 'vinit' command before " << argv[0] << "\n";
85 TopoDS_Shape theShape = DBRep::Get(argv[1]);
87 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
88 myAISContext->Display( anAISShape, Standard_True );
89 myAISContext->OpenLocalContext();
90 myAISContext->ActivateStandardMode(TopAbs_FACE);
94 static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
98 di << "Usage : "<< argv[0] << " shape\n";
104 TopoDS_Shape theShape = DBRep::Get(argv[1]);
106 // ViewerTest::GetAISContext();
107 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
108 if(myAISContext.IsNull()) {
109 di << "use 'vinit' command before " << argv[0] << "\n";
112 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
113 myAISContext->Display( anAISShape, Standard_True );
114 myAISContext->OpenLocalContext();
115 myAISContext->ActivateStandardMode(TopAbs_COMPOUND);
116 // myAISContext->ActivateStandardMode(TopAbs_SOLID);
118 // cout << "vfini" << endl;
122 #include<BRep_Builder.hxx>
123 #include<BRepTools_ShapeSet.hxx>
124 #include<BRepTools.hxx>
125 #include<BRepAdaptor_HSurface.hxx>
126 #include<TopOpeBRep_PointClassifier.hxx>
127 #include<Precision.hxx>
132 static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
137 // BUC60609 shape name
138 } else if ( argc == 5 ) {
139 // BUC60609 shape name U V
141 di << "Usage : "<< argv[0] << " shape name [U V]\n";
145 TCollection_AsciiString aFilePath(argv[1]);
149 if (!fic.open(aFilePath.ToCString(),ios::in)) {
150 di << "Cannot open file for reading : " << aFilePath << "\n";
154 TopoDS_Shape theShape;
158 if( !strcmp(typ, "DBRep_DrawableShape") ){
160 BRepTools_ShapeSet S(B);
164 di << "Wrong entity type in " << aFilePath << "\n";
169 const TopoDS_Face &face = TopoDS::Face (theShape);
172 DBRep::Set(argv[2],face);
175 Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
177 BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
179 di << "The bounds of the trimmed face:\n";
180 di << faceUMin << " <= U <= " << faceUMax << "\n";
181 di << faceVMin << " <= V <= " << faceVMax << "\n";
183 Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
185 TopOpeBRep_PointClassifier PClass;
187 di << "Now test the point classifier by inputting U,V values\n";
188 di << "inside or outside the bounds displayed above\n";
189 di << "Type stop to exit\n";
191 // Please register this:
192 // ***********************************************
193 // Note also that for periodic surfaces such as nimpod_1.topo,
194 // the U/V values may be +- 2pi compared to the actual face bounds
195 // (because U,V is probably coming from a Geom package routine).
196 // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
197 // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
198 // *************************************************
201 uvSurf = gp_Pnt2d(0.14,5.1);
202 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
203 if(state == TopAbs_IN || state == TopAbs_ON){
204 di << "U=" << 0.14 << " V=" << 5.1 << " classified INSIDE\n";
206 di << "U=" << 0.14 << " V=" << 5.1 << " classified OUTSIDE\n";
209 uvSurf = gp_Pnt2d(1.28,5.1);
210 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
211 if(state == TopAbs_IN || state == TopAbs_ON){
212 di << "U=" << 1.28 << " V=" << 5.1 << " classified INSIDE\n";
214 di << "U=" << 1.28 << " V=" << 5.1 << " classified OUTSIDE\n";
217 uvSurf = gp_Pnt2d(Draw::Atof(argv[3]),Draw::Atof(argv[4]));
218 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
219 if(state == TopAbs_IN || state == TopAbs_ON){
220 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified INSIDE\n";
222 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified OUTSIDE\n";
228 #include<BRepBuilderAPI_MakeVertex.hxx>
229 #include<TCollection_ExtendedString.hxx>
230 #include<AIS_LengthDimension.hxx>
232 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
235 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
236 if(myAIScontext.IsNull()) {
237 di << "use 'vinit' command before " << a[0] << "\n";
240 myAIScontext->EraseAll();
242 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
243 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
245 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
246 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
248 myAIScontext->Display(Ve1);
249 myAIScontext->Display(Ve2);
251 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
252 TCollection_ExtendedString Ext1("Dim1");
253 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln());
254 Dim1->SetCustomValue (Draw::Atof(a[2]));
256 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
257 anAspect->MakeArrows3d (Standard_False);
258 anAspect->MakeText3d (Standard_True);
259 anAspect->MakeTextShaded (Standard_True);
260 anAspect->TextAspect()->SetHeight (2.5);
261 anAspect->ArrowAspect()->SetLength (1.0);
262 Dim1->SetDimensionAspect (anAspect);
264 myAIScontext->SetDisplayMode(Dim1, Draw::Atoi(a[1]));
265 myAIScontext->Display(Dim1);
269 #include<TopoDS_Wire.hxx>
271 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
274 di << "Usage : BUC60652 fase" << "\n";
277 TopoDS_Shape shape = DBRep::Get( argv[1] );
278 TopoDS_Face face = TopoDS::Face( shape );
279 TopoDS_Wire ow = BRepTools::OuterWire( face );
280 DBRep::Set( "w", ow );
284 #include <BRepAlgo_BooleanOperations.hxx>
286 static Standard_Integer defNbPntMax = 30;
287 static Standard_Real defTol3d = 1.e-7;
288 static Standard_Real defTol2d = 1.e-7;
289 Standard_Integer NbPntMax = defNbPntMax;
290 Standard_Real Toler3d =defTol3d;
291 Standard_Real Toler2d = defTol2d;
292 // //== // ksection : operateur section appelant BRepAlgo_BooleanOperation
293 //== // ksection : operateur section appelant BRepAlgo_BooleanOperations
294 //=======================================================================
295 Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) {
297 di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d" << "\n";
306 TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL);
307 TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL);
308 if (s1.IsNull() || s2.IsNull()) return 1;
309 NbPntMax=Draw::Atoi(a[4]);
310 Toler3d=Draw::Atof(a[5]);
311 Toler2d=Draw::Atof(a[6]);
313 di << "BRepAlgo_BooleanOperations myalgo\n";
314 BRepAlgo_BooleanOperations myalgo;
316 myalgo.Shapes(s1, s2);
317 myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d);
318 TopoDS_Shape res; res = myalgo.Section();
319 DBRep::Set(a[1],res);
323 #include <Geom_Axis2Placement.hxx>
324 #include <AIS_Trihedron.hxx>
326 static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
329 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
330 if(myAISContext.IsNull()) {
331 di << "use 'vinit' command before " << a[0] << "\n";
335 Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY());
336 Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis);
339 aTrsf.SetTranslation(trans);
340 TopLoc_Location aLoc(aTrsf);
341 myAISContext->SetLocation(atri,aLoc);
342 myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
343 myAISContext->OpenLocalContext(Standard_False,
344 Standard_True,Standard_False,Standard_False);
345 myAISContext->Load(atri,3,Standard_True);
350 #include <TopoDS_Solid.hxx>
351 #include <BRepPrimAPI_MakeBox.hxx>
352 #include <BRepPrimAPI_MakeSphere.hxx>
354 #include <BRepAlgoAPI_Fuse.hxx>
355 #include <BRepAlgo_Fuse.hxx>
357 #include <V3d_View.hxx>
358 #include <gce_MakePln.hxx>
360 static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
363 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
364 if(myAISContext.IsNull()) {
365 di << "use 'vinit' command before " << a[0] << "\n";
368 TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid();
369 TopAbs_ShapeEnum theType = B1.ShapeType();
370 if ( theType == TopAbs_SOLID ) {
371 di << "It is a solid." << "\n";
373 di << "It is not solid." << "\n";
375 myAISContext->Display(new AIS_Shape(B1));
376 myAISContext->OpenLocalContext();
377 TopAbs_ShapeEnum amode = TopAbs_SOLID;
378 myAISContext->ActivateStandardMode(amode);
380 di.Eval("QAMoveTo 200 200");
381 di.Eval("QASelect 200 200");
382 myAISContext->InitSelected() ;
383 if ( myAISContext->MoreSelected() ) {
384 if (myAISContext->HasSelectedShape() ) {
385 di << "has selected shape : OK" << "\n";
387 di << "has selected shape : bugged - Faulty " << "\n";
393 static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
396 di << "Usage : " << argv[0] << " [1/0]\n";
400 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
401 if(myAIScontext.IsNull()) {
402 di << "use 'vinit' command before " << argv[0] << "\n";
405 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
407 if((argc == 2) && (Draw::Atof(argv[1]) == 0))
408 myV3dView->SetAntialiasingOff();
410 myV3dView->SetAntialiasingOn();
416 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
418 //=======================================================================
419 //function : GetColorFromName
420 //purpose : get the Quantity_NameOfColor from a string
421 //=======================================================================
423 static Quantity_NameOfColor GetColorFromName( const char *name )
425 Quantity_NameOfColor ret = DEFAULT_COLOR;
427 Standard_Boolean Found = Standard_False;
428 Standard_CString colstring;
429 for(Standard_Integer i=0;i<=514 && !Found;i++)
431 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
432 if (!strcasecmp(name,colstring)) {
433 ret = (Quantity_NameOfColor)i;
434 Found = Standard_True;
441 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
444 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
445 if(myAISContext.IsNull()) {
446 di << "use 'vinit' command before " << argv[0] << "\n";
450 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
456 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
458 // Change the background color of the view with a predefined name Graphic3d_NOC_<name>
460 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
461 myV3dView -> Redraw();
467 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
468 // setcolor <object> <name>
469 // Change the object color with a predefined name
471 TopoDS_Shape aShape = DBRep::Get(argv[1]);
472 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
473 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
474 myAISContext->Display(myShape,Standard_True);
475 myAISContext->UpdateCurrentViewer();
481 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
483 // setcolor <r> <g> <b>
484 // Change the background color of the view with the color values <r>,<g>,<b>
485 // A color value must be defined in the space [0.,1.]
487 Standard_Real QuantityOfRed = Draw::Atoi(argv[1]);
488 Standard_Real QuantityOfGreen = Draw::Atoi(argv[2]);
489 Standard_Real QuantityOfBlue = Draw::Atoi(argv[3]);
490 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
497 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
499 // setcolor <object> <r> <g> <b>
500 // change the object color with RGB values.
503 Standard_Real QuantityOfRed = Draw::Atof(argv[2]);
504 Standard_Real QuantityOfGreen = Draw::Atof(argv[3]);
505 Standard_Real QuantityOfBlue = Draw::Atof(argv[4]);
507 TopoDS_Shape aShape = DBRep::Get(argv[1]);
508 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
509 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
510 myAISContext->Display(myShape,Standard_True);
511 myAISContext->UpdateCurrentViewer();
512 // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
513 // myShape->Redisplay();
520 static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
522 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
523 if(myAISContext.IsNull()) {
524 di << "use 'vinit' command before " << argv[0] << "\n";
529 di << "Usage : " << argv[0] << " 0/1\n";
532 if(Draw::Atoi(argv[1]) == 0) {
533 myAISContext->CloseAllContexts();
534 BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.);
535 Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());
536 myAISContext->Display(aBox);
537 } else if(Draw::Atoi(argv[1]) == 1) {
538 myAISContext->CloseAllContexts();
539 myAISContext->OpenLocalContext();
540 myAISContext->ActivateStandardMode(TopAbs_EDGE);
541 } else if(Draw::Atoi(argv[1]) == 2) {
542 myAISContext->CloseAllContexts();
543 myAISContext->OpenLocalContext();
544 myAISContext->ActivateStandardMode(TopAbs_FACE);
546 di << "Usage : " << argv[0] << " 0/1\n";
553 #include <BRepBndLib.hxx>
554 #include <Bnd_HArray1OfBox.hxx>
556 static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ )
559 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
561 BRepBndLib::Add(aShape , aMainBox );
563 Standard_Integer siMaxNbrBox = 6;
564 Bnd_BoundSortBox m_BoundSortBox;
565 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
566 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
570 // Bnd_Box __emptyBox; // Box is void !
571 // Handle(Bnd_HArray1OfBox) __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
573 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
575 const TopoDS_Shape& aFace = aExplorer.Current();
577 BRepBndLib::Add( aFace, aBox );
578 m_BoundSortBox.Add( aBox, i );
579 // __aSetOfBox->SetValue( i, aBox );
581 // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
586 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
588 TCollection_AsciiString as1("");
589 TCollection_AsciiString as2('\0');
590 if(as1.ToCString() == NULL || as1.Length() != 0 || as1.ToCString()[0] != '\0')
591 di << "Error : the first string is not zero string : " << as1.ToCString() << "\n";
593 if(as2.ToCString() == NULL || as2.Length() != 0 || as2.ToCString()[0] != '\0')
594 di << "Error : the second string is not zero string : " << as2.ToCString() << "\n";
599 #include <UnitsAPI.hxx>
601 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
603 di <<"Program Test\n";
604 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
605 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
610 #include <gp_Circ.hxx>
611 #include <Geom_Circle.hxx>
612 #include <GeomAPI.hxx>
613 #include <Geom2d_CartesianPoint.hxx>
614 #include <Geom2dGcc_QualifiedCurve.hxx>
615 #include <Geom2dGcc_Circ2d2TanRad.hxx>
616 #include <Geom2d_Circle.hxx>
617 #include <ProjLib.hxx>
619 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
621 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
622 if(aContext.IsNull()) {
623 di << "use 'vinit' command before " << argv[0] << "\n";
627 gp_Pnt pt3d(0, 20, 150);
628 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
629 gp_Circ circ(anAx2, 50.0);
630 Handle(Geom_Circle) gcir = new Geom_Circle(circ);
631 Handle(Geom_Plane) pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
632 Handle(Geom2d_Curve) gcir1 = GeomAPI::To2d(gcir, pln->Pln());
633 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
634 Handle(AIS_Shape) ais1 = new AIS_Shape(sh1);
635 aContext->SetColor(ais1, Quantity_NOC_INDIANRED);
636 aContext->Display(ais1);
637 DBRep::Set("sh0",sh1);
639 // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
640 thepoint = ProjLib::Project(pln->Pln(),pt3d);
641 Handle(Geom2d_CartesianPoint) ThePoint = new Geom2d_CartesianPoint(thepoint);
642 Geom2dAdaptor_Curve acur1(gcir1) ;
643 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
644 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
645 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
646 Handle(Geom2d_Circle) gccc;
647 if( cirtanrad.NbSolutions() ) {
648 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
649 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
650 gccc = new Geom2d_Circle(ccc);
651 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
652 Standard_Character aStr[5];
653 Sprintf(aStr,"sh%d",i);
655 Handle(AIS_Shape) ais = new AIS_Shape(sh);
657 aContext->SetColor(ais, Quantity_NOC_GREEN);
659 aContext->SetColor(ais, Quantity_NOC_HOTPINK);
660 aContext->Display(ais);
661 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
662 gp_Pnt2d PntSol1, PntSol2;
663 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
664 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
665 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
666 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
672 #include <TColgp_Array2OfPnt.hxx>
673 #include <Geom_BezierSurface.hxx>
674 #include <BRepBuilderAPI_MakeFace.hxx>
675 #include <BRepBuilderAPI_MakeWire.hxx>
676 #include <Geom_OffsetSurface.hxx>
677 #include <BRepFilletAPI_MakeFillet2d.hxx>
678 #include <GeomProjLib.hxx>
679 #include <Geom_TrimmedCurve.hxx>
681 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
685 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
686 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
687 Standard_Real f = 0.0, l = 0.0;
688 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
689 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
690 GC = new Geom_TrimmedCurve(GC, f, l);
691 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
692 BRepBuilderAPI_MakeWire *myWire;
693 myWire = new BRepBuilderAPI_MakeWire();
694 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
695 DBRep::Set(argv[1],myWire->Wire());
699 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
700 if(aContext.IsNull()) {
701 di << "use 'vinit' command before " << argv[0] << "\n";
705 //step 1. creating a Bezier Surface and a patch
709 Handle(AIS_Shape) ais1;
710 Handle(AIS_Shape) ais2;
711 Handle(Geom_BezierSurface) BZ1;
712 TColgp_Array2OfPnt array1(1,3,1,3);
713 array1.SetValue(1,1,gp_Pnt(0,100,0));
714 array1.SetValue(1,2,gp_Pnt(200,100,0));
715 array1.SetValue(1,3,gp_Pnt(400,100,0));
716 array1.SetValue(2,1,gp_Pnt(0,200,100));
717 array1.SetValue(2,2,gp_Pnt(200,200,100));
718 array1.SetValue(2,3,gp_Pnt(400,200,100));
719 array1.SetValue(3,1,gp_Pnt(0,300,0));
720 array1.SetValue(3,2,gp_Pnt(200,300,0));
721 array1.SetValue(3,3,gp_Pnt(400,300,0));
722 BZ1 = new Geom_BezierSurface(array1);
723 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
724 TopoDS_Face F1= bzf1.Face();
725 ais1 = new AIS_Shape(F1);
727 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
728 aContext->Display(ais1);
733 shell.Closed (BRep_Tool::IsClosed (shell));
736 gp_Dir D(0, 0, 1.0f);
737 BRepBuilderAPI_MakeWire mkw;
738 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
739 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
740 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
742 p1 = gp_Pnt(350., 150., 260.);
743 p2 = gp_Pnt(350., 250., 260.);
744 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
746 p1 = gp_Pnt(350., 250., 260.);
747 p2 = gp_Pnt(300., 250.0, 260.);
748 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
750 p1 = gp_Pnt(300., 250.0, 260.);
751 p2 = gp_Pnt(200., 200.0, 260.);
752 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
754 p1 = gp_Pnt(200., 200.0, 260.);
755 p2 = gp_Pnt(150., 200.0, 260.);
756 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
758 p1 = gp_Pnt(150., 200.0, 260.);
759 p2 = gp_Pnt(150., 150.0, 260.);
760 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
762 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
763 ais2 = new AIS_Shape( FP );
764 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
765 aContext->Display( ais2 );
769 //step 2. offseting the surface.
770 Handle(Geom_OffsetSurface) offsurf;
771 offsurf = new Geom_OffsetSurface(BZ1, -100);
772 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
773 TopoDS_Face F2= bzf2.Face();
774 Handle(AIS_Shape) ais22 = new AIS_Shape(F2);
775 aContext->Display(ais22);
778 //step 3. filleting the patch.
779 //( I want to project wire of this patch on offseted surface above)
780 BRepFilletAPI_MakeFillet2d fillet( FP );
782 Ex.Init(FP, TopAbs_VERTEX);
783 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
784 fillet.AddFillet(v1, 20);
785 di << "\nError is " << fillet.Status() << "\n";
786 // printf("\nError is %d ", fillet.Status());
788 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
789 fillet.AddFillet(V2, 20);
790 di << "\nError is " << fillet.Status() << "\n";
791 // printf("\nError is %d ", fillet.Status());
793 FP1 = fillet.Shape();
794 ais2 = new AIS_Shape( FP1 );
795 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
796 aContext->Display( ais2 );
798 DBRep::Set("FP1",FP1);
800 //step 4. Projecting the wire of this patch on offsetted surface.
801 // TopExp_Explorer Ex;
802 BRepBuilderAPI_MakeWire *myWire;
803 myWire = new BRepBuilderAPI_MakeWire();
804 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
806 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
807 Standard_Real f = 0.0, l = 0.0;
808 Handle(Geom_Curve) newBSplin = BRep_Tool::Curve(e1, f, l);
809 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
810 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
811 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
813 Handle(AIS_Shape) ais33 = new AIS_Shape( myWire->Wire() );
814 aContext->Display(ais33);
816 DBRep::Set("Wire",myWire->Wire());
821 #include<GeomAPI_ExtremaCurveCurve.hxx>
823 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
827 printf("Usage: %s edge1 edge2",argv[0]);
831 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
832 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
834 Standard_Real fp , lp;
836 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
837 C2 = BRep_Tool::Curve(E2 , fp , lp);
839 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
841 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
846 #include <BRepBuilderAPI_MakePolygon.hxx>
847 #include <BRepOffsetAPI_ThruSections.hxx>
849 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
852 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
855 Standard_Boolean IsBRepAlgoAPI = Standard_True;
857 Standard_Integer IsB = Draw::Atoi(argv[1]);
859 IsBRepAlgoAPI = Standard_False;
860 #if ! defined(BRepAlgo_def01)
861 // di << "Error: There is not BRepAlgo_Fuse class\n";
867 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
868 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
869 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
870 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
871 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
873 for (int i=0;i<4;i++) {
874 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
875 bottompolygon1.Add(tmppnt);
876 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
877 toppolygon1.Add(tmppnt);
878 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
879 bottompolygon2.Add(tmppnt);
880 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
881 toppolygon2.Add(tmppnt);
883 bottompolygon1.Close();
884 DBRep::Set("B1",bottompolygon1.Shape());
886 DBRep::Set("T1",toppolygon1.Shape());
887 bottompolygon2.Close();
888 DBRep::Set("B2",bottompolygon2.Shape());
890 DBRep::Set("T2",toppolygon2.Shape());
891 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
892 loft1.AddWire(bottompolygon1.Wire());
893 loft1.AddWire(toppolygon1.Wire());
895 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
896 loft2.AddWire(bottompolygon2.Wire());
897 loft2.AddWire(toppolygon2.Wire());
899 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
901 DBRep::Set("TS1",loft1.Shape());
902 DBRep::Set("TS2",loft2.Shape());
904 //#if ! defined(BRepAlgoAPI_def01)
905 // BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
907 // BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
910 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())\n";
911 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
912 DBRep::Set("F",result.Shape());
914 di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())\n";
915 BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
916 DBRep::Set("F",result.Shape());
919 // DBRep::Set("F",result.Shape());
923 #include <Geom_RectangularTrimmedSurface.hxx>
924 #include <GC_MakeTrimmedCone.hxx>
926 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
928 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
929 if(aContext.IsNull()) {
930 di << "use 'vinit' command before " << argv[0] << "\n";
937 P1(0,0,20), P2(0,0,45);
938 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
939 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
940 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
941 aContext->Display(ais1);
942 aContext->SetColor(ais1, Quantity_NOC_BLUE1);
944 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
945 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
946 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
947 aContext->Display(ais2);
948 aContext->SetColor(ais2, Quantity_NOC_RED);
952 //==========================================================================
953 //function : CoordLoad
954 // chargement d une face dans l explorer.
955 //==========================================================================
956 static Standard_Integer coordload (Draw_Interpretor& theDi,
957 Standard_Integer theArgsNb,
958 const char** theArgVec)
965 std::ifstream aFile (theArgVec[2], ios::in);
968 theDi << "unable to open " << theArgVec[2] << " for input\n";
973 memset (aLine, 0, 40);
974 aFile.getline (aLine, 80);
976 gp_Pnt aPnt (0.0, 0.0, 0.0);
978 aPnt.SetY (Draw::Atof (&aLine[20]));
980 aPnt.SetX (Draw::Atof (aLine));
981 TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt);
982 BRepBuilderAPI_MakeWire aMakeWire;
985 memset (aLine, 0, 40);
986 aFile.getline (aLine, 80);
993 aPnt.SetY (Draw::Atof (&aLine[20]));
995 aPnt.SetX (Draw::Atof (aLine));
996 TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt);
997 aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2));
1002 if (!aMakeWire.IsDone())
1004 DBRep::Set (theArgVec[1], TopoDS_Face());
1008 BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire());
1009 DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face());
1013 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
1014 Standard_Integer /*nb*/,
1015 const char ** /*arg*/)
1017 TCollection_ExtendedString aString(1024*1024, 'A');
1021 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
1022 Standard_Integer argc,
1025 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1026 if(aContext.IsNull()) {
1027 di << "use 'vinit' command before " << argv[0] << "\n";
1030 if((argc != 2) && (argc != 3)) {
1031 di<< "usage : " << argv[0] << " shape [mode==1]\n";
1034 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1035 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
1036 // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
1037 anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
1038 aContext->Display(anIO);
1042 //=======================================================================
1043 //function : buc60773
1045 //=======================================================================
1047 #include<TCollection_HAsciiString.hxx>
1049 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
1051 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
1052 Standard_CString aStr = hAscii->ToCString();
1053 TCollection_AsciiString aAscii(aStr);
1058 #include<BRepPrimAPI_MakeCylinder.hxx>
1059 #include<BRepPrimAPI_MakeCone.hxx>
1061 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1065 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
1068 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1070 Standard_Integer IsB = Draw::Atoi(argv[1]);
1072 IsBRepAlgoAPI = Standard_False;
1073 #if ! defined(BRepAlgo_def01)
1074 // di << "Error: There is not BRepAlgo_Fuse class\n";
1080 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
1082 Standard_Real x11 = 36.085182;
1083 Standard_Real y11 = 20.0;
1084 Standard_Real z11 = 8.431413;
1085 Standard_Real x12 = 88.04671;
1086 Standard_Real y12 = 20.0;
1087 Standard_Real z12 = 38.931416;
1088 Standard_Real radius = 10.0;
1090 gp_Pnt base1(x11, y11, z11);
1091 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
1092 gp_Ax2 axis1(base1, vect1);
1093 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
1094 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
1096 TopoDS_Shape SCyl = cylinder.Shape();
1097 DBRep::Set("cyl", SCyl);
1100 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
1101 Standard_Real x21 = 70.7262;
1102 Standard_Real y21 = 20.0;
1103 Standard_Real z21 = 28.431412;
1104 Standard_Real x22 = 105.36722;
1105 Standard_Real y22 = 20.0;
1106 Standard_Real z22 = 48.431416;
1107 Standard_Real radius1 = 6.0;
1108 Standard_Real radius2 = 3.0;
1110 gp_Pnt base2(x21, y21, z21);
1111 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
1112 gp_Ax2 axis2(base2, vect2);
1113 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
1114 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1116 TopoDS_Shape SCon = cone.Shape();
1117 DBRep::Set("con", SCon);
1119 //#if ! defined(BRepAlgoAPI_def01)
1120 // BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1122 // BRepAlgo_Fuse SFuse(SCyl, SCon);
1125 // if(! SFuse.IsDone() )
1126 // cout<<"Error: Boolean fuse operation failed !"<<endl;
1128 // TopoDS_Shape fuse = SFuse.Shape();
1131 if (IsBRepAlgoAPI) {
1132 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)\n";
1133 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1134 if(! SFuse.IsDone() )
1135 di<<"Error: Boolean fuse operation failed !\n";
1136 fuse = SFuse.Shape();
1138 di << "BRepAlgo_Fuse SFuse(SCyl, SCon)\n";
1139 BRepAlgo_Fuse SFuse(SCyl, SCon);
1140 if(! SFuse.IsDone() )
1141 di<<"Error: Boolean fuse operation failed !\n";
1142 fuse = SFuse.Shape();
1145 DBRep::Set("fus", fuse);
1150 #include <Dico_DictionaryOfInteger.hxx>
1151 #include <TColStd_HSequenceOfAsciiString.hxx>
1152 #include <TopExp.hxx>
1153 #include <TopoDS_Iterator.hxx>
1155 //---------------------------------------------------------------------------------------
1157 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1160 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1163 di<<"Invalid input shape\n";
1166 Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
1167 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1168 Standard_CString aString;
1169 Standard_Integer i=1,j=1,l=1,aa=1;
1170 TopExp_Explorer expl;
1171 Standard_Real f3d,l3d;
1172 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1175 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1176 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1177 aString = aSurface->DynamicType()->Name();
1179 if(aDico->GetItem(aString,aa) != 0)
1181 aDico->GetItem(aString,aa);
1182 aDico->SetItem(aString,aa+1);
1184 aDico->SetItem(aString,1);
1185 aSequence->Append(aString);
1191 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1193 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1194 TopoDS_Iterator anIt(aFace);
1195 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1196 TopoDS_Iterator it (aWire);
1197 for (; it.More(); it.Next()) {
1198 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1199 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1200 aString = aCurve2d->DynamicType()->Name();
1201 if(aDico->GetItem(aString,aa) != 0)
1203 aDico->GetItem(aString,aa);
1204 aDico->SetItem(aString,aa+1);
1206 aDico->SetItem(aString,1);
1207 aSequence->Append(aString);
1214 TopExp_Explorer exp;
1215 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
1217 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1218 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1219 if(aCurve3d.IsNull())
1224 aString = aCurve3d->DynamicType()->Name();
1225 if(aDico->GetItem(aString,aa) != 0)
1227 aDico->GetItem(aString,aa);
1228 aDico->SetItem(aString,aa+1);
1230 aDico->SetItem(aString,1);
1231 aSequence->Append(aString);
1241 aDico->GetItem(aSequence->Value(j),aa);
1242 di<<aa<<" -- "<<aSequence->Value(j).ToCString()<<"\n";
1246 di<<"Degenerated edges :\n";
1247 di<<l<<" -- Degenerated edges \n";
1253 #include <BRepBuilderAPI_Transform.hxx>
1255 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1258 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
1261 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1263 Standard_Integer IsB = Draw::Atoi(argv[1]);
1265 IsBRepAlgoAPI = Standard_False;
1266 #if ! defined(BRepAlgo_def01)
1267 // di << "Error: There is not BRepAlgo_Fuse class\n";
1273 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1274 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1275 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1277 TopoDS_Shape sh1 = cyl.Shape();
1278 DBRep::Set("sh1",sh1);
1279 gp_Trsf trsf1, trsf2;
1280 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1281 gp_Pnt(0.000000,700.000000,-95.000000));
1282 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1283 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1284 BRepBuilderAPI_Transform trans1(sh1, trsf1);
1285 TopoDS_Shape sh2 = trans1.Shape();
1286 DBRep::Set("sh2",sh2);
1288 //#if ! defined(BRepAlgoAPI_def01)
1289 // BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1291 // BRepAlgo_Fuse fuse1(sh1, sh2);
1294 // TopoDS_Shape fsh1 = fuse1.Shape();
1297 if (IsBRepAlgoAPI) {
1298 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)\n";
1299 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1300 fsh1 = fuse1.Shape();
1302 di << "BRepAlgo_Fuse fuse1(sh1, sh2)\n";
1303 BRepAlgo_Fuse fuse1(sh1, sh2);
1304 fsh1 = fuse1.Shape();
1307 DBRep::Set("fsh1",fsh1);
1308 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1309 TopoDS_Shape sh3 = trans2.Shape();
1310 DBRep::Set("sh3",sh3);
1312 //#if ! defined(BRepAlgoAPI_def01)
1313 // BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1315 // BRepAlgo_Fuse fuse2(fsh1,sh3);
1318 // TopoDS_Shape fsh2 = fuse2.Shape();
1321 if (IsBRepAlgoAPI) {
1322 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)\n";
1323 BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1324 fsh2 = fuse2.Shape();
1326 di << "BRepAlgo_Fuse fuse2(fsh1,sh3)\n";
1327 BRepAlgo_Fuse fuse2(fsh1,sh3);
1328 fsh2 = fuse2.Shape();
1331 DBRep::Set("fsh2",fsh2);
1332 Handle(AIS_Shape) aisp1 = new AIS_Shape(fsh2);
1333 // aContext->Display(aisp1);
1337 #include <ShapeBuild_Edge.hxx>
1339 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1341 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1342 ShapeBuild_Edge().BuildCurve3d(e);
1348 #include<TDF_Label.hxx>
1349 #include<TDataStd_TreeNode.hxx>
1351 #include<DDocStd.hxx>
1355 #include<TDocStd_Modified.hxx>
1356 #include<TDF_ListIteratorOfDeltaList.hxx>
1357 #include<TDocStd_Document.hxx>
1358 #include<TDocStd_Application.hxx>
1359 #include<TDF_Delta.hxx>
1360 #include<TDataXtd_Constraint.hxx>
1361 #include<TPrsStd_AISPresentation.hxx>
1362 #include<TPrsStd_AISViewer.hxx>
1363 #include<TNaming_Builder.hxx>
1364 #include<TNaming_Naming.hxx>
1365 #include<TNaming_NamedShape.hxx>
1367 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1369 di << "Usage : " << argv[0] << " D\n";
1374 Handle(TDF_Data) DF;
1375 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1378 Handle(TDataStd_TreeNode) TN1,TN2;
1380 DDF::AddLabel(DF,"0:2",L1);
1381 TN1 = TDataStd_TreeNode::Set(L1);
1383 DDF::AddLabel(DF,"0:3",L2);
1384 TN2 = TDataStd_TreeNode::Set(L2);
1387 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1388 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1394 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1396 di << "Usage : " << argv[0] << " D\n";
1401 Handle(TDF_Data) DF;
1402 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1405 DDF::FindLabel(DF,"0:1",L,Standard_False);
1406 Handle(TDocStd_Modified) MDF;
1407 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1408 MDF = new TDocStd_Modified();
1409 L.Root().AddAttribute(MDF);
1412 di<<!MDF->IsEmpty();
1416 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1418 di << "Usage : " << argv[0] << " D Label\n";
1423 Handle(TDF_Data) DF;
1424 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1427 DDF::FindLabel(DF,argv[2],L,Standard_False);
1429 TDocStd_Modified::Add(L);
1435 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1437 di << "Usage : " << argv[0] << " D\n";
1443 Handle(TDF_Data) aDF;
1444 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1446 Handle(TDocStd_Document) aDocument;
1447 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1450 Handle(TDataStd_TreeNode) TN;
1452 aDocument->NewCommand();
1453 DDF::AddLabel(aDF,"0:2",L);
1454 TN = TDataStd_TreeNode::Set(L);
1456 aDocument->NewCommand();
1457 DDF::AddLabel(aDF,"0:3",L);
1458 TN = TDataStd_TreeNode::Set(L);
1460 aDocument->NewCommand();
1461 DDF::AddLabel(aDF,"0:4",L);
1462 TN = TDataStd_TreeNode::Set(L);
1463 aDocument->NewCommand();
1465 TDF_DeltaList Us,Rs;
1466 Us = aDocument->GetUndos();
1467 Rs = aDocument->GetUndos();
1470 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1472 TDF_ListIteratorOfDeltaList IDL;
1473 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1474 Handle(TDF_Delta) D = IDL.Value();
1475 TCollection_ExtendedString S(Names[i-1]);
1477 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1483 Us = aDocument->GetUndos();
1484 Rs = aDocument->GetRedos();
1486 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1487 Handle(TDF_Delta) D = IDL.Value();
1488 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1491 TCollection_ExtendedString n2name ("n2");
1492 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1493 Handle(TDF_Delta) D = IDL.Value();
1494 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1505 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1507 di << "Usage : " << argv[0] << " D Shape\n";
1512 Handle(TDF_Data) aDF;
1513 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1515 TopoDS_Shape s = DBRep::Get(argv[2]);
1516 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
1518 DDF::AddLabel(aDF, "0:2", L);
1519 TNaming_Builder SI (L);
1522 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1526 // if (!NS->IsEmpty()) {di<<3;return 0;}
1527 if (NS->IsEmpty()) {di<<4;return 0;}
1532 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1534 di << "Usage : " << argv[0] << " D Shape\n";
1539 Handle(TDF_Data) aDF;
1540 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1542 TopoDS_Shape s = DBRep::Get(argv[2]);
1543 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
1545 DDF::AddLabel(aDF, "0:2", L);
1546 TNaming_Builder SI (L);
1549 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1553 if (NS->IsEmpty()) {di<<4;return 0;}
1558 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1560 TCollection_ExtendedString path (argv[1]);
1561 Handle(TDocStd_Application) A;
1562 if (!DDocStd::Find(A)) {di<<1;return 0;}
1563 Handle(TDocStd_Document) D;
1564 Standard_Integer insession = A->IsInSession(path);
1565 if (insession > 0) {
1566 di <<"document " << insession << " is already in session\n";
1570 PCDM_ReaderStatus Result = A->Open(path,D);
1571 if(Result==PCDM_RS_OK){
1580 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1582 di << "Usage : " << argv[0] << " D\n";
1587 Handle(TDF_Data) aDF;
1588 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1591 DDF::AddLabel(aDF, "0:2", L);
1593 Handle(TPrsStd_AISPresentation) AISP =
1594 TPrsStd_AISPresentation::Set(L,TDataXtd_Constraint::GetID());
1596 if (AISP->HasOwnMode()) {di<<3;return 0;}
1598 Standard_Integer Mode = AISP->Mode();
1599 if (Mode!=3) {di<<4;return 0;}
1600 if (!AISP->HasOwnMode()) {di<<5;return 0;}
1602 if (AISP->HasOwnMode()) {di<<6;return 0;}
1607 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1609 di << "Usage : " << argv[0] << " D\n";
1614 Handle(TDF_Data) aDF;
1615 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1618 DDF::AddLabel(aDF, "0:2", L);
1622 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1623 // Handle(TNaming_Name) NN = new TNaming_Name;
1626 NN.Type(TNaming_IDENTITY);
1628 Standard_Boolean Res = NN.Solve(L,LM);
1630 if (Res!=Standard_False) {di<<3;return 0;}
1635 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1637 di << "Usage : " << argv[0] << " D\n";
1643 Handle(TDocStd_Document) aDocument;
1644 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
1646 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
1647 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
1653 //=======================================================================
1654 //function : AISWidth
1655 //purpose : AISWidth (DOC,entry,[width])
1656 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
1657 //=======================================================================
1659 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1662 Handle(TDocStd_Document) D;
1663 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
1665 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
1667 Handle(TPrsStd_AISViewer) viewer;
1668 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
1670 Handle(TPrsStd_AISPresentation) prs;
1671 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1673 prs->SetWidth(Draw::Atof(argv[3]));
1674 TPrsStd_AISViewer::Update(L);
1677 if (prs->HasOwnWidth()){
1678 // cout << "Width = " << prs->Width() << endl;
1682 di << "AISWidth: Warning : Width wasn't set\n";
1689 di << "AISWidth : Error" << "\n";
1694 //=======================================================================
1695 //function : BUC60921 ( & BUC60954 )
1696 //purpose : Test memory allocation of OCAF in Undo/Redo operations
1697 //=======================================================================
1699 static Standard_Integer BUC60921 (Draw_Interpretor& di,
1700 Standard_Integer nb,
1704 Handle(TDocStd_Document) D;
1705 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
1707 DDF::AddLabel(D->GetData(),arg[2],L);
1711 BRepTools::Read ( S, arg[3], B );
1713 TNaming_Builder tnBuild(L);
1714 tnBuild.Generated(S);
1715 // di << "File " << arg[3] << " added";
1719 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
1724 #include<IGESControl_Reader.hxx>
1725 #include<BRepPrimAPI_MakeHalfSpace.hxx>
1727 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
1731 // cerr << "Usage : " << a[0] << " file.igs" << endl;
1734 if(argc < 2 || argc > 3) {
1735 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
1738 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1740 Standard_Integer IsB = Draw::Atoi(a[2]);
1742 IsBRepAlgoAPI = Standard_False;
1743 #if ! defined(BRepAlgo_def01)
1744 // di << "Error: There is not BRepAlgo_Fuse class\n";
1750 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
1752 if(myContext.IsNull()) {
1753 di << "use 'vinit' command before " << a[0] << "\n";
1757 // IGESControlStd_Reader reader;
1758 IGESControl_Reader reader;
1759 reader.ReadFile(a[1]);
1760 reader.TransferRoots();
1761 TopoDS_Shape shape = reader.OneShape();
1762 printf("\n iges1 shape type = %d", shape.ShapeType() );
1763 TopTools_IndexedMapOfShape list;
1764 TopExp::MapShapes(shape, TopAbs_FACE, list);
1765 printf("\n No. of faces = %d", list.Extent());
1768 BRep_Builder builder;
1769 builder.MakeShell(shell);
1770 for(int i=1;i<=list.Extent(); i++) {
1771 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
1772 builder.Add(shell, face);
1774 shell.Closed (BRep_Tool::IsClosed (shell));
1776 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
1777 TopoDS_Solid sol = half.Solid();
1778 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
1779 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
1780 TopoDS_Shape sh = cyl.Shape();
1782 //#if ! defined(BRepAlgoAPI_def01)
1783 // BRepAlgoAPI_Fuse fuse(sol, sh);
1785 // BRepAlgo_Fuse fuse(sol, sh);
1788 // sh = fuse.Shape();
1790 if (IsBRepAlgoAPI) {
1791 di << "BRepAlgoAPI_Fuse fuse(sol, sh)\n";
1792 BRepAlgoAPI_Fuse fuse(sol, sh);
1795 di << "BRepAlgo_Fuse fuse(sol, sh)\n";
1796 BRepAlgo_Fuse fuse(sol, sh);
1800 Handle(AIS_Shape) res = new AIS_Shape(sh);
1801 myContext->Display( res );
1805 void QABugs::Commands_3(Draw_Interpretor& theCommands) {
1806 const char *group = "QABugs";
1808 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
1809 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
1810 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
1811 theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group);
1812 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
1813 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
1814 theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d",__FILE__,ksection,group);
1815 theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d",__FILE__,ksection,group);
1816 theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d",__FILE__,ksection,group);
1817 theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d",__FILE__,ksection,group);
1818 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
1820 theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
1821 theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
1822 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
1823 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
1825 theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
1826 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
1827 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
1828 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
1829 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
1830 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
1832 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
1834 theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
1836 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
1838 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
1840 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
1841 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
1842 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
1843 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
1845 theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
1847 theCommands.Add("statface","statface face",__FILE__,statface,group);
1849 theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
1851 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
1853 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
1854 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
1855 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
1856 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
1857 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
1858 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
1859 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
1860 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
1861 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
1862 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
1863 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
1864 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
1866 theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );