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.
21 #include <Draw_Interpretor.hxx>
22 #include <TopLoc_Location.hxx>
23 #include <TopoDS_Face.hxx>
26 #include <Geom_Surface.hxx>
27 #include <BRep_Tool.hxx>
28 #include <GeomInt_IntSS.hxx>
29 #include <BRepBuilderAPI_MakeEdge.hxx>
30 #include <Standard_ErrorHandler.hxx>
31 #include <Graphic3d_ClipPlane.hxx>
35 static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
39 di << "Usage : " << a[0] << " result Shape1 Shape2" << "\n";
45 TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
46 TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
47 Handle(Geom_Surface) GSF1 = BRep_Tool::Surface(F1, L1);
48 Handle(Geom_Surface) GSF2 = BRep_Tool::Surface(F2, L2);
50 Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1));
51 if (!Inter.IsDone()) {
52 di << "Intersection not done" << "\n";
55 Standard_Integer nbsol = Inter.NbLines();
57 di << "The number of solutions is zero!" << "\n";
60 Handle(Geom_Curve) Sol = Inter.Line(1);
62 DBRep::Set(a[1], BRepBuilderAPI_MakeEdge(Sol));
64 } else di << "The first solution is Null!" << "\n";
70 #include<ViewerTest.hxx>
71 #include<AIS_InteractiveContext.hxx>
72 #include<AIS_Shape.hxx>
74 static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
78 di << "Usage : " << argv[0] << " shape" << "\n";
82 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
83 if(myAISContext.IsNull()) {
84 di << "use 'vinit' command before " << argv[0] << "\n";
88 TopoDS_Shape theShape = DBRep::Get(argv[1]);
90 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
91 myAISContext->Display( anAISShape, Standard_True );
92 myAISContext->OpenLocalContext();
93 myAISContext->ActivateStandardMode(TopAbs_FACE);
97 static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
101 di << "Usage : "<< argv[0] << " shape" << "\n";
107 TopoDS_Shape theShape = DBRep::Get(argv[1]);
109 // ViewerTest::GetAISContext();
110 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
111 if(myAISContext.IsNull()) {
112 di << "use 'vinit' command before " << argv[0] << "\n";
115 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
116 myAISContext->Display( anAISShape, Standard_True );
117 myAISContext->OpenLocalContext();
118 myAISContext->ActivateStandardMode(TopAbs_COMPOUND);
119 // myAISContext->ActivateStandardMode(TopAbs_SOLID);
121 // cout << "vfini" << endl;
125 #include<BRep_Builder.hxx>
126 #include<BRepTools_ShapeSet.hxx>
127 #include<BRepTools.hxx>
128 #include<BRepAdaptor_HSurface.hxx>
129 #include<TopOpeBRep_PointClassifier.hxx>
130 #include<Precision.hxx>
135 static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
140 // BUC60609 shape name
141 } else if ( argc == 5 ) {
142 // BUC60609 shape name U V
144 di << "Usage : "<< argv[0] << " shape name [U V]" << "\n";
148 TCollection_AsciiString aFilePath(argv[1]);
152 if (!fic.open(aFilePath.ToCString(),ios::in)) {
153 di << "Cannot open file for reading : " << aFilePath << "\n";
157 TopoDS_Shape theShape;
161 if( !strcmp(typ, "DBRep_DrawableShape") ){
163 BRepTools_ShapeSet S(B);
167 di << "Wrong entity type in " << aFilePath << "\n";
172 const TopoDS_Face &face = TopoDS::Face (theShape);
175 DBRep::Set(argv[2],face);
178 Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
180 BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
182 di << "The bounds of the trimmed face:" << "\n";
183 di << faceUMin << " <= U <= " << faceUMax << "\n";
184 di << faceVMin << " <= V <= " << faceVMax << "\n";
186 Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
188 TopOpeBRep_PointClassifier PClass;
190 di << "Now test the point classifier by inputting U,V values" << "\n";
191 di << "inside or outside the bounds displayed above" << "\n";
192 di << "Type stop to exit" << "\n";
194 // Please register this:
195 // ***********************************************
196 // Note also that for periodic surfaces such as nimpod_1.topo,
197 // the U/V values may be +- 2pi compared to the actual face bounds
198 // (because U,V is probably coming from a Geom package routine).
199 // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
200 // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
201 // *************************************************
204 uvSurf = gp_Pnt2d(0.14,5.1);
205 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
206 if(state == TopAbs_IN || state == TopAbs_ON){
207 di << "U=" << 0.14 << " V=" << 5.1 << " classified INSIDE" << "\n";
209 di << "U=" << 0.14 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
212 uvSurf = gp_Pnt2d(1.28,5.1);
213 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
214 if(state == TopAbs_IN || state == TopAbs_ON){
215 di << "U=" << 1.28 << " V=" << 5.1 << " classified INSIDE" << "\n";
217 di << "U=" << 1.28 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
220 uvSurf = gp_Pnt2d(Draw::Atof(argv[3]),Draw::Atof(argv[4]));
221 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
222 if(state == TopAbs_IN || state == TopAbs_ON){
223 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified INSIDE" << "\n";
225 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified OUTSIDE" << "\n";
231 #include<BRepBuilderAPI_MakeVertex.hxx>
232 #include<TCollection_ExtendedString.hxx>
233 #include<AIS_LengthDimension.hxx>
235 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
238 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
239 if(myAIScontext.IsNull()) {
240 di << "use 'vinit' command before " << a[0] << "\n";
243 myAIScontext->EraseAll();
245 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
246 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
248 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
249 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
251 myAIScontext->Display(Ve1);
252 myAIScontext->Display(Ve2);
254 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
255 TCollection_ExtendedString Ext1("Dim1");
256 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln());
257 Dim1->SetCustomValue (Draw::Atof(a[2]));
259 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
260 anAspect->MakeArrows3d (Standard_False);
261 anAspect->MakeText3d (Standard_True);
262 anAspect->MakeTextShaded (Standard_True);
263 anAspect->TextAspect()->SetHeight (2.5);
264 anAspect->ArrowAspect()->SetLength (1.0);
265 Dim1->SetDimensionAspect (anAspect);
267 myAIScontext->SetDisplayMode(Dim1, Draw::Atoi(a[1]));
268 myAIScontext->Display(Dim1);
272 #include<TopoDS_Wire.hxx>
274 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
277 di << "Usage : BUC60652 fase" << "\n";
280 TopoDS_Shape shape = DBRep::Get( argv[1] );
281 TopoDS_Face face = TopoDS::Face( shape );
282 TopoDS_Wire ow = BRepTools::OuterWire( face );
283 DBRep::Set( "w", ow );
287 #include <BRepAlgo_BooleanOperations.hxx>
289 static Standard_Integer defNbPntMax = 30;
290 static Standard_Real defTol3d = 1.e-7;
291 static Standard_Real defTol2d = 1.e-7;
292 static Standard_Boolean defRelativeTol=Standard_True;
293 Standard_Integer NbPntMax = defNbPntMax;
294 Standard_Real Toler3d =defTol3d;
295 Standard_Real Toler2d = defTol2d;
296 Standard_Boolean RelativeTol= defRelativeTol;
297 // //== // ksection : operateur section appelant BRepAlgo_BooleanOperation
298 //== // ksection : operateur section appelant BRepAlgo_BooleanOperations
299 //=======================================================================
300 Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) {
302 di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol" << "\n";
312 TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL);
313 TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL);
314 if (s1.IsNull() || s2.IsNull()) return 1;
315 NbPntMax=Draw::Atoi(a[4]);
316 Toler3d=Draw::Atof(a[5]);
317 Toler2d=Draw::Atof(a[6]);
318 RelativeTol=Draw::Atoi(a[7]);
320 di << "BRepAlgo_BooleanOperations myalgo" << "\n";
321 BRepAlgo_BooleanOperations myalgo;
323 myalgo.Shapes(s1, s2);
324 myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d,RelativeTol);
325 TopoDS_Shape res; res = myalgo.Section();
326 DBRep::Set(a[1],res);
330 #include <Geom_Axis2Placement.hxx>
331 #include <AIS_Trihedron.hxx>
333 static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
336 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
337 if(myAISContext.IsNull()) {
338 di << "use 'vinit' command before " << a[0] << "\n";
342 Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY());
343 Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis);
346 aTrsf.SetTranslation(trans);
347 TopLoc_Location aLoc(aTrsf);
348 myAISContext->SetLocation(atri,aLoc);
349 myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
350 myAISContext->OpenLocalContext(Standard_False,
351 Standard_True,Standard_False,Standard_False);
352 myAISContext->Load(atri,3,Standard_True);
357 #include <TopoDS_Solid.hxx>
358 #include <BRepPrimAPI_MakeBox.hxx>
359 #include <BRepPrimAPI_MakeSphere.hxx>
361 #include <BRepAlgoAPI_Fuse.hxx>
362 #include <BRepAlgo_Fuse.hxx>
364 #include <V3d_View.hxx>
365 #include <gce_MakePln.hxx>
367 static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
370 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
371 if(myAISContext.IsNull()) {
372 di << "use 'vinit' command before " << a[0] << "\n";
375 TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid();
376 TopAbs_ShapeEnum theType = B1.ShapeType();
377 if ( theType == TopAbs_SOLID ) {
378 di << "It is a solid." << "\n";
380 di << "It is not solid." << "\n";
382 myAISContext->Display(new AIS_Shape(B1));
383 myAISContext->OpenLocalContext();
384 TopAbs_ShapeEnum amode = TopAbs_SOLID;
385 myAISContext->ActivateStandardMode(amode);
387 di.Eval("QAMoveTo 200 200");
388 di.Eval("QASelect 200 200");
389 myAISContext->InitSelected() ;
390 if ( myAISContext->MoreSelected() ) {
391 if (myAISContext->HasSelectedShape() ) {
392 di << "has selected shape : OK" << "\n";
394 di << "has selected shape : bugged - Faulty " << "\n";
400 static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
403 di << "Usage : " << argv[0] << " [1/0]" << "\n";
407 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
408 if(myAIScontext.IsNull()) {
409 di << "use 'vinit' command before " << argv[0] << "\n";
412 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
414 if((argc == 2) && (Draw::Atof(argv[1]) == 0))
415 myV3dView->SetAntialiasingOff();
417 myV3dView->SetAntialiasingOn();
423 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
425 //=======================================================================
426 //function : GetColorFromName
427 //purpose : get the Quantity_NameOfColor from a string
428 //=======================================================================
430 static Quantity_NameOfColor GetColorFromName( const char *name )
432 Quantity_NameOfColor ret = DEFAULT_COLOR;
434 Standard_Boolean Found = Standard_False;
435 Standard_CString colstring;
436 for(Standard_Integer i=0;i<=514 && !Found;i++)
438 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
439 if (!strcasecmp(name,colstring)) {
440 ret = (Quantity_NameOfColor)i;
441 Found = Standard_True;
448 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
451 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
452 if(myAISContext.IsNull()) {
453 di << "use 'vinit' command before " << argv[0] << "\n";
457 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
463 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
465 // Change the background color of the view with a predefined name Graphic3d_NOC_<name>
467 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
468 myV3dView -> Redraw();
474 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
475 // setcolor <object> <name>
476 // Change the object color with a predefined name
478 TopoDS_Shape aShape = DBRep::Get(argv[1]);
479 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
480 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
481 myAISContext->Display(myShape,Standard_True);
482 myAISContext->UpdateCurrentViewer();
488 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
490 // setcolor <r> <g> <b>
491 // Change the background color of the view with the color values <r>,<g>,<b>
492 // A color value must be defined in the space [0.,1.]
494 Standard_Real QuantityOfRed = Draw::Atoi(argv[1]);
495 Standard_Real QuantityOfGreen = Draw::Atoi(argv[2]);
496 Standard_Real QuantityOfBlue = Draw::Atoi(argv[3]);
497 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
504 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
506 // setcolor <object> <r> <g> <b>
507 // change the object color with RGB values.
510 Standard_Real QuantityOfRed = Draw::Atof(argv[2]);
511 Standard_Real QuantityOfGreen = Draw::Atof(argv[3]);
512 Standard_Real QuantityOfBlue = Draw::Atof(argv[4]);
514 TopoDS_Shape aShape = DBRep::Get(argv[1]);
515 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
516 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
517 myAISContext->Display(myShape,Standard_True);
518 myAISContext->UpdateCurrentViewer();
519 // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
520 // myShape->Redisplay();
527 static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
529 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
530 if(myAISContext.IsNull()) {
531 di << "use 'vinit' command before " << argv[0] << "\n";
536 di << "Usage : " << argv[0] << " 0/1" << "\n";
539 if(Draw::Atoi(argv[1]) == 0) {
540 myAISContext->CloseAllContexts();
541 BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.);
542 Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());
543 myAISContext->Display(aBox);
544 } else if(Draw::Atoi(argv[1]) == 1) {
545 myAISContext->CloseAllContexts();
546 myAISContext->OpenLocalContext();
547 myAISContext->ActivateStandardMode(TopAbs_EDGE);
548 } else if(Draw::Atoi(argv[1]) == 2) {
549 myAISContext->CloseAllContexts();
550 myAISContext->OpenLocalContext();
551 myAISContext->ActivateStandardMode(TopAbs_FACE);
553 di << "Usage : " << argv[0] << " 0/1" << "\n";
560 #include <BRepBndLib.hxx>
561 #include <Bnd_HArray1OfBox.hxx>
563 static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ )
566 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
568 BRepBndLib::Add(aShape , aMainBox );
570 Standard_Integer siMaxNbrBox = 6;
571 Bnd_BoundSortBox m_BoundSortBox;
572 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
573 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
577 // Bnd_Box __emptyBox; // Box is void !
578 // Handle(Bnd_HArray1OfBox) __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
580 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
582 const TopoDS_Shape& aFace = aExplorer.Current();
584 BRepBndLib::Add( aFace, aBox );
585 m_BoundSortBox.Add( aBox, i );
586 // __aSetOfBox->SetValue( i, aBox );
588 // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
593 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
595 TCollection_AsciiString as1("");
596 TCollection_AsciiString as2('\0');
597 if(as1.ToCString() == NULL || as1.Length() != 0 || as1.ToCString()[0] != '\0')
598 di << "Error : the first string is not zero string : " << as1.ToCString() << "\n";
600 if(as2.ToCString() == NULL || as2.Length() != 0 || as2.ToCString()[0] != '\0')
601 di << "Error : the second string is not zero string : " << as2.ToCString() << "\n";
606 #include <UnitsAPI.hxx>
608 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
610 di <<"Program Test" << "\n";
611 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
612 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
617 #include <gp_Circ.hxx>
618 #include <Geom_Circle.hxx>
619 #include <GeomAPI.hxx>
620 #include <Geom2d_CartesianPoint.hxx>
621 #include <Geom2dGcc_QualifiedCurve.hxx>
622 #include <Geom2dGcc_Circ2d2TanRad.hxx>
623 #include <Geom2d_Circle.hxx>
624 #include <ProjLib.hxx>
626 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
628 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
629 if(aContext.IsNull()) {
630 di << "use 'vinit' command before " << argv[0] << "\n";
634 gp_Pnt pt3d(0, 20, 150);
635 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
636 gp_Circ circ(anAx2, 50.0);
637 Handle(Geom_Circle) gcir = new Geom_Circle(circ);
638 Handle(Geom_Plane) pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
639 Handle(Geom2d_Curve) gcir1 = GeomAPI::To2d(gcir, pln->Pln());
640 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
641 Handle(AIS_Shape) ais1 = new AIS_Shape(sh1);
642 aContext->SetColor(ais1, Quantity_NOC_INDIANRED);
643 aContext->Display(ais1);
644 DBRep::Set("sh0",sh1);
646 // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
647 thepoint = ProjLib::Project(pln->Pln(),pt3d);
648 Handle(Geom2d_CartesianPoint) ThePoint = new Geom2d_CartesianPoint(thepoint);
649 Geom2dAdaptor_Curve acur1(gcir1) ;
650 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
651 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
652 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
653 Handle(Geom2d_Circle) gccc;
654 if( cirtanrad.NbSolutions() ) {
655 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
656 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
657 gccc = new Geom2d_Circle(ccc);
658 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
659 Standard_Character aStr[5];
660 Sprintf(aStr,"sh%d",i);
662 Handle(AIS_Shape) ais = new AIS_Shape(sh);
664 aContext->SetColor(ais, Quantity_NOC_GREEN);
666 aContext->SetColor(ais, Quantity_NOC_HOTPINK);
667 aContext->Display(ais);
668 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
669 gp_Pnt2d PntSol1, PntSol2;
670 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
671 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
672 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
673 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
679 #include <TColgp_Array2OfPnt.hxx>
680 #include <Geom_BezierSurface.hxx>
681 #include <BRepBuilderAPI_MakeFace.hxx>
682 #include <BRepBuilderAPI_MakeWire.hxx>
683 #include <Geom_OffsetSurface.hxx>
684 #include <BRepFilletAPI_MakeFillet2d.hxx>
685 #include <GeomProjLib.hxx>
686 #include <Geom_TrimmedCurve.hxx>
688 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
692 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
693 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
694 Standard_Real f = 0.0, l = 0.0;
695 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
696 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
697 GC = new Geom_TrimmedCurve(GC, f, l);
698 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
699 BRepBuilderAPI_MakeWire *myWire;
700 myWire = new BRepBuilderAPI_MakeWire();
701 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
702 DBRep::Set(argv[1],myWire->Wire());
706 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
707 if(aContext.IsNull()) {
708 di << "use 'vinit' command before " << argv[0] << "\n";
712 //step 1. creating a Bezier Surface and a patch
716 Handle(AIS_Shape) ais1;
717 Handle(AIS_Shape) ais2;
718 Handle(Geom_BezierSurface) BZ1;
719 TColgp_Array2OfPnt array1(1,3,1,3);
720 array1.SetValue(1,1,gp_Pnt(0,100,0));
721 array1.SetValue(1,2,gp_Pnt(200,100,0));
722 array1.SetValue(1,3,gp_Pnt(400,100,0));
723 array1.SetValue(2,1,gp_Pnt(0,200,100));
724 array1.SetValue(2,2,gp_Pnt(200,200,100));
725 array1.SetValue(2,3,gp_Pnt(400,200,100));
726 array1.SetValue(3,1,gp_Pnt(0,300,0));
727 array1.SetValue(3,2,gp_Pnt(200,300,0));
728 array1.SetValue(3,3,gp_Pnt(400,300,0));
729 BZ1 = new Geom_BezierSurface(array1);
730 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
731 TopoDS_Face F1= bzf1.Face();
732 ais1 = new AIS_Shape(F1);
734 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
735 aContext->Display(ais1);
742 gp_Dir D(0, 0, 1.0f);
743 BRepBuilderAPI_MakeWire mkw;
744 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
745 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
746 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
748 p1 = gp_Pnt(350., 150., 260.);
749 p2 = gp_Pnt(350., 250., 260.);
750 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
752 p1 = gp_Pnt(350., 250., 260.);
753 p2 = gp_Pnt(300., 250.0, 260.);
754 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
756 p1 = gp_Pnt(300., 250.0, 260.);
757 p2 = gp_Pnt(200., 200.0, 260.);
758 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
760 p1 = gp_Pnt(200., 200.0, 260.);
761 p2 = gp_Pnt(150., 200.0, 260.);
762 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
764 p1 = gp_Pnt(150., 200.0, 260.);
765 p2 = gp_Pnt(150., 150.0, 260.);
766 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
768 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
769 ais2 = new AIS_Shape( FP );
770 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
771 aContext->Display( ais2 );
775 //step 2. offseting the surface.
776 Handle(Geom_OffsetSurface) offsurf;
777 offsurf = new Geom_OffsetSurface(BZ1, -100);
778 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
779 TopoDS_Face F2= bzf2.Face();
780 Handle(AIS_Shape) ais22 = new AIS_Shape(F2);
781 aContext->Display(ais22);
784 //step 3. filleting the patch.
785 //( I want to project wire of this patch on offseted surface above)
786 BRepFilletAPI_MakeFillet2d fillet( FP );
788 Ex.Init(FP, TopAbs_VERTEX);
789 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
790 fillet.AddFillet(v1, 20);
791 di << "\n" << "Error is " << fillet.Status() << "\n";
792 // printf("\nError is %d ", fillet.Status());
794 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
795 fillet.AddFillet(V2, 20);
796 di << "\n" << "Error is " << fillet.Status() << "\n";
797 // printf("\nError is %d ", fillet.Status());
799 FP1 = fillet.Shape();
800 ais2 = new AIS_Shape( FP1 );
801 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
802 aContext->Display( ais2 );
804 DBRep::Set("FP1",FP1);
806 //step 4. Projecting the wire of this patch on offsetted surface.
807 // TopExp_Explorer Ex;
808 BRepBuilderAPI_MakeWire *myWire;
809 myWire = new BRepBuilderAPI_MakeWire();
810 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
812 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
813 Standard_Real f = 0.0, l = 0.0;
814 Handle(Geom_Curve) newBSplin = BRep_Tool::Curve(e1, f, l);
815 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
816 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
817 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
819 Handle(AIS_Shape) ais33 = new AIS_Shape( myWire->Wire() );
820 aContext->Display(ais33);
822 DBRep::Set("Wire",myWire->Wire());
827 #include<GeomAPI_ExtremaCurveCurve.hxx>
829 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
833 printf("Usage: %s edge1 edge2",argv[0]);
837 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
838 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
840 Standard_Real fp , lp;
842 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
843 C2 = BRep_Tool::Curve(E2 , fp , lp);
845 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
847 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
852 #include <BRepBuilderAPI_MakePolygon.hxx>
853 #include <BRepOffsetAPI_ThruSections.hxx>
855 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
858 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
861 Standard_Boolean IsBRepAlgoAPI = Standard_True;
863 Standard_Integer IsB = Draw::Atoi(argv[1]);
865 IsBRepAlgoAPI = Standard_False;
866 #if ! defined(BRepAlgo_def01)
867 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
873 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
874 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
875 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
876 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
877 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
879 for (int i=0;i<4;i++) {
880 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
881 bottompolygon1.Add(tmppnt);
882 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
883 toppolygon1.Add(tmppnt);
884 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
885 bottompolygon2.Add(tmppnt);
886 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
887 toppolygon2.Add(tmppnt);
889 bottompolygon1.Close();
890 DBRep::Set("B1",bottompolygon1.Shape());
892 DBRep::Set("T1",toppolygon1.Shape());
893 bottompolygon2.Close();
894 DBRep::Set("B2",bottompolygon2.Shape());
896 DBRep::Set("T2",toppolygon2.Shape());
897 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
898 loft1.AddWire(bottompolygon1.Wire());
899 loft1.AddWire(toppolygon1.Wire());
901 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
902 loft2.AddWire(bottompolygon2.Wire());
903 loft2.AddWire(toppolygon2.Wire());
905 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
907 DBRep::Set("TS1",loft1.Shape());
908 DBRep::Set("TS2",loft2.Shape());
910 //#if ! defined(BRepAlgoAPI_def01)
911 // BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
913 // BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
916 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
917 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
918 DBRep::Set("F",result.Shape());
920 di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
921 BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
922 DBRep::Set("F",result.Shape());
925 // DBRep::Set("F",result.Shape());
929 #include <Geom_RectangularTrimmedSurface.hxx>
930 #include <GC_MakeTrimmedCone.hxx>
932 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
934 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
935 if(aContext.IsNull()) {
936 di << "use 'vinit' command before " << argv[0] << "\n";
943 P1(0,0,20), P2(0,0,45);
944 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
945 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
946 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
947 aContext->Display(ais1);
948 aContext->SetColor(ais1, Quantity_NOC_BLUE1);
950 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
951 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
952 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
953 aContext->Display(ais2);
954 aContext->SetColor(ais2, Quantity_NOC_RED);
958 //==========================================================================
959 //function : CoordLoad
960 // chargement d une face dans l explorer.
961 //==========================================================================
962 static Standard_Integer coordload (Draw_Interpretor& theDi,
963 Standard_Integer theArgsNb,
964 const char** theArgVec)
971 std::ifstream aFile (theArgVec[2], ios::in);
974 theDi << "unable to open " << theArgVec[2] << " for input\n";
979 memset (aLine, 0, 40);
980 aFile.getline (aLine, 80);
982 gp_Pnt aPnt (0.0, 0.0, 0.0);
984 aPnt.SetY (Draw::Atof (&aLine[20]));
986 aPnt.SetX (Draw::Atof (aLine));
987 TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt);
988 BRepBuilderAPI_MakeWire aMakeWire;
991 memset (aLine, 0, 40);
992 aFile.getline (aLine, 80);
999 aPnt.SetY (Draw::Atof (&aLine[20]));
1001 aPnt.SetX (Draw::Atof (aLine));
1002 TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt);
1003 aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2));
1008 if (!aMakeWire.IsDone())
1010 DBRep::Set (theArgVec[1], TopoDS_Face());
1014 BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire());
1015 DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face());
1019 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
1020 Standard_Integer /*nb*/,
1021 const char ** /*arg*/)
1023 TCollection_ExtendedString aString(1024*1024, 'A');
1027 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
1028 Standard_Integer argc,
1031 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1032 if(aContext.IsNull()) {
1033 di << "use 'vinit' command before " << argv[0] << "\n";
1036 if((argc != 2) && (argc != 3)) {
1037 di<< "usage : " << argv[0] << " shape [mode==1]" << "\n";
1040 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1041 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
1042 // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
1043 anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
1044 aContext->Display(anIO);
1048 //=======================================================================
1049 //function : buc60773
1051 //=======================================================================
1053 #include<TCollection_HAsciiString.hxx>
1055 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
1057 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
1058 Standard_CString aStr = hAscii->ToCString();
1059 TCollection_AsciiString aAscii(aStr);
1064 #include<BRepPrimAPI_MakeCylinder.hxx>
1065 #include<BRepPrimAPI_MakeCone.hxx>
1067 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1071 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1074 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1076 Standard_Integer IsB = Draw::Atoi(argv[1]);
1078 IsBRepAlgoAPI = Standard_False;
1079 #if ! defined(BRepAlgo_def01)
1080 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1086 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
1088 Standard_Real x11 = 36.085182;
1089 Standard_Real y11 = 20.0;
1090 Standard_Real z11 = 8.431413;
1091 Standard_Real x12 = 88.04671;
1092 Standard_Real y12 = 20.0;
1093 Standard_Real z12 = 38.931416;
1094 Standard_Real radius = 10.0;
1096 gp_Pnt base1(x11, y11, z11);
1097 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
1098 gp_Ax2 axis1(base1, vect1);
1099 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
1100 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
1102 TopoDS_Shape SCyl = cylinder.Shape();
1103 DBRep::Set("cyl", SCyl);
1106 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
1107 Standard_Real x21 = 70.7262;
1108 Standard_Real y21 = 20.0;
1109 Standard_Real z21 = 28.431412;
1110 Standard_Real x22 = 105.36722;
1111 Standard_Real y22 = 20.0;
1112 Standard_Real z22 = 48.431416;
1113 Standard_Real radius1 = 6.0;
1114 Standard_Real radius2 = 3.0;
1116 gp_Pnt base2(x21, y21, z21);
1117 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
1118 gp_Ax2 axis2(base2, vect2);
1119 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
1120 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1122 TopoDS_Shape SCon = cone.Shape();
1123 DBRep::Set("con", SCon);
1125 //#if ! defined(BRepAlgoAPI_def01)
1126 // BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1128 // BRepAlgo_Fuse SFuse(SCyl, SCon);
1131 // if(! SFuse.IsDone() )
1132 // cout<<"Error: Boolean fuse operation failed !"<<endl;
1134 // TopoDS_Shape fuse = SFuse.Shape();
1137 if (IsBRepAlgoAPI) {
1138 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n";
1139 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1140 if(! SFuse.IsDone() )
1141 di<<"Error: Boolean fuse operation failed !"<<"\n";
1142 fuse = SFuse.Shape();
1144 di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n";
1145 BRepAlgo_Fuse SFuse(SCyl, SCon);
1146 if(! SFuse.IsDone() )
1147 di<<"Error: Boolean fuse operation failed !"<<"\n";
1148 fuse = SFuse.Shape();
1151 DBRep::Set("fus", fuse);
1156 #include <Dico_DictionaryOfInteger.hxx>
1157 #include <TColStd_HSequenceOfAsciiString.hxx>
1158 #include <TopExp.hxx>
1159 #include <TopoDS_Iterator.hxx>
1161 //---------------------------------------------------------------------------------------
1163 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1166 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1169 di<<"Invalid input shape"<<"\n";
1172 Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
1173 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1174 Standard_CString aString;
1175 Standard_Integer i=1,j=1,l=1,aa=1;
1176 TopExp_Explorer expl;
1177 Standard_Real f3d,l3d;
1178 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1181 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1182 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1183 aString = aSurface->DynamicType()->Name();
1185 if(aDico->GetItem(aString,aa) != 0)
1187 aDico->GetItem(aString,aa);
1188 aDico->SetItem(aString,aa+1);
1190 aDico->SetItem(aString,1);
1191 aSequence->Append(aString);
1197 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1199 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1200 TopoDS_Iterator anIt(aFace);
1201 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1202 TopoDS_Iterator it (aWire);
1203 for (; it.More(); it.Next()) {
1204 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1205 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1206 aString = aCurve2d->DynamicType()->Name();
1207 if(aDico->GetItem(aString,aa) != 0)
1209 aDico->GetItem(aString,aa);
1210 aDico->SetItem(aString,aa+1);
1212 aDico->SetItem(aString,1);
1213 aSequence->Append(aString);
1220 TopExp_Explorer exp;
1221 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
1223 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1224 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1225 if(aCurve3d.IsNull())
1230 aString = aCurve3d->DynamicType()->Name();
1231 if(aDico->GetItem(aString,aa) != 0)
1233 aDico->GetItem(aString,aa);
1234 aDico->SetItem(aString,aa+1);
1236 aDico->SetItem(aString,1);
1237 aSequence->Append(aString);
1247 aDico->GetItem(aSequence->Value(j),aa);
1248 di<<aa<<" -- "<<aSequence->Value(j).ToCString()<<"\n";
1252 di<<"Degenerated edges :"<<"\n";
1253 di<<l<<" -- "<<"Degenerated edges "<<"\n";
1259 #include <BRepBuilderAPI_Transform.hxx>
1261 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1264 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1267 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1269 Standard_Integer IsB = Draw::Atoi(argv[1]);
1271 IsBRepAlgoAPI = Standard_False;
1272 #if ! defined(BRepAlgo_def01)
1273 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1279 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1280 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1281 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1283 TopoDS_Shape sh1 = cyl.Shape();
1284 DBRep::Set("sh1",sh1);
1285 gp_Trsf trsf1, trsf2;
1286 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1287 gp_Pnt(0.000000,700.000000,-95.000000));
1288 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1289 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1290 BRepBuilderAPI_Transform trans1(sh1, trsf1);
1291 TopoDS_Shape sh2 = trans1.Shape();
1292 DBRep::Set("sh2",sh2);
1294 //#if ! defined(BRepAlgoAPI_def01)
1295 // BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1297 // BRepAlgo_Fuse fuse1(sh1, sh2);
1300 // TopoDS_Shape fsh1 = fuse1.Shape();
1303 if (IsBRepAlgoAPI) {
1304 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n";
1305 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1306 fsh1 = fuse1.Shape();
1308 di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n";
1309 BRepAlgo_Fuse fuse1(sh1, sh2);
1310 fsh1 = fuse1.Shape();
1313 DBRep::Set("fsh1",fsh1);
1314 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1315 TopoDS_Shape sh3 = trans2.Shape();
1316 DBRep::Set("sh3",sh3);
1318 //#if ! defined(BRepAlgoAPI_def01)
1319 // BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1321 // BRepAlgo_Fuse fuse2(fsh1,sh3);
1324 // TopoDS_Shape fsh2 = fuse2.Shape();
1327 if (IsBRepAlgoAPI) {
1328 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n";
1329 BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1330 fsh2 = fuse2.Shape();
1332 di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n";
1333 BRepAlgo_Fuse fuse2(fsh1,sh3);
1334 fsh2 = fuse2.Shape();
1337 DBRep::Set("fsh2",fsh2);
1338 Handle(AIS_Shape) aisp1 = new AIS_Shape(fsh2);
1339 // aContext->Display(aisp1);
1343 #include <ShapeBuild_Edge.hxx>
1345 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1347 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1348 ShapeBuild_Edge().BuildCurve3d(e);
1354 #include<TDF_Label.hxx>
1355 #include<TDataStd_TreeNode.hxx>
1357 #include<DDocStd.hxx>
1361 #include<TDocStd_Modified.hxx>
1362 #include<TDF_ListIteratorOfDeltaList.hxx>
1363 #include<TDocStd_Document.hxx>
1364 #include<TDocStd_Application.hxx>
1365 #include<TDF_Delta.hxx>
1366 #include<TDataXtd_Constraint.hxx>
1367 #include<TPrsStd_AISPresentation.hxx>
1368 #include<TPrsStd_AISViewer.hxx>
1369 #include<TNaming_Builder.hxx>
1370 #include<TNaming_Naming.hxx>
1371 #include<TNaming_NamedShape.hxx>
1373 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1375 di << "Usage : " << argv[0] << " D" << "\n";
1380 Handle(TDF_Data) DF;
1381 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1384 Handle(TDataStd_TreeNode) TN1,TN2;
1386 DDF::AddLabel(DF,"0:2",L1);
1387 TN1 = TDataStd_TreeNode::Set(L1);
1389 DDF::AddLabel(DF,"0:3",L2);
1390 TN2 = TDataStd_TreeNode::Set(L2);
1393 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1394 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1400 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1402 di << "Usage : " << argv[0] << " D" << "\n";
1407 Handle(TDF_Data) DF;
1408 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1411 DDF::FindLabel(DF,"0:1",L,Standard_False);
1412 Handle(TDocStd_Modified) MDF;
1413 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1414 MDF = new TDocStd_Modified();
1415 L.Root().AddAttribute(MDF);
1418 di<<!MDF->IsEmpty();
1422 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1424 di << "Usage : " << argv[0] << " D Label" << "\n";
1429 Handle(TDF_Data) DF;
1430 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1433 DDF::FindLabel(DF,argv[2],L,Standard_False);
1435 TDocStd_Modified::Add(L);
1441 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1443 di << "Usage : " << argv[0] << " D" << "\n";
1449 Handle(TDF_Data) aDF;
1450 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1452 Handle(TDocStd_Document) aDocument;
1453 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1456 Handle(TDataStd_TreeNode) TN;
1458 aDocument->NewCommand();
1459 DDF::AddLabel(aDF,"0:2",L);
1460 TN = TDataStd_TreeNode::Set(L);
1462 aDocument->NewCommand();
1463 DDF::AddLabel(aDF,"0:3",L);
1464 TN = TDataStd_TreeNode::Set(L);
1466 aDocument->NewCommand();
1467 DDF::AddLabel(aDF,"0:4",L);
1468 TN = TDataStd_TreeNode::Set(L);
1469 aDocument->NewCommand();
1471 TDF_DeltaList Us,Rs;
1472 Us = aDocument->GetUndos();
1473 Rs = aDocument->GetUndos();
1476 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1478 TDF_ListIteratorOfDeltaList IDL;
1479 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1480 Handle(TDF_Delta) D = IDL.Value();
1481 TCollection_ExtendedString S(Names[i-1]);
1483 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1489 Us = aDocument->GetUndos();
1490 Rs = aDocument->GetRedos();
1492 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1493 Handle(TDF_Delta) D = IDL.Value();
1494 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1497 TCollection_ExtendedString n2name ("n2");
1498 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1499 Handle(TDF_Delta) D = IDL.Value();
1500 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1511 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1513 di << "Usage : " << argv[0] << " D Shape" << "\n";
1518 Handle(TDF_Data) aDF;
1519 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1521 TopoDS_Shape s = DBRep::Get(argv[2]);
1522 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1524 DDF::AddLabel(aDF, "0:2", L);
1525 TNaming_Builder SI (L);
1528 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1532 // if (!NS->IsEmpty()) {di<<3;return 0;}
1533 if (NS->IsEmpty()) {di<<4;return 0;}
1538 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1540 di << "Usage : " << argv[0] << " D Shape" << "\n";
1545 Handle(TDF_Data) aDF;
1546 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1548 TopoDS_Shape s = DBRep::Get(argv[2]);
1549 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1551 DDF::AddLabel(aDF, "0:2", L);
1552 TNaming_Builder SI (L);
1555 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1559 if (NS->IsEmpty()) {di<<4;return 0;}
1564 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1566 TCollection_ExtendedString path (argv[1]);
1567 Handle(TDocStd_Application) A;
1568 if (!DDocStd::Find(A)) {di<<1;return 0;}
1569 Handle(TDocStd_Document) D;
1570 Standard_Integer insession = A->IsInSession(path);
1571 if (insession > 0) {
1572 di <<"document " << insession << " is already in session" << "\n";
1576 PCDM_ReaderStatus Result = A->Open(path,D);
1577 if(Result==PCDM_RS_OK){
1586 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1588 di << "Usage : " << argv[0] << " D" << "\n";
1593 Handle(TDF_Data) aDF;
1594 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1597 DDF::AddLabel(aDF, "0:2", L);
1599 Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation;
1601 AISP->Set(L,TDataXtd_Constraint::GetID());
1603 if (AISP->HasOwnMode()) {di<<3;return 0;}
1605 Standard_Integer Mode = AISP->Mode();
1606 if (Mode!=3) {di<<4;return 0;}
1607 if (!AISP->HasOwnMode()) {di<<5;return 0;}
1609 if (AISP->HasOwnMode()) {di<<6;return 0;}
1614 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1616 di << "Usage : " << argv[0] << " D" << "\n";
1621 Handle(TDF_Data) aDF;
1622 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1625 DDF::AddLabel(aDF, "0:2", L);
1629 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1630 // Handle(TNaming_Name) NN = new TNaming_Name;
1633 NN.Type(TNaming_IDENTITY);
1635 Standard_Boolean Res = NN.Solve(L,LM);
1637 if (Res!=Standard_False) {di<<3;return 0;}
1642 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1644 di << "Usage : " << argv[0] << " D" << "\n";
1650 Handle(TDocStd_Document) aDocument;
1651 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
1653 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
1654 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
1660 //=======================================================================
1661 //function : AISWidth
1662 //purpose : AISWidth (DOC,entry,[width])
1663 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
1664 //=======================================================================
1666 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1669 Handle(TDocStd_Document) D;
1670 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
1672 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
1674 Handle(TPrsStd_AISViewer) viewer;
1675 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
1677 Handle(TPrsStd_AISPresentation) prs;
1678 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1680 prs->SetWidth(Draw::Atof(argv[3]));
1681 TPrsStd_AISViewer::Update(L);
1684 if (prs->HasOwnWidth()){
1685 // cout << "Width = " << prs->Width() << endl;
1689 di << "AISWidth: Warning : Width wasn't set" << "\n";
1696 di << "AISWidth : Error" << "\n";
1701 //=======================================================================
1702 //function : BUC60921 ( & BUC60954 )
1703 //purpose : Test memory allocation of OCAF in Undo/Redo operations
1704 //=======================================================================
1706 static Standard_Integer BUC60921 (Draw_Interpretor& di,
1707 Standard_Integer nb,
1711 Handle(TDocStd_Document) D;
1712 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
1714 DDF::AddLabel(D->GetData(),arg[2],L);
1718 BRepTools::Read ( S, arg[3], B );
1720 TNaming_Builder tnBuild(L);
1721 tnBuild.Generated(S);
1722 // di << "File " << arg[3] << " added";
1726 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
1731 #include<IGESControl_Reader.hxx>
1732 #include<BRepPrimAPI_MakeHalfSpace.hxx>
1734 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
1738 // cerr << "Usage : " << a[0] << " file.igs" << endl;
1741 if(argc < 2 || argc > 3) {
1742 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1745 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1747 Standard_Integer IsB = Draw::Atoi(a[2]);
1749 IsBRepAlgoAPI = Standard_False;
1750 #if ! defined(BRepAlgo_def01)
1751 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1757 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
1759 if(myContext.IsNull()) {
1760 di << "use 'vinit' command before " << a[0] << "\n";
1764 // IGESControlStd_Reader reader;
1765 IGESControl_Reader reader;
1766 reader.ReadFile(a[1]);
1767 reader.TransferRoots();
1768 TopoDS_Shape shape = reader.OneShape();
1769 printf("\n iges1 shape type = %d", shape.ShapeType() );
1770 TopTools_IndexedMapOfShape list;
1771 TopExp::MapShapes(shape, TopAbs_FACE, list);
1772 printf("\n No. of faces = %d", list.Extent());
1775 BRep_Builder builder;
1776 builder.MakeShell(shell);
1777 for(int i=1;i<=list.Extent(); i++) {
1778 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
1779 builder.Add(shell, face);
1782 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
1783 TopoDS_Solid sol = half.Solid();
1784 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
1785 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
1786 TopoDS_Shape sh = cyl.Shape();
1788 //#if ! defined(BRepAlgoAPI_def01)
1789 // BRepAlgoAPI_Fuse fuse(sol, sh);
1791 // BRepAlgo_Fuse fuse(sol, sh);
1794 // sh = fuse.Shape();
1796 if (IsBRepAlgoAPI) {
1797 di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n";
1798 BRepAlgoAPI_Fuse fuse(sol, sh);
1801 di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n";
1802 BRepAlgo_Fuse fuse(sol, sh);
1806 Handle(AIS_Shape) res = new AIS_Shape(sh);
1807 myContext->Display( res );
1811 void QABugs::Commands_3(Draw_Interpretor& theCommands) {
1812 const char *group = "QABugs";
1814 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
1815 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
1816 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
1817 theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group);
1818 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
1819 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
1820 theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
1821 theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
1822 theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
1823 theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
1824 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
1826 theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
1827 theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
1828 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
1829 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
1831 theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
1832 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
1833 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
1834 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
1835 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
1836 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
1838 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
1840 theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
1842 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
1844 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
1846 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
1847 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
1848 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
1849 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
1851 theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
1853 theCommands.Add("statface","statface face",__FILE__,statface,group);
1855 theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
1857 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
1859 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
1860 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
1861 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
1862 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
1863 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
1864 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
1865 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
1866 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
1867 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
1868 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
1869 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
1870 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
1872 theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );