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<BRepBuilderAPI_MakeVertex.hxx>
130 #include<TCollection_ExtendedString.hxx>
131 #include<AIS_LengthDimension.hxx>
133 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
136 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
137 if(myAIScontext.IsNull()) {
138 di << "use 'vinit' command before " << a[0] << "\n";
141 myAIScontext->EraseAll (Standard_False);
143 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
144 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
146 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
147 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
149 myAIScontext->Display (Ve1, Standard_False);
150 myAIScontext->Display (Ve2, Standard_False);
152 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
153 TCollection_ExtendedString Ext1("Dim1");
154 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln());
155 Dim1->SetCustomValue (Draw::Atof(a[2]));
157 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
158 anAspect->MakeArrows3d (Standard_False);
159 anAspect->MakeText3d (Standard_True);
160 anAspect->MakeTextShaded (Standard_True);
161 anAspect->TextAspect()->SetHeight (2.5);
162 anAspect->ArrowAspect()->SetLength (1.0);
163 Dim1->SetDimensionAspect (anAspect);
165 myAIScontext->SetDisplayMode (Dim1, Draw::Atoi(a[1]), Standard_False);
166 myAIScontext->Display (Dim1, Standard_True);
170 #include<TopoDS_Wire.hxx>
171 #include <BRepTools.hxx>
173 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
176 di << "Usage : BUC60652 fase" << "\n";
179 TopoDS_Shape shape = DBRep::Get( argv[1] );
180 TopoDS_Face face = TopoDS::Face( shape );
181 TopoDS_Wire ow = BRepTools::OuterWire( face );
182 DBRep::Set( "w", ow );
186 #include <Geom_Axis2Placement.hxx>
187 #include <AIS_Trihedron.hxx>
189 static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
192 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
193 if(myAISContext.IsNull()) {
194 di << "use 'vinit' command before " << a[0] << "\n";
198 Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY());
199 Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis);
202 aTrsf.SetTranslation(trans);
203 TopLoc_Location aLoc(aTrsf);
204 myAISContext->SetLocation(atri,aLoc);
205 myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
207 Standard_DISABLE_DEPRECATION_WARNINGS
208 myAISContext->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False);
209 Standard_ENABLE_DEPRECATION_WARNINGS
211 myAISContext->Load(atri,3,Standard_True);
216 #include <TopoDS_Solid.hxx>
217 #include <BRepPrimAPI_MakeBox.hxx>
218 #include <BRepPrimAPI_MakeSphere.hxx>
220 #include <BRepAlgoAPI_Fuse.hxx>
222 #include <V3d_View.hxx>
223 #include <gce_MakePln.hxx>
225 #define DEFAULT_COLOR Quantity_NOC_GOLDENROD
227 //=======================================================================
228 //function : GetColorFromName
229 //purpose : get the Quantity_NameOfColor from a string
230 //=======================================================================
232 static Quantity_NameOfColor GetColorFromName( const char *name )
234 Quantity_NameOfColor ret = DEFAULT_COLOR;
236 Standard_Boolean Found = Standard_False;
237 Standard_CString colstring;
238 for(Standard_Integer i=0;i<=514 && !Found;i++)
240 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
241 if (!strcasecmp(name,colstring)) {
242 ret = (Quantity_NameOfColor)i;
243 Found = Standard_True;
250 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
253 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
254 if(myAISContext.IsNull()) {
255 di << "use 'vinit' command before " << argv[0] << "\n";
259 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
265 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
267 // Change the background color of the view with a predefined name Graphic3d_NOC_<name>
269 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
270 myV3dView -> Redraw();
276 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
277 // setcolor <object> <name>
278 // Change the object color with a predefined name
280 TopoDS_Shape aShape = DBRep::Get(argv[1]);
281 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
282 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
283 myAISContext->Display(myShape,Standard_True);
284 myAISContext->UpdateCurrentViewer();
290 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
292 // setcolor <r> <g> <b>
293 // Change the background color of the view with the color values <r>,<g>,<b>
294 // A color value must be defined in the space [0.,1.]
296 Standard_Real QuantityOfRed = Draw::Atoi(argv[1]);
297 Standard_Real QuantityOfGreen = Draw::Atoi(argv[2]);
298 Standard_Real QuantityOfBlue = Draw::Atoi(argv[3]);
299 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
306 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
308 // setcolor <object> <r> <g> <b>
309 // change the object color with RGB values.
312 Standard_Real QuantityOfRed = Draw::Atof(argv[2]);
313 Standard_Real QuantityOfGreen = Draw::Atof(argv[3]);
314 Standard_Real QuantityOfBlue = Draw::Atof(argv[4]);
316 TopoDS_Shape aShape = DBRep::Get(argv[1]);
317 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
318 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
319 myAISContext->Display(myShape,Standard_True);
320 myAISContext->UpdateCurrentViewer();
321 // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
322 // myShape->Redisplay();
329 #include <Bnd_BoundSortBox.hxx>
330 #include <BRepBndLib.hxx>
331 #include <Bnd_HArray1OfBox.hxx>
332 #include <TopExp_Explorer.hxx>
334 static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ )
337 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
339 BRepBndLib::Add(aShape , aMainBox );
341 Standard_Integer siMaxNbrBox = 6;
342 Bnd_BoundSortBox m_BoundSortBox;
343 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
344 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
348 // Bnd_Box __emptyBox; // Box is void !
349 // Handle(Bnd_HArray1OfBox) __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
351 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
353 const TopoDS_Shape& aFace = aExplorer.Current();
355 BRepBndLib::Add( aFace, aBox );
356 m_BoundSortBox.Add( aBox, i );
357 // __aSetOfBox->SetValue( i, aBox );
359 // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
364 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
366 TCollection_AsciiString as1("");
367 TCollection_AsciiString as2('\0');
368 if(as1.ToCString() == NULL || as1.Length() != 0 || as1.ToCString()[0] != '\0')
369 di << "Error : the first string is not zero string : " << as1.ToCString() << "\n";
371 if(as2.ToCString() == NULL || as2.Length() != 0 || as2.ToCString()[0] != '\0')
372 di << "Error : the second string is not zero string : " << as2.ToCString() << "\n";
377 #include <UnitsAPI.hxx>
379 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
381 di <<"Program Test\n";
382 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
383 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
388 #include <gp_Circ.hxx>
389 #include <Geom_Circle.hxx>
390 #include <GeomAPI.hxx>
391 #include <Geom2d_CartesianPoint.hxx>
392 #include <Geom2dGcc_QualifiedCurve.hxx>
393 #include <Geom2dGcc_Circ2d2TanRad.hxx>
394 #include <Geom2d_Circle.hxx>
395 #include <ProjLib.hxx>
397 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
399 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
400 if(aContext.IsNull()) {
401 di << "use 'vinit' command before " << argv[0] << "\n";
405 gp_Pnt pt3d(0, 20, 150);
406 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
407 gp_Circ circ(anAx2, 50.0);
408 Handle(Geom_Circle) gcir = new Geom_Circle(circ);
409 Handle(Geom_Plane) pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
410 Handle(Geom2d_Curve) gcir1 = GeomAPI::To2d(gcir, pln->Pln());
411 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
412 Handle(AIS_Shape) ais1 = new AIS_Shape(sh1);
413 aContext->SetColor (ais1, Quantity_NOC_INDIANRED, Standard_False);
414 aContext->Display (ais1, Standard_False);
415 DBRep::Set("sh0",sh1);
417 // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
418 thepoint = ProjLib::Project(pln->Pln(),pt3d);
419 Handle(Geom2d_CartesianPoint) ThePoint = new Geom2d_CartesianPoint(thepoint);
420 Geom2dAdaptor_Curve acur1(gcir1) ;
421 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
422 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
423 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
424 Handle(Geom2d_Circle) gccc;
425 if( cirtanrad.NbSolutions() ) {
426 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
427 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
428 gccc = new Geom2d_Circle(ccc);
429 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
430 Standard_Character aStr[5];
431 Sprintf(aStr,"sh%d",i);
433 Handle(AIS_Shape) ais = new AIS_Shape(sh);
435 aContext->SetColor (ais, Quantity_NOC_GREEN, Standard_False);
437 aContext->SetColor (ais, Quantity_NOC_HOTPINK, Standard_False);
438 aContext->Display (ais, Standard_False);
439 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
440 gp_Pnt2d PntSol1, PntSol2;
441 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
442 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
443 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
444 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
447 aContext->UpdateCurrentViewer();
451 #include <TColgp_Array2OfPnt.hxx>
452 #include <Geom_BezierSurface.hxx>
453 #include <BRepBuilderAPI_MakeFace.hxx>
454 #include <BRepBuilderAPI_MakeWire.hxx>
455 #include <Geom_OffsetSurface.hxx>
456 #include <BRepFilletAPI_MakeFillet2d.hxx>
457 #include <GeomProjLib.hxx>
458 #include <Geom_TrimmedCurve.hxx>
460 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
464 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
465 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
466 Standard_Real f = 0.0, l = 0.0;
467 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
468 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
469 GC = new Geom_TrimmedCurve(GC, f, l);
470 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
471 BRepBuilderAPI_MakeWire *myWire;
472 myWire = new BRepBuilderAPI_MakeWire();
473 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
474 DBRep::Set(argv[1],myWire->Wire());
478 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
479 if(aContext.IsNull()) {
480 di << "use 'vinit' command before " << argv[0] << "\n";
484 //step 1. creating a Bezier Surface and a patch
488 Handle(AIS_Shape) ais1;
489 Handle(AIS_Shape) ais2;
490 Handle(Geom_BezierSurface) BZ1;
491 TColgp_Array2OfPnt array1(1,3,1,3);
492 array1.SetValue(1,1,gp_Pnt(0,100,0));
493 array1.SetValue(1,2,gp_Pnt(200,100,0));
494 array1.SetValue(1,3,gp_Pnt(400,100,0));
495 array1.SetValue(2,1,gp_Pnt(0,200,100));
496 array1.SetValue(2,2,gp_Pnt(200,200,100));
497 array1.SetValue(2,3,gp_Pnt(400,200,100));
498 array1.SetValue(3,1,gp_Pnt(0,300,0));
499 array1.SetValue(3,2,gp_Pnt(200,300,0));
500 array1.SetValue(3,3,gp_Pnt(400,300,0));
501 BZ1 = new Geom_BezierSurface(array1);
502 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
503 TopoDS_Face F1= bzf1.Face();
504 ais1 = new AIS_Shape(F1);
506 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
507 aContext->Display (ais1, Standard_False);
512 shell.Closed (BRep_Tool::IsClosed (shell));
515 gp_Dir D(0, 0, 1.0f);
516 BRepBuilderAPI_MakeWire mkw;
517 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
518 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
519 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
521 p1 = gp_Pnt(350., 150., 260.);
522 p2 = gp_Pnt(350., 250., 260.);
523 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
525 p1 = gp_Pnt(350., 250., 260.);
526 p2 = gp_Pnt(300., 250.0, 260.);
527 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
529 p1 = gp_Pnt(300., 250.0, 260.);
530 p2 = gp_Pnt(200., 200.0, 260.);
531 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
533 p1 = gp_Pnt(200., 200.0, 260.);
534 p2 = gp_Pnt(150., 200.0, 260.);
535 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
537 p1 = gp_Pnt(150., 200.0, 260.);
538 p2 = gp_Pnt(150., 150.0, 260.);
539 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
541 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
542 ais2 = new AIS_Shape( FP );
543 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
544 aContext->Display (ais2, Standard_False);
548 //step 2. offseting the surface.
549 Handle(Geom_OffsetSurface) offsurf;
550 offsurf = new Geom_OffsetSurface(BZ1, -100);
551 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
552 TopoDS_Face F2= bzf2.Face();
553 Handle(AIS_Shape) ais22 = new AIS_Shape(F2);
554 aContext->Display (ais22, Standard_False);
557 //step 3. filleting the patch.
558 //( I want to project wire of this patch on offseted surface above)
559 BRepFilletAPI_MakeFillet2d fillet( FP );
561 Ex.Init(FP, TopAbs_VERTEX);
562 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
563 fillet.AddFillet(v1, 20);
564 di << "\nError is " << fillet.Status() << "\n";
565 // printf("\nError is %d ", fillet.Status());
567 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
568 fillet.AddFillet(V2, 20);
569 di << "\nError is " << fillet.Status() << "\n";
570 // printf("\nError is %d ", fillet.Status());
572 FP1 = fillet.Shape();
573 ais2 = new AIS_Shape( FP1 );
574 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
575 aContext->Display (ais2, Standard_False);
577 DBRep::Set("FP1",FP1);
579 //step 4. Projecting the wire of this patch on offsetted surface.
580 // TopExp_Explorer Ex;
581 BRepBuilderAPI_MakeWire *myWire;
582 myWire = new BRepBuilderAPI_MakeWire();
583 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
585 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
586 Standard_Real f = 0.0, l = 0.0;
587 Handle(Geom_Curve) newBSplin = BRep_Tool::Curve(e1, f, l);
588 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
589 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
590 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
592 Handle(AIS_Shape) ais33 = new AIS_Shape( myWire->Wire() );
593 aContext->Display (ais33, Standard_True);
595 DBRep::Set("Wire",myWire->Wire());
600 #include<GeomAPI_ExtremaCurveCurve.hxx>
602 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
606 printf("Usage: %s edge1 edge2",argv[0]);
610 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
611 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
613 Standard_Real fp , lp;
615 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
616 C2 = BRep_Tool::Curve(E2 , fp , lp);
618 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
620 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
625 #include <BRepBuilderAPI_MakePolygon.hxx>
626 #include <BRepOffsetAPI_ThruSections.hxx>
628 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
631 di << "Usage : " << argv[0] << "\n";
635 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
636 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
637 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
638 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
639 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
641 for (int i=0;i<4;i++) {
642 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
643 bottompolygon1.Add(tmppnt);
644 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
645 toppolygon1.Add(tmppnt);
646 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
647 bottompolygon2.Add(tmppnt);
648 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
649 toppolygon2.Add(tmppnt);
651 bottompolygon1.Close();
652 DBRep::Set("B1",bottompolygon1.Shape());
654 DBRep::Set("T1",toppolygon1.Shape());
655 bottompolygon2.Close();
656 DBRep::Set("B2",bottompolygon2.Shape());
658 DBRep::Set("T2",toppolygon2.Shape());
659 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
660 loft1.AddWire(bottompolygon1.Wire());
661 loft1.AddWire(toppolygon1.Wire());
663 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
664 loft2.AddWire(bottompolygon2.Wire());
665 loft2.AddWire(toppolygon2.Wire());
667 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
669 DBRep::Set("TS1",loft1.Shape());
670 DBRep::Set("TS2",loft2.Shape());
672 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())\n";
673 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
674 DBRep::Set("F", result.Shape());
679 #include <Geom_RectangularTrimmedSurface.hxx>
680 #include <GC_MakeTrimmedCone.hxx>
682 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
684 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
685 if(aContext.IsNull()) {
686 di << "use 'vinit' command before " << argv[0] << "\n";
693 P1(0,0,20), P2(0,0,45);
694 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
695 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
696 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
697 aContext->Display (ais1, Standard_False);
698 aContext->SetColor (ais1, Quantity_NOC_BLUE1, Standard_False);
700 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
701 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
702 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
703 aContext->Display (ais2, Standard_False);
704 aContext->SetColor (ais2, Quantity_NOC_RED, Standard_False);
708 //==========================================================================
709 //function : CoordLoad
710 // chargement d une face dans l explorer.
711 //==========================================================================
712 static Standard_Integer coordload (Draw_Interpretor& theDi,
713 Standard_Integer theArgsNb,
714 const char** theArgVec)
721 std::ifstream aFile (theArgVec[2], ios::in);
724 theDi << "unable to open " << theArgVec[2] << " for input\n";
729 memset (aLine, 0, 40);
730 aFile.getline (aLine, 80);
732 gp_Pnt aPnt (0.0, 0.0, 0.0);
734 aPnt.SetY (Draw::Atof (&aLine[20]));
736 aPnt.SetX (Draw::Atof (aLine));
737 TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt);
738 BRepBuilderAPI_MakeWire aMakeWire;
741 memset (aLine, 0, 40);
742 aFile.getline (aLine, 80);
749 aPnt.SetY (Draw::Atof (&aLine[20]));
751 aPnt.SetX (Draw::Atof (aLine));
752 TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt);
753 aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2));
758 if (!aMakeWire.IsDone())
760 DBRep::Set (theArgVec[1], TopoDS_Face());
764 BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire());
765 DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face());
769 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
770 Standard_Integer /*nb*/,
771 const char ** /*arg*/)
773 TCollection_ExtendedString aString(1024*1024, 'A');
777 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
778 Standard_Integer argc,
781 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
782 if(aContext.IsNull()) {
783 di << "use 'vinit' command before " << argv[0] << "\n";
786 if((argc != 2) && (argc != 3)) {
787 di<< "usage : " << argv[0] << " shape [mode==1]\n";
790 TopoDS_Shape aShape = DBRep::Get(argv[1]);
791 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
792 // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
793 anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
794 aContext->Display (anIO, Standard_True);
798 //=======================================================================
799 //function : buc60773
801 //=======================================================================
803 #include<TCollection_HAsciiString.hxx>
805 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
807 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
808 Standard_CString aStr = hAscii->ToCString();
809 TCollection_AsciiString aAscii(aStr);
814 #include<BRepPrimAPI_MakeCylinder.hxx>
815 #include<BRepPrimAPI_MakeCone.hxx>
817 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
821 di << "Usage : " << argv[0] << "\n";
825 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
827 Standard_Real x11 = 36.085182;
828 Standard_Real y11 = 20.0;
829 Standard_Real z11 = 8.431413;
830 Standard_Real x12 = 88.04671;
831 Standard_Real y12 = 20.0;
832 Standard_Real z12 = 38.931416;
833 Standard_Real radius = 10.0;
835 gp_Pnt base1(x11, y11, z11);
836 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
837 gp_Ax2 axis1(base1, vect1);
838 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
839 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
841 TopoDS_Shape SCyl = cylinder.Shape();
842 DBRep::Set("cyl", SCyl);
845 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
846 Standard_Real x21 = 70.7262;
847 Standard_Real y21 = 20.0;
848 Standard_Real z21 = 28.431412;
849 Standard_Real x22 = 105.36722;
850 Standard_Real y22 = 20.0;
851 Standard_Real z22 = 48.431416;
852 Standard_Real radius1 = 6.0;
853 Standard_Real radius2 = 3.0;
855 gp_Pnt base2(x21, y21, z21);
856 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
857 gp_Ax2 axis2(base2, vect2);
858 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
859 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
861 TopoDS_Shape SCon = cone.Shape();
862 DBRep::Set("con", SCon);
864 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)\n";
865 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
866 if (!SFuse.IsDone()) {
867 di << "Error: Boolean fuse operation failed !\n";
870 const TopoDS_Shape& fuse = SFuse.Shape();
871 DBRep::Set("fus", fuse);
876 #include <NCollection_DataMap.hxx>
877 #include <TColStd_HSequenceOfAsciiString.hxx>
878 #include <TopExp.hxx>
879 #include <TopoDS_Iterator.hxx>
881 //---------------------------------------------------------------------------------------
883 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
886 TopoDS_Shape aShape = DBRep::Get(argv[1]);
889 di<<"Invalid input shape\n";
892 NCollection_DataMap<TCollection_AsciiString, Standard_Integer> aMap;
893 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
894 Standard_CString aString;
895 Standard_Integer l=0;
896 TopExp_Explorer expl;
897 Standard_Real f3d,l3d;
898 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
901 TopoDS_Face aFace = TopoDS::Face (expl.Current());
902 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
903 aString = aSurface->DynamicType()->Name();
905 if (aMap.IsBound(aString))
906 aMap.ChangeFind(aString)++;
908 aMap.Bind(aString, 1);
909 aSequence->Append(aString);
913 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
915 TopoDS_Face aFace = TopoDS::Face (expl.Current());
916 TopoDS_Iterator anIt(aFace);
917 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
918 TopoDS_Iterator it (aWire);
919 for (; it.More(); it.Next()) {
920 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
921 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
922 aString = aCurve2d->DynamicType()->Name();
923 if(aMap.IsBound(aString))
924 aMap.ChangeFind(aString)++;
926 aMap.Bind(aString, 1);
927 aSequence->Append(aString);
933 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
935 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
936 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
937 if(aCurve3d.IsNull())
941 aString = aCurve3d->DynamicType()->Name();
942 if (aMap.IsBound(aString))
944 aMap.ChangeFind(aString)++;
946 aMap.Bind(aString, 1);
947 aSequence->Append(aString);
954 for (Standard_Integer i = 1; i <= aSequence->Length(); i++) {
955 di << aMap.Find(aSequence->Value(i)) << " -- " << aSequence->Value(i).ToCString() << "\n";
959 di<<"Degenerated edges :\n";
960 di<<l<<" -- Degenerated edges \n";
966 #include <BRepBuilderAPI_Transform.hxx>
968 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
971 di << "Usage : " << argv[0] << "\n";
975 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
976 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
977 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
979 TopoDS_Shape sh1 = cyl.Shape();
980 DBRep::Set("sh1",sh1);
981 gp_Trsf trsf1, trsf2;
982 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
983 gp_Pnt(0.000000,700.000000,-95.000000));
984 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
985 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
986 BRepBuilderAPI_Transform trans1(sh1, trsf1);
987 TopoDS_Shape sh2 = trans1.Shape();
988 DBRep::Set("sh2",sh2);
990 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)\n";
991 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
992 TopoDS_Shape fsh1 = fuse1.Shape();
993 DBRep::Set("fsh1",fsh1);
995 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
996 TopoDS_Shape sh3 = trans2.Shape();
997 DBRep::Set("sh3",sh3);
999 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)\n";
1000 BRepAlgoAPI_Fuse fuse2(fsh1, sh3);
1001 const TopoDS_Shape& fsh2 = fuse2.Shape();
1002 DBRep::Set("fsh2",fsh2);
1004 Handle(AIS_Shape) aisp1 = new AIS_Shape(fsh2);
1008 #include <ShapeBuild_Edge.hxx>
1010 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1012 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1013 ShapeBuild_Edge().BuildCurve3d(e);
1019 #include<TDF_Label.hxx>
1020 #include<TDataStd_TreeNode.hxx>
1022 #include<DDocStd.hxx>
1026 #include<TDocStd_Modified.hxx>
1027 #include<TDF_ListIteratorOfDeltaList.hxx>
1028 #include<TDocStd_Document.hxx>
1029 #include<TDocStd_Application.hxx>
1030 #include<TDF_Delta.hxx>
1031 #include<TDataXtd_Constraint.hxx>
1032 #include<TPrsStd_AISPresentation.hxx>
1033 #include<TPrsStd_AISViewer.hxx>
1034 #include<TNaming_Builder.hxx>
1035 #include<TNaming_Naming.hxx>
1036 #include<TNaming_NamedShape.hxx>
1038 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1040 di << "Usage : " << argv[0] << " D\n";
1045 Handle(TDF_Data) DF;
1046 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1049 Handle(TDataStd_TreeNode) TN1,TN2;
1051 DDF::AddLabel(DF,"0:2",L1);
1052 TN1 = TDataStd_TreeNode::Set(L1);
1054 DDF::AddLabel(DF,"0:3",L2);
1055 TN2 = TDataStd_TreeNode::Set(L2);
1058 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1059 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1065 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1067 di << "Usage : " << argv[0] << " D\n";
1072 Handle(TDF_Data) DF;
1073 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1076 DDF::FindLabel(DF,"0:1",L,Standard_False);
1077 Handle(TDocStd_Modified) MDF;
1078 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1079 MDF = new TDocStd_Modified();
1080 L.Root().AddAttribute(MDF);
1083 di<<!MDF->IsEmpty();
1087 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1089 di << "Usage : " << argv[0] << " D Label\n";
1094 Handle(TDF_Data) DF;
1095 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1098 DDF::FindLabel(DF,argv[2],L,Standard_False);
1100 TDocStd_Modified::Add(L);
1106 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1108 di << "Usage : " << argv[0] << " D\n";
1114 Handle(TDF_Data) aDF;
1115 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1117 Handle(TDocStd_Document) aDocument;
1118 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1121 Handle(TDataStd_TreeNode) TN;
1123 aDocument->NewCommand();
1124 DDF::AddLabel(aDF,"0:2",L);
1125 TN = TDataStd_TreeNode::Set(L);
1127 aDocument->NewCommand();
1128 DDF::AddLabel(aDF,"0:3",L);
1129 TN = TDataStd_TreeNode::Set(L);
1131 aDocument->NewCommand();
1132 DDF::AddLabel(aDF,"0:4",L);
1133 TN = TDataStd_TreeNode::Set(L);
1134 aDocument->NewCommand();
1136 TDF_DeltaList Us,Rs;
1137 Us = aDocument->GetUndos();
1138 Rs = aDocument->GetUndos();
1141 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1143 TDF_ListIteratorOfDeltaList IDL;
1144 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1145 Handle(TDF_Delta) D = IDL.Value();
1146 TCollection_ExtendedString S(Names[i-1]);
1148 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1154 Us = aDocument->GetUndos();
1155 Rs = aDocument->GetRedos();
1157 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1158 Handle(TDF_Delta) D = IDL.Value();
1159 // cout<<" U"<<i<<"="<<D->Name()<<endl;
1162 TCollection_ExtendedString n2name ("n2");
1163 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1164 Handle(TDF_Delta) D = IDL.Value();
1165 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1176 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1178 di << "Usage : " << argv[0] << " D Shape\n";
1183 Handle(TDF_Data) aDF;
1184 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1186 TopoDS_Shape s = DBRep::Get(argv[2]);
1187 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
1189 DDF::AddLabel(aDF, "0:2", L);
1190 TNaming_Builder SI (L);
1193 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1197 // if (!NS->IsEmpty()) {di<<3;return 0;}
1198 if (NS->IsEmpty()) {di<<4;return 0;}
1203 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1205 di << "Usage : " << argv[0] << " D Shape\n";
1210 Handle(TDF_Data) aDF;
1211 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1213 TopoDS_Shape s = DBRep::Get(argv[2]);
1214 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
1216 DDF::AddLabel(aDF, "0:2", L);
1217 TNaming_Builder SI (L);
1220 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1224 if (NS->IsEmpty()) {di<<4;return 0;}
1229 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1231 TCollection_ExtendedString path (argv[1]);
1232 Handle(TDocStd_Application) A = DDocStd::GetApplication();
1233 Handle(TDocStd_Document) D;
1234 Standard_Integer insession = A->IsInSession(path);
1235 if (insession > 0) {
1236 di <<"document " << insession << " is already in session\n";
1240 PCDM_ReaderStatus Result = A->Open(path,D);
1241 if(Result==PCDM_RS_OK){
1250 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1252 di << "Usage : " << argv[0] << " D\n";
1257 Handle(TDF_Data) aDF;
1258 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1261 DDF::AddLabel(aDF, "0:2", L);
1263 Handle(TPrsStd_AISPresentation) AISP =
1264 TPrsStd_AISPresentation::Set(L,TDataXtd_Constraint::GetID());
1266 if (AISP->HasOwnMode()) {di<<3;return 0;}
1268 Standard_Integer Mode = AISP->Mode();
1269 if (Mode!=3) {di<<4;return 0;}
1270 if (!AISP->HasOwnMode()) {di<<5;return 0;}
1272 if (AISP->HasOwnMode()) {di<<6;return 0;}
1277 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1279 di << "Usage : " << argv[0] << " D\n";
1284 Handle(TDF_Data) aDF;
1285 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1288 DDF::AddLabel(aDF, "0:2", L);
1292 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1293 // Handle(TNaming_Name) NN = new TNaming_Name;
1296 NN.Type(TNaming_IDENTITY);
1298 Standard_Boolean Res = NN.Solve(L,LM);
1300 if (Res!=Standard_False) {di<<3;return 0;}
1305 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1307 di << "Usage : " << argv[0] << " D\n";
1313 Handle(TDocStd_Document) aDocument;
1314 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
1316 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
1317 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
1323 //=======================================================================
1324 //function : AISWidth
1325 //purpose : AISWidth (DOC,entry,[width])
1326 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
1327 //=======================================================================
1329 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1332 Handle(TDocStd_Document) D;
1333 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
1335 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
1337 Handle(TPrsStd_AISViewer) viewer;
1338 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
1340 Handle(TPrsStd_AISPresentation) prs;
1341 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1343 prs->SetWidth(Draw::Atof(argv[3]));
1344 TPrsStd_AISViewer::Update(L);
1347 if (prs->HasOwnWidth()){
1348 // cout << "Width = " << prs->Width() << endl;
1352 di << "AISWidth: Warning : Width wasn't set\n";
1359 di << "AISWidth : Error" << "\n";
1364 //=======================================================================
1365 //function : BUC60921 ( & BUC60954 )
1366 //purpose : Test memory allocation of OCAF in Undo/Redo operations
1367 //=======================================================================
1369 static Standard_Integer BUC60921 (Draw_Interpretor& di,
1370 Standard_Integer nb,
1374 Handle(TDocStd_Document) D;
1375 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
1377 DDF::AddLabel(D->GetData(),arg[2],L);
1381 BRepTools::Read ( S, arg[3], B );
1383 TNaming_Builder tnBuild(L);
1384 tnBuild.Generated(S);
1385 // di << "File " << arg[3] << " added";
1389 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
1394 #include<IGESControl_Reader.hxx>
1395 #include<BRepPrimAPI_MakeHalfSpace.hxx>
1397 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
1400 di << "Usage : " << a[0] << " file.igs\n";
1404 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
1406 if(myContext.IsNull()) {
1407 di << "use 'vinit' command before " << a[0] << "\n";
1411 // IGESControlStd_Reader reader;
1412 IGESControl_Reader reader;
1413 reader.ReadFile(a[1]);
1414 reader.TransferRoots();
1415 TopoDS_Shape shape = reader.OneShape();
1416 printf("\n iges1 shape type = %d", shape.ShapeType() );
1417 TopTools_IndexedMapOfShape list;
1418 TopExp::MapShapes(shape, TopAbs_FACE, list);
1419 printf("\n No. of faces = %d", list.Extent());
1422 BRep_Builder builder;
1423 builder.MakeShell(shell);
1424 for(int i=1;i<=list.Extent(); i++) {
1425 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
1426 builder.Add(shell, face);
1428 shell.Closed (BRep_Tool::IsClosed (shell));
1430 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
1431 TopoDS_Solid sol = half.Solid();
1432 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
1433 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
1434 TopoDS_Shape sh = cyl.Shape();
1436 di << "BRepAlgoAPI_Fuse fuse(sol, sh)\n";
1437 BRepAlgoAPI_Fuse fuse(sol, sh);
1440 Handle(AIS_Shape) res = new AIS_Shape(sh);
1441 myContext->Display (res, Standard_True);
1445 void QABugs::Commands_3(Draw_Interpretor& theCommands) {
1446 const char *group = "QABugs";
1448 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
1449 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
1450 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
1451 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
1452 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
1453 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
1455 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
1456 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
1458 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
1459 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
1460 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
1461 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
1462 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
1464 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
1466 theCommands.Add("OCC10006","OCC10006",__FILE__,OCC10006,group);
1468 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
1470 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
1472 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
1473 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
1474 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
1475 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
1477 theCommands.Add("TestCMD","TestCMD",__FILE__,TestCMD,group);
1479 theCommands.Add("statface","statface face",__FILE__,statface,group);
1481 theCommands.Add("BUC60841","BUC60841",__FILE__,BUC60841,group);
1483 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
1485 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
1486 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
1487 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
1488 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
1489 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
1490 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
1491 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
1492 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
1493 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
1494 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
1495 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
1496 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
1498 theCommands.Add("BUC60951","BUC60951 file.igs",__FILE__,BUC60951_, group );