0031007: Coding - eliminate warnings issued while compiling with -pedantic flag
[occt.git] / src / QABugs / QABugs_16.cxx
1 // Created on: 2002-03-18
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <QABugs.hxx>
17
18 #include <Draw.hxx>
19 #include <Draw_Interpretor.hxx>
20 #include <DBRep.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <AIS_InteractiveContext.hxx>
23 #include <ViewerTest.hxx>
24 #include <AIS_Shape.hxx>
25 #include <TopoDS_Shape.hxx>
26
27 #include <GProp_GProps.hxx>
28 #include <BRepGProp.hxx>
29 #include <TopoDS_Edge.hxx>
30 #include <BRepBuilderAPI_MakeEdge.hxx>
31 #include <AIS_Trihedron.hxx>
32 #include <Geom_Axis2Placement.hxx>
33 #include <gp_Ax2.hxx>
34 #include <Geom_Circle.hxx>
35 #include <AIS_Circle.hxx>
36 #include <TopoDS.hxx>
37 #include <Geom_Plane.hxx>
38 #include <gp_Pln.hxx>
39 #include <AIS_AngleDimension.hxx>
40
41 #include <Aspect_Window.hxx>
42 #include <V3d_View.hxx>
43
44 #include <TopExp_Explorer.hxx>
45 #include <BRepAdaptor_Curve.hxx>
46 #include <GC_MakePlane.hxx>
47 #include <AIS_PlaneTrihedron.hxx>
48 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
49
50 #include <BRep_Tool.hxx>
51 #include <Geom_BSplineCurve.hxx>
52 #include <GeomConvert_CompCurveToBSplineCurve.hxx>
53 #include <BRepBuilderAPI_MakeEdge.hxx>
54 #include <Precision.hxx>
55
56 #include <GProp_PrincipalProps.hxx>
57
58 #include <OSD_Path.hxx>
59 #include <Standard_ProgramError.hxx>
60
61 #include <ShapeFix_Wireframe.hxx>
62 #include <ShapeBuild_ReShape.hxx>
63
64 #include <BRepBuilderAPI_MakeEdge.hxx>
65
66 #include <ViewerTest_EventManager.hxx>
67
68 #include <TColgp_Array1OfPnt2d.hxx>
69
70 #include <DDocStd.hxx>
71 #include <TDocStd_Document.hxx>
72 #include <Standard_ErrorHandler.hxx>
73
74 #if ! defined(_WIN32)
75 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
76 #else
77 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
78 #endif
79
80 static Standard_Integer BUC60848 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
81 {
82   if ( argc != 2 ) {
83     di << "Usage : " << argv[0] << " shape \n";
84     return 1;
85   }
86   TopoDS_Shape S = DBRep::Get( argv[1] );
87   if ( S.IsNull() ) {
88     di << "Shape is empty\n";
89     return 1;
90   }
91   GProp_GProps G;
92   BRepGProp::VolumeProperties( S,G );
93   Standard_Real GRes;
94   GRes = G.Mass();
95   if ( GRes < 0 ) {
96     di << "Result is negative : " << GRes << "\n";
97     return 1;
98   } else {
99     di << "Volume : " << GRes << "\n";
100   }
101
102   return 0;
103 }
104
105 static Standard_Integer BUC60828 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
106 {
107   TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(0.,0.,1.)); 
108   Standard_Boolean aValue; 
109   aValue=anEdge.Infinite(); 
110   di << "Initial flag : " << (Standard_Integer) aValue << "\n";
111   anEdge.Infinite(Standard_True); 
112   Standard_Boolean aValue1; 
113   aValue1=anEdge.Infinite(); 
114   di << "Current flag : " << (Standard_Integer) aValue1 << "\n";
115   if(aValue1) di << "Flag was set properly.\n";
116   else di << "Faulty : flag was not set properly.\n";
117   return 0;
118 }
119
120 static Standard_Integer  BUC60814(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
121 {
122   if(argc!=1)
123   {
124     di << "Usage : " << argv[0] << "\n";
125     return 1;
126   }
127
128
129   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
130   if(myAISContext.IsNull()) {
131     di << "use 'vinit' command before " << argv[0] << "\n";
132     return 1;
133   }
134   
135   // TRIHEDRON
136   Handle(AIS_InteractiveObject) aTrihedron;
137   Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
138   aTrihedron=new AIS_Trihedron(aTrihedronAxis);
139   myAISContext->Display (aTrihedron, Standard_False);
140   
141   //Circle
142   gp_Pnt P(10,10,10);
143   gp_Dir V(1,0,0);
144   gp_Ax2 aAx2(P,V);
145   
146   Handle(Geom_Circle) ahCircle=new Geom_Circle(aAx2,20);
147   Handle(AIS_InteractiveObject)   aCircle=new AIS_Circle(ahCircle);
148   myAISContext->Display (aCircle, Standard_False);
149     
150   const Handle(Prs3d_Drawer)& aSelStyle = myAISContext->SelectionStyle();
151   aSelStyle->SetColor (Quantity_NOC_BLUE1);
152   
153   myAISContext->AddOrRemoveSelected (aTrihedron, Standard_False);
154   myAISContext->AddOrRemoveSelected (aCircle, Standard_True);
155   
156   return 0;
157 }
158
159 //=======================================================================
160 //function : BUC60774
161 //purpose  : 
162 //=======================================================================
163 static Standard_Integer BUC60774 (Draw_Interpretor& theDi,
164                                   Standard_Integer theArgNb,
165                                   const char** theArgv)
166 {
167   if (theArgNb != 1)
168   {
169     std::cout << "Usage : " << theArgv[0] << "\n";
170     return -1;
171   }
172
173   const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
174   if (anAISContext.IsNull())
175   {
176     std::cout << "use 'vinit' command before " << theArgv[0] << "\n";
177     return -1;
178   }
179
180   const Handle(V3d_View)& aV3dView = ViewerTest::CurrentView();
181
182   Standard_Integer aWinWidth  = 0;
183   Standard_Integer aWinHeight = 0;
184   aV3dView->Window()->Size (aWinWidth, aWinHeight);
185
186   Standard_Integer aXPixMin = 0;
187   Standard_Integer aYPixMin = 0;
188   Standard_Integer aXPixMax = aWinWidth;
189   Standard_Integer aYPixMax = aWinHeight;
190
191   AIS_StatusOfPick aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView, Standard_False);
192   theDi << (aPickStatus == AIS_SOP_NothingSelected
193     ? "status = AIS_SOP_NothingSelected : OK"
194     : "status = AIS_SOP_NothingSelected : bugged - Faulty ");
195   theDi << "\n";
196
197   theDi.Eval ("box b 10 10 10");
198   theDi.Eval (" vdisplay b");
199
200   aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView, Standard_False);
201   theDi << (aPickStatus == AIS_SOP_OneSelected
202     ? "status = AIS_SOP_OneSelected : OK"
203     : "status = AIS_SOP_OneSelected : bugged - Faulty ");
204   theDi << "\n";
205
206   theDi.Eval ("box w 20 20 20 20 20 20");
207   theDi.Eval (" vdisplay w");
208
209   aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView, Standard_True);
210   theDi << (aPickStatus == AIS_SOP_SeveralSelected
211     ? "status = AIS_SOP_SeveralSelected : OK"
212     : "status = AIS_SOP_SeveralSelected : bugged - Faulty ");
213   theDi << "\n";
214
215   return 0;
216 }
217
218 static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
219 {
220   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
221   if(aContext.IsNull()) { 
222     di << "use 'vinit' command before " << argv[0] << "\n";
223     return 1;
224   }
225
226   if(argc != 6) {
227     di << "Usage : " << argv[0] << " edge edge plane val text\n";
228     return 1;
229   }
230   
231   TopoDS_Edge aFirst = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
232   TopoDS_Edge aSecond = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
233   Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[3]));
234   if(aPlane.IsNull())
235     return 1;
236   
237   di << aPlane->Pln().SquareDistance( gp_Pnt(0,0,0) ) << "\n";
238   
239   TCollection_ExtendedString aText(argv[5]);
240   //Standard_ExtString ExtString_aText = aText.ToExtString();
241   //di << ExtString_aText << " " << Draw::Atof(argv[4]) << "\n";
242   di << argv[5] << " " << Draw::Atof(argv[4]) << "\n";
243   
244   Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond);
245   aContext->Display (aDim, Standard_True);
246   
247   return 0;
248 }
249
250 static Standard_Integer OCC218bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
251 {
252   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
253   if(aContext.IsNull()) { 
254     di << "use 'vinit' command before " << argv[0] << "\n";
255     return 1;
256   }
257
258   if(argc != 5) {
259     di << "Usage : " << argv[0] << " name plane Xlabel Ylabel\n";
260     return 1;
261   }
262
263   TopoDS_Shape S = DBRep::Get( argv[2] );
264   if ( S.IsNull() ) {
265     di << "Shape is empty\n";
266     return 1;
267   }
268
269   TCollection_AsciiString name(argv[1]);
270   TCollection_AsciiString Xlabel(argv[3]);
271   TCollection_AsciiString Ylabel(argv[4]);
272   
273   // Construction de l'AIS_PlaneTrihedron
274   Handle(AIS_PlaneTrihedron) theAISPlaneTri;
275
276   Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
277   if (IsBound) {
278     // on recupere la shape dans la map des objets displayes
279     Handle(AIS_InteractiveObject) aShape = GetMapOfAIS().Find2(name);
280       
281     // On verifie que l'AIS InteraciveObject est bien 
282     // un AIS_PlaneTrihedron
283     if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==4) {
284       // On downcast aShape de AIS_InteractiveObject a AIS_PlaneTrihedron
285       theAISPlaneTri = Handle(AIS_PlaneTrihedron)::DownCast (aShape);
286
287       theAISPlaneTri->SetXLabel(Xlabel);
288       theAISPlaneTri->SetYLabel(Ylabel);
289   
290       aContext->Redisplay(theAISPlaneTri, Standard_False);
291       aContext->UpdateCurrentViewer();
292     }
293   } else {
294     TopoDS_Face  FaceB=TopoDS::Face(S);
295   
296     // Construction du Plane
297     // recuperation des edges des faces.
298     TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
299   
300     TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
301     // declarations 
302     gp_Pnt A,B,C;
303   
304     // si il y a plusieurs edges
305     if (FaceExpB.More() ) {
306       FaceExpB.Next();
307       TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() );
308       BRepAdaptor_Curve theCurveB(EdgeB);
309       BRepAdaptor_Curve theCurveC(EdgeC);
310       A=theCurveC.Value(0.1);
311       B=theCurveC.Value(0.9);
312       C=theCurveB.Value(0.5);
313     }
314     else {
315       // FaceB a 1 unique edge courbe
316       BRepAdaptor_Curve theCurveB(EdgeB);
317       A=theCurveB.Value(0.1);
318       B=theCurveB.Value(0.9);
319       C=theCurveB.Value(0.5);
320     }
321     // Construction du Geom_Plane
322     GC_MakePlane MkPlane(A,B,C);
323     Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
324     
325     // on le display & bind
326     theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
327     
328     theAISPlaneTri->SetXLabel(Xlabel);
329     theAISPlaneTri->SetYLabel(Ylabel);
330     
331     GetMapOfAIS().Bind ( theAISPlaneTri, name);
332     aContext->Display (theAISPlaneTri, Standard_True);
333   }
334   return 0;
335 }
336
337 static Standard_Integer OCC295(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
338 {
339   if(argc != 4) {
340     di << "Usage : " << argv[0] << " edge_result edge1 edge2\n";
341     return 1;
342   }
343   
344   TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
345   TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
346   if(Sh1.IsNull() || Sh2.IsNull()) return 1;
347   if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
348   TopoDS_Edge e1 = TopoDS::Edge(Sh1);
349   TopoDS_Edge e2 = TopoDS::Edge(Sh2);
350   Standard_Real f1,l1,f2,l2;
351   Standard_Boolean After =  Standard_True;
352   Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
353   Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
354   Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
355   Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
356   if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
357   gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
358   bsplc1->SetPole(bsplc1->NbPoles(), pmid);
359   bsplc2->SetPole(1, pmid);
360   GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
361   if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
362   BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
363   if(MkEdge.IsDone()) {
364     TopoDS_Edge nedge = MkEdge.Edge();
365     DBRep::Set ( argv[1], nedge );
366     return 0;
367   }
368   else return 1;
369 }
370
371 static Standard_Integer OCC49 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
372 {
373
374   if ( argc != 2 ) {
375     di << "Usage : " << argv[0] << " name\n";
376     return 1;
377   }
378
379   TopoDS_Shape S = DBRep::Get(argv[1]);
380   if (S.IsNull()) return 0;
381
382   GProp_GProps G;
383   BRepGProp::VolumeProperties(S,G);
384   GProp_PrincipalProps Pr = G.PrincipalProperties();
385   Standard_Boolean Result = Pr.HasSymmetryAxis();
386   if (Result) {
387     di << "1\n";
388   } else {
389     di << "0\n";
390   }
391   return 0;
392 }
393
394 static Standard_Integer OCC132 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
395 {
396   /*
397      OCC132:
398      =======
399
400      ... the validation of the name of files in Analyse_DOS and Analyse_UNIX is : 
401
402      characters not allowed in DOS/WNT names are 
403      / 
404      : 
405      * 
406      ? 
407      " 
408      < 
409      > 
410      | 
411      and  more than one dot in filename.
412      */
413
414   if ( argc != 2 ) {
415     di << "Usage : " << argv[0] << " DependentName\n";
416     return 1;
417   }
418
419   OSD_SysType SysType1 = OSD_OS2;
420   OSD_SysType SysType2 = OSD_WindowsNT;
421
422   {
423     try {
424       OCC_CATCH_SIGNALS
425       OSD_Path Path (argv[1], SysType1);
426     }
427     catch (Standard_ProgramError const&) {
428       di << "1\n";
429       return 0;
430     }
431   }
432
433   {
434     try {
435       OCC_CATCH_SIGNALS
436       OSD_Path Path (argv[1], SysType2);
437     }
438     catch (Standard_ProgramError const&) {
439       di << "2\n";
440       return 0;
441     }
442   }
443   
444   di << "0\n";
445   return 0;
446 }
447
448 static Standard_Integer OCC405 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
449 {
450   if(argc != 4) {
451     di << "Usage : " << argv[0] << " edge_result edge1 edge2; merge two edges\n";
452     return 1;
453   }
454   
455   TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
456   TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
457   if(Sh1.IsNull() || Sh2.IsNull()) return 1;
458   if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
459   TopoDS_Edge e1 = TopoDS::Edge(Sh1);
460   TopoDS_Edge e2 = TopoDS::Edge(Sh2);
461   Standard_Real f1,l1,f2,l2;
462   Standard_Boolean After =  Standard_True;
463   Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
464   Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
465   if(e1.Orientation() == TopAbs_REVERSED) {
466     Standard_Real cf = f1;
467       f1 = ac1->ReversedParameter ( l1 );
468       l1 = ac1->ReversedParameter ( cf );
469       ac1 = ac1->Reversed();
470     }
471     if(e2.Orientation() == TopAbs_REVERSED) {
472       Standard_Real cf = f2;
473       f2 = ac2->ReversedParameter ( l2 );
474       l2 = ac2->ReversedParameter ( cf );
475       ac2 = ac2->Reversed();
476     }
477   Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
478   Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
479   if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
480   if(bsplc1->FirstParameter() < f1 - Precision::PConfusion() || 
481      bsplc1->LastParameter() > l1 + Precision::PConfusion()) {
482     Handle(Geom_BSplineCurve) aBstmp  = Handle(Geom_BSplineCurve)::DownCast(bsplc1->Copy());
483     aBstmp->Segment(f1,l1);
484     bsplc1 =aBstmp; 
485   }
486   if(bsplc2->FirstParameter() < f2 - Precision::PConfusion() || 
487      bsplc2->LastParameter() > l2 + Precision::PConfusion()) {
488     Handle(Geom_BSplineCurve) aBstmp  = Handle(Geom_BSplineCurve)::DownCast(bsplc2->Copy());
489     aBstmp->Segment(f2,l2);
490     bsplc2 =aBstmp; 
491   }
492   gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
493   bsplc1->SetPole(bsplc1->NbPoles(), pmid);
494   bsplc2->SetPole(1, pmid);
495   GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
496   if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
497   BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
498   if(MkEdge.IsDone()) {
499     TopoDS_Edge nedge = MkEdge.Edge();
500     DBRep::Set ( argv[1], nedge );
501     return 0;
502   }
503   else return 1;
504 }
505
506 static Standard_Integer OCC395 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
507 {
508   if(argc != 4) {
509     di << "Usage : " << argv[0] << " edge_result edge1 edge2\n";
510     return 1;
511   }
512   //TCollection_AsciiString fnom(a[1]);
513   //Standard_Boolean modfic = XSDRAW::FileAndVar(a[1],a[2],a[3],"IGES",fnom,rnom,resnom);
514   TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
515   TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
516   if(Sh1.IsNull() || Sh2.IsNull()) return 1;
517   if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
518   TopoDS_Edge e1 = TopoDS::Edge(Sh1);
519   TopoDS_Edge e2 = TopoDS::Edge(Sh2);
520   Standard_Real f1,l1,f2,l2;
521   Standard_Boolean After =  Standard_True;
522   Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
523   Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
524   if(e1.Orientation() == TopAbs_REVERSED) {
525       //Standard_Real cf = cf1;
526       //cf1 = ac1->ReversedParameter ( cl1 );
527       //cl1 = ac1->ReversedParameter ( cf );
528       ac1 = ac1->Reversed();
529     }
530     if(e2.Orientation() == TopAbs_REVERSED) {
531       //Standard_Real cf = cf2;
532       //ac2 = ac2->ReversedParameter ( cl2 );
533       //ac2 = ac2->ReversedParameter ( cf );
534       ac2 = ac2->Reversed();
535     }
536   Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
537   Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
538   if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
539   gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
540   bsplc1->SetPole(bsplc1->NbPoles(), pmid);
541   bsplc2->SetPole(1, pmid);
542   GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
543   if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
544   BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
545   if(MkEdge.IsDone()) {
546     TopoDS_Edge nedge = MkEdge.Edge();
547     DBRep::Set ( argv[1], nedge );
548     return 0;
549   }
550   else return 1;
551 }
552
553 static Standard_Integer OCC394 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
554 {
555   if(argc < 3) {
556     di << "Usage : " << argv[0] << " edge_result edge [tol [mode [tolang]]]\n";
557     return 1;
558   }
559    TopoDS_Shape Sh = DBRep::Get(argv[2]);
560  
561    Standard_Integer k = 3;
562    Standard_Real tol = 100000;
563    Standard_Integer mode = 2;
564    Standard_Real tolang = M_PI/2;
565    if(argc > k) 
566      tol = Draw::Atof(argv[k++]);
567    
568    if(argc > k) 
569      mode=  Draw::Atoi(argv[k++]);
570    
571    if(argc > k) 
572      tolang = Draw::Atof(argv[k++]);
573      
574    
575    Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe();
576    Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape;
577    aSfwr->SetContext(aReShape);
578    aSfwr->Load(Sh);
579    aSfwr->SetPrecision(tol);
580    Standard_Boolean aModeDrop = Standard_True;
581    if(mode == 2) 
582      aModeDrop = Standard_False;
583    
584     TopTools_MapOfShape theSmallEdges, theMultyEdges;
585   TopTools_DataMapOfShapeListOfShape theEdgeToFaces,theFaceWithSmall;
586   aSfwr->CheckSmallEdges(theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges);
587   aSfwr->MergeSmallEdges (theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges, aModeDrop,tolang);
588    //aSfwr->FixSmallEdges(); 
589   TopoDS_Shape resShape = aSfwr->Shape();
590   DBRep::Set ( argv[1], resShape );
591   return 0;
592 }
593
594 static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
595 {
596   Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
597   if(context.IsNull()) {
598     di << "use 'vinit' command before " << argv[0] << "\n";
599     return 1;
600   }
601   if ( argc != 3 ) {
602     di << "Usage : " << argv[0] << " ArcRadius ArrowSize\n";
603     return 1;
604   }
605
606   Standard_Real aRadius = Draw::Atof(argv[1]);
607   Standard_Real anArrowSize = Draw::Atof(argv[2]);
608
609   gp_Pnt p1 = gp_Pnt(10.,10.,0.);
610   gp_Pnt p2 = gp_Pnt(50.,10.,0.);
611   gp_Pnt p3 = gp_Pnt(50.,50.,0.);
612
613   TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(p1, p2);
614   TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(p2, p3);
615
616   context->Display (new AIS_Shape(E1), Standard_False);
617   context->Display (new AIS_Shape(E2), Standard_True);
618
619   gp_Pnt plnpt(0, 0, 0);
620   gp_Dir plndir(0, 0, 1);
621   Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
622
623   Handle(AIS_AngleDimension) anAngleDimension = new AIS_AngleDimension (p1.Mirrored (p2), p2, p3);
624
625   Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
626   anAspect->MakeArrows3d (Standard_True);
627   anAspect->ArrowAspect()->SetLength (anArrowSize);
628   anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right);
629   anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW);
630   anAngleDimension->SetDimensionAspect (anAspect);
631   // Another position of dimension
632   anAngleDimension->SetFlyout (aRadius);
633   context->Display (anAngleDimension, 0);
634   return 0;
635 }
636
637 static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
638 {
639   if(argc != 2) {
640     di << "Usage : " << argv[0] << " Doc\n";
641     return 1;
642   }
643
644   Handle(TDocStd_Document) Doc;
645   if(DDocStd::GetDocument(argv[1], Doc)) {
646     Doc->ClearRedos();
647     return 0;
648   } else
649     return 1;
650 }
651
652 #include <OSD_File.hxx>
653 static Standard_Integer OCC710 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
654 {
655   if(argc != 2) {
656     di << "Usage : " << argv[0] << " path\n";
657   }
658
659   TCollection_AsciiString in(argv[1]);
660   OSD_File* aFile = new OSD_File(in);
661   Standard_Boolean anExists = aFile->Exists();
662   if(anExists == Standard_True) 
663     di << "1\n";
664   else
665     di << "0\n";
666   return 0;
667 }
668
669 #include <ShapeFix_Shell.hxx>
670 #include <AIS_InteractiveObject.hxx>
671 static Standard_Integer OCC904 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
672 {
673   if(argc != 4) {
674     di << "Usage : " << argv[0] << " result shape nonmanifoldmode(0/1)\n";
675   }
676   TopoDS_Shape S = DBRep::Get(argv[2]);
677   if (S.IsNull() || S.ShapeType() != TopAbs_SHELL) {
678     di << " Shape is null\n";
679     return 1;
680   }
681   Standard_Boolean nonmanifmode = (Draw::Atoi(argv[3]) != 0);
682   Handle(ShapeFix_Shell) SFSh = new ShapeFix_Shell;
683   SFSh->FixFaceOrientation(TopoDS::Shell(S),Standard_True,nonmanifmode);
684   DBRep::Set(argv[1],SFSh->Shape());
685   return 0;
686 }
687
688 void QABugs::Commands_16(Draw_Interpretor& theCommands) {
689   const char *group = "QABugs";
690
691   theCommands.Add ("BUC60848", "BUC60848 shape", __FILE__, BUC60848, group);
692   theCommands.Add ("BUC60828", "BUC60828", __FILE__, BUC60828, group);
693   theCommands.Add ("BUC60814", "BUC60814", __FILE__, BUC60814, group);
694   theCommands.Add ("BUC60774", "BUC60774", __FILE__, BUC60774, group);
695   theCommands.Add ("BUC60972", "BUC60972 edge edge plane val text ", __FILE__, BUC60972, group);
696   theCommands.Add ("OCC218", "OCC218 name plane Xlabel Ylabel", __FILE__, OCC218bug, group);
697   theCommands.Add ("OCC295", "OCC295 edge_result edge1 edge2", __FILE__, OCC295, group);
698   theCommands.Add ("OCC49", "OCC49 name", __FILE__, OCC49, group);
699   theCommands.Add ("OCC132", "OCC132 DependentName", __FILE__, OCC132, group);
700   theCommands.Add ("OCC405", "OCC405 edge_result edge1 edge2; merge two edges", __FILE__, OCC405, group);
701   theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group);
702   theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group);
703   theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group);
704   theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group);
705   theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group);
706   theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group);
707
708   return;
709 }