0024202: Support class methods as callbacks for Draw Harness commands
[occt.git] / src / QABugs / QABugs_19.cxx
1 // Created on: 2002-05-21
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
8 // under the terms of the GNU Lesser General Public version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <QABugs.hxx>
17
18 #include <Draw_Interpretor.hxx>
19 #include <DBRep.hxx>
20 #include <DrawTrSurf.hxx>
21 #include <AIS_InteractiveContext.hxx>
22 #include <ViewerTest.hxx>
23 #include <AIS_Shape.hxx>
24 #include <TopoDS_Shape.hxx>
25
26 #include <gp_Pnt2d.hxx>
27 #include <gp_Ax1.hxx>
28 #include <GCE2d_MakeSegment.hxx>
29 #include <Geom2d_TrimmedCurve.hxx>
30 #include <DrawTrSurf.hxx>
31
32 #include <Precision.hxx>
33
34 #include <PCollection_HAsciiString.hxx>
35
36 #include <cstdio>
37 #include <cmath>
38 #include <iostream>
39 #include <OSD_PerfMeter.hxx>
40 #include <OSD_Timer.hxx>
41 #include <BRepPrimAPI_MakeBox.hxx>
42 #include <BRepPrimAPI_MakeSphere.hxx>
43 #include <BRepAlgo_Cut.hxx>
44 #include <NCollection_Map.hxx>
45 #include <NCollection_Handle.hxx>
46 #include <TCollection_HAsciiString.hxx>
47
48 #include <Standard_Version.hxx>
49
50 #define QCOMPARE(val1, val2) \
51   di << "Checking " #val1 " == " #val2 << \
52         ((val1) == (val2) ? ": OK\n" : ": Error\n")
53
54 static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
55 {
56   if ( argc != 4) {
57     di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d" << "\n";
58     return 1;
59   }
60
61   gp_Pnt2d P1, P2;
62   if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
63     di << "ERROR OCC230: " << argv[2] << " is not Pnt2d" << "\n";
64     return 1;
65   }
66   if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
67     di << "ERROR OCC230: " << argv[3] << " is not Pnt2d" << "\n";
68     return 1;
69   }
70
71   GCE2d_MakeSegment MakeSegment(P1,P2);
72   Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
73   DrawTrSurf::Set(argv[1], TrimmedCurve);
74   return 0;
75 }
76
77 static Standard_Integer OCC142 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
78 {
79   for(Standard_Integer i= 0;i <= 20;i++){
80     Handle(PCollection_HAsciiString) pstr = new PCollection_HAsciiString("TEST");
81     pstr->Clear();
82   }
83   di << "OCC142: OK" << "\n";
84   return 0;
85 }
86
87 static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
88 {
89   gp_Pnt p(0, 0, 2);
90   
91   gp_Trsf t1, t2;
92   t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267);
93   t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880);
94
95   gp_Trsf tComp = t2 * t1;
96
97   gp_Pnt p1(10, 3, 4);
98   gp_Pnt p2 = p1.Transformed(tComp);
99   gp_Pnt p3 = p1.Transformed(t1);
100   p3.Transform(t2);
101
102   // points must be equal
103   if ( ! p2.IsEqual(p3, Precision::Confusion()) )
104     di << "ERROR OCC23361: equivalent transformations does not produce equal points" << "\n";
105   else 
106     di << "OCC23361: OK" << "\n";
107
108   return 0;
109 }
110
111 static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
112 {
113   OSD_PerfMeter aPM("TestMeter",0);
114   OSD_Timer aTM;
115   
116   // run some operation in cycle for about 2 seconds to have good values of times to compare
117   int count = 0;
118   printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n");
119   for (; aTM.ElapsedTime() < 2.; count++)
120   {
121     aPM.Start();
122     aTM.Start();
123
124     // do some operation that will take considerable time compared with time of starting / stopping timers
125     BRepPrimAPI_MakeBox aBox (10., 10., 10.);
126     BRepPrimAPI_MakeSphere aSphere (10.);
127     BRepAlgo_Cut aCutter (aBox.Shape(), aSphere.Shape());
128
129     aTM.Stop();
130     aPM.Stop();
131   }
132  
133   int aNbEnters = 0;
134   Standard_Real aPerfMeter_CPUtime = 0., aTimer_ElapsedTime = aTM.ElapsedTime();
135
136   perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
137
138   Standard_Real aTimeDiff = (fabs(aTimer_ElapsedTime - aPerfMeter_CPUtime) / aTimer_ElapsedTime);
139
140   printf("\nMeasurement results (%d cycles):\n", count);
141   printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer elapsed time: %lf\n", aPerfMeter_CPUtime, aTimer_ElapsedTime);
142   printf("Time delta is: %.3lf %%\n", aTimeDiff * 100);
143
144   if (aTimeDiff > 0.2)
145     di << "OCC23237: Error: too much difference between CPU and elapsed times";
146   else if (aNbEnters != count)
147     di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles";
148   else
149     di << "OCC23237: OK";
150
151   return 0;
152 }
153
154 #ifdef HAVE_TBB
155
156 #include <Standard_Atomic.hxx>
157 #include <tbb/blocked_range.h>
158 #include <tbb/parallel_for.h>
159
160 class IncrementerDecrementer
161 {
162 public:
163     IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
164     {}
165     void operator() (const tbb::blocked_range<size_t>& r) const
166     {
167         if (myPositive)
168             for (size_t i = r.begin(); i != r.end(); ++i)
169                 Standard_Atomic_Increment (myVal);
170         else
171             for (size_t i = r.begin(); i != r.end(); ++i)
172                 Standard_Atomic_Decrement (myVal);
173     }
174 private:
175     Standard_Integer*   myVal;
176     Standard_Boolean   myPositive;
177 };
178 #endif
179
180 #ifdef HAVE_TBB
181 static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
182 {
183   int aSum = 0;
184
185   //check returned value
186   QCOMPARE (Standard_Atomic_Decrement (&aSum), -1);
187   QCOMPARE (Standard_Atomic_Increment (&aSum), 0);
188   QCOMPARE (Standard_Atomic_Increment (&aSum), 1);
189   QCOMPARE (Standard_Atomic_Increment (&aSum), 2);
190 //  QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0);
191 //  QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1);
192
193   //check atomicity 
194   aSum = 0;
195   const int N = 1 << 24; //big enough to ensure concurrency
196
197   //increment
198   tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, true));
199   QCOMPARE (aSum, N);
200
201   //decrement
202   tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, false));
203   QCOMPARE (aSum, 0);
204
205   return 0;
206 }
207
208 #else /* HAVE_TBB */
209
210 static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char **argv)
211 {
212   di << "Test skipped: command " << argv[0] << " requires TBB library\n";
213   return 0;
214 }
215
216 #endif /* HAVE_TBB */
217
218 #include <TDocStd_Application.hxx>
219 #include <XCAFApp_Application.hxx>
220 #include <TDocStd_Document.hxx>
221 #include <XCAFDoc_ShapeTool.hxx>
222 #include <XCAFDoc_DocumentTool.hxx>
223 #include <TDF_Label.hxx>
224 #include <TDataStd_Name.hxx>
225
226 static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
227 {
228   const Handle(TDocStd_Application)& anApp = XCAFApp_Application::GetApplication();
229   Handle(TDocStd_Document) aDoc;
230   anApp->NewDocument ("XmlXCAF", aDoc);
231   QCOMPARE (!aDoc.IsNull(), Standard_True);
232
233   Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
234
235   //check default value
236   Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
237   QCOMPARE (aValue, Standard_True);
238
239   //true
240   XCAFDoc_ShapeTool::SetAutoNaming (Standard_True);
241   TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape();
242   TDF_Label aLabel = aShTool->AddShape (aShape);
243   Handle(TDataStd_Name) anAttr;
244   QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
245
246   //false
247   XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
248   aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape();
249   aLabel = aShTool->AddShape (aShape);
250   QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
251
252   //restore
253   XCAFDoc_ShapeTool::SetAutoNaming (aValue);
254
255   return 0;
256 }
257
258 #include <ExprIntrp_GenExp.hxx>
259 Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
260 {
261
262   if (argc != 3) {
263     di << "Usage : " << argv[0] << " string nb\n";
264     return 1;
265   }
266
267   TCollection_AsciiString aToken = argv[1];
268   Standard_Integer aNb = atoi(argv[2]);
269
270   Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create();
271   for (Standard_Integer i=0; i < aNb; i++)
272   {
273     aGen->Process(aToken);
274     Handle(Expr_GeneralExpression) aExpr = aGen->Expression();
275   }
276
277   return 0;
278 }
279
280 Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
281 {
282   gp_Mat M0;
283   di << "M0 = "
284   << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"
285   << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}"
286   << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}";
287   return 0;
288 }
289
290 #include <TopoDS_Face.hxx>
291 #include <TopoDS_Face.hxx>
292 #include <TopoDS.hxx>
293 #include <BRepBuilderAPI_Transform.hxx>
294 #include <BRepExtrema_DistShapeShape.hxx>
295 #include <BRepTools.hxx>
296
297 static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di)
298 {
299   BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN);
300   if(!distShapeShape.IsDone()) {
301     di <<"Distance ShapeShape is Not Done\n";
302     return Standard_False;
303   }
304
305   if(distShapeShape.Value() > 0.01) {
306     di << "Wrong Dist = " <<distShapeShape.Value() << "\n";
307     return Standard_False;
308   } else
309     di << "Dist0 = " <<distShapeShape.Value() <<"\n";
310
311   //////////////////////////////////////////////////////////////////////////
312   /// First Flip Y
313   const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970);
314   const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970);
315
316   gp_Vec2d mirrorVector1(axis1P1,axis1P2);
317
318   gp_Trsf2d mirror1;
319   mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1));
320
321   BRepBuilderAPI_Transform transformer1(mirror1);
322   transformer1.Perform(originalWire);
323   if(!transformer1.IsDone()) {
324     di << "Not Done1 " << "\n";
325     return Standard_False;
326   }
327   const TopoDS_Shape& step1ModifiedShape = transformer1.ModifiedShape(originalWire);
328   
329   BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN);
330   if(!distShapeShape1.IsDone())
331     return Standard_False;
332   if(distShapeShape1.Value() > 0.01) {
333     di << "Dist = " <<distShapeShape1.Value() <<"\n";
334     return Standard_False;
335   } else
336     di << "Dist1 = " <<distShapeShape1.Value() <<"\n";
337
338   //////////////////////////////////////////////////////////////////////////
339   /// Second flip Y
340   transformer1.Perform(step1ModifiedShape);
341   if(!transformer1.IsDone()) {
342     di << "Not Done1 \n";
343     return Standard_False;
344   }
345   const TopoDS_Shape& step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
346
347   //This is identity matrix for values but for type is gp_Rotation ?!
348   gp_Trsf2d mirror11 = mirror1;
349   mirror11.PreMultiply(mirror1);
350
351   BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN);
352   if(!distShapeShape2.IsDone())
353     return Standard_False;
354
355   //This last test case give error (the value is 1008.8822038689706)
356   if(distShapeShape2.Value() > 0.01) {
357     di  << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n";
358     Standard_Integer N = distShapeShape2.NbSolution();
359     di << "Nb = " <<N <<"\n";
360     for (Standard_Integer i=1;i <= N;i++)
361         di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n";
362     return Standard_False;
363   }
364   di << "Distance2 = " <<distShapeShape2.Value() <<"\n";
365  
366   return Standard_True;
367 }
368 static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a)
369
370
371   if (n != 3) {
372         di <<"OCC23774: invalid number of input parameters\n";
373         return 1;
374   }
375
376   const char *ns1 = (a[1]), *ns2 = (a[2]);
377   TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2));
378   if (S1.IsNull() || S2.IsNull()) {
379         di <<"OCC23774: Null input shapes\n";
380         return 1;
381   }
382   const TopoDS_Face& aFace  = TopoDS::Face(S1);
383   if(!OCC23774Test(aFace, S2, di))
384         di << "Something is wrong\n";
385
386  return 0;
387 }
388
389 #include <GeomConvert_ApproxSurface.hxx>
390 #include <Geom_BSplineSurface.hxx>
391 #include <Draw.hxx>
392 #include <OSD_Thread.hxx>
393 static void GeomConvertTest (Draw_Interpretor& di, Standard_Integer theTargetNbUPoles, Standard_CString theFileName)
394 {
395         Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theFileName);
396         GeomConvert_ApproxSurface aGAS (aSurf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
397         if (!aGAS.IsDone()) {
398                 di << "ApproxSurface is not done!" << "\n";
399                 return;
400         }
401         const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
402         if (aBSurf.IsNull()) {
403                 di << "BSplineSurface is not created!" << "\n";
404                 return;
405         }
406         di << "Number of UPoles:" << aBSurf->NbUPoles() << "\n";
407         QCOMPARE (aBSurf->NbUPoles(), theTargetNbUPoles);
408 }
409
410 struct aData {
411         Draw_Interpretor* di;
412         Standard_Integer nbupoles;
413         Standard_CString filename;
414 };
415
416 Standard_EXPORT Standard_Address convert(Standard_Address data)
417 {
418         aData* info = (aData*) data;
419         GeomConvertTest(*(info->di),info->nbupoles,info->filename);
420         return NULL;
421 }
422
423 static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
424 {
425         if (argc != 3) {
426                 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
427                 return 1;
428         }
429         struct aData aStorage;
430         aStorage.di = &di;
431         aStorage.nbupoles = Draw::Atoi(argv[1]); 
432         aStorage.filename = argv[2];
433
434         OSD_Thread aThread1(convert);
435         aThread1.Run(&aStorage);
436         GeomConvertTest(di,aStorage.nbupoles,aStorage.filename);
437         cout << "result of thread: " << aThread1.Wait() << endl;
438
439         return 0;
440 }
441
442 #include <GeomInt_IntSS.hxx>
443 static void GeomIntSSTest (Draw_Interpretor& di, Standard_Integer theNbSol, Standard_CString theFileName1, Standard_CString theFileName2)
444 {
445         Handle(Geom_Surface) aSurf1 = DrawTrSurf::GetSurface(theFileName1);
446         Handle(Geom_Surface) aSurf2 = DrawTrSurf::GetSurface(theFileName2);
447         GeomInt_IntSS anInter;
448         anInter.Perform(aSurf1, aSurf2, Precision::Confusion(), Standard_True);
449         if (!anInter.IsDone()) {
450                 di << "An intersection is not done!" << "\n";
451                 return;
452         }
453
454         di << "Number of Lines:" << anInter.NbLines() << "\n";
455         QCOMPARE (anInter.NbLines(), theNbSol);
456 }
457
458 struct aNewData {
459         Draw_Interpretor* di;
460         Standard_Integer nbsol;
461         Standard_CString filename1;
462         Standard_CString filename2;
463 };
464 Standard_EXPORT Standard_Address convert_inter(Standard_Address data)
465 {
466         aNewData* info = (aNewData*) data;
467         GeomIntSSTest(*(info->di),info->nbsol,info->filename1,info->filename2);
468         return NULL;
469 }
470
471 static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
472 {
473         if (argc != 4) {
474                 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
475                 return 1;
476         }
477         struct aNewData aStorage;
478         aStorage.di = &di;
479         aStorage.nbsol = Draw::Atoi(argv[1]); 
480         aStorage.filename1 = argv[2];
481         aStorage.filename2 = argv[3];
482
483         OSD_Thread aThread1(convert_inter);
484         aThread1.Run(&aStorage);
485         GeomIntSSTest(di,aStorage.nbsol,aStorage.filename1,aStorage.filename2);
486         cout << "result of thread: " << aThread1.Wait() << endl;
487
488         return 0;
489 }
490
491 #include <Geom_SurfaceOfRevolution.hxx> 
492 static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
493 {
494   if (argc < 2) {
495     di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n";
496     return 1;
497   }
498
499   Standard_Integer ucontinuity = 1;
500   Standard_Integer vcontinuity = 1;
501   Standard_Boolean iscnu = false;
502   Standard_Boolean iscnv = false;
503   
504   Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
505
506   QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
507   QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
508
509   return 0;
510 }
511
512 #include <gp_Ax1.hxx>
513 #include <gp_Ax22d.hxx>
514 #include <Geom_Plane.hxx>
515 #include <Geom2d_Circle.hxx>
516 #include <Geom2d_TrimmedCurve.hxx>
517 #include <BRepBuilderAPI_MakeEdge.hxx>
518 #include <BRepPrimAPI_MakeRevol.hxx>
519 #include <Geom2d_OffsetCurve.hxx>
520
521 static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
522 {
523   // Check the command arguments
524   if ( argc != 1 )
525   {
526     di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
527     di << "Usage: type help " << argv[0] << "\n";
528     return 1; // TCL_ERROR
529   }
530
531   gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
532   gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
533   Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
534
535   di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>" << "\n";
536   di << "-----------------------------------------------------------------------" << "\n";
537
538   Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
539   Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
540   TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
541
542   DBRep::Set("e1", E1);
543
544   BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
545   TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
546
547   DBRep::Set("f1", F1);
548
549   di << "Result: f1" << "\n";
550
551   di << "<<<< Preparing sample surface of revolution based on offset curve  >>>>" << "\n";
552   di << "-----------------------------------------------------------------------" << "\n";
553
554   Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
555   TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
556
557   DBRep::Set("e2", E2);
558
559   BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
560   TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
561
562   DBRep::Set("f2", F2);
563
564   di << "Result: f2" << "\n";
565
566   return 0;
567 }
568
569 #include <Geom_Curve.hxx>
570 #include <Geom_Surface.hxx>
571 #include <Precision.hxx>
572 #include <ShapeConstruct_ProjectCurveOnSurface.hxx>
573 //=======================================================================
574 //function : OCC24008
575 //purpose  : 
576 //=======================================================================
577 static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
578 {
579   if (argc != 3) {
580     di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
581     return 1;
582   }
583   Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]);
584   Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]);
585   if (aCurve.IsNull()) {
586     di << "Curve was not read" << "\n";
587         return 1;
588   }
589   if (aSurf.IsNull()) {
590         di << "Surface was not read" << "\n";
591         return 1;
592   }
593   ShapeConstruct_ProjectCurveOnSurface aProj;
594   aProj.Init (aSurf, Precision::Confusion());
595   try {
596     Handle(Geom2d_Curve) aPCurve;
597     aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve);
598     if (aPCurve.IsNull()) {
599           di << "PCurve was not created" << "\n";
600           return 1;
601     }
602   } catch (...) {
603     di << "Exception was caught" << "\n";
604   }
605   return 0;
606 }
607
608 #include <GeomAdaptor_Surface.hxx>
609 #include <Draw.hxx>
610 //=======================================================================
611 //function : OCC23945
612 //purpose  : 
613 //=======================================================================
614
615 static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
616 {
617   if (n < 5) return 1;
618
619   Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
620   if (aS.IsNull()) return 1;
621
622   GeomAdaptor_Surface GS(aS);
623
624   Standard_Real U = Draw::Atof(a[2]);
625   Standard_Real V = Draw::Atof(a[3]);
626
627   Standard_Boolean DrawPoint = ( n%3 == 2);
628   if ( DrawPoint) n--;
629
630   gp_Pnt P;
631   if (n >= 13) {
632     gp_Vec DU,DV;
633     if (n >= 22) {
634       gp_Vec D2U,D2V,D2UV;
635       GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
636       Draw::Set(a[13],D2U.X());
637       Draw::Set(a[14],D2U.Y());
638       Draw::Set(a[15],D2U.Z());
639       Draw::Set(a[16],D2V.X());
640       Draw::Set(a[17],D2V.Y());
641       Draw::Set(a[18],D2V.Z());
642       Draw::Set(a[19],D2UV.X());
643       Draw::Set(a[20],D2UV.Y());
644       Draw::Set(a[21],D2UV.Z());
645     }
646     else
647       GS.D1(U,V,P,DU,DV);
648
649     Draw::Set(a[7],DU.X());
650     Draw::Set(a[8],DU.Y());
651     Draw::Set(a[9],DU.Z());
652     Draw::Set(a[10],DV.X());
653     Draw::Set(a[11],DV.Y());
654     Draw::Set(a[12],DV.Z());
655   }
656   else 
657     GS.D0(U,V,P);
658
659   if ( n > 6) {
660     Draw::Set(a[4],P.X());
661     Draw::Set(a[5],P.Y());
662     Draw::Set(a[6],P.Z());
663   }
664   if ( DrawPoint) {
665     DrawTrSurf::Set(a[n],P);
666   }
667
668   return 0;
669 }
670
671 #include <Voxel_BoolDS.hxx>
672 #include <Voxel_FastConverter.hxx>
673 #include <Voxel_BooleanOperation.hxx>
674 static Standard_Integer OCC24019 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) 
675 {
676   if ( argc != 2 ) {
677     di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
678         return 1;
679   }
680
681   TCollection_AsciiString aFileName = argv[1];
682   TopoDS_Shape aShape;
683   BRep_Builder aBuilder;
684
685   if (!BRepTools::Read(aShape, aFileName.ToCString(), aBuilder)) {
686     di << "Error: Could not read a shape!" << "\n";
687         return 1;
688   }
689   
690   TopoDS_Solid aShape1 = BRepPrimAPI_MakeSphere(gp_Pnt(20,25,35), 7);
691
692   Standard_Real deflection = 0.005;
693   Standard_Integer nbThreads = 1;
694   Standard_Integer nbx = 200, nby = 200, nbz = 200;
695   Voxel_BoolDS theVoxels(0,0,0, 50, 50, 50, nbx, nby, nbz);
696   Voxel_BoolDS theVoxels1(0,0,0, 50, 50, 50, nbx, nby, nbz);
697
698   Standard_Integer progress = 0;
699   Voxel_FastConverter fcp(aShape, theVoxels, deflection, nbx, nby, nbz, nbThreads);
700   fcp.ConvertUsingSAT(progress, 1);
701   fcp.FillInVolume(1);
702
703   Voxel_FastConverter fcp1(aShape1, theVoxels1, deflection, nbx, nby, nbz, nbThreads);
704   fcp1.ConvertUsingSAT(progress, 1);
705   fcp1.FillInVolume(1);
706
707   Voxel_BooleanOperation op;
708   Standard_Boolean result = op.Cut(theVoxels1, theVoxels);
709   if ( result != 1 ) {
710     di << "Error: invalid boolean operation" << "\n";
711   } else {
712         di << "OK: boolean operation is ok" << "\n";
713   }
714
715   return 0;
716 }
717
718 //=======================================================================
719 //function : OCC11758
720 //purpose  : 
721 //=======================================================================
722 static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
723 {
724   if (n != 1) return 1;
725
726   const char* theStr = "0123456789";
727   Standard_Integer i, j;
728   for ( i = 0; i < 5; ++i ) {
729     // TCollection_AsciiString(const Standard_CString astring)
730     TCollection_AsciiString a(theStr+i);
731     // IsEqual (const Standard_CString other)const
732     //assert( a == theStr+i );
733     QCOMPARE ( a , theStr+i );
734
735     //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen )
736     TCollection_AsciiString b(theStr+i, 3);
737     //assert( b.Length() == 3 );
738     //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 );
739     //assert( strlen( b.ToCString() ) == 3 );
740     QCOMPARE ( b.Length() , 3 );
741     QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 );
742     QCOMPARE ( b.Length() , 3 );
743
744     //TCollection_AsciiString(const Standard_Integer aValue)
745     TCollection_AsciiString c(i);
746     //assert( c.IsIntegerValue() );
747     //assert( c.IntegerValue() == i );
748     QCOMPARE ( c.IsIntegerValue() , Standard_True );
749     QCOMPARE ( c.IntegerValue() , i );
750
751     //TCollection_AsciiString(const Standard_Real aValue)
752     TCollection_AsciiString d( 0.1*i );
753     //assert( d.IsRealValue() );
754     //assert( TCollection_AsciiString(3.3) == "3.3");
755     QCOMPARE ( d.IsRealValue() , Standard_True );
756     QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" );
757
758     //TCollection_AsciiString(const TCollection_AsciiString& astring)
759     TCollection_AsciiString e(d);
760     //assert( e == d );
761     //assert( e.Length() == d.Length() );
762     //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
763     QCOMPARE ( e ,d  );
764     QCOMPARE ( e.Length() , d.Length() );
765     QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
766
767     // TCollection_AsciiString(const TCollection_AsciiString& astring ,
768     //                         const Standard_Character other )
769     TCollection_AsciiString f(e,'\a');
770     //assert( f.Length() == e.Length() + 1 );
771     //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 );
772     //assert( f.Value( f.Length() ) == '\a');
773     QCOMPARE ( f.Length() , e.Length() + 1 );
774     QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 );
775     QCOMPARE ( f.Value( f.Length() ) , '\a' );
776
777     // TCollection_AsciiString(const TCollection_AsciiString& astring ,
778     //                         const Standard_CString other )
779     TCollection_AsciiString g(f, theStr);
780     //assert( g.Length() == f.Length() + strlen( theStr ));
781     //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 );
782     //assert( g.Search( theStr ) == f.Length() + 1 );
783     QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) );
784     QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 );
785     QCOMPARE ( g.Search( theStr ) , f.Length() + 1 );
786
787     // TCollection_AsciiString(const TCollection_AsciiString& astring ,
788     //                         const TCollection_AsciiString& other )
789     TCollection_AsciiString h(d,a);
790     //assert( h.Length() == d.Length() + a.Length() );
791     //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 );
792     //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 );
793     QCOMPARE ( h.Length() , d.Length() + a.Length() );
794     QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 );
795     QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 );
796
797     // AssignCat(const Standard_CString other)
798     c.AssignCat( a.ToCString() );
799     //assert( c.Length() == 1 + a.Length() );
800     //assert( c.Search( a ) == 2 );
801     QCOMPARE ( c.Length() , 1 + a.Length() );
802     QCOMPARE ( c.Search( a ) , 2 );
803
804     // AssignCat(const TCollection_AsciiString& other)
805     Standard_Integer dl = d.Length();
806     d.AssignCat( a );
807     //assert( d.Length() == dl + a.Length() );
808     //assert( d.Search( a ) == dl + 1 );
809     QCOMPARE ( d.Length() , dl + a.Length() );
810     QCOMPARE ( d.Search( a ) , dl + 1 );
811
812     // Capitalize()
813     TCollection_AsciiString capitalize("aBC");
814     capitalize.Capitalize();
815     //assert( capitalize == "Abc" );
816     QCOMPARE ( capitalize , "Abc" );
817
818     // Copy(const Standard_CString fromwhere)
819     d = theStr+i;
820     //assert( d == theStr+i );
821     QCOMPARE ( d , theStr+i );
822
823     // Copy(const TCollection_AsciiString& fromwhere)
824     d = h;
825     // IsEqual (const TCollection_AsciiString& other)const
826     //assert( d == h );
827     QCOMPARE ( d , h );
828
829     // Insert(const Standard_Integer where, const Standard_CString what)
830     dl = d.Length();
831     d.Insert( 2, theStr );
832     //assert( d.Length() == dl + strlen( theStr ));
833     //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 );
834     QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) );
835     QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 );
836
837     //Insert(const Standard_Integer where,const Standard_Character what)
838     d = theStr;
839     d.Insert( i+1, 'i' );
840     //assert( d.Length() == strlen( theStr ) + 1 );
841     //assert( d.Value( i+1 ) == 'i');
842     //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
843     QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
844     QCOMPARE ( d.Value( i+1 ) , 'i' );
845     QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
846
847     //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
848     d = theStr;
849     d.Insert( i+1, TCollection_AsciiString( "i" ));
850     //assert( d.Length() == strlen( theStr ) + 1 );
851     //assert( d.Value( i+1 ) == 'i');
852     //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
853     QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
854     QCOMPARE ( d.Value( i+1 ) , 'i' );
855     QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
856
857     // IsDifferent (const Standard_CString other)const
858     //assert( d.IsDifferent( theStr ));
859     //assert( d.IsDifferent( "theStr" ));
860     //assert( d.IsDifferent( "" ));
861     //assert( !d.IsDifferent( d.ToCString() ));
862     QCOMPARE ( d.IsDifferent( theStr ) , Standard_True );
863     QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True );
864     QCOMPARE ( d.IsDifferent( "" ) , Standard_True );
865     QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True );
866
867     // IsDifferent (const TCollection_AsciiString& other)const
868     //assert( d.IsDifferent( TCollection_AsciiString() ));
869     //assert( d.IsDifferent( a ));
870     //assert( d.IsDifferent( h ));
871     //assert( !d.IsDifferent( d ));
872     QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True );
873     QCOMPARE ( d.IsDifferent( a ) , Standard_True );
874     QCOMPARE ( d.IsDifferent( h ) , Standard_True );
875     QCOMPARE ( !d.IsDifferent( d ) , Standard_True );
876
877     // IsLess (const Standard_CString other)const
878     //assert( TCollection_AsciiString ("0"). IsLess("1"));
879     //assert( TCollection_AsciiString ("0"). IsLess("00"));
880     //assert( TCollection_AsciiString ("").  IsLess("0"));
881     //assert( !TCollection_AsciiString("1"). IsLess("0"));
882     //assert( !TCollection_AsciiString("00").IsLess("0"));
883     //assert( !TCollection_AsciiString("0"). IsLess(""));
884     //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1));
885     QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True );
886     QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True );
887     QCOMPARE ( TCollection_AsciiString ("").  IsLess("0") , Standard_True );
888     QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True );
889     QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True );
890     QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True );
891     QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True );
892
893     // IsLess (const TCollection_AsciiString& other)const
894     //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )));
895     //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")));
896     //assert( TCollection_AsciiString ("").  IsLess(TCollection_AsciiString("0" )));
897     //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )));
898     //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )));
899     //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString(""  )));
900     //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)));
901     QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True );
902     QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True );
903     QCOMPARE ( TCollection_AsciiString ("").  IsLess(TCollection_AsciiString("0" )) , Standard_True );
904     QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True );
905     QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True );
906     QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString(""  )) , Standard_True );
907     QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True );
908
909     // IsGreater (const Standard_CString other)const
910     //assert( !TCollection_AsciiString("0"). IsGreater("1"));
911     //assert( !TCollection_AsciiString("0"). IsGreater("00"));
912     //assert( !TCollection_AsciiString("").  IsGreater("0"));
913     //assert( TCollection_AsciiString ("1"). IsGreater("0"));
914     //assert( TCollection_AsciiString ("00").IsGreater("0"));
915     //assert( TCollection_AsciiString ("0"). IsGreater(""));
916     //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i));
917     QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True );
918     QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True );
919     QCOMPARE ( !TCollection_AsciiString("").  IsGreater("0") , Standard_True );
920     QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True );
921     QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True );
922     QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True );
923     QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True );
924
925     // IsGreater (const TCollection_AsciiString& other)const
926     //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )));
927     //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")));
928     //assert( !TCollection_AsciiString("").  IsGreater(TCollection_AsciiString("0" )));
929     //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )));
930     //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )));
931     //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString(""  )));
932     //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)));
933     QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True );
934     QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True );
935     QCOMPARE ( !TCollection_AsciiString("").  IsGreater(TCollection_AsciiString("0" )) , Standard_True );
936     QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
937     QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True );
938     QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString(""  )) , Standard_True );
939     QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True );
940
941     // void Read(Standard_IStream& astream)
942     std::istringstream is( theStr );
943     e.Read( is );
944     //assert( e == theStr );
945     QCOMPARE ( e , theStr );
946
947     // Standard_Integer SearchFromEnd (const Standard_CString what)const
948     //assert( e.SearchFromEnd( theStr + i ) == i + 1 );
949     QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 );
950
951     // SetValue(const Standard_Integer where, const Standard_CString what)
952     e.SetValue( i+1, "what");
953     //assert( e.Search( "what" ) == i+1 );
954     //assert( e.Length() == strlen( theStr ));
955     QCOMPARE ( e.Search( "what" ) , i+1 );
956     QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) );
957
958     // TCollection_AsciiString Split (const Standard_Integer where)
959     e = theStr;
960     d = e.Split( i+1 );
961     //assert( d.Length() + e.Length() == strlen( theStr ));
962     QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
963
964     // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
965     //                                    const Standard_Integer ToIndex) const
966     e = theStr;
967     d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 );
968     //assert( d.Length() == 3 );
969     //assert( d.Value(1) == theStr[ i ]);
970     QCOMPARE ( d.Length() , 3 );
971     QCOMPARE ( d.Value(1) , theStr[ i ] );
972
973     // TCollection_AsciiString Token (const Standard_CString separators,
974     //                                const Standard_Integer whichone) const
975     e = " ";
976     for ( j = 0; j < i; ++j ) {
977       e += TCollection_AsciiString( theStr[j] ) + " ";
978       //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 ));
979       QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) );
980     }
981   }
982   for ( i = 0; i < 5; ++i )
983   {
984     // TCollection_ExtendedString (const Standard_CString astring, 
985     //                             const Standard_Boolean isMultiByte) 
986     const TCollection_ExtendedString a( theStr+i );
987     //assert( TCollection_AsciiString( a ) == theStr+i );
988     QCOMPARE ( TCollection_AsciiString( a ) , theStr+i );
989
990     //TCollection_ExtendedString (const Standard_ExtString astring)
991     const TCollection_ExtendedString b( a.ToExtString() );
992     //assert( a == b );
993     QCOMPARE ( a , b );
994
995     // TCollection_ExtendedString (const Standard_Integer      length,
996     //                             const Standard_ExtCharacter filler )
997     const TCollection_ExtendedString c( i, 1 );
998     //assert( c.Length() == i );
999     QCOMPARE ( c.Length() , i );
1000     if ( c.Length() > 0 ) {
1001       //assert( c.Value( i ) == 1 );
1002       QCOMPARE ( c.Value( i ) , 1 );
1003     }
1004
1005     // TCollection_ExtendedString (const Standard_Integer aValue)
1006     TCollection_ExtendedString d( i );
1007     const TCollection_AsciiString da( d );
1008     //assert( da.IsIntegerValue() );
1009     //assert( da.IntegerValue() == i );
1010     QCOMPARE ( da.IsIntegerValue() , Standard_True );
1011     QCOMPARE (  da.IntegerValue(), i );
1012
1013     // TCollection_ExtendedString (const Standard_Real aValue)
1014     const TCollection_ExtendedString e( 0.1 * i );
1015     const TCollection_AsciiString ea( e );
1016     //assert( ea.IsRealValue() );
1017     //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 );
1018     QCOMPARE ( ea.IsRealValue() , Standard_True );
1019     QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True );
1020
1021     // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1022     const TCollection_ExtendedString f(e);
1023     //assert( f.Length() == e.Length());
1024     //assert( f == e );
1025     QCOMPARE ( f.Length() , e.Length() );
1026     QCOMPARE ( f , e );
1027
1028     // TCollection_ExtendedString (const TCollection_AsciiString& astring)
1029     const TCollection_ExtendedString g( ea );
1030     //assert( g.Length() == ea.Length() );
1031     //assert( TCollection_AsciiString( g ) == ea );
1032     QCOMPARE ( g.Length() , ea.Length() );
1033     QCOMPARE ( TCollection_AsciiString( g ) , ea );
1034
1035     // AssignCat (const TCollection_ExtendedString& other)
1036     const TCollection_ExtendedString sep(",");
1037     d.AssignCat( sep );
1038     d.AssignCat( g );
1039     //assert( d.Length() == 2 + g.Length() );
1040     //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i ));
1041     //assert( d.Token( sep.ToExtString(), 2 ) == g );
1042     QCOMPARE ( d.Length() , 2 + g.Length() );
1043     QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) );
1044     QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g );
1045
1046     // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const
1047     const TCollection_ExtendedString cat = a.Cat( sep );
1048     //assert( cat.Length() == a.Length() + sep.Length() );
1049     //assert( cat.Search( a ) == 1 );
1050     //assert( cat.Search( sep ) == a.Length() + 1 );
1051     QCOMPARE ( cat.Length() , a.Length() + sep.Length() );
1052     QCOMPARE ( cat.Search( a ) , 1 );
1053     QCOMPARE ( cat.Search( sep ) , a.Length() + 1 );
1054
1055     // Copy (const TCollection_ExtendedString& fromwhere)
1056     d = cat;
1057     //assert( d.Length() == cat.Length() );
1058     //assert( d == cat );
1059     QCOMPARE ( d.Length() , cat.Length() );
1060     QCOMPARE ( d , cat );
1061
1062     // IsEqual (const Standard_ExtString other) const
1063     //assert( d.IsEqual( d.ToExtString() ));
1064     QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1065
1066     // IsDifferent (const Standard_ExtString other ) const
1067     //assert( d.IsDifferent( a.ToExtString() ));
1068     QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1069
1070     // IsDifferent (const TCollection_ExtendedString& other) const
1071     //assert( d.IsDifferent( a ));
1072     QCOMPARE ( d.IsDifferent( a ) , Standard_True );
1073
1074     // IsLess (const Standard_ExtString other) const
1075     const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1);
1076     //assert( l0. IsLess( l1.ToExtString() ));
1077     //assert( l0. IsLess( l00.ToExtString() ));
1078     //assert( l.  IsLess( l0.ToExtString() ));
1079     //assert( ! l1. IsLess( l0.ToExtString() ));
1080     //assert( ! l00.IsLess( l0.ToExtString() ));
1081     //assert( ! l0. IsLess( l.ToExtString() ));
1082     //assert( ls.IsLess( ls1.ToExtString() ));
1083     QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True );
1084     QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True );
1085     QCOMPARE ( l.  IsLess( l0.ToExtString() ) , Standard_True );
1086     QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True );
1087     QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True );
1088     QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True );
1089     QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True );
1090
1091     // IsLess (const TCollection_ExtendedString& other) const
1092     //assert( l0. IsLess( l1 ));
1093     //assert( l0. IsLess( l00 ));
1094     //assert( l.  IsLess( l0 ));
1095     //assert( ! l1. IsLess( l0 ));
1096     //assert( ! l00.IsLess( l0 ));
1097     //assert( ! l0. IsLess( l ));
1098     //assert( ls.IsLess( ls1 ));
1099     QCOMPARE ( l0. IsLess( l1 ) , Standard_True );
1100     QCOMPARE ( l0. IsLess( l00 ) , Standard_True );
1101     QCOMPARE ( l.  IsLess( l0 ) , Standard_True );
1102     QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True );
1103     QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True );
1104     QCOMPARE ( ! l0. IsLess( l ) , Standard_True );
1105     QCOMPARE ( ls.IsLess( ls1 ) , Standard_True );
1106
1107     // IsGreater (const Standard_ExtString other) const
1108     //assert( ! l0.IsGreater( l1.ToExtString() ));
1109     //assert( ! l0.IsGreater( l00.ToExtString() ));
1110     //assert( ! l. IsGreater( l0.ToExtString() ));
1111     //assert(  l1. IsGreater( l0.ToExtString() ));
1112     //assert(  l00.IsGreater( l0.ToExtString() ));
1113     //assert(  l0. IsGreater( l.ToExtString() ));
1114     //assert(  ls1.IsGreater( ls.ToExtString() ));
1115     QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True );
1116     QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True );
1117     QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True );
1118     QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True );
1119     QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True );
1120     QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True );
1121     QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True  );
1122
1123     // IsGreater (const TCollection_ExtendedString& other) const
1124     //assert( ! l0.IsGreater( l1));
1125     //assert( ! l0.IsGreater( l00));
1126     //assert( ! l. IsGreater( l0));
1127     //assert(  l1. IsGreater( l0));
1128     //assert(  l00.IsGreater( l0));
1129     //assert(  l0. IsGreater( l));
1130     //assert(  ls1.IsGreater( ls));
1131     QCOMPARE ( ! l0.IsGreater( l1) , Standard_True );
1132     QCOMPARE ( ! l0.IsGreater( l00) , Standard_True );
1133     QCOMPARE ( ! l. IsGreater( l0) , Standard_True );
1134     QCOMPARE ( l1. IsGreater( l0) , Standard_True );
1135     QCOMPARE ( l00.IsGreater( l0) , Standard_True );
1136     QCOMPARE ( l0. IsGreater( l) , Standard_True );
1137     QCOMPARE ( ls1.IsGreater( ls) , Standard_True );
1138
1139     // ==========================
1140     //TCollection_HAsciiString::
1141     // ==========================
1142
1143     // IsDifferent(const Handle(TCollection_HAsciiString)& S)
1144     Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i );
1145     Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 );
1146     //assert( ha1->IsDifferent( ha2 ));
1147     //assert( !ha1->IsDifferent( ha1 ));
1148     QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True );
1149     QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True );
1150
1151     // IsSameString (const Handle(TCollection_HAsciiString)& S)
1152     //assert( !ha1->IsSameString( ha2 ));
1153     //assert( ha1->IsSameString( ha1 ));
1154     QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True );
1155     QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True );
1156
1157     // IsSameState (const Handle(TCollection_HAsciiString)& other) const
1158     //assert( !ha1->IsSameState( ha2 ));
1159     //assert( ha1->IsSameState( ha1 ));
1160     QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True );
1161     QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True );
1162
1163     // IsSameString (const Handle(TCollection_HAsciiString)& S ,
1164     //               const Standard_Boolean CaseSensitive) const
1165     //assert( !ha1->IsSameString( ha2, true ));
1166     //assert( ha1->IsSameString( ha1, true ));
1167     //assert( !ha1->IsSameString( ha2, false ));
1168     //assert( ha1->IsSameString( ha1, false ));
1169     QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1170     QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True );
1171     QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True );
1172     QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True );
1173
1174     ha1->SetValue( 1, "AbC0000000");
1175     ha2->SetValue( 1, "aBc0000000");
1176     //assert( !ha1->IsSameString( ha2, true ));
1177     //assert( ha1->IsSameString( ha2, false ));
1178     QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1179     QCOMPARE (  ha1->IsSameString( ha2, Standard_False ), Standard_True );
1180   }
1181   return 0;
1182 }
1183
1184 #include <Geom_CylindricalSurface.hxx>
1185 #include <IntTools_FaceFace.hxx>
1186 #include <IntTools_Curve.hxx>
1187 #include <IntTools_PntOn2Faces.hxx>
1188
1189 static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) 
1190 {
1191   if(theNArg < 2)
1192   {
1193     theDI << "Wrong a number of arguments!\n";
1194     return 1;
1195   }
1196
1197   Handle_Geom_Plane plane(new Geom_Plane(
1198                                   gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
1199                                   gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
1200                                   gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000))));
1201   Handle(Geom_CylindricalSurface) cylinder(
1202                   new Geom_CylindricalSurface(
1203                                   gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
1204                                   gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
1205                                   gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
1206                                                                                           19.712534607908712));
1207
1208   DrawTrSurf::Set("pln", plane);
1209   theDI << "pln\n";
1210   DrawTrSurf::Set("cyl", cylinder);
1211   theDI << "cyl\n";
1212
1213   BRep_Builder builder;
1214   TopoDS_Face face1, face2;
1215   builder.MakeFace(face1, plane, Precision::Confusion());
1216   builder.MakeFace(face2, cylinder, Precision::Confusion());
1217   IntTools_FaceFace anInters;
1218   anInters.SetParameters(false, true, true, Precision::Confusion());
1219   anInters.Perform(face1, face2);
1220
1221   if (!anInters.IsDone())
1222   {
1223     theDI<<"No intersections found!"<<"\n";
1224
1225     return 1;
1226   }
1227
1228   //Handle(Geom_Curve) aResult;
1229   //gp_Pnt             aPoint;
1230
1231   const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1232   const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1233
1234   char buf[1024];  
1235   Standard_Integer aNbCurves, aNbPoints;
1236
1237   aNbCurves=aCvsX.Length();
1238   aNbPoints=aPntsX.Length();
1239
1240   if (aNbCurves >= 2)
1241   {
1242     for (Standard_Integer i=1; i<=aNbCurves; ++i)
1243     {
1244       Sprintf(buf, "%s_%d",theArgv[1],i);
1245       theDI << buf << " ";
1246       
1247       const IntTools_Curve& aIC = aCvsX(i);
1248       const Handle(Geom_Curve)& aC3D= aIC.Curve();
1249       DrawTrSurf::Set(buf,aC3D);
1250     }
1251   }
1252   else if (aNbCurves == 1)
1253   {
1254     const IntTools_Curve& aIC = aCvsX(1);
1255     const Handle(Geom_Curve)& aC3D= aIC.Curve();
1256     Sprintf(buf, "%s",theArgv[1]);
1257     theDI << buf << " ";
1258     DrawTrSurf::Set(buf,aC3D);
1259   }
1260
1261   for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1262   {
1263     const IntTools_PntOn2Faces& aPi=aPntsX(i);
1264     const gp_Pnt& aP=aPi.P1().Pnt();
1265     
1266     Sprintf(buf,"%s_p_%d",theArgv[1],i);
1267     theDI << buf << " ";
1268     DrawTrSurf::Set(buf, aP);
1269   }
1270
1271   return 0;
1272 }
1273
1274 #include <Extrema_FuncExtPS.hxx>
1275 #include <math_FunctionSetRoot.hxx>
1276 #include <math_Vector.hxx>
1277 #include <BRepBuilderAPI_MakeVertex.hxx>
1278 static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) 
1279 {
1280   Standard_Integer anArgIter = 1;
1281   if (theNArg < 5)
1282     {
1283       theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]"<<"\n";
1284       return 1;
1285     }
1286
1287   // get target shape
1288   Standard_CString aFaceName = theArgv[anArgIter++];
1289   Standard_CString aVertName = theArgv[anArgIter++];
1290   const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
1291   const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
1292   const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
1293   const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
1294   const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
1295   if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
1296     {
1297       std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1298       return 1;
1299     }
1300   if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1301     {
1302       std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1303       return 1;
1304     }
1305   const TopoDS_Face   aFace = TopoDS::Face   (aShapeF);
1306   const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1307   GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1308
1309   gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1310
1311   Extrema_FuncExtPS    anExtFunc;
1312   math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
1313
1314   math_Vector aTolUV (1, 2), aUVinf  (1, 2), aUVsup  (1, 2), aFromUV (1, 2);
1315   aTolUV (1) =  Precision::Confusion(); aTolUV (2) =  Precision::Confusion();
1316   aUVinf (1) = -Precision::Infinite();  aUVinf (2) = -Precision::Infinite();
1317   aUVsup (1) =  Precision::Infinite();  aUVsup (2) =  Precision::Infinite();
1318   aFromUV(1) =  aUFrom; aFromUV(2) = aVFrom;
1319
1320   anExtFunc.Initialize (aSurf);
1321   anExtFunc.SetPoint (aPnt);
1322   aRoot.SetTolerance (aTolUV);
1323   aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1324   if (!aRoot.IsDone())
1325     {
1326       std::cerr << "No results!\n";
1327       return 1;
1328     }
1329
1330   theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1331   
1332   aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1333   DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1334   return 0;
1335 }
1336
1337 //! Check boolean operations on NCollection_Map
1338 static Standard_Integer OCC24271 (Draw_Interpretor& di,
1339                                   Standard_Integer  /*theArgNb*/,
1340                                   const char**      /*theArgVec*/)
1341 {
1342   // input data
1343   const Standard_Integer aLeftLower  = 1;
1344   const Standard_Integer aLeftUpper  = 10;
1345   const Standard_Integer aRightLower = 5;
1346   const Standard_Integer aRightUpper = 15;
1347
1348   // define arguments
1349   NCollection_Map<Standard_Integer> aMapLeft;
1350   for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1351   {
1352     aMapLeft.Add (aKeyIter);
1353   }
1354
1355   NCollection_Map<Standard_Integer> aMapRight;
1356   for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1357   {
1358     aMapRight.Add (aKeyIter);
1359   }
1360
1361   QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1362   QCOMPARE (aMapRight.Contains (aMapLeft),  Standard_False);
1363
1364   // validate Union operation
1365   NCollection_Map<Standard_Integer> aMapUnion;
1366   aMapUnion.Union (aMapLeft, aMapRight);
1367   QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1);
1368   for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter)
1369   {
1370     QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
1371   }
1372
1373   // validate Intersection operation
1374   NCollection_Map<Standard_Integer> aMapSect;
1375   aMapSect.Intersection (aMapLeft, aMapRight);
1376   QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1);
1377   for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1378   {
1379     QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1380   }
1381   QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1382   QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
1383
1384   // validate Substruction operation
1385   NCollection_Map<Standard_Integer> aMapSubsLR;
1386   aMapSubsLR.Subtraction (aMapLeft, aMapRight);
1387   QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower);
1388   for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1389   {
1390     QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
1391   }
1392
1393   NCollection_Map<Standard_Integer> aMapSubsRL;
1394   aMapSubsRL.Subtraction (aMapRight, aMapLeft);
1395   QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper);
1396   for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1397   {
1398     QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
1399   }
1400
1401   // validate Difference operation
1402   NCollection_Map<Standard_Integer> aMapDiff;
1403   aMapDiff.Difference (aMapLeft, aMapRight);
1404   QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper);
1405   for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1406   {
1407     QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1408   }
1409   for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1410   {
1411     QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1412   }
1413
1414   // validate Exchange operation
1415   NCollection_Map<Standard_Integer> aMapSwap;
1416   aMapSwap.Exchange (aMapSect);
1417   for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1418   {
1419     QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1420   }
1421   QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1422   aMapSwap.Add (34);
1423   aMapSect.Add (43);
1424
1425   NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1426   QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1427   aMapCopy.Remove (34);
1428   aMapCopy.Add    (43);
1429   QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1430
1431   return 0;
1432 }
1433
1434 #include <ShapeFix_EdgeProjAux.hxx>
1435 static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1436 {
1437   if (argc < 5) {
1438     di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n";
1439     return 1;
1440   }
1441
1442   TopoDS_Shape aSh = DBRep::Get(argv[1]);
1443   if (aSh.IsNull()) {
1444     di << argv[0] << " Error: Null input edge\n";
1445     return 1;
1446   }
1447   const TopoDS_Edge& anEdge = TopoDS::Edge (aSh);
1448
1449   Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]);
1450   if (aC.IsNull()) {
1451     di << argv[0] << " Error: Null input curve\n";
1452     return 1;
1453   }
1454
1455   Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]);
1456   if (aS.IsNull()) {
1457     di << argv[0] << " Error: Null input surface\n";
1458     return 1;
1459   }
1460
1461   Standard_Real prec = Draw::Atof(argv[4]);
1462   
1463   //prepare data
1464   TopoDS_Face aFace;
1465   BRep_Builder aB;
1466   aB.MakeFace (aFace, aS, Precision::Confusion());
1467   aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion());
1468   aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter());
1469
1470   //call algorithm
1471   ShapeFix_EdgeProjAux aProj (aFace, anEdge);
1472   aProj.Compute (prec);
1473   
1474   Standard_Boolean isfirstdone = aProj.IsFirstDone();
1475   Standard_Boolean islastdone = aProj.IsLastDone();
1476
1477   Standard_Real first = 0.;
1478   Standard_Real last = 0.;
1479   Standard_Integer isfirstdoneInteger = 0;
1480   Standard_Integer islastdoneInteger = 0;
1481
1482
1483   if (isfirstdone) {
1484     first = aProj.FirstParam();
1485     isfirstdoneInteger = 1;
1486   }
1487  
1488   if (islastdone) {
1489     last= aProj.LastParam();
1490     islastdoneInteger = 1;
1491   }
1492
1493   di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n";
1494
1495   return 0;
1496 }
1497
1498 template<typename T, typename HT>
1499 static void DoIsNull(Draw_Interpretor& di)
1500 {
1501   HT aHandle;
1502   //    QVERIFY (aHandle.IsNull());
1503   QCOMPARE (aHandle.IsNull(), Standard_True);
1504   const T* p = aHandle.Access();
1505 #if OCC_VERSION_HEX > 0x060700
1506   //QVERIFY (!p);
1507   //QVERIFY (p == 0);
1508   QCOMPARE (!p, Standard_True);
1509   QCOMPARE (p == 0, Standard_True);
1510 #endif
1511
1512   aHandle = new T;
1513   //QVERIFY (!aHandle.IsNull());
1514   QCOMPARE (!aHandle.IsNull(), Standard_True);
1515   p = aHandle.Access();
1516   //QVERIFY (p);
1517   //QVERIFY (p != 0);
1518   QCOMPARE (p != NULL, Standard_True);
1519   QCOMPARE (p != 0, Standard_True);
1520 }
1521
1522 //=======================================================================
1523 //function : OCC24533
1524 //purpose  : 
1525 //=======================================================================
1526 static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**)
1527 {
1528   if (n != 1) return 1;
1529
1530   DoIsNull<Standard_Transient, Handle_Standard_Transient>(di);
1531   DoIsNull<Standard_Persistent, Handle_Standard_Persistent>(di);
1532
1533   return 0;
1534 }
1535
1536 // Dummy class to test interface for compilation issues
1537 class QABugs_HandleClass : public Standard_Transient
1538 {
1539 public:
1540   Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer  , const char** theArgVec)
1541   {
1542     std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n";
1543     return 0;
1544   }
1545   DEFINE_STANDARD_RTTI(QABugs_HandleClass) // Type definition
1546 };
1547 DEFINE_STANDARD_HANDLE    (QABugs_HandleClass, Standard_Transient)
1548 IMPLEMENT_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1549 IMPLEMENT_STANDARD_RTTIEXT(QABugs_HandleClass, Standard_Transient)
1550
1551 // Dummy class to test interface for compilation issues
1552 struct QABugs_NHandleClass
1553 {
1554   Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer  , const char** theArgVec)
1555   {
1556     std::cerr << "QABugs_NHandleClass[" << this << "] " << "" << theArgVec[0] << "\n";
1557     return 0;
1558   }
1559 };
1560
1561 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
1562   const char *group = "QABugs";
1563
1564   Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass();
1565   theCommands.Add ("OCC24202_1", "Test Handle-based procedure",
1566                    __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group);
1567   NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass();
1568   theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure",
1569                    __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group);
1570
1571   theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
1572   theCommands.Add ("OCC142", "OCC142", __FILE__, OCC142, group);
1573   theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
1574   theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group); 
1575   theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
1576   theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
1577   theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
1578   theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
1579   theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
1580   theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
1581   theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
1582   theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
1583   theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
1584   theCommands.Add ("OCC23945", "OCC23945 surfname U V X Y Z [DUX DUY DUZ DVX DVY DVZ [D2UX D2UY D2UZ D2VX D2VY D2VZ D2UVX D2UVY D2UVZ]]", __FILE__, OCC23945,group);
1585   theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
1586   theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group);
1587   theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
1588   theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
1589   theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
1590   theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
1591   theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group);
1592   theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group);
1593   return;
1594 }