0025163: Wrong result of common operation for faces.
[occt.git] / src / QABugs / QABugs_19.cxx
... / ...
CommitLineData
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 under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <QABugs.hxx>
17
18#include <Draw_Interpretor.hxx>
19#include <DBRep.hxx>
20#include <DrawTrSurf.hxx>
21#include <ViewerTest.hxx>
22#include <TopoDS_Shape.hxx>
23#include <AIS_InteractiveContext.hxx>
24#include <AIS_TexturedShape.hxx>
25#include <Image_PixMap.hxx>
26#include <Image_Color.hxx>
27
28#include <gp_Pnt2d.hxx>
29#include <gp_Ax1.hxx>
30#include <GCE2d_MakeSegment.hxx>
31#include <Geom2d_TrimmedCurve.hxx>
32#include <DrawTrSurf.hxx>
33
34#include <Precision.hxx>
35
36#include <PCollection_HAsciiString.hxx>
37
38#include <cstdio>
39#include <cmath>
40#include <iostream>
41#include <OSD_PerfMeter.hxx>
42#include <OSD_Timer.hxx>
43#include <BRepPrimAPI_MakeBox.hxx>
44#include <BRepPrimAPI_MakeSphere.hxx>
45#include <BRepAlgo_Cut.hxx>
46#include <NCollection_Map.hxx>
47#include <NCollection_Handle.hxx>
48#include <TCollection_HAsciiString.hxx>
49#include <GeomFill_Trihedron.hxx>
50#include <BRepOffsetAPI_MakePipe.hxx>
51
52#include <Standard_Version.hxx>
53
54#define QCOMPARE(val1, val2) \
55 di << "Checking " #val1 " == " #val2 << \
56 ((val1) == (val2) ? ": OK\n" : ": Error\n")
57
58static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
59{
60 if ( argc != 4) {
61 di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d" << "\n";
62 return 1;
63 }
64
65 gp_Pnt2d P1, P2;
66 if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
67 di << "ERROR OCC230: " << argv[2] << " is not Pnt2d" << "\n";
68 return 1;
69 }
70 if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
71 di << "ERROR OCC230: " << argv[3] << " is not Pnt2d" << "\n";
72 return 1;
73 }
74
75 GCE2d_MakeSegment MakeSegment(P1,P2);
76 Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
77 DrawTrSurf::Set(argv[1], TrimmedCurve);
78 return 0;
79}
80
81static Standard_Integer OCC142 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
82{
83 for(Standard_Integer i= 0;i <= 20;i++){
84 Handle(PCollection_HAsciiString) pstr = new PCollection_HAsciiString("TEST");
85 pstr->Clear();
86 }
87 di << "OCC142: OK" << "\n";
88 return 0;
89}
90
91static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
92{
93 gp_Pnt p(0, 0, 2);
94
95 gp_Trsf t1, t2;
96 t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267);
97 t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880);
98
99 gp_Trsf tComp = t2 * t1;
100
101 gp_Pnt p1(10, 3, 4);
102 gp_Pnt p2 = p1.Transformed(tComp);
103 gp_Pnt p3 = p1.Transformed(t1);
104 p3.Transform(t2);
105
106 // points must be equal
107 if ( ! p2.IsEqual(p3, Precision::Confusion()) )
108 di << "ERROR OCC23361: equivalent transformations does not produce equal points" << "\n";
109 else
110 di << "OCC23361: OK" << "\n";
111
112 return 0;
113}
114
115static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
116{
117 OSD_PerfMeter aPM("TestMeter",0);
118 OSD_Timer aTM;
119
120 // run some operation in cycle for about 2 seconds to have good values of times to compare
121 int count = 0;
122 printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n");
123 for (; aTM.ElapsedTime() < 2.; count++)
124 {
125 aPM.Start();
126 aTM.Start();
127
128 // do some operation that will take considerable time compared with time of starting / stopping timers
129 BRepPrimAPI_MakeBox aBox (10., 10., 10.);
130 BRepPrimAPI_MakeSphere aSphere (10.);
131 BRepAlgo_Cut aCutter (aBox.Shape(), aSphere.Shape());
132
133 aTM.Stop();
134 aPM.Stop();
135 }
136
137 int aNbEnters = 0;
138 Standard_Real aPerfMeter_CPUtime = 0., aTimer_ElapsedTime = aTM.ElapsedTime();
139
140 perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
141
142 Standard_Real aTimeDiff = (fabs(aTimer_ElapsedTime - aPerfMeter_CPUtime) / aTimer_ElapsedTime);
143
144 printf("\nMeasurement results (%d cycles):\n", count);
145 printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer elapsed time: %lf\n", aPerfMeter_CPUtime, aTimer_ElapsedTime);
146 printf("Time delta is: %.3lf %%\n", aTimeDiff * 100);
147
148 if (aTimeDiff > 0.2)
149 di << "OCC23237: Error: too much difference between CPU and elapsed times";
150 else if (aNbEnters != count)
151 di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles";
152 else
153 di << "OCC23237: OK";
154
155 return 0;
156}
157
158#ifdef HAVE_TBB
159
160#include <Standard_Atomic.hxx>
161#include <tbb/blocked_range.h>
162#include <tbb/parallel_for.h>
163
164class IncrementerDecrementer
165{
166public:
167 IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
168 {}
169 void operator() (const tbb::blocked_range<size_t>& r) const
170 {
171 if (myPositive)
172 for (size_t i = r.begin(); i != r.end(); ++i)
173 Standard_Atomic_Increment (myVal);
174 else
175 for (size_t i = r.begin(); i != r.end(); ++i)
176 Standard_Atomic_Decrement (myVal);
177 }
178private:
179 Standard_Integer* myVal;
180 Standard_Boolean myPositive;
181};
182#endif
183
184#ifdef HAVE_TBB
185static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
186{
187 int aSum = 0;
188
189 //check returned value
190 QCOMPARE (Standard_Atomic_Decrement (&aSum), -1);
191 QCOMPARE (Standard_Atomic_Increment (&aSum), 0);
192 QCOMPARE (Standard_Atomic_Increment (&aSum), 1);
193 QCOMPARE (Standard_Atomic_Increment (&aSum), 2);
194// QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0);
195// QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1);
196
197 //check atomicity
198 aSum = 0;
199 const int N = 1 << 24; //big enough to ensure concurrency
200
201 //increment
202 tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, true));
203 QCOMPARE (aSum, N);
204
205 //decrement
206 tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, false));
207 QCOMPARE (aSum, 0);
208
209 return 0;
210}
211
212#else /* HAVE_TBB */
213
214static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char **argv)
215{
216 di << "Test skipped: command " << argv[0] << " requires TBB library\n";
217 return 0;
218}
219
220#endif /* HAVE_TBB */
221
222#include <TDocStd_Application.hxx>
223#include <XCAFApp_Application.hxx>
224#include <TDocStd_Document.hxx>
225#include <XCAFDoc_ShapeTool.hxx>
226#include <XCAFDoc_DocumentTool.hxx>
227#include <TDF_Label.hxx>
228#include <TDataStd_Name.hxx>
229
230static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
231{
232 const Handle(TDocStd_Application)& anApp = XCAFApp_Application::GetApplication();
233 Handle(TDocStd_Document) aDoc;
234 anApp->NewDocument ("XmlXCAF", aDoc);
235 QCOMPARE (!aDoc.IsNull(), Standard_True);
236
237 Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
238
239 //check default value
240 Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
241 QCOMPARE (aValue, Standard_True);
242
243 //true
244 XCAFDoc_ShapeTool::SetAutoNaming (Standard_True);
245 TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape();
246 TDF_Label aLabel = aShTool->AddShape (aShape);
247 Handle(TDataStd_Name) anAttr;
248 QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
249
250 //false
251 XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
252 aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape();
253 aLabel = aShTool->AddShape (aShape);
254 QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
255
256 //restore
257 XCAFDoc_ShapeTool::SetAutoNaming (aValue);
258
259 return 0;
260}
261
262#include <ExprIntrp_GenExp.hxx>
263Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
264{
265
266 if (argc != 3) {
267 di << "Usage : " << argv[0] << " string nb\n";
268 return 1;
269 }
270
271 TCollection_AsciiString aToken = argv[1];
272 Standard_Integer aNb = atoi(argv[2]);
273
274 Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create();
275 for (Standard_Integer i=0; i < aNb; i++)
276 {
277 aGen->Process(aToken);
278 Handle(Expr_GeneralExpression) aExpr = aGen->Expression();
279 }
280
281 return 0;
282}
283
284Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
285{
286 gp_Mat M0;
287 di << "M0 = "
288 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"
289 << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}"
290 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}";
291 return 0;
292}
293
294#include <TopoDS_Face.hxx>
295#include <TopoDS_Face.hxx>
296#include <TopoDS.hxx>
297#include <BRepBuilderAPI_Transform.hxx>
298#include <BRepExtrema_DistShapeShape.hxx>
299#include <BRepTools.hxx>
300
301static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di)
302{
303 BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN);
304 if(!distShapeShape.IsDone()) {
305 di <<"Distance ShapeShape is Not Done\n";
306 return Standard_False;
307 }
308
309 if(distShapeShape.Value() > 0.01) {
310 di << "Wrong Dist = " <<distShapeShape.Value() << "\n";
311 return Standard_False;
312 } else
313 di << "Dist0 = " <<distShapeShape.Value() <<"\n";
314
315 //////////////////////////////////////////////////////////////////////////
316 /// First Flip Y
317 const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970);
318 const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970);
319
320 gp_Vec2d mirrorVector1(axis1P1,axis1P2);
321
322 gp_Trsf2d mirror1;
323 mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1));
324
325 BRepBuilderAPI_Transform transformer1(mirror1);
326 transformer1.Perform(originalWire);
327 if(!transformer1.IsDone()) {
328 di << "Not Done1 " << "\n";
329 return Standard_False;
330 }
331 const TopoDS_Shape& step1ModifiedShape = transformer1.ModifiedShape(originalWire);
332
333 BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN);
334 if(!distShapeShape1.IsDone())
335 return Standard_False;
336 if(distShapeShape1.Value() > 0.01) {
337 di << "Dist = " <<distShapeShape1.Value() <<"\n";
338 return Standard_False;
339 } else
340 di << "Dist1 = " <<distShapeShape1.Value() <<"\n";
341
342 //////////////////////////////////////////////////////////////////////////
343 /// Second flip Y
344 transformer1.Perform(step1ModifiedShape);
345 if(!transformer1.IsDone()) {
346 di << "Not Done1 \n";
347 return Standard_False;
348 }
349 const TopoDS_Shape& step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
350
351 //This is identity matrix for values but for type is gp_Rotation ?!
352 gp_Trsf2d mirror11 = mirror1;
353 mirror11.PreMultiply(mirror1);
354
355 BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN);
356 if(!distShapeShape2.IsDone())
357 return Standard_False;
358
359 //This last test case give error (the value is 1008.8822038689706)
360 if(distShapeShape2.Value() > 0.01) {
361 di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n";
362 Standard_Integer N = distShapeShape2.NbSolution();
363 di << "Nb = " <<N <<"\n";
364 for (Standard_Integer i=1;i <= N;i++)
365 di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n";
366 return Standard_False;
367 }
368 di << "Distance2 = " <<distShapeShape2.Value() <<"\n";
369
370 return Standard_True;
371}
372static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a)
373{
374
375 if (n != 3) {
376 di <<"OCC23774: invalid number of input parameters\n";
377 return 1;
378 }
379
380 const char *ns1 = (a[1]), *ns2 = (a[2]);
381 TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2));
382 if (S1.IsNull() || S2.IsNull()) {
383 di <<"OCC23774: Null input shapes\n";
384 return 1;
385 }
386 const TopoDS_Face& aFace = TopoDS::Face(S1);
387 if(!OCC23774Test(aFace, S2, di))
388 di << "Something is wrong\n";
389
390 return 0;
391}
392
393#include <GeomConvert_ApproxSurface.hxx>
394#include <Geom_BSplineSurface.hxx>
395#include <Draw.hxx>
396#include <OSD_Thread.hxx>
397static void GeomConvertTest (Draw_Interpretor& di, Standard_Integer theTargetNbUPoles, Standard_CString theFileName)
398{
399 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theFileName);
400 GeomConvert_ApproxSurface aGAS (aSurf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
401 if (!aGAS.IsDone()) {
402 di << "ApproxSurface is not done!" << "\n";
403 return;
404 }
405 const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
406 if (aBSurf.IsNull()) {
407 di << "BSplineSurface is not created!" << "\n";
408 return;
409 }
410 di << "Number of UPoles:" << aBSurf->NbUPoles() << "\n";
411 QCOMPARE (aBSurf->NbUPoles(), theTargetNbUPoles);
412}
413
414struct aData {
415 Draw_Interpretor* di;
416 Standard_Integer nbupoles;
417 Standard_CString filename;
418};
419
420Standard_EXPORT Standard_Address convert(Standard_Address data)
421{
422 aData* info = (aData*) data;
423 GeomConvertTest(*(info->di),info->nbupoles,info->filename);
424 return NULL;
425}
426
427static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
428{
429 if (argc != 3) {
430 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
431 return 1;
432 }
433 struct aData aStorage;
434 aStorage.di = &di;
435 aStorage.nbupoles = Draw::Atoi(argv[1]);
436 aStorage.filename = argv[2];
437
438 OSD_Thread aThread1(convert);
439 aThread1.Run(&aStorage);
440 GeomConvertTest(di,aStorage.nbupoles,aStorage.filename);
441 cout << "result of thread: " << aThread1.Wait() << endl;
442
443 return 0;
444}
445
446#include <GeomInt_IntSS.hxx>
447static void GeomIntSSTest (Draw_Interpretor& di, Standard_Integer theNbSol, Standard_CString theFileName1, Standard_CString theFileName2)
448{
449 Handle(Geom_Surface) aSurf1 = DrawTrSurf::GetSurface(theFileName1);
450 Handle(Geom_Surface) aSurf2 = DrawTrSurf::GetSurface(theFileName2);
451 GeomInt_IntSS anInter;
452 anInter.Perform(aSurf1, aSurf2, Precision::Confusion(), Standard_True);
453 if (!anInter.IsDone()) {
454 di << "An intersection is not done!" << "\n";
455 return;
456 }
457
458 di << "Number of Lines:" << anInter.NbLines() << "\n";
459 QCOMPARE (anInter.NbLines(), theNbSol);
460}
461
462struct aNewData {
463 Draw_Interpretor* di;
464 Standard_Integer nbsol;
465 Standard_CString filename1;
466 Standard_CString filename2;
467};
468Standard_EXPORT Standard_Address convert_inter(Standard_Address data)
469{
470 aNewData* info = (aNewData*) data;
471 GeomIntSSTest(*(info->di),info->nbsol,info->filename1,info->filename2);
472 return NULL;
473}
474
475static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
476{
477 if (argc != 4) {
478 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
479 return 1;
480 }
481 struct aNewData aStorage;
482 aStorage.di = &di;
483 aStorage.nbsol = Draw::Atoi(argv[1]);
484 aStorage.filename1 = argv[2];
485 aStorage.filename2 = argv[3];
486
487 OSD_Thread aThread1(convert_inter);
488 aThread1.Run(&aStorage);
489 GeomIntSSTest(di,aStorage.nbsol,aStorage.filename1,aStorage.filename2);
490 cout << "result of thread: " << aThread1.Wait() << endl;
491
492 return 0;
493}
494
495#include <Geom_SurfaceOfRevolution.hxx>
496static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
497{
498 if (argc < 2) {
499 di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n";
500 return 1;
501 }
502
503 Standard_Integer ucontinuity = 1;
504 Standard_Integer vcontinuity = 1;
505 Standard_Boolean iscnu = false;
506 Standard_Boolean iscnv = false;
507
508 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
509
510 QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
511 QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
512
513 return 0;
514}
515
516#include <gp_Ax1.hxx>
517#include <gp_Ax22d.hxx>
518#include <Geom_Plane.hxx>
519#include <Geom2d_Circle.hxx>
520#include <Geom2d_TrimmedCurve.hxx>
521#include <BRepBuilderAPI_MakeEdge.hxx>
522#include <BRepPrimAPI_MakeRevol.hxx>
523#include <Geom2d_OffsetCurve.hxx>
524
525static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
526{
527 // Check the command arguments
528 if ( argc != 1 )
529 {
530 di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
531 di << "Usage: type help " << argv[0] << "\n";
532 return 1; // TCL_ERROR
533 }
534
535 gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
536 gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
537 Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
538
539 di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>" << "\n";
540 di << "-----------------------------------------------------------------------" << "\n";
541
542 Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
543 Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
544 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
545
546 DBRep::Set("e1", E1);
547
548 BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
549 TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
550
551 DBRep::Set("f1", F1);
552
553 di << "Result: f1" << "\n";
554
555 di << "<<<< Preparing sample surface of revolution based on offset curve >>>>" << "\n";
556 di << "-----------------------------------------------------------------------" << "\n";
557
558 Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
559 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
560
561 DBRep::Set("e2", E2);
562
563 BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
564 TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
565
566 DBRep::Set("f2", F2);
567
568 di << "Result: f2" << "\n";
569
570 return 0;
571}
572
573#include <Geom_Curve.hxx>
574#include <Geom_Surface.hxx>
575#include <Precision.hxx>
576#include <ShapeConstruct_ProjectCurveOnSurface.hxx>
577//=======================================================================
578//function : OCC24008
579//purpose :
580//=======================================================================
581static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
582{
583 if (argc != 3) {
584 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
585 return 1;
586 }
587 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]);
588 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]);
589 if (aCurve.IsNull()) {
590 di << "Curve was not read" << "\n";
591 return 1;
592 }
593 if (aSurf.IsNull()) {
594 di << "Surface was not read" << "\n";
595 return 1;
596 }
597 ShapeConstruct_ProjectCurveOnSurface aProj;
598 aProj.Init (aSurf, Precision::Confusion());
599 try {
600 Handle(Geom2d_Curve) aPCurve;
601 aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve);
602 if (aPCurve.IsNull()) {
603 di << "PCurve was not created" << "\n";
604 return 1;
605 }
606 } catch (...) {
607 di << "Exception was caught" << "\n";
608 }
609 return 0;
610}
611
612#include <GeomAdaptor_Surface.hxx>
613#include <Draw.hxx>
614//=======================================================================
615//function : OCC23945
616//purpose :
617//=======================================================================
618
619static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
620{
621 if (n < 5) return 1;
622
623 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
624 if (aS.IsNull()) return 1;
625
626 GeomAdaptor_Surface GS(aS);
627
628 Standard_Real U = Draw::Atof(a[2]);
629 Standard_Real V = Draw::Atof(a[3]);
630
631 Standard_Boolean DrawPoint = ( n%3 == 2);
632 if ( DrawPoint) n--;
633
634 gp_Pnt P;
635 if (n >= 13) {
636 gp_Vec DU,DV;
637 if (n >= 22) {
638 gp_Vec D2U,D2V,D2UV;
639 GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
640 Draw::Set(a[13],D2U.X());
641 Draw::Set(a[14],D2U.Y());
642 Draw::Set(a[15],D2U.Z());
643 Draw::Set(a[16],D2V.X());
644 Draw::Set(a[17],D2V.Y());
645 Draw::Set(a[18],D2V.Z());
646 Draw::Set(a[19],D2UV.X());
647 Draw::Set(a[20],D2UV.Y());
648 Draw::Set(a[21],D2UV.Z());
649 }
650 else
651 GS.D1(U,V,P,DU,DV);
652
653 Draw::Set(a[7],DU.X());
654 Draw::Set(a[8],DU.Y());
655 Draw::Set(a[9],DU.Z());
656 Draw::Set(a[10],DV.X());
657 Draw::Set(a[11],DV.Y());
658 Draw::Set(a[12],DV.Z());
659 }
660 else
661 GS.D0(U,V,P);
662
663 if ( n > 6) {
664 Draw::Set(a[4],P.X());
665 Draw::Set(a[5],P.Y());
666 Draw::Set(a[6],P.Z());
667 }
668 if ( DrawPoint) {
669 DrawTrSurf::Set(a[n],P);
670 }
671
672 return 0;
673}
674
675#include <Voxel_BoolDS.hxx>
676#include <Voxel_FastConverter.hxx>
677#include <Voxel_BooleanOperation.hxx>
678static Standard_Integer OCC24019 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
679{
680 if ( argc != 2 ) {
681 di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
682 return 1;
683 }
684
685 TCollection_AsciiString aFileName = argv[1];
686 TopoDS_Shape aShape;
687 BRep_Builder aBuilder;
688
689 if (!BRepTools::Read(aShape, aFileName.ToCString(), aBuilder)) {
690 di << "Error: Could not read a shape!" << "\n";
691 return 1;
692 }
693
694 TopoDS_Solid aShape1 = BRepPrimAPI_MakeSphere(gp_Pnt(20,25,35), 7);
695
696 Standard_Real deflection = 0.005;
697 Standard_Integer nbThreads = 1;
698 Standard_Integer nbx = 200, nby = 200, nbz = 200;
699 Voxel_BoolDS theVoxels(0,0,0, 50, 50, 50, nbx, nby, nbz);
700 Voxel_BoolDS theVoxels1(0,0,0, 50, 50, 50, nbx, nby, nbz);
701
702 Standard_Integer progress = 0;
703 Voxel_FastConverter fcp(aShape, theVoxels, deflection, nbx, nby, nbz, nbThreads);
704 fcp.ConvertUsingSAT(progress, 1);
705 fcp.FillInVolume(1);
706
707 Voxel_FastConverter fcp1(aShape1, theVoxels1, deflection, nbx, nby, nbz, nbThreads);
708 fcp1.ConvertUsingSAT(progress, 1);
709 fcp1.FillInVolume(1);
710
711 Voxel_BooleanOperation op;
712 Standard_Boolean result = op.Cut(theVoxels1, theVoxels);
713 if ( result != 1 ) {
714 di << "Error: invalid boolean operation" << "\n";
715 } else {
716 di << "OK: boolean operation is ok" << "\n";
717 }
718
719 return 0;
720}
721
722//=======================================================================
723//function : OCC11758
724//purpose :
725//=======================================================================
726static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
727{
728 if (n != 1) return 1;
729
730 const char* theStr = "0123456789";
731 Standard_Integer i, j;
732 for ( i = 0; i < 5; ++i ) {
733 // TCollection_AsciiString(const Standard_CString astring)
734 TCollection_AsciiString a(theStr+i);
735 // IsEqual (const Standard_CString other)const
736 //assert( a == theStr+i );
737 QCOMPARE ( a , theStr+i );
738
739 //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen )
740 TCollection_AsciiString b(theStr+i, 3);
741 //assert( b.Length() == 3 );
742 //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 );
743 //assert( strlen( b.ToCString() ) == 3 );
744 QCOMPARE ( b.Length() , 3 );
745 QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 );
746 QCOMPARE ( b.Length() , 3 );
747
748 //TCollection_AsciiString(const Standard_Integer aValue)
749 TCollection_AsciiString c(i);
750 //assert( c.IsIntegerValue() );
751 //assert( c.IntegerValue() == i );
752 QCOMPARE ( c.IsIntegerValue() , Standard_True );
753 QCOMPARE ( c.IntegerValue() , i );
754
755 //TCollection_AsciiString(const Standard_Real aValue)
756 TCollection_AsciiString d( 0.1*i );
757 //assert( d.IsRealValue() );
758 //assert( TCollection_AsciiString(3.3) == "3.3");
759 QCOMPARE ( d.IsRealValue() , Standard_True );
760 QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" );
761
762 //TCollection_AsciiString(const TCollection_AsciiString& astring)
763 TCollection_AsciiString e(d);
764 //assert( e == d );
765 //assert( e.Length() == d.Length() );
766 //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
767 QCOMPARE ( e ,d );
768 QCOMPARE ( e.Length() , d.Length() );
769 QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
770
771 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
772 // const Standard_Character other )
773 TCollection_AsciiString f(e,'\a');
774 //assert( f.Length() == e.Length() + 1 );
775 //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 );
776 //assert( f.Value( f.Length() ) == '\a');
777 QCOMPARE ( f.Length() , e.Length() + 1 );
778 QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 );
779 QCOMPARE ( f.Value( f.Length() ) , '\a' );
780
781 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
782 // const Standard_CString other )
783 TCollection_AsciiString g(f, theStr);
784 //assert( g.Length() == f.Length() + strlen( theStr ));
785 //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 );
786 //assert( g.Search( theStr ) == f.Length() + 1 );
787 QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) );
788 QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 );
789 QCOMPARE ( g.Search( theStr ) , f.Length() + 1 );
790
791 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
792 // const TCollection_AsciiString& other )
793 TCollection_AsciiString h(d,a);
794 //assert( h.Length() == d.Length() + a.Length() );
795 //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 );
796 //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 );
797 QCOMPARE ( h.Length() , d.Length() + a.Length() );
798 QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 );
799 QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 );
800
801 // AssignCat(const Standard_CString other)
802 c.AssignCat( a.ToCString() );
803 //assert( c.Length() == 1 + a.Length() );
804 //assert( c.Search( a ) == 2 );
805 QCOMPARE ( c.Length() , 1 + a.Length() );
806 QCOMPARE ( c.Search( a ) , 2 );
807
808 // AssignCat(const TCollection_AsciiString& other)
809 Standard_Integer dl = d.Length();
810 d.AssignCat( a );
811 //assert( d.Length() == dl + a.Length() );
812 //assert( d.Search( a ) == dl + 1 );
813 QCOMPARE ( d.Length() , dl + a.Length() );
814 QCOMPARE ( d.Search( a ) , dl + 1 );
815
816 // Capitalize()
817 TCollection_AsciiString capitalize("aBC");
818 capitalize.Capitalize();
819 //assert( capitalize == "Abc" );
820 QCOMPARE ( capitalize , "Abc" );
821
822 // Copy(const Standard_CString fromwhere)
823 d = theStr+i;
824 //assert( d == theStr+i );
825 QCOMPARE ( d , theStr+i );
826
827 // Copy(const TCollection_AsciiString& fromwhere)
828 d = h;
829 // IsEqual (const TCollection_AsciiString& other)const
830 //assert( d == h );
831 QCOMPARE ( d , h );
832
833 // Insert(const Standard_Integer where, const Standard_CString what)
834 dl = d.Length();
835 d.Insert( 2, theStr );
836 //assert( d.Length() == dl + strlen( theStr ));
837 //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 );
838 QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) );
839 QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 );
840
841 //Insert(const Standard_Integer where,const Standard_Character what)
842 d = theStr;
843 d.Insert( i+1, 'i' );
844 //assert( d.Length() == strlen( theStr ) + 1 );
845 //assert( d.Value( i+1 ) == 'i');
846 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
847 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
848 QCOMPARE ( d.Value( i+1 ) , 'i' );
849 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
850
851 //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
852 d = theStr;
853 d.Insert( i+1, TCollection_AsciiString( "i" ));
854 //assert( d.Length() == strlen( theStr ) + 1 );
855 //assert( d.Value( i+1 ) == 'i');
856 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
857 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
858 QCOMPARE ( d.Value( i+1 ) , 'i' );
859 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
860
861 // IsDifferent (const Standard_CString other)const
862 //assert( d.IsDifferent( theStr ));
863 //assert( d.IsDifferent( "theStr" ));
864 //assert( d.IsDifferent( "" ));
865 //assert( !d.IsDifferent( d.ToCString() ));
866 QCOMPARE ( d.IsDifferent( theStr ) , Standard_True );
867 QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True );
868 QCOMPARE ( d.IsDifferent( "" ) , Standard_True );
869 QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True );
870
871 // IsDifferent (const TCollection_AsciiString& other)const
872 //assert( d.IsDifferent( TCollection_AsciiString() ));
873 //assert( d.IsDifferent( a ));
874 //assert( d.IsDifferent( h ));
875 //assert( !d.IsDifferent( d ));
876 QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True );
877 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
878 QCOMPARE ( d.IsDifferent( h ) , Standard_True );
879 QCOMPARE ( !d.IsDifferent( d ) , Standard_True );
880
881 // IsLess (const Standard_CString other)const
882 //assert( TCollection_AsciiString ("0"). IsLess("1"));
883 //assert( TCollection_AsciiString ("0"). IsLess("00"));
884 //assert( TCollection_AsciiString (""). IsLess("0"));
885 //assert( !TCollection_AsciiString("1"). IsLess("0"));
886 //assert( !TCollection_AsciiString("00").IsLess("0"));
887 //assert( !TCollection_AsciiString("0"). IsLess(""));
888 //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1));
889 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True );
890 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True );
891 QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True );
892 QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True );
893 QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True );
894 QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True );
895 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True );
896
897 // IsLess (const TCollection_AsciiString& other)const
898 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )));
899 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")));
900 //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )));
901 //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )));
902 //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )));
903 //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )));
904 //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)));
905 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True );
906 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True );
907 QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True );
908 QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True );
909 QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True );
910 QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True );
911 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True );
912
913 // IsGreater (const Standard_CString other)const
914 //assert( !TCollection_AsciiString("0"). IsGreater("1"));
915 //assert( !TCollection_AsciiString("0"). IsGreater("00"));
916 //assert( !TCollection_AsciiString(""). IsGreater("0"));
917 //assert( TCollection_AsciiString ("1"). IsGreater("0"));
918 //assert( TCollection_AsciiString ("00").IsGreater("0"));
919 //assert( TCollection_AsciiString ("0"). IsGreater(""));
920 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i));
921 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True );
922 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True );
923 QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True );
924 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True );
925 QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True );
926 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True );
927 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True );
928
929 // IsGreater (const TCollection_AsciiString& other)const
930 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )));
931 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")));
932 //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )));
933 //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )));
934 //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )));
935 //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )));
936 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)));
937 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True );
938 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True );
939 QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
940 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
941 QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True );
942 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True );
943 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True );
944
945 // void Read(Standard_IStream& astream)
946 std::istringstream is( theStr );
947 e.Read( is );
948 //assert( e == theStr );
949 QCOMPARE ( e , theStr );
950
951 // Standard_Integer SearchFromEnd (const Standard_CString what)const
952 //assert( e.SearchFromEnd( theStr + i ) == i + 1 );
953 QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 );
954
955 // SetValue(const Standard_Integer where, const Standard_CString what)
956 e.SetValue( i+1, "what");
957 //assert( e.Search( "what" ) == i+1 );
958 //assert( e.Length() == strlen( theStr ));
959 QCOMPARE ( e.Search( "what" ) , i+1 );
960 QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) );
961
962 // TCollection_AsciiString Split (const Standard_Integer where)
963 e = theStr;
964 d = e.Split( i+1 );
965 //assert( d.Length() + e.Length() == strlen( theStr ));
966 QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
967
968 // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
969 // const Standard_Integer ToIndex) const
970 e = theStr;
971 d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 );
972 //assert( d.Length() == 3 );
973 //assert( d.Value(1) == theStr[ i ]);
974 QCOMPARE ( d.Length() , 3 );
975 QCOMPARE ( d.Value(1) , theStr[ i ] );
976
977 // TCollection_AsciiString Token (const Standard_CString separators,
978 // const Standard_Integer whichone) const
979 e = " ";
980 for ( j = 0; j < i; ++j ) {
981 e += TCollection_AsciiString( theStr[j] ) + " ";
982 //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 ));
983 QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) );
984 }
985 }
986 for ( i = 0; i < 5; ++i )
987 {
988 // TCollection_ExtendedString (const Standard_CString astring,
989 // const Standard_Boolean isMultiByte)
990 const TCollection_ExtendedString a( theStr+i );
991 //assert( TCollection_AsciiString( a ) == theStr+i );
992 QCOMPARE ( TCollection_AsciiString( a ) , theStr+i );
993
994 //TCollection_ExtendedString (const Standard_ExtString astring)
995 const TCollection_ExtendedString b( a.ToExtString() );
996 //assert( a == b );
997 QCOMPARE ( a , b );
998
999 // TCollection_ExtendedString (const Standard_Integer length,
1000 // const Standard_ExtCharacter filler )
1001 const TCollection_ExtendedString c( i, 1 );
1002 //assert( c.Length() == i );
1003 QCOMPARE ( c.Length() , i );
1004 if ( c.Length() > 0 ) {
1005 //assert( c.Value( i ) == 1 );
1006 QCOMPARE ( c.Value( i ) , 1 );
1007 }
1008
1009 // TCollection_ExtendedString (const Standard_Integer aValue)
1010 TCollection_ExtendedString d( i );
1011 const TCollection_AsciiString da( d );
1012 //assert( da.IsIntegerValue() );
1013 //assert( da.IntegerValue() == i );
1014 QCOMPARE ( da.IsIntegerValue() , Standard_True );
1015 QCOMPARE ( da.IntegerValue(), i );
1016
1017 // TCollection_ExtendedString (const Standard_Real aValue)
1018 const TCollection_ExtendedString e( 0.1 * i );
1019 const TCollection_AsciiString ea( e );
1020 //assert( ea.IsRealValue() );
1021 //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 );
1022 QCOMPARE ( ea.IsRealValue() , Standard_True );
1023 QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True );
1024
1025 // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1026 const TCollection_ExtendedString f(e);
1027 //assert( f.Length() == e.Length());
1028 //assert( f == e );
1029 QCOMPARE ( f.Length() , e.Length() );
1030 QCOMPARE ( f , e );
1031
1032 // TCollection_ExtendedString (const TCollection_AsciiString& astring)
1033 const TCollection_ExtendedString g( ea );
1034 //assert( g.Length() == ea.Length() );
1035 //assert( TCollection_AsciiString( g ) == ea );
1036 QCOMPARE ( g.Length() , ea.Length() );
1037 QCOMPARE ( TCollection_AsciiString( g ) , ea );
1038
1039 // AssignCat (const TCollection_ExtendedString& other)
1040 const TCollection_ExtendedString sep(",");
1041 d.AssignCat( sep );
1042 d.AssignCat( g );
1043 //assert( d.Length() == 2 + g.Length() );
1044 //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i ));
1045 //assert( d.Token( sep.ToExtString(), 2 ) == g );
1046 QCOMPARE ( d.Length() , 2 + g.Length() );
1047 QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) );
1048 QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g );
1049
1050 // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const
1051 const TCollection_ExtendedString cat = a.Cat( sep );
1052 //assert( cat.Length() == a.Length() + sep.Length() );
1053 //assert( cat.Search( a ) == 1 );
1054 //assert( cat.Search( sep ) == a.Length() + 1 );
1055 QCOMPARE ( cat.Length() , a.Length() + sep.Length() );
1056 QCOMPARE ( cat.Search( a ) , 1 );
1057 QCOMPARE ( cat.Search( sep ) , a.Length() + 1 );
1058
1059 // Copy (const TCollection_ExtendedString& fromwhere)
1060 d = cat;
1061 //assert( d.Length() == cat.Length() );
1062 //assert( d == cat );
1063 QCOMPARE ( d.Length() , cat.Length() );
1064 QCOMPARE ( d , cat );
1065
1066 // IsEqual (const Standard_ExtString other) const
1067 //assert( d.IsEqual( d.ToExtString() ));
1068 QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1069
1070 // IsDifferent (const Standard_ExtString other ) const
1071 //assert( d.IsDifferent( a.ToExtString() ));
1072 QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1073
1074 // IsDifferent (const TCollection_ExtendedString& other) const
1075 //assert( d.IsDifferent( a ));
1076 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
1077
1078 // IsLess (const Standard_ExtString other) const
1079 const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1);
1080 //assert( l0. IsLess( l1.ToExtString() ));
1081 //assert( l0. IsLess( l00.ToExtString() ));
1082 //assert( l. IsLess( l0.ToExtString() ));
1083 //assert( ! l1. IsLess( l0.ToExtString() ));
1084 //assert( ! l00.IsLess( l0.ToExtString() ));
1085 //assert( ! l0. IsLess( l.ToExtString() ));
1086 //assert( ls.IsLess( ls1.ToExtString() ));
1087 QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True );
1088 QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True );
1089 QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True );
1090 QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True );
1091 QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True );
1092 QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True );
1093 QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True );
1094
1095 // IsLess (const TCollection_ExtendedString& other) const
1096 //assert( l0. IsLess( l1 ));
1097 //assert( l0. IsLess( l00 ));
1098 //assert( l. IsLess( l0 ));
1099 //assert( ! l1. IsLess( l0 ));
1100 //assert( ! l00.IsLess( l0 ));
1101 //assert( ! l0. IsLess( l ));
1102 //assert( ls.IsLess( ls1 ));
1103 QCOMPARE ( l0. IsLess( l1 ) , Standard_True );
1104 QCOMPARE ( l0. IsLess( l00 ) , Standard_True );
1105 QCOMPARE ( l. IsLess( l0 ) , Standard_True );
1106 QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True );
1107 QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True );
1108 QCOMPARE ( ! l0. IsLess( l ) , Standard_True );
1109 QCOMPARE ( ls.IsLess( ls1 ) , Standard_True );
1110
1111 // IsGreater (const Standard_ExtString other) const
1112 //assert( ! l0.IsGreater( l1.ToExtString() ));
1113 //assert( ! l0.IsGreater( l00.ToExtString() ));
1114 //assert( ! l. IsGreater( l0.ToExtString() ));
1115 //assert( l1. IsGreater( l0.ToExtString() ));
1116 //assert( l00.IsGreater( l0.ToExtString() ));
1117 //assert( l0. IsGreater( l.ToExtString() ));
1118 //assert( ls1.IsGreater( ls.ToExtString() ));
1119 QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True );
1120 QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True );
1121 QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True );
1122 QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True );
1123 QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True );
1124 QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True );
1125 QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True );
1126
1127 // IsGreater (const TCollection_ExtendedString& other) const
1128 //assert( ! l0.IsGreater( l1));
1129 //assert( ! l0.IsGreater( l00));
1130 //assert( ! l. IsGreater( l0));
1131 //assert( l1. IsGreater( l0));
1132 //assert( l00.IsGreater( l0));
1133 //assert( l0. IsGreater( l));
1134 //assert( ls1.IsGreater( ls));
1135 QCOMPARE ( ! l0.IsGreater( l1) , Standard_True );
1136 QCOMPARE ( ! l0.IsGreater( l00) , Standard_True );
1137 QCOMPARE ( ! l. IsGreater( l0) , Standard_True );
1138 QCOMPARE ( l1. IsGreater( l0) , Standard_True );
1139 QCOMPARE ( l00.IsGreater( l0) , Standard_True );
1140 QCOMPARE ( l0. IsGreater( l) , Standard_True );
1141 QCOMPARE ( ls1.IsGreater( ls) , Standard_True );
1142
1143 // ==========================
1144 //TCollection_HAsciiString::
1145 // ==========================
1146
1147 // IsDifferent(const Handle(TCollection_HAsciiString)& S)
1148 Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i );
1149 Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 );
1150 //assert( ha1->IsDifferent( ha2 ));
1151 //assert( !ha1->IsDifferent( ha1 ));
1152 QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True );
1153 QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True );
1154
1155 // IsSameString (const Handle(TCollection_HAsciiString)& S)
1156 //assert( !ha1->IsSameString( ha2 ));
1157 //assert( ha1->IsSameString( ha1 ));
1158 QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True );
1159 QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True );
1160
1161 // IsSameState (const Handle(TCollection_HAsciiString)& other) const
1162 //assert( !ha1->IsSameState( ha2 ));
1163 //assert( ha1->IsSameState( ha1 ));
1164 QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True );
1165 QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True );
1166
1167 // IsSameString (const Handle(TCollection_HAsciiString)& S ,
1168 // const Standard_Boolean CaseSensitive) const
1169 //assert( !ha1->IsSameString( ha2, true ));
1170 //assert( ha1->IsSameString( ha1, true ));
1171 //assert( !ha1->IsSameString( ha2, false ));
1172 //assert( ha1->IsSameString( ha1, false ));
1173 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1174 QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True );
1175 QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True );
1176 QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True );
1177
1178 ha1->SetValue( 1, "AbC0000000");
1179 ha2->SetValue( 1, "aBc0000000");
1180 //assert( !ha1->IsSameString( ha2, true ));
1181 //assert( ha1->IsSameString( ha2, false ));
1182 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1183 QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True );
1184 }
1185 return 0;
1186}
1187
1188#include <Geom_CylindricalSurface.hxx>
1189#include <IntTools_FaceFace.hxx>
1190#include <IntTools_Curve.hxx>
1191#include <IntTools_PntOn2Faces.hxx>
1192
1193static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1194{
1195 if(theNArg < 2)
1196 {
1197 theDI << "Wrong a number of arguments!\n";
1198 return 1;
1199 }
1200
1201 Handle(Geom_Plane) plane(new Geom_Plane(
1202 gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
1203 gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
1204 gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000))));
1205 Handle(Geom_CylindricalSurface) cylinder(
1206 new Geom_CylindricalSurface(
1207 gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
1208 gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
1209 gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
1210 19.712534607908712));
1211
1212 DrawTrSurf::Set("pln", plane);
1213 theDI << "pln\n";
1214 DrawTrSurf::Set("cyl", cylinder);
1215 theDI << "cyl\n";
1216
1217 BRep_Builder builder;
1218 TopoDS_Face face1, face2;
1219 builder.MakeFace(face1, plane, Precision::Confusion());
1220 builder.MakeFace(face2, cylinder, Precision::Confusion());
1221 IntTools_FaceFace anInters;
1222 anInters.SetParameters(false, true, true, Precision::Confusion());
1223 anInters.Perform(face1, face2);
1224
1225 if (!anInters.IsDone())
1226 {
1227 theDI<<"No intersections found!"<<"\n";
1228
1229 return 1;
1230 }
1231
1232 //Handle(Geom_Curve) aResult;
1233 //gp_Pnt aPoint;
1234
1235 const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1236 const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1237
1238 char buf[1024];
1239 Standard_Integer aNbCurves, aNbPoints;
1240
1241 aNbCurves=aCvsX.Length();
1242 aNbPoints=aPntsX.Length();
1243
1244 if (aNbCurves >= 2)
1245 {
1246 for (Standard_Integer i=1; i<=aNbCurves; ++i)
1247 {
1248 Sprintf(buf, "%s_%d",theArgv[1],i);
1249 theDI << buf << " ";
1250
1251 const IntTools_Curve& aIC = aCvsX(i);
1252 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1253 DrawTrSurf::Set(buf,aC3D);
1254 }
1255 }
1256 else if (aNbCurves == 1)
1257 {
1258 const IntTools_Curve& aIC = aCvsX(1);
1259 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1260 Sprintf(buf, "%s",theArgv[1]);
1261 theDI << buf << " ";
1262 DrawTrSurf::Set(buf,aC3D);
1263 }
1264
1265 for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1266 {
1267 const IntTools_PntOn2Faces& aPi=aPntsX(i);
1268 const gp_Pnt& aP=aPi.P1().Pnt();
1269
1270 Sprintf(buf,"%s_p_%d",theArgv[1],i);
1271 theDI << buf << " ";
1272 DrawTrSurf::Set(buf, aP);
1273 }
1274
1275 return 0;
1276}
1277
1278#include <BRepAlgo_NormalProjection.hxx>
1279static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1280{
1281 if (argc != 3) {
1282 di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)";
1283 return 1;
1284 }
1285
1286 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1287 if(myAISContext.IsNull()) {
1288 di << "use 'vinit' command before " << argv[0] << "\n";
1289 return 1;
1290 }
1291
1292 TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1]));
1293 TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2]));
1294
1295 BRepAlgo_NormalProjection anormpro(m_Face1);
1296 anormpro.Add(m_Edge);
1297 anormpro.SetDefaultParams();
1298
1299 //anormpro.Compute3d();
1300 //anormpro.SetLimit();
1301
1302 anormpro.Build();
1303
1304 if (anormpro.IsDone())
1305 {
1306 TopoDS_Shape rshape = anormpro.Projection();
1307 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape);
1308 myAISContext->SetColor(myShape, Quantity_Color(Quantity_NOC_YELLOW));
1309 myAISContext->Display(myShape, Standard_True);
1310 }
1311
1312 return 0;
1313}
1314
1315#include <Voxel_FastConverter.hxx>
1316static Standard_Integer OCC24051 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1317{
1318 if (argc != 1) {
1319 di << "Usage : " << argv[0] << " should be one argument (command name only)";
1320 return 1;
1321 }
1322
1323 TopoDS_Shape shape = BRepPrimAPI_MakeBox(gp_Pnt(5, 10, 10), 10, 20, 30).Shape();
1324 Standard_Integer progress = 0;
1325 Standard_Real deflection = 0.005;
1326 Standard_Integer nbx = 200, nby = 200, nbz = 200;
1327 Voxel_BoolDS theVoxels(-50,-50,-30, 100, 100, 100, nbx, nby, nbz);
1328 Voxel_BoolDS theVoxels1(-50,-50,-30, 100, 100, 100, nbx, nby, nbz);
1329 Standard_Integer nbThreads = 5;
1330 Voxel_FastConverter fcp(shape, theVoxels, deflection, nbx, nby, nbz, nbThreads, Standard_True);
1331
1332 #ifdef WNT
1333 #pragma omp parallel for
1334 for(int i = 0; i < nbThreads; i++)
1335 fcp.ConvertUsingSAT(progress, i+1);
1336 #endif
1337
1338 fcp.ConvertUsingSAT(progress);
1339
1340 return 0;
1341}
1342
1343#include <BRepFeat_SplitShape.hxx>
1344#include <ShapeAnalysis_ShapeContents.hxx>
1345#include <BRepAlgo.hxx>
1346static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1347{
1348 if (argc != 3) {
1349 di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)";
1350 return 1;
1351 }
1352
1353 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1354 if(myAISContext.IsNull()) {
1355 di << "use 'vinit' command before " << argv[0] << "\n";
1356 return 1;
1357 }
1358
1359 TopoDS_Shape result;
1360 TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1]));
1361 TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2]));
1362
1363 BRepFeat_SplitShape asplit(face);
1364 asplit.Add(wire, face);
1365 asplit.Build();
1366 result = asplit.Shape();
1367 ShapeAnalysis_ShapeContents ana;
1368 ana.Perform(result);
1369 ana.NbFaces();
1370
1371 if (!(BRepAlgo::IsValid(result))) {
1372 di << "Result was checked and it is INVALID" << "\n";
1373 } else {
1374 di << "Result was checked and it is VALID" << "\n";
1375 }
1376
1377 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result);
1378 myAISContext->Display(myShape, Standard_True);
1379
1380 return 0;
1381}
1382
1383#include <Geom_Circle.hxx>
1384#include <GeomAdaptor_Curve.hxx>
1385#include <Extrema_ExtPC.hxx>
1386#include <gp_Cylinder.hxx>
1387#include <ElSLib.hxx>
1388static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1389{
1390 if (argc != 1) {
1391 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
1392 return 1;
1393 }
1394
1395 gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 );
1396 gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() );
1397 Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 );
1398 GeomAdaptor_Curve aC3D( aCircle );
1399
1400 Extrema_ExtPC aExtPC( aP3D, aC3D );
1401 //Standard_Real aParam = (aExtPC.Point(1)).Parameter();
1402 gp_Pnt aProj = (aExtPC.Point(1)).Value();
1403 di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n";
1404
1405 // Result of deviation
1406 gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() );
1407 gp_Cylinder aCylinder( aCylAxis, 1890. );
1408
1409 Standard_Real aU = 0., aV = 0.;
1410 ElSLib::Parameters( aCylinder, aProj, aU, aV );
1411 di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n";
1412
1413 return 0;
1414}
1415
1416#include <Extrema_FuncExtPS.hxx>
1417#include <math_FunctionSetRoot.hxx>
1418#include <math_Vector.hxx>
1419#include <BRepBuilderAPI_MakeVertex.hxx>
1420static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1421{
1422 Standard_Integer anArgIter = 1;
1423 if (theNArg < 5)
1424 {
1425 theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]"<<"\n";
1426 return 1;
1427 }
1428
1429 // get target shape
1430 Standard_CString aFaceName = theArgv[anArgIter++];
1431 Standard_CString aVertName = theArgv[anArgIter++];
1432 const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
1433 const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
1434 const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
1435 const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
1436 const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
1437 if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
1438 {
1439 std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1440 return 1;
1441 }
1442 if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1443 {
1444 std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1445 return 1;
1446 }
1447 const TopoDS_Face aFace = TopoDS::Face (aShapeF);
1448 const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1449 GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1450
1451 gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1452
1453 Extrema_FuncExtPS anExtFunc;
1454 math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
1455
1456 math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2);
1457 aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion();
1458 aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite();
1459 aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite();
1460 aFromUV(1) = aUFrom; aFromUV(2) = aVFrom;
1461
1462 anExtFunc.Initialize (aSurf);
1463 anExtFunc.SetPoint (aPnt);
1464 aRoot.SetTolerance (aTolUV);
1465 aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1466 if (!aRoot.IsDone())
1467 {
1468 std::cerr << "No results!\n";
1469 return 1;
1470 }
1471
1472 theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1473
1474 aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1475 DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1476 return 0;
1477}
1478
1479//! Check boolean operations on NCollection_Map
1480static Standard_Integer OCC24271 (Draw_Interpretor& di,
1481 Standard_Integer /*theArgNb*/,
1482 const char** /*theArgVec*/)
1483{
1484 // input data
1485 const Standard_Integer aLeftLower = 1;
1486 const Standard_Integer aLeftUpper = 10;
1487 const Standard_Integer aRightLower = 5;
1488 const Standard_Integer aRightUpper = 15;
1489
1490 // define arguments
1491 NCollection_Map<Standard_Integer> aMapLeft;
1492 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1493 {
1494 aMapLeft.Add (aKeyIter);
1495 }
1496
1497 NCollection_Map<Standard_Integer> aMapRight;
1498 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1499 {
1500 aMapRight.Add (aKeyIter);
1501 }
1502
1503 QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1504 QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False);
1505
1506 // validate Union operation
1507 NCollection_Map<Standard_Integer> aMapUnion;
1508 aMapUnion.Union (aMapLeft, aMapRight);
1509 QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1);
1510 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter)
1511 {
1512 QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
1513 }
1514
1515 // validate Intersection operation
1516 NCollection_Map<Standard_Integer> aMapSect;
1517 aMapSect.Intersection (aMapLeft, aMapRight);
1518 QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1);
1519 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1520 {
1521 QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1522 }
1523 QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1524 QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
1525
1526 // validate Substruction operation
1527 NCollection_Map<Standard_Integer> aMapSubsLR;
1528 aMapSubsLR.Subtraction (aMapLeft, aMapRight);
1529 QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower);
1530 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1531 {
1532 QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
1533 }
1534
1535 NCollection_Map<Standard_Integer> aMapSubsRL;
1536 aMapSubsRL.Subtraction (aMapRight, aMapLeft);
1537 QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper);
1538 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1539 {
1540 QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
1541 }
1542
1543 // validate Difference operation
1544 NCollection_Map<Standard_Integer> aMapDiff;
1545 aMapDiff.Difference (aMapLeft, aMapRight);
1546 QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper);
1547 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1548 {
1549 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1550 }
1551 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1552 {
1553 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1554 }
1555
1556 // validate Exchange operation
1557 NCollection_Map<Standard_Integer> aMapSwap;
1558 aMapSwap.Exchange (aMapSect);
1559 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1560 {
1561 QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1562 }
1563 QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1564 aMapSwap.Add (34);
1565 aMapSect.Add (43);
1566
1567 NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1568 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1569 aMapCopy.Remove (34);
1570 aMapCopy.Add (43);
1571 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1572
1573 return 0;
1574}
1575
1576#define QVERIFY(val1) \
1577 di << "Checking " #val1 " == Standard_True" << \
1578 ((val1) == Standard_True ? ": OK\n" : ": Error\n")
1579
1580#include <GeomInt_IntSS.hxx>
1581#include <Geom_ConicalSurface.hxx>
1582#include <Standard_ErrorHandler.hxx>
1583//=======================================================================
1584//function : OCC23972
1585//purpose :
1586//=======================================================================
1587static void DoGeomIntSSTest (const Handle(Geom_Surface)& theSurf1,
1588 const Handle(Geom_Surface)& theSurf2,
1589 const Standard_Integer theNbSol,
1590 Draw_Interpretor& di)
1591{
1592 try {
1593 OCC_CATCH_SIGNALS
1594 GeomInt_IntSS anInter;
1595 anInter.Perform (theSurf1, theSurf2, Precision::Confusion(), Standard_True);
1596 QVERIFY (anInter.IsDone());
1597 QCOMPARE (anInter.NbLines(), theNbSol);
1598 } catch (...) {
1599 QVERIFY (Standard_False);
1600 }
1601}
1602
1603namespace {
1604 static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc,
1605 const gp_Dir& theDir,
1606 const gp_Dir& theXDir,
1607 const Standard_Real theRad,
1608 const Standard_Real theSin,
1609 const Standard_Real theCos)
1610 {
1611 const Standard_Real anA = atan (theSin / theCos);
1612 gp_Ax3 anAxis (theLoc, theDir, theXDir);
1613 Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad);
1614 return aSurf;
1615 }
1616}
1617
1618static Standard_Integer OCC23972 (Draw_Interpretor& di,Standard_Integer n, const char**)
1619{
1620 if (n != 1) return 1;
1621
1622 //process specific cones, cannot read them from files because due to rounding the original error
1623 //in math_FunctionRoots gets hidden
1624 Handle(Geom_Surface) aS1 = CreateCone (
1625 gp_Pnt (123.694345356663, 789.9, 68.15),
1626 gp_Dir (-1, 3.48029791472957e-016, -8.41302743359754e-017),
1627 gp_Dir (-3.48029791472957e-016, -1, -3.17572289932207e-016),
1628 3.28206830417112,
1629 0.780868809443031,
1630 0.624695047554424);
1631 Handle(Geom_Surface) aS2 = CreateCone (
1632 gp_Pnt (123.694345356663, 784.9, 68.15),
1633 gp_Dir (-1, -2.5209507537117e-016, -1.49772808948866e-016),
1634 gp_Dir (1.49772808948866e-016, 3.17572289932207e-016, -1),
1635 3.28206830417112,
1636 0.780868809443031,
1637 0.624695047554424);
1638
1639 DoGeomIntSSTest (aS1, aS2, 2, di);
1640
1641 return 0;
1642}
1643
1644#include <ShapeFix_EdgeProjAux.hxx>
1645static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1646{
1647 if (argc < 5) {
1648 di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n";
1649 return 1;
1650 }
1651
1652 TopoDS_Shape aSh = DBRep::Get(argv[1]);
1653 if (aSh.IsNull()) {
1654 di << argv[0] << " Error: Null input edge\n";
1655 return 1;
1656 }
1657 const TopoDS_Edge& anEdge = TopoDS::Edge (aSh);
1658
1659 Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]);
1660 if (aC.IsNull()) {
1661 di << argv[0] << " Error: Null input curve\n";
1662 return 1;
1663 }
1664
1665 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]);
1666 if (aS.IsNull()) {
1667 di << argv[0] << " Error: Null input surface\n";
1668 return 1;
1669 }
1670
1671 Standard_Real prec = Draw::Atof(argv[4]);
1672
1673 //prepare data
1674 TopoDS_Face aFace;
1675 BRep_Builder aB;
1676 aB.MakeFace (aFace, aS, Precision::Confusion());
1677 aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion());
1678 aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter());
1679
1680 //call algorithm
1681 ShapeFix_EdgeProjAux aProj (aFace, anEdge);
1682 aProj.Compute (prec);
1683
1684 Standard_Boolean isfirstdone = aProj.IsFirstDone();
1685 Standard_Boolean islastdone = aProj.IsLastDone();
1686
1687 Standard_Real first = 0.;
1688 Standard_Real last = 0.;
1689 Standard_Integer isfirstdoneInteger = 0;
1690 Standard_Integer islastdoneInteger = 0;
1691
1692
1693 if (isfirstdone) {
1694 first = aProj.FirstParam();
1695 isfirstdoneInteger = 1;
1696 }
1697
1698 if (islastdone) {
1699 last= aProj.LastParam();
1700 islastdoneInteger = 1;
1701 }
1702
1703 di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n";
1704
1705 return 0;
1706}
1707
1708template<typename T, typename HT>
1709static void DoIsNull(Draw_Interpretor& di)
1710{
1711 HT aHandle;
1712 // QVERIFY (aHandle.IsNull());
1713 QCOMPARE (aHandle.IsNull(), Standard_True);
1714 const T* p = aHandle.Access();
1715#if OCC_VERSION_HEX > 0x060700
1716 //QVERIFY (!p);
1717 //QVERIFY (p == 0);
1718 QCOMPARE (!p, Standard_True);
1719 QCOMPARE (p == 0, Standard_True);
1720#endif
1721
1722 aHandle = new T;
1723 //QVERIFY (!aHandle.IsNull());
1724 QCOMPARE (!aHandle.IsNull(), Standard_True);
1725 p = aHandle.Access();
1726 //QVERIFY (p);
1727 //QVERIFY (p != 0);
1728 QCOMPARE (p != NULL, Standard_True);
1729 QCOMPARE (p != 0, Standard_True);
1730}
1731
1732//=======================================================================
1733//function : OCC24533
1734//purpose :
1735//=======================================================================
1736static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**)
1737{
1738 if (n != 1) return 1;
1739
1740 DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di);
1741 DoIsNull<Standard_Persistent, Handle(Standard_Persistent)>(di);
1742
1743 return 0;
1744}
1745
1746// Dummy class to test interface for compilation issues
1747class QABugs_HandleClass : public Standard_Transient
1748{
1749public:
1750 Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1751 {
1752 std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n";
1753 return 0;
1754 }
1755 DEFINE_STANDARD_RTTI(QABugs_HandleClass) // Type definition
1756};
1757DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1758IMPLEMENT_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1759IMPLEMENT_STANDARD_RTTIEXT(QABugs_HandleClass, Standard_Transient)
1760
1761// Dummy class to test interface for compilation issues
1762struct QABugs_NHandleClass
1763{
1764 Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1765 {
1766 std::cerr << "QABugs_NHandleClass[" << this << "] " << "" << theArgVec[0] << "\n";
1767 return 0;
1768 }
1769};
1770
1771#include <XCAFDoc_ColorTool.hxx>
1772#include <STEPControl_StepModelType.hxx>
1773#include <STEPCAFControl_Writer.hxx>
1774static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1775{
1776 if (argc != 1) {
1777 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
1778 return 1;
1779 }
1780 Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");;
1781 TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape();
1782 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape();
1783 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1);
1784 TDataStd_Name::Set(lab1, "Box1");
1785
1786 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1787 XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen);
1788 XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0);
1789
1790 STEPControl_StepModelType mode = STEPControl_AsIs;
1791 STEPCAFControl_Writer writer;
1792 if ( ! writer.Transfer (aDoc, mode ) )
1793 {
1794 di << "The document cannot be translated or gives no result" << "\n";
1795 return 1;
1796 }
1797
1798 writer.Write("test_box.step");
1799 return 0;
1800}
1801
1802
1803//=======================================================================
1804//function : OCC23950
1805//purpose :
1806//=======================================================================
1807static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1808{
1809 if (argc != 2) {
1810 di << "Usage : " << argv[0] << " step_file\n";
1811 return 1;
1812 }
1813
1814 Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy");
1815 TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
1816 gp_Trsf t0;
1817 TopLoc_Location location0 (t0);
1818
1819 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1820 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6);
1821 TDataStd_Name::Set(lab1, "Point1");
1822
1823 TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1824 TDataStd_Name::Set(labelA0, "ASSEMBLY");
1825
1826 TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
1827
1828 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1829 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
1830 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
1831
1832 STEPControl_StepModelType mode = STEPControl_AsIs;
1833 STEPCAFControl_Writer writer;
1834 if (! writer.Transfer (aDoc, mode))
1835 {
1836 di << "The document cannot be translated or gives no result" << "\n";
1837 return 1;
1838 }
1839
1840 writer.Write (argv[1]);
1841 return 0;
1842}
1843
1844//=======================================================================
1845//function : OCC24622
1846//purpose : The command tests sourcing Image_PixMap to AIS_TexturedShape
1847//=======================================================================
1848static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
1849{
1850 if (theArgNb != 2)
1851 {
1852 std::cout << "Usage : " << theArgVec[0] << " texture={1D|2D}";
1853 return 1;
1854 }
1855
1856 const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
1857 if (anAISContext.IsNull())
1858 {
1859 std::cout << "Please initialize view with \"vinit\".\n";
1860 return 1;
1861 }
1862
1863 Handle(Image_PixMap) anImage = new Image_PixMap();
1864
1865 static const Image_ColorRGB aBitmap[8] =
1866 {
1867 {{255, 0, 0}}, {{0, 148, 255}}, {{ 0, 148, 255}}, {{255, 94, 0}},
1868 {{255, 121, 0}}, {{76, 255, 0}}, {{76, 255, 0}}, {{255, 202, 0}}
1869 };
1870
1871 TCollection_AsciiString aTextureTypeArg (theArgVec[1]);
1872 aTextureTypeArg.UpperCase();
1873 if (aTextureTypeArg == "1D")
1874 {
1875 anImage->InitWrapper (Image_PixMap::ImgRGB, (Standard_Byte*)aBitmap, 8, 1);
1876 }
1877 else if (aTextureTypeArg == "2D")
1878 {
1879 anImage->InitTrash (Image_PixMap::ImgRGB, 8, 8);
1880 for (Standard_Integer aRow = 0; aRow < 8; ++aRow)
1881 {
1882 for (Standard_Integer aCol = 0; aCol < 8; ++aCol)
1883 {
1884 anImage->ChangeValue<Image_ColorRGB> (aRow, aCol) = aBitmap[aRow];
1885 }
1886 }
1887 }
1888 else
1889 {
1890 std::cout << "Please specify type of texture to test {1D|2D}.\n";
1891 return 1;
1892 }
1893
1894 TopoDS_Shape aBlankShape = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
1895
1896 Handle(AIS_TexturedShape) aTexturedShape = new AIS_TexturedShape (aBlankShape);
1897 aTexturedShape->SetTexturePixMap (anImage);
1898 anAISContext->Display (aTexturedShape, 3, 0);
1899
1900 return 0;
1901}
1902
1903//=======================================================================
1904//function : OCC24667
1905//purpose :
1906//=======================================================================
1907static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1908{
1909 if (n == 1)
1910 {
1911 di << "OCC24667 result Wire_spine Profile [Mode [Approx]]" << "\n";
1912 di << "Mode = 0 - CorrectedFrenet," << "\n";
1913 di << " = 1 - Frenet," << "\n";
1914 di << " = 2 - DiscreteTrihedron" << "\n";
1915 di << "Approx - force C1-approximation if result is C0" << "\n";
1916 return 0;
1917 }
1918
1919 if (n > 1 && n < 4) return 1;
1920
1921 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
1922 if ( Spine.IsNull()) return 1;
1923
1924 TopoDS_Shape Profile = DBRep::Get(a[3]);
1925 if ( Profile.IsNull()) return 1;
1926
1927 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
1928 if (n >= 5)
1929 {
1930 Standard_Integer iMode = atoi(a[4]);
1931 if (iMode == 1)
1932 Mode = GeomFill_IsFrenet;
1933 else if (iMode == 2)
1934 Mode = GeomFill_IsDiscreteTrihedron;
1935 }
1936
1937 Standard_Boolean ForceApproxC1 = Standard_False;
1938 if (n >= 6)
1939 ForceApproxC1 = Standard_True;
1940
1941 BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine),
1942 Profile,
1943 Mode,
1944 ForceApproxC1);
1945
1946 TopoDS_Shape S = aPipe.Shape();
1947 TopoDS_Shape aSF = aPipe.FirstShape();
1948 TopoDS_Shape aSL = aPipe.LastShape();
1949
1950 DBRep::Set(a[1],S);
1951
1952 TCollection_AsciiString aStrF(a[1], "_f");
1953 TCollection_AsciiString aStrL(a[1], "_l");
1954
1955 DBRep::Set(aStrF.ToCString(), aSF);
1956 DBRep::Set(aStrL.ToCString(), aSL);
1957
1958 return 0;
1959}
1960
1961#include <IGESControl_Reader.hxx>
1962#include <IGESControl_Controller.hxx>
1963#include <IGESData_IGESEntity.hxx>
1964#include <BRepCheck_Analyzer.hxx>
1965#include <PTColStd_TransientPersistentMap.hxx>
1966#include <PTopoDS_HShape.hxx>
1967#include <Storage_Data.hxx>
1968#include <TopExp_Explorer.hxx>
1969#include <MgtBRep.hxx>
1970#include <FSD_File.hxx>
1971#include <ShapeSchema.hxx>
1972#include <TColStd_HSequenceOfTransient.hxx>
1973#include <PTColStd_PersistentTransientMap.hxx>
1974#include <Storage_Root.hxx>
1975
1976static Standard_Integer OCC24565 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1977{
1978 if (argc != 3) {
1979 di << "Usage : " << argv[0] << " FileNameIGS FileNameSTOR";
1980 return 1;
1981 }
1982
1983 Standard_CString sFileNameIGS = argv[1];
1984 Standard_CString sFileNameSTOR = argv[2];
1985
1986 IGESControl_Reader ICReader;
1987
1988 /* * * * * * *
1989 * Read the IGES file and make sure it is valid
1990 *
1991 * * * * * * */
1992 IGESControl_Controller::Init();
1993
1994 if (!ICReader.ReadFile(sFileNameIGS)) {
1995 printf("%s:%d - Error reading '%s'\n",__FUNCTION__,__LINE__,sFileNameIGS);fflush(stdout);
1996 return -1;
1997 }
1998
1999 int nbShapes = ICReader.NbShapes();
2000
2001 printf("%s:%d - nbShapes = '%d'\n",__FUNCTION__,__LINE__,nbShapes);fflush(stdout);
2002
2003 TopoDS_Shape Shape;
2004 if(nbShapes == 0)
2005 {
2006 Handle(TColStd_HSequenceOfTransient) faces=ICReader.GiveList("iges-faces");
2007 Handle(TColStd_HSequenceOfTransient) surfaceList=ICReader.GiveList("xst-transferrable-roots",faces);
2008
2009 if (surfaceList.IsNull())
2010 {
2011 printf("%s:%d - surfaceList.IsNull()\n",__FUNCTION__,__LINE__);fflush(stdout);
2012 return -1;
2013 }
2014 BRep_Builder builder;
2015 TopoDS_Compound* pC = new TopoDS_Compound();
2016 builder.MakeCompound(*pC);
2017
2018 for (int j=1;j<=surfaceList->Length();j++)
2019 {
2020 Handle(IGESData_IGESEntity) igesEntity=Handle(IGESData_IGESEntity)::DownCast(surfaceList->Value(j));
2021 if (igesEntity.IsNull()) continue;
2022 ICReader.ClearShapes();
2023 Standard_Boolean rv;
2024 try {
2025 rv=ICReader.TransferEntity(igesEntity);
2026 }
2027 catch (...) {
2028 rv=Standard_False;
2029 }
2030 if (!rv) {
2031 printf("%s:%d - Error transferring IGES entity\n",__FUNCTION__,__LINE__);fflush(stdout);
2032 printf("%s:%d - FormNumber = %d, TypeNumber = %d\n",__FUNCTION__,__LINE__,igesEntity->FormNumber(),igesEntity->TypeNumber());fflush(stdout);
2033 return -1;
2034 }
2035
2036 TopoDS_Shape S;
2037 try {
2038 S=ICReader.Shape();
2039 }
2040 catch(...) {
2041 printf("%s:%d - Error reading IGES entity\n",__FUNCTION__,__LINE__);fflush(stdout);
2042 printf("%s:%d - FormNumber = %d, TypeNumber = %d\n",__FUNCTION__,__LINE__,igesEntity->FormNumber(),igesEntity->TypeNumber());fflush(stdout);
2043 return -1;
2044 }
2045 if (S.IsNull()) {
2046 printf("%s:%d - NULL Surface encountered\n",__FUNCTION__,__LINE__);
2047 return -1;
2048 }
2049
2050 try
2051 {
2052 builder.Add(*pC,S);
2053 }
2054 catch(...)
2055 {
2056 printf("%s: Exception adding face.\n",__FUNCTION__);
2057 }
2058 }
2059 Shape = TopoDS_Shape(*pC);
2060 }
2061 else
2062 {
2063 Shape = ICReader.OneShape();
2064 }
2065 {
2066 BRepCheck_Analyzer brca(Shape);
2067
2068 if(!brca.IsValid())
2069 {
2070 printf("%s: Invalid shape after reading IGES file.\n",__FUNCTION__);
2071 }
2072 }
2073
2074 /* * * * * * *
2075 * Write the contents of the Shape to a STOR file
2076 *
2077 * * * * * * */
2078 PTColStd_TransientPersistentMap aMapTP;
2079 Handle(PTopoDS_HShape) aPShape_write;
2080 Handle(Storage_Data) d_write=new Storage_Data;
2081 char Name[32];
2082
2083 TopExp_Explorer Ex;
2084 int i;
2085 int max_i = 0;
2086
2087 for (i=0,Ex.Init(Shape,TopAbs_FACE);Ex.More();i++,Ex.Next())
2088 {
2089
2090 max_i = i;
2091 try {
2092 aPShape_write=MgtBRep::Translate(Ex.Current(),aMapTP,MgtBRep_WithoutTriangle);
2093 }
2094 catch (...) {
2095 printf("%s: Error translating surface '%d'\n",__FUNCTION__,i);
2096 }
2097
2098 sprintf(Name,"S%010d",i);
2099
2100 {
2101 BRepCheck_Analyzer brca(Ex.Current());
2102 if(!brca.IsValid())
2103 {
2104 printf("INVALID face '%s' in the shape, which will be written to the STOR file.\n",Name);
2105 }
2106 }
2107 try {
2108 d_write->AddRoot(Name,aPShape_write);
2109 }
2110 catch (...) {
2111 printf("%s: Error adding surface '%d', RootName = '%s'\n",__FUNCTION__,i,Name);
2112 }
2113 }
2114 printf("%s: Going to write %d surfaces.\n",__FUNCTION__,max_i+1);
2115
2116 FSD_File f_write;
2117 if(f_write.Open(sFileNameSTOR, Storage_VSWrite)!=Storage_VSOk)
2118 {
2119 printf("%s: Error opening file: %s\n", __FUNCTION__,sFileNameSTOR);
2120 return -1;
2121 }
2122 Handle(ShapeSchema) s_write=new ShapeSchema;
2123 s_write->Write(f_write,d_write);
2124 f_write.Close();
2125 printf("%s: Wrote to the STOR file.\n",__FUNCTION__);
2126
2127 /* * * * * * *
2128 * Read the contents of the Shape from a STOR file
2129 *
2130 * * * * * * */
2131 FSD_File f_read;
2132 if(f_read.Open(sFileNameSTOR, Storage_VSRead)!=Storage_VSOk)
2133 {
2134 printf("%s: Error opening file: %s\n", __FUNCTION__,sFileNameSTOR);
2135 return -1;
2136 }
2137 Handle(ShapeSchema) s_read=new ShapeSchema;
2138 Handle(Storage_Data) d_read=s_read->Read(f_read);
2139
2140 Handle(Standard_Persistent) p;
2141 Handle(Storage_Root) r;
2142 Handle(PTopoDS_HShape) aPShape_read;
2143 PTColStd_PersistentTransientMap aMapPT;
2144 TopoDS_Shape S_read;
2145
2146 printf("%s: Extracting %d faces from the STOR file.\n",__FUNCTION__,max_i+1);
2147 for(int i = 0; i <= max_i; ++i)
2148 {
2149 sprintf(Name,"S%010d",i);
2150 r=d_read->Find(Name);
2151 if(r.IsNull())
2152 {
2153 printf("%s:%d '%s' IsNull().\n",__FUNCTION__,__LINE__,Name);fflush(stdout);
2154 continue;
2155 }
2156 p=r->Object();
2157 aPShape_read = Handle(PTopoDS_HShape)::DownCast(p);
2158 try {
2159 MgtBRep::Translate(aPShape_read,aMapPT,S_read,MgtBRep_WithoutTriangle);
2160 }
2161 catch (Standard_Failure) {
2162 Handle(Standard_Failure) E=Standard_Failure::Caught();
2163 std::string str;
2164 str="Exception: ";
2165 str+=E->DynamicType()->Name();
2166 str+=" => ";
2167 str+=E->GetMessageString();
2168 printf("%s(1): %s: %s\n",__FUNCTION__,Name,str.c_str());fflush(stdout);
2169 }
2170 catch (...) {
2171 printf("%s(1): Unhandled exception in MgtBRep::Translate\n",__FUNCTION__);
2172 }
2173
2174 BRepCheck_Analyzer brca(S_read);
2175
2176 if(!brca.IsValid())
2177 {
2178 printf("%s: Read INVALID face (%s)!\n",__FUNCTION__,Name);
2179 }
2180 }
2181
2182 printf("Completed.\n");fflush(stdout);
2183
2184 return 0;
2185}
2186
2187#include <Handle_BRepTools_NurbsConvertModification.hxx>
2188#include <BRepPrimAPI_MakeCylinder.hxx>
2189#include <BRepBuilderAPI_Copy.hxx>
2190#include <BRepTools_NurbsConvertModification.hxx>
2191static TopoDS_Shape CreateTestShape (int& theShapeNb)
2192{
2193 TopoDS_Compound aComp;
2194 BRep_Builder aBuilder;
2195 aBuilder.MakeCompound (aComp);
2196 //NURBS modifier is used to increase footprint of each shape
2197 Handle_BRepTools_NurbsConvertModification aNurbsModif = new BRepTools_NurbsConvertModification;
2198 TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid();
2199 BRepTools_Modifier aModifier (aRefShape, aNurbsModif);
2200 if (aModifier.IsDone()) {
2201 aRefShape = aModifier.ModifiedShape (aRefShape);
2202 }
2203 int aSiblingNb = 0;
2204 for (; theShapeNb > 0; --theShapeNb) {
2205 TopoDS_Shape aShape;
2206 if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists
2207 aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape();
2208 } else {
2209 aShape = CreateTestShape (theShapeNb);
2210 }
2211 aBuilder.Add (aComp, aShape);
2212 }
2213 return aComp;
2214}
2215
2216#include <AppStd_Application.hxx>
2217#include <TDataStd_Integer.hxx>
2218#include <TNaming_Builder.hxx>
2219static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2220{
2221 if (argc != 1) {
2222 di << "Usage: " << argv[0] << " invalid number of arguments"<<"\n";
2223 return 1;
2224 }
2225 TCollection_ExtendedString aFileName ("testdocument.xml");
2226 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2227
2228 Handle(TDocStd_Application) anApp = new AppStd_Application;
2229 {
2230 Handle(TDocStd_Document) aDoc;
2231 anApp->NewDocument ("XmlOcaf", aDoc);
2232 TDF_Label aLab = aDoc->Main();
2233 TDataStd_Integer::Set (aLab, 0);
2234 int n = 10000; //must be big enough
2235 TopoDS_Shape aShape = CreateTestShape (n);
2236 TNaming_Builder aBuilder (aLab);
2237 aBuilder.Generated (aShape);
2238
2239 aSStatus = anApp->SaveAs (aDoc, aFileName);
2240 anApp->Close (aDoc);
2241 }
2242 QCOMPARE (aSStatus, PCDM_SS_OK);
2243 return 0;
2244}
2245
2246#include <AppStdL_Application.hxx>
2247#include <TDocStd_Application.hxx>
2248#include <TDataStd_Integer.hxx>
2249#include <TDF_AttributeIterator.hxx>
2250//=======================================================================
2251//function : OCC24755
2252//purpose :
2253//=======================================================================
2254static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2255{
2256 if (n != 1)
2257 {
2258 std::cout << "Usage : " << a[0] << "\n";
2259 return 1;
2260 }
2261
2262 Handle(TDocStd_Application) anApp = new AppStdL_Application;
2263 Handle(TDocStd_Document) aDoc;
2264 anApp->NewDocument ("MDTV-Standard", aDoc);
2265 TDF_Label aLab = aDoc->Main();
2266 TDataStd_Integer::Set (aLab, 0);
2267 TDataStd_Name::Set (aLab, "test");
2268
2269 TDF_AttributeIterator i (aLab);
2270 Handle(TDF_Attribute) anAttr = i.Value();
2271 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True);
2272 i.Next();
2273 anAttr = i.Value();
2274 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True);
2275
2276 return 0;
2277}
2278
2279struct MyStubObject
2280{
2281 MyStubObject() : ptr(0L) {}
2282 MyStubObject(void* thePtr) : ptr(thePtr) {}
2283 char overhead[40];
2284 void* ptr;
2285};
2286
2287//=======================================================================
2288//function : OCC24834
2289//purpose :
2290//=======================================================================
2291static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2292{
2293 if (n != 1)
2294 {
2295 std::cout << "Usage : " << a[0] << "\n";
2296 return 1;
2297 }
2298
2299 int i = sizeof (char*);
2300 if (i > 4) {
2301 std::cout << "64-bit architecture is not supported.\n";
2302 return 0;
2303 }
2304
2305 NCollection_List<MyStubObject> aList;
2306 const Standard_Integer aSmallBlockSize = 40;
2307 const Standard_Integer aLargeBlockSize = 1500000;
2308
2309 // quick populate memory with large blocks
2310 try
2311 {
2312 for (;;)
2313 {
2314 aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize)));
2315 }
2316 }
2317 catch (Standard_Failure)
2318 {
2319 di << "caught out of memory for large blocks: OK\n";
2320 }
2321 catch (...)
2322 {
2323 di << "skept out of memory for large blocks: Error\n";
2324 }
2325
2326 // allocate small blocks
2327 try
2328 {
2329 for (;;)
2330 {
2331 aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize)));
2332 }
2333 }
2334 catch (Standard_Failure)
2335 {
2336 di << "caught out of memory for small blocks: OK\n";
2337 }
2338 catch (...)
2339 {
2340 di << "skept out of memory for small blocks: Error\n";
2341 }
2342
2343 // release all allocated blocks
2344 for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next())
2345 {
2346 Standard::Free(it.Value().ptr);
2347 }
2348 return 0;
2349}
2350
2351
2352#include <Geom2dAPI_InterCurveCurve.hxx>
2353#include <IntRes2d_IntersectionPoint.hxx>
2354//=======================================================================
2355//function : OCC24889
2356//purpose :
2357//=======================================================================
2358static Standard_Integer OCC24889 (Draw_Interpretor& theDI,
2359 Standard_Integer /*theNArg*/,
2360 const char** /*theArgs*/)
2361{
2362 // Curves
2363 Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle(
2364 gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2365
2366 Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle(
2367 gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2368
2369 Handle( Geom2d_TrimmedCurve ) aTrim[2] = {
2370 new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ),
2371 new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 )
2372 };
2373
2374 DrawTrSurf::Set("c_1", aTrim[0]);
2375 DrawTrSurf::Set("c_2", aTrim[1]);
2376
2377 // Intersection
2378 const Standard_Real aTol = Precision::Confusion();
2379 Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol );
2380
2381 const IntRes2d_IntersectionPoint& aIntPnt =
2382 aIntTool.Intersector().Point( 1 );
2383
2384 gp_Pnt2d aIntRes = aIntTool.Point( 1 );
2385 Standard_Real aPar[2] = {
2386 aIntPnt.ParamOnFirst(),
2387 aIntPnt.ParamOnSecond()
2388 };
2389
2390 //theDI.precision( 5 );
2391 theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n";
2392 for (int i = 0; i < 2; ++i)
2393 {
2394 theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() <<
2395 "; LastParam = " << aTrim[i]->LastParameter() <<
2396 "; IntParameter = " << aPar[i] << "\n";
2397 }
2398
2399 return 0;
2400}
2401
2402#include <math_GlobOptMin.hxx>
2403#include <math_MultipleVarFunctionWithHessian.hxx>
2404//=======================================================================
2405//function : OCC25004
2406//purpose : Check extremaCC on Branin function.
2407//=======================================================================
2408// Function is:
2409// f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s
2410// Standard borders are:
2411// -5 <= u <= 10
2412// 0 <= v <= 15
2413class BraninFunction : public math_MultipleVarFunctionWithHessian
2414{
2415public:
2416 BraninFunction()
2417 {
2418 a = 1.0;
2419 b = 5.1 / (4.0 * M_PI * M_PI);
2420 c = 5.0 / M_PI;
2421 r = 6.0;
2422 s = 10.0;
2423 t = 1.0 / (8.0 * M_PI);
2424 }
2425 virtual Standard_Integer NbVariables() const
2426 {
2427 return 2;
2428 }
2429 virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F)
2430 {
2431 Standard_Real u = X(1);
2432 Standard_Real v = X(2);
2433
2434 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2435 Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion.
2436 F = a * aSqPt * aSqPt + aLnPt + s;
2437 return Standard_True;
2438 }
2439 virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G)
2440 {
2441 Standard_Real u = X(1);
2442 Standard_Real v = X(2);
2443
2444 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2445 G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u);
2446 G(2) = 2 * a * aSqPt;
2447
2448 return Standard_True;
2449 }
2450 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
2451 {
2452 Value(X,F);
2453 Gradient(X,G);
2454
2455 return Standard_True;
2456 }
2457 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H)
2458 {
2459 Value(X,F);
2460 Gradient(X,G);
2461
2462 Standard_Real u = X(1);
2463 Standard_Real v = X(2);
2464
2465 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2466 Standard_Real aTmpPt = c - 2 * b *u; // Tmp part.
2467 H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u);
2468 H(1,2) = 2 * a * aTmpPt;
2469 H(2,1) = H(1,2);
2470 H(2,2) = 2 * a;
2471
2472 return Standard_True;
2473 }
2474
2475private:
2476 // Standard parameters.
2477 Standard_Real a, b, c, r, s, t;
2478};
2479
2480static Standard_Integer OCC25004 (Draw_Interpretor& theDI,
2481 Standard_Integer /*theNArg*/,
2482 const char** /*theArgs*/)
2483{
2484 math_MultipleVarFunction* aFunc = new BraninFunction();
2485
2486 math_Vector aLower(1,2), aUpper(1,2);
2487 aLower(1) = -5;
2488 aLower(2) = 0;
2489 aUpper(1) = 10;
2490 aUpper(2) = 15;
2491
2492 Standard_Integer aGridOrder = 16;
2493 math_Vector aFuncValues(1, aGridOrder * aGridOrder);
2494
2495 Standard_Real aLipConst = 0;
2496 math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2);
2497
2498 // Get Lipshitz constant estimation on regular grid.
2499 Standard_Integer i, j, idx = 1;
2500 for(i = 1; i <= aGridOrder; i++)
2501 {
2502 for(j = 1; j <= aGridOrder; j++)
2503 {
2504 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2505 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2506
2507 aFunc->Value(aCurrPnt1, aFuncValues(idx));
2508 idx++;
2509 }
2510 }
2511
2512 Standard_Integer k, l;
2513 Standard_Integer idx1, idx2;
2514 for(i = 1; i <= aGridOrder; i++)
2515 for(j = 1; j <= aGridOrder; j++)
2516 for(k = 1; k <= aGridOrder; k++)
2517 for(l = 1; l <= aGridOrder; l++)
2518 {
2519 if (i == k && j == l)
2520 continue;
2521
2522 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2523 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2524 idx1 = (i - 1) * aGridOrder + j;
2525
2526 aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0);
2527 aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0);
2528 idx2 = (k - 1) * aGridOrder + l;
2529
2530 aCurrPnt1.Add(-aCurrPnt2);
2531 Standard_Real dist = aCurrPnt1.Norm();
2532
2533 Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist;
2534 if (C > aLipConst)
2535 aLipConst = C;
2536 }
2537
2538 math_GlobOptMin aFinder(aFunc, aLower, aUpper, aLipConst);
2539 aFinder.Perform();
2540 //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475)
2541
2542 Standard_Real anExtValue = aFinder.GetF();
2543 theDI << "F = " << anExtValue << "\n";
2544
2545 Standard_Integer aNbExt = aFinder.NbExtrema();
2546 theDI << "NbExtrema = " << aNbExt << "\n";
2547
2548 return 0;
2549}
2550
2551#include <OSD_Environment.hxx>
2552#include <Plugin.hxx>
2553#include <Plugin_Macro.hxx>
2554#include <Resource_Manager.hxx>
2555
2556#define THE_QATEST_DOC_FORMAT "My Proprietary Format"
2557
2558#define QA_CHECK(theDesc, theExpr, theValue) \
2559{\
2560 const bool isTrue = !!(theExpr); \
2561 std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \
2562}
2563
2564class Test_TDocStd_Application : public TDocStd_Application
2565{
2566public:
2567
2568 static void initGlobalPluginMap (const TCollection_AsciiString& thePlugin,
2569 const TCollection_AsciiString& theSaver,
2570 const TCollection_AsciiString& theLoader)
2571 {
2572 const Handle(Resource_Manager)& aManager = Plugin::AdditionalPluginMap();
2573 aManager->SetResource ((theSaver + ".Location").ToCString(), thePlugin.ToCString());
2574 aManager->SetResource ((theLoader + ".Location").ToCString(), thePlugin.ToCString());
2575 }
2576
2577 Test_TDocStd_Application (const TCollection_AsciiString& thePlugin,
2578 const TCollection_AsciiString& theSaver,
2579 const TCollection_AsciiString& theLoader)
2580 {
2581 initGlobalPluginMap (thePlugin, theSaver, theLoader);
2582
2583 // explicitly initialize resource manager
2584 myResources = new Resource_Manager ("");
2585 myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT);
2586 myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document");
2587 myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml");
2588 myResources->SetResource (THE_QATEST_DOC_FORMAT ".StoragePlugin", theSaver.ToCString());
2589 myResources->SetResource (THE_QATEST_DOC_FORMAT ".RetrievalPlugin", theLoader.ToCString());
2590 }
2591
2592 virtual Standard_CString ResourcesName() { return ""; }
2593 virtual void Formats (TColStd_SequenceOfExtendedString& theFormats) { theFormats.Clear(); }
2594};
2595
2596//=======================================================================
2597//function : OCC24925
2598//purpose :
2599//=======================================================================
2600static Standard_Integer OCC24925 (Draw_Interpretor& theDI,
2601 Standard_Integer theArgNb,
2602 const char** theArgVec)
2603{
2604 if (theArgNb != 2
2605 && theArgNb != 5)
2606 {
2607 std::cout << "Error: wrong syntax! See usage:\n";
2608 theDI.PrintHelp (theArgVec[0]);
2609 return 1;
2610 }
2611
2612 Standard_Integer anArgIter = 1;
2613 TCollection_ExtendedString aFileName = theArgVec[anArgIter++];
2614 TCollection_AsciiString aPlugin = "TKXml";
2615 TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx
2616 TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx
2617 if (anArgIter < theArgNb)
2618 {
2619 aPlugin = theArgVec[anArgIter++];
2620 aSaver = theArgVec[anArgIter++];
2621 aLoader = theArgVec[anArgIter++];
2622 }
2623
2624 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2625 PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError;
2626
2627 Handle(TDocStd_Application) anApp = new Test_TDocStd_Application (aPlugin, aSaver, aLoader);
2628 {
2629 Handle(TDocStd_Document) aDoc;
2630 anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc);
2631 TDF_Label aLab = aDoc->Main();
2632 TDataStd_Integer::Set (aLab, 0);
2633 TDataStd_Name::Set (aLab, "QABugs_19.cxx");
2634
2635 aSStatus = anApp->SaveAs (aDoc, aFileName);
2636 anApp->Close (aDoc);
2637 }
2638 QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true);
2639
2640 {
2641 Handle(TDocStd_Document) aDoc;
2642 aRStatus = anApp->Open (aFileName, aDoc);
2643 anApp->Close (aDoc);
2644 }
2645 QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true);
2646 return 0;
2647}
2648
2649//=======================================================================
2650//function : OCC23010
2651//purpose :
2652//=======================================================================
2653#include <STEPCAFControl_Reader.hxx>
2654
2655class mOcafApplication : public TDocStd_Application
2656{
2657 void Formats(TColStd_SequenceOfExtendedString& Formats)
2658 {
2659 Formats.Append(TCollection_ExtendedString("mOcafApplication"));
2660 }
2661 Standard_CString ResourcesName()
2662 {
2663 return Standard_CString("Resources");
2664 }
2665};
2666
2667static Standard_Integer OCC23010 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2668{
2669 if (argc != 2) {
2670 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
2671 return 1;
2672 }
2673 std::string fileName=argv[1];
2674 mOcafApplication *mCasApp = new mOcafApplication();
2675 Handle(TDocStd_Document) doc;
2676 mCasApp->NewDocument("MDTV-XCAF", doc);
2677 STEPCAFControl_Reader stepReader;
2678 IFSelect_ReturnStatus status = stepReader.ReadFile (fileName.c_str());
2679 if (status != IFSelect_RetDone)
2680 return false;
2681 stepReader.SetColorMode(Standard_True);
2682 stepReader.SetLayerMode(Standard_True);
2683 stepReader.SetNameMode(Standard_True);
2684 stepReader.Transfer(doc); // ERROR HERE!!!
2685 delete mCasApp;
2686 return 0;
2687}
2688
2689/*****************************************************************************/
2690
2691void QABugs::Commands_19(Draw_Interpretor& theCommands) {
2692 const char *group = "QABugs";
2693
2694 Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass();
2695 theCommands.Add ("OCC24202_1", "Test Handle-based procedure",
2696 __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group);
2697 NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass();
2698 theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure",
2699 __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group);
2700
2701 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
2702 theCommands.Add ("OCC142", "OCC142", __FILE__, OCC142, group);
2703 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
2704 theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
2705 theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
2706 theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
2707 theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
2708 theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
2709 theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
2710 theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
2711 theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
2712 theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
2713 theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
2714 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);
2715 theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
2716 theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group);
2717 theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
2718 theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
2719 theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
2720 theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
2721 theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group);
2722 theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group);
2723 theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group);
2724 theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group);
2725 theCommands.Add ("OCC24051", "OCC24051", __FILE__, OCC24051, group);
2726 theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group);
2727 theCommands.Add ("OCC24622", "OCC24622 texture={1D|2D}\n Tests sourcing of 1D/2D pixmaps for AIS_TexturedShape", __FILE__, OCC24622, group);
2728 theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group);
2729 theCommands.Add ("OCC24565", "OCC24565 FileNameIGS FileNameSTOR", __FILE__, OCC24565, group);
2730 theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group);
2731 theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group);
2732 theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group);
2733 theCommands.Add ("OCC23951", "OCC23951", __FILE__, OCC23951, group);
2734 theCommands.Add ("OCC24931", "OCC24931", __FILE__, OCC24931, group);
2735 theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group);
2736 theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
2737 theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group);
2738 theCommands.Add ("OCC24925",
2739 "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]"
2740 "\nOCAF persistence without setting environment variables",
2741 __FILE__, OCC24925, group);
2742 theCommands.Add ("OCC23010", "OCC23010 STEP_file", __FILE__, OCC23010, group);
2743 return;
2744}