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 );
90 Standard_DISABLE_DEPRECATION_WARNINGS
91 myAISContext->OpenLocalContext();
92 myAISContext->ActivateStandardMode(TopAbs_FACE);
93 Standard_ENABLE_DEPRECATION_WARNINGS
98 static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
102 di << "Usage : "<< argv[0] << " shape\n";
108 TopoDS_Shape theShape = DBRep::Get(argv[1]);
110 // ViewerTest::GetAISContext();
111 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
112 if(myAISContext.IsNull()) {
113 di << "use 'vinit' command before " << argv[0] << "\n";
116 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
117 myAISContext->Display( anAISShape, Standard_True );
119 Standard_DISABLE_DEPRECATION_WARNINGS
120 myAISContext->OpenLocalContext();
121 myAISContext->ActivateStandardMode(TopAbs_COMPOUND);
122 Standard_ENABLE_DEPRECATION_WARNINGS
123 // myAISContext->ActivateStandardMode(TopAbs_SOLID);
125 // cout << "vfini" << endl;
129 #include<BRep_Builder.hxx>
130 #include<BRepTools_ShapeSet.hxx>
131 #include<BRepTools.hxx>
132 #include<BRepAdaptor_HSurface.hxx>
133 #include<TopOpeBRep_PointClassifier.hxx>
134 #include<Precision.hxx>
139 static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
144 // BUC60609 shape name
145 } else if ( argc == 5 ) {
146 // BUC60609 shape name U V
148 di << "Usage : "<< argv[0] << " shape name [U V]\n";
152 TCollection_AsciiString aFilePath(argv[1]);
156 if (!fic.open(aFilePath.ToCString(),ios::in)) {
157 di << "Cannot open file for reading : " << aFilePath << "\n";
161 TopoDS_Shape theShape;
165 if( !strcmp(typ, "DBRep_DrawableShape") ){
167 BRepTools_ShapeSet S(B);
171 di << "Wrong entity type in " << aFilePath << "\n";
176 const TopoDS_Face &face = TopoDS::Face (theShape);
179 DBRep::Set(argv[2],face);
182 Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
184 BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
186 di << "The bounds of the trimmed face:\n";
187 di << faceUMin << " <= U <= " << faceUMax << "\n";
188 di << faceVMin << " <= V <= " << faceVMax << "\n";
190 Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
192 TopOpeBRep_PointClassifier PClass;
194 di << "Now test the point classifier by inputting U,V values\n";
195 di << "inside or outside the bounds displayed above\n";
196 di << "Type stop to exit\n";
198 // Please register this:
199 // ***********************************************
200 // Note also that for periodic surfaces such as nimpod_1.topo,
201 // the U/V values may be +- 2pi compared to the actual face bounds
202 // (because U,V is probably coming from a Geom package routine).
203 // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
204 // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
205 // *************************************************
208 uvSurf = gp_Pnt2d(0.14,5.1);
209 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
210 if(state == TopAbs_IN || state == TopAbs_ON){
211 di << "U=" << 0.14 << " V=" << 5.1 << " classified INSIDE\n";
213 di << "U=" << 0.14 << " V=" << 5.1 << " classified OUTSIDE\n";
216 uvSurf = gp_Pnt2d(1.28,5.1);
217 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
218 if(state == TopAbs_IN || state == TopAbs_ON){
219 di << "U=" << 1.28 << " V=" << 5.1 << " classified INSIDE\n";
221 di << "U=" << 1.28 << " V=" << 5.1 << " classified OUTSIDE\n";
224 uvSurf = gp_Pnt2d(Draw::Atof(argv[3]),Draw::Atof(argv[4]));
225 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
226 if(state == TopAbs_IN || state == TopAbs_ON){
227 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified INSIDE\n";
229 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified OUTSIDE\n";
235 #include<BRepBuilderAPI_MakeVertex.hxx>
236 #include<TCollection_ExtendedString.hxx>
237 #include<AIS_LengthDimension.hxx>
239 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
242 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
243 if(myAIScontext.IsNull()) {
244 di << "use 'vinit' command before " << a[0] << "\n";
247 myAIScontext->EraseAll (Standard_False);
249 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
250 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
252 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
253 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
255 myAIScontext->Display (Ve1, Standard_False);
256 myAIScontext->Display (Ve2, Standard_False);
258 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
259 TCollection_ExtendedString Ext1("Dim1");
260 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln());
261 Dim1->SetCustomValue (Draw::Atof(a[2]));
263 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
264 anAspect->MakeArrows3d (Standard_False);
265 anAspect->MakeText3d (Standard_True);
266 anAspect->MakeTextShaded (Standard_True);
267 anAspect->TextAspect()->SetHeight (2.5);
268 anAspect->ArrowAspect()->SetLength (1.0);
269 Dim1->SetDimensionAspect (anAspect);
271 myAIScontext->SetDisplayMode (Dim1, Draw::Atoi(a[1]), Standard_False);
272 myAIScontext->Display (Dim1, Standard_True);
276 #include<TopoDS_Wire.hxx>
278 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
281 di << "Usage : BUC60652 fase" << "\n";
284 TopoDS_Shape shape = DBRep::Get( argv[1] );
285 TopoDS_Face face = TopoDS::Face( shape );
286 TopoDS_Wire ow = BRepTools::OuterWire( face );
287 DBRep::Set( "w", ow );
291 #include <Geom_Axis2Placement.hxx>
292 #include <AIS_Trihedron.hxx>
294 static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
297 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
298 if(myAISContext.IsNull()) {
299 di << "use 'vinit' command before " << a[0] << "\n";
303 Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY());
304 Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis);
307 aTrsf.SetTranslation(trans);
308 TopLoc_Location aLoc(aTrsf);
309 myAISContext->SetLocation(atri,aLoc);
310 myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
312 Standard_DISABLE_DEPRECATION_WARNINGS
313 myAISContext->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False);
314 Standard_ENABLE_DEPRECATION_WARNINGS
316 myAISContext->Load(atri,3,Standard_True);
321 #include <TopoDS_Solid.hxx>
322 #include <BRepPrimAPI_MakeBox.hxx>
323 #include <BRepPrimAPI_MakeSphere.hxx>
325 #include <BRepAlgoAPI_Fuse.hxx>
326 #include <BRepAlgo_Fuse.hxx>
328 #include <V3d_View.hxx>
329 #include <gce_MakePln.hxx>
331 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
333 //=======================================================================
334 //function : GetColorFromName
335 //purpose : get the Quantity_NameOfColor from a string
336 //=======================================================================
338 static Quantity_NameOfColor GetColorFromName( const char *name )
340 Quantity_NameOfColor ret = DEFAULT_COLOR;
342 Standard_Boolean Found = Standard_False;
343 Standard_CString colstring;
344 for(Standard_Integer i=0;i<=514 && !Found;i++)
346 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
347 if (!strcasecmp(name,colstring)) {
348 ret = (Quantity_NameOfColor)i;
349 Found = Standard_True;
356 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
359 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
360 if(myAISContext.IsNull()) {
361 di << "use 'vinit' command before " << argv[0] << "\n";
365 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
371 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
373 // Change the background color of the view with a predefined name Graphic3d_NOC_<name>
375 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
376 myV3dView -> Redraw();
382 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
383 // setcolor <object> <name>
384 // Change the object color with a predefined name
386 TopoDS_Shape aShape = DBRep::Get(argv[1]);
387 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
388 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
389 myAISContext->Display(myShape,Standard_True);
390 myAISContext->UpdateCurrentViewer();
396 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
398 // setcolor <r> <g> <b>
399 // Change the background color of the view with the color values <r>,<g>,<b>
400 // A color value must be defined in the space [0.,1.]
402 Standard_Real QuantityOfRed = Draw::Atoi(argv[1]);
403 Standard_Real QuantityOfGreen = Draw::Atoi(argv[2]);
404 Standard_Real QuantityOfBlue = Draw::Atoi(argv[3]);
405 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
412 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
414 // setcolor <object> <r> <g> <b>
415 // change the object color with RGB values.
418 Standard_Real QuantityOfRed = Draw::Atof(argv[2]);
419 Standard_Real QuantityOfGreen = Draw::Atof(argv[3]);
420 Standard_Real QuantityOfBlue = Draw::Atof(argv[4]);
422 TopoDS_Shape aShape = DBRep::Get(argv[1]);
423 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
424 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
425 myAISContext->Display(myShape,Standard_True);
426 myAISContext->UpdateCurrentViewer();
427 // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
428 // myShape->Redisplay();
435 #include <Bnd_BoundSortBox.hxx>
436 #include <BRepBndLib.hxx>
437 #include <Bnd_HArray1OfBox.hxx>
439 static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ )
442 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
444 BRepBndLib::Add(aShape , aMainBox );
446 Standard_Integer siMaxNbrBox = 6;
447 Bnd_BoundSortBox m_BoundSortBox;
448 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
449 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
453 // Bnd_Box __emptyBox; // Box is void !
454 // Handle(Bnd_HArray1OfBox) __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
456 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
458 const TopoDS_Shape& aFace = aExplorer.Current();
460 BRepBndLib::Add( aFace, aBox );
461 m_BoundSortBox.Add( aBox, i );
462 // __aSetOfBox->SetValue( i, aBox );
464 // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
469 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
471 TCollection_AsciiString as1("");
472 TCollection_AsciiString as2('\0');
473 if(as1.ToCString() == NULL || as1.Length() != 0 || as1.ToCString()[0] != '\0')
474 di << "Error : the first string is not zero string : " << as1.ToCString() << "\n";
476 if(as2.ToCString() == NULL || as2.Length() != 0 || as2.ToCString()[0] != '\0')
477 di << "Error : the second string is not zero string : " << as2.ToCString() << "\n";
482 #include <UnitsAPI.hxx>
484 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
486 di <<"Program Test\n";
487 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
488 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
493 #include <gp_Circ.hxx>
494 #include <Geom_Circle.hxx>
495 #include <GeomAPI.hxx>
496 #include <Geom2d_CartesianPoint.hxx>
497 #include <Geom2dGcc_QualifiedCurve.hxx>
498 #include <Geom2dGcc_Circ2d2TanRad.hxx>
499 #include <Geom2d_Circle.hxx>
500 #include <ProjLib.hxx>
502 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
504 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
505 if(aContext.IsNull()) {
506 di << "use 'vinit' command before " << argv[0] << "\n";
510 gp_Pnt pt3d(0, 20, 150);
511 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
512 gp_Circ circ(anAx2, 50.0);
513 Handle(Geom_Circle) gcir = new Geom_Circle(circ);
514 Handle(Geom_Plane) pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
515 Handle(Geom2d_Curve) gcir1 = GeomAPI::To2d(gcir, pln->Pln());
516 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
517 Handle(AIS_Shape) ais1 = new AIS_Shape(sh1);
518 aContext->SetColor (ais1, Quantity_NOC_INDIANRED, Standard_False);
519 aContext->Display (ais1, Standard_False);
520 DBRep::Set("sh0",sh1);
522 // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
523 thepoint = ProjLib::Project(pln->Pln(),pt3d);
524 Handle(Geom2d_CartesianPoint) ThePoint = new Geom2d_CartesianPoint(thepoint);
525 Geom2dAdaptor_Curve acur1(gcir1) ;
526 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
527 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
528 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
529 Handle(Geom2d_Circle) gccc;
530 if( cirtanrad.NbSolutions() ) {
531 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
532 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
533 gccc = new Geom2d_Circle(ccc);
534 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
535 Standard_Character aStr[5];
536 Sprintf(aStr,"sh%d",i);
538 Handle(AIS_Shape) ais = new AIS_Shape(sh);
540 aContext->SetColor (ais, Quantity_NOC_GREEN, Standard_False);
542 aContext->SetColor (ais, Quantity_NOC_HOTPINK, Standard_False);
543 aContext->Display (ais, Standard_False);
544 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
545 gp_Pnt2d PntSol1, PntSol2;
546 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
547 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
548 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
549 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
552 aContext->UpdateCurrentViewer();
556 #include <TColgp_Array2OfPnt.hxx>
557 #include <Geom_BezierSurface.hxx>
558 #include <BRepBuilderAPI_MakeFace.hxx>
559 #include <BRepBuilderAPI_MakeWire.hxx>
560 #include <Geom_OffsetSurface.hxx>
561 #include <BRepFilletAPI_MakeFillet2d.hxx>
562 #include <GeomProjLib.hxx>
563 #include <Geom_TrimmedCurve.hxx>
565 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
569 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
570 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
571 Standard_Real f = 0.0, l = 0.0;
572 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
573 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
574 GC = new Geom_TrimmedCurve(GC, f, l);
575 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
576 BRepBuilderAPI_MakeWire *myWire;
577 myWire = new BRepBuilderAPI_MakeWire();
578 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
579 DBRep::Set(argv[1],myWire->Wire());
583 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
584 if(aContext.IsNull()) {
585 di << "use 'vinit' command before " << argv[0] << "\n";
589 //step 1. creating a Bezier Surface and a patch
593 Handle(AIS_Shape) ais1;
594 Handle(AIS_Shape) ais2;
595 Handle(Geom_BezierSurface) BZ1;
596 TColgp_Array2OfPnt array1(1,3,1,3);
597 array1.SetValue(1,1,gp_Pnt(0,100,0));
598 array1.SetValue(1,2,gp_Pnt(200,100,0));
599 array1.SetValue(1,3,gp_Pnt(400,100,0));
600 array1.SetValue(2,1,gp_Pnt(0,200,100));
601 array1.SetValue(2,2,gp_Pnt(200,200,100));
602 array1.SetValue(2,3,gp_Pnt(400,200,100));
603 array1.SetValue(3,1,gp_Pnt(0,300,0));
604 array1.SetValue(3,2,gp_Pnt(200,300,0));
605 array1.SetValue(3,3,gp_Pnt(400,300,0));
606 BZ1 = new Geom_BezierSurface(array1);
607 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
608 TopoDS_Face F1= bzf1.Face();
609 ais1 = new AIS_Shape(F1);
611 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
612 aContext->Display (ais1, Standard_False);
617 shell.Closed (BRep_Tool::IsClosed (shell));
620 gp_Dir D(0, 0, 1.0f);
621 BRepBuilderAPI_MakeWire mkw;
622 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
623 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
624 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
626 p1 = gp_Pnt(350., 150., 260.);
627 p2 = gp_Pnt(350., 250., 260.);
628 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
630 p1 = gp_Pnt(350., 250., 260.);
631 p2 = gp_Pnt(300., 250.0, 260.);
632 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
634 p1 = gp_Pnt(300., 250.0, 260.);
635 p2 = gp_Pnt(200., 200.0, 260.);
636 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
638 p1 = gp_Pnt(200., 200.0, 260.);
639 p2 = gp_Pnt(150., 200.0, 260.);
640 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
642 p1 = gp_Pnt(150., 200.0, 260.);
643 p2 = gp_Pnt(150., 150.0, 260.);
644 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
646 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
647 ais2 = new AIS_Shape( FP );
648 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
649 aContext->Display (ais2, Standard_False);
653 //step 2. offseting the surface.
654 Handle(Geom_OffsetSurface) offsurf;
655 offsurf = new Geom_OffsetSurface(BZ1, -100);
656 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
657 TopoDS_Face F2= bzf2.Face();
658 Handle(AIS_Shape) ais22 = new AIS_Shape(F2);
659 aContext->Display (ais22, Standard_False);
662 //step 3. filleting the patch.
663 //( I want to project wire of this patch on offseted surface above)
664 BRepFilletAPI_MakeFillet2d fillet( FP );
666 Ex.Init(FP, TopAbs_VERTEX);
667 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
668 fillet.AddFillet(v1, 20);
669 di << "\nError is " << fillet.Status() << "\n";
670 // printf("\nError is %d ", fillet.Status());
672 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
673 fillet.AddFillet(V2, 20);
674 di << "\nError is " << fillet.Status() << "\n";
675 // printf("\nError is %d ", fillet.Status());
677 FP1 = fillet.Shape();
678 ais2 = new AIS_Shape( FP1 );
679 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
680 aContext->Display (ais2, Standard_False);
682 DBRep::Set("FP1",FP1);
684 //step 4. Projecting the wire of this patch on offsetted surface.
685 // TopExp_Explorer Ex;
686 BRepBuilderAPI_MakeWire *myWire;
687 myWire = new BRepBuilderAPI_MakeWire();
688 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
690 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
691 Standard_Real f = 0.0, l = 0.0;
692 Handle(Geom_Curve) newBSplin = BRep_Tool::Curve(e1, f, l);
693 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
694 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
695 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
697 Handle(AIS_Shape) ais33 = new AIS_Shape( myWire->Wire() );
698 aContext->Display (ais33, Standard_True);
700 DBRep::Set("Wire",myWire->Wire());
705 #include<GeomAPI_ExtremaCurveCurve.hxx>
707 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
711 printf("Usage: %s edge1 edge2",argv[0]);
715 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
716 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
718 Standard_Real fp , lp;
720 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
721 C2 = BRep_Tool::Curve(E2 , fp , lp);
723 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
725 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
730 #include <BRepBuilderAPI_MakePolygon.hxx>
731 #include <BRepOffsetAPI_ThruSections.hxx>
733 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
736 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
739 Standard_Boolean IsBRepAlgoAPI = Standard_True;
741 Standard_Integer IsB = Draw::Atoi(argv[1]);
743 IsBRepAlgoAPI = Standard_False;
744 #if ! defined(BRepAlgo_def01)
745 // di << "Error: There is not BRepAlgo_Fuse class\n";
751 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
752 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
753 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
754 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
755 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
757 for (int i=0;i<4;i++) {
758 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
759 bottompolygon1.Add(tmppnt);
760 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
761 toppolygon1.Add(tmppnt);
762 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
763 bottompolygon2.Add(tmppnt);
764 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
765 toppolygon2.Add(tmppnt);
767 bottompolygon1.Close();
768 DBRep::Set("B1",bottompolygon1.Shape());
770 DBRep::Set("T1",toppolygon1.Shape());
771 bottompolygon2.Close();
772 DBRep::Set("B2",bottompolygon2.Shape());
774 DBRep::Set("T2",toppolygon2.Shape());
775 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
776 loft1.AddWire(bottompolygon1.Wire());
777 loft1.AddWire(toppolygon1.Wire());
779 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
780 loft2.AddWire(bottompolygon2.Wire());
781 loft2.AddWire(toppolygon2.Wire());
783 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
785 DBRep::Set("TS1",loft1.Shape());
786 DBRep::Set("TS2",loft2.Shape());
788 //#if ! defined(BRepAlgoAPI_def01)
789 // BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
791 // BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
794 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())\n";
795 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
796 DBRep::Set("F",result.Shape());
798 di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())\n";
799 BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
800 DBRep::Set("F",result.Shape());
803 // DBRep::Set("F",result.Shape());
807 #include <Geom_RectangularTrimmedSurface.hxx>
808 #include <GC_MakeTrimmedCone.hxx>
810 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
812 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
813 if(aContext.IsNull()) {
814 di << "use 'vinit' command before " << argv[0] << "\n";
821 P1(0,0,20), P2(0,0,45);
822 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
823 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
824 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
825 aContext->Display (ais1, Standard_False);
826 aContext->SetColor (ais1, Quantity_NOC_BLUE1, Standard_False);
828 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
829 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
830 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
831 aContext->Display (ais2, Standard_False);
832 aContext->SetColor (ais2, Quantity_NOC_RED, Standard_False);
836 //==========================================================================
837 //function : CoordLoad
838 // chargement d une face dans l explorer.
839 //==========================================================================
840 static Standard_Integer coordload (Draw_Interpretor& theDi,
841 Standard_Integer theArgsNb,
842 const char** theArgVec)
849 std::ifstream aFile (theArgVec[2], ios::in);
852 theDi << "unable to open " << theArgVec[2] << " for input\n";
857 memset (aLine, 0, 40);
858 aFile.getline (aLine, 80);
860 gp_Pnt aPnt (0.0, 0.0, 0.0);
862 aPnt.SetY (Draw::Atof (&aLine[20]));
864 aPnt.SetX (Draw::Atof (aLine));
865 TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt);
866 BRepBuilderAPI_MakeWire aMakeWire;
869 memset (aLine, 0, 40);
870 aFile.getline (aLine, 80);
877 aPnt.SetY (Draw::Atof (&aLine[20]));
879 aPnt.SetX (Draw::Atof (aLine));
880 TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt);
881 aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2));
886 if (!aMakeWire.IsDone())
888 DBRep::Set (theArgVec[1], TopoDS_Face());
892 BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire());
893 DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face());
897 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
898 Standard_Integer /*nb*/,
899 const char ** /*arg*/)
901 TCollection_ExtendedString aString(1024*1024, 'A');
905 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
906 Standard_Integer argc,
909 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
910 if(aContext.IsNull()) {
911 di << "use 'vinit' command before " << argv[0] << "\n";
914 if((argc != 2) && (argc != 3)) {
915 di<< "usage : " << argv[0] << " shape [mode==1]\n";
918 TopoDS_Shape aShape = DBRep::Get(argv[1]);
919 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
920 // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
921 anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
922 aContext->Display (anIO, Standard_True);
926 //=======================================================================
927 //function : buc60773
929 //=======================================================================
931 #include<TCollection_HAsciiString.hxx>
933 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
935 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
936 Standard_CString aStr = hAscii->ToCString();
937 TCollection_AsciiString aAscii(aStr);
942 #include<BRepPrimAPI_MakeCylinder.hxx>
943 #include<BRepPrimAPI_MakeCone.hxx>
945 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
949 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
952 Standard_Boolean IsBRepAlgoAPI = Standard_True;
954 Standard_Integer IsB = Draw::Atoi(argv[1]);
956 IsBRepAlgoAPI = Standard_False;
957 #if ! defined(BRepAlgo_def01)
958 // di << "Error: There is not BRepAlgo_Fuse class\n";
964 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
966 Standard_Real x11 = 36.085182;
967 Standard_Real y11 = 20.0;
968 Standard_Real z11 = 8.431413;
969 Standard_Real x12 = 88.04671;
970 Standard_Real y12 = 20.0;
971 Standard_Real z12 = 38.931416;
972 Standard_Real radius = 10.0;
974 gp_Pnt base1(x11, y11, z11);
975 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
976 gp_Ax2 axis1(base1, vect1);
977 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
978 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
980 TopoDS_Shape SCyl = cylinder.Shape();
981 DBRep::Set("cyl", SCyl);
984 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
985 Standard_Real x21 = 70.7262;
986 Standard_Real y21 = 20.0;
987 Standard_Real z21 = 28.431412;
988 Standard_Real x22 = 105.36722;
989 Standard_Real y22 = 20.0;
990 Standard_Real z22 = 48.431416;
991 Standard_Real radius1 = 6.0;
992 Standard_Real radius2 = 3.0;
994 gp_Pnt base2(x21, y21, z21);
995 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
996 gp_Ax2 axis2(base2, vect2);
997 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
998 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1000 TopoDS_Shape SCon = cone.Shape();
1001 DBRep::Set("con", SCon);
1003 //#if ! defined(BRepAlgoAPI_def01)
1004 // BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1006 // BRepAlgo_Fuse SFuse(SCyl, SCon);
1009 // if(! SFuse.IsDone() )
1010 // cout<<"Error: Boolean fuse operation failed !"<<endl;
1012 // TopoDS_Shape fuse = SFuse.Shape();
1015 if (IsBRepAlgoAPI) {
1016 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)\n";
1017 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1018 if(! SFuse.IsDone() )
1019 di<<"Error: Boolean fuse operation failed !\n";
1020 fuse = SFuse.Shape();
1022 di << "BRepAlgo_Fuse SFuse(SCyl, SCon)\n";
1023 BRepAlgo_Fuse SFuse(SCyl, SCon);
1024 if(! SFuse.IsDone() )
1025 di<<"Error: Boolean fuse operation failed !\n";
1026 fuse = SFuse.Shape();
1029 DBRep::Set("fus", fuse);
1034 #include <NCollection_DataMap.hxx>
1035 #include <TColStd_HSequenceOfAsciiString.hxx>
1036 #include <TopExp.hxx>
1037 #include <TopoDS_Iterator.hxx>
1039 //---------------------------------------------------------------------------------------
1041 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1044 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1047 di<<"Invalid input shape\n";
1050 NCollection_DataMap<TCollection_AsciiString, Standard_Integer> aMap;
1051 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1052 Standard_CString aString;
1053 Standard_Integer l=0;
1054 TopExp_Explorer expl;
1055 Standard_Real f3d,l3d;
1056 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1059 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1060 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1061 aString = aSurface->DynamicType()->Name();
1063 if (aMap.IsBound(aString))
1064 aMap.ChangeFind(aString)++;
1066 aMap.Bind(aString, 1);
1067 aSequence->Append(aString);
1071 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1073 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1074 TopoDS_Iterator anIt(aFace);
1075 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1076 TopoDS_Iterator it (aWire);
1077 for (; it.More(); it.Next()) {
1078 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1079 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1080 aString = aCurve2d->DynamicType()->Name();
1081 if(aMap.IsBound(aString))
1082 aMap.ChangeFind(aString)++;
1084 aMap.Bind(aString, 1);
1085 aSequence->Append(aString);
1090 TopExp_Explorer exp;
1091 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
1093 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1094 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1095 if(aCurve3d.IsNull())
1099 aString = aCurve3d->DynamicType()->Name();
1100 if (aMap.IsBound(aString))
1102 aMap.ChangeFind(aString)++;
1104 aMap.Bind(aString, 1);
1105 aSequence->Append(aString);
1112 for (Standard_Integer i = 1; i <= aSequence->Length(); i++) {
1113 di << aMap.Find(aSequence->Value(i)) << " -- " << aSequence->Value(i).ToCString() << "\n";
1117 di<<"Degenerated edges :\n";
1118 di<<l<<" -- Degenerated edges \n";
1124 #include <BRepBuilderAPI_Transform.hxx>
1126 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1129 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
1132 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1134 Standard_Integer IsB = Draw::Atoi(argv[1]);
1136 IsBRepAlgoAPI = Standard_False;
1137 #if ! defined(BRepAlgo_def01)
1138 // di << "Error: There is not BRepAlgo_Fuse class\n";
1144 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1145 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1146 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1148 TopoDS_Shape sh1 = cyl.Shape();
1149 DBRep::Set("sh1",sh1);
1150 gp_Trsf trsf1, trsf2;
1151 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1152 gp_Pnt(0.000000,700.000000,-95.000000));
1153 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1154 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1155 BRepBuilderAPI_Transform trans1(sh1, trsf1);
1156 TopoDS_Shape sh2 = trans1.Shape();
1157 DBRep::Set("sh2",sh2);
1159 //#if ! defined(BRepAlgoAPI_def01)
1160 // BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1162 // BRepAlgo_Fuse fuse1(sh1, sh2);
1165 // TopoDS_Shape fsh1 = fuse1.Shape();
1168 if (IsBRepAlgoAPI) {
1169 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)\n";
1170 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1171 fsh1 = fuse1.Shape();
1173 di << "BRepAlgo_Fuse fuse1(sh1, sh2)\n";
1174 BRepAlgo_Fuse fuse1(sh1, sh2);
1175 fsh1 = fuse1.Shape();
1178 DBRep::Set("fsh1",fsh1);
1179 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1180 TopoDS_Shape sh3 = trans2.Shape();
1181 DBRep::Set("sh3",sh3);
1183 //#if ! defined(BRepAlgoAPI_def01)
1184 // BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1186 // BRepAlgo_Fuse fuse2(fsh1,sh3);
1189 // TopoDS_Shape fsh2 = fuse2.Shape();
1192 if (IsBRepAlgoAPI) {
1193 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)\n";
1194 BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1195 fsh2 = fuse2.Shape();
1197 di << "BRepAlgo_Fuse fuse2(fsh1,sh3)\n";
1198 BRepAlgo_Fuse fuse2(fsh1,sh3);
1199 fsh2 = fuse2.Shape();
1202 DBRep::Set("fsh2",fsh2);
1203 Handle(AIS_Shape) aisp1 = new AIS_Shape(fsh2);
1204 // aContext->Display(aisp1);
1208 #include <ShapeBuild_Edge.hxx>
1210 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1212 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1213 ShapeBuild_Edge().BuildCurve3d(e);
1219 #include<TDF_Label.hxx>
1220 #include<TDataStd_TreeNode.hxx>
1222 #include<DDocStd.hxx>
1226 #include<TDocStd_Modified.hxx>
1227 #include<TDF_ListIteratorOfDeltaList.hxx>
1228 #include<TDocStd_Document.hxx>
1229 #include<TDocStd_Application.hxx>
1230 #include<TDF_Delta.hxx>
1231 #include<TDataXtd_Constraint.hxx>
1232 #include<TPrsStd_AISPresentation.hxx>
1233 #include<TPrsStd_AISViewer.hxx>
1234 #include<TNaming_Builder.hxx>
1235 #include<TNaming_Naming.hxx>
1236 #include<TNaming_NamedShape.hxx>
1238 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1240 di << "Usage : " << argv[0] << " D\n";
1245 Handle(TDF_Data) DF;
1246 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1249 Handle(TDataStd_TreeNode) TN1,TN2;
1251 DDF::AddLabel(DF,"0:2",L1);
1252 TN1 = TDataStd_TreeNode::Set(L1);
1254 DDF::AddLabel(DF,"0:3",L2);
1255 TN2 = TDataStd_TreeNode::Set(L2);
1258 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1259 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1265 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1267 di << "Usage : " << argv[0] << " D\n";
1272 Handle(TDF_Data) DF;
1273 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1276 DDF::FindLabel(DF,"0:1",L,Standard_False);
1277 Handle(TDocStd_Modified) MDF;
1278 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1279 MDF = new TDocStd_Modified();
1280 L.Root().AddAttribute(MDF);
1283 di<<!MDF->IsEmpty();
1287 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1289 di << "Usage : " << argv[0] << " D Label\n";
1294 Handle(TDF_Data) DF;
1295 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1298 DDF::FindLabel(DF,argv[2],L,Standard_False);
1300 TDocStd_Modified::Add(L);
1306 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1308 di << "Usage : " << argv[0] << " D\n";
1314 Handle(TDF_Data) aDF;
1315 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1317 Handle(TDocStd_Document) aDocument;
1318 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1321 Handle(TDataStd_TreeNode) TN;
1323 aDocument->NewCommand();
1324 DDF::AddLabel(aDF,"0:2",L);
1325 TN = TDataStd_TreeNode::Set(L);
1327 aDocument->NewCommand();
1328 DDF::AddLabel(aDF,"0:3",L);
1329 TN = TDataStd_TreeNode::Set(L);
1331 aDocument->NewCommand();
1332 DDF::AddLabel(aDF,"0:4",L);
1333 TN = TDataStd_TreeNode::Set(L);
1334 aDocument->NewCommand();
1336 TDF_DeltaList Us,Rs;
1337 Us = aDocument->GetUndos();
1338 Rs = aDocument->GetUndos();
1341 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1343 TDF_ListIteratorOfDeltaList IDL;
1344 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1345 Handle(TDF_Delta) D = IDL.Value();
1346 TCollection_ExtendedString S(Names[i-1]);
1348 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1354 Us = aDocument->GetUndos();
1355 Rs = aDocument->GetRedos();
1357 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1358 Handle(TDF_Delta) D = IDL.Value();
1359 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1362 TCollection_ExtendedString n2name ("n2");
1363 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1364 Handle(TDF_Delta) D = IDL.Value();
1365 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1376 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1378 di << "Usage : " << argv[0] << " D Shape\n";
1383 Handle(TDF_Data) aDF;
1384 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1386 TopoDS_Shape s = DBRep::Get(argv[2]);
1387 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
1389 DDF::AddLabel(aDF, "0:2", L);
1390 TNaming_Builder SI (L);
1393 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1397 // if (!NS->IsEmpty()) {di<<3;return 0;}
1398 if (NS->IsEmpty()) {di<<4;return 0;}
1403 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1405 di << "Usage : " << argv[0] << " D Shape\n";
1410 Handle(TDF_Data) aDF;
1411 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1413 TopoDS_Shape s = DBRep::Get(argv[2]);
1414 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
1416 DDF::AddLabel(aDF, "0:2", L);
1417 TNaming_Builder SI (L);
1420 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1424 if (NS->IsEmpty()) {di<<4;return 0;}
1429 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1431 TCollection_ExtendedString path (argv[1]);
1432 Handle(TDocStd_Application) A = DDocStd::GetApplication();
1433 Handle(TDocStd_Document) D;
1434 Standard_Integer insession = A->IsInSession(path);
1435 if (insession > 0) {
1436 di <<"document " << insession << " is already in session\n";
1440 PCDM_ReaderStatus Result = A->Open(path,D);
1441 if(Result==PCDM_RS_OK){
1450 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1452 di << "Usage : " << argv[0] << " D\n";
1457 Handle(TDF_Data) aDF;
1458 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1461 DDF::AddLabel(aDF, "0:2", L);
1463 Handle(TPrsStd_AISPresentation) AISP =
1464 TPrsStd_AISPresentation::Set(L,TDataXtd_Constraint::GetID());
1466 if (AISP->HasOwnMode()) {di<<3;return 0;}
1468 Standard_Integer Mode = AISP->Mode();
1469 if (Mode!=3) {di<<4;return 0;}
1470 if (!AISP->HasOwnMode()) {di<<5;return 0;}
1472 if (AISP->HasOwnMode()) {di<<6;return 0;}
1477 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1479 di << "Usage : " << argv[0] << " D\n";
1484 Handle(TDF_Data) aDF;
1485 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1488 DDF::AddLabel(aDF, "0:2", L);
1492 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1493 // Handle(TNaming_Name) NN = new TNaming_Name;
1496 NN.Type(TNaming_IDENTITY);
1498 Standard_Boolean Res = NN.Solve(L,LM);
1500 if (Res!=Standard_False) {di<<3;return 0;}
1505 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1507 di << "Usage : " << argv[0] << " D\n";
1513 Handle(TDocStd_Document) aDocument;
1514 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
1516 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
1517 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
1523 //=======================================================================
1524 //function : AISWidth
1525 //purpose : AISWidth (DOC,entry,[width])
1526 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
1527 //=======================================================================
1529 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1532 Handle(TDocStd_Document) D;
1533 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
1535 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
1537 Handle(TPrsStd_AISViewer) viewer;
1538 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
1540 Handle(TPrsStd_AISPresentation) prs;
1541 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1543 prs->SetWidth(Draw::Atof(argv[3]));
1544 TPrsStd_AISViewer::Update(L);
1547 if (prs->HasOwnWidth()){
1548 // cout << "Width = " << prs->Width() << endl;
1552 di << "AISWidth: Warning : Width wasn't set\n";
1559 di << "AISWidth : Error" << "\n";
1564 //=======================================================================
1565 //function : BUC60921 ( & BUC60954 )
1566 //purpose : Test memory allocation of OCAF in Undo/Redo operations
1567 //=======================================================================
1569 static Standard_Integer BUC60921 (Draw_Interpretor& di,
1570 Standard_Integer nb,
1574 Handle(TDocStd_Document) D;
1575 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
1577 DDF::AddLabel(D->GetData(),arg[2],L);
1581 BRepTools::Read ( S, arg[3], B );
1583 TNaming_Builder tnBuild(L);
1584 tnBuild.Generated(S);
1585 // di << "File " << arg[3] << " added";
1589 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
1594 #include<IGESControl_Reader.hxx>
1595 #include<BRepPrimAPI_MakeHalfSpace.hxx>
1597 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
1601 // cerr << "Usage : " << a[0] << " file.igs" << endl;
1604 if(argc < 2 || argc > 3) {
1605 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
1608 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1610 Standard_Integer IsB = Draw::Atoi(a[2]);
1612 IsBRepAlgoAPI = Standard_False;
1613 #if ! defined(BRepAlgo_def01)
1614 // di << "Error: There is not BRepAlgo_Fuse class\n";
1620 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
1622 if(myContext.IsNull()) {
1623 di << "use 'vinit' command before " << a[0] << "\n";
1627 // IGESControlStd_Reader reader;
1628 IGESControl_Reader reader;
1629 reader.ReadFile(a[1]);
1630 reader.TransferRoots();
1631 TopoDS_Shape shape = reader.OneShape();
1632 printf("\n iges1 shape type = %d", shape.ShapeType() );
1633 TopTools_IndexedMapOfShape list;
1634 TopExp::MapShapes(shape, TopAbs_FACE, list);
1635 printf("\n No. of faces = %d", list.Extent());
1638 BRep_Builder builder;
1639 builder.MakeShell(shell);
1640 for(int i=1;i<=list.Extent(); i++) {
1641 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
1642 builder.Add(shell, face);
1644 shell.Closed (BRep_Tool::IsClosed (shell));
1646 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
1647 TopoDS_Solid sol = half.Solid();
1648 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
1649 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
1650 TopoDS_Shape sh = cyl.Shape();
1652 //#if ! defined(BRepAlgoAPI_def01)
1653 // BRepAlgoAPI_Fuse fuse(sol, sh);
1655 // BRepAlgo_Fuse fuse(sol, sh);
1658 // sh = fuse.Shape();
1660 if (IsBRepAlgoAPI) {
1661 di << "BRepAlgoAPI_Fuse fuse(sol, sh)\n";
1662 BRepAlgoAPI_Fuse fuse(sol, sh);
1665 di << "BRepAlgo_Fuse fuse(sol, sh)\n";
1666 BRepAlgo_Fuse fuse(sol, sh);
1670 Handle(AIS_Shape) res = new AIS_Shape(sh);
1671 myContext->Display (res, Standard_True);
1675 void QABugs::Commands_3(Draw_Interpretor& theCommands) {
1676 const char *group = "QABugs";
1678 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
1679 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
1680 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
1681 theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group);
1682 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
1683 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
1684 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
1686 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
1687 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
1689 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
1690 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
1691 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
1692 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
1693 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
1695 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
1697 theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
1699 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
1701 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
1703 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
1704 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
1705 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
1706 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
1708 theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
1710 theCommands.Add("statface","statface face",__FILE__,statface,group);
1712 theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
1714 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
1716 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
1717 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
1718 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
1719 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
1720 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
1721 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
1722 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
1723 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
1724 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
1725 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
1726 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
1727 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
1729 theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );