1 // Created on: 2002-03-20
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 <stdio.h>
17 
18 #include <QABugs.hxx>
19 
20 #include <Draw.hxx>
21 #include <Draw_Interpretor.hxx>
22 #include <DBRep.hxx>
23 #include <DrawTrSurf.hxx>
24 #include <AIS_InteractiveContext.hxx>
25 #include <ViewerTest.hxx>
26 #include <AIS_Shape.hxx>
27 #include <TopoDS_Shape.hxx>
28 
29 #include <Geom_Surface.hxx>
30 #include <Geom_Axis2Placement.hxx>
31 #include <gp.hxx>
32 #include <gp_Trsf.hxx>
33 #include <AIS_Trihedron.hxx>
34 #include <BRepPrimAPI_MakeBox.hxx>
35 #include <Graphic3d_MaterialAspect.hxx>
36 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
37 #include <TopoDS_Solid.hxx>
38 #include <BRepPrimAPI_MakeSphere.hxx>
39 #include <BRepPrimAPI_MakeCone.hxx>
40 #include <BRepPrimAPI_MakeCylinder.hxx>
41 #include <IGESToBRep_Reader.hxx>
42 #include <TopExp_Explorer.hxx>
43 #include <TopoDS.hxx>
44 #include <GCPnts_UniformDeflection.hxx>
45 #include <BRepAdaptor_Curve.hxx>
46 #include <IGESToBRep.hxx>
47 #include <V3d_Viewer.hxx>
48 #include <BRepAdaptor_CompCurve.hxx>
49 #include <GCPnts_AbscissaPoint.hxx>
50 #include <Standard_ErrorHandler.hxx>
51 #include <Standard_Overflow.hxx>
52 #include <Standard_Underflow.hxx>
53 #include <Standard_DivideByZero.hxx>
54 #include <OSD_SIGSEGV.hxx>
55 #include <OSD_Exception_ACCESS_VIOLATION.hxx>
56 #include <OSD_Exception_STACK_OVERFLOW.hxx>
57 #include <OSD.hxx>
58 #include <OSD_Timer.hxx>
59 #include <OSD_ThreadPool.hxx>
60 #include <OSD_Parallel.hxx>
61 #include <STEPCAFControl_Writer.hxx>
62 #include <STEPControl_StepModelType.hxx>
63 #include <Interface_Static.hxx>
64 #include <IFSelect_ReturnStatus.hxx>
65 #include <Standard_Failure.hxx>
66 #include <TColgp_HArray1OfPnt2d.hxx>
67 #include <Geom2dAPI_Interpolate.hxx>
68 #include <Geom2d_BSplineCurve.hxx>
69 #include <Geom2dConvert_BSplineCurveToBezierCurve.hxx>
70 #include <Geom2d_BezierCurve.hxx>
71 #include <BRep_Tool.hxx>
72 #include <GeomProjLib.hxx>
73 #include <Geom2dAPI_InterCurveCurve.hxx>
74 #include <IntRes2d_IntersectionSegment.hxx>
75 #include <TDataStd_RealArray.hxx>
76 #include <TDF_CopyLabel.hxx>
77 #include <NCollection_Vector.hxx>
78 #include <TColStd_Array1OfInteger.hxx>
79 #include <Geom_BSplineCurve.hxx>
80 #include <TColgp_Array1OfPnt.hxx>
81 #include <AIS_ColorScale.hxx>
82 #include <AIS_ListOfInteractive.hxx>
83 #include <AIS_ListIteratorOfListOfInteractive.hxx>
84 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
85 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
86 #include <BRepBuilderAPI_MakePolygon.hxx>
87 #include <gp_GTrsf.hxx>
88 #include <Poly_Triangulation.hxx>
89 #include <IGESControl_Reader.hxx>
90 #include <IGESData_IGESModel.hxx>
91 #include <IGESData_IGESEntity.hxx>
92 #include <V3d_View.hxx>
93 #include <BRepFeat_SplitShape.hxx>
94 #include <BRepAlgoAPI_Section.hxx>
95 #include <TColStd_PackedMapOfInteger.hxx>
96 #include <Message.hxx>
97 #include <Draw_Printer.hxx>
98 
99 #if ! defined(_WIN32)
100 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
101 #else
102 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
103 #endif
104 
OCC128(Draw_Interpretor & di,Standard_Integer,const char ** argv)105 static Standard_Integer  OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
106 {
107   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
108   if(myAISContext.IsNull()) {
109     di << "use 'vinit' command before " << argv[0] ;
110     return 1;
111   }
112 
113   Handle(Geom_Axis2Placement) aTrihedronAxis = new Geom_Axis2Placement(gp::XOY());
114 
115   gp_Trsf trsf1;
116   trsf1.SetTranslation(gp_Vec(100, 100, 0));
117   aTrihedronAxis->Transform(trsf1);
118   Handle(AIS_Trihedron) myTrihedron = new AIS_Trihedron(aTrihedronAxis);
119   myTrihedron->SetColor(Quantity_NOC_LIGHTSTEELBLUE4);
120   myTrihedron->SetSize(100);
121   myAISContext->Display(myTrihedron, Standard_True);
122 
123 //  TopoDS_Shape shape1 = (TopoDS_Shape) BRepPrimAPI_MakeBox(50,50,50);
124   TopoDS_Shape shape1 = BRepPrimAPI_MakeBox(50,50,50).Shape();
125   Handle(AIS_Shape) AS = new AIS_Shape(shape1);
126   AS->SetDisplayMode(1);
127   Graphic3d_MaterialAspect mat (Graphic3d_NameOfMaterial_Plastified);
128   AS->SetMaterial(mat);
129   AS->SetColor(Quantity_NOC_RED);
130   myAISContext->Display (AS, Standard_False);
131 
132   gp_Trsf TouchTrsf;
133   TouchTrsf.SetTranslation(gp_Vec(20, 20, 0));
134 
135   myAISContext->ResetLocation(AS);
136   myAISContext->SetLocation(AS , TouchTrsf) ;
137   myAISContext->Redisplay(AS, Standard_True);
138 
139  return 0;
140 }
141 
OCC136(Draw_Interpretor & di,Standard_Integer argc,const char **)142 static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
143 {
144   if(argc > 1){
145     di<<"Usage: OCC136\n";
146     return 1;
147   }
148 
149   //create some primitives:
150   // Two basic points:
151   Standard_Real Size=100;
152   gp_Pnt P0(0,0,0), P1(Size,Size,Size);
153   //box
154   TopoDS_Solid aBox = BRepPrimAPI_MakeBox(P0,P1);
155   //sphere
156   TopoDS_Solid aSphere = BRepPrimAPI_MakeSphere (Size*0.5);
157   //cone
158   gp_Ax2 anAx2(P1, gp_Dir(1,1,1));
159   TopoDS_Solid aCone = BRepPrimAPI_MakeCone(anAx2, Size*0.7, Size*0.3, Size);
160   //cylinder
161   anAx2.SetLocation(gp_Pnt(Size,0,0));
162   anAx2.SetDirection(gp_Dir(-1,-1,1));
163   TopoDS_Solid aCyl = BRepPrimAPI_MakeCylinder(anAx2, Size*0.5, Size);
164 
165   Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
166   if(anAISCtx.IsNull()){
167     di<<"Null interactive context. Use 'vinit' at first.\n";
168     return 1;
169   }
170 
171   anAISCtx->EraseAll (Standard_False);
172 
173   //load primitives to context
174   Handle(AIS_InteractiveObject) aSh1 = new AIS_Shape(aBox);
175   anAISCtx->Display (aSh1, Standard_False);
176 
177   Handle(AIS_InteractiveObject) aSh2 = new AIS_Shape(aSphere);
178   anAISCtx->Display (aSh2, Standard_False);
179 
180   Handle(AIS_InteractiveObject) aSh3 = new AIS_Shape(aCone);
181   anAISCtx->Display (aSh3, Standard_False);
182 
183   Handle(AIS_InteractiveObject) aSh4 = new AIS_Shape(aCyl);
184   anAISCtx->Display (aSh4, Standard_False);
185 
186   //set selected
187   anAISCtx->InitSelected();
188   anAISCtx->AddOrRemoveSelected (aSh1, Standard_False);
189   anAISCtx->AddOrRemoveSelected (aSh2, Standard_False);
190   anAISCtx->AddOrRemoveSelected (aSh3, Standard_False);
191   anAISCtx->AddOrRemoveSelected (aSh4, Standard_False);
192 
193   //remove all this objects from context
194   anAISCtx->Remove (aSh1, Standard_False);
195   anAISCtx->Remove (aSh2, Standard_False);
196   anAISCtx->Remove (aSh3, Standard_False);
197   anAISCtx->Remove (aSh4, Standard_False);
198 
199   anAISCtx->UpdateCurrentViewer();
200   return 0;
201 }
202 
BUC60610(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)203 static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
204   if(argc < 2){
205     printf("Usage: %s  iges_input [name]\n",argv[0]);
206     return(1);
207   }
208   Standard_Character *Ch = NULL;
209 
210   if(argc > 2) {
211     Ch = new Standard_Character[strlen(argv[2])+3];
212   }
213   IGESToBRep_Reader IR;
214   IR.LoadFile (argv[1]);
215   IR.Clear();
216   IR.TransferRoots();
217   TopoDS_Shape aTopShape = IR.OneShape();
218   TopExp_Explorer ex(aTopShape, TopAbs_EDGE);
219   Standard_Integer i=0;
220   for( ; ex.More(); ex.Next()){
221     const TopoDS_Edge &E = TopoDS::Edge(ex.Current());
222     BRepAdaptor_Curve aCurve(E);
223     GCPnts_UniformDeflection plin(aCurve, 0.1);
224     di << "Num points = " << plin.NbPoints() << "\n";
225     if(argc > 2) {
226       i++;
227       Sprintf(Ch,"%s_%i",argv[2],1);
228       DBRep::Set(Ch,E);
229     }
230   }
231   return (1);
232 }
233 
234 //====================================================
235 //
236 // Following code is inserted from
237 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
238 // ( 75455 Apr 16 18:59)
239 //
240 //====================================================
241 
242 //OCC105
243 #include <BRepTools_WireExplorer.hxx>
244 #include <BRep_Tool.hxx>
245 #include <GCPnts_UniformAbscissa.hxx>
246 #include <TopExp.hxx>
247 
248 //
249 // usage : OCC105 shape
250 //
251 // comments:
252 //GCPnts_UniformAbscissa returns bad end point foe first edge. Its value is
253 
254 //Value Pnt = -338.556216693211 -394.465571897208 0
255 //should be
256 //Value Pnt = -307.47165394 -340.18073533 0
257 
OCC105(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)258 static int OCC105(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
259 {
260   if (argc != 2){
261     di<<"Usage : OCC105 shape\n";
262     return 1;
263   }
264 //  TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get("aa.brep"));
265   TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1]));
266   Standard_Real l = 0.5; //Draw::Atof(argv[2]);
267   // Find the first vertex of the wire
268   BRepTools_WireExplorer wire_exp(myTopoDSWire);
269   TopoDS_Vertex vlast;
270   {
271     TopoDS_Vertex vw1, vw2;
272     TopExp::Vertices(myTopoDSWire,vw1,vw2);
273     TopoDS_Vertex ve1, ve2;
274     TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
275     TopExp::Vertices(edge,ve1,ve2);
276     if (vw1.IsSame(ve1) || vw1.IsSame(ve2))
277       vlast = vw1;
278     else {
279 //      assert(vw2.IsSame(ve1) || vw2.IsSame(ve2));
280       vlast = vw2;
281     }
282   }
283   for ( ; wire_exp.More(); wire_exp.Next())
284     {
285       di << "\n\n New Edge \n"   << "\n";
286       Standard_Real newufirst, newulast;
287       TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
288       Standard_Real ufirst, ulast;
289       Handle(Geom_Curve) acurve;
290       TopoDS_Vertex ve1, ve2;
291       TopExp::Vertices(edge,ve1,ve2);
292       if (ve1.IsSame(vlast))
293 	{
294           acurve = BRep_Tool::Curve(edge, ufirst, ulast);
295           newufirst = ufirst;
296           newulast  = ulast;
297           vlast = ve2;
298 	}
299       else
300 	{
301 //          assert(ve2.IsSame(vlast));
302 //          assert ( wire_exp.Orientation( ) == TopAbs_REVERSED );
303           acurve = BRep_Tool::Curve( edge, ufirst, ulast );
304           newufirst = acurve->ReversedParameter( ufirst );
305           newulast  = acurve->ReversedParameter( ulast );
306           acurve = acurve->Reversed( );
307           vlast = ve1;
308 	}
309 
310       GeomAdaptor_Curve   curve;
311       GCPnts_UniformAbscissa  algo;
312       curve.Load(acurve);
313       algo.Initialize( curve, l, newufirst, newulast );
314       if (!algo.IsDone())
315         di << "Not Done!!!"   << "\n";
316       for (Standard_Integer Index = 1; Index<=algo.NbPoints();Index++) {
317         Standard_Real t = algo.Parameter(Index);
318         gp_Pnt      pt3 = curve.Value(t);
319         di << "Parameter t = " << t   << "\n";
320         di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z()  << "\n";
321       }
322     }
323   return 0;
324 
325 }
326 
327 #include <TColStd_SequenceOfTransient.hxx>
328 #include <GeomFill_Pipe.hxx>
pipe_OCC9(Draw_Interpretor & di,Standard_Integer n,const char ** a)329 static int pipe_OCC9 (Draw_Interpretor& di,
330 		      Standard_Integer n, const char ** a)
331 {
332   if (n < 6) {
333     di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]\n";
334     return 1;
335   }
336 
337   TColStd_SequenceOfTransient aCurveSeq;
338   Standard_Integer i;
339   for (i=2 ; i<=4; i++) {
340     Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast( DrawTrSurf::Get(a[i]) );
341     if (aC.IsNull()) {
342       di << a[i] << " is not a curve\n";
343       return 1;
344     }
345     aCurveSeq.Append(aC);
346   }
347 
348   GeomFill_Pipe aPipe(Handle(Geom_Curve)::DownCast( aCurveSeq(1) ),
349 		      Handle(Geom_Curve)::DownCast( aCurveSeq(2) ),
350 		      Handle(Geom_Curve)::DownCast( aCurveSeq(3) ),
351 		      Draw::Atof (a[5]) );
352 
353   if (n == 7) {
354     aPipe.Perform(Draw::Atof (a[6]), Standard_True);
355   } else {
356     aPipe.Perform(Standard_True/*, Standard_True*/);
357   }
358 
359   if (!aPipe.IsDone()) {
360     di << "GeomFill_Pipe cannot make a surface\n";
361     return 1;
362   }
363 
364   Handle(Geom_Surface) aSurf = aPipe.Surface();
365 
366   DrawTrSurf::Set(a[1], aSurf);
367   return 0;
368 }
369 
370 //======================================================================
371 // OCC125
372 // usage : OCC125 shell
373 //======================================================================
374 #include <ShapeFix_Shell.hxx>
375 
OCC125(Draw_Interpretor & di,Standard_Integer n,const char ** a)376 Standard_Integer  OCC125(Draw_Interpretor& di ,
377 			 Standard_Integer n,
378 			 const char ** a)
379 {
380   if (n!=2) {
381     di<<" Use OCC125 shell";
382     return 1;
383   }
384 
385   TopoDS_Shape S = DBRep::Get(a[1]);
386 
387   if (S.IsNull()) {
388     di<<" Null shape is not allowed";
389     return 1;
390   }
391 
392   TopAbs_ShapeEnum aT;
393   aT=S.ShapeType();
394   if (aT!=TopAbs_SHELL) {
395     di<<" Shape Type must be SHELL";
396     return 1;
397   }
398 
399   const TopoDS_Shell& aShell = TopoDS::Shell(S);
400   //
401   Standard_Boolean isAccountMultiConex, bNonManifold, bResult;
402 
403   isAccountMultiConex=Standard_True;
404   bNonManifold=Standard_False;
405 
406   Handle (ShapeFix_Shell) aFix = new ShapeFix_Shell(aShell);
407   bResult=aFix->FixFaceOrientation(aShell, isAccountMultiConex, bNonManifold);
408 
409   di<<"bResult="<<(Standard_Integer)bResult;
410 
411   TopoDS_Shape aShape;
412   aShape=aFix->Shape();
413 
414   TCollection_AsciiString aName(a[1]), aDef("_sh"), aRName;
415   aRName=aName;
416   aRName=aRName+aDef;
417   DBRep::Set (aRName.ToCString(), aShape);
418   di<<aRName.ToCString();
419   //
420   return 0;
421 }
422 
423 #include <BRepLib_FindSurface.hxx>
424 #include <BRepBuilderAPI_MakeFace.hxx>
OCC157(Draw_Interpretor & di,Standard_Integer n,const char ** a)425 Standard_Integer  OCC157(Draw_Interpretor& di,
426 			 Standard_Integer n,
427 			 const char ** a)
428 //static Standard_Integer findplanarsurface(Draw_Interpretor&, Standard_Integer n, const char ** a)
429 {
430   if (n<3) {
431     di << "bad number of arguments\n";
432     return 1;
433   }
434 
435   // try to read a shape:
436   TopoDS_Shape inputShape=DBRep::Get(a[2]);
437   if (inputShape.IsNull() || inputShape.ShapeType() != TopAbs_WIRE) {
438     di << "Invalid input shape\n";
439     return 1;
440   }
441   Standard_Real toler = Draw::Atof(a[3]);
442   TopoDS_Wire aWire = TopoDS::Wire(inputShape);
443   BRepLib_FindSurface FS(aWire, toler, Standard_True);
444   if(FS.Found()) {
445     di<<"OCC157: OK; Planar surface is found\n";
446     Handle(Geom_Surface) aSurf = FS.Surface();
447     BRepBuilderAPI_MakeFace aMakeFace(aSurf,aWire,Standard_True);
448     if(aMakeFace.IsDone()) {
449       TopoDS_Face aFace = aMakeFace.Face();
450       DBRep::Set(a[1],aFace);
451     }
452   }
453   else di<<"OCC157: ERROR; Planar surface is not found with toler = "<<toler <<"\n";
454   return 0;
455 
456 }
457 
458 // #include <MyCommandsCMD.h>
459 #include <ShapeFix_Shape.hxx>
460 #include <BRepOffset_MakeOffset.hxx>
461 #include <BRepOffsetAPI_MakeOffset.hxx>
462 #include <BRepOffset_Mode.hxx>
463 #include <GeomAbs_JoinType.hxx>
464 #include <AIS_Shape.hxx>
465 
466 #include <BRepTools.hxx>
467 
OCC165(Draw_Interpretor & di,Standard_Integer n,const char ** a)468 Standard_Integer  OCC165(Draw_Interpretor& di ,
469 			 Standard_Integer n,
470 			 const char ** a)
471 
472 
473 //=======================================================================
474 
475 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv);
476 
477 // void MyOffsets_Commands(Draw_Interpretor& theCommands)
478 // {
479 // 	theCommands.Add("yoffset" , "yoffset" , __FILE__, YOffset, " Offset on Z Direction");
480 // }
481 
482 //=======================================================================
483 
484 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
485  {
486    if (n > 2)
487      {
488        di <<"Usage : " << a[0] << " [file]\n";
489        return 1;
490      }
491 	di.Eval ("axo");
492 
493 #define _OFFSET_TELCO_
494 #ifdef _OFFSET_TELCO_
495 
496 	Standard_CString file = a[1];
497 
498 	BRep_Builder aBuilder;
499 	TopoDS_Shape theShape;
500 	//BRepTools::Read(theShape, Standard_CString("/dn02/users_SUN/inv/3/OCC165/2d_tr_line.brep"), aBuilder);
501 	BRepTools::Read(theShape, file, aBuilder);
502 	DBRep::Set("shape", theShape);
503 
504 	TopoDS_Wire theWire = TopoDS::Wire(theShape);
505 
506 	Standard_Real anOffset = 1.5;
507 
508 #else
509 
510 	Standard_Real xA = 0.0, xB = 200.0, xC = 200.0, xD = 0.0,
511 		yA = 0.0, yB = 0.0, yC = 200.0, yD = 200.0,
512 		zA = 0.0, zB = 0.0, zC = 0.0, zD = 0.0;
513 
514 	BRepBuilderAPI_MakePolygon theSquare;
515 	TopoDS_Vertex theA = BRepBuilderAPI_MakeVertex(gp_Pnt(xA, yA, zA));
516 	theSquare.Add(theA);
517 	TopoDS_Vertex theB = BRepBuilderAPI_MakeVertex(gp_Pnt(xB, yB, zB));
518 	theSquare.Add(theB);
519 	TopoDS_Vertex theC = BRepBuilderAPI_MakeVertex(gp_Pnt(xC, yC, zC));
520 	theSquare.Add(theC);
521 	TopoDS_Vertex theD = BRepBuilderAPI_MakeVertex(gp_Pnt(xD, yD, zD));
522 	theSquare.Add(theD);
523 
524 	theSquare.Close();
525 	TopoDS_Wire theWire = theSquare.Wire();
526 
527 	Standard_Real anOffset = 10;
528 
529 
530 #endif /* _OFFSET_TELCO_ */
531 
532 
533 	TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire).Face();
534 	DBRep::Set("face", theFace);
535 
536 
537 	Standard_Real anAlt = 0.;
538 	GeomAbs_JoinType theJoin = GeomAbs_Intersection;
539 //GeomAbs_Intersection; //GeomAbs_Arc;
540 	BRepOffsetAPI_MakeOffset aMakeOffset(theFace, theJoin);
541 	aMakeOffset.AddWire(theWire);
542 
543 	aMakeOffset.Perform(anOffset, anAlt);
544 
545 	TopoDS_Shape theOffsetShapePos = aMakeOffset.Shape();
546 	DBRep::Set("offset", theOffsetShapePos);
547 	return 0;
548 // 	return TCL_OK;
549 }
550 
551 #include<BRepAlgoAPI_Cut.hxx>
552 
553 #include<BRepPrimAPI_MakeHalfSpace.hxx>
554 #include<Geom_CartesianPoint.hxx>
555 #include<AIS_Point.hxx>
556 
557 #include <BRepBuilderAPI_MakeEdge.hxx>
558 #include <BRepBuilderAPI_MakeWire.hxx>
559 #include <BRepBuilderAPI_MakeFace.hxx>
560 
OCC297(Draw_Interpretor & di,Standard_Integer,const char ** argv)561 static Standard_Integer OCC297 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
562 
563 {
564   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
565   if (myAISContext.IsNull()) {
566     di << "use 'vinit' command before " << argv[0] << "\n";
567     return -1;
568   }
569 
570   gp_Pnt pt1_(250., 250., 0.);
571   gp_Pnt pt2_(-250., 250., 0.);
572   gp_Pnt pt3_(-250., -250., 0.);
573   gp_Pnt pt4_(250., -250., 0.);
574   BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
575   BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
576   BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
577   BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
578 
579   BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
580   BRepBuilderAPI_MakeFace face_(wire_);
581   TopoDS_Face sh_ = face_.Face();
582 
583   int up = 1;
584 
585   gp_Pnt g_pnt;
586   if (up)
587     g_pnt = gp_Pnt(0, 0, -100);
588   else
589     g_pnt = gp_Pnt(0, 0, 100);
590 
591   myAISContext->EraseAll(Standard_False);
592   Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
593   Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
594   myAISContext->Display(AISPoint, Standard_True);
595 
596   BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
597   TopoDS_Solid sol1_ = half_.Solid();
598 
599   DBRep::Set("Face", sol1_);
600 
601   gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
602 
603   Standard_Real x = 0., y = 0., z = -80.;
604 
605   BRepPrimAPI_MakeBox box(gp_Pnt(x, y, z), gp_Pnt(x + 150, y + 200, z + 200));
606 
607   DBRep::Set("Box", box.Shape());
608 
609   return 0;
610 
611 }
612 
613 #include<GProp_GProps.hxx>
614 #include<BRepGProp.hxx>
615 
OCC305(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)616 static Standard_Integer OCC305 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
617 
618 {
619   if (argc != 2)
620   {
621     di <<"Usage : " << argv[0] << " file\n";
622     return 1;
623   }
624   Standard_CString file = argv[1];
625 
626   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
627   if(myAISContext.IsNull()) {
628     di << "use 'vinit' command before " << argv[0] << "\n";
629     return -1;
630   }
631 
632 TopoDS_Shape sh;
633 BRep_Builder builder;
634 //BRepTools::Read(sh, "/dn02/users_SUN/inv/3/OCC305/testc.brep", builder);
635 BRepTools::Read(sh, file, builder);
636 
637 TopoDS_Wire wire;
638 builder.MakeWire(wire);
639 TopoDS_Edge ed;
640 TopoDS_Vertex vt1, vt2;
641 TopExp_Explorer wex(sh, TopAbs_EDGE);
642 for(;wex.More();wex.Next())
643 {
644     ed = TopoDS::Edge(wex.Current());
645     TopExp::Vertices(ed, vt1, vt2);
646     builder.UpdateVertex(vt1, 0.01);
647     builder.UpdateVertex(vt2, 0.01);
648     builder.UpdateEdge(ed, 0.01);
649     builder.Add(wire, ed);
650 
651 
652     GProp_GProps lprop;
653     BRepGProp::LinearProperties(ed, lprop);
654     printf("\n length = %f", lprop.Mass());
655 }
656  DBRep::Set("Wire",wire);
657 // Handle(AIS_Shape) res = new AIS_Shape( wire );
658 // aContext->SetColor( res, Quantity_NOC_RED );
659 // aContext->Display( res );
660 
661 // BRepOffsetAPI_MakeOffset off(wire, GeomAbs_Arc);
662 // off.Perform(0.5, 0);
663 
664 // printf("\n IsDone = %d", off.IsDone());
665 // sh = off.Shape();
666 // res = new AIS_Shape( sh );
667 // aContext->SetColor( res, Quantity_NOC_GREEN );
668 // aContext->Display( res );
669 
670   return 0;
671 
672 }
673 
674 #include <TDocStd_Document.hxx>
675 #include <DDocStd.hxx>
676 #include <PCDM_StoreStatus.hxx>
677 #include <TDocStd_Application.hxx>
678 
OCC381_Save(Draw_Interpretor & di,Standard_Integer nb,const char ** a)679 static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
680 {
681   if (nb != 2) {
682     di << "Usage: " << a[0] << " Doc\n";
683     return 1;
684   }
685 
686   Handle(TDocStd_Document) D;
687   if (!DDocStd::GetDocument(a[1],D)) return 1;
688 
689   Handle(TDocStd_Application) A = DDocStd::GetApplication();
690 
691   TCollection_ExtendedString theStatusMessage;
692   if (!D->IsSaved()) {
693     di << "this document has never been saved\n";
694     return 0;
695   }
696   PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
697   if (theStatus != PCDM_SS_OK ) {
698     switch ( theStatus ) {
699       case PCDM_SS_DriverFailure: {
700         di << "Error saving document: Could not store , no driver found to make it\n";
701         break ;
702       }
703       case PCDM_SS_WriteFailure: {
704         di << "Error saving document: Write access failure\n";
705         break;
706       }
707       case PCDM_SS_Failure: {
708         di << "Error saving document: Write failure\n" ;
709         break;
710       }
711       case PCDM_SS_Doc_IsNull: {
712         di << "Error saving document: No document to save\n";
713         break ;
714       }
715       case PCDM_SS_No_Obj: {
716         di << "Error saving document: No objects written\n";
717         break;
718       }
719       case PCDM_SS_Info_Section_Error: {
720         di << "Error saving document: Write info section failure\n" ;
721         break;
722       }
723       default:
724           break;
725     }
726     return 1;
727   }
728   return 0;
729 }
730 
OCC381_SaveAs(Draw_Interpretor & di,Standard_Integer nb,const char ** a)731 static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
732 {
733   if (nb != 3) {
734     di << "Usage: " << a[0] << " Doc Path\n";
735     return 1;
736   }
737 
738   Handle(TDocStd_Document) D;
739   if (!DDocStd::GetDocument(a[1],D)) return 1;
740 
741   TCollection_ExtendedString path (a[2]);
742   Handle(TDocStd_Application) A = DDocStd::GetApplication();
743 
744   TCollection_ExtendedString theStatusMessage;
745   PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
746   if (theStatus != PCDM_SS_OK ) {
747     switch ( theStatus ) {
748       case PCDM_SS_DriverFailure: {
749         di << "Error saving document: Could not store , no driver found to make it\n";
750         break ;
751       }
752       case PCDM_SS_WriteFailure: {
753         di << "Error saving document: Write access failure\n";
754         break;
755       }
756       case PCDM_SS_Failure: {
757         di << "Error saving document: Write failure\n" ;
758         break;
759       }
760       case PCDM_SS_Doc_IsNull: {
761         di << "Error saving document: No document to save\n";
762         break ;
763       }
764       case PCDM_SS_No_Obj: {
765         di << "Error saving document: No objects written\n";
766         break;
767       }
768       case PCDM_SS_Info_Section_Error: {
769         di << "Error saving document: Write info section failure\n" ;
770         break;
771       }
772       default:
773           break;
774     }
775     return 1;
776   }
777 
778   return 0;
779 }
780 
781 #include <BRepClass3d_SolidClassifier.hxx>
782 
OCC299bug(Draw_Interpretor & theDi,Standard_Integer theArgNb,const char ** theArgVec)783 Standard_Integer OCC299bug (Draw_Interpretor& theDi,
784                             Standard_Integer  theArgNb,
785                             const char**      theArgVec)
786 {
787   if (theArgNb < 3)
788   {
789     theDi << "Usage : " << theArgVec[0] << " Solid Point [Tolerance=1.e-7]\n";
790     return -1;
791   }
792 
793   TopoDS_Shape aS = DBRep::Get (theArgVec[1]);
794   if (aS.IsNull())
795   {
796     theDi << " Null Shape is not allowed here\n";
797     return 1;
798   }
799   else if (aS.ShapeType() != TopAbs_SOLID)
800   {
801     theDi << " Shape type must be SOLID\n";
802     return 1;
803   }
804 
805   gp_Pnt aP (8., 9., 10.);
806   if (!DrawTrSurf::GetPoint (theArgVec[2], aP))
807   {
808     theDi << " Null Point is not allowed here\n";
809     return 1;
810   }
811   const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : 1.e-7;
812 
813   BRepClass3d_SolidClassifier aSC (aS);
814   aSC.Perform (aP, aTol);
815 
816   switch (aSC.State())
817   {
818     case TopAbs_IN:      theDi << "The point is IN shape\n";      return 0;
819     case TopAbs_OUT:     theDi << "The point is OUT of shape\n";  return 0;
820     case TopAbs_ON:      theDi << "The point is ON shape\n";      return 0;
821     case TopAbs_UNKNOWN:
822     default:             theDi << "The point is UNKNOWN shape\n"; return 0;
823   }
824 }
825 
826 #include <OSD_Process.hxx>
827 #include <OSD_Path.hxx>
828 
OCC309bug(Draw_Interpretor & di,Standard_Integer nb,const char ** a)829 static Standard_Integer OCC309bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
830 {
831   if (nb != 1) {
832     di << "Usage: " << a[0] << "\n";
833     return 1;
834   }
835   OSD_Process p;
836   OSD_Path d = p.CurrentDirectory();
837   TCollection_AsciiString s;
838   d.SystemName(s);
839   di << "*" <<  s.ToCString() << "*\n";
840   d.UpTrek();
841   d.SystemName(s);
842   di <<  "*" <<  s.ToCString() <<  "*\n";
843   return 0;
844 }
845 
OCC310bug(Draw_Interpretor & di,Standard_Integer nb,const char ** a)846 static Standard_Integer OCC310bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
847 {
848   if (nb != 1) {
849     di << "Usage: " << a[0] << "\n";
850     return 1;
851   }
852   OSD_Path p("/where/you/want/tmp/qwerty/tmp/");
853   di << p.Trek().ToCString() << "\n";
854   p.UpTrek();
855   di << p.Trek().ToCString() << "\n";
856   return 0;
857 }
858 
859 #include <BRepAlgoAPI_Fuse.hxx>
860 #include <BRepAlgoAPI_Common.hxx>
861 
OCC277bug(Draw_Interpretor & di,Standard_Integer nb,const char ** a)862 static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
863 {
864   if(nb != 1) {
865     di << "Usage : " << a[0] << "\n";
866     return 1;
867   }
868 
869   BRepPrimAPI_MakeBox box1( 100, 100, 100 );
870   BRepPrimAPI_MakeBox box2( gp_Pnt( 50, 50,50 ), 200, 200, 200 );
871 
872   TopoDS_Shape shape1 = box1.Shape();
873   TopoDS_Shape shape2 = box2.Shape();
874 
875   TopoDS_Shape fuse,comm;
876   di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )\n";
877   di << "comm = BRepAlgoAPI_Common( shape1, shape2 )\n";
878   fuse = BRepAlgoAPI_Fuse(shape1, shape2).Shape();
879   comm = BRepAlgoAPI_Common(shape1, shape2).Shape();
880 
881   return 0;
882 }
883 
884 #include <DDocStd_DrawDocument.hxx>
885 #include <TDataStd_Name.hxx>
886 #include <Draw.hxx>
887 #include <XCAFDoc_ShapeTool.hxx>
888 #include <XCAFDoc_DocumentTool.hxx>
889 #include <TDF_LabelSequence.hxx>
890 #include <TPrsStd_AISPresentation.hxx>
891 #include <TDF_Data.hxx>
892 #include <TDF_Label.hxx>
893 #include <XCAFPrs_Driver.hxx>
894 
895 //------------------------------------------------------------------------------------------
896 // name    : OCC363
897 // Purpose :
898 //------------------------------------------------------------------------------------------
OCC363(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)899 static Standard_Integer OCC363 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
900 {
901   try
902   {
903     OCC_CATCH_SIGNALS
904     // 1. Verufy amount of arguments
905     if(argc < 3) { di <<"Error OCC363 : Use : OCC363 document filename\n"; return 1; }
906 
907     // 2. Retrieve DDocStd application
908     Handle(TDocStd_Application) App = DDocStd::GetApplication();
909 
910     // 3. Open document
911     TCollection_ExtendedString name(argv[2]);
912     Handle(TDocStd_Document) Doc;
913     if(App->Open(name, Doc) != PCDM_RS_OK) { di << "Error OCC363 : document was not opened successfully\n"; return 1;}
914     Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(Doc);
915     TDataStd_Name::Set(Doc->GetData()->Root(),argv[1]);
916     Draw::Set(argv[1],DD);
917 
918     // 4. Create prsentations
919     Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
920     TDF_LabelSequence seq;
921     shapes->GetFreeShapes ( seq );
922     Handle(TPrsStd_AISPresentation) prs;
923     for ( Standard_Integer i=1; i <= seq.Length(); i++ )
924       if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) )
925         prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
926   }
927   catch(Standard_Failure const&) { di << "FAULTY OCC363 : Exception during reading document.\n";return 0;}
928 
929   di << "OCC363 OK\n";
930   return 0;
931 }
932 
933 // Must use OCC299
934 ////======================================================================================
935 //// Function : OCC372
936 //// Purpose  :
937 ////======================================================================================
938 //static Standard_Integer OCC372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
939 //{
940 //  try
941 //  {
942 //    OCC_CATCH_SIGNALS
943 //    // 1. Verufy amount of arguments
944 //    if(argc < 2) {di << "OCC372 FAULTY. Use : OCC372 brep-file";return 0;}
945 //
946 //    // 2. Read solid
947 //    BRep_Builder B;
948 //    TopoDS_Shape Ref;
949 //    BRepTools::Read(Ref, argv[1], B);
950 //
951 //    // 3. Calculate location of aP3d in relation to the solid
952 //    gp_Pnt aP3d(6311.4862583184, -2841.3092756034, 16.461053497188);
953 //    BRepClass3d_SolidClassifier SC(Ref);
954 //    SC.Perform(aP3d, 1e-7);
955 //
956 //    // 4. Check returned state. The point must be inside the solid.
957 //    TopAbs_State aState=SC.State();
958 //    switch (aState)
959 //    {
960 //    case TopAbs_OUT:
961 //      di<<"OCC372 FAULTY. aState = TopAbs_OUT";
962 //      return 0;
963 //    case TopAbs_ON:
964 //      di<<"OCC372 FAULTY. aState = TopAbs_ON";
965 //     return 0;
966 //    case TopAbs_IN:
967 //      di<<"OCC372 OK. aState = TopAbs_IN" ;
968 //      return 0;
969 //    default:
970 //      di<<"OCC372 FAULTY. aState = UNKNOWN";
971 //      return 0;
972 //    }
973 //  }
974 //  catch (Standard_Failure) { di<<"OCC372 FAULTY. Exception raised"; }
975 //
976 //  return 0;
977 //}
978 
979 #include <BRepTopAdaptor_FClass2d.hxx>
980 
981 //======================================================================================
982 // Function : OCC377
983 // Purpose  :
984 //======================================================================================
OCC377(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)985 static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
986 {
987   try
988   {
989     OCC_CATCH_SIGNALS
990     // 1. Verify validity of arguments
991     if ( argc < 1 ) {di << "Error OCC377. Use  OCC377 file x y precuv \n";return 0;}
992 
993     // 2. Initialize parameters
994     gp_Pnt2d p2d;
995     p2d.SetX ( Draw::Atof(argv[2]) );
996     p2d.SetY ( Draw::Atof(argv[3]) );
997     Standard_Real precuv = Draw::Atof (argv[4] );
998 
999     // 3. Read shape
1000     BRep_Builder B;
1001     TopoDS_Shape Shape;
1002     BRepTools::Read ( Shape, argv[1], B );
1003 
1004     // 4. Verify whether enrtry point is on wire and reversed ones (indeed results of veridying must be same)
1005     TopExp_Explorer exp;
1006     Standard_Integer i=1;
1007     for (exp.Init(Shape.Oriented(TopAbs_FORWARD),TopAbs_WIRE); exp.More(); exp.Next(), i++)
1008     {
1009       // 4.1. Verify whether enrtry point is on wire
1010       const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
1011       TopoDS_Face newFace = TopoDS::Face(Shape.EmptyCopied());
1012 
1013       TopAbs_Orientation orWire = wir.Orientation();
1014       newFace.Orientation(TopAbs_FORWARD);
1015       B.Add(newFace,wir);
1016 
1017       BRepTopAdaptor_FClass2d FClass2d1(newFace,precuv);
1018       TopAbs_State stat1 = FClass2d1.PerformInfinitePoint();
1019       //di << "Wire " << i << ": Infinite point is " <<
1020       //  ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1021 
1022       TCollection_AsciiString TmpString;
1023       stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1024       di << "Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1025 
1026       stat1 = FClass2d1.Perform(p2d);
1027       //di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1028       //  ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1029 
1030       TmpString.Clear();
1031       stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1032       di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1033 
1034       // 4.2. Verify whether enrtry point is on reversed wire
1035       newFace = TopoDS::Face(Shape.EmptyCopied());
1036       newFace.Orientation(TopAbs_FORWARD);
1037       orWire = TopAbs::Reverse(orWire);
1038       B.Add(newFace,wir.Oriented(orWire));
1039       BRepTopAdaptor_FClass2d FClass2d2(newFace,precuv);
1040       TopAbs_State stat2 = FClass2d2.PerformInfinitePoint();
1041       //di << "Reversed Wire " << i << ": Infinite point is " <<
1042       //  ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1043 
1044       TmpString.Clear();
1045       stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1046       di << "Reversed Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1047 
1048       stat2 = FClass2d2.Perform(p2d);
1049       //di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1050       //  ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1051 
1052       TmpString.Clear();
1053       stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1054       di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1055 
1056       // 4.3. Compare results (they must be same)
1057       if(stat1 ==stat2) di << "OCC377 OK\n";
1058       else {di << "OCC377 FAULTY\n"; return 0;}
1059     }
1060   }
1061   catch(Standard_Failure const&)
1062   {
1063     di << "OCC377 Exception";
1064   }
1065 
1066   return 0;
1067 }
1068 
1069 #include <ShapeUpgrade_ShapeDivideAngle.hxx>
1070 #include <ShapeBuild_ReShape.hxx>
1071 
1072 //=======================================================================
1073 //function : OCC22
1074 //purpose  :
1075 //=======================================================================
OCC22(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1076 static Standard_Integer OCC22 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1077 {
1078   try
1079   {
1080     OCC_CATCH_SIGNALS
1081     // 1. Verify arguments of the command
1082     if (argc < 5) { di << "OCC22 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation"; return 0;}
1083 
1084     Standard_Boolean aConsiderLocation;
1085     if(strcmp(argv[4], "0")==0) aConsiderLocation = Standard_False;
1086     else aConsiderLocation = Standard_True;
1087 
1088     // 2. Iniitialize aShapeUpgrade
1089     ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(M_PI/2.);
1090     // precision
1091     aShapeUpgrade.SetPrecision (Precision::Confusion());
1092     // tolerance
1093     aShapeUpgrade.SetMaxTolerance(0.1);
1094     // subshapes to be divided
1095     TopoDS_Shape aSubShapesToBeDivided = DBRep::Get(argv[3]);
1096     if(aSubShapesToBeDivided.IsNull()) {di << "OCC22 FAULTY. Compound of subshapes to be divided is not exist. Please, verify input values. \n";return 0;}
1097     aShapeUpgrade.Init(aSubShapesToBeDivided);
1098     // context
1099     Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1100     aShapeUpgrade.SetContext(aReshape);
1101     if(aConsiderLocation) aReshape->ModeConsiderLocation() = Standard_True;
1102 
1103     // 3. Perform splitting
1104     if (aShapeUpgrade.Perform (Standard_False))         di << "Upgrade_SplitRevolution_Done \n";
1105     else if (aShapeUpgrade.Status (ShapeExtend_OK))     di << "Upgrade_SplitRevolution_OK \n";
1106     else if (aShapeUpgrade.Status (ShapeExtend_FAIL)) { di << "OCC22 FAULTY. Operation failed. Angle was not divided\n";return 0;}
1107 
1108     // 4. Perform rebuilding shape
1109     // 4.1. Retrieve Shape
1110     TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1111     if(anInitShape.IsNull()) { di << "OCC22 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1112     // 4.2 Rebuild retrieved shape
1113     TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1114     // 4.3. Create result Draw shape
1115     DBRep::Set(argv[1], aResultShape);
1116   }
1117   catch (Standard_Failure const&) {di << "OCC22 Exception \n" ;return 0;}
1118 
1119   return 0;
1120 }
1121 
1122 
1123 #include <ShapeProcess_OperLibrary.hxx>
1124 #include <ShapeProcess_ShapeContext.hxx>
1125 #include <ShapeProcess.hxx>
1126 
1127 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
1128 #include <BRepMesh_IncrementalMesh.hxx>
1129 #include <IMeshTools_Parameters.hxx>
1130 
1131 //=======================================================================
1132 //function : OCC24
1133 //purpose  :
1134 //=======================================================================
OCC24(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1135 static Standard_Integer OCC24 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1136 {
1137   try
1138   {
1139     OCC_CATCH_SIGNALS
1140     // 1. Verify amount of arguments of the command
1141     if (argc < 6) { di << "OCC24 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapes ResourceFileName SequenceName"; return 0;}
1142 
1143     // 2. Retrieve parameters
1144     // initial shape
1145     TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1146     if(anInitShape.IsNull()) { di << "OCC24 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1147     // compound of subshapes
1148     TopoDS_Shape aSubShapes = DBRep::Get(argv[3]);
1149     if(aSubShapes.IsNull()) {di << "OCC24 FAULTY. Compound of subshapes is not exist. Please, verify input values. \n";return 0;}
1150     // name of resource file
1151     const char* aResourceFile = argv[4];
1152     // name of sequence from resource file to be executed
1153     const char* aSequenceName = argv[5];
1154 
1155     // 3. Initialize ShapeContext and perform sequence of operation specified with resource file
1156     ShapeProcess_OperLibrary::Init();
1157     Handle(ShapeProcess_ShapeContext) aShapeContext = new ShapeProcess_ShapeContext (aSubShapes, aResourceFile);
1158     aShapeContext->SetDetalisation (TopAbs_EDGE);
1159     ShapeProcess::Perform (aShapeContext, aSequenceName);
1160 
1161     // 4. Rebuild initil shape in accordance with performed operation
1162     Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1163     TopTools_DataMapIteratorOfDataMapOfShapeShape anIter (aShapeContext->Map());
1164     for (; anIter.More(); anIter.Next())
1165       aReshape->Replace(anIter.Key(), anIter.Value());
1166     TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1167 
1168     // 5 Create resultant Draw shape
1169     DBRep::Set(argv[1], aResultShape);
1170 
1171   }
1172   catch (Standard_Failure const&) {di << "OCC24 Exception \n" ;return 0;}
1173 
1174   return 0;
1175 }
1176 
1177 //=======================================================================
1178 //function : OCC369
1179 //purpose  : Verify whether exception occurs during building mesh
1180 //=======================================================================
OCC369(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1181 static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1182 {
1183   try
1184   {
1185     OCC_CATCH_SIGNALS
1186     // 1. Verify amount of arguments of the command
1187     if (argc < 2) { di << "OCC369 FAULTY. Use : OCC369 Shape \n"; return 0;}
1188 
1189     // 2. Retrieve shape
1190     TopoDS_Shape aShape = DBRep::Get(argv[1]);
1191     if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
1192 
1193     // 3. Build mesh
1194     IMeshTools_Parameters aMeshParams;
1195     aMeshParams.Relative   = Standard_True;
1196     aMeshParams.Deflection = 0.2;
1197     aMeshParams.Angle      = M_PI / 6.0;
1198     BRepMesh_IncrementalMesh aMesh(aShape, aMeshParams);
1199 
1200   }
1201   catch (Standard_Failure const&) {di << "OCC369 Exception \n" ;return 0;}
1202 
1203   di << "OCC369 OK \n";
1204   return 0;
1205 }
1206 
1207 #include <math_Vector.hxx>
1208 #include <math_Matrix.hxx>
OCC524(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1209 static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1210 {
1211   if(argc != 9){
1212     di<<"Usage : " << argv[0] << " LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix\n";
1213     return 1;
1214   }
1215   Standard_Integer LowerVector = Draw::Atoi(argv[1]);
1216   Standard_Integer UpperVector = Draw::Atoi(argv[2]);
1217   Standard_Real InitialValueVector = Draw::Atof(argv[3]);
1218   Standard_Integer LowerRowMatrix = Draw::Atoi(argv[4]);
1219   Standard_Integer UpperRowMatrix = Draw::Atoi(argv[5]);
1220   Standard_Integer LowerColMatrix = Draw::Atoi(argv[6]);
1221   Standard_Integer UpperColMatrix = Draw::Atoi(argv[7]);
1222   Standard_Real InitialValueMatrix = Draw::Atof(argv[8]);
1223 
1224   math_Vector Vector1(LowerVector, UpperVector);
1225   math_Vector Vector2(LowerVector, UpperVector);
1226 
1227   math_Vector Vector(LowerVector, UpperVector, InitialValueVector);
1228   math_Matrix Matrix(LowerRowMatrix, UpperRowMatrix, LowerColMatrix, UpperColMatrix, InitialValueMatrix);
1229 
1230   //Vector.Dump(std::cout);
1231   //std::cout<<std::endl;
1232 
1233   //Matrix.Dump(std::cout);
1234   //std::cout<<std::endl;
1235 
1236   Vector1.Multiply(Vector, Matrix);
1237 
1238   //Vector1.Dump(std::cout);
1239   Standard_SStream aSStream1;
1240   Vector1.Dump(aSStream1);
1241   di << aSStream1;
1242   di<<"\n";
1243 
1244   if (Matrix.RowNumber() > 1) {
1245     Matrix(Matrix.LowerRow() + 1, Matrix.LowerCol()) += 1.;
1246   }
1247   Vector2.TMultiply(Vector, Matrix);
1248 
1249   //Vector2.Dump(std::cout);
1250   Standard_SStream aSStream2;
1251   Vector2.Dump(aSStream2);
1252   di << aSStream2;
1253   di<<"\n";
1254 
1255   return 0;
1256 }
1257 
1258 #include <GeomPlate_BuildPlateSurface.hxx>
1259 //=======================================================================
1260 //function : OCC525
1261 //purpose  :
1262 //=======================================================================
OCC525(Draw_Interpretor & di,Standard_Integer,const char **)1263 static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
1264 {
1265   GeomPlate_BuildPlateSurface aBuilder;
1266   aBuilder.Perform();
1267 
1268   if (aBuilder.IsDone())
1269   {
1270     di << "Error in OCC525. Null result is expected.\n";
1271   }
1272   else
1273   {
1274     di << "OCC525 OK \n";
1275   }
1276 
1277   return 0;
1278 }
1279 
1280 #include <BRepPrimAPI_MakeWedge.hxx>
1281 #include <gce_MakeRotation.hxx>
1282 #include <gce_MakeTranslation.hxx>
1283 #include <BRepBuilderAPI_Transform.hxx>
1284 #include <BRepPrimAPI_MakeWedge.hxx>
1285 //=======================================================================
1286 //function :  OCC578
1287 //purpose  :
1288 //=======================================================================
OCC578(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1289 static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1290 {
1291   if(argc != 4) {
1292     di << "Usage : " << argv[0] << " shape1 shape2 shape3\n";
1293     return 1;
1294   }
1295 
1296   gp_Pnt P0(0,0,0.0);
1297   double xperiod = 1.0;
1298   double yperiod = 1.0;
1299   double sub_thick = 0.5;
1300 
1301   // mask_substrate
1302   //TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick );
1303   TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick ).Shape();
1304 
1305   // --------------------------------------------------------------------
1306 
1307   // wedge
1308   //TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1309 	//				      0.1,  0.1  , 0.4, 0.4 );
1310   TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1311 					      0.1,  0.1  , 0.4, 0.4 ).Shape();
1312 
1313   gp_Trsf rotate = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1314 				     gp_Dir(1.0,0.0,0.0),
1315 				     1.570795 );
1316 
1317   gp_Trsf translate = gce_MakeTranslation(gp_Pnt( 0.0, -0.5, 0.0),
1318 					  gp_Pnt( 0.25, 0.25, 0.5)
1319 					  );
1320 
1321   rotate.PreMultiply( translate );
1322 
1323   TopoDS_Shape wedge1a = BRepBuilderAPI_Transform( wedge1, rotate );
1324 
1325   if (wedge1a.IsNull()) {
1326     di<<" Null shape1 is not allowed\n";
1327     return 1;
1328   }
1329   DBRep::Set(argv[1], wedge1a);
1330 
1331   // --------------------------------------------------------------------
1332 
1333   // wedge top
1334   //TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1335 	//				      0.1,  0.1  , 0.4, 0.4 );
1336   TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1337 					      0.1,  0.1  , 0.4, 0.4 ).Shape();
1338 
1339   gp_Trsf rotate2 = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1340 				      gp_Dir(1.0,0.0,0.0),
1341 				      1.570795 * 3.0 );
1342 
1343   gp_Trsf translate2 = gce_MakeTranslation(gp_Pnt( 0.0, 0.0, 0.0),
1344 					   gp_Pnt( 0.25, 0.25, 0.5)
1345 					   );
1346 
1347   rotate2.PreMultiply( translate2 );
1348 
1349   TopoDS_Shape wedge2a = BRepBuilderAPI_Transform( wedge2, rotate2 );
1350 
1351   if (wedge2a.IsNull()) {
1352     di<<" Null shape2 is not allowed\n";
1353     return 1;
1354   }
1355   DBRep::Set(argv[2], wedge2a);
1356 
1357 
1358   // combine wedges
1359   di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)\n";
1360   TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a).Shape();
1361 
1362   di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)\n";
1363   TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common).Shape();
1364 
1365   if (sub_etch1.IsNull()) {
1366     di<<" Null shape3 is not allowed\n";
1367     return 1;
1368   }
1369   DBRep::Set(argv[3], sub_etch1);
1370 
1371   return 0;
1372 }
1373 
1374 #include <Standard_GUID.hxx>
1375 //=======================================================================
1376 //function :  OCC669
1377 //purpose  :
1378 //=======================================================================
OCC669(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1379 static Standard_Integer OCC669 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1380 {
1381   if(argc != 2){
1382     di<<"Usage : " << argv[0] << " GUID\n";
1383     return -1;
1384   }
1385   Standard_GUID guid(argv[1]);
1386   //guid.ShallowDump(std::cout);
1387   Standard_SStream aSStream;
1388   guid.ShallowDump(aSStream);
1389   di << aSStream;
1390   di<<"\n";
1391   return 0;
1392 }
1393 
1394 #include <XCAFDoc.hxx>
1395 //=======================================================================
1396 //function :  OCC738_ShapeRef
1397 //purpose  :
1398 //=======================================================================
OCC738_ShapeRef(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1399 static Standard_Integer OCC738_ShapeRef (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1400 {
1401   if(argc != 1){
1402     di<<"Usage : " << argv[0] << "\n";
1403     return -1;
1404   }
1405   const Standard_GUID& guid = XCAFDoc::ShapeRefGUID ();
1406   //guid.ShallowDump(std::cout);
1407   Standard_SStream aSStream;
1408   guid.ShallowDump(aSStream);
1409   di << aSStream;
1410   return 0;
1411 }
1412 
1413 //=======================================================================
1414 //function :  OCC738_Assembly
1415 //purpose  :
1416 //=======================================================================
OCC738_Assembly(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1417 static Standard_Integer OCC738_Assembly (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1418 {
1419   if(argc != 1){
1420     di<<"Usage : " << argv[0] << "\n";
1421     return -1;
1422   }
1423   const Standard_GUID& guid = XCAFDoc::AssemblyGUID ();
1424   //guid.ShallowDump(std::cout);
1425   Standard_SStream aSStream;
1426   guid.ShallowDump(aSStream);
1427   di << aSStream;
1428   return 0;
1429 }
1430 
1431 #if defined(DDataStd_def01)
1432 #include <DDataStd_DrawPresentation.hxx>
1433 //=======================================================================
1434 //function :  OCC739_DrawPresentation
1435 //purpose  :
1436 //=======================================================================
OCC739_DrawPresentation(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1437 static Standard_Integer OCC739_DrawPresentation (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1438 {
1439   if(argc != 1){
1440     di<<"Usage : " << argv[0] << "\n";
1441     return -1;
1442   }
1443   const Standard_GUID& guid = DDataStd_DrawPresentation::GetID() ;
1444   //guid.ShallowDump(std::cout);
1445   Standard_SStream aSStream;
1446   guid.ShallowDump(aSStream);
1447   di << aSStream;
1448   return 0;
1449 }
1450 #endif
1451 
1452 //=======================================================================
1453 //function :  OCC708
1454 //purpose  :
1455 //=======================================================================
OCC708(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1456 static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1457 {
1458   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1459   if(aContext.IsNull()) {
1460     di << argv[0] << "ERROR : use 'vinit' command before \n";
1461     return 1;
1462   }
1463 
1464   if ( argc != 2) {
1465     di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation\n";
1466     return 1;
1467   }
1468 
1469   Standard_Boolean updateviewer = Standard_True;
1470 
1471   ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1472 
1473   TCollection_AsciiString aName(argv[1]);
1474   Handle(AIS_InteractiveObject) AISObj;
1475 
1476   if (!aMap.Find2 (aName, AISObj)
1477     || AISObj.IsNull())
1478   {
1479     di << "Use 'vdisplay' before\n";
1480     return 1;
1481   }
1482 
1483   AISObj->ResetTransformation();
1484 
1485   aContext->Erase(AISObj, updateviewer);
1486   aContext->UpdateCurrentViewer();
1487   aContext->Display(AISObj, updateviewer);
1488   aContext->UpdateCurrentViewer();
1489   return 0;
1490 }
1491 
1492 //=======================================================================
1493 //function :  OCC670
1494 //purpose  :
1495 //=======================================================================
1496 #include <TColStd_Array2OfInteger.hxx>
OCC670(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1497 static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1498 {
1499   if(argc != 1){
1500     di<<"Usage : " << argv[0] << "\n";
1501     return -1;
1502   }
1503 
1504   // check that exception initialized without message string can be safely handled and printed
1505   try {
1506     throw Standard_OutOfRange();
1507   }
1508   catch (Standard_Failure const& anException) {
1509     std::cout << "Caught successfully: ";
1510     std::cout << anException << std::endl;
1511   }
1512   return 0;
1513 }
1514 
1515 #include <GeomAPI_ProjectPointOnSurf.hxx>
1516 //=======================================================================
1517 //function :  OCC867
1518 //purpose  :
1519 //=======================================================================
OCC867(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1520 static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1521 {
1522   if (argc!=7)
1523   {
1524     di<<"Usage : " << argv[0] << " Point Surface Umin Usup Vmin Vsup \n";
1525     return 1;
1526   }
1527 
1528   gp_Pnt aPoint3d;
1529   DrawTrSurf::GetPoint(argv[1],aPoint3d);
1530   Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
1531   Standard_Real             Umin=Draw::Atof(argv[3]);
1532   Standard_Real             Usup=Draw::Atof(argv[4]);
1533   Standard_Real             Vmin=Draw::Atof(argv[5]);
1534   Standard_Real             Vsup=Draw::Atof(argv[6]);
1535 
1536   if (aSurface.IsNull()) {
1537     di << argv[2] << " Null surface \n" ;
1538     return 1;
1539   }
1540 
1541   GeomAPI_ProjectPointOnSurf PonSurf;
1542   PonSurf.Init(aSurface, Umin, Usup, Vmin, Vsup);
1543   PonSurf.Perform(aPoint3d);
1544 
1545   return 0;
1546 }
1547 
1548 //=======================================================================
1549 //function :  OCC909
1550 //purpose  :
1551 //=======================================================================
OCC909(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1552 static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1553 {
1554   if (argc!=3)
1555   {
1556     di<<"Usage : " << argv[0] << " wire face\n";
1557     return 1;
1558   }
1559 
1560   TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
1561   TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
1562   if (awire.IsNull() || aface.IsNull()) {
1563     di << "Null object\n";
1564     return 1;
1565   }
1566 
1567   Standard_Integer count = 0;
1568   TopExp_Explorer TE(awire, TopAbs_VERTEX);
1569   if ( TE.More()) {
1570     BRepTools_WireExplorer WE;
1571     for ( WE.Init(awire,aface); WE.More(); WE.Next()) {
1572       TopoDS_Edge E = WE.Current();
1573       count++;
1574     }
1575   }
1576   di << "Count = " << count << "\n";
1577 
1578   return 0;
1579 }
1580 
1581 //=======================================================================
1582 //function :  OCC921
1583 //purpose  :
1584 //=======================================================================
OCC921(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1585 static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1586 {
1587   if (argc != 2)
1588   {
1589     di <<"Usage : " << argv[0] << " face\n";
1590     return 1;
1591   }
1592   Standard_Real u1, u2, v1, v2;
1593   TopoDS_Face F = TopoDS::Face( DBRep::Get(argv[1]) ); //read the shape
1594   if (F.IsNull())
1595     return 1;
1596   BRepTools::UVBounds(F, u1, u2, v1, v2);
1597   di << "Bounds: " << u1 << "   " << u2 << "   " << v1 << "   " << v2 << "\n";
1598   return 0;
1599 }
1600 
1601 #include <Expr_NamedUnknown.hxx>
1602 #include <Expr_GeneralExpression.hxx>
1603 #include <Expr_Exponential.hxx>
1604 #include <ExprIntrp_GenExp.hxx>
1605 //=======================================================================
1606 //function :  OCC902
1607 //purpose  :
1608 //=======================================================================
OCC902(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1609 static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1610 {
1611   if (argc != 2)
1612   {
1613     di <<"Usage : " << argv[0] << " expression\n";
1614     return 1;
1615   }
1616 
1617   TCollection_AsciiString  anExpStr(argv[1]);
1618   anExpStr.AssignCat("*x");
1619   anExpStr.Prepend("Exp(");
1620   anExpStr.AssignCat(")");
1621 
1622   Handle(ExprIntrp_GenExp) exprIntrp = ExprIntrp_GenExp::Create();
1623 
1624   //
1625   // Create the expression
1626   exprIntrp->Process(anExpStr);
1627 
1628   if (!exprIntrp->IsDone())
1629   {
1630     di << "Interpretation of expression " << argv[1] << " failed\n";
1631     return 1;
1632   }
1633 
1634 
1635   Handle(Expr_GeneralExpression) anExpr = exprIntrp->Expression();
1636   Handle(Expr_NamedUnknown) aVar = new Expr_NamedUnknown("x");
1637   Handle (Expr_GeneralExpression) newExpr = anExpr->Derivative(aVar);
1638 
1639 
1640  TCollection_AsciiString  res        = newExpr->String();
1641  Standard_CString         resStr     = res.ToCString();
1642  TCollection_AsciiString  res_old    = anExpr->String();
1643  Standard_CString         res_oldStr = res_old.ToCString();
1644 
1645 
1646  di << "X = " << argv[1] << "\n";
1647  di << "Y = " << res_oldStr << "\n";
1648  di << "Y' = " << resStr  << "\n";
1649 
1650  return 0;
1651 }
1652 
1653 #include <DDF.hxx>
1654 #include <TPrsStd_AISViewer.hxx>
1655 #include <TDF_Label.hxx>
1656 #include <TPrsStd_AISPresentation.hxx>
1657 //=======================================================================
1658 //function : OCC1029_AISTransparency
1659 //purpose  : OCC1029_AISTransparency  (DOC,entry,[real])
1660 //=======================================================================
1661 
OCC1029_AISTransparency(Draw_Interpretor & di,Standard_Integer nb,const char ** arg)1662 static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
1663 					     Standard_Integer nb,
1664 					     const char ** arg)
1665 {
1666   if (nb >= 3 ) {
1667     Handle(TDocStd_Document) D;
1668     if (!DDocStd::GetDocument(arg[1],D)) return 1;
1669     TDF_Label L;
1670     if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1671 
1672     Handle(TPrsStd_AISViewer) viewer;
1673     if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1674 
1675     Handle(TPrsStd_AISPresentation) prs;
1676     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1677       if( nb == 4 ) {
1678 	prs->SetTransparency(Draw::Atof(arg[3]));
1679 	TPrsStd_AISViewer::Update(L);
1680       }
1681       else {
1682          di << "Transparency = " << prs->Transparency() << "\n";
1683       }
1684       return 0;
1685     }
1686   }
1687   di << arg[0] << " : Error\n";
1688   return 1;
1689 }
1690 
1691 //=======================================================================
1692 //function : OCC1031_AISMaterial
1693 //purpose  : OCC1031_AISMaterial (DOC,entry,[material])
1694 //=======================================================================
1695 
OCC1031_AISMaterial(Draw_Interpretor & di,Standard_Integer nb,const char ** arg)1696 static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
1697 					 Standard_Integer nb,
1698 					 const char ** arg)
1699 {
1700   if (nb >= 3) {
1701     Handle(TDocStd_Document) D;
1702     if (!DDocStd::GetDocument(arg[1],D)) return 1;
1703     TDF_Label L;
1704     if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1705 
1706     Handle(TPrsStd_AISViewer) viewer;
1707     if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1708 
1709     Handle(TPrsStd_AISPresentation) prs;
1710     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1711       if( nb == 4 ) {
1712 	prs->SetMaterial((Graphic3d_NameOfMaterial)Draw::Atoi(arg[3]));
1713 	TPrsStd_AISViewer::Update(L);
1714       }
1715       else {
1716          di << "Material = " << prs->Material() << "\n";
1717       }
1718       return 0;
1719     }
1720   }
1721   di << arg[0] << " : Error\n";
1722   return 1;
1723 }
1724 
1725 //=======================================================================
1726 //function : OCC1032_AISWidth
1727 //purpose  : OCC1032_AISWidth (DOC,entry,[width])
1728 //=======================================================================
1729 
OCC1032_AISWidth(Draw_Interpretor & di,Standard_Integer nb,const char ** arg)1730 static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
1731 				      Standard_Integer nb,
1732 				      const char ** arg)
1733 {
1734   if (nb >= 3) {
1735     Handle(TDocStd_Document) D;
1736     if (!DDocStd::GetDocument(arg[1],D)) return 1;
1737     TDF_Label L;
1738     if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1739 
1740     Handle(TPrsStd_AISViewer) viewer;
1741     if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1742 
1743     Handle(TPrsStd_AISPresentation) prs;
1744     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1745       if( nb == 4 ) {
1746 	prs->SetWidth(Draw::Atof(arg[3]));
1747 	TPrsStd_AISViewer::Update(L);
1748       }
1749       else {
1750          di << "Width = " << prs->Width() << "\n";
1751       }
1752       return 0;
1753     }
1754   }
1755   di << arg[0] << " : Error\n";
1756   return 1;
1757 }
1758 
1759 //=======================================================================
1760 //function : OCC1033_AISMode
1761 //purpose  : OCC1033_AISMode (DOC,entry,[mode])
1762 //=======================================================================
1763 
OCC1033_AISMode(Draw_Interpretor & di,Standard_Integer nb,const char ** arg)1764 static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
1765 				     Standard_Integer nb,
1766 				     const char ** arg)
1767 {
1768   if (nb >= 3) {
1769     Handle(TDocStd_Document) D;
1770     if (!DDocStd::GetDocument(arg[1],D)) return 1;
1771     TDF_Label L;
1772     if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1773 
1774     Handle(TPrsStd_AISViewer) viewer;
1775     if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1776 
1777     Handle(TPrsStd_AISPresentation) prs;
1778     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1779       if( nb == 4 ) {
1780 	prs->SetMode(Draw::Atoi(arg[3]));
1781 	TPrsStd_AISViewer::Update(L);
1782       }
1783       else {
1784          di << "Mode = " << prs->Mode() << "\n";
1785       }
1786       return 0;
1787     }
1788   }
1789   di << arg[0] << " : Error\n";
1790   return 1;
1791 }
1792 
1793 //=======================================================================
1794 //function : OCC1034_AISSelectionMode
1795 //purpose  : OCC1034_AISSelectionMode (DOC,entry,[selectionmode])
1796 //=======================================================================
1797 
OCC1034_AISSelectionMode(Draw_Interpretor & di,Standard_Integer nb,const char ** arg)1798 static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
1799 					      Standard_Integer nb,
1800 					      const char ** arg)
1801 {
1802   if (nb >= 3) {
1803     Handle(TDocStd_Document) D;
1804     if (!DDocStd::GetDocument(arg[1],D)) return 1;
1805     TDF_Label L;
1806     if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1807 
1808     Handle(TPrsStd_AISViewer) viewer;
1809     if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1810 
1811     Handle(TPrsStd_AISPresentation) prs;
1812     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1813       if( nb == 4 ) {
1814 	prs->SetSelectionMode(Draw::Atoi(arg[3]));
1815 	TPrsStd_AISViewer::Update(L);
1816       }
1817       else {
1818          di << "SelectionMode = " << prs->SelectionMode() << "\n";
1819       }
1820       return 0;
1821     }
1822   }
1823   di << arg[0] << " : Error\n";
1824   return 1;
1825 }
1826 
1827 //=======================================================================
1828 //function :  OCC1487
1829 //purpose  :
1830 //=======================================================================
OCC1487(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1831 static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1832 {
1833   if(argc != 5) {
1834     di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape\n";
1835     return 1;
1836   }
1837 
1838   Standard_Integer CaseNumber = Draw::Atoi(argv[1]);
1839 
1840   //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
1841   gp_Dir myDir(1,0,0);
1842   gp_Pnt myPnt(0,-50,140);
1843   gp_Ax2 myAx2(myPnt, myDir);
1844   BRepPrimAPI_MakeCylinder o_mc1 (myAx2, 50,1000);
1845 
1846   TopoDS_Shape cyl1 = o_mc1.Shape();
1847 
1848   TopoDS_Shape cyl2;
1849   TopoDS_Shape o_cut_shape;
1850   if (CaseNumber == 1) {
1851     //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(21.65064, -50.0, 127.5),gp_Dir(-sin(M_PI/3), 0.0, 0.5)), 5, 150);
1852     gp_Dir myDir_mc2(-sin(M_PI/3), 0.0, 0.5);
1853     gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
1854     gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
1855     BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
1856 
1857     cyl2 = o_mc2.Shape();
1858     di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
1859     o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ()).Shape();
1860   } else {
1861     //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(978.34936, -50.0, 127.5),gp_Dir(sin(M_PI/3), 0.0, 0.5)), 5, 150);
1862     gp_Dir myDir_mc2(sin(M_PI/3), 0.0, 0.5);
1863     gp_Pnt myPnt_mc2(978.34936, -50.0, 127.5);
1864     gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
1865     BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
1866 
1867     cyl2 = o_mc2.Shape();
1868     di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
1869     o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ()).Shape();
1870   }
1871 
1872   DBRep::Set(argv[2],cyl1);
1873   DBRep::Set(argv[3],cyl2);
1874   DBRep::Set(argv[4],o_cut_shape);
1875 
1876   return 0;
1877 }
1878 
1879 #include<TopTools_ListIteratorOfListOfShape.hxx>
1880 #include<BRepFilletAPI_MakeFillet.hxx>
1881 //=======================================================================
1882 //function :  OCC1077
1883 //purpose  :
1884 //=======================================================================
OCC1077_boolbl(BRepAlgoAPI_BooleanOperation & aBoolenaOperation,const Standard_Real aRadius)1885 TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
1886 {
1887   Standard_Real t3d = 1.e-4;
1888   Standard_Real t2d = 1.e-5;
1889   Standard_Real ta  = 1.e-2;
1890   Standard_Real fl  = 1.e-3;
1891   Standard_Real tapp_angle = 1.e-2;
1892   GeomAbs_Shape blend_cont = GeomAbs_C1;
1893 
1894   TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
1895 
1896   TopTools_ListIteratorOfListOfShape its;
1897 
1898   TopoDS_Compound result;
1899   BRep_Builder B;
1900   B.MakeCompound(result);
1901 
1902   TopExp_Explorer ex;
1903   for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
1904     {
1905       const TopoDS_Shape& cutsol = ex.Current();
1906 
1907       BRepFilletAPI_MakeFillet fill(cutsol);
1908       fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
1909       fill.SetContinuity(blend_cont, tapp_angle);
1910       its = aBoolenaOperation.SectionEdges();
1911       while (its.More())
1912 	{
1913 	  TopoDS_Edge E = TopoDS::Edge(its.Value());
1914 	  fill.Add(aRadius, E);
1915 	  its.Next();
1916 	}
1917 
1918       fill.Build();
1919       if (fill.IsDone())
1920 	{
1921 	  B.Add(result, fill.Shape());
1922 	}
1923       else
1924 	{
1925 	  B.Add(result, cutsol);
1926 	}
1927     }
1928   return result;
1929 }
1930 
OCC1077_cut_blend(const TopoDS_Shape & aShapeToCut,const TopoDS_Shape & aTool,const Standard_Real aRadius)1931 TopoDS_Shape OCC1077_cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
1932 {
1933   //return OCC1077_boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
1934   BRepAlgoAPI_Cut aCut(aShapeToCut, aTool);
1935   return OCC1077_boolbl(aCut,aRadius);
1936 }
1937 
1938 //TopoDS_Shape OCC1077_common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
1939 //{
1940 //  return OCC1077_boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
1941 //}
1942 
OCC1077_Bug()1943 TopoDS_Shape OCC1077_Bug()
1944 {
1945   TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10).Shape();
1946   TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7).Shape();
1947 
1948   TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
1949   TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10),
1950 							      gp_Dir(0, 0, 1)), 3, 20).Shape();
1951   TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0),
1952 							      gp_Dir(1, 0, 0)), 3, 20).Shape();
1953   TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
1954 							      gp_Dir(0, 1, 0)), 3, 20).Shape();
1955   TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
1956   Handle(ShapeFix_Shape) fixer = new ShapeFix_Shape(theTmp1);
1957   fixer->Perform();
1958   theTmp1 = fixer->Shape();
1959   TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
1960   fixer->Init(theTmp2);
1961   fixer->Perform();
1962   theTmp2 = fixer->Shape();
1963   TopoDS_Shape theResult = OCC1077_cut_blend(theTmp2,theCylinder3,0.7);
1964   fixer->Init(theResult);
1965   fixer->Perform();
1966   theResult = fixer->Shape();
1967   return theResult;
1968 }
1969 
OCC1077(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1970 static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1971 {
1972   if(argc < 1 || argc > 2) {
1973     di << "Usage : " << argv[0] << " result\n";
1974     return 1;
1975   }
1976 
1977   TopoDS_Shape S = OCC1077_Bug();
1978   DBRep::Set(argv[1],S);
1979 
1980   return 0;
1981 }
1982 
1983 //////////////////////////////////////////////////////////////
1984 /*!
1985  * Compute uniform distribution of points using GCPnts_UniformAbscissa
1986  */
1987 //////////////////////////////////////////////////////////////
OCC5739_UniAbs(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)1988 static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1989 {
1990   if (argc < 4)
1991   {
1992     di << "Usage : " << argv[0] << " name shape step\n";
1993     return 1;
1994   }
1995   const char *name = argv[1];
1996   Adaptor3d_Curve *adapCurve=NULL;
1997   Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
1998   if (!curve.IsNull())
1999     adapCurve = new GeomAdaptor_Curve(curve);
2000   else
2001   {
2002     TopoDS_Shape wire = DBRep::Get(argv[2]);
2003     if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
2004     {
2005       di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected\n";
2006       return 1;
2007     }
2008     adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
2009   }
2010   double step = Draw::Atof(argv[3]);
2011   GCPnts_UniformAbscissa aUni(*adapCurve, step);
2012   int res;
2013   if (!aUni.IsDone())
2014   {
2015     di << argv[0] <<" : fail\n";
2016     res = 1;
2017   }
2018   else
2019   {
2020     int i, np = aUni.NbPoints();
2021     for (i=0; i < np; i++)
2022     {
2023       double par = aUni.Parameter(i+1);
2024       gp_Pnt p = adapCurve->Value(par);
2025       char n[20], *pname=n;
2026       Sprintf(n,"%s_%d",name,i+1);
2027       DrawTrSurf::Set(pname,p);
2028       di<<pname<<" ";
2029     }
2030     res = 0;
2031   }
2032   delete adapCurve;
2033   return res;
2034 }
2035 
OCC6046(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)2036 static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2037 {
2038   if (argc != 3)
2039   {
2040     di << "Usage : " << argv[0] << " nb_of_vectors size\n";
2041     return 1;
2042   }
2043 
2044   Standard_Integer nb = Draw::Atoi(argv[1]);
2045   Standard_Integer sz = Draw::Atoi(argv[2]);
2046   Standard_Real val = 10;
2047   math_Vector **pv = new math_Vector *[nb];
2048 
2049   di<<"creating "<<nb<<" vectors "<<sz<<" elements each...\n";
2050   Standard_Integer i;
2051   for (i=0; i < nb; i++) {
2052     pv[i] = new math_Vector (1, sz, val);
2053     if ((i % (nb/10)) == 0) {
2054       di<<" "<<i;
2055       //std::cout.flush();
2056       di<<"\n";
2057     }
2058   }
2059   di<<" done\n";
2060   di<<"deleting them ...\n";
2061   for (i=0; i < nb; i++) {
2062     delete pv[i];
2063     if ((i % (nb/10)) == 0) {
2064       di<<" "<<i;
2065       //std::cout.flush();
2066       di<<"\n";
2067     }
2068   }
2069   di<<" done\n";
2070 
2071   delete [] pv;
2072 
2073   return 0;
2074 }
2075 
OCC5698(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)2076 static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2077 {
2078   if (argc != 2)
2079   {
2080     di << "Usage : " << argv[0] << " wire\n";
2081     return 1;
2082   }
2083   TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
2084   if (shape.IsNull())
2085     return 1;
2086   TopoDS_Wire wire = TopoDS::Wire(shape);
2087   // create curve parameterised by curvilinear distance
2088   BRepAdaptor_CompCurve curve(wire,Standard_True);
2089   Standard_Real length = curve.LastParameter();
2090   Standard_Real need_length = length/2;
2091   gp_Pnt pnt;
2092   curve.D0(need_length,pnt);
2093   // create check_curve parameterised in a general way
2094   BRepAdaptor_CompCurve check_curve(wire);
2095   Standard_Real check_par =
2096     GCPnts_AbscissaPoint(check_curve, need_length, 0).Parameter();
2097   gp_Pnt check_pnt;
2098   check_curve.D0(check_par,check_pnt);
2099   // check that points are coinciding
2100   Standard_Real error_dist = pnt.Distance(check_pnt);
2101   if (error_dist > Precision::Confusion()) {
2102     //std::cout.precision(3);
2103     di<<"error_dist = "<<error_dist<<
2104       "  ( "<<error_dist/need_length*100<<" %)\n";
2105     return 0;
2106   }
2107   di<<"OK\n";
2108   return 0;
2109 }
2110 
2111 // stack overflow can be successfully handled only on 32-bit Windows
2112 #if defined(_WIN32) && !defined(_WIN64)
StackOverflow(int i=-1)2113 static int StackOverflow (int i = -1)
2114 {
2115   char arr[2000];
2116   memset (arr, 0, sizeof(arr));
2117   if (i < 0)
2118     StackOverflow(i-1);
2119   return i;
2120 }
2121 #endif
2122 
2123 // this code does not work with optimize mode on Windows
2124 #if defined(_MSC_VER) && !defined(__clang__)
2125 #pragma optimize( "", off )
2126 #endif
OCC6143(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)2127 static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2128 {
2129   if (argc != 1)
2130     {
2131       std::cout << "Usage : " << argv[0] << "\n";
2132       return 1;
2133     }
2134   Standard_Boolean Succes;
2135 
2136   Succes = Standard_True;
2137   //OSD::SetSignal();
2138 
2139   {//==== Test Divide ByZero (Integer) ========================================
2140     try{
2141       OCC_CATCH_SIGNALS
2142       std::cout << "(Integer) Divide By Zero..." << std::endl;
2143       di << "(Integer) Divide By Zero...";
2144       //std::cout.flush();
2145       di << "\n";
2146       Standard_Integer res, a =4, b = 0 ;
2147       res = a / b;
2148       di << "Error: 4 / 0 = " << res << " - no exception is raised!\n";
2149       Succes = Standard_False;
2150     }
2151 #if defined(SOLARIS) || defined(_WIN32)
2152     catch(Standard_DivideByZero const&)
2153 #else
2154     catch(Standard_NumericError const&)
2155 #endif
2156     {
2157       di << "Caught, OK\n";
2158     }
2159     catch(Standard_Failure const& anException) {
2160       di << " Caught (";
2161       di << anException.GetMessageString();
2162       di << ")... KO\n";
2163       Succes = Standard_False;
2164     }
2165     // this case tests if (...) supersedes (Standard_*),
2166     // the normal behaviour is not
2167     catch(...) {
2168       di<<" unknown exception... (But) Ok\n";
2169     }
2170   }
2171 
2172   {//==== Test Divide ByZero (Real) ===========================================
2173     try{
2174       OCC_CATCH_SIGNALS
2175       std::cout << "(Real) Divide By Zero..." << std::endl;
2176       di << "(Real) Divide By Zero...";
2177       //std::cout.flush();
2178       di << "\n";
2179       Standard_Real res, a= 4.0, b=0.0;
2180       res = a / b;
2181       di << "Error: 4.0 / 0.0 = " << res << " - no exception is raised!\n";
2182       Succes = Standard_False;
2183     }
2184     catch(Standard_DivideByZero const&) // Solaris, Windows w/o SSE2
2185     {
2186       di << "Caught, OK\n";
2187     }
2188     catch(Standard_NumericError const&) // Linux, Windows with SSE2
2189     {
2190       di << "Caught, OK\n";
2191     }
2192     catch(Standard_Failure const& anException) {
2193       //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2194       di << " Caught (";
2195       di << anException.GetMessageString();
2196       di << ")... KO\n";
2197       Succes = Standard_False;
2198     }
2199   }
2200 
2201   {//==== Test Overflow (Integer) =============================================
2202     try{
2203       OCC_CATCH_SIGNALS
2204       std::cout << "(Integer) Overflow..." << std::endl;
2205       di << "(Integer) Overflow...";
2206       //std::cout.flush();
2207       di << "\n";
2208       Standard_Integer res, i=IntegerLast();
2209       res = i + 1;
2210       //++++ std::cout << " -- "<<res<<"="<<i<<"+1   Does not Caught... KO"<< std::endl;
2211       //++++ Succes = Standard_False;
2212       di << "Not caught: " << i << " + 1 = " << res << ", still OK\n";
2213     }
2214     catch(Standard_Overflow const&) {
2215       di << "Caught, OK\n";
2216     }
2217     catch(Standard_Failure const& anException) {
2218       //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2219       di << " Caught (";
2220       di << anException.GetMessageString();
2221       di << ")... KO\n";
2222       Succes = Standard_False;
2223     }
2224   }
2225 
2226   {//==== Test Overflow (Real) ================================================
2227     try{
2228       OCC_CATCH_SIGNALS
2229       std::cout << "(Real) Overflow..." << std::endl;
2230       di << "(Real) Overflow...";
2231       //std::cout.flush();
2232       di << "\n";
2233       Standard_Real res, r=RealLast();
2234       res = r * r;
2235 
2236       (void)sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
2237 
2238       di << "Error: " << r << "*" << r << " = " << res << " - no exception is raised!\n";
2239       Succes = Standard_False;
2240     }
2241     catch(Standard_Overflow const&) // Solaris, Windows w/o SSE2
2242     {
2243       di << "Caught, OK\n";
2244     }
2245     catch(Standard_NumericError const&) // Linux, Windows with SSE2
2246     {
2247       di << "Caught, OK\n";
2248     }
2249     catch(Standard_Failure const& anException) {
2250       //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2251       di << " Caught (";
2252       di << anException.GetMessageString();
2253       di << ")... KO\n";
2254       Succes = Standard_False;
2255     }
2256   }
2257 
2258   {//==== Test Underflow (Real) ===============================================
2259     try{
2260       OCC_CATCH_SIGNALS
2261       std::cout << "(Real) Underflow" << std::endl; // to have message in log even if process crashed
2262       di << "(Real) Underflow";
2263       //std::cout.flush();
2264       di << "\n";
2265       Standard_Real res, r = RealSmall();
2266       res = r * r;
2267       //res = res + 1.;
2268       //++++ std::cout<<"-- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... KO"<<std::endl;
2269       //++++ Succes = Standard_False;
2270       di << "Not caught: " << r << "*" << r << " = " << res << ", still OK\n";
2271     }
2272     catch(Standard_Underflow const&) // could be on Solaris, Windows w/o SSE2
2273     {
2274       di << "Exception caught, KO\n";
2275       Succes = Standard_False;
2276     }
2277     catch(Standard_NumericError const&) // could be on Linux, Windows with SSE2
2278     {
2279       di << "Exception caught, KO\n";
2280       Succes = Standard_False;
2281     }
2282     catch(Standard_Failure const& anException) {
2283       //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2284       di << " Caught (";
2285       di << anException.GetMessageString();
2286       di << ")... KO\n";
2287       Succes = Standard_False;
2288     }
2289   }
2290 
2291   {//==== Test Invalid Operation (Real) ===============================================
2292     try{
2293       OCC_CATCH_SIGNALS
2294       std::cout << "(Real) Invalid Operation..." << std::endl;
2295       di << "(Real) Invalid Operation...";
2296       //std::cout.flush();
2297       di << "\n";
2298       Standard_Real res, r=-1;
2299       res = sqrt(r);
2300       di << "Error: swrt(-1) = " << res << " - no exception is raised!\n";
2301       Succes = Standard_False;
2302     }
2303     catch(Standard_NumericError const&) {
2304       di << "Caught, OK\n";
2305     }
2306     catch(Standard_Failure const& anException) {
2307       //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2308       di << " Caught (";
2309       di << anException.GetMessageString();
2310       di << ")... KO\n";
2311       Succes = Standard_False;
2312     }
2313   }
2314 
2315   {//==== Test Access Violation ===============================================
2316     try {
2317       OCC_CATCH_SIGNALS
2318       std::cout << "Segmentation Fault..." << std::endl;
2319       di << "Segmentation Fault...";
2320       //std::cout.flush();
2321       di << "\n";
2322       int* pint=NULL;
2323       *pint = 4;
2324       di << "Error: writing by NULL address - no exception is raised!\n";
2325       Succes = Standard_False;
2326     }
2327 #ifdef _WIN32
2328     catch(OSD_Exception_ACCESS_VIOLATION const&)
2329 #else
2330     catch(OSD_SIGSEGV const&)
2331 #endif
2332     {
2333       di << "Caught, OK\n";
2334     } catch(Standard_Failure const& anException) {
2335       //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2336       di << " Caught (";
2337       di << anException.GetMessageString();
2338       di << ")... KO\n";
2339       Succes = Standard_False;
2340     }
2341   }
2342 
2343 #if defined(_WIN32) && !defined(_WIN64)
2344   {//==== Test Stack Overflow ===============================================
2345     try {
2346       OCC_CATCH_SIGNALS
2347       std::cout << "Stack Overflow..." << std::endl;
2348       di << "Stack Overflow...";
2349       //std::cout.flush();
2350       di << "\n";
2351       StackOverflow();
2352       di << "Error - no exception is raised!\n";
2353       Succes = Standard_False;
2354     }
2355     catch(OSD_Exception_STACK_OVERFLOW const&) {
2356       di << "Caught, OK\n";
2357     }
2358     catch(Standard_Failure const& anException) {
2359       //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2360       di << " Caught (";
2361       di << anException.GetMessageString();
2362       di << ")... KO\n";
2363       Succes = Standard_False;
2364     }
2365   }
2366 #endif
2367 
2368  if(Succes) {
2369    di << "TestExcept: Successful completion\n";
2370  } else {
2371    di << "TestExcept: failure\n";
2372  }
2373 
2374   return 0;
2375 }
2376 
2377 //! Auxiliary functor.
2378 struct TestParallelFunctor
2379 {
TestParallelFunctorTestParallelFunctor2380   TestParallelFunctor() : myNbNotRaised (0), myNbSigSegv (0), myNbUnknown (0) {}
2381 
NbNotRaisedTestParallelFunctor2382   Standard_Integer NbNotRaised() const { return myNbNotRaised; }
NbSigSegvTestParallelFunctor2383   Standard_Integer NbSigSegv()   const { return myNbSigSegv; }
NbUnknownTestParallelFunctor2384   Standard_Integer NbUnknown()   const { return myNbUnknown; }
2385 
operator ()TestParallelFunctor2386   void operator() (int theThreadId, int theTaskId) const
2387   {
2388     (void )theThreadId;
2389     (void )theTaskId;
2390 
2391     // Test Access Violation
2392     {
2393       try {
2394         OCC_CATCH_SIGNALS
2395         int* pint = NULL;
2396         *pint = 4;
2397         Standard_Atomic_Increment (&myNbNotRaised);
2398       }
2399     #ifdef _WIN32
2400       catch (OSD_Exception_ACCESS_VIOLATION const&)
2401     #else
2402       catch (OSD_SIGSEGV const&)
2403     #endif
2404       {
2405         Standard_Atomic_Increment (&myNbSigSegv);
2406       }
2407       catch (Standard_Failure const& )
2408       {
2409         Standard_Atomic_Increment (&myNbUnknown);
2410       }
2411     }
2412   }
2413 private:
2414   mutable volatile Standard_Integer myNbNotRaised;
2415   mutable volatile Standard_Integer myNbSigSegv;
2416   mutable volatile Standard_Integer myNbUnknown;
2417 };
2418 
OCC30775(Draw_Interpretor & theDI,Standard_Integer theNbArgs,const char **)2419 static Standard_Integer OCC30775 (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** )
2420 {
2421   if (theNbArgs != 1)
2422   {
2423     std::cout << "Syntax error: wrong number of arguments\n";
2424     return 1;
2425   }
2426 
2427   Handle(OSD_ThreadPool) aPool = new OSD_ThreadPool (4);
2428   OSD_ThreadPool::Launcher aLauncher (*aPool, 4);
2429   TestParallelFunctor aFunctor;
2430   aLauncher.Perform (0, 100, aFunctor);
2431   theDI << "NbRaised: "    << (aFunctor.NbSigSegv() + aFunctor.NbUnknown()) << "\n"
2432         << "NbNotRaised: " << aFunctor.NbNotRaised() << "\n"
2433         << "NbSigSeg: "    << aFunctor.NbSigSegv() << "\n"
2434         << "NbUnknown: "   << aFunctor.NbUnknown() << "\n";
2435   return 0;
2436 }
2437 
2438 #if defined(_MSC_VER) && !defined(__clang__)
2439 #pragma optimize( "", on )
2440 #endif
2441 
2442 // try disabling compiler optimizations and function inlining for proper stack
2443 // (VS2010 is skipped due to generation of extra compiler warnings)
2444 #if defined(_MSC_VER) && (_MSC_VER >= 1700) && !defined(__clang__)
2445   #pragma optimize( "", off)
2446 #endif
2447 //! Auxiliary functions for printing synthetic backtrace
2448 class MyTestInterface : public Standard_Transient
2449 {
2450 public:
2451   virtual int Standard_NOINLINE testMethod3 (int* theIntPtr, bool theToPrintStack) = 0;
2452 };
2453 
2454 class MyTestClass : public MyTestInterface
2455 {
2456 public:
MyTestClass()2457   MyTestClass() {}
testMethod3(int * theIntPtr,bool theToPrintStack)2458   virtual int Standard_NOINLINE testMethod3 (int* theIntPtr, bool theToPrintStack)
2459   {
2460     if (theToPrintStack)
2461     {
2462       char aMsg[4096] = {};
2463       Standard::StackTrace (aMsg, 4096, 10);
2464       std::cout << aMsg << "\n";
2465       return 0;
2466     }
2467     *theIntPtr = 4;
2468     return *theIntPtr;
2469   }
2470 };
2471 
myTestFunction2(int * theIntPtr,bool theToPrintStack)2472 static int Standard_NOINLINE myTestFunction2 (int* theIntPtr, bool theToPrintStack)
2473 {
2474   Handle(MyTestInterface) aTest = new MyTestClass();
2475   return aTest->testMethod3 (theIntPtr, theToPrintStack);
2476 }
2477 
myTestFunction1(bool theToPrintStack)2478 static void Standard_NOINLINE myTestFunction1 (bool theToPrintStack)
2479 {
2480   int* anIntPtr = NULL;
2481   myTestFunction2 (anIntPtr, theToPrintStack);
2482 }
2483 
OCC30762(Draw_Interpretor & theDI,Standard_Integer theNbArgs,const char **)2484 static Standard_NOINLINE Standard_Integer OCC30762 (Draw_Interpretor& theDI,
2485                                                     Standard_Integer theNbArgs,
2486                                                     const char** )
2487 {
2488   if (theNbArgs != 1)
2489   {
2490     theDI << "Syntax error: wrong number of arguments";
2491     return 1;
2492   }
2493 
2494   // just print stack
2495   std::cout << "Test normal backtrace...\n";
2496   myTestFunction1 (true);
2497 
2498   // test access violation
2499   {
2500     try
2501     {
2502       OCC_CATCH_SIGNALS
2503       std::cout << "Test segmentation Fault...\n";
2504       myTestFunction1 (false);
2505       std::cout << "Error: writing by NULL address - no exception is raised!\n";
2506     }
2507   #ifdef _WIN32
2508     catch (OSD_Exception_ACCESS_VIOLATION const& aSegException)
2509   #else
2510     catch (OSD_SIGSEGV const& aSegException)
2511   #endif
2512     {
2513       theDI << " Caught (";
2514       theDI << aSegException.GetMessageString();
2515       theDI << aSegException.GetStackString();
2516       theDI << ")... OK\n";
2517     }
2518     catch (Standard_Failure const& anException)
2519     {
2520       theDI << " Caught (";
2521       theDI << anException.GetMessageString();
2522       theDI << anException.GetStackString();
2523       theDI << ")... KO\n";
2524     }
2525   }
2526   return 0;
2527 }
2528 #if defined(_MSC_VER) && (_MSC_VER >= 1700) && !defined(__clang__)
2529   #pragma optimize( "", on)
2530 #endif
2531 
AddTestStructure(int nCount_)2532 static TopoDS_Compound AddTestStructure(int nCount_)
2533 {
2534   BRep_Builder B;
2535   int nCount=nCount_;
2536   TopoDS_Compound C;
2537   B.MakeCompound(C);
2538   BRepPrimAPI_MakeBox mkBox(1.0, 2.0, 3.0);
2539   for (int i=0; i<nCount; i++) {
2540     for (int j=0; j<nCount; j++) {
2541       gp_Trsf trsf;
2542       trsf.SetTranslationPart(gp_Vec(5.0*i, 05.0*j, 0.0));
2543       TopLoc_Location topLoc(trsf);
2544       TopoDS_Shape tempShape=mkBox.Shape().Located(topLoc);
2545       B.Add(C, tempShape);
2546     }
2547   }
2548   return C;
2549 }
2550 
OCC7141(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)2551 static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2552 {
2553   if (argc != 2 && argc != 3)
2554   {
2555     std::cout << "Usage : " << argv[0] << " [nCount] path\n";
2556     return 1;
2557   }
2558 
2559   int nCount = (argc > 2 ? Draw::Atoi(argv[1]) : 10);
2560   TCollection_AsciiString aFilePath (argv[argc > 2 ? 2 : 1]);
2561   STEPCAFControl_Writer writer;
2562   Handle(TDocStd_Document) document;
2563   document = new TDocStd_Document("Pace Test-StepExporter-");
2564   Handle(XCAFDoc_ShapeTool) shapeTool;
2565   shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
2566   shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
2567   STEPControl_StepModelType mode = STEPControl_AsIs;
2568   if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
2569     di << "Failed to set assembly mode for step data\n\n";
2570     return 0;
2571   }
2572   try {
2573     OCC_CATCH_SIGNALS
2574     if( writer.Transfer(document, mode)) {
2575     	writer.Write(aFilePath.ToCString());
2576     }
2577   }
2578   catch(OSD_Exception_STACK_OVERFLOW const&) {
2579     di << "Failed : STACK OVERFLOW\n\n";
2580   }
2581   catch (Standard_Failure const& anException) {
2582     di << "Failed :\n\n";
2583     //std::cout << Standard_Failure::Caught() << std::endl;
2584     di << anException.GetMessageString();
2585   }
2586   di << argv[0] << " : Finish\n";
2587 
2588   return 0;
2589 }
2590 
OCC7372(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)2591 static Standard_Integer OCC7372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2592 {
2593   if (argc != 1)
2594     {
2595       di << "Usage : " << argv[0] << "\n";
2596       return 1;
2597     }
2598 
2599   // 1. Create an array of points
2600   Handle(TColgp_HArray1OfPnt2d) ap = new TColgp_HArray1OfPnt2d(1,5);
2601   ap->SetValue(1,gp_Pnt2d(100.0,0.0));
2602   ap->SetValue(2,gp_Pnt2d(100.0,100.0));
2603   ap->SetValue(3,gp_Pnt2d(0.0,100.0));
2604   ap->SetValue(4,gp_Pnt2d(0.0,0.0));
2605   ap->SetValue(5,gp_Pnt2d(50.0,-50.0));
2606 
2607   // 2. Create a periodic bspline through these 5 points
2608   Geom2dAPI_Interpolate intp(ap,Standard_True,1e-6);
2609   intp.Perform();
2610   Handle(Geom2d_BSplineCurve) bspline1 = intp.Curve();
2611 
2612   // 3. Increase degree of curve from 3 to 8
2613   bspline1->IncreaseDegree(8); // Increase degree to demonstrate the error
2614   Standard_CString CString1 = "BSplineCurve";
2615   DrawTrSurf::Set(CString1,bspline1);
2616 
2617   // 4. Converts BSpline curve to Bezier segments
2618   Geom2dConvert_BSplineCurveToBezierCurve bc(bspline1);
2619 
2620   // 5. Test the result of conversion
2621   TCollection_AsciiString aRName;
2622   for(Standard_Integer i = 1; i <= bc.NbArcs(); i++) {
2623     Handle(Geom2d_BezierCurve) arc = bc.Arc(i);
2624     aRName="segment_";
2625     aRName=aRName+TCollection_AsciiString(i);
2626     Standard_CString aRNameStr = aRName.ToCString();
2627     DrawTrSurf::Set(aRNameStr,arc);
2628     di << aRNameStr << " ";
2629   }
2630 
2631   return 0;
2632 }
2633 
OCC8169(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)2634 static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2635 {
2636   if (argc != 4)
2637   {
2638     di << "Usage : " << argv[0] << " edge1 edge2 plane\n";
2639     return 1;
2640   }
2641   TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
2642   if (theEdge1.IsNull()) {
2643     di << "Invalid input shape " << argv[1] << "\n";
2644     return 1;
2645   }
2646   TopoDS_Edge theEdge2 = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
2647   if (theEdge2.IsNull()) {
2648     di << "Invalid input shape " << argv[2] << "\n";
2649     return 1;
2650   }
2651   TopoDS_Face theFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
2652   if (theFace.IsNull()) {
2653     di << "Invalid input shape " << argv[3] << "\n";
2654     return 1;
2655   }
2656 
2657   Handle(Geom_Surface) thePlane = BRep_Tool::Surface(theFace);
2658 
2659   Standard_Real aConfusion = Precision::Confusion();
2660   Standard_Real aP1first, aP1last, aP2first, aP2last;
2661 
2662   Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(theEdge1, aP1first, aP1last);
2663   Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(theEdge2, aP2first, aP2last);
2664   Handle(Geom2d_Curve) aCurve2d1 = GeomProjLib::Curve2d(aCurve1, aP1first, aP1last, thePlane);
2665   Handle(Geom2d_Curve) aCurve2d2 = GeomProjLib::Curve2d(aCurve2, aP2first, aP2last, thePlane);
2666 
2667   Geom2dAPI_InterCurveCurve anInter(aCurve2d1, aCurve2d2, aConfusion);
2668 
2669   Standard_Integer NbPoints = anInter.NbPoints();
2670 
2671   di << "NbPoints = " << NbPoints << "\n" ;
2672 
2673   if (NbPoints > 0) {
2674     Standard_Integer i;
2675     for (i=1; i<=NbPoints; i++) {
2676       gp_Pnt2d aPi = anInter.Point(i);
2677       di << "Point.X(" << i << ") = " << aPi.X() << "   Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
2678     }
2679   }
2680 
2681   Standard_Integer NbSegments = anInter.NbSegments();
2682 
2683   di << "\nNbSegments = " << NbSegments << "\n" ;
2684 
2685   if (NbSegments > 0) {
2686     IntRes2d_IntersectionSegment aSegment = anInter.Intersector().Segment(1);
2687 
2688     gp_Pnt2d aP1 = aCurve2d1->Value(aSegment.FirstPoint().ParamOnFirst());
2689     gp_Pnt2d aP2 = aCurve2d2->Value(aSegment.FirstPoint().ParamOnSecond());
2690 
2691     Standard_Real aDist = aP1.Distance(aP2);
2692 
2693     di << "aP1.X() = " << aP1.X() << "   aP1.Y() = " << aP1.Y() << "\n" ;
2694     di << "aP2.X() = " << aP2.X() << "   aP2.Y() = " << aP2.Y() << "\n" ;
2695 
2696     di << "Distance = " << aDist << "\n" ;
2697 
2698     di << "Confusion = " << aConfusion << "\n" ;
2699 
2700     if (aDist > aConfusion) {
2701       di << "\n" << argv[0] << " Faulty\n" ;
2702     } else {
2703       di << "\n" << argv[0] << " OK\n" ;
2704     }
2705   } else {
2706     di << "\n" << argv[0] << " OK\n" ;
2707   }
2708 
2709   return 0;
2710 }
OCC10138(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)2711 static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2712 {
2713   if (argc != 3)
2714   {
2715     di << "Usage : " << argv[0] << " lower upper\n";
2716     return 1;
2717   }
2718 
2719   Standard_Integer LOWER = Draw::Atoi(argv[1]);
2720   Standard_Integer UPPER = Draw::Atoi(argv[2]);
2721 
2722   //! 0. Create an empty document with several test labels
2723   Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
2724   doc->SetUndoLimit(100);
2725   TDF_Label main_label = doc->Main();
2726   TDF_Label label1 = main_label.FindChild(1, Standard_True);
2727   TDF_Label label2 = main_label.FindChild(2, Standard_True);
2728 
2729   //! 1. Set/Get OCAF attribute
2730   doc->OpenCommand();
2731   TDataStd_RealArray::Set(label1, LOWER, UPPER);
2732   Handle(TDataStd_RealArray) array;
2733   if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) &&
2734       array->Lower() == LOWER && array->Upper() == UPPER)
2735     std::cout<<"1: OK"<<std::endl;
2736   else
2737   {
2738     std::cout<<"1: Failed.."<<std::endl;
2739     return 1;
2740   }
2741   doc->CommitCommand();
2742 
2743   //! 2. Set/Get value
2744   doc->OpenCommand();
2745   Standard_Integer i;
2746   for (i = LOWER; i <= UPPER; i++)
2747     array->SetValue(i, i);
2748   for (i = LOWER; i <= UPPER; i++)
2749   {
2750     if (array->Value(i) != i)
2751     {
2752       std::cout<<"2: Failed.."<<std::endl;
2753       return 2;
2754     }
2755   }
2756   std::cout<<"2: OK"<<std::endl;
2757   doc->CommitCommand();
2758 
2759   //! 3. Re-init the array
2760   doc->OpenCommand();
2761   array->Init(LOWER + 2, UPPER + 4);
2762   if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4)
2763   {
2764     std::cout<<"3: Failed.."<<std::endl;
2765     return 3;
2766   }
2767   for (i = LOWER + 2; i <= UPPER + 4; i++)
2768     array->SetValue(i, i);
2769   for (i = LOWER + 2; i <= UPPER + 4; i++)
2770   {
2771     if (array->Value(i) != i)
2772     {
2773       std::cout<<"3: Failed.."<<std::endl;
2774       return 3;
2775     }
2776   }
2777   std::cout<<"3: OK"<<std::endl;
2778   doc->CommitCommand();
2779 
2780   //! 4. Change array
2781   doc->OpenCommand();
2782   Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(LOWER + 5, UPPER + 5);
2783   for (i = LOWER + 5; i <= UPPER + 5; i++)
2784     arr->SetValue(i, i);
2785   array->ChangeArray(arr);
2786   for (i = LOWER + 5; i <= UPPER + 5; i++)
2787   {
2788     if (array->Value(i) != i)
2789     {
2790       std::cout<<"4: Failed.."<<std::endl;
2791       return 4;
2792     }
2793   }
2794   std::cout<<"4: OK"<<std::endl;
2795   doc->CommitCommand();
2796 
2797   //! 5. Copy the array
2798   doc->OpenCommand();
2799   TDF_CopyLabel copier(label1, label2);
2800   copier.Perform();
2801   if (!copier.IsDone())
2802   {
2803     std::cout<<"5: Failed.."<<std::endl;
2804     return 5;
2805   }
2806   Handle(TDataStd_RealArray) array2;
2807   if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2808   {
2809     std::cout<<"5: Failed.."<<std::endl;
2810     return 5;
2811   }
2812   for (i = LOWER + 5; i <= UPPER + 5; i++)
2813   {
2814     if (array->Value(i) != i)
2815     {
2816       std::cout<<"5: Failed.."<<std::endl;
2817       return 5;
2818     }
2819   }
2820   std::cout<<"5: OK"<<std::endl;
2821   doc->CommitCommand();
2822 
2823   //! 6. Undo/Redo
2824   //! 6.a: undoes the 5th action: the copied array should disappear
2825   doc->Undo();
2826   if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2827       label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2828   {
2829     std::cout<<"6.a: Failed.."<<std::endl;
2830     return 6;
2831   }
2832   //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4)
2833   doc->Undo();
2834   if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2835       array->Lower() != LOWER + 2 ||
2836       array->Upper() != UPPER + 4)
2837   {
2838     std::cout<<"6.b: Failed.."<<std::endl;
2839     return 6;
2840   }
2841   for (i = LOWER + 2; i <= UPPER + 4; i++)
2842   {
2843     if (array->Value(i) != i)
2844     {
2845       std::cout<<"6.b: Failed.."<<std::endl;
2846       return 6;
2847     }
2848   }
2849   //! 6.c: undoes the 3d action: the array should be changed to (lower,upper)
2850   doc->Undo();
2851   if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2852       array->Lower() != LOWER ||
2853       array->Upper() != UPPER)
2854   {
2855     std::cout<<"6.c: Failed.."<<std::endl;
2856     return 6;
2857   }
2858   for (i = LOWER; i <= UPPER; i++)
2859   {
2860     if (array->Value(i) != i)
2861     {
2862       std::cout<<"6.c: Failed.."<<std::endl;
2863       return 6;
2864     }
2865   }
2866   //! 6.d: undoes and redoes the 2nd action: no change is expected.
2867   doc->Undo();
2868   doc->Redo();
2869   if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2870       array->Lower() != LOWER ||
2871       array->Upper() != UPPER)
2872   {
2873     std::cout<<"6.d: Failed.."<<std::endl;
2874     return 6;
2875   }
2876   for (i = LOWER; i <= UPPER; i++)
2877   {
2878     if (array->Value(i) != i)
2879     {
2880       std::cout<<"6.d: Failed.."<<std::endl;
2881       return 6;
2882     }
2883   }
2884   std::cout<<"6: OK"<<std::endl;
2885 
2886   //! 7. Re-set the array
2887   doc->OpenCommand();
2888   array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1);
2889   if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1)
2890   {
2891     std::cout<<"7: Failed.."<<std::endl;
2892     return 7;
2893   }
2894   for (i = LOWER + 1; i <= UPPER + 1; i++)
2895     array->SetValue(i, i);
2896   for (i = LOWER + 1; i <= UPPER + 1; i++)
2897   {
2898     if (array->Value(i) != i)
2899     {
2900       std::cout<<"7: Failed.."<<std::endl;
2901       return 7;
2902     }
2903   }
2904   std::cout<<"7: OK"<<std::endl;
2905   doc->CommitCommand();
2906 
2907   //! 8.Test of speed: set LOWER and UPPER equal to great integer number and
2908   //! measure the time spent by this test.
2909   //! Good luck!
2910 
2911   return 0;
2912 }
2913 
OCC7639(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)2914 static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2915 {
2916   Standard_Boolean IsEvenArgc =  Standard_True;
2917   if (argc % 2 == 0) {
2918     IsEvenArgc =  Standard_True;
2919   } else {
2920     IsEvenArgc =  Standard_False;
2921   }
2922 
2923   if (argc < 3 || IsEvenArgc)
2924     {
2925       di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]\n";
2926       return 1;
2927     }
2928 
2929   Standard_Integer i, aValue, aPosition;
2930   NCollection_Vector<int> vec;
2931   for (i = 0; i < argc - 1; i++) {
2932     i++;
2933     aValue = Draw::Atoi(argv[i]);
2934     aPosition = Draw::Atoi(argv[i+1]);
2935     vec.SetValue(aValue, aPosition);
2936   }
2937   NCollection_Vector<int>::Iterator it(vec);
2938   Standard_Integer j;
2939   for (j = 0; it.More(); it.Next(), j++) {
2940     //di << it.Value() << "\n";
2941     di << j << " " << it.Value() << "\n";
2942   }
2943 
2944   return 0;
2945 }
2946 
OCC8797(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)2947 static Standard_Integer OCC8797 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2948 {
2949   if (argc != 1) {
2950     di << "Usage : " << argv[0] << "\n";
2951     return 1;
2952   }
2953 
2954   gp_Pnt point(0.0,0.0,0.0);
2955 
2956   TColgp_Array1OfPnt poles(0,6);
2957   poles(0)=point;
2958 
2959   point.SetCoord(1.0,1.0,0.0);
2960   poles(1)=point;
2961 
2962   point.SetCoord(2.0,1.0,0.0);
2963   poles(2)=point;
2964 
2965   point.SetCoord(3.0,0.0,0.0);
2966   poles(3)=point;
2967 
2968   point.SetCoord(4.0,1.0,0.0);
2969   poles(4)=point;
2970 
2971   point.SetCoord(5.0,1.0,0.0);
2972   poles(5)=point;
2973 
2974   point.SetCoord(6.0,0.0,0.0);
2975   poles(6)=point;
2976 
2977   TColStd_Array1OfReal knots(0,2);
2978   knots(0)=0.0;
2979   knots(1)=0.5;
2980   knots(2)=1.0;
2981 
2982   TColStd_Array1OfInteger multi(0,2);
2983   multi(0)=4;
2984   multi(1)=3;
2985   multi(2)=4;
2986 
2987   Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles,knots,multi,3);
2988 
2989   //length!! 1.
2990   Standard_Real l_abcissa,l_gprop;
2991   GeomAdaptor_Curve adaptor_spline(spline);
2992   GCPnts_AbscissaPoint temp;
2993   l_abcissa=temp.Length(adaptor_spline);
2994   std::cout<<"Length Spline(abcissa_Pnt): "<<l_abcissa<<std::endl;
2995 
2996   //length!! 2.
2997   TopoDS_Edge edge = BRepBuilderAPI_MakeEdge (spline);
2998   GProp_GProps prop;
2999   BRepGProp::LinearProperties(edge,prop);
3000   l_gprop=prop.Mass();
3001   std::cout<<"Length Spline(GProp_GProps): "<<l_gprop<<std::endl;
3002 
3003   std::cout<<"Difference (abcissa_Pnt<->GProp_GProps): "<<l_gprop-l_abcissa<<std::endl;
3004 
3005   return 0;
3006 }
3007 
OCC7068(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)3008 static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3009 {
3010   if (argc != 1)
3011   {
3012     di << "Usage : " << argv[0] << "\n";
3013     return 1;
3014   }
3015 
3016   Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
3017   if(AISContext.IsNull())
3018   {
3019     di << "use 'vinit' command before " << argv[0] << "\n";
3020     return 1;
3021   }
3022 
3023   // ObjectsInside
3024   AIS_ListOfInteractive ListOfIO_1;
3025   AISContext->ObjectsInside(ListOfIO_1);
3026   di<< "ObjectsInside = " << ListOfIO_1.Extent() <<"\n";
3027   if (!ListOfIO_1.IsEmpty() ) {
3028     AIS_ListIteratorOfListOfInteractive iter;
3029     for (iter.Initialize(ListOfIO_1); iter.More() ; iter.Next() ) {
3030       Handle(AIS_InteractiveObject) aIO=iter.Value();
3031       di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3032     }
3033   }
3034 
3035   return 0;
3036 }
3037 
3038 // Test AIS_InteractiveContext::Hilight() call.
OCC31965(Draw_Interpretor & theDI,Standard_Integer theArgNb,const char ** theArgVec)3039 static Standard_Integer OCC31965 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3040 {
3041   if (theArgNb != 2)
3042   {
3043     theDI << "Syntax error: wrong number of arguments";
3044     return 1;
3045   }
3046 
3047   Handle(AIS_InteractiveObject) aPrs = GetMapOfAIS().Find2 (theArgVec[1]);
3048   ViewerTest::GetAISContext()->HilightWithColor (aPrs, ViewerTest::GetAISContext()->HighlightStyle (Prs3d_TypeOfHighlight_Dynamic), true);
3049   return 0;
3050 }
3051 
OCC11457(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)3052 static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3053 {
3054   if ((argc < 9) || (((argc-3) % 3) != 0))
3055   {
3056     di << "Usage : " << argv[0] << "polygon lastedge x1 y1 z1 x2 y2 z2 ...\n";
3057     return 1;
3058   }
3059   Standard_Integer i, j, np = (argc-3) / 3;
3060   BRepBuilderAPI_MakePolygon W;
3061   j = 3;
3062   for (i = 1; i <= np; i ++) {
3063     W.Add(gp_Pnt(Draw::Atof(argv[j]),Draw::Atof(argv[j+1]),Draw::Atof(argv[j+2])));
3064     j += 3;
3065   }
3066   W.Close();
3067   DBRep::Set(argv[1],W.Wire());
3068   DBRep::Set(argv[2],W.Edge());
3069   return 0;
3070 }
3071 
OCC13963(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)3072 static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3073 {
3074   if (argc < 5) {
3075     di << "Usage : " << argv[0] << " ratio origin_x origin_y origin_z\n";
3076     return 1;
3077   }
3078   gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
3079                gp_Dir(1., -1., 0.));
3080   gp_GTrsf aTrf;
3081   aTrf.SetAffinity (aPln, Draw::Atof(argv[4]));
3082   gp_XYZ aOrigin (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3083   gp_XYZ aResult (aOrigin);
3084   aTrf.Transforms(aResult);
3085   char sbf[512];
3086   Sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
3087           aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
3088           aResult.X(), aResult.Y(), aResult.Z());
3089   di<<sbf;
3090   return 0;
3091 }
3092 
OCC14376(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)3093 Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3094 {
3095   if (argc < 2) {
3096     di << "Usage : " << argv[0] << " shape [deflection]\n";
3097     return 1;
3098   }
3099 
3100   TopoDS_Shape aShape = DBRep::Get(argv[1]);
3101 
3102   if (aShape.IsNull()) {
3103     di<<" Null shape is not allowed";
3104     return 1;
3105   }
3106 
3107   Standard_Real aDeflection = 0.45110277533;
3108   if (argc > 2) {
3109     aDeflection = Draw::Atof(argv[2]);
3110   }
3111   di<<"deflection="<< aDeflection << "\n";
3112 
3113   BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI / 9.);
3114   TopLoc_Location aLocation;
3115   Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
3116 
3117   if(aTriang.IsNull()) {
3118     di << argv[0] << " : Faulty\n" ;
3119   } else {
3120     di << argv[0] << " : OK\n" ;
3121     di<<"NbNodes="<< aTriang->NbNodes()<< "\n";
3122     di<<"NbTriangles="<< aTriang->NbTriangles()<< "\n";
3123   }
3124   return 0;
3125 }
3126 
OCC15489(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)3127 static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3128 {
3129   if (argc != 4) {
3130     di << "Usage : " << argv[0] << " A B C\n";
3131     return 1;
3132   }
3133   try
3134     {
3135       gp_Lin2d aLin2d (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3136       gp_Pnt2d anOrigin = aLin2d.Location();
3137       di << "X_0 = " << anOrigin.X() << "   Y_0 = " << anOrigin.Y() << "\n" ;
3138     }
3139   catch(Standard_ConstructionError const&)
3140     {
3141       di << argv[0] << " Exception: Sqrt(A*A + B*B) <= Resolution from gp\n";
3142     }
3143   return 0;
3144 }
3145 
OCC15755(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)3146 static Standard_Integer OCC15755 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3147 {
3148   if (argc != 3) {
3149     di << "Usage : " << argv[0] << " file shape\n";
3150     return 1;
3151   }
3152 
3153   IGESControl_Reader aReader;
3154   aReader.ReadFile(argv[1]);
3155   aReader.SetReadVisible(Standard_True);
3156   aReader.TransferRoots();
3157 
3158   Handle(IGESData_IGESModel) model = aReader.IGESModel();
3159   if (model.IsNull()) {
3160     di << "model.IsNull()\n";
3161     return 1;
3162   }
3163   Standard_Integer nb = model->NbEntities();
3164   for (Standard_Integer i = 1; i <= nb; i ++) {
3165     Handle(IGESData_IGESEntity) ent = model->Entity(i);
3166     Handle(TCollection_HAsciiString) name;
3167     name = ent->NameValue();
3168     Standard_CString aStr = name->ToCString();
3169     di << "NameValue = " << aStr << "\n";
3170   }
3171 
3172   TopoDS_Shape shape = aReader.OneShape();
3173   DBRep::Set(argv[2],shape);
3174   return 0;
3175 }
3176 
3177 // For OCC16782 testing
3178 #include <AppStd_Application.hxx>
3179 #include <TDF_Tool.hxx>
3180 #include <TColStd_HArray1OfInteger.hxx>
3181 // Iterators
3182 #include <TColStd_ListIteratorOfListOfInteger.hxx>
3183 #include <TColStd_ListIteratorOfListOfReal.hxx>
3184 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
3185 #include <TDataStd_ListIteratorOfListOfByte.hxx>
3186 #include <TDF_ListIteratorOfLabelList.hxx>
3187 // Attributes
3188 #include <TDataStd_Tick.hxx>
3189 #include <TDataStd_IntegerList.hxx>
3190 #include <TDataStd_RealList.hxx>
3191 #include <TDataStd_ExtStringList.hxx>
3192 #include <TDataStd_BooleanList.hxx>
3193 #include <TDataStd_ReferenceList.hxx>
3194 #include <TDataStd_BooleanArray.hxx>
3195 #include <TDataStd_ReferenceArray.hxx>
3196 #include <TDataStd_ByteArray.hxx>
3197 #include <TDataStd_NamedData.hxx>
3198 #include <TDF_Reference.hxx>
3199 //
3200 Handle(AppStd_Application) app;
TestSetGet(const Handle (TDocStd_Document)& doc)3201 int TestSetGet(const Handle(TDocStd_Document)& doc)
3202 {
3203   // TDataStd_Tick:
3204   // Set
3205   TDataStd_Tick::Set(doc->Main());
3206   // Get
3207   Handle(TDataStd_Tick) tick;
3208   if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick))
3209     return 1;
3210   // Forget
3211   doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3212   if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3213     return 2;
3214   doc->Main().ResumeAttribute(tick);
3215   if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3216     return 3;
3217   // Forget
3218   doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3219   if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3220     return 2;
3221 
3222   // TDataStd_IntegerList:
3223   // Set
3224   Handle(TDataStd_IntegerList) setintlist = TDataStd_IntegerList::Set(doc->Main());
3225   setintlist->Append(2);
3226   setintlist->Prepend(1);
3227   setintlist->InsertAfter(3, 2);
3228   setintlist->InsertBefore(0, 1);
3229   setintlist->Append(200);
3230   setintlist->Remove(0);
3231   setintlist->Remove(200);
3232   // Get
3233   Handle(TDataStd_IntegerList) getintlist;
3234   if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist))
3235     return 1;
3236   if (getintlist->First() != 1)
3237     return 2;
3238   if (getintlist->Last() != 3)
3239     return 3;
3240   const TColStd_ListOfInteger& intlist = getintlist->List();
3241   TColStd_ListIteratorOfListOfInteger itr_intlist(intlist);
3242   for (; itr_intlist.More(); itr_intlist.Next())
3243   {
3244     if (itr_intlist.Value() != 1 &&
3245 	itr_intlist.Value() != 2 &&
3246 	itr_intlist.Value() != 3)
3247     {
3248       return 4;
3249     }
3250   }
3251   getintlist->Clear();
3252 
3253   // TDataStd_RealList:
3254   // Set
3255   Handle(TDataStd_RealList) setdbllist = TDataStd_RealList::Set(doc->Main());
3256   setdbllist->Append(2.5);
3257   setdbllist->Prepend(1.5);
3258   setdbllist->InsertAfter(3.5, 2.5);
3259   setdbllist->InsertBefore(0.5, 1.5);
3260   setdbllist->Append(200.5);
3261   setdbllist->Remove(0.5);
3262   setdbllist->Remove(200.5);
3263   // Get
3264   Handle(TDataStd_RealList) getdbllist;
3265   if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist))
3266     return 1;
3267   if (getdbllist->First() != 1.5)
3268     return 2;
3269   if (getdbllist->Last() != 3.5)
3270     return 3;
3271   const TColStd_ListOfReal& dbllist = getdbllist->List();
3272   TColStd_ListIteratorOfListOfReal itr_dbllist(dbllist);
3273   for (; itr_dbllist.More(); itr_dbllist.Next())
3274   {
3275     if (itr_dbllist.Value() != 1.5 &&
3276 	itr_dbllist.Value() != 2.5 &&
3277 	itr_dbllist.Value() != 3.5)
3278     {
3279       return 4;
3280     }
3281   }
3282   getdbllist->Clear();
3283 
3284   // TDataStd_ExtStringList:
3285   // Set
3286   Handle(TDataStd_ExtStringList) setstrlist = TDataStd_ExtStringList::Set(doc->Main());
3287   setstrlist->Append("Hello");
3288   setstrlist->Prepend("Guten Tag");
3289   setstrlist->InsertAfter("Bonjour", "Guten Tag");
3290   setstrlist->InsertBefore("Bonsoir", "Hello");
3291   setstrlist->Append("Good bye");
3292   setstrlist->Remove("Bonsoir");
3293   setstrlist->Remove("Good bye");
3294   // Get
3295   Handle(TDataStd_ExtStringList) getstrlist;
3296   if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist))
3297     return 1;
3298   if (getstrlist->First() != "Guten Tag")
3299     return 2;
3300   if (getstrlist->Last() != "Hello")
3301     return 3;
3302   const TDataStd_ListOfExtendedString& strlist = getstrlist->List();
3303   TDataStd_ListIteratorOfListOfExtendedString itr_strlist(strlist);
3304   for (; itr_strlist.More(); itr_strlist.Next())
3305   {
3306     if (itr_strlist.Value() != "Guten Tag" &&
3307 	itr_strlist.Value() != "Bonjour" &&
3308 	itr_strlist.Value() != "Hello")
3309     {
3310       return 4;
3311     }
3312   }
3313   getstrlist->Clear();
3314 
3315   // TDataStd_BooleanList:
3316   // Set
3317   Handle(TDataStd_BooleanList) setboollist = TDataStd_BooleanList::Set(doc->Main());
3318   setboollist->Append(Standard_True);
3319   setboollist->Prepend(Standard_False);
3320   // Get
3321   Handle(TDataStd_BooleanList) getboollist;
3322   if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist))
3323     return 1;
3324   if (getboollist->First() != Standard_False)
3325     return 2;
3326   if (getboollist->Last() != Standard_True)
3327     return 3;
3328   const TDataStd_ListOfByte& boollist = getboollist->List();
3329   for (TDataStd_ListIteratorOfListOfByte itr_boollist(boollist); itr_boollist.More(); itr_boollist.Next())
3330   {
3331     if (itr_boollist.Value() != 1
3332      && itr_boollist.Value() != 0)
3333     {
3334       return 4;
3335     }
3336   }
3337   getboollist->Clear();
3338 
3339   // TDataStd_ReferenceList:
3340   TDF_Label L1 = doc->Main().FindChild(100);
3341   TDF_Label L2 = doc->Main().FindChild(101);
3342   TDF_Label L3 = doc->Main().FindChild(102);
3343   TDF_Label L4 = doc->Main().FindChild(103);
3344   TDF_Label L5 = doc->Main().FindChild(104);
3345   // Set
3346   Handle(TDataStd_ReferenceList) setreflist = TDataStd_ReferenceList::Set(doc->Main());
3347   setreflist->Append(L1);
3348   setreflist->Prepend(L2);
3349   setreflist->InsertAfter(L3, L2);
3350   setreflist->InsertBefore(L4, L1);
3351   setreflist->Append(L5);
3352   setreflist->Remove(L4);
3353   setreflist->Remove(L5);
3354   // Get
3355   Handle(TDataStd_ReferenceList) getreflist;
3356   if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist))
3357     return 1;
3358   if (getreflist->First() != L2)
3359     return 2;
3360   if (getreflist->Last() != L1)
3361     return 3;
3362   const TDF_LabelList& reflist = getreflist->List();
3363   TDF_ListIteratorOfLabelList itr_reflist(reflist);
3364   for (; itr_reflist.More(); itr_reflist.Next())
3365   {
3366     if (itr_reflist.Value() != L1 &&
3367 	itr_reflist.Value() != L2 &&
3368 	itr_reflist.Value() != L3)
3369     {
3370       return 4;
3371     }
3372   }
3373   getreflist->Clear();
3374 
3375   // TDataStd_BooleanArray:
3376   // Set
3377   Handle(TDataStd_BooleanArray) setboolarr = TDataStd_BooleanArray::Set(doc->Main(), 12, 16);
3378   setboolarr->SetValue(12, Standard_True);
3379   setboolarr->SetValue(13, Standard_False);
3380   setboolarr->SetValue(14, Standard_False);
3381   setboolarr->SetValue(15, Standard_False);
3382   setboolarr->SetValue(16, Standard_True);
3383   setboolarr->SetValue(14, Standard_True);
3384   // Get
3385   Handle(TDataStd_BooleanArray) getboolarr;
3386   if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr))
3387     return 1;
3388   if (getboolarr->Value(12) != Standard_True)
3389     return 2;
3390   if (getboolarr->Value(13) != Standard_False)
3391     return 2;
3392   if (getboolarr->Value(14) != Standard_True)
3393     return 2;
3394   if (getboolarr->Value(15) != Standard_False)
3395     return 2;
3396   if (getboolarr->Value(16) != Standard_True)
3397     return 2;
3398 
3399   // TDataStd_ReferenceArray:
3400   // Set
3401   Handle(TDataStd_ReferenceArray) setrefarr = TDataStd_ReferenceArray::Set(doc->Main(), 0, 4);
3402   setrefarr->SetValue(0, L1);
3403   setrefarr->SetValue(1, L2);
3404   setrefarr->SetValue(2, L3);
3405   setrefarr->SetValue(3, L4);
3406   setrefarr->SetValue(4, L5);
3407   // Get
3408   Handle(TDataStd_ReferenceArray) getrefarr;
3409   if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr))
3410     return 1;
3411   if (getrefarr->Value(0) != L1)
3412     return 2;
3413   if (getrefarr->Value(1) != L2)
3414     return 2;
3415   if (getrefarr->Value(2) != L3)
3416     return 2;
3417   if (getrefarr->Value(3) != L4)
3418     return 2;
3419   if (getrefarr->Value(4) != L5)
3420     return 2;
3421 
3422   // TDataStd_ByteArray:
3423   // Set
3424   Handle(TDataStd_ByteArray) setbytearr = TDataStd_ByteArray::Set(doc->Main(), 12, 16);
3425   setbytearr->SetValue(12, 0);
3426   setbytearr->SetValue(13, 1);
3427   setbytearr->SetValue(14, 2);
3428   setbytearr->SetValue(15, 3);
3429   setbytearr->SetValue(16, 255);
3430   // Get
3431   Handle(TDataStd_ByteArray) getbytearr;
3432   if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr))
3433     return 1;
3434   if (getbytearr->Value(12) != 0)
3435     return 2;
3436   if (getbytearr->Value(13) != 1)
3437     return 2;
3438   if (getbytearr->Value(14) != 2)
3439     return 2;
3440   if (getbytearr->Value(15) != 3)
3441     return 2;
3442   if (getbytearr->Value(16) != 255)
3443     return 2;
3444 
3445   // TDataStd_NamedData:
3446   // Set:
3447   Handle(TDataStd_NamedData) setnd = TDataStd_NamedData::Set(doc->Main());
3448   setnd->SetInteger("Integer1", 1);
3449   setnd->SetInteger("Integer2", 2);
3450   setnd->SetInteger("Integer3", 8);
3451   setnd->SetInteger("Integer3", 3);
3452   // Get:
3453   Handle(TDataStd_NamedData) getnd;
3454   if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd))
3455     return 1;
3456   if (!getnd->HasIntegers())
3457     return 2;
3458   if (!getnd->HasInteger("Integer1"))
3459     return 3;
3460   if (getnd->GetInteger("Integer2") != 2)
3461     return 4;
3462   if (getnd->GetInteger("Integer3") != 3)
3463     return 4;
3464 
3465   return 0;
3466 }
3467 
TestUndoRedo(const Handle (TDocStd_Document)& doc)3468 int TestUndoRedo(const Handle(TDocStd_Document)& doc)
3469 {
3470   // TDataStd_Tick:
3471   doc->OpenCommand();
3472   Handle(TDataStd_Tick) tick = TDataStd_Tick::Set(doc->Main());
3473   doc->CommitCommand();
3474   if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3475     return 1;
3476   doc->Undo();
3477   if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3478     return 2;
3479   doc->Redo();
3480   if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3481     return 3;
3482 
3483   // TDataStd_IntegerList:
3484   doc->OpenCommand();
3485   Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc->Main());
3486   intlist->Append(2);
3487   intlist->Prepend(1);
3488   intlist->InsertBefore(0, 1);
3489   intlist->InsertAfter(3, 2);
3490   doc->CommitCommand();
3491   if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID()))
3492     return 1;
3493   doc->Undo();
3494   if (!intlist->IsEmpty())
3495     return 2;
3496   doc->Redo();
3497   if (!intlist->Extent())
3498     return 3;
3499   if (intlist->First() != 0)
3500     return 4;
3501   if (intlist->Last() != 3)
3502     return 5;
3503   intlist->Clear();
3504 
3505   // TDataStd_RealList:
3506   doc->OpenCommand();
3507   Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc->Main());
3508   dbllist->Append(2.5);
3509   dbllist->Prepend(1.5);
3510   dbllist->InsertBefore(0.5, 1.5);
3511   dbllist->InsertAfter(3.5, 2.5);
3512   doc->CommitCommand();
3513   if (!doc->Main().IsAttribute(TDataStd_RealList::GetID()))
3514     return 1;
3515   doc->Undo();
3516   if (!dbllist->IsEmpty())
3517     return 2;
3518   doc->Redo();
3519   if (!dbllist->Extent())
3520     return 3;
3521   if (dbllist->First() != 0.5)
3522     return 4;
3523   if (dbllist->Last() != 3.5)
3524     return 5;
3525   dbllist->Clear();
3526 
3527   // TDataStd_ExtStringList:
3528   doc->OpenCommand();
3529   Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc->Main());
3530   strlist->Append("Hello");
3531   strlist->Prepend("Guten Tag");
3532   strlist->InsertAfter("Bonjour", "Guten Tag");
3533   strlist->InsertBefore("Bonsoir", "Hello");
3534   doc->CommitCommand();
3535   if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID()))
3536     return 1;
3537   doc->Undo();
3538   if (!strlist->IsEmpty())
3539     return 2;
3540   doc->Redo();
3541   if (!strlist->Extent())
3542     return 3;
3543   if (strlist->First() != "Guten Tag")
3544     return 4;
3545   if (strlist->Last() != "Hello")
3546     return 5;
3547   strlist->Clear();
3548 
3549   // TDataStd_BooleanList:
3550   doc->OpenCommand();
3551   Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc->Main());
3552   boollist->Append(Standard_True);
3553   boollist->Prepend(Standard_False);
3554   doc->CommitCommand();
3555   if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID()))
3556     return 1;
3557   doc->Undo();
3558   if (!boollist->IsEmpty())
3559     return 2;
3560   doc->Redo();
3561   if (!boollist->Extent())
3562     return 3;
3563   if (boollist->First() != Standard_False)
3564     return 4;
3565   if (boollist->Last() != Standard_True)
3566     return 5;
3567   boollist->Clear();
3568 
3569   // TDataStd_ReferenceList:
3570   TDF_Label L1 = doc->Main().FindChild(100);
3571   TDF_Label L2 = doc->Main().FindChild(101);
3572   TDF_Label L3 = doc->Main().FindChild(102);
3573   TDF_Label L4 = doc->Main().FindChild(103);
3574   doc->OpenCommand();
3575   Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc->Main());
3576   reflist->Append(L1);
3577   reflist->Prepend(L2);
3578   reflist->InsertBefore(L3, L1);
3579   reflist->InsertAfter(L4, L2);
3580   doc->CommitCommand();
3581   if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID()))
3582     return 1;
3583   doc->Undo();
3584   if (!reflist->IsEmpty())
3585     return 2;
3586   doc->Redo();
3587   if (!reflist->Extent())
3588     return 3;
3589   if (reflist->First() != L2)
3590     return 4;
3591   if (reflist->Last() != L1)
3592     return 5;
3593   reflist->Clear();
3594 
3595   // TDataStd_BooleanArray:
3596   doc->OpenCommand();
3597   Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc->Main(), 23, 25);
3598   boolarr->SetValue(23, Standard_True);
3599   boolarr->SetValue(25, Standard_True);
3600   doc->CommitCommand();
3601   doc->OpenCommand();
3602   boolarr = TDataStd_BooleanArray::Set(doc->Main(), 230, 250);
3603   boolarr->SetValue(230, Standard_True);
3604   boolarr->SetValue(250, Standard_True);
3605   doc->CommitCommand();
3606   doc->Undo();
3607   if (boolarr->Value(23) != Standard_True)
3608     return 2;
3609   if (boolarr->Value(24) != Standard_False)
3610     return 2;
3611   if (boolarr->Value(25) != Standard_True)
3612     return 2;
3613   doc->Redo();
3614   if (boolarr->Value(230) != Standard_True)
3615     return 3;
3616   if (boolarr->Value(240) != Standard_False)
3617     return 3;
3618   if (boolarr->Value(250) != Standard_True)
3619     return 3;
3620 
3621   // TDataStd_ReferenceArray:
3622   doc->OpenCommand();
3623   Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc->Main(), 5, 8);
3624   refarr->SetValue(5, L1);
3625   refarr->SetValue(6, L2);
3626   refarr->SetValue(7, L3);
3627   refarr->SetValue(8, L4);
3628   doc->CommitCommand();
3629   if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID()))
3630     return 1;
3631   doc->Undo();
3632   doc->Redo();
3633   if (refarr->Value(5) != L1)
3634     return 4;
3635   if (refarr->Value(6) != L2)
3636     return 4;
3637   if (refarr->Value(7) != L3)
3638     return 4;
3639   if (refarr->Value(8) != L4)
3640     return 4;
3641 
3642   // TDataStd_ByteArray:
3643   doc->OpenCommand();
3644   Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc->Main(), 23, 25);
3645   bytearr->SetValue(23, 23);
3646   bytearr->SetValue(25, 25);
3647   doc->CommitCommand();
3648   doc->OpenCommand();
3649   bytearr = TDataStd_ByteArray::Set(doc->Main(), 230, 250);
3650   bytearr->SetValue(230, 230);
3651   bytearr->SetValue(250, 250);
3652   doc->CommitCommand();
3653   doc->Undo();
3654   if (bytearr->Value(23) != 23)
3655     return 2;
3656   if (bytearr->Value(25) != 25)
3657     return 2;
3658   doc->Redo();
3659   if (bytearr->Value(230) != 230)
3660     return 3;
3661   if (bytearr->Value(250) != 250)
3662     return 3;
3663 
3664   // TDataStd_NamedData:
3665   doc->OpenCommand();
3666   Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(doc->Main());
3667   nd->SetByte("b14", 12);
3668   nd->SetByte("b17", 18);
3669   nd->SetByte("b14", 14);
3670   nd->SetByte("b17", 17);
3671   doc->CommitCommand();
3672   doc->OpenCommand();
3673   nd = TDataStd_NamedData::Set(doc->Main());
3674   nd->SetReal("r14", 14);
3675   nd->SetReal("r17", 17);
3676   nd->SetReal("r14", 14.4);
3677   nd->SetReal("r17", 17.7);
3678   doc->CommitCommand();
3679   doc->Undo();
3680   if (nd->HasStrings())
3681     return 1;
3682   if (nd->HasReals())
3683     return 1;
3684   if (nd->HasReal("r17"))
3685     return 2;
3686   if (!nd->HasBytes())
3687     return 3;
3688   if (nd->GetByte("b14") != 14)
3689     return 4;
3690   if (nd->GetByte("b17") != 17)
3691     return 4;
3692   if (nd->HasByte("b18"))
3693     return 5;
3694   doc->Redo();
3695   if (!nd->HasBytes())
3696     return 1;
3697   if (!nd->HasReals())
3698     return 1;
3699   if (nd->GetByte("b14") != 14)
3700     return 2;
3701   if (nd->GetReal("r14") != 14.4)
3702     return 2;
3703   if (nd->GetReal("r17") != 17.7)
3704     return 2;
3705 
3706   return 0;
3707 }
3708 
TestCopyPaste(const Handle (TDocStd_Document)& doc)3709 int TestCopyPaste(const Handle(TDocStd_Document)& doc)
3710 {
3711   TDF_Label L1 = doc->Main().FindChild(1);
3712   TDF_Label L2 = doc->Main().FindChild(2);
3713   TDF_CopyLabel copier(L1, L2);
3714 
3715   // TDataStd_Tick:
3716   TDataStd_Tick::Set(L1);
3717   copier.Perform();
3718   if (!copier.IsDone())
3719     return 1;
3720   if (!L2.IsAttribute(TDataStd_Tick::GetID()))
3721     return 2;
3722 
3723   // TDataStd_IntegerList:
3724   Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(L1);
3725   intlist->Append(1);
3726   intlist->InsertAfter(2, 1);
3727   copier.Perform();
3728   if (!copier.IsDone())
3729     return 1;
3730   intlist->Clear();
3731   intlist.Nullify();
3732   if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3733     return 2;
3734   if (intlist->First() != 1)
3735     return 3;
3736   if (intlist->Last() != 2)
3737     return 4;
3738   intlist->Clear();
3739 
3740   // TDataStd_RealList:
3741   Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(L1);
3742   dbllist->Append(1.5);
3743   dbllist->InsertAfter(2.5, 1.5);
3744   copier.Perform();
3745   if (!copier.IsDone())
3746     return 1;
3747   dbllist->Clear();
3748   dbllist.Nullify();
3749   if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist))
3750     return 2;
3751   if (dbllist->First() != 1.5)
3752     return 3;
3753   if (dbllist->Last() != 2.5)
3754     return 4;
3755   dbllist->Clear();
3756 
3757   // TDataStd_ExtStringList:
3758   Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(L1);
3759   strlist->Append("Open CASCADE");
3760   strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE");
3761   copier.Perform();
3762   if (!copier.IsDone())
3763     return 1;
3764   strlist->Clear();
3765   strlist.Nullify();
3766   if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
3767     return 2;
3768   if (strlist->First() != "Open CASCADE")
3769     return 3;
3770   if (strlist->Last() != " - is the best set of libraries!")
3771     return 4;
3772   strlist->Clear();
3773 
3774   // TDataStd_BooleanList:
3775   Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(L1);
3776   boollist->Append(Standard_True);
3777   boollist->Prepend(Standard_False);
3778   copier.Perform();
3779   if (!copier.IsDone())
3780     return 1;
3781   boollist->Clear();
3782   boollist.Nullify();
3783   if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist))
3784     return 2;
3785   if (boollist->First() != Standard_False)
3786     return 3;
3787   if (boollist->Last() != Standard_True)
3788     return 4;
3789   boollist->Clear();
3790 
3791   // TDataStd_ReferenceList:
3792   TDF_Label L100 = doc->Main().FindChild(100);
3793   TDF_Label L101 = doc->Main().FindChild(101);
3794   Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(L1);
3795   reflist->Append(L100);
3796   reflist->InsertAfter(L101, L100);
3797   copier.Perform();
3798   if (!copier.IsDone())
3799     return 1;
3800   reflist->Clear();
3801   reflist.Nullify();
3802   if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
3803     return 2;
3804   if (reflist->First() != L100)
3805     return 3;
3806   if (reflist->Last() != L101)
3807     return 4;
3808   reflist->Clear();
3809 
3810   // TDataStd_BooleanArray:
3811   Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(L1, 4, 6);
3812   boolarr->SetValue(4, Standard_True);
3813   boolarr->SetValue(6, Standard_True);
3814   copier.Perform();
3815   if (!copier.IsDone())
3816     return 1;
3817   boolarr.Nullify();
3818   if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
3819     return 2;
3820   if (boolarr->Value(4) != Standard_True)
3821     return 3;
3822   if (boolarr->Value(5) != Standard_False)
3823     return 3;
3824   if (boolarr->Value(6) != Standard_True)
3825     return 3;
3826 
3827   // TDataStd_ReferenceArray:
3828   Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(L1, 3, 4);
3829   refarr->SetValue(3, L100);
3830   refarr->SetValue(4, L101);
3831   copier.Perform();
3832   if (!copier.IsDone())
3833     return 1;
3834   refarr.Nullify();
3835   if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
3836     return 2;
3837   if (refarr->Value(3) != L100)
3838     return 3;
3839   if (refarr->Value(4) != L101)
3840     return 3;
3841 
3842   // TDataStd_ByteArray:
3843   Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(L1, 4, 6);
3844   bytearr->SetValue(4, 40);
3845   bytearr->SetValue(6, 60);
3846   copier.Perform();
3847   if (!copier.IsDone())
3848     return 1;
3849   bytearr.Nullify();
3850   if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
3851     return 2;
3852   if (bytearr->Value(4) != 40)
3853     return 3;
3854   if (bytearr->Value(6) != 60)
3855     return 3;
3856 
3857   // TDataStd_NamedData:
3858   Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(L1);
3859   nd->SetInteger("Integer1", 11);
3860   nd->SetReal("Real1", 11.1);
3861   nd->SetString("String1", "11.11111111");
3862   nd->SetByte("Byte1", 111);
3863   Handle(TColStd_HArray1OfInteger) ints_arr = new TColStd_HArray1OfInteger(4, 5);
3864   ints_arr->SetValue(4, 4);
3865   ints_arr->SetValue(5, 5);
3866   nd->SetArrayOfIntegers("Integers1", ints_arr);
3867   copier.Perform();
3868   if (!copier.IsDone())
3869     return 1;
3870   nd.Nullify();
3871   if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd))
3872     return 2;
3873   if (!nd->HasIntegers())
3874     return 3;
3875   if (!nd->HasReals())
3876     return 3;
3877   if (!nd->HasStrings())
3878     return 3;
3879   if (!nd->HasBytes())
3880     return 3;
3881   if (!nd->HasArraysOfIntegers())
3882     return 3;
3883   if (nd->HasArraysOfReals())
3884     return 3;
3885   if (!nd->HasInteger("Integer1"))
3886     return 4;
3887   if (nd->GetInteger("Integer1") != 11)
3888     return 4;
3889   if (!nd->HasReal("Real1"))
3890     return 4;
3891   if (nd->GetReal("Real1") != 11.1)
3892     return 4;
3893   if (!nd->HasString("String1"))
3894     return 4;
3895   if (nd->GetString("String1") != "11.11111111")
3896     return 4;
3897   if (!nd->HasByte("Byte1"))
3898     return 4;
3899   if (nd->GetByte("Byte1") != 111)
3900     return 4;
3901   if (!nd->HasArrayOfIntegers("Integers1"))
3902     return 4;
3903   const Handle(TColStd_HArray1OfInteger)& ints_arr_out = nd->GetArrayOfIntegers("Integers1");
3904   if (ints_arr_out.IsNull())
3905     return 4;
3906   if (ints_arr_out->Value(5) != 5)
3907     return 4;
3908 
3909   return 0;
3910 }
3911 
TestOpenSave(TCollection_ExtendedString aFile1,TCollection_ExtendedString aFile2,TCollection_ExtendedString aFile3)3912 int TestOpenSave(TCollection_ExtendedString aFile1,
3913 		 TCollection_ExtendedString aFile2,
3914 		 TCollection_ExtendedString aFile3)
3915 {
3916   // Std
3917   Handle(TDocStd_Document) doc_std, doc_std_open;
3918   app->NewDocument("BinOcaf", doc_std);
3919   // TDataStd_Tick:
3920   TDataStd_Tick::Set(doc_std->Main());
3921   // TDataStd_IntegerList:
3922   Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc_std->Main());
3923   intlist->Append(1);
3924   intlist->Append(5);
3925   // TDataStd_RealList:
3926   Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc_std->Main());
3927   dbllist->Append(1.5);
3928   dbllist->Append(5.5);
3929   // TDataStd_ExtStringList:
3930   Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc_std->Main());
3931   strlist->Append("Auf");
3932   strlist->Append("Wiedersehen");
3933   // TDataStd_BooleanList:
3934   Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc_std->Main());
3935   boollist->Append(Standard_False);
3936   boollist->Append(Standard_True);
3937   // TDataStd_ReferenceList:
3938   TCollection_AsciiString entry1, entry2, entry_first, entry_last;
3939   TDF_Label Lstd1 = doc_std->Main().FindChild(100);
3940   TDF_Tool::Entry(Lstd1, entry1);
3941   TDF_Label Lstd2 = doc_std->Main().FindChild(101);
3942   TDF_Tool::Entry(Lstd2, entry2);
3943   Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc_std->Main());
3944   reflist->Append(Lstd1);
3945   reflist->Append(Lstd2);
3946   // TDataStd_BooleanArray:
3947   Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc_std->Main(), 15, 18);
3948   boolarr->SetValue(15, Standard_False);
3949   boolarr->SetValue(16, Standard_True);
3950   boolarr->SetValue(17, Standard_True);
3951   boolarr->SetValue(18, Standard_True);
3952   // TDataStd_ReferenceArray:
3953   Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc_std->Main(), 45, 46);
3954   refarr->SetValue(45, Lstd1);
3955   refarr->SetValue(46, Lstd2);
3956   // TDataStd_ByteArray:
3957   Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc_std->Main(), 15, 18);
3958   bytearr->SetValue(15, 150);
3959   bytearr->SetValue(16, 160);
3960   bytearr->SetValue(17, 170);
3961   bytearr->SetValue(18, 180);
3962   // TDataStd_NamedData:
3963   Handle(TDataStd_NamedData) nameddata = TDataStd_NamedData::Set(doc_std->Main());
3964   // TDF_Reference:
3965   TDF_Label Lstd3 = doc_std->Main().FindChild(103);
3966   Handle(TDF_Reference) ref = TDF_Reference::Set(doc_std->Main(), Lstd3);
3967   //
3968   // Save
3969   //if (app->SaveAs(doc_std, "W:\\doc.std") != PCDM_SS_OK)
3970   if (app->SaveAs(doc_std, aFile1) != PCDM_SS_OK)
3971     return 1;
3972   intlist.Nullify();
3973   dbllist.Nullify();
3974   strlist.Nullify();
3975   boollist.Nullify();
3976   reflist.Nullify();
3977   boolarr.Nullify();
3978   ref.Nullify();
3979   app->Close(doc_std);
3980   doc_std.Nullify();
3981   //if (app->Open("W:\\doc.std", doc_std_open) != PCDM_RS_OK)
3982   if (app->Open(aFile1, doc_std_open) != PCDM_RS_OK)
3983     return 2;
3984   if (!doc_std_open->Main().IsAttribute(TDataStd_Tick::GetID()))
3985     return 3;
3986   if (!doc_std_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3987     return 4;
3988   if (intlist->First() != 1)
3989     return 5;
3990   if (intlist->Last() != 5)
3991     return 6;
3992   if (!doc_std_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
3993     return 4;
3994   if (dbllist->First() != 1.5)
3995     return 5;
3996   if (dbllist->Last() != 5.5)
3997     return 6;
3998   if (!doc_std_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
3999     return 4;
4000   if (strlist->First() != "Auf")
4001     return 5;
4002   if (strlist->Last() != "Wiedersehen")
4003     return 6;
4004   if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4005     return 4;
4006   if (boollist->First() != Standard_False)
4007     return 5;
4008   if (boollist->Last() != Standard_True)
4009     return 6;
4010   if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4011     return 4;
4012   TDF_Tool::Entry(reflist->First(), entry_first);
4013   if (entry1 != entry_first)
4014     return 5;
4015   TDF_Tool::Entry(reflist->Last(), entry_last);
4016   if (entry2 != entry_last)
4017     return 6;
4018   if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4019     return 4;
4020   if (boolarr->Value(15) != Standard_False)
4021     return 5;
4022   if (boolarr->Value(16) != Standard_True)
4023     return 5;
4024   if (boolarr->Value(17) != Standard_True)
4025     return 5;
4026   if (boolarr->Value(18) != Standard_True)
4027     return 5;
4028   if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4029     return 4;
4030   TDF_Tool::Entry(refarr->Value(45), entry_first);
4031   if (entry1 != entry_first)
4032     return 5;
4033   TDF_Tool::Entry(refarr->Value(46), entry_last);
4034   if (entry2 != entry_last)
4035     return 6;
4036   if (!doc_std_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4037     return 4;
4038   if (bytearr->Value(15) != 150)
4039     return 5;
4040   if (bytearr->Value(16) != 160)
4041     return 5;
4042   if (bytearr->Value(17) != 170)
4043     return 5;
4044   if (bytearr->Value(18) != 180)
4045     return 5;
4046   if (!doc_std_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4047     return 4;
4048   if (ref->Get().IsNull())
4049     return 5;
4050   if (ref->Get().Tag() != 103)
4051       return 5;
4052 
4053   // Xml
4054   Handle(TDocStd_Document) doc_xml, doc_xml_open;
4055   app->NewDocument("XmlOcaf", doc_xml);
4056   // TDataStd_Tick:
4057   TDataStd_Tick::Set(doc_xml->Main());
4058   // TDataStd_IntegerList:
4059   intlist = TDataStd_IntegerList::Set(doc_xml->Main());
4060   intlist->Append(1);
4061   intlist->Append(5);
4062   // TDataStd_RealList:
4063   dbllist = TDataStd_RealList::Set(doc_xml->Main());
4064   dbllist->Append(1.5);
4065   dbllist->Append(5.5);
4066   // TDataStd_ExtStringList:
4067   strlist = TDataStd_ExtStringList::Set(doc_xml->Main());
4068   strlist->Append("Guten ");
4069   strlist->Append("Tag");
4070   // TDataStd_BooleanList:
4071   boollist = TDataStd_BooleanList::Set(doc_xml->Main());
4072   boollist->Append(Standard_False);
4073   boollist->Append(Standard_True);
4074   // TDataStd_ReferenceList:
4075   TDF_Label Lxml1 = doc_xml->Main().FindChild(100);
4076   TDF_Tool::Entry(Lxml1, entry1);
4077   TDF_Label Lxml2 = doc_xml->Main().FindChild(101);
4078   TDF_Tool::Entry(Lxml2, entry2);
4079   reflist = TDataStd_ReferenceList::Set(doc_xml->Main());
4080   reflist->Append(Lxml1);
4081   reflist->Append(Lxml2);
4082   // TDataStd_BooleanArray:
4083   boolarr = TDataStd_BooleanArray::Set(doc_xml->Main(), 15, 24);
4084   boolarr->SetValue(15, Standard_False);
4085   boolarr->SetValue(16, Standard_True);
4086   boolarr->SetValue(17, Standard_True);
4087   boolarr->SetValue(18, Standard_True);
4088   boolarr->SetValue(19, Standard_True);
4089   boolarr->SetValue(20, Standard_True);
4090   boolarr->SetValue(21, Standard_False);
4091   boolarr->SetValue(22, Standard_True);
4092   boolarr->SetValue(23, Standard_True);
4093   boolarr->SetValue(24, Standard_True);
4094   // TDataStd_ReferenceArray:
4095   refarr = TDataStd_ReferenceArray::Set(doc_xml->Main(), 444, 445);
4096   refarr->SetValue(444, Lxml1);
4097   refarr->SetValue(445, Lxml2);
4098   // TDataStd_ByteArray:
4099   bytearr = TDataStd_ByteArray::Set(doc_xml->Main(), 15, 24);
4100   bytearr->SetValue(15, 0);
4101   bytearr->SetValue(16, 10);
4102   bytearr->SetValue(17, 100);
4103   bytearr->SetValue(18, 200);
4104   bytearr->SetValue(19, 250);
4105   bytearr->SetValue(20, 251);
4106   bytearr->SetValue(21, 252);
4107   bytearr->SetValue(22, 253);
4108   bytearr->SetValue(23, 254);
4109   bytearr->SetValue(24, 255);
4110   // TDF_Reference:
4111   Lstd3 = doc_xml->Main().FindChild(103);
4112   ref = TDF_Reference::Set(doc_xml->Main(), Lstd3);
4113   //
4114   // Save
4115   //if (app->SaveAs(doc_xml, "W:\\doc.xml") != PCDM_SS_OK)
4116   if (app->SaveAs(doc_xml, aFile2) != PCDM_SS_OK)
4117     return 1;
4118   intlist.Nullify();
4119   ref.Nullify();
4120   app->Close(doc_xml);
4121   doc_xml.Nullify();
4122   //if (app->Open("W:\\doc.xml", doc_xml_open) != PCDM_RS_OK)
4123   if (app->Open(aFile2, doc_xml_open) != PCDM_RS_OK)
4124     return 2;
4125   if (!doc_xml_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4126     return 3;
4127   if (!doc_xml_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4128     return 4;
4129   if (intlist->First() != 1)
4130     return 5;
4131   if (intlist->Last() != 5)
4132     return 6;
4133   if (!doc_xml_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4134     return 4;
4135   if (dbllist->First() != 1.5)
4136     return 5;
4137   if (dbllist->Last() != 5.5)
4138     return 6;
4139   if (!doc_xml_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4140     return 4;
4141   if (strlist->First() != "Guten ")
4142     return 5;
4143   if (strlist->Last() != "Tag")
4144     return 6;
4145   if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4146     return 4;
4147   if (boollist->First() != Standard_False)
4148     return 5;
4149   if (boollist->Last() != Standard_True)
4150     return 6;
4151   if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4152     return 4;
4153   TDF_Tool::Entry(reflist->First(), entry_first);
4154   if (entry1 != entry_first)
4155     return 5;
4156   TDF_Tool::Entry(reflist->Last(), entry_last);
4157   if (entry2 != entry_last)
4158     return 6;
4159   if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4160     return 4;
4161   if (boolarr->Value(15) != Standard_False)
4162     return 5;
4163   if (boolarr->Value(16) != Standard_True)
4164     return 5;
4165   if (boolarr->Value(17) != Standard_True)
4166     return 5;
4167   if (boolarr->Value(18) != Standard_True)
4168     return 5;
4169   if (boolarr->Value(19) != Standard_True)
4170     return 5;
4171   if (boolarr->Value(20) != Standard_True)
4172     return 5;
4173   if (boolarr->Value(21) != Standard_False)
4174     return 5;
4175   if (boolarr->Value(22) != Standard_True)
4176     return 5;
4177   if (boolarr->Value(23) != Standard_True)
4178     return 5;
4179   if (boolarr->Value(24) != Standard_True)
4180     return 5;
4181   if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4182     return 4;
4183   TDF_Tool::Entry(refarr->Value(444), entry_first);
4184   if (entry1 != entry_first)
4185     return 5;
4186   TDF_Tool::Entry(refarr->Value(445), entry_last);
4187   if (entry2 != entry_last)
4188     return 6;
4189   if (!doc_xml_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4190     return 4;
4191   if (bytearr->Value(15) != 0)
4192     return 5;
4193   if (bytearr->Value(16) != 10)
4194     return 5;
4195   if (bytearr->Value(17) != 100)
4196     return 5;
4197   if (bytearr->Value(18) != 200)
4198     return 5;
4199   if (bytearr->Value(19) != 250)
4200     return 5;
4201   if (bytearr->Value(20) != 251)
4202     return 5;
4203   if (bytearr->Value(21) != 252)
4204     return 5;
4205   if (bytearr->Value(22) != 253)
4206     return 5;
4207   if (bytearr->Value(23) != 254)
4208     return 5;
4209   if (bytearr->Value(24) != 255)
4210     return 5;
4211   if (!doc_xml_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4212     return 4;
4213   if (ref->Get().IsNull())
4214     return 5;
4215   if (ref->Get().Tag() != 103)
4216       return 5;
4217 
4218   // Bin
4219   Handle(TDocStd_Document) doc_bin, doc_bin_open;
4220   app->NewDocument("BinOcaf", doc_bin);
4221   // TDataStd_Tick:
4222   TDataStd_Tick::Set(doc_bin->Main());
4223   // TDataStd_IntegerList:
4224   intlist = TDataStd_IntegerList::Set(doc_bin->Main());
4225   intlist->Append(1);
4226   intlist->Append(5);
4227   // TDataStd_RealList:
4228   dbllist = TDataStd_RealList::Set(doc_bin->Main());
4229   dbllist->Append(1.5);
4230   dbllist->Append(5.5);
4231   // TDataStd_ExtStringList:
4232   strlist = TDataStd_ExtStringList::Set(doc_bin->Main());
4233   strlist->Append("Bonjour");
4234   strlist->Append("Bonsoir");
4235   // TDataStd_BooleanList:
4236   boollist = TDataStd_BooleanList::Set(doc_bin->Main());
4237   boollist->Append(Standard_False);
4238   boollist->Append(Standard_True);
4239   // TDataStd_ReferenceList:
4240   TDF_Label Lbin1 = doc_bin->Main().FindChild(100);
4241   TDF_Tool::Entry(Lbin1, entry1);
4242   TDF_Label Lbin2 = doc_bin->Main().FindChild(101);
4243   TDF_Tool::Entry(Lbin2, entry2);
4244   reflist = TDataStd_ReferenceList::Set(doc_bin->Main());
4245   reflist->Append(Lbin1);
4246   reflist->Append(Lbin2);
4247   // TDataStd_BooleanArray:
4248   boolarr = TDataStd_BooleanArray::Set(doc_bin->Main(), 15, 24);
4249   boolarr->SetValue(15, Standard_False);
4250   boolarr->SetValue(16, Standard_True);
4251   boolarr->SetValue(17, Standard_True);
4252   boolarr->SetValue(18, Standard_True);
4253   boolarr->SetValue(19, Standard_True);
4254   boolarr->SetValue(20, Standard_True);
4255   boolarr->SetValue(21, Standard_False);
4256   boolarr->SetValue(22, Standard_True);
4257   boolarr->SetValue(23, Standard_True);
4258   boolarr->SetValue(24, Standard_True);
4259   // TDataStd_ReferenceArray:
4260   refarr = TDataStd_ReferenceArray::Set(doc_bin->Main(), 0, 1);
4261   refarr->SetValue(0, Lbin1);
4262   refarr->SetValue(1, Lbin2);
4263   // TDataStd_ByteArray:
4264   bytearr = TDataStd_ByteArray::Set(doc_bin->Main(), 15, 16);
4265   bytearr->SetValue(15, 0);
4266   bytearr->SetValue(16, 255);
4267   // TDataStd_NamedData:
4268   nameddata = TDataStd_NamedData::Set(doc_bin->Main());
4269   nameddata->SetByte("A", 12);
4270   nameddata->SetByte("B", 234);
4271   // TDF_Reference:
4272   Lstd3 = doc_bin->Main().FindChild(103);
4273   ref = TDF_Reference::Set(doc_bin->Main(), Lstd3);
4274   //
4275   // Save
4276   //if (app->SaveAs(doc_bin, "W:\\doc.cbf") != PCDM_SS_OK)
4277   if (app->SaveAs(doc_bin, aFile3) != PCDM_SS_OK)
4278     return 1;
4279   intlist.Nullify();
4280   ref.Nullify();
4281   app->Close(doc_bin);
4282   doc_bin.Nullify();
4283   //if (app->Open("W:\\doc.cbf", doc_bin_open) != PCDM_RS_OK)
4284   if (app->Open(aFile3, doc_bin_open) != PCDM_RS_OK)
4285     return 2;
4286   if (!doc_bin_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4287     return 3;
4288   if (!doc_bin_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4289     return 4;
4290   if (intlist->First() != 1)
4291     return 5;
4292   if (intlist->Last() != 5)
4293     return 6;
4294   if (!doc_bin_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4295     return 4;
4296   if (dbllist->First() != 1.5)
4297     return 5;
4298   if (dbllist->Last() != 5.5)
4299     return 6;
4300   if (!doc_bin_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4301     return 4;
4302   if (strlist->First() != "Bonjour")
4303     return 5;
4304   if (strlist->Last() != "Bonsoir")
4305     return 6;
4306   if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4307     return 4;
4308   if (boollist->First() != Standard_False)
4309     return 5;
4310   if (boollist->Last() != Standard_True)
4311     return 6;
4312   if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4313     return 4;
4314   TDF_Tool::Entry(reflist->First(), entry_first);
4315   if (entry1 != entry_first)
4316     return 5;
4317   TDF_Tool::Entry(reflist->Last(), entry_last);
4318   if (entry2 != entry_last)
4319     return 6;
4320   if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4321     return 4;
4322   if (boolarr->Value(15) != Standard_False)
4323     return 5;
4324   if (boolarr->Value(16) != Standard_True)
4325     return 5;
4326   if (boolarr->Value(17) != Standard_True)
4327     return 5;
4328   if (boolarr->Value(18) != Standard_True)
4329     return 5;
4330   if (boolarr->Value(19) != Standard_True)
4331     return 5;
4332   if (boolarr->Value(20) != Standard_True)
4333     return 5;
4334   if (boolarr->Value(21) != Standard_False)
4335     return 5;
4336   if (boolarr->Value(22) != Standard_True)
4337     return 5;
4338   if (boolarr->Value(23) != Standard_True)
4339     return 5;
4340   if (boolarr->Value(24) != Standard_True)
4341     return 5;
4342   if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4343     return 4;
4344   TDF_Tool::Entry(refarr->Value(0), entry_first);
4345   if (entry1 != entry_first)
4346     return 5;
4347   TDF_Tool::Entry(refarr->Value(1), entry_last);
4348   if (entry2 != entry_last)
4349     return 6;
4350   if (!doc_bin_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4351     return 4;
4352   if (bytearr->Value(15) != 0)
4353     return 5;
4354   if (bytearr->Value(16) != 255)
4355     return 5;
4356   if (!doc_bin_open->Main().FindAttribute(TDataStd_NamedData::GetID(), nameddata))
4357     return 4;
4358   if (nameddata->GetByte("A") != 12)
4359     return 5;
4360   if (nameddata->GetByte("B") != 234)
4361     return 5;
4362   if (!doc_bin_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4363     return 4;
4364   if (ref->Get().IsNull())
4365     return 5;
4366   if (ref->Get().Tag() != 103)
4367       return 5;
4368 
4369   return 0;
4370 }
4371 // For OCC16782 testing
4372 
OCC16782(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4373 static Standard_Integer OCC16782 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4374 {
4375   if (argc != 4)
4376   {
4377     di << "Usage : " << argv[0] << " file.std file.xml file.cbf\n";
4378     return 1;
4379   }
4380   TCollection_ExtendedString aFile1(argv[1]);
4381   TCollection_ExtendedString aFile2(argv[2]);
4382   TCollection_ExtendedString aFile3(argv[3]);
4383 
4384   if (app.IsNull())
4385     app = new AppStd_Application();
4386 
4387   int good = 0;
4388 
4389   Handle(TDocStd_Document) doc;
4390   app->NewDocument("BinOcaf", doc);
4391   doc->SetUndoLimit(10);
4392 
4393   di <<"\nTestSetGet start\n";
4394   good += TestSetGet(doc);
4395   di <<"TestSetGet finish\n";
4396   di <<"Status = " << good << "\n";
4397 
4398   di <<"\nTestUndoRedo start\n";
4399   good += TestUndoRedo(doc);
4400   di <<"TestUndoRedo finish\n";
4401   di <<"Status = " << good << "\n";
4402 
4403   di <<"\nTestCopyPaste start\n";
4404   good += TestCopyPaste(doc);
4405   di <<"TestCopyPaste finish\n";
4406   di <<"Status = " << good << "\n";
4407 
4408   di <<"\nTestOpenSave start\n";
4409   good += TestOpenSave(aFile1, aFile2, aFile3);
4410   di <<"TestOpenSave finish\n";
4411   di <<"Status = " << good << "\n";
4412 
4413   if (!good)
4414     di <<"\nThe " << argv[0] << " test is passed well, OK\n";
4415   else
4416     di <<"\nThe " << argv[0] << " test failed, Faulty\n";
4417 
4418   return 0;
4419 }
4420 
OCC12584(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4421 static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4422 {
4423   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4424   if(aContext.IsNull()) {
4425     di << argv[0] << " ERROR : use 'vinit' command before \n";
4426     return -1;
4427   }
4428 
4429   if (argc > 2)
4430   {
4431     di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4432     return 1;
4433   }
4434   Standard_Integer mode = 0;
4435   if (argc == 2)
4436   {
4437     mode = Draw::Atoi(argv[1]);
4438   }
4439   if (mode > 2 || mode < 0)
4440   {
4441     di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4442     return 1;
4443   }
4444   Handle(V3d_View) V = ViewerTest::CurrentView();
4445   static Handle(AIS_ColorScale) aCS;
4446   if (aCS.IsNull())
4447   {
4448     aCS = new AIS_ColorScale();
4449   }
4450   if (aCS->ZLayer() != Graphic3d_ZLayerId_TopOSD)
4451   {
4452     aCS->SetZLayer (Graphic3d_ZLayerId_TopOSD);
4453   }
4454   if (aCS->TransformPersistence().IsNull()
4455    || aCS->TransformPersistence()->Mode() != Graphic3d_TMF_2d)
4456   {
4457     aContext->SetTransformPersistence (aCS, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
4458   }
4459   Standard_Integer aWinWidth, aWinHeight;
4460   V->Window()->Size (aWinWidth, aWinHeight);
4461   aCS->SetSize (aWinWidth, aWinHeight);
4462   if ( !V.IsNull() ) {
4463     if (mode == 0) {
4464       aContext->Display (aCS, Standard_True);
4465     }
4466     if (mode == 1) {
4467       aContext->Erase (aCS, Standard_False);
4468       V->UpdateLights();
4469       V->Update();
4470     }
4471     if (mode == 2) {
4472       Standard_Boolean IsDisplayed = aContext->IsDisplayed (aCS);
4473       if (IsDisplayed)
4474 	di <<"ColorScaleIsDisplayed = 1\n";
4475       else
4476 	di <<"ColorScaleIsDisplayed = 0\n";
4477     }
4478   }
4479   return 0;
4480 }
4481 
4482 #include <Interface_Macros.hxx>
4483 #include <IGESControl_Controller.hxx>
4484 #include <XSDRAW.hxx>
4485 #include <Draw_ProgressIndicator.hxx>
4486 #include <XSControl_WorkSession.hxx>
4487 #include <Transfer_TransientProcess.hxx>
4488 #include <TColStd_HSequenceOfTransient.hxx>
4489 #include <Message_ProgressScope.hxx>
4490 #include <XSControl_TransferReader.hxx>
4491 
4492 #include <Geom_Plane.hxx>
OCC20766(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4493 static Standard_Integer OCC20766 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4494 {
4495   if (argc != 6)
4496   {
4497     di << "Usage : " << argv[0] << " plane a b c d\n";
4498     return 1;
4499   }
4500 
4501   Standard_Real A = Draw::Atof(argv[2]);
4502   Standard_Real B = Draw::Atof(argv[3]);
4503   Standard_Real C = Draw::Atof(argv[4]);
4504   Standard_Real D = Draw::Atof(argv[5]);
4505 
4506   Handle(Geom_Geometry) result;
4507 
4508   Handle(Geom_Plane) aPlane = new Geom_Plane(A, B, C, D);
4509   result = aPlane;
4510 
4511   DrawTrSurf::Set(argv[1],result);
4512   return 0;
4513 }
4514 
OCC20627(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4515 static Standard_Integer OCC20627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4516 {
4517   if(argc!=2)
4518     {
4519       di << "Usage : " << argv[0] << " MaxNbr\n";
4520       return -1;
4521     }
4522   Standard_Integer aMaxNbr = Draw::Atoi(argv[1]);
4523 
4524   for (Standard_Integer i=0;i<aMaxNbr;i++)
4525     {
4526       BRepBuilderAPI_MakePolygon w(gp_Pnt(0,0,0),gp_Pnt(0,100,0),gp_Pnt(20,100,0),gp_Pnt(20,0,0));
4527       w.Close();
4528       TopoDS_Wire wireShape( w.Wire());
4529       BRepBuilderAPI_MakeFace faceBuilder(wireShape);
4530       TopoDS_Face f( faceBuilder.Face());
4531       BRepMesh_IncrementalMesh im(f,1);
4532       BRepTools::Clean(f);
4533     }
4534   return 0;
4535 }
4536 
4537 #include <IntCurvesFace_ShapeIntersector.hxx>
4538 #include <gp_Lin.hxx>
OCC17424(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4539 Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4540 {
4541   if(argc!=9)
4542     {
4543       di << "Usage : " << argv[0] << " shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf\n";
4544       return -1;
4545     }
4546 
4547   TopoDS_Shape shape = DBRep::Get(argv[1]);
4548 
4549   if (shape.IsNull()) {
4550     di<<" Null shape is not allowed";
4551     return 1;
4552   }
4553 
4554   Standard_Real X_Pnt = Draw::Atof(argv[2]);
4555   Standard_Real Y_Pnt = Draw::Atof(argv[3]);
4556   Standard_Real Z_Pnt = Draw::Atof(argv[4]);
4557 
4558   Standard_Real X_Dir = Draw::Atof(argv[5]);
4559   Standard_Real Y_Dir = Draw::Atof(argv[6]);
4560   Standard_Real Z_Dir = Draw::Atof(argv[7]);
4561 
4562   Standard_Real PInf  = Draw::Atof(argv[8]);
4563 
4564   IntCurvesFace_ShapeIntersector intersector;
4565   intersector.Load(shape, Precision::Intersection());
4566 
4567   gp_Pnt origin(X_Pnt, Y_Pnt, Z_Pnt);
4568   gp_Dir dir(X_Dir, Y_Dir, Z_Dir);
4569   gp_Lin ray(origin, dir);
4570 
4571   Standard_Real PSup = RealLast();
4572   intersector.PerformNearest(ray, PInf, PSup);
4573   if (intersector.NbPnt() != 0)
4574     {
4575       di << argv[0] << " status = 0 \n";
4576       Standard_Real w = intersector.WParameter(1);
4577       di << "w = " << w << "\n";
4578     } else {
4579       di << argv[0] << " status = -1 \n";
4580     }
4581   return 0;
4582 }
4583 
OCC22301(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4584 Standard_Integer OCC22301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4585 {
4586   if (argc != 1) {
4587     di << "Usage : " << argv[0] << "\n";
4588     return 1;
4589   }
4590 
4591   // Create mask 1111: extent == 4
4592   TColStd_PackedMapOfInteger aFullMask;
4593   for (Standard_Integer i = 0; i < 4; i++)
4594     aFullMask.Add(i);
4595 
4596   // Create mask 1100: extent == 2
4597   TColStd_PackedMapOfInteger aPartMask;
4598   for (Standard_Integer i = 0; i < 2; i++)
4599     aPartMask.Add(i);
4600 
4601   di << "aFullMask = 1111\n";
4602   di << "aPartMask = 1100\n";
4603 
4604   Standard_Boolean isAffected;
4605 
4606   isAffected = aFullMask.Intersect(aPartMask); // true; extent == 2 (OK)
4607   di << "First time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
4608   isAffected = aFullMask.Intersect(aPartMask); // true; extent == 0 (?)
4609   di << "Second time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
4610   isAffected = aFullMask.Subtract(aPartMask); // false (?)
4611   di << "After two intersections: aFullMask.Subtract(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
4612 
4613   return 0;
4614 }
4615 
4616 #include <NCollection_DataMap.hxx>
OCC22744(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4617 Standard_Integer OCC22744 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4618 {
4619 
4620   if (argc != 1) {
4621     di << "Usage : " << argv[0] << "\n";
4622     return 1;
4623   }
4624 
4625   TCollection_ExtendedString anExtString;
4626 
4627   Standard_ExtCharacter aNonAsciiChar = 0x0f00;
4628   anExtString.Insert(1, aNonAsciiChar);
4629 
4630   di << "Is ASCII: " << ( anExtString.IsAscii() ? "true : Error" : "false : OK" ) << "\n";
4631   NCollection_DataMap<TCollection_ExtendedString, Standard_Integer> aMap;
4632   aMap.Bind(anExtString, 0);
4633 
4634   return 0;
4635 
4636 }
4637 
OCC22558(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4638 Standard_Integer OCC22558 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4639 {
4640     if (argc != 10) {
4641 	di << "Wrong number of arguments" << argv[0] << "\n";
4642 	return 1;
4643     }
4644 
4645     Standard_Real X_vec = Draw::Atof(argv[1]);
4646     Standard_Real Y_vec = Draw::Atof(argv[2]);
4647     Standard_Real Z_vec = Draw::Atof(argv[3]);
4648 
4649     Standard_Real X_dir = Draw::Atof(argv[4]);
4650     Standard_Real Y_dir = Draw::Atof(argv[5]);
4651     Standard_Real Z_dir = Draw::Atof(argv[6]);
4652 
4653     Standard_Real X_pnt = Draw::Atof(argv[7]);
4654     Standard_Real Y_pnt = Draw::Atof(argv[8]);
4655     Standard_Real Z_pnt = Draw::Atof(argv[9]);
4656 
4657     gp_Dir toSym(X_vec, Y_vec, Z_vec);
4658     gp_Dir dir(X_dir, Y_dir, Z_dir);
4659     gp_Pnt loc(X_pnt, Y_pnt, Z_pnt);
4660     gp_Ax2 symObj(loc,dir);
4661     toSym.Mirror(symObj);
4662 
4663     di << "The result " << toSym.X() << " " << toSym.Y() << " " << toSym.Z() << "\n";
4664     return 0;
4665 }
4666 
4667 
OCC22736(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4668 Standard_Integer OCC22736 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4669 {
4670 
4671   if (argc != 9) {
4672     di << "Usage : " << argv[0] << " X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2\n";
4673     return 1;
4674   }
4675 
4676   Standard_Real X_mirrorFirstPoint = Draw::Atof(argv[1]);
4677   Standard_Real Y_mirrorFirstPoint = Draw::Atof(argv[2]);
4678   Standard_Real X_mirrorSecondPoint = Draw::Atof(argv[3]);
4679   Standard_Real Y_mirrorSecondPoint = Draw::Atof(argv[4]);
4680   Standard_Real X_p1 = Draw::Atof(argv[5]);
4681   Standard_Real Y_p1 = Draw::Atof(argv[6]);
4682   Standard_Real X_p2 = Draw::Atof(argv[7]);
4683   Standard_Real Y_p2 = Draw::Atof(argv[8]);
4684 
4685   gp_Trsf2d identityTransformation;
4686 
4687   gp_Pnt2d mirrorFirstPoint(X_mirrorFirstPoint,Y_mirrorFirstPoint);
4688   gp_Pnt2d mirrorSecondPoint(X_mirrorSecondPoint,Y_mirrorSecondPoint);
4689   gp_Ax2d  mirrorAxis(mirrorFirstPoint,gp_Vec2d(mirrorFirstPoint,mirrorSecondPoint));
4690 
4691   gp_Pnt2d p1(X_p1,Y_p1);
4692   gp_Pnt2d p2(X_p2,Y_p2);
4693 
4694   gp_Trsf2d M1;
4695   M1.SetMirror(mirrorAxis);
4696   gp_Trsf2d M2;
4697   M2.SetMirror(mirrorAxis);
4698   gp_Trsf2d Tcomp;
4699   Tcomp = M2.Multiplied(M1);
4700 
4701   Standard_Real aTol = Precision::Confusion();
4702   Standard_Integer aStatus = 0;
4703 
4704   //After applying two times the same mirror the point is located on the same location OK
4705   gp_Pnt2d p1MirrorM1   = p1.Transformed(M1);
4706   if ( Abs(p2.X() - p1MirrorM1.X()) > aTol )
4707     aStatus = 2;
4708   if ( Abs(p2.Y() - p1MirrorM1.Y()) > aTol )
4709     aStatus = 3;
4710 
4711   gp_Pnt2d p1MirrorM1M2 = p1MirrorM1.Transformed(M2);
4712   if ( Abs(p1.X() - p1MirrorM1M2.X()) > aTol )
4713     aStatus = 4;
4714   if ( Abs(p1.Y() - p1MirrorM1M2.Y()) > aTol )
4715     aStatus = 5;
4716 
4717   //If we apply the composed transformation of the same two mirrors to a point the result is //not located on the initial position.-->>ERROR
4718   gp_Pnt2d p1MirrorComp = p1.Transformed(Tcomp);
4719   if ( Abs(p1.X() - p1MirrorComp.X()) > aTol )
4720     aStatus = 6;
4721   if ( Abs(p1.Y() - p1MirrorComp.Y()) > aTol )
4722     aStatus = 7;
4723 
4724   di << "Status = " << aStatus << "\n";
4725   return 0;
4726 }
4727 
OCC23429(Draw_Interpretor &,Standard_Integer narg,const char ** a)4728 Standard_Integer OCC23429(Draw_Interpretor& /*di*/,
4729                           Standard_Integer narg, const char** a)
4730 {
4731   if (narg < 4) return 1;
4732 
4733   TopoDS_Shape aShape = DBRep::Get(a[2]);
4734   if (aShape.IsNull()) return 1;
4735 
4736   BRepFeat_SplitShape Spls(aShape);
4737   Spls.SetCheckInterior(Standard_False);
4738 
4739   TopoDS_Shape aTool = DBRep::Get(a[3]);
4740 
4741   BRepAlgoAPI_Section Builder(aShape, aTool, Standard_False);
4742   Builder.ComputePCurveOn1(Standard_True);
4743   if (narg == 5)
4744     Builder.Approximation(Standard_True);
4745   Builder.Build();
4746   TopoDS_Shape aSection = Builder.Shape();
4747 
4748   TopExp_Explorer ExpSec(aSection, TopAbs_EDGE);
4749   for (; ExpSec.More(); ExpSec.Next())
4750   {
4751     TopoDS_Edge anEdge = TopoDS::Edge(ExpSec.Current());
4752     Handle(Geom2d_Curve) thePCurve;
4753     Handle(Geom_Surface) theSurface;
4754     TopLoc_Location theLoc;
4755     Standard_Real fpar, lpar;
4756     BRep_Tool::CurveOnSurface(anEdge, thePCurve, theSurface, theLoc, fpar, lpar);
4757     TopoDS_Face aFace;
4758     TopExp_Explorer ExpShape(aShape, TopAbs_FACE);
4759     for (; ExpShape.More(); ExpShape.Next())
4760     {
4761       aFace = TopoDS::Face(ExpShape.Current());
4762       TopLoc_Location aLoc;
4763       Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace, aLoc);
4764       if (aSurface == theSurface && aLoc == theLoc)
4765         break;
4766     }
4767     Spls.Add(anEdge, aFace);
4768   }
4769 
4770   TopoDS_Shape Result = Spls.Shape();
4771   DBRep::Set(a[1], Result);
4772 
4773   return 0;
4774 }
4775 
4776 #include <ExprIntrp_GenExp.hxx>
CR23403(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4777 Standard_Integer CR23403 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4778 {
4779 
4780   if (argc != 2) {
4781     di << "Usage : " << argv[0] << " string\n";
4782     return 1;
4783   }
4784 
4785   Standard_CString aString = argv[1];
4786   Handle(ExprIntrp_GenExp) myExpr = ExprIntrp_GenExp::Create();
4787   try {
4788     OCC_CATCH_SIGNALS
4789     myExpr->Process( aString );
4790   }
4791   catch(Standard_Failure const& anException) {
4792     di << "Exception : " << anException.GetMessageString() << "\n";
4793   }
4794 
4795   return 0;
4796 }
4797 
OCC28478(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4798 Standard_Integer OCC28478 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4799 {
4800   Standard_Integer nbOuter = (argc > 1 ? Draw::Atoi(argv[1]) : 3);
4801   Standard_Integer nbInner = (argc > 2 ? Draw::Atoi(argv[2]) : 2);
4802   Standard_Boolean isInf = (argc > 3 && ! strcmp (argv[3], "-inf"));
4803 
4804   // test behavior of progress indicator when using nested scopes with names
4805   Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1);
4806 
4807   // Outer cycle
4808   Message_ProgressScope anOuter (aProgress->Start(), "Outer", nbOuter);
4809   for (int i = 0; i < nbOuter && anOuter.More(); i++)
4810   {
4811     // Inner cycle
4812     Message_ProgressScope anInner (anOuter.Next(), "Inner", nbInner, isInf);
4813     for (int j = 0; j < (isInf ? 2 * nbInner : nbInner) && anInner.More(); j++, anInner.Next())
4814     {
4815       // Cycle body
4816     }
4817   }
4818 
4819   return 0;
4820 }
4821 
OCC31189(Draw_Interpretor & theDI,Standard_Integer,const char **)4822 Standard_Integer OCC31189 (Draw_Interpretor& theDI, Standard_Integer /*argc*/, const char ** /*argv*/)
4823 {
4824   // redirect output of default messenger to DRAW (temporarily)
4825   const Handle(Message_Messenger)& aMsgMgr = Message::DefaultMessenger();
4826   Message_SequenceOfPrinters aPrinters;
4827   aPrinters.Append (aMsgMgr->ChangePrinters());
4828   aMsgMgr->AddPrinter (new Draw_Printer (theDI));
4829 
4830   // scope block to test output of message on destruction of a stream buffer
4831   {
4832     Message_Messenger::StreamBuffer aSender = Message::SendInfo();
4833 
4834     // check that messages output to sender and directly to messenger do not intermix
4835     aSender << "Sender message 1: start ...";
4836     aMsgMgr->Send ("Direct message 1");
4837     aSender << "... end" << std::endl; // endl should send the message
4838 
4839 	// check that empty stream buffer does not produce output on destruction
4840 	Message::SendInfo();
4841 
4842     // additional message to check that they go in expected order
4843     aMsgMgr->Send ("Direct message 2");
4844 
4845 	// check that empty stream buffer does produce empty line if std::endl is passed
4846 	Message::SendInfo() << std::endl;
4847 
4848     // last message should be sent on destruction of a sender
4849 	aSender << "Sender message 2";
4850   }
4851 
4852   // restore initial output queue
4853   aMsgMgr->RemovePrinters (STANDARD_TYPE(Draw_Printer));
4854   aMsgMgr->ChangePrinters().Append (aPrinters);
4855 
4856   return 0;
4857 }
4858 
4859 namespace
4860 {
4861   struct Task
4862   {
4863     Message_ProgressRange Range;
4864     math_Matrix Mat1, Mat2, Mat3;
4865 
Task__anonaff3c01f0111::Task4866     Task(const Message_ProgressRange& thePR, int theSize)
4867     : Range(thePR),
4868       Mat1(1, theSize, 1, theSize, 0.12345), Mat2(1, theSize, 1, theSize, 12345),
4869       Mat3(1, theSize, 1, theSize)
4870     {}
4871   };
4872   struct Functor
4873   {
operator ()__anonaff3c01f0111::Functor4874     void operator()(Task& theTask) const
4875     {
4876       if (theTask.Range.More())
4877       {
4878         if (theTask.Mat1.RowNumber() > 1)
4879           theTask.Mat3 = theTask.Mat1 * theTask.Mat2;
4880       }
4881       theTask.Range.Close();
4882     }
4883   };
4884 }
4885 
OCC25748(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)4886 Standard_Integer OCC25748(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4887 {
4888   // test behavior of progress indicator in multi-threaded execution
4889   Standard_Integer nIter = 1000;
4890   Standard_Integer aMatSize = 1;
4891   Standard_Boolean isProgress = false;
4892   Standard_Boolean isParallel = false;
4893 
4894   for (int i = 1; i < argc; i++)
4895   {
4896     if (strcmp(argv[i], "-niter") == 0)
4897       nIter = Draw::Atoi(argv[++i]);
4898     else if (strcmp(argv[i], "-matsize") == 0)
4899       aMatSize = Draw::Atoi(argv[++i]);
4900     else if (strcmp(argv[i], "-progr") == 0)
4901       isProgress = true;
4902     else if (strcmp(argv[i], "-parallel") == 0)
4903       isParallel = true;
4904     else
4905     {
4906       di.PrintHelp("OCC25748");
4907       return 1;
4908     }
4909   }
4910 
4911   OSD_Timer aTimerWhole;
4912   aTimerWhole.Start();
4913 
4914   Handle(Draw_ProgressIndicator) aProgress;
4915   if (isProgress)
4916   {
4917     aProgress = new Draw_ProgressIndicator(di, 1);
4918   }
4919   Message_ProgressScope aPS(Message_ProgressIndicator::Start(aProgress),
4920                             "Parallel data processing", nIter);
4921 
4922   std::vector<Task> aTasks;
4923   aTasks.reserve (nIter);
4924   for (int i = 0; i < nIter; i++)
4925   {
4926     aTasks.push_back (Task (aPS.Next(), aMatSize));
4927   }
4928 
4929   OSD_Timer aTimer;
4930   aTimer.Start();
4931   OSD_Parallel::ForEach(aTasks.begin(), aTasks.end(), Functor(), !isParallel);
4932   aTimer.Stop();
4933 
4934   aTimerWhole.Stop();
4935 
4936   TCollection_AsciiString aText(nIter);
4937   aText += (isParallel ? " parallel" : " sequential");
4938   if (aMatSize > 1)
4939     aText = aText + " calculations on matrices " + aMatSize + "x" + aMatSize;
4940   else
4941     aText += " empty tasks";
4942   if (isProgress)
4943     aText += " with progress";
4944   di << "COUNTER " << aText << ": " << aTimer.ElapsedTime();
4945   di << "\nCOUNTER " << "including preparations" << ": " << aTimerWhole.ElapsedTime();
4946   return 0;
4947 }
4948 
Commands_11(Draw_Interpretor & theCommands)4949 void QABugs::Commands_11(Draw_Interpretor& theCommands) {
4950   const char *group = "QABugs";
4951 
4952   theCommands.Add("OCC128", "OCC128", __FILE__, OCC128, group);
4953 
4954   // Remove as bad version of QAAddOrRemoveSelected from QADraw
4955   //theCommands.Add("OCC129", "OCC129 shape islocal", __FILE__, OCC129, group);
4956 
4957   theCommands.Add("OCC136", "OCC136", __FILE__, OCC136, group);
4958   theCommands.Add("BUC60610","BUC60610 iges_input [name]",__FILE__,BUC60610,group);
4959 
4960   theCommands.Add("OCC105","OCC105 shape",__FILE__,OCC105,group);
4961   theCommands.Add("OCC9"," result path cur1 cur2 radius [tolerance]:\t test GeomFill_Pipe", __FILE__, pipe_OCC9,group);
4962 
4963   theCommands.Add("OCC125","OCC125 shell", __FILE__, OCC125,group);
4964 
4965   theCommands.Add("OCC157","findplanarsurface Result wire Tol",__FILE__,OCC157,group);
4966   //theCommands.Add("OCC165","OCC165",__FILE__,OCC165,group);
4967   theCommands.Add("OCC165","OCC165 file",__FILE__,OCC165,group);
4968   theCommands.Add("OCC297","OCC297",__FILE__,OCC297,group);
4969   //theCommands.Add("OCC305","OCC305",__FILE__,OCC305,group);
4970   theCommands.Add("OCC305","OCC305 file",__FILE__,OCC305,group);
4971 
4972   // New commands:
4973   theCommands.Add("OCC381_Save", "OCC381_Save Doc", __FILE__, OCC381_Save, group);
4974   theCommands.Add("OCC381_SaveAs", "OCC381_SaveAs Doc Path", __FILE__, OCC381_SaveAs, group);
4975 
4976   theCommands.Add("OCC299","OCC299 Solid Point [Tolerance=1.e-7]", __FILE__, OCC299bug, group);
4977   theCommands.Add("OCC309","OCC309", __FILE__, OCC309bug, group);
4978   theCommands.Add("OCC310","OCC310", __FILE__, OCC310bug, group);
4979 
4980   //theCommands.Add("OCC277","OCC277", __FILE__, OCC277bug, group);
4981   theCommands.Add("OCC277","OCC277", __FILE__, OCC277bug, group);
4982 
4983   theCommands.Add("OCC363", "OCC363 document filename ", __FILE__, OCC363, group);
4984   // Must use OCC299
4985   //theCommands.Add("OCC372", "OCC372", __FILE__, OCC372, group);
4986   theCommands.Add("OCC377", "OCC377", __FILE__, OCC377, group);
4987   theCommands.Add("OCC22", "OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation", __FILE__, OCC22, group);
4988   theCommands.Add("OCC24", "OCC24 Result Shape CompoundOfSubshapes ResourceFileName", __FILE__, OCC24, group);
4989   theCommands.Add("OCC369", "OCC369 Shape", __FILE__, OCC369, group);
4990   theCommands.Add("OCC524", "OCC524 LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix", __FILE__, OCC524, group);
4991   theCommands.Add("OCC525", "OCC525", __FILE__, OCC525, group);
4992   //theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
4993   theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
4994   theCommands.Add("OCC669", "OCC669 GUID", __FILE__, OCC669, group);
4995   theCommands.Add("OCC738_ShapeRef", "OCC738_ShapeRef", __FILE__, OCC738_ShapeRef, group);
4996   theCommands.Add("OCC738_Assembly", "OCC738_Assembly", __FILE__, OCC738_Assembly, group);
4997   theCommands.Add("OCC708", "OCC708 shape ; Deactivate the current transformation", __FILE__, OCC708, group);
4998   theCommands.Add("OCC670", "OCC670", __FILE__, OCC670, group);
4999   theCommands.Add("OCC867", "OCC867 Point Surface Umin Usup Vmin Vsup", __FILE__, OCC867, group);
5000   theCommands.Add("OCC909", "OCC909 wire face", __FILE__, OCC909, group);
5001   theCommands.Add("OCC921", "OCC921 face", __FILE__, OCC921, group);
5002   theCommands.Add("OCC902", "OCC902 expression", __FILE__, OCC902, group);
5003 
5004   theCommands.Add ("OCC1029_AISTransparency","OCC1029_AISTransparency (DOC, entry, [real])",__FILE__, OCC1029_AISTransparency, group);
5005   theCommands.Add ("OCC1031_AISMaterial", "OCC1031_AISMaterial (DOC, entry, [material])", __FILE__, OCC1031_AISMaterial, group);
5006   theCommands.Add ("OCC1032_AISWidth", "OCC1032_AISWidth (DOC, entry, [width])", __FILE__, OCC1032_AISWidth, group);
5007   theCommands.Add ("OCC1033_AISMode", "OCC1033_AISMode (DOC, entry, [mode])", __FILE__, OCC1033_AISMode, group);
5008   theCommands.Add ("OCC1034_AISSelectionMode", "OCC1034_AISSelectionMode (DOC, entry, [selectionmode])", __FILE__, OCC1034_AISSelectionMode, group);
5009 
5010   //theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape", __FILE__, OCC1487, group);
5011   theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape", __FILE__, OCC1487, group);
5012 
5013   theCommands.Add("OCC1077", "OCC1077 result", __FILE__, OCC1077, group);
5014   theCommands.Add("OCC5739", "OCC5739 name shape step", __FILE__, OCC5739_UniAbs, group);
5015   theCommands.Add("OCC6046", "OCC6046 nb_of_vectors size", __FILE__, OCC6046, group);
5016   theCommands.Add("OCC5698", "OCC5698 wire", __FILE__, OCC5698, group);
5017   theCommands.Add("OCC6143", "OCC6143 catching signals", __FILE__, OCC6143, group);
5018   theCommands.Add("OCC30775", "OCC30775 catching signals in threads", __FILE__, OCC30775, group);
5019   theCommands.Add("OCC30762", "OCC30762 printing backtrace", __FILE__, OCC30762, group);
5020   theCommands.Add("OCC7141", "OCC7141 [nCount] aPath", __FILE__, OCC7141, group);
5021   theCommands.Add("OCC7372", "OCC7372", __FILE__, OCC7372, group);
5022   theCommands.Add("OCC8169", "OCC8169 edge1 edge2 plane", __FILE__, OCC8169, group);
5023   theCommands.Add("OCC10138", "OCC10138 lower upper", __FILE__, OCC10138, group);
5024   theCommands.Add("OCC7639", "OCC7639 index1 value1 ... [indexN valueN]", __FILE__, OCC7639, group);
5025   theCommands.Add("OCC8797", "OCC8797", __FILE__, OCC8797, group);
5026   theCommands.Add("OCC7068", "OCC7068", __FILE__, OCC7068, group);
5027   theCommands.Add("OCC11457", "OCC11457 polygon lastedge x1 y1 z1 x2 y2 z2 ...", __FILE__, OCC11457, group);
5028   theCommands.Add("OCC13963", "OCC13963 ratio origin_x origin_y origin_z", __FILE__, OCC13963, group);
5029   theCommands.Add("OCC14376", "OCC14376 shape [deflection]", __FILE__, OCC14376, group);
5030   theCommands.Add("OCC15489", "OCC15489 A B C", __FILE__, OCC15489, group);
5031   theCommands.Add("OCC15755", "OCC15755 file shape", __FILE__, OCC15755, group);
5032   theCommands.Add("OCC16782", "OCC16782 file.std file.xml file.cbf", __FILE__, OCC16782, group);
5033   theCommands.Add("OCC12584", "OCC12584 [mode = 0/1/2]", __FILE__, OCC12584, group);
5034   theCommands.Add("OCC20766", "OCC20766 plane a b c d", __FILE__, OCC20766, group);
5035   theCommands.Add("OCC20627", "OCC20627", __FILE__, OCC20627, group);
5036   theCommands.Add("OCC17424", "OCC17424  shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf", __FILE__, OCC17424, group);
5037   theCommands.Add("OCC22301", "OCC22301", __FILE__, OCC22301, group);
5038   theCommands.Add("OCC22736", "OCC22736 X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2", __FILE__, OCC22736, group);
5039   theCommands.Add("OCC22744", "OCC22744", __FILE__, OCC22744, group);
5040   theCommands.Add("OCC22558", "OCC22558 x_vec y_vec z_vec x_dir y_dir z_dit x_pnt y_pnt z_pnt", __FILE__, OCC22558, group);
5041   theCommands.Add("CR23403", "CR23403 string", __FILE__, CR23403, group);
5042   theCommands.Add("OCC23429", "OCC23429 res shape tool [appr]", __FILE__, OCC23429, group);
5043   theCommands.Add("OCC28478", "OCC28478 [nb_outer=3 [nb_inner=2] [-inf]: test progress indicator on nested cycles", __FILE__, OCC28478, group);
5044   theCommands.Add("OCC31189", "OCC31189: check stream buffer interface of Message_Messenger", __FILE__, OCC31189, group);
5045   theCommands.Add("OCC25748", "OCC25748 [-niter val] [-matsize val] [-progr] [-parallel]\n"
5046                   "\t\ttest progress indicator in parallel execution", __FILE__, OCC25748, group);
5047 
5048   theCommands.Add("OCC31965", "OCC31965 object : tests AIS_InteractiveContext::Hilight()", __FILE__, OCC31965, group);
5049   return;
5050 }
5051