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>
327 #include <V3d_View.hxx>
328 #include <gce_MakePln.hxx>
330 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
332 //=======================================================================
333 //function : GetColorFromName
334 //purpose : get the Quantity_NameOfColor from a string
335 //=======================================================================
337 static Quantity_NameOfColor GetColorFromName( const char *name )
339 Quantity_NameOfColor ret = DEFAULT_COLOR;
341 Standard_Boolean Found = Standard_False;
342 Standard_CString colstring;
343 for(Standard_Integer i=0;i<=514 && !Found;i++)
345 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
346 if (!strcasecmp(name,colstring)) {
347 ret = (Quantity_NameOfColor)i;
348 Found = Standard_True;
355 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
358 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
359 if(myAISContext.IsNull()) {
360 di << "use 'vinit' command before " << argv[0] << "\n";
364 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
370 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
372 // Change the background color of the view with a predefined name Graphic3d_NOC_<name>
374 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
375 myV3dView -> Redraw();
381 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
382 // setcolor <object> <name>
383 // Change the object color with a predefined name
385 TopoDS_Shape aShape = DBRep::Get(argv[1]);
386 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
387 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
388 myAISContext->Display(myShape,Standard_True);
389 myAISContext->UpdateCurrentViewer();
395 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
397 // setcolor <r> <g> <b>
398 // Change the background color of the view with the color values <r>,<g>,<b>
399 // A color value must be defined in the space [0.,1.]
401 Standard_Real QuantityOfRed = Draw::Atoi(argv[1]);
402 Standard_Real QuantityOfGreen = Draw::Atoi(argv[2]);
403 Standard_Real QuantityOfBlue = Draw::Atoi(argv[3]);
404 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
411 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
413 // setcolor <object> <r> <g> <b>
414 // change the object color with RGB values.
417 Standard_Real QuantityOfRed = Draw::Atof(argv[2]);
418 Standard_Real QuantityOfGreen = Draw::Atof(argv[3]);
419 Standard_Real QuantityOfBlue = Draw::Atof(argv[4]);
421 TopoDS_Shape aShape = DBRep::Get(argv[1]);
422 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
423 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
424 myAISContext->Display(myShape,Standard_True);
425 myAISContext->UpdateCurrentViewer();
426 // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
427 // myShape->Redisplay();
434 #include <Bnd_BoundSortBox.hxx>
435 #include <BRepBndLib.hxx>
436 #include <Bnd_HArray1OfBox.hxx>
438 static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ )
441 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
443 BRepBndLib::Add(aShape , aMainBox );
445 Standard_Integer siMaxNbrBox = 6;
446 Bnd_BoundSortBox m_BoundSortBox;
447 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
448 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
452 // Bnd_Box __emptyBox; // Box is void !
453 // Handle(Bnd_HArray1OfBox) __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
455 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
457 const TopoDS_Shape& aFace = aExplorer.Current();
459 BRepBndLib::Add( aFace, aBox );
460 m_BoundSortBox.Add( aBox, i );
461 // __aSetOfBox->SetValue( i, aBox );
463 // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
468 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
470 TCollection_AsciiString as1("");
471 TCollection_AsciiString as2('\0');
472 if(as1.ToCString() == NULL || as1.Length() != 0 || as1.ToCString()[0] != '\0')
473 di << "Error : the first string is not zero string : " << as1.ToCString() << "\n";
475 if(as2.ToCString() == NULL || as2.Length() != 0 || as2.ToCString()[0] != '\0')
476 di << "Error : the second string is not zero string : " << as2.ToCString() << "\n";
481 #include <UnitsAPI.hxx>
483 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
485 di <<"Program Test\n";
486 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
487 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
492 #include <gp_Circ.hxx>
493 #include <Geom_Circle.hxx>
494 #include <GeomAPI.hxx>
495 #include <Geom2d_CartesianPoint.hxx>
496 #include <Geom2dGcc_QualifiedCurve.hxx>
497 #include <Geom2dGcc_Circ2d2TanRad.hxx>
498 #include <Geom2d_Circle.hxx>
499 #include <ProjLib.hxx>
501 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
503 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
504 if(aContext.IsNull()) {
505 di << "use 'vinit' command before " << argv[0] << "\n";
509 gp_Pnt pt3d(0, 20, 150);
510 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
511 gp_Circ circ(anAx2, 50.0);
512 Handle(Geom_Circle) gcir = new Geom_Circle(circ);
513 Handle(Geom_Plane) pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
514 Handle(Geom2d_Curve) gcir1 = GeomAPI::To2d(gcir, pln->Pln());
515 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
516 Handle(AIS_Shape) ais1 = new AIS_Shape(sh1);
517 aContext->SetColor (ais1, Quantity_NOC_INDIANRED, Standard_False);
518 aContext->Display (ais1, Standard_False);
519 DBRep::Set("sh0",sh1);
521 // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
522 thepoint = ProjLib::Project(pln->Pln(),pt3d);
523 Handle(Geom2d_CartesianPoint) ThePoint = new Geom2d_CartesianPoint(thepoint);
524 Geom2dAdaptor_Curve acur1(gcir1) ;
525 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
526 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
527 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
528 Handle(Geom2d_Circle) gccc;
529 if( cirtanrad.NbSolutions() ) {
530 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
531 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
532 gccc = new Geom2d_Circle(ccc);
533 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
534 Standard_Character aStr[5];
535 Sprintf(aStr,"sh%d",i);
537 Handle(AIS_Shape) ais = new AIS_Shape(sh);
539 aContext->SetColor (ais, Quantity_NOC_GREEN, Standard_False);
541 aContext->SetColor (ais, Quantity_NOC_HOTPINK, Standard_False);
542 aContext->Display (ais, Standard_False);
543 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
544 gp_Pnt2d PntSol1, PntSol2;
545 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
546 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
547 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
548 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
551 aContext->UpdateCurrentViewer();
555 #include <TColgp_Array2OfPnt.hxx>
556 #include <Geom_BezierSurface.hxx>
557 #include <BRepBuilderAPI_MakeFace.hxx>
558 #include <BRepBuilderAPI_MakeWire.hxx>
559 #include <Geom_OffsetSurface.hxx>
560 #include <BRepFilletAPI_MakeFillet2d.hxx>
561 #include <GeomProjLib.hxx>
562 #include <Geom_TrimmedCurve.hxx>
564 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
568 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
569 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
570 Standard_Real f = 0.0, l = 0.0;
571 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
572 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
573 GC = new Geom_TrimmedCurve(GC, f, l);
574 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
575 BRepBuilderAPI_MakeWire *myWire;
576 myWire = new BRepBuilderAPI_MakeWire();
577 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
578 DBRep::Set(argv[1],myWire->Wire());
582 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
583 if(aContext.IsNull()) {
584 di << "use 'vinit' command before " << argv[0] << "\n";
588 //step 1. creating a Bezier Surface and a patch
592 Handle(AIS_Shape) ais1;
593 Handle(AIS_Shape) ais2;
594 Handle(Geom_BezierSurface) BZ1;
595 TColgp_Array2OfPnt array1(1,3,1,3);
596 array1.SetValue(1,1,gp_Pnt(0,100,0));
597 array1.SetValue(1,2,gp_Pnt(200,100,0));
598 array1.SetValue(1,3,gp_Pnt(400,100,0));
599 array1.SetValue(2,1,gp_Pnt(0,200,100));
600 array1.SetValue(2,2,gp_Pnt(200,200,100));
601 array1.SetValue(2,3,gp_Pnt(400,200,100));
602 array1.SetValue(3,1,gp_Pnt(0,300,0));
603 array1.SetValue(3,2,gp_Pnt(200,300,0));
604 array1.SetValue(3,3,gp_Pnt(400,300,0));
605 BZ1 = new Geom_BezierSurface(array1);
606 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
607 TopoDS_Face F1= bzf1.Face();
608 ais1 = new AIS_Shape(F1);
610 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
611 aContext->Display (ais1, Standard_False);
616 shell.Closed (BRep_Tool::IsClosed (shell));
619 gp_Dir D(0, 0, 1.0f);
620 BRepBuilderAPI_MakeWire mkw;
621 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
622 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
623 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
625 p1 = gp_Pnt(350., 150., 260.);
626 p2 = gp_Pnt(350., 250., 260.);
627 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
629 p1 = gp_Pnt(350., 250., 260.);
630 p2 = gp_Pnt(300., 250.0, 260.);
631 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
633 p1 = gp_Pnt(300., 250.0, 260.);
634 p2 = gp_Pnt(200., 200.0, 260.);
635 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
637 p1 = gp_Pnt(200., 200.0, 260.);
638 p2 = gp_Pnt(150., 200.0, 260.);
639 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
641 p1 = gp_Pnt(150., 200.0, 260.);
642 p2 = gp_Pnt(150., 150.0, 260.);
643 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
645 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
646 ais2 = new AIS_Shape( FP );
647 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
648 aContext->Display (ais2, Standard_False);
652 //step 2. offseting the surface.
653 Handle(Geom_OffsetSurface) offsurf;
654 offsurf = new Geom_OffsetSurface(BZ1, -100);
655 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
656 TopoDS_Face F2= bzf2.Face();
657 Handle(AIS_Shape) ais22 = new AIS_Shape(F2);
658 aContext->Display (ais22, Standard_False);
661 //step 3. filleting the patch.
662 //( I want to project wire of this patch on offseted surface above)
663 BRepFilletAPI_MakeFillet2d fillet( FP );
665 Ex.Init(FP, TopAbs_VERTEX);
666 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
667 fillet.AddFillet(v1, 20);
668 di << "\nError is " << fillet.Status() << "\n";
669 // printf("\nError is %d ", fillet.Status());
671 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
672 fillet.AddFillet(V2, 20);
673 di << "\nError is " << fillet.Status() << "\n";
674 // printf("\nError is %d ", fillet.Status());
676 FP1 = fillet.Shape();
677 ais2 = new AIS_Shape( FP1 );
678 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
679 aContext->Display (ais2, Standard_False);
681 DBRep::Set("FP1",FP1);
683 //step 4. Projecting the wire of this patch on offsetted surface.
684 // TopExp_Explorer Ex;
685 BRepBuilderAPI_MakeWire *myWire;
686 myWire = new BRepBuilderAPI_MakeWire();
687 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
689 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
690 Standard_Real f = 0.0, l = 0.0;
691 Handle(Geom_Curve) newBSplin = BRep_Tool::Curve(e1, f, l);
692 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
693 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
694 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
696 Handle(AIS_Shape) ais33 = new AIS_Shape( myWire->Wire() );
697 aContext->Display (ais33, Standard_True);
699 DBRep::Set("Wire",myWire->Wire());
704 #include<GeomAPI_ExtremaCurveCurve.hxx>
706 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
710 printf("Usage: %s edge1 edge2",argv[0]);
714 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
715 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
717 Standard_Real fp , lp;
719 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
720 C2 = BRep_Tool::Curve(E2 , fp , lp);
722 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
724 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
729 #include <BRepBuilderAPI_MakePolygon.hxx>
730 #include <BRepOffsetAPI_ThruSections.hxx>
732 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
735 di << "Usage : " << argv[0] << "\n";
739 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
740 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
741 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
742 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
743 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
745 for (int i=0;i<4;i++) {
746 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
747 bottompolygon1.Add(tmppnt);
748 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
749 toppolygon1.Add(tmppnt);
750 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
751 bottompolygon2.Add(tmppnt);
752 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
753 toppolygon2.Add(tmppnt);
755 bottompolygon1.Close();
756 DBRep::Set("B1",bottompolygon1.Shape());
758 DBRep::Set("T1",toppolygon1.Shape());
759 bottompolygon2.Close();
760 DBRep::Set("B2",bottompolygon2.Shape());
762 DBRep::Set("T2",toppolygon2.Shape());
763 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
764 loft1.AddWire(bottompolygon1.Wire());
765 loft1.AddWire(toppolygon1.Wire());
767 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
768 loft2.AddWire(bottompolygon2.Wire());
769 loft2.AddWire(toppolygon2.Wire());
771 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
773 DBRep::Set("TS1",loft1.Shape());
774 DBRep::Set("TS2",loft2.Shape());
776 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())\n";
777 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
778 DBRep::Set("F", result.Shape());
783 #include <Geom_RectangularTrimmedSurface.hxx>
784 #include <GC_MakeTrimmedCone.hxx>
786 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
788 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
789 if(aContext.IsNull()) {
790 di << "use 'vinit' command before " << argv[0] << "\n";
797 P1(0,0,20), P2(0,0,45);
798 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
799 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
800 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
801 aContext->Display (ais1, Standard_False);
802 aContext->SetColor (ais1, Quantity_NOC_BLUE1, Standard_False);
804 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
805 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
806 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
807 aContext->Display (ais2, Standard_False);
808 aContext->SetColor (ais2, Quantity_NOC_RED, Standard_False);
812 //==========================================================================
813 //function : CoordLoad
814 // chargement d une face dans l explorer.
815 //==========================================================================
816 static Standard_Integer coordload (Draw_Interpretor& theDi,
817 Standard_Integer theArgsNb,
818 const char** theArgVec)
825 std::ifstream aFile (theArgVec[2], ios::in);
828 theDi << "unable to open " << theArgVec[2] << " for input\n";
833 memset (aLine, 0, 40);
834 aFile.getline (aLine, 80);
836 gp_Pnt aPnt (0.0, 0.0, 0.0);
838 aPnt.SetY (Draw::Atof (&aLine[20]));
840 aPnt.SetX (Draw::Atof (aLine));
841 TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt);
842 BRepBuilderAPI_MakeWire aMakeWire;
845 memset (aLine, 0, 40);
846 aFile.getline (aLine, 80);
853 aPnt.SetY (Draw::Atof (&aLine[20]));
855 aPnt.SetX (Draw::Atof (aLine));
856 TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt);
857 aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2));
862 if (!aMakeWire.IsDone())
864 DBRep::Set (theArgVec[1], TopoDS_Face());
868 BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire());
869 DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face());
873 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
874 Standard_Integer /*nb*/,
875 const char ** /*arg*/)
877 TCollection_ExtendedString aString(1024*1024, 'A');
881 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
882 Standard_Integer argc,
885 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
886 if(aContext.IsNull()) {
887 di << "use 'vinit' command before " << argv[0] << "\n";
890 if((argc != 2) && (argc != 3)) {
891 di<< "usage : " << argv[0] << " shape [mode==1]\n";
894 TopoDS_Shape aShape = DBRep::Get(argv[1]);
895 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
896 // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
897 anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
898 aContext->Display (anIO, Standard_True);
902 //=======================================================================
903 //function : buc60773
905 //=======================================================================
907 #include<TCollection_HAsciiString.hxx>
909 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
911 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
912 Standard_CString aStr = hAscii->ToCString();
913 TCollection_AsciiString aAscii(aStr);
918 #include<BRepPrimAPI_MakeCylinder.hxx>
919 #include<BRepPrimAPI_MakeCone.hxx>
921 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
925 di << "Usage : " << argv[0] << "\n";
929 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
931 Standard_Real x11 = 36.085182;
932 Standard_Real y11 = 20.0;
933 Standard_Real z11 = 8.431413;
934 Standard_Real x12 = 88.04671;
935 Standard_Real y12 = 20.0;
936 Standard_Real z12 = 38.931416;
937 Standard_Real radius = 10.0;
939 gp_Pnt base1(x11, y11, z11);
940 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
941 gp_Ax2 axis1(base1, vect1);
942 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
943 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
945 TopoDS_Shape SCyl = cylinder.Shape();
946 DBRep::Set("cyl", SCyl);
949 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
950 Standard_Real x21 = 70.7262;
951 Standard_Real y21 = 20.0;
952 Standard_Real z21 = 28.431412;
953 Standard_Real x22 = 105.36722;
954 Standard_Real y22 = 20.0;
955 Standard_Real z22 = 48.431416;
956 Standard_Real radius1 = 6.0;
957 Standard_Real radius2 = 3.0;
959 gp_Pnt base2(x21, y21, z21);
960 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
961 gp_Ax2 axis2(base2, vect2);
962 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
963 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
965 TopoDS_Shape SCon = cone.Shape();
966 DBRep::Set("con", SCon);
968 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)\n";
969 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
970 if (!SFuse.IsDone()) {
971 di << "Error: Boolean fuse operation failed !\n";
974 const TopoDS_Shape& fuse = SFuse.Shape();
975 DBRep::Set("fus", fuse);
980 #include <NCollection_DataMap.hxx>
981 #include <TColStd_HSequenceOfAsciiString.hxx>
982 #include <TopExp.hxx>
983 #include <TopoDS_Iterator.hxx>
985 //---------------------------------------------------------------------------------------
987 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
990 TopoDS_Shape aShape = DBRep::Get(argv[1]);
993 di<<"Invalid input shape\n";
996 NCollection_DataMap<TCollection_AsciiString, Standard_Integer> aMap;
997 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
998 Standard_CString aString;
999 Standard_Integer l=0;
1000 TopExp_Explorer expl;
1001 Standard_Real f3d,l3d;
1002 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1005 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1006 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1007 aString = aSurface->DynamicType()->Name();
1009 if (aMap.IsBound(aString))
1010 aMap.ChangeFind(aString)++;
1012 aMap.Bind(aString, 1);
1013 aSequence->Append(aString);
1017 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1019 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1020 TopoDS_Iterator anIt(aFace);
1021 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1022 TopoDS_Iterator it (aWire);
1023 for (; it.More(); it.Next()) {
1024 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1025 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1026 aString = aCurve2d->DynamicType()->Name();
1027 if(aMap.IsBound(aString))
1028 aMap.ChangeFind(aString)++;
1030 aMap.Bind(aString, 1);
1031 aSequence->Append(aString);
1036 TopExp_Explorer exp;
1037 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
1039 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1040 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1041 if(aCurve3d.IsNull())
1045 aString = aCurve3d->DynamicType()->Name();
1046 if (aMap.IsBound(aString))
1048 aMap.ChangeFind(aString)++;
1050 aMap.Bind(aString, 1);
1051 aSequence->Append(aString);
1058 for (Standard_Integer i = 1; i <= aSequence->Length(); i++) {
1059 di << aMap.Find(aSequence->Value(i)) << " -- " << aSequence->Value(i).ToCString() << "\n";
1063 di<<"Degenerated edges :\n";
1064 di<<l<<" -- Degenerated edges \n";
1070 #include <BRepBuilderAPI_Transform.hxx>
1072 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1075 di << "Usage : " << argv[0] << "\n";
1079 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1080 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1081 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1083 TopoDS_Shape sh1 = cyl.Shape();
1084 DBRep::Set("sh1",sh1);
1085 gp_Trsf trsf1, trsf2;
1086 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1087 gp_Pnt(0.000000,700.000000,-95.000000));
1088 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1089 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1090 BRepBuilderAPI_Transform trans1(sh1, trsf1);
1091 TopoDS_Shape sh2 = trans1.Shape();
1092 DBRep::Set("sh2",sh2);
1094 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)\n";
1095 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1096 TopoDS_Shape fsh1 = fuse1.Shape();
1097 DBRep::Set("fsh1",fsh1);
1099 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1100 TopoDS_Shape sh3 = trans2.Shape();
1101 DBRep::Set("sh3",sh3);
1103 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)\n";
1104 BRepAlgoAPI_Fuse fuse2(fsh1, sh3);
1105 const TopoDS_Shape& fsh2 = fuse2.Shape();
1106 DBRep::Set("fsh2",fsh2);
1108 Handle(AIS_Shape) aisp1 = new AIS_Shape(fsh2);
1112 #include <ShapeBuild_Edge.hxx>
1114 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1116 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1117 ShapeBuild_Edge().BuildCurve3d(e);
1123 #include<TDF_Label.hxx>
1124 #include<TDataStd_TreeNode.hxx>
1126 #include<DDocStd.hxx>
1130 #include<TDocStd_Modified.hxx>
1131 #include<TDF_ListIteratorOfDeltaList.hxx>
1132 #include<TDocStd_Document.hxx>
1133 #include<TDocStd_Application.hxx>
1134 #include<TDF_Delta.hxx>
1135 #include<TDataXtd_Constraint.hxx>
1136 #include<TPrsStd_AISPresentation.hxx>
1137 #include<TPrsStd_AISViewer.hxx>
1138 #include<TNaming_Builder.hxx>
1139 #include<TNaming_Naming.hxx>
1140 #include<TNaming_NamedShape.hxx>
1142 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1144 di << "Usage : " << argv[0] << " D\n";
1149 Handle(TDF_Data) DF;
1150 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1153 Handle(TDataStd_TreeNode) TN1,TN2;
1155 DDF::AddLabel(DF,"0:2",L1);
1156 TN1 = TDataStd_TreeNode::Set(L1);
1158 DDF::AddLabel(DF,"0:3",L2);
1159 TN2 = TDataStd_TreeNode::Set(L2);
1162 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1163 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1169 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1171 di << "Usage : " << argv[0] << " D\n";
1176 Handle(TDF_Data) DF;
1177 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1180 DDF::FindLabel(DF,"0:1",L,Standard_False);
1181 Handle(TDocStd_Modified) MDF;
1182 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1183 MDF = new TDocStd_Modified();
1184 L.Root().AddAttribute(MDF);
1187 di<<!MDF->IsEmpty();
1191 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1193 di << "Usage : " << argv[0] << " D Label\n";
1198 Handle(TDF_Data) DF;
1199 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1202 DDF::FindLabel(DF,argv[2],L,Standard_False);
1204 TDocStd_Modified::Add(L);
1210 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1212 di << "Usage : " << argv[0] << " D\n";
1218 Handle(TDF_Data) aDF;
1219 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1221 Handle(TDocStd_Document) aDocument;
1222 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1225 Handle(TDataStd_TreeNode) TN;
1227 aDocument->NewCommand();
1228 DDF::AddLabel(aDF,"0:2",L);
1229 TN = TDataStd_TreeNode::Set(L);
1231 aDocument->NewCommand();
1232 DDF::AddLabel(aDF,"0:3",L);
1233 TN = TDataStd_TreeNode::Set(L);
1235 aDocument->NewCommand();
1236 DDF::AddLabel(aDF,"0:4",L);
1237 TN = TDataStd_TreeNode::Set(L);
1238 aDocument->NewCommand();
1240 TDF_DeltaList Us,Rs;
1241 Us = aDocument->GetUndos();
1242 Rs = aDocument->GetUndos();
1245 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1247 TDF_ListIteratorOfDeltaList IDL;
1248 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1249 Handle(TDF_Delta) D = IDL.Value();
1250 TCollection_ExtendedString S(Names[i-1]);
1252 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1258 Us = aDocument->GetUndos();
1259 Rs = aDocument->GetRedos();
1261 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1262 Handle(TDF_Delta) D = IDL.Value();
1263 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1266 TCollection_ExtendedString n2name ("n2");
1267 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1268 Handle(TDF_Delta) D = IDL.Value();
1269 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1280 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1282 di << "Usage : " << argv[0] << " D Shape\n";
1287 Handle(TDF_Data) aDF;
1288 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1290 TopoDS_Shape s = DBRep::Get(argv[2]);
1291 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
1293 DDF::AddLabel(aDF, "0:2", L);
1294 TNaming_Builder SI (L);
1297 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1301 // if (!NS->IsEmpty()) {di<<3;return 0;}
1302 if (NS->IsEmpty()) {di<<4;return 0;}
1307 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1309 di << "Usage : " << argv[0] << " D Shape\n";
1314 Handle(TDF_Data) aDF;
1315 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1317 TopoDS_Shape s = DBRep::Get(argv[2]);
1318 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
1320 DDF::AddLabel(aDF, "0:2", L);
1321 TNaming_Builder SI (L);
1324 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1328 if (NS->IsEmpty()) {di<<4;return 0;}
1333 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1335 TCollection_ExtendedString path (argv[1]);
1336 Handle(TDocStd_Application) A = DDocStd::GetApplication();
1337 Handle(TDocStd_Document) D;
1338 Standard_Integer insession = A->IsInSession(path);
1339 if (insession > 0) {
1340 di <<"document " << insession << " is already in session\n";
1344 PCDM_ReaderStatus Result = A->Open(path,D);
1345 if(Result==PCDM_RS_OK){
1354 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1356 di << "Usage : " << argv[0] << " D\n";
1361 Handle(TDF_Data) aDF;
1362 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1365 DDF::AddLabel(aDF, "0:2", L);
1367 Handle(TPrsStd_AISPresentation) AISP =
1368 TPrsStd_AISPresentation::Set(L,TDataXtd_Constraint::GetID());
1370 if (AISP->HasOwnMode()) {di<<3;return 0;}
1372 Standard_Integer Mode = AISP->Mode();
1373 if (Mode!=3) {di<<4;return 0;}
1374 if (!AISP->HasOwnMode()) {di<<5;return 0;}
1376 if (AISP->HasOwnMode()) {di<<6;return 0;}
1381 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1383 di << "Usage : " << argv[0] << " D\n";
1388 Handle(TDF_Data) aDF;
1389 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1392 DDF::AddLabel(aDF, "0:2", L);
1396 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1397 // Handle(TNaming_Name) NN = new TNaming_Name;
1400 NN.Type(TNaming_IDENTITY);
1402 Standard_Boolean Res = NN.Solve(L,LM);
1404 if (Res!=Standard_False) {di<<3;return 0;}
1409 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1411 di << "Usage : " << argv[0] << " D\n";
1417 Handle(TDocStd_Document) aDocument;
1418 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
1420 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
1421 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
1427 //=======================================================================
1428 //function : AISWidth
1429 //purpose : AISWidth (DOC,entry,[width])
1430 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
1431 //=======================================================================
1433 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1436 Handle(TDocStd_Document) D;
1437 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
1439 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
1441 Handle(TPrsStd_AISViewer) viewer;
1442 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
1444 Handle(TPrsStd_AISPresentation) prs;
1445 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1447 prs->SetWidth(Draw::Atof(argv[3]));
1448 TPrsStd_AISViewer::Update(L);
1451 if (prs->HasOwnWidth()){
1452 // cout << "Width = " << prs->Width() << endl;
1456 di << "AISWidth: Warning : Width wasn't set\n";
1463 di << "AISWidth : Error" << "\n";
1468 //=======================================================================
1469 //function : BUC60921 ( & BUC60954 )
1470 //purpose : Test memory allocation of OCAF in Undo/Redo operations
1471 //=======================================================================
1473 static Standard_Integer BUC60921 (Draw_Interpretor& di,
1474 Standard_Integer nb,
1478 Handle(TDocStd_Document) D;
1479 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
1481 DDF::AddLabel(D->GetData(),arg[2],L);
1485 BRepTools::Read ( S, arg[3], B );
1487 TNaming_Builder tnBuild(L);
1488 tnBuild.Generated(S);
1489 // di << "File " << arg[3] << " added";
1493 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
1498 #include<IGESControl_Reader.hxx>
1499 #include<BRepPrimAPI_MakeHalfSpace.hxx>
1501 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
1504 di << "Usage : " << a[0] << " file.igs\n";
1508 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
1510 if(myContext.IsNull()) {
1511 di << "use 'vinit' command before " << a[0] << "\n";
1515 // IGESControlStd_Reader reader;
1516 IGESControl_Reader reader;
1517 reader.ReadFile(a[1]);
1518 reader.TransferRoots();
1519 TopoDS_Shape shape = reader.OneShape();
1520 printf("\n iges1 shape type = %d", shape.ShapeType() );
1521 TopTools_IndexedMapOfShape list;
1522 TopExp::MapShapes(shape, TopAbs_FACE, list);
1523 printf("\n No. of faces = %d", list.Extent());
1526 BRep_Builder builder;
1527 builder.MakeShell(shell);
1528 for(int i=1;i<=list.Extent(); i++) {
1529 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
1530 builder.Add(shell, face);
1532 shell.Closed (BRep_Tool::IsClosed (shell));
1534 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
1535 TopoDS_Solid sol = half.Solid();
1536 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
1537 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
1538 TopoDS_Shape sh = cyl.Shape();
1540 di << "BRepAlgoAPI_Fuse fuse(sol, sh)\n";
1541 BRepAlgoAPI_Fuse fuse(sol, sh);
1544 Handle(AIS_Shape) res = new AIS_Shape(sh);
1545 myContext->Display (res, Standard_True);
1549 void QABugs::Commands_3(Draw_Interpretor& theCommands) {
1550 const char *group = "QABugs";
1552 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
1553 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
1554 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
1555 theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group);
1556 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
1557 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
1558 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
1560 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
1561 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
1563 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
1564 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
1565 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
1566 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
1567 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
1569 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
1571 theCommands.Add("OCC10006","OCC10006",__FILE__,OCC10006,group);
1573 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
1575 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
1577 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
1578 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
1579 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
1580 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
1582 theCommands.Add("TestCMD","TestCMD",__FILE__,TestCMD,group);
1584 theCommands.Add("statface","statface face",__FILE__,statface,group);
1586 theCommands.Add("BUC60841","BUC60841",__FILE__,BUC60841,group);
1588 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
1590 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
1591 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
1592 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
1593 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
1594 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
1595 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
1596 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
1597 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
1598 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
1599 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
1600 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
1601 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
1603 theCommands.Add("BUC60951","BUC60951 file.igs",__FILE__,BUC60951_, group );