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