0027065: BRepOffsetAPI_MakePipe misses definition of virtual method Generated()
[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//
d5f74e42 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
973c2be1 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>
7fd59977 21#include <ViewerTest.hxx>
4a350f94 22#include <V3d_View.hxx>
7fd59977 23#include <TopoDS_Shape.hxx>
f376ac72 24#include <AIS_InteractiveContext.hxx>
c070aa39 25#include <AIS_LocalContext.hxx>
f376ac72 26#include <AIS_TexturedShape.hxx>
27#include <Image_PixMap.hxx>
28#include <Image_Color.hxx>
7fd59977 29
30#include <gp_Pnt2d.hxx>
f6f03db9 31#include <gp_Ax1.hxx>
4f5ad416 32#include <gp_Quaternion.hxx>
7fd59977 33#include <GCE2d_MakeSegment.hxx>
34#include <Geom2d_TrimmedCurve.hxx>
35#include <DrawTrSurf.hxx>
36
f6f03db9 37#include <Precision.hxx>
38
c2ae831c 39#include <cstdio>
40#include <cmath>
41#include <iostream>
c2ae831c 42#include <OSD_Timer.hxx>
c7b59798 43#include <OSD_Parallel.hxx>
44#include <OSD_PerfMeter.hxx>
c2ae831c 45#include <BRepPrimAPI_MakeBox.hxx>
46#include <BRepPrimAPI_MakeSphere.hxx>
47#include <BRepAlgo_Cut.hxx>
ab2db9a5 48#include <NCollection_Map.hxx>
dda67c1c 49#include <NCollection_Handle.hxx>
d09dda09 50#include <NCollection_IncAllocator.hxx>
29cb310a 51#include <TCollection_HAsciiString.hxx>
2cd138b8 52#include <GeomFill_Trihedron.hxx>
53#include <BRepOffsetAPI_MakePipe.hxx>
fff263bd 54#include <TopExp_Explorer.hxx>
29cb310a 55
badc9305 56#include <SelectMgr_Filter.hxx>
57
05d7de53 58#include <Standard_Version.hxx>
59
29cb310a 60#define QCOMPARE(val1, val2) \
61 di << "Checking " #val1 " == " #val2 << \
62 ((val1) == (val2) ? ": OK\n" : ": Error\n")
d2786814 63
7fd59977 64static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
65{
66 if ( argc != 4) {
586db386 67 di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d\n";
7fd59977 68 return 1;
69 }
70
71 gp_Pnt2d P1, P2;
72 if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
586db386 73 di << "ERROR OCC230: " << argv[2] << " is not Pnt2d\n";
7fd59977 74 return 1;
75 }
76 if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
586db386 77 di << "ERROR OCC230: " << argv[3] << " is not Pnt2d\n";
7fd59977 78 return 1;
79 }
80
81 GCE2d_MakeSegment MakeSegment(P1,P2);
82 Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
83 DrawTrSurf::Set(argv[1], TrimmedCurve);
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()) )
586db386 104 di << "ERROR OCC23361: equivalent transformations does not produce equal points\n";
f6f03db9 105 else
586db386 106 di << "OCC23361: OK\n";
f6f03db9 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;
3510db62 134 Standard_Real aPerfMeter_CPUtime = 0., aTimer_CPUTime = 0., aS;
135 Standard_Integer aM, aH;
136 aTM.Show(aS, aM, aH, aTimer_CPUTime);
c2ae831c 137
138 perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
3510db62 139 perf_init_meter("TestMeter");
c2ae831c 140
3510db62 141 Standard_Real aTimeDiff = (fabs(aTimer_CPUTime - aPerfMeter_CPUtime) / aTimer_CPUTime);
c2ae831c 142
143 printf("\nMeasurement results (%d cycles):\n", count);
3510db62 144 printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer CPU time: %lf\n",
145 aPerfMeter_CPUtime, aTimer_CPUTime);
c2ae831c 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
1365140b
RL
158class IncrementerDecrementer
159{
160public:
161 IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
162 {}
c7b59798 163 void operator() (const size_t) const
1365140b 164 {
c7b59798 165 if ( myPositive )
166 Standard_Atomic_Increment(myVal);
167 else
168 Standard_Atomic_Decrement(myVal);
1365140b
RL
169 }
170private:
171 Standard_Integer* myVal;
c7b59798 172 Standard_Boolean myPositive;
1365140b 173};
1365140b 174
1365140b
RL
175static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
176{
177 int aSum = 0;
178
179 //check returned value
180 QCOMPARE (Standard_Atomic_Decrement (&aSum), -1);
181 QCOMPARE (Standard_Atomic_Increment (&aSum), 0);
182 QCOMPARE (Standard_Atomic_Increment (&aSum), 1);
183 QCOMPARE (Standard_Atomic_Increment (&aSum), 2);
184// QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0);
185// QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1);
186
187 //check atomicity
188 aSum = 0;
189 const int N = 1 << 24; //big enough to ensure concurrency
190
191 //increment
c7b59798 192 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, true));
1365140b
RL
193 QCOMPARE (aSum, N);
194
195 //decrement
c7b59798 196 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, false));
1365140b
RL
197 QCOMPARE (aSum, 0);
198
199 return 0;
200}
201
e6aad0ee
RL
202#include <TDocStd_Application.hxx>
203#include <XCAFApp_Application.hxx>
204#include <TDocStd_Document.hxx>
205#include <XCAFDoc_ShapeTool.hxx>
206#include <XCAFDoc_DocumentTool.hxx>
207#include <TDF_Label.hxx>
208#include <TDataStd_Name.hxx>
209
773f53f1 210static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
e6aad0ee 211{
5b111128 212 Handle(TDocStd_Application) anApp = XCAFApp_Application::GetApplication();
e6aad0ee
RL
213 Handle(TDocStd_Document) aDoc;
214 anApp->NewDocument ("XmlXCAF", aDoc);
215 QCOMPARE (!aDoc.IsNull(), Standard_True);
216
217 Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
218
219 //check default value
220 Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
221 QCOMPARE (aValue, Standard_True);
222
223 //true
224 XCAFDoc_ShapeTool::SetAutoNaming (Standard_True);
225 TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape();
226 TDF_Label aLabel = aShTool->AddShape (aShape);
227 Handle(TDataStd_Name) anAttr;
228 QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
229
230 //false
231 XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
232 aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape();
233 aLabel = aShTool->AddShape (aShape);
234 QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
235
236 //restore
237 XCAFDoc_ShapeTool::SetAutoNaming (aValue);
238
239 return 0;
240}
241
5d1833ef 242#include <ExprIntrp_GenExp.hxx>
243Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
244{
245
246 if (argc != 3) {
247 di << "Usage : " << argv[0] << " string nb\n";
248 return 1;
249 }
250
251 TCollection_AsciiString aToken = argv[1];
252 Standard_Integer aNb = atoi(argv[2]);
253
254 Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create();
255 for (Standard_Integer i=0; i < aNb; i++)
256 {
257 aGen->Process(aToken);
258 Handle(Expr_GeneralExpression) aExpr = aGen->Expression();
259 }
260
261 return 0;
262}
263
35e08fe8 264Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
e187cc0a 265{
266 gp_Mat M0;
267 di << "M0 = "
268 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"
269 << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}"
270 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}";
271 return 0;
272}
273
bead40f2 274#include <TopoDS_Face.hxx>
275#include <TopoDS_Face.hxx>
276#include <TopoDS.hxx>
277#include <BRepBuilderAPI_Transform.hxx>
278#include <BRepExtrema_DistShapeShape.hxx>
279#include <BRepTools.hxx>
280
f24125b9 281static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di)
bead40f2 282{
283 BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN);
284 if(!distShapeShape.IsDone()) {
285 di <<"Distance ShapeShape is Not Done\n";
286 return Standard_False;
287 }
288
289 if(distShapeShape.Value() > 0.01) {
290 di << "Wrong Dist = " <<distShapeShape.Value() << "\n";
291 return Standard_False;
292 } else
293 di << "Dist0 = " <<distShapeShape.Value() <<"\n";
294
295 //////////////////////////////////////////////////////////////////////////
296 /// First Flip Y
297 const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970);
298 const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970);
299
300 gp_Vec2d mirrorVector1(axis1P1,axis1P2);
301
302 gp_Trsf2d mirror1;
303 mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1));
304
305 BRepBuilderAPI_Transform transformer1(mirror1);
306 transformer1.Perform(originalWire);
307 if(!transformer1.IsDone()) {
586db386 308 di << "Not Done1 \n";
bead40f2 309 return Standard_False;
310 }
346cf025 311 TopoDS_Shape step1ModifiedShape = transformer1.ModifiedShape(originalWire);
bead40f2 312
313 BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN);
314 if(!distShapeShape1.IsDone())
315 return Standard_False;
316 if(distShapeShape1.Value() > 0.01) {
317 di << "Dist = " <<distShapeShape1.Value() <<"\n";
318 return Standard_False;
319 } else
320 di << "Dist1 = " <<distShapeShape1.Value() <<"\n";
321
322 //////////////////////////////////////////////////////////////////////////
323 /// Second flip Y
324 transformer1.Perform(step1ModifiedShape);
325 if(!transformer1.IsDone()) {
326 di << "Not Done1 \n";
327 return Standard_False;
328 }
346cf025 329 TopoDS_Shape step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
bead40f2 330
331 //This is identity matrix for values but for type is gp_Rotation ?!
332 gp_Trsf2d mirror11 = mirror1;
333 mirror11.PreMultiply(mirror1);
334
335 BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN);
336 if(!distShapeShape2.IsDone())
337 return Standard_False;
338
339 //This last test case give error (the value is 1008.8822038689706)
340 if(distShapeShape2.Value() > 0.01) {
341 di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n";
342 Standard_Integer N = distShapeShape2.NbSolution();
343 di << "Nb = " <<N <<"\n";
344 for (Standard_Integer i=1;i <= N;i++)
345 di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n";
346 return Standard_False;
347 }
348 di << "Distance2 = " <<distShapeShape2.Value() <<"\n";
349
350 return Standard_True;
351}
352static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a)
353{
354
355 if (n != 3) {
356 di <<"OCC23774: invalid number of input parameters\n";
357 return 1;
358 }
359
360 const char *ns1 = (a[1]), *ns2 = (a[2]);
361 TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2));
362 if (S1.IsNull() || S2.IsNull()) {
363 di <<"OCC23774: Null input shapes\n";
364 return 1;
365 }
366 const TopoDS_Face& aFace = TopoDS::Face(S1);
367 if(!OCC23774Test(aFace, S2, di))
368 di << "Something is wrong\n";
369
370 return 0;
371}
372
1ef32e96
RL
373#include <GeomConvert_ApproxSurface.hxx>
374#include <Geom_BSplineSurface.hxx>
375#include <Draw.hxx>
376#include <OSD_Thread.hxx>
1ef32e96 377
7a5f1202 378struct GeomConvertTest_Data
379{
380 Standard_Integer nbupoles;
381 Handle(Geom_Surface) surf;
1ef32e96
RL
382};
383
7a5f1202 384static Standard_Address GeomConvertTest (Standard_Address data)
1ef32e96 385{
7a5f1202 386 GeomConvertTest_Data* info = (GeomConvertTest_Data*)data;
387
388 GeomConvert_ApproxSurface aGAS (info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
389 if (!aGAS.IsDone()) {
390 cout << "Error: ApproxSurface is not done!" << endl;
caaeed1b 391 return 0;
7a5f1202 392 }
393 const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
394 if (aBSurf.IsNull()) {
395 cout << "Error: BSplineSurface is not created!" << endl;
caaeed1b 396 return 0;
7a5f1202 397 }
398 cout << "Number of UPoles:" << aBSurf->NbUPoles();
399 if (aBSurf->NbUPoles() == info->nbupoles)
400 {
401 cout << ": OK" << endl;
402 return data; // any non-null pointer
403 }
404 else
405 {
406 cout << ": Error, must be " << info->nbupoles << endl;
407 return 0;
408 }
1ef32e96
RL
409}
410
411static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
412{
7a5f1202 413 if (argc != 3) {
414 cout << "Error: invalid number of arguments" << endl;
415 return 1;
416 }
417
418 struct GeomConvertTest_Data aStorage;
419 aStorage.nbupoles = Draw::Atoi(argv[1]);
420 aStorage.surf = DrawTrSurf::GetSurface(argv[2]);
421 if (aStorage.surf.IsNull())
422 {
423 cout << "Error: " << argv[2] << " is not a DRAW surface!" << endl;
424 return 0;
425 }
426
427 // start conversion in several threads
428 const int NBTHREADS = 100;
429 OSD_Thread aThread[NBTHREADS];
430 for (int i=0; i < NBTHREADS; i++)
431 {
432 aThread[i].SetFunction (GeomConvertTest);
433 if (!aThread[i].Run(&aStorage))
434 di << "Error: Cannot start thread << " << i << "\n";
435 }
436
437 // check results
438 for (int i=0; i < NBTHREADS; i++)
439 {
440 Standard_Address aResult = 0;
441 if (!aThread[i].Wait(aResult))
442 di << "Error: Failed waiting for thread << " << i << "\n";
443 if (!aResult)
444 di << "Error: wrong number of poles in thread " << i << "!\n";
445 }
446
447 return 0;
1ef32e96 448}
d2786814 449
1ef32e96 450#include <GeomInt_IntSS.hxx>
1ef32e96 451
7a5f1202 452struct GeomIntSSTest_Data
453{
454 Standard_Integer nbsol;
455 Handle(Geom_Surface) surf1, surf2;
1ef32e96 456};
7a5f1202 457
458static Standard_Address GeomIntSSTest (Standard_Address data)
1ef32e96 459{
7a5f1202 460 GeomIntSSTest_Data* info = (GeomIntSSTest_Data*)data;
461 GeomInt_IntSS anInter;
462 anInter.Perform (info->surf1, info->surf2, Precision::Confusion(), Standard_True);
463 if (!anInter.IsDone()) {
464 cout << "An intersection is not done!" << endl;
465 return 0;
466 }
467
468 cout << "Number of Lines:" << anInter.NbLines();
469 if (anInter.NbLines() == info->nbsol)
470 {
471 cout << ": OK" << endl;
472 return data; // any non-null pointer
473 }
474 else
475 {
476 cout << ": Error, must be " << info->nbsol << endl;
477 return 0;
478 }
1ef32e96
RL
479}
480
481static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
482{
7a5f1202 483 if (argc != 4) {
484 cout << "Error: invalid number of arguments" << endl;
485 return 1;
486 }
487
488 struct GeomIntSSTest_Data aStorage;
489 aStorage.nbsol = Draw::Atoi(argv[1]);
490 aStorage.surf1 = DrawTrSurf::GetSurface(argv[2]);
491 aStorage.surf2 = DrawTrSurf::GetSurface(argv[3]);
492 if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull())
493 {
494 cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" << endl;
495 return 0;
496 }
497
498 // start conversion in several threads
499 const int NBTHREADS = 100;
500 OSD_Thread aThread[NBTHREADS];
501 for (int i=0; i < NBTHREADS; i++)
502 {
503 aThread[i].SetFunction (GeomIntSSTest);
504 if (!aThread[i].Run(&aStorage))
505 di << "Error: Cannot start thread << " << i << "\n";
506 }
507
508 // check results
509 for (int i=0; i < NBTHREADS; i++)
510 {
511 Standard_Address aResult = 0;
512 if (!aThread[i].Wait(aResult))
513 di << "Error: Failed waiting for thread << " << i << "\n";
514 if (!aResult)
515 di << "Error: wrong number of intersections in thread " << i << "!\n";
516 }
517
518 return 0;
1ef32e96
RL
519}
520
521#include <Geom_SurfaceOfRevolution.hxx>
06be28a4
RL
522static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
523{
524 if (argc < 2) {
586db386 525 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
06be28a4
RL
526 return 1;
527 }
528
529 Standard_Integer ucontinuity = 1;
530 Standard_Integer vcontinuity = 1;
531 Standard_Boolean iscnu = false;
532 Standard_Boolean iscnv = false;
533
534 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
535
536 QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
537 QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
538
539 return 0;
540}
541
1939140c 542#include <gp_Ax1.hxx>
543#include <gp_Ax22d.hxx>
544#include <Geom_Plane.hxx>
545#include <Geom2d_Circle.hxx>
546#include <Geom2d_TrimmedCurve.hxx>
547#include <BRepBuilderAPI_MakeEdge.hxx>
548#include <BRepPrimAPI_MakeRevol.hxx>
549#include <Geom2d_OffsetCurve.hxx>
550
551static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
552{
553 // Check the command arguments
554 if ( argc != 1 )
555 {
586db386 556 di << "Error: " << argv[0] << " - invalid number of arguments\n";
1939140c 557 di << "Usage: type help " << argv[0] << "\n";
558 return 1; // TCL_ERROR
559 }
560
561 gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
562 gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
563 Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
564
586db386 565 di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>\n";
566 di << "-----------------------------------------------------------------------\n";
1939140c 567
568 Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
569 Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
570 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
571
572 DBRep::Set("e1", E1);
573
574 BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
575 TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
576
577 DBRep::Set("f1", F1);
578
586db386 579 di << "Result: f1\n";
1939140c 580
586db386 581 di << "<<<< Preparing sample surface of revolution based on offset curve >>>>\n";
582 di << "-----------------------------------------------------------------------\n";
1939140c 583
584 Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
585 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
586
587 DBRep::Set("e2", E2);
588
589 BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
590 TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
591
592 DBRep::Set("f2", F2);
593
586db386 594 di << "Result: f2\n";
1939140c 595
596 return 0;
597}
598
2e9fd4bc 599#include <Geom_Curve.hxx>
600#include <Geom_Surface.hxx>
601#include <Precision.hxx>
602#include <ShapeConstruct_ProjectCurveOnSurface.hxx>
603//=======================================================================
604//function : OCC24008
605//purpose :
606//=======================================================================
607static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
608{
609 if (argc != 3) {
586db386 610 di << "Usage: " << argv[0] << " invalid number of arguments\n";
2e9fd4bc 611 return 1;
612 }
613 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]);
614 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]);
615 if (aCurve.IsNull()) {
586db386 616 di << "Curve was not read\n";
2e9fd4bc 617 return 1;
618 }
619 if (aSurf.IsNull()) {
586db386 620 di << "Surface was not read\n";
2e9fd4bc 621 return 1;
622 }
623 ShapeConstruct_ProjectCurveOnSurface aProj;
624 aProj.Init (aSurf, Precision::Confusion());
625 try {
626 Handle(Geom2d_Curve) aPCurve;
627 aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve);
628 if (aPCurve.IsNull()) {
586db386 629 di << "PCurve was not created\n";
2e9fd4bc 630 return 1;
631 }
632 } catch (...) {
586db386 633 di << "Exception was caught\n";
2e9fd4bc 634 }
635 return 0;
636}
637
470ebb43 638#include <GeomAdaptor_Surface.hxx>
639#include <Draw.hxx>
640//=======================================================================
641//function : OCC23945
642//purpose :
643//=======================================================================
644
35e08fe8 645static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
470ebb43 646{
647 if (n < 5) return 1;
648
649 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
650 if (aS.IsNull()) return 1;
651
652 GeomAdaptor_Surface GS(aS);
653
654 Standard_Real U = Draw::Atof(a[2]);
655 Standard_Real V = Draw::Atof(a[3]);
656
657 Standard_Boolean DrawPoint = ( n%3 == 2);
658 if ( DrawPoint) n--;
659
660 gp_Pnt P;
661 if (n >= 13) {
662 gp_Vec DU,DV;
663 if (n >= 22) {
664 gp_Vec D2U,D2V,D2UV;
665 GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
666 Draw::Set(a[13],D2U.X());
667 Draw::Set(a[14],D2U.Y());
668 Draw::Set(a[15],D2U.Z());
669 Draw::Set(a[16],D2V.X());
670 Draw::Set(a[17],D2V.Y());
671 Draw::Set(a[18],D2V.Z());
672 Draw::Set(a[19],D2UV.X());
673 Draw::Set(a[20],D2UV.Y());
674 Draw::Set(a[21],D2UV.Z());
675 }
676 else
677 GS.D1(U,V,P,DU,DV);
678
679 Draw::Set(a[7],DU.X());
680 Draw::Set(a[8],DU.Y());
681 Draw::Set(a[9],DU.Z());
682 Draw::Set(a[10],DV.X());
683 Draw::Set(a[11],DV.Y());
684 Draw::Set(a[12],DV.Z());
685 }
686 else
687 GS.D0(U,V,P);
688
689 if ( n > 6) {
690 Draw::Set(a[4],P.X());
691 Draw::Set(a[5],P.Y());
692 Draw::Set(a[6],P.Z());
693 }
694 if ( DrawPoint) {
695 DrawTrSurf::Set(a[n],P);
696 }
697
698 return 0;
699}
700
29cb310a 701//=======================================================================
702//function : OCC11758
703//purpose :
704//=======================================================================
498ce76b 705static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
29cb310a 706{
707 if (n != 1) return 1;
708
709 const char* theStr = "0123456789";
710 Standard_Integer i, j;
711 for ( i = 0; i < 5; ++i ) {
712 // TCollection_AsciiString(const Standard_CString astring)
713 TCollection_AsciiString a(theStr+i);
714 // IsEqual (const Standard_CString other)const
715 //assert( a == theStr+i );
716 QCOMPARE ( a , theStr+i );
717
718 //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen )
719 TCollection_AsciiString b(theStr+i, 3);
720 //assert( b.Length() == 3 );
721 //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 );
722 //assert( strlen( b.ToCString() ) == 3 );
723 QCOMPARE ( b.Length() , 3 );
724 QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 );
725 QCOMPARE ( b.Length() , 3 );
726
727 //TCollection_AsciiString(const Standard_Integer aValue)
728 TCollection_AsciiString c(i);
729 //assert( c.IsIntegerValue() );
730 //assert( c.IntegerValue() == i );
731 QCOMPARE ( c.IsIntegerValue() , Standard_True );
732 QCOMPARE ( c.IntegerValue() , i );
733
734 //TCollection_AsciiString(const Standard_Real aValue)
735 TCollection_AsciiString d( 0.1*i );
736 //assert( d.IsRealValue() );
737 //assert( TCollection_AsciiString(3.3) == "3.3");
738 QCOMPARE ( d.IsRealValue() , Standard_True );
739 QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" );
740
741 //TCollection_AsciiString(const TCollection_AsciiString& astring)
742 TCollection_AsciiString e(d);
743 //assert( e == d );
744 //assert( e.Length() == d.Length() );
745 //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
746 QCOMPARE ( e ,d );
747 QCOMPARE ( e.Length() , d.Length() );
748 QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
749
750 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
751 // const Standard_Character other )
752 TCollection_AsciiString f(e,'\a');
753 //assert( f.Length() == e.Length() + 1 );
754 //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 );
755 //assert( f.Value( f.Length() ) == '\a');
756 QCOMPARE ( f.Length() , e.Length() + 1 );
757 QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 );
758 QCOMPARE ( f.Value( f.Length() ) , '\a' );
759
760 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
761 // const Standard_CString other )
762 TCollection_AsciiString g(f, theStr);
763 //assert( g.Length() == f.Length() + strlen( theStr ));
764 //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 );
765 //assert( g.Search( theStr ) == f.Length() + 1 );
766 QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) );
767 QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 );
768 QCOMPARE ( g.Search( theStr ) , f.Length() + 1 );
769
770 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
771 // const TCollection_AsciiString& other )
772 TCollection_AsciiString h(d,a);
773 //assert( h.Length() == d.Length() + a.Length() );
774 //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 );
775 //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 );
776 QCOMPARE ( h.Length() , d.Length() + a.Length() );
777 QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 );
778 QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 );
779
780 // AssignCat(const Standard_CString other)
781 c.AssignCat( a.ToCString() );
782 //assert( c.Length() == 1 + a.Length() );
783 //assert( c.Search( a ) == 2 );
784 QCOMPARE ( c.Length() , 1 + a.Length() );
785 QCOMPARE ( c.Search( a ) , 2 );
786
787 // AssignCat(const TCollection_AsciiString& other)
788 Standard_Integer dl = d.Length();
789 d.AssignCat( a );
790 //assert( d.Length() == dl + a.Length() );
791 //assert( d.Search( a ) == dl + 1 );
792 QCOMPARE ( d.Length() , dl + a.Length() );
793 QCOMPARE ( d.Search( a ) , dl + 1 );
794
795 // Capitalize()
796 TCollection_AsciiString capitalize("aBC");
797 capitalize.Capitalize();
798 //assert( capitalize == "Abc" );
799 QCOMPARE ( capitalize , "Abc" );
800
801 // Copy(const Standard_CString fromwhere)
802 d = theStr+i;
803 //assert( d == theStr+i );
804 QCOMPARE ( d , theStr+i );
805
806 // Copy(const TCollection_AsciiString& fromwhere)
807 d = h;
808 // IsEqual (const TCollection_AsciiString& other)const
809 //assert( d == h );
810 QCOMPARE ( d , h );
811
812 // Insert(const Standard_Integer where, const Standard_CString what)
813 dl = d.Length();
814 d.Insert( 2, theStr );
815 //assert( d.Length() == dl + strlen( theStr ));
816 //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 );
817 QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) );
818 QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 );
819
820 //Insert(const Standard_Integer where,const Standard_Character what)
821 d = theStr;
822 d.Insert( i+1, 'i' );
823 //assert( d.Length() == strlen( theStr ) + 1 );
824 //assert( d.Value( i+1 ) == 'i');
825 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
826 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
827 QCOMPARE ( d.Value( i+1 ) , 'i' );
828 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
829
830 //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
831 d = theStr;
832 d.Insert( i+1, TCollection_AsciiString( "i" ));
833 //assert( d.Length() == strlen( theStr ) + 1 );
834 //assert( d.Value( i+1 ) == 'i');
835 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
836 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
837 QCOMPARE ( d.Value( i+1 ) , 'i' );
838 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
839
840 // IsDifferent (const Standard_CString other)const
841 //assert( d.IsDifferent( theStr ));
842 //assert( d.IsDifferent( "theStr" ));
843 //assert( d.IsDifferent( "" ));
844 //assert( !d.IsDifferent( d.ToCString() ));
845 QCOMPARE ( d.IsDifferent( theStr ) , Standard_True );
846 QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True );
847 QCOMPARE ( d.IsDifferent( "" ) , Standard_True );
848 QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True );
849
850 // IsDifferent (const TCollection_AsciiString& other)const
851 //assert( d.IsDifferent( TCollection_AsciiString() ));
852 //assert( d.IsDifferent( a ));
853 //assert( d.IsDifferent( h ));
854 //assert( !d.IsDifferent( d ));
855 QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True );
856 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
857 QCOMPARE ( d.IsDifferent( h ) , Standard_True );
858 QCOMPARE ( !d.IsDifferent( d ) , Standard_True );
859
860 // IsLess (const Standard_CString other)const
861 //assert( TCollection_AsciiString ("0"). IsLess("1"));
862 //assert( TCollection_AsciiString ("0"). IsLess("00"));
863 //assert( TCollection_AsciiString (""). IsLess("0"));
864 //assert( !TCollection_AsciiString("1"). IsLess("0"));
865 //assert( !TCollection_AsciiString("00").IsLess("0"));
866 //assert( !TCollection_AsciiString("0"). IsLess(""));
867 //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1));
868 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True );
869 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True );
870 QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True );
871 QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True );
872 QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True );
873 QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True );
874 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True );
875
876 // IsLess (const TCollection_AsciiString& other)const
877 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )));
878 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")));
879 //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )));
880 //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )));
881 //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )));
882 //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )));
883 //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)));
884 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True );
885 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True );
886 QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True );
887 QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True );
888 QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True );
889 QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True );
890 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True );
891
892 // IsGreater (const Standard_CString other)const
893 //assert( !TCollection_AsciiString("0"). IsGreater("1"));
894 //assert( !TCollection_AsciiString("0"). IsGreater("00"));
895 //assert( !TCollection_AsciiString(""). IsGreater("0"));
896 //assert( TCollection_AsciiString ("1"). IsGreater("0"));
897 //assert( TCollection_AsciiString ("00").IsGreater("0"));
898 //assert( TCollection_AsciiString ("0"). IsGreater(""));
899 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i));
900 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True );
901 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True );
902 QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True );
903 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True );
904 QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True );
905 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True );
906 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True );
907
908 // IsGreater (const TCollection_AsciiString& other)const
909 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )));
910 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")));
911 //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )));
912 //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )));
913 //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )));
914 //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )));
915 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)));
916 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True );
917 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True );
918 QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
919 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
920 QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True );
921 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True );
922 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True );
923
924 // void Read(Standard_IStream& astream)
925 std::istringstream is( theStr );
926 e.Read( is );
927 //assert( e == theStr );
928 QCOMPARE ( e , theStr );
929
930 // Standard_Integer SearchFromEnd (const Standard_CString what)const
931 //assert( e.SearchFromEnd( theStr + i ) == i + 1 );
932 QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 );
933
934 // SetValue(const Standard_Integer where, const Standard_CString what)
935 e.SetValue( i+1, "what");
936 //assert( e.Search( "what" ) == i+1 );
937 //assert( e.Length() == strlen( theStr ));
938 QCOMPARE ( e.Search( "what" ) , i+1 );
939 QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) );
940
941 // TCollection_AsciiString Split (const Standard_Integer where)
942 e = theStr;
943 d = e.Split( i+1 );
944 //assert( d.Length() + e.Length() == strlen( theStr ));
945 QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
946
947 // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
948 // const Standard_Integer ToIndex) const
949 e = theStr;
950 d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 );
951 //assert( d.Length() == 3 );
952 //assert( d.Value(1) == theStr[ i ]);
953 QCOMPARE ( d.Length() , 3 );
954 QCOMPARE ( d.Value(1) , theStr[ i ] );
955
956 // TCollection_AsciiString Token (const Standard_CString separators,
957 // const Standard_Integer whichone) const
958 e = " ";
959 for ( j = 0; j < i; ++j ) {
960 e += TCollection_AsciiString( theStr[j] ) + " ";
961 //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 ));
962 QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) );
963 }
964 }
965 for ( i = 0; i < 5; ++i )
966 {
967 // TCollection_ExtendedString (const Standard_CString astring,
968 // const Standard_Boolean isMultiByte)
969 const TCollection_ExtendedString a( theStr+i );
970 //assert( TCollection_AsciiString( a ) == theStr+i );
971 QCOMPARE ( TCollection_AsciiString( a ) , theStr+i );
972
973 //TCollection_ExtendedString (const Standard_ExtString astring)
974 const TCollection_ExtendedString b( a.ToExtString() );
975 //assert( a == b );
976 QCOMPARE ( a , b );
977
978 // TCollection_ExtendedString (const Standard_Integer length,
979 // const Standard_ExtCharacter filler )
980 const TCollection_ExtendedString c( i, 1 );
981 //assert( c.Length() == i );
982 QCOMPARE ( c.Length() , i );
983 if ( c.Length() > 0 ) {
984 //assert( c.Value( i ) == 1 );
985 QCOMPARE ( c.Value( i ) , 1 );
986 }
987
988 // TCollection_ExtendedString (const Standard_Integer aValue)
989 TCollection_ExtendedString d( i );
990 const TCollection_AsciiString da( d );
991 //assert( da.IsIntegerValue() );
992 //assert( da.IntegerValue() == i );
993 QCOMPARE ( da.IsIntegerValue() , Standard_True );
994 QCOMPARE ( da.IntegerValue(), i );
995
996 // TCollection_ExtendedString (const Standard_Real aValue)
997 const TCollection_ExtendedString e( 0.1 * i );
998 const TCollection_AsciiString ea( e );
999 //assert( ea.IsRealValue() );
1000 //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 );
1001 QCOMPARE ( ea.IsRealValue() , Standard_True );
1002 QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True );
1003
1004 // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1005 const TCollection_ExtendedString f(e);
1006 //assert( f.Length() == e.Length());
1007 //assert( f == e );
1008 QCOMPARE ( f.Length() , e.Length() );
1009 QCOMPARE ( f , e );
1010
1011 // TCollection_ExtendedString (const TCollection_AsciiString& astring)
1012 const TCollection_ExtendedString g( ea );
1013 //assert( g.Length() == ea.Length() );
1014 //assert( TCollection_AsciiString( g ) == ea );
1015 QCOMPARE ( g.Length() , ea.Length() );
1016 QCOMPARE ( TCollection_AsciiString( g ) , ea );
1017
1018 // AssignCat (const TCollection_ExtendedString& other)
1019 const TCollection_ExtendedString sep(",");
1020 d.AssignCat( sep );
1021 d.AssignCat( g );
1022 //assert( d.Length() == 2 + g.Length() );
1023 //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i ));
1024 //assert( d.Token( sep.ToExtString(), 2 ) == g );
1025 QCOMPARE ( d.Length() , 2 + g.Length() );
1026 QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) );
1027 QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g );
1028
1029 // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const
1030 const TCollection_ExtendedString cat = a.Cat( sep );
1031 //assert( cat.Length() == a.Length() + sep.Length() );
1032 //assert( cat.Search( a ) == 1 );
1033 //assert( cat.Search( sep ) == a.Length() + 1 );
1034 QCOMPARE ( cat.Length() , a.Length() + sep.Length() );
1035 QCOMPARE ( cat.Search( a ) , 1 );
1036 QCOMPARE ( cat.Search( sep ) , a.Length() + 1 );
1037
1038 // Copy (const TCollection_ExtendedString& fromwhere)
1039 d = cat;
1040 //assert( d.Length() == cat.Length() );
1041 //assert( d == cat );
1042 QCOMPARE ( d.Length() , cat.Length() );
1043 QCOMPARE ( d , cat );
1044
1045 // IsEqual (const Standard_ExtString other) const
1046 //assert( d.IsEqual( d.ToExtString() ));
1047 QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1048
1049 // IsDifferent (const Standard_ExtString other ) const
1050 //assert( d.IsDifferent( a.ToExtString() ));
1051 QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1052
1053 // IsDifferent (const TCollection_ExtendedString& other) const
1054 //assert( d.IsDifferent( a ));
1055 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
1056
1057 // IsLess (const Standard_ExtString other) const
1058 const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1);
1059 //assert( l0. IsLess( l1.ToExtString() ));
1060 //assert( l0. IsLess( l00.ToExtString() ));
1061 //assert( l. IsLess( l0.ToExtString() ));
1062 //assert( ! l1. IsLess( l0.ToExtString() ));
1063 //assert( ! l00.IsLess( l0.ToExtString() ));
1064 //assert( ! l0. IsLess( l.ToExtString() ));
1065 //assert( ls.IsLess( ls1.ToExtString() ));
1066 QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True );
1067 QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True );
1068 QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True );
1069 QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True );
1070 QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True );
1071 QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True );
1072 QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True );
1073
1074 // IsLess (const TCollection_ExtendedString& other) const
1075 //assert( l0. IsLess( l1 ));
1076 //assert( l0. IsLess( l00 ));
1077 //assert( l. IsLess( l0 ));
1078 //assert( ! l1. IsLess( l0 ));
1079 //assert( ! l00.IsLess( l0 ));
1080 //assert( ! l0. IsLess( l ));
1081 //assert( ls.IsLess( ls1 ));
1082 QCOMPARE ( l0. IsLess( l1 ) , Standard_True );
1083 QCOMPARE ( l0. IsLess( l00 ) , Standard_True );
1084 QCOMPARE ( l. IsLess( l0 ) , Standard_True );
1085 QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True );
1086 QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True );
1087 QCOMPARE ( ! l0. IsLess( l ) , Standard_True );
1088 QCOMPARE ( ls.IsLess( ls1 ) , Standard_True );
1089
1090 // IsGreater (const Standard_ExtString other) const
1091 //assert( ! l0.IsGreater( l1.ToExtString() ));
1092 //assert( ! l0.IsGreater( l00.ToExtString() ));
1093 //assert( ! l. IsGreater( l0.ToExtString() ));
1094 //assert( l1. IsGreater( l0.ToExtString() ));
1095 //assert( l00.IsGreater( l0.ToExtString() ));
1096 //assert( l0. IsGreater( l.ToExtString() ));
1097 //assert( ls1.IsGreater( ls.ToExtString() ));
1098 QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True );
1099 QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True );
1100 QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True );
1101 QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True );
1102 QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True );
1103 QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True );
1104 QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True );
1105
1106 // IsGreater (const TCollection_ExtendedString& other) const
1107 //assert( ! l0.IsGreater( l1));
1108 //assert( ! l0.IsGreater( l00));
1109 //assert( ! l. IsGreater( l0));
1110 //assert( l1. IsGreater( l0));
1111 //assert( l00.IsGreater( l0));
1112 //assert( l0. IsGreater( l));
1113 //assert( ls1.IsGreater( ls));
1114 QCOMPARE ( ! l0.IsGreater( l1) , Standard_True );
1115 QCOMPARE ( ! l0.IsGreater( l00) , Standard_True );
1116 QCOMPARE ( ! l. IsGreater( l0) , Standard_True );
1117 QCOMPARE ( l1. IsGreater( l0) , Standard_True );
1118 QCOMPARE ( l00.IsGreater( l0) , Standard_True );
1119 QCOMPARE ( l0. IsGreater( l) , Standard_True );
1120 QCOMPARE ( ls1.IsGreater( ls) , Standard_True );
1121
1122 // ==========================
1123 //TCollection_HAsciiString::
1124 // ==========================
1125
1126 // IsDifferent(const Handle(TCollection_HAsciiString)& S)
1127 Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i );
1128 Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 );
1129 //assert( ha1->IsDifferent( ha2 ));
1130 //assert( !ha1->IsDifferent( ha1 ));
1131 QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True );
1132 QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True );
1133
1134 // IsSameString (const Handle(TCollection_HAsciiString)& S)
1135 //assert( !ha1->IsSameString( ha2 ));
1136 //assert( ha1->IsSameString( ha1 ));
1137 QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True );
1138 QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True );
1139
1140 // IsSameState (const Handle(TCollection_HAsciiString)& other) const
1141 //assert( !ha1->IsSameState( ha2 ));
1142 //assert( ha1->IsSameState( ha1 ));
1143 QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True );
1144 QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True );
1145
1146 // IsSameString (const Handle(TCollection_HAsciiString)& S ,
1147 // const Standard_Boolean CaseSensitive) const
1148 //assert( !ha1->IsSameString( ha2, true ));
1149 //assert( ha1->IsSameString( ha1, true ));
1150 //assert( !ha1->IsSameString( ha2, false ));
1151 //assert( ha1->IsSameString( ha1, false ));
1152 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1153 QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True );
1154 QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True );
1155 QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True );
1156
1157 ha1->SetValue( 1, "AbC0000000");
1158 ha2->SetValue( 1, "aBc0000000");
1159 //assert( !ha1->IsSameString( ha2, true ));
1160 //assert( ha1->IsSameString( ha2, false ));
1161 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1162 QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True );
1163 }
1164 return 0;
1165}
1166
788cbaf4 1167#include <Geom_CylindricalSurface.hxx>
1168#include <IntTools_FaceFace.hxx>
1169#include <IntTools_Curve.hxx>
1170#include <IntTools_PntOn2Faces.hxx>
1171
1172static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1173{
1174 if(theNArg < 2)
1175 {
1176 theDI << "Wrong a number of arguments!\n";
1177 return 1;
1178 }
1179
857ffd5e 1180 Handle(Geom_Plane) plane(new Geom_Plane(
788cbaf4 1181 gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
1182 gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
1183 gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000))));
1184 Handle(Geom_CylindricalSurface) cylinder(
1185 new Geom_CylindricalSurface(
1186 gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
1187 gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
1188 gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
1189 19.712534607908712));
1190
1191 DrawTrSurf::Set("pln", plane);
1192 theDI << "pln\n";
1193 DrawTrSurf::Set("cyl", cylinder);
1194 theDI << "cyl\n";
1195
1196 BRep_Builder builder;
1197 TopoDS_Face face1, face2;
1198 builder.MakeFace(face1, plane, Precision::Confusion());
1199 builder.MakeFace(face2, cylinder, Precision::Confusion());
1200 IntTools_FaceFace anInters;
1201 anInters.SetParameters(false, true, true, Precision::Confusion());
1202 anInters.Perform(face1, face2);
1203
1204 if (!anInters.IsDone())
1205 {
586db386 1206 theDI<<"No intersections found!\n";
788cbaf4 1207
1208 return 1;
1209 }
1210
1211 //Handle(Geom_Curve) aResult;
1212 //gp_Pnt aPoint;
1213
1214 const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1215 const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1216
1217 char buf[1024];
1218 Standard_Integer aNbCurves, aNbPoints;
1219
1220 aNbCurves=aCvsX.Length();
1221 aNbPoints=aPntsX.Length();
1222
1223 if (aNbCurves >= 2)
1224 {
1225 for (Standard_Integer i=1; i<=aNbCurves; ++i)
1226 {
1227 Sprintf(buf, "%s_%d",theArgv[1],i);
1228 theDI << buf << " ";
1229
1230 const IntTools_Curve& aIC = aCvsX(i);
1231 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1232 DrawTrSurf::Set(buf,aC3D);
1233 }
1234 }
1235 else if (aNbCurves == 1)
1236 {
1237 const IntTools_Curve& aIC = aCvsX(1);
1238 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1239 Sprintf(buf, "%s",theArgv[1]);
1240 theDI << buf << " ";
1241 DrawTrSurf::Set(buf,aC3D);
1242 }
1243
1244 for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1245 {
1246 const IntTools_PntOn2Faces& aPi=aPntsX(i);
1247 const gp_Pnt& aP=aPi.P1().Pnt();
1248
1249 Sprintf(buf,"%s_p_%d",theArgv[1],i);
1250 theDI << buf << " ";
1251 DrawTrSurf::Set(buf, aP);
1252 }
1253
1254 return 0;
1255}
1256
1b7602c8 1257#include <BRepAlgo_NormalProjection.hxx>
1258static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1259{
1260 if (argc != 3) {
1261 di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)";
1262 return 1;
1263 }
1264
1265 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1266 if(myAISContext.IsNull()) {
1267 di << "use 'vinit' command before " << argv[0] << "\n";
1268 return 1;
1269 }
1270
1271 TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1]));
1272 TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2]));
1273
1274 BRepAlgo_NormalProjection anormpro(m_Face1);
1275 anormpro.Add(m_Edge);
1276 anormpro.SetDefaultParams();
1277
1278 //anormpro.Compute3d();
1279 //anormpro.SetLimit();
1280
1281 anormpro.Build();
1282
1283 if (anormpro.IsDone())
1284 {
1285 TopoDS_Shape rshape = anormpro.Projection();
1286 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape);
1287 myAISContext->SetColor(myShape, Quantity_Color(Quantity_NOC_YELLOW));
1288 myAISContext->Display(myShape, Standard_True);
1289 }
1290
1291 return 0;
1292}
1293
69fd2d1b 1294#include <BRepFeat_SplitShape.hxx>
1295#include <ShapeAnalysis_ShapeContents.hxx>
1296#include <BRepAlgo.hxx>
1297static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1298{
1299 if (argc != 3) {
1300 di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)";
1301 return 1;
1302 }
1303
1304 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1305 if(myAISContext.IsNull()) {
1306 di << "use 'vinit' command before " << argv[0] << "\n";
1307 return 1;
1308 }
1309
1310 TopoDS_Shape result;
1311 TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1]));
1312 TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2]));
1313
1314 BRepFeat_SplitShape asplit(face);
1315 asplit.Add(wire, face);
1316 asplit.Build();
1317 result = asplit.Shape();
1318 ShapeAnalysis_ShapeContents ana;
1319 ana.Perform(result);
1320 ana.NbFaces();
1321
1322 if (!(BRepAlgo::IsValid(result))) {
586db386 1323 di << "Result was checked and it is INVALID\n";
69fd2d1b 1324 } else {
586db386 1325 di << "Result was checked and it is VALID\n";
69fd2d1b 1326 }
1327
1328 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result);
1329 myAISContext->Display(myShape, Standard_True);
1330
1331 return 0;
1332}
1333
c764e804 1334#include <Geom_Circle.hxx>
1335#include <GeomAdaptor_Curve.hxx>
1336#include <Extrema_ExtPC.hxx>
1337#include <gp_Cylinder.hxx>
1338#include <ElSLib.hxx>
1339static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1340{
1341 if (argc != 1) {
586db386 1342 di << "Usage: " << argv[0] << " invalid number of arguments\n";
c764e804 1343 return 1;
1344 }
1345
1346 gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 );
1347 gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() );
1348 Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 );
1349 GeomAdaptor_Curve aC3D( aCircle );
1350
1351 Extrema_ExtPC aExtPC( aP3D, aC3D );
1352 //Standard_Real aParam = (aExtPC.Point(1)).Parameter();
1353 gp_Pnt aProj = (aExtPC.Point(1)).Value();
1354 di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n";
1355
1356 // Result of deviation
1357 gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() );
1358 gp_Cylinder aCylinder( aCylAxis, 1890. );
1359
1360 Standard_Real aU = 0., aV = 0.;
1361 ElSLib::Parameters( aCylinder, aProj, aU, aV );
1362 di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n";
1363
1364 return 0;
1365}
1366
89d8607f 1367#include <Extrema_FuncExtPS.hxx>
1368#include <math_FunctionSetRoot.hxx>
1369#include <math_Vector.hxx>
1370#include <BRepBuilderAPI_MakeVertex.hxx>
1371static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1372{
1373 Standard_Integer anArgIter = 1;
1374 if (theNArg < 5)
1375 {
586db386 1376 theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]\n";
89d8607f 1377 return 1;
1378 }
1379
1380 // get target shape
1381 Standard_CString aFaceName = theArgv[anArgIter++];
1382 Standard_CString aVertName = theArgv[anArgIter++];
1383 const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
1384 const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
1385 const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
1386 const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
1387 const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
1388 if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
1389 {
1390 std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1391 return 1;
1392 }
1393 if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1394 {
1395 std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1396 return 1;
1397 }
1398 const TopoDS_Face aFace = TopoDS::Face (aShapeF);
1399 const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1400 GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1401
1402 gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1403
1404 Extrema_FuncExtPS anExtFunc;
1405 math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
1406
1407 math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2);
1408 aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion();
1409 aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite();
1410 aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite();
1411 aFromUV(1) = aUFrom; aFromUV(2) = aVFrom;
1412
1413 anExtFunc.Initialize (aSurf);
1414 anExtFunc.SetPoint (aPnt);
1415 aRoot.SetTolerance (aTolUV);
1416 aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1417 if (!aRoot.IsDone())
1418 {
1419 std::cerr << "No results!\n";
1420 return 1;
1421 }
1422
1423 theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1424
1425 aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1426 DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1427 return 0;
1428}
1429
ab2db9a5 1430//! Check boolean operations on NCollection_Map
1431static Standard_Integer OCC24271 (Draw_Interpretor& di,
1432 Standard_Integer /*theArgNb*/,
1433 const char** /*theArgVec*/)
1434{
1435 // input data
1436 const Standard_Integer aLeftLower = 1;
1437 const Standard_Integer aLeftUpper = 10;
1438 const Standard_Integer aRightLower = 5;
1439 const Standard_Integer aRightUpper = 15;
1440
1441 // define arguments
1442 NCollection_Map<Standard_Integer> aMapLeft;
1443 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1444 {
1445 aMapLeft.Add (aKeyIter);
1446 }
1447
1448 NCollection_Map<Standard_Integer> aMapRight;
1449 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1450 {
1451 aMapRight.Add (aKeyIter);
1452 }
1453
1454 QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1455 QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False);
1456
1457 // validate Union operation
1458 NCollection_Map<Standard_Integer> aMapUnion;
1459 aMapUnion.Union (aMapLeft, aMapRight);
1460 QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1);
1461 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter)
1462 {
1463 QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
1464 }
1465
1466 // validate Intersection operation
1467 NCollection_Map<Standard_Integer> aMapSect;
1468 aMapSect.Intersection (aMapLeft, aMapRight);
1469 QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1);
1470 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1471 {
1472 QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1473 }
1474 QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1475 QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
1476
1477 // validate Substruction operation
1478 NCollection_Map<Standard_Integer> aMapSubsLR;
1479 aMapSubsLR.Subtraction (aMapLeft, aMapRight);
1480 QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower);
1481 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1482 {
1483 QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
1484 }
1485
1486 NCollection_Map<Standard_Integer> aMapSubsRL;
1487 aMapSubsRL.Subtraction (aMapRight, aMapLeft);
1488 QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper);
1489 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1490 {
1491 QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
1492 }
1493
1494 // validate Difference operation
1495 NCollection_Map<Standard_Integer> aMapDiff;
1496 aMapDiff.Difference (aMapLeft, aMapRight);
1497 QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper);
1498 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1499 {
1500 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1501 }
1502 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1503 {
1504 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1505 }
1506
1507 // validate Exchange operation
1508 NCollection_Map<Standard_Integer> aMapSwap;
1509 aMapSwap.Exchange (aMapSect);
1510 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1511 {
1512 QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1513 }
1514 QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1515 aMapSwap.Add (34);
1516 aMapSect.Add (43);
1517
1518 NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1519 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1520 aMapCopy.Remove (34);
1521 aMapCopy.Add (43);
1522 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1523
1524 return 0;
1525}
1526
e6c9f595 1527#define QVERIFY(val1) \
1528 di << "Checking " #val1 " == Standard_True" << \
1529 ((val1) == Standard_True ? ": OK\n" : ": Error\n")
1530
1531#include <GeomInt_IntSS.hxx>
1532#include <Geom_ConicalSurface.hxx>
1533#include <Standard_ErrorHandler.hxx>
1534//=======================================================================
1535//function : OCC23972
1536//purpose :
1537//=======================================================================
1538static void DoGeomIntSSTest (const Handle(Geom_Surface)& theSurf1,
1539 const Handle(Geom_Surface)& theSurf2,
1540 const Standard_Integer theNbSol,
1541 Draw_Interpretor& di)
1542{
1543 try {
1544 OCC_CATCH_SIGNALS
1545 GeomInt_IntSS anInter;
1546 anInter.Perform (theSurf1, theSurf2, Precision::Confusion(), Standard_True);
1547 QVERIFY (anInter.IsDone());
1548 QCOMPARE (anInter.NbLines(), theNbSol);
1549 } catch (...) {
1550 QVERIFY (Standard_False);
1551 }
1552}
1553
1554namespace {
1555 static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc,
1556 const gp_Dir& theDir,
1557 const gp_Dir& theXDir,
1558 const Standard_Real theRad,
1559 const Standard_Real theSin,
1560 const Standard_Real theCos)
1561 {
1562 const Standard_Real anA = atan (theSin / theCos);
1563 gp_Ax3 anAxis (theLoc, theDir, theXDir);
1564 Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad);
1565 return aSurf;
1566 }
1567}
1568
1569static Standard_Integer OCC23972 (Draw_Interpretor& di,Standard_Integer n, const char**)
1570{
1571 if (n != 1) return 1;
1572
1573 //process specific cones, cannot read them from files because due to rounding the original error
1574 //in math_FunctionRoots gets hidden
1575 Handle(Geom_Surface) aS1 = CreateCone (
1576 gp_Pnt (123.694345356663, 789.9, 68.15),
1577 gp_Dir (-1, 3.48029791472957e-016, -8.41302743359754e-017),
1578 gp_Dir (-3.48029791472957e-016, -1, -3.17572289932207e-016),
1579 3.28206830417112,
1580 0.780868809443031,
1581 0.624695047554424);
1582 Handle(Geom_Surface) aS2 = CreateCone (
1583 gp_Pnt (123.694345356663, 784.9, 68.15),
1584 gp_Dir (-1, -2.5209507537117e-016, -1.49772808948866e-016),
1585 gp_Dir (1.49772808948866e-016, 3.17572289932207e-016, -1),
1586 3.28206830417112,
1587 0.780868809443031,
1588 0.624695047554424);
1589
1590 DoGeomIntSSTest (aS1, aS2, 2, di);
1591
1592 return 0;
1593}
1594
e3096dec 1595#include <ShapeFix_EdgeProjAux.hxx>
1596static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1597{
1598 if (argc < 5) {
586db386 1599 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
e3096dec 1600 return 1;
1601 }
1602
1603 TopoDS_Shape aSh = DBRep::Get(argv[1]);
1604 if (aSh.IsNull()) {
1605 di << argv[0] << " Error: Null input edge\n";
1606 return 1;
1607 }
1608 const TopoDS_Edge& anEdge = TopoDS::Edge (aSh);
1609
1610 Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]);
1611 if (aC.IsNull()) {
1612 di << argv[0] << " Error: Null input curve\n";
1613 return 1;
1614 }
1615
1616 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]);
1617 if (aS.IsNull()) {
1618 di << argv[0] << " Error: Null input surface\n";
1619 return 1;
1620 }
1621
1622 Standard_Real prec = Draw::Atof(argv[4]);
1623
1624 //prepare data
1625 TopoDS_Face aFace;
1626 BRep_Builder aB;
1627 aB.MakeFace (aFace, aS, Precision::Confusion());
1628 aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion());
1629 aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter());
1630
1631 //call algorithm
1632 ShapeFix_EdgeProjAux aProj (aFace, anEdge);
1633 aProj.Compute (prec);
1634
1635 Standard_Boolean isfirstdone = aProj.IsFirstDone();
1636 Standard_Boolean islastdone = aProj.IsLastDone();
1637
1638 Standard_Real first = 0.;
1639 Standard_Real last = 0.;
1640 Standard_Integer isfirstdoneInteger = 0;
1641 Standard_Integer islastdoneInteger = 0;
1642
1643
1644 if (isfirstdone) {
1645 first = aProj.FirstParam();
1646 isfirstdoneInteger = 1;
1647 }
1648
1649 if (islastdone) {
1650 last= aProj.LastParam();
1651 islastdoneInteger = 1;
1652 }
1653
1654 di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n";
1655
1656 return 0;
1657}
1658
05d7de53 1659template<typename T, typename HT>
1660static void DoIsNull(Draw_Interpretor& di)
1661{
1662 HT aHandle;
1663 // QVERIFY (aHandle.IsNull());
1664 QCOMPARE (aHandle.IsNull(), Standard_True);
c04c30b3 1665 const T* p = aHandle.get();
05d7de53 1666#if OCC_VERSION_HEX > 0x060700
1667 //QVERIFY (!p);
1668 //QVERIFY (p == 0);
1669 QCOMPARE (!p, Standard_True);
1670 QCOMPARE (p == 0, Standard_True);
1671#endif
1672
1673 aHandle = new T;
1674 //QVERIFY (!aHandle.IsNull());
1675 QCOMPARE (!aHandle.IsNull(), Standard_True);
c04c30b3 1676 p = aHandle.get();
05d7de53 1677 //QVERIFY (p);
1678 //QVERIFY (p != 0);
1679 QCOMPARE (p != NULL, Standard_True);
1680 QCOMPARE (p != 0, Standard_True);
1681}
1682
1683//=======================================================================
1684//function : OCC24533
1685//purpose :
1686//=======================================================================
1687static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**)
1688{
1689 if (n != 1) return 1;
1690
857ffd5e 1691 DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di);
05d7de53 1692
1693 return 0;
1694}
1695
dda67c1c 1696// Dummy class to test interface for compilation issues
1697class QABugs_HandleClass : public Standard_Transient
1698{
1699public:
1700 Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1701 {
1702 std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n";
1703 return 0;
1704 }
92efcf78 1705 DEFINE_STANDARD_RTTI_INLINE(QABugs_HandleClass,Standard_Transient) // Type definition
dda67c1c 1706};
1707DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
ec357c5c 1708
dda67c1c 1709
1710// Dummy class to test interface for compilation issues
1711struct QABugs_NHandleClass
1712{
1713 Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1714 {
586db386 1715 std::cerr << "QABugs_NHandleClass[" << this << "] " << theArgVec[0] << "\n";
dda67c1c 1716 return 0;
1717 }
1718};
1719
574d7236 1720#include <XCAFDoc_ColorTool.hxx>
1721#include <STEPControl_StepModelType.hxx>
1722#include <STEPCAFControl_Writer.hxx>
1723static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1724{
7a7e8cf1 1725 if (argc != 2) {
586db386 1726 di << "Usage: " << argv[0] << " invalid number of arguments\n";
574d7236 1727 return 1;
1728 }
1729 Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");;
1730 TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape();
1731 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape();
1732 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1);
1733 TDataStd_Name::Set(lab1, "Box1");
1734
1735 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1736 XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen);
1737 XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0);
1738
1739 STEPControl_StepModelType mode = STEPControl_AsIs;
1740 STEPCAFControl_Writer writer;
1741 if ( ! writer.Transfer (aDoc, mode ) )
1742 {
1743 di << "The document cannot be translated or gives no result" << "\n";
1744 return 1;
1745 }
1746
7a7e8cf1 1747 writer.Write(argv[1]);
574d7236 1748 return 0;
1749}
1750
1751
f376ac72 1752//=======================================================================
0c674248 1753//function : OCC23950
1754//purpose :
1755//=======================================================================
1756static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1757{
1fa7cb8c 1758 if (argc != 2) {
1759 di << "Usage : " << argv[0] << " step_file\n";
0c674248 1760 return 1;
1761 }
1762
1763 Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy");
1764 TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
1765 gp_Trsf t0;
1766 TopLoc_Location location0 (t0);
1767
1768 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1769 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6);
1770 TDataStd_Name::Set(lab1, "Point1");
1771
1772 TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1773 TDataStd_Name::Set(labelA0, "ASSEMBLY");
1774
1775 TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
1776
1777 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1778 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
1779 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
1780
1781 STEPControl_StepModelType mode = STEPControl_AsIs;
1782 STEPCAFControl_Writer writer;
1783 if (! writer.Transfer (aDoc, mode))
1784 {
586db386 1785 di << "The document cannot be translated or gives no result\n";
0c674248 1786 return 1;
1787 }
1788
1fa7cb8c 1789 writer.Write (argv[1]);
0c674248 1790 return 0;
1791}
1792
1793//=======================================================================
f376ac72 1794//function : OCC24622
1795//purpose : The command tests sourcing Image_PixMap to AIS_TexturedShape
1796//=======================================================================
1797static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
1798{
1799 if (theArgNb != 2)
1800 {
1801 std::cout << "Usage : " << theArgVec[0] << " texture={1D|2D}";
1802 return 1;
1803 }
1804
1805 const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
1806 if (anAISContext.IsNull())
1807 {
1808 std::cout << "Please initialize view with \"vinit\".\n";
1809 return 1;
1810 }
1811
1812 Handle(Image_PixMap) anImage = new Image_PixMap();
1813
b56dd33f 1814 static const Image_ColorRGB aBitmap[8] =
1815 {
1816 {{255, 0, 0}}, {{0, 148, 255}}, {{ 0, 148, 255}}, {{255, 94, 0}},
1817 {{255, 121, 0}}, {{76, 255, 0}}, {{76, 255, 0}}, {{255, 202, 0}}
f376ac72 1818 };
1819
1820 TCollection_AsciiString aTextureTypeArg (theArgVec[1]);
1821 aTextureTypeArg.UpperCase();
1822 if (aTextureTypeArg == "1D")
1823 {
1824 anImage->InitWrapper (Image_PixMap::ImgRGB, (Standard_Byte*)aBitmap, 8, 1);
1825 }
1826 else if (aTextureTypeArg == "2D")
1827 {
1828 anImage->InitTrash (Image_PixMap::ImgRGB, 8, 8);
f376ac72 1829 for (Standard_Integer aRow = 0; aRow < 8; ++aRow)
1830 {
1831 for (Standard_Integer aCol = 0; aCol < 8; ++aCol)
1832 {
ca0c0b11 1833 anImage->ChangeValue<Image_ColorRGB> (aRow, aCol) = aBitmap[aRow];
f376ac72 1834 }
1835 }
1836 }
1837 else
1838 {
1839 std::cout << "Please specify type of texture to test {1D|2D}.\n";
1840 return 1;
1841 }
1842
1843 TopoDS_Shape aBlankShape = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
1844
1845 Handle(AIS_TexturedShape) aTexturedShape = new AIS_TexturedShape (aBlankShape);
1846 aTexturedShape->SetTexturePixMap (anImage);
1847 anAISContext->Display (aTexturedShape, 3, 0);
1848
1849 return 0;
1850}
1851
2cd138b8 1852//=======================================================================
1853//function : OCC24667
1854//purpose :
1855//=======================================================================
1856static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1857{
1858 if (n == 1)
1859 {
586db386 1860 di << "OCC24667 result Wire_spine Profile [Mode [Approx]]\n";
1861 di << "Mode = 0 - CorrectedFrenet,\n";
1862 di << " = 1 - Frenet,\n";
1863 di << " = 2 - DiscreteTrihedron\n";
1864 di << "Approx - force C1-approximation if result is C0\n";
2cd138b8 1865 return 0;
1866 }
1867
1868 if (n > 1 && n < 4) return 1;
1869
1870 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
1871 if ( Spine.IsNull()) return 1;
1872
1873 TopoDS_Shape Profile = DBRep::Get(a[3]);
1874 if ( Profile.IsNull()) return 1;
1875
1876 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
1877 if (n >= 5)
1878 {
1879 Standard_Integer iMode = atoi(a[4]);
1880 if (iMode == 1)
1881 Mode = GeomFill_IsFrenet;
1882 else if (iMode == 2)
1883 Mode = GeomFill_IsDiscreteTrihedron;
1884 }
1885
1886 Standard_Boolean ForceApproxC1 = Standard_False;
1887 if (n >= 6)
1888 ForceApproxC1 = Standard_True;
1889
1890 BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine),
1891 Profile,
1892 Mode,
1893 ForceApproxC1);
1894
1895 TopoDS_Shape S = aPipe.Shape();
1896 TopoDS_Shape aSF = aPipe.FirstShape();
1897 TopoDS_Shape aSL = aPipe.LastShape();
1898
1899 DBRep::Set(a[1],S);
1900
1901 TCollection_AsciiString aStrF(a[1], "_f");
1902 TCollection_AsciiString aStrL(a[1], "_l");
1903
1904 DBRep::Set(aStrF.ToCString(), aSF);
1905 DBRep::Set(aStrL.ToCString(), aSL);
1906
1907 return 0;
1908}
1909
70167e69
RL
1910#include <BRepPrimAPI_MakeCylinder.hxx>
1911#include <BRepBuilderAPI_Copy.hxx>
1912#include <BRepTools_NurbsConvertModification.hxx>
1913static TopoDS_Shape CreateTestShape (int& theShapeNb)
1914{
1915 TopoDS_Compound aComp;
1916 BRep_Builder aBuilder;
1917 aBuilder.MakeCompound (aComp);
1918 //NURBS modifier is used to increase footprint of each shape
35c0599a 1919 Handle(BRepTools_NurbsConvertModification) aNurbsModif = new BRepTools_NurbsConvertModification;
70167e69
RL
1920 TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid();
1921 BRepTools_Modifier aModifier (aRefShape, aNurbsModif);
1922 if (aModifier.IsDone()) {
1923 aRefShape = aModifier.ModifiedShape (aRefShape);
1924 }
1925 int aSiblingNb = 0;
1926 for (; theShapeNb > 0; --theShapeNb) {
1927 TopoDS_Shape aShape;
1928 if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists
1929 aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape();
1930 } else {
1931 aShape = CreateTestShape (theShapeNb);
1932 }
1933 aBuilder.Add (aComp, aShape);
1934 }
1935 return aComp;
1936}
1937
1938#include <AppStd_Application.hxx>
1939#include <TDataStd_Integer.hxx>
1940#include <TNaming_Builder.hxx>
1941static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1942{
7a7e8cf1 1943 if (argc != 2) {
586db386 1944 di << "Usage: " << argv[0] << " invalid number of arguments\n";
70167e69
RL
1945 return 1;
1946 }
7a7e8cf1 1947 TCollection_ExtendedString aFileName (argv[1]);
70167e69
RL
1948 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
1949
1950 Handle(TDocStd_Application) anApp = new AppStd_Application;
1951 {
1952 Handle(TDocStd_Document) aDoc;
1953 anApp->NewDocument ("XmlOcaf", aDoc);
1954 TDF_Label aLab = aDoc->Main();
1955 TDataStd_Integer::Set (aLab, 0);
1956 int n = 10000; //must be big enough
1957 TopoDS_Shape aShape = CreateTestShape (n);
1958 TNaming_Builder aBuilder (aLab);
1959 aBuilder.Generated (aShape);
1960
1961 aSStatus = anApp->SaveAs (aDoc, aFileName);
1962 anApp->Close (aDoc);
1963 }
1964 QCOMPARE (aSStatus, PCDM_SS_OK);
1965 return 0;
1966}
1967
d01cc61d 1968#include <AppStdL_Application.hxx>
1969#include <TDocStd_Application.hxx>
1970#include <TDataStd_Integer.hxx>
1971#include <TDF_AttributeIterator.hxx>
1972//=======================================================================
1973//function : OCC24755
1974//purpose :
1975//=======================================================================
1976static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1977{
1978 if (n != 1)
1979 {
1980 std::cout << "Usage : " << a[0] << "\n";
1981 return 1;
1982 }
1983
1984 Handle(TDocStd_Application) anApp = new AppStdL_Application;
1985 Handle(TDocStd_Document) aDoc;
fff263bd 1986 anApp->NewDocument ("BinOcaf", aDoc);
d01cc61d 1987 TDF_Label aLab = aDoc->Main();
1988 TDataStd_Integer::Set (aLab, 0);
1989 TDataStd_Name::Set (aLab, "test");
1990
1991 TDF_AttributeIterator i (aLab);
1992 Handle(TDF_Attribute) anAttr = i.Value();
1993 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True);
1994 i.Next();
1995 anAttr = i.Value();
1996 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True);
1997
1998 return 0;
1999}
2000
a73267f2 2001struct MyStubObject
2002{
2003 MyStubObject() : ptr(0L) {}
2004 MyStubObject(void* thePtr) : ptr(thePtr) {}
2005 char overhead[40];
2006 void* ptr;
2007};
2008
2009//=======================================================================
2010//function : OCC24834
2011//purpose :
2012//=======================================================================
2013static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2014{
2015 if (n != 1)
2016 {
2017 std::cout << "Usage : " << a[0] << "\n";
2018 return 1;
2019 }
5a89733f 2020
2021 int i = sizeof (char*);
2022 if (i > 4) {
2d7b28ac 2023 std::cout << "64-bit architecture is not supported.\n";
2024 return 0;
2025 }
a73267f2 2026
2027 NCollection_List<MyStubObject> aList;
2028 const Standard_Integer aSmallBlockSize = 40;
2029 const Standard_Integer aLargeBlockSize = 1500000;
2030
2031 // quick populate memory with large blocks
2032 try
2033 {
2034 for (;;)
2035 {
2036 aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize)));
2037 }
2038 }
2039 catch (Standard_Failure)
2040 {
2041 di << "caught out of memory for large blocks: OK\n";
2042 }
2043 catch (...)
2044 {
2045 di << "skept out of memory for large blocks: Error\n";
2046 }
2047
2048 // allocate small blocks
2049 try
2050 {
2051 for (;;)
2052 {
2053 aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize)));
2054 }
2055 }
2056 catch (Standard_Failure)
2057 {
2058 di << "caught out of memory for small blocks: OK\n";
2059 }
2060 catch (...)
2061 {
2062 di << "skept out of memory for small blocks: Error\n";
2063 }
2064
2065 // release all allocated blocks
2066 for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next())
2067 {
2068 Standard::Free(it.Value().ptr);
2069 }
2070 return 0;
2071}
2072
8696d65d 2073
2074#include <Geom2dAPI_InterCurveCurve.hxx>
2075#include <IntRes2d_IntersectionPoint.hxx>
2076//=======================================================================
2077//function : OCC24889
2078//purpose :
2079//=======================================================================
2080static Standard_Integer OCC24889 (Draw_Interpretor& theDI,
2081 Standard_Integer /*theNArg*/,
2082 const char** /*theArgs*/)
2083{
2084 // Curves
2085 Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle(
2086 gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2087
2088 Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle(
2089 gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2090
2091 Handle( Geom2d_TrimmedCurve ) aTrim[2] = {
2092 new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ),
2093 new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 )
2094 };
2095
2096 DrawTrSurf::Set("c_1", aTrim[0]);
2097 DrawTrSurf::Set("c_2", aTrim[1]);
2098
2099 // Intersection
2100 const Standard_Real aTol = Precision::Confusion();
2101 Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol );
2102
2103 const IntRes2d_IntersectionPoint& aIntPnt =
2104 aIntTool.Intersector().Point( 1 );
2105
2106 gp_Pnt2d aIntRes = aIntTool.Point( 1 );
2107 Standard_Real aPar[2] = {
2108 aIntPnt.ParamOnFirst(),
2109 aIntPnt.ParamOnSecond()
2110 };
2111
2112 //theDI.precision( 5 );
2113 theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n";
2114 for (int i = 0; i < 2; ++i)
2115 {
2116 theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() <<
2117 "; LastParam = " << aTrim[i]->LastParameter() <<
2118 "; IntParameter = " << aPar[i] << "\n";
2119 }
2120
2121 return 0;
2122}
2123
5493d334 2124#include <math_GlobOptMin.hxx>
2125#include <math_MultipleVarFunctionWithHessian.hxx>
2126//=======================================================================
2127//function : OCC25004
2128//purpose : Check extremaCC on Branin function.
2129//=======================================================================
2130// Function is:
2131// f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s
2132// Standard borders are:
2133// -5 <= u <= 10
2134// 0 <= v <= 15
2135class BraninFunction : public math_MultipleVarFunctionWithHessian
2136{
2137public:
2138 BraninFunction()
2139 {
2140 a = 1.0;
2141 b = 5.1 / (4.0 * M_PI * M_PI);
2142 c = 5.0 / M_PI;
2143 r = 6.0;
2144 s = 10.0;
2145 t = 1.0 / (8.0 * M_PI);
2146 }
2147 virtual Standard_Integer NbVariables() const
2148 {
2149 return 2;
2150 }
2151 virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F)
2152 {
2153 Standard_Real u = X(1);
2154 Standard_Real v = X(2);
2155
2156 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2157 Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion.
2158 F = a * aSqPt * aSqPt + aLnPt + s;
2159 return Standard_True;
2160 }
2161 virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G)
2162 {
2163 Standard_Real u = X(1);
2164 Standard_Real v = X(2);
2165
2166 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2167 G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u);
2168 G(2) = 2 * a * aSqPt;
2169
2170 return Standard_True;
2171 }
2172 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
2173 {
2174 Value(X,F);
2175 Gradient(X,G);
2176
2177 return Standard_True;
2178 }
2179 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H)
2180 {
2181 Value(X,F);
2182 Gradient(X,G);
2183
2184 Standard_Real u = X(1);
2185 Standard_Real v = X(2);
2186
2187 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2188 Standard_Real aTmpPt = c - 2 * b *u; // Tmp part.
2189 H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u);
2190 H(1,2) = 2 * a * aTmpPt;
2191 H(2,1) = H(1,2);
2192 H(2,2) = 2 * a;
2193
2194 return Standard_True;
2195 }
2196
2197private:
2198 // Standard parameters.
2199 Standard_Real a, b, c, r, s, t;
2200};
2201
2202static Standard_Integer OCC25004 (Draw_Interpretor& theDI,
2203 Standard_Integer /*theNArg*/,
2204 const char** /*theArgs*/)
2205{
4b65fc77 2206 BraninFunction aFunc;
5493d334 2207
2208 math_Vector aLower(1,2), aUpper(1,2);
2209 aLower(1) = -5;
2210 aLower(2) = 0;
2211 aUpper(1) = 10;
2212 aUpper(2) = 15;
2213
2214 Standard_Integer aGridOrder = 16;
2215 math_Vector aFuncValues(1, aGridOrder * aGridOrder);
2216
2217 Standard_Real aLipConst = 0;
2218 math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2);
2219
2220 // Get Lipshitz constant estimation on regular grid.
2221 Standard_Integer i, j, idx = 1;
2222 for(i = 1; i <= aGridOrder; i++)
2223 {
2224 for(j = 1; j <= aGridOrder; j++)
2225 {
2226 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2227 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2228
4b65fc77 2229 aFunc.Value(aCurrPnt1, aFuncValues(idx));
5493d334 2230 idx++;
2231 }
2232 }
2233
2234 Standard_Integer k, l;
2235 Standard_Integer idx1, idx2;
2236 for(i = 1; i <= aGridOrder; i++)
2237 for(j = 1; j <= aGridOrder; j++)
2238 for(k = 1; k <= aGridOrder; k++)
2239 for(l = 1; l <= aGridOrder; l++)
2240 {
2241 if (i == k && j == l)
2242 continue;
2243
2244 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2245 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2246 idx1 = (i - 1) * aGridOrder + j;
2247
2248 aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0);
2249 aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0);
2250 idx2 = (k - 1) * aGridOrder + l;
2251
2252 aCurrPnt1.Add(-aCurrPnt2);
2253 Standard_Real dist = aCurrPnt1.Norm();
2254
2255 Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist;
2256 if (C > aLipConst)
2257 aLipConst = C;
2258 }
2259
4b65fc77 2260 math_GlobOptMin aFinder(&aFunc, aLower, aUpper, aLipConst);
5493d334 2261 aFinder.Perform();
2262 //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475)
2263
2264 Standard_Real anExtValue = aFinder.GetF();
2265 theDI << "F = " << anExtValue << "\n";
2266
2267 Standard_Integer aNbExt = aFinder.NbExtrema();
2268 theDI << "NbExtrema = " << aNbExt << "\n";
2269
2270 return 0;
2271}
8696d65d 2272
b6c0b841
RL
2273#include <OSD_Environment.hxx>
2274#include <Plugin.hxx>
2275#include <Plugin_Macro.hxx>
2276#include <Resource_Manager.hxx>
2277
2278#define THE_QATEST_DOC_FORMAT "My Proprietary Format"
2279
2280#define QA_CHECK(theDesc, theExpr, theValue) \
2281{\
2282 const bool isTrue = !!(theExpr); \
2283 std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \
2284}
2285
2286class Test_TDocStd_Application : public TDocStd_Application
2287{
2288public:
2289
2290 static void initGlobalPluginMap (const TCollection_AsciiString& thePlugin,
2291 const TCollection_AsciiString& theSaver,
2292 const TCollection_AsciiString& theLoader)
2293 {
2294 const Handle(Resource_Manager)& aManager = Plugin::AdditionalPluginMap();
2295 aManager->SetResource ((theSaver + ".Location").ToCString(), thePlugin.ToCString());
2296 aManager->SetResource ((theLoader + ".Location").ToCString(), thePlugin.ToCString());
2297 }
2298
2299 Test_TDocStd_Application (const TCollection_AsciiString& thePlugin,
2300 const TCollection_AsciiString& theSaver,
2301 const TCollection_AsciiString& theLoader)
2302 {
2303 initGlobalPluginMap (thePlugin, theSaver, theLoader);
2304
2305 // explicitly initialize resource manager
2306 myResources = new Resource_Manager ("");
2307 myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT);
2308 myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document");
2309 myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml");
2310 myResources->SetResource (THE_QATEST_DOC_FORMAT ".StoragePlugin", theSaver.ToCString());
2311 myResources->SetResource (THE_QATEST_DOC_FORMAT ".RetrievalPlugin", theLoader.ToCString());
2312 }
2313
2314 virtual Standard_CString ResourcesName() { return ""; }
2315 virtual void Formats (TColStd_SequenceOfExtendedString& theFormats) { theFormats.Clear(); }
2316};
2317
2318//=======================================================================
2319//function : OCC24925
2320//purpose :
2321//=======================================================================
2322static Standard_Integer OCC24925 (Draw_Interpretor& theDI,
2323 Standard_Integer theArgNb,
2324 const char** theArgVec)
2325{
2326 if (theArgNb != 2
2327 && theArgNb != 5)
2328 {
2329 std::cout << "Error: wrong syntax! See usage:\n";
2330 theDI.PrintHelp (theArgVec[0]);
2331 return 1;
2332 }
2333
2334 Standard_Integer anArgIter = 1;
2335 TCollection_ExtendedString aFileName = theArgVec[anArgIter++];
2336 TCollection_AsciiString aPlugin = "TKXml";
2337 TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx
2338 TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx
2339 if (anArgIter < theArgNb)
2340 {
2341 aPlugin = theArgVec[anArgIter++];
2342 aSaver = theArgVec[anArgIter++];
2343 aLoader = theArgVec[anArgIter++];
2344 }
2345
2346 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2347 PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError;
2348
2349 Handle(TDocStd_Application) anApp = new Test_TDocStd_Application (aPlugin, aSaver, aLoader);
2350 {
2351 Handle(TDocStd_Document) aDoc;
2352 anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc);
2353 TDF_Label aLab = aDoc->Main();
2354 TDataStd_Integer::Set (aLab, 0);
2355 TDataStd_Name::Set (aLab, "QABugs_19.cxx");
2356
2357 aSStatus = anApp->SaveAs (aDoc, aFileName);
2358 anApp->Close (aDoc);
2359 }
2360 QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true);
2361
2362 {
2363 Handle(TDocStd_Document) aDoc;
2364 aRStatus = anApp->Open (aFileName, aDoc);
2365 anApp->Close (aDoc);
2366 }
2367 QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true);
2368 return 0;
2369}
2370
e4b5c45a 2371//=======================================================================
a967f104 2372//function : OCC25043
2373//purpose :
2374//=======================================================================
2375#include <BRepAlgoAPI_Check.hxx>
2376static Standard_Integer OCC25043 (Draw_Interpretor& theDI,
2377 Standard_Integer theArgNb,
2378 const char** theArgVec)
2379{
2380 if (theArgNb != 2) {
2381 theDI << "Usage: " << theArgVec[0] << " shape\n";
2382 return 1;
2383 }
2384
2385 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
2386 if (aShape.IsNull())
2387 {
2388 theDI << theArgVec[1] << " shape is NULL\n";
2389 return 1;
2390 }
2391
2392 BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True);
2393
2394 if (!anAlgoApiCheck.IsValid())
2395 {
2396 BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result());
2397 for (; anCheckIter.More(); anCheckIter.Next())
2398 {
2399 const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value();
2400 const BOPCol_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1();
2401 BOPCol_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes);
2402 for (; aFaultyIter.More(); aFaultyIter.Next())
2403 {
2404 const TopoDS_Shape& aFaultyShape = aFaultyIter.Value();
2405
2406 Standard_Boolean anIsFaultyShapeFound = Standard_False;
2407 TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType());
2408 for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next())
2409 {
2410 if (anExp.Current().IsEqual(aFaultyShape))
2411 anIsFaultyShapeFound = Standard_True;
2412 }
2413
2414 if (!anIsFaultyShapeFound)
2415 {
2416 theDI << "Error. Faulty Shape is NOT found in source shape.\n";
2417 return 0;
2418 }
2419 else
2420 {
3510db62 2421 theDI << "Info. Faulty shape is found in source shape\n";
a967f104 2422 }
2423 }
2424 }
2425 }
2426 else
2427 {
3510db62 2428 theDI << "Problems are not detected. Test is not performed.";
a967f104 2429 }
2430
2431 return 0;
2432}
2433
2434//=======================================================================
4a350f94 2435//function : OCC24606
2436//purpose :
2437//=======================================================================
2438static Standard_Integer OCC24606 (Draw_Interpretor& theDI,
2439 Standard_Integer theArgNb,
2440 const char** theArgVec)
2441{
2442 if (theArgNb > 1)
2443 {
2444 std::cerr << "Error: incorrect number of arguments.\n";
2445 theDI << "Usage : " << theArgVec[0] << "\n";
2446 return 1;
2447 }
2448
2449 Handle(V3d_View) aView = ViewerTest::CurrentView();
2450 if (aView.IsNull())
2451 {
2452 std::cerr << "Errro: no active view, please call 'vinit'.\n";
2453 return 1;
2454 }
2455
2456 aView->DepthFitAll();
2457 aView->FitAll();
2458
2459 return 0;
2460}
2461
2462//=======================================================================
e4b5c45a 2463//function : OCC23010
2464//purpose :
2465//=======================================================================
2466#include <STEPCAFControl_Reader.hxx>
2467
2468class mOcafApplication : public TDocStd_Application
2469{
2470 void Formats(TColStd_SequenceOfExtendedString& Formats)
2471 {
2472 Formats.Append(TCollection_ExtendedString("mOcafApplication"));
2473 }
2474 Standard_CString ResourcesName()
2475 {
2476 return Standard_CString("Resources");
2477 }
2478};
2479
2480static Standard_Integer OCC23010 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2481{
2482 if (argc != 2) {
586db386 2483 di << "Usage: " << argv[0] << " invalid number of arguments\n";
e4b5c45a 2484 return 1;
2485 }
2486 std::string fileName=argv[1];
2487 mOcafApplication *mCasApp = new mOcafApplication();
2488 Handle(TDocStd_Document) doc;
fff263bd 2489 mCasApp->NewDocument("BinXCAF", doc);
e4b5c45a 2490 STEPCAFControl_Reader stepReader;
2491 IFSelect_ReturnStatus status = stepReader.ReadFile (fileName.c_str());
2492 if (status != IFSelect_RetDone)
2493 return false;
2494 stepReader.SetColorMode(Standard_True);
2495 stepReader.SetLayerMode(Standard_True);
2496 stepReader.SetNameMode(Standard_True);
2497 stepReader.Transfer(doc); // ERROR HERE!!!
2498 delete mCasApp;
2499 return 0;
2500}
2501
ab860031 2502//=======================================================================
2503//function : OCC25202
2504//purpose :
2505//=======================================================================
2506#include <ShapeBuild_ReShape.hxx>
2507static Standard_Integer OCC25202 ( Draw_Interpretor& theDI,
2508 Standard_Integer theArgN,
2509 const char** theArgVal)
2510{
2511 // 0 1 2 3 4 5 6
2512 //reshape res shape numF1 face1 numF2 face2
2513 if(theArgN < 7)
2514 {
2515 theDI << "Use: reshape res shape numF1 face1 numF2 face2\n";
2516 return 1;
2517 }
2518
2519 TopoDS_Shape aShape = DBRep::Get(theArgVal[2]);
2520 const Standard_Integer aNumOfRE1 = Draw::Atoi(theArgVal[3]),
2521 aNumOfRE2 = Draw::Atoi(theArgVal[5]);
2522 TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])),
2523 aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6]));
2524
2525 if(aShape.IsNull())
2526 {
2527 theDI << theArgVal[2] << " is null shape\n";
2528 return 1;
2529 }
2530
2531 if(aShapeForRepl1.IsNull())
2532 {
2533 theDI << theArgVal[4] << " is not a replaced type\n";
2534 return 1;
2535 }
2536
2537 if(aShapeForRepl2.IsNull())
2538 {
2539 theDI << theArgVal[6] << " is not a replaced type\n";
2540 return 1;
2541 }
2542
2543
2544 TopoDS_Shape aReplacedShape;
2545 ShapeBuild_ReShape aReshape;
2546
2547 //////////////////// explode (begin)
2548 TopTools_MapOfShape M;
2549 M.Add(aShape);
2550 Standard_Integer aNbShapes = 0;
2551 for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next())
2552 {
2553 const TopoDS_Shape& Sx = ex.Current();
2554 Standard_Boolean added = M.Add(Sx);
2555 if (added)
2556 {
2557 aNbShapes++;
2558 if(aNbShapes == aNumOfRE1)
2559 {
2560 aReplacedShape = Sx;
2561
2562 aReshape.Replace(aReplacedShape, aShapeForRepl1);
2563 }
2564
2565 if(aNbShapes == aNumOfRE2)
2566 {
2567 aReplacedShape = Sx;
2568
2569 aReshape.Replace(aReplacedShape, aShapeForRepl2);
2570 }
2571 }
2572 }
2573 //////////////////// explode (end)
2574
2575 if(aReplacedShape.IsNull())
2576 {
2577 theDI << "There is not any shape for replacing.\n";
2578 }
2579
2580 DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2));
2581
2582 return 0;
2583}
2584
c6037065 2585#include <ShapeFix_Wireframe.hxx>
2586//=======================================================================
2587//function : OCC7570
2588//purpose :
2589//=======================================================================
2590static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2591{
2592 if (n != 2) {
586db386 2593 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
c6037065 2594 return 1;
2595 }
2596 TopoDS_Shape in_shape (DBRep::Get (a[1]));
2597 ShapeFix_Wireframe fix_tool (in_shape);
2598 fix_tool.ModeDropSmallEdges () = Standard_True;
2599 fix_tool.SetPrecision (1.e+6);
2600 fix_tool.SetLimitAngle (0.01);
2601 fix_tool.FixSmallEdges ();
2602 TopoDS_Shape new_shape = fix_tool.Shape ();
2603 return 0;
2604}
2605
54a16ee4 2606#include <AIS_TypeFilter.hxx>
5e452c37 2607//=======================================================================
2608//function : OCC25340
2609//purpose :
2610//=======================================================================
54a16ee4 2611static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/,
2612 Standard_Integer /*theArgNb*/,
2613 const char** /*theArgVec*/)
2614{
2615 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2616 if (aCtx.IsNull())
2617 {
2618 std::cerr << "Error: No opened viewer!\n";
2619 return 1;
2620 }
2621 Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
2622 aCtx->AddFilter (aFilter);
2623 return 0;
2624}
2625
c7b59798 2626//=======================================================================
2627//function : OCC24826
2628//purpose :
2629//=======================================================================
2630class ParallelTest_Saxpy
2631{
2632public:
2633 typedef NCollection_Array1<Standard_Real> Vector;
2634
2635 //! Constructor
2636 ParallelTest_Saxpy(const Vector& theX, Vector& theY, Standard_Real theScalar)
2637 : myX(theX),
2638 myY(theY),
2639 myScalar(theScalar)
2640 {
2641 }
2642
2643 //! Dummy calculation
2644 void operator() (const Standard_Integer theIndex) const
2645 {
2646 myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex);
2647 }
2648
2649private:
2650 ParallelTest_Saxpy( const ParallelTest_Saxpy& );
2651 ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& );
2652
2653private:
2654 const Vector& myX;
2655 Vector& myY;
2656 const Standard_Real myScalar;
2657};
2658
2659//---------------------------------------------------------------------
2660static Standard_Integer OCC24826(Draw_Interpretor& theDI,
2661 Standard_Integer trheArgc,
2662 const char** theArgv)
2663{
2664 if ( trheArgc != 2 )
2665 {
2666 theDI << "Usage: "
2667 << theArgv[0]
2668 << " vec_length\n";
2669 return 1;
2670 }
2671
2672 // Generate data;
2673 Standard_Integer aLength = Draw::Atoi(theArgv[1]);
2674
2675 NCollection_Array1<Standard_Real> aX (0, aLength - 1);
2676 NCollection_Array1<Standard_Real> anY(0, aLength - 1);
2677
2678 for ( Standard_Integer i = 0; i < aLength; ++i )
2679 {
2680 aX(i) = anY(i) = (Standard_Real) i;
2681 }
2682
2683 OSD_Timer aTimer;
2684
2685 aTimer.Start();
2686
2687 //! Serial proccesing
2688 for ( Standard_Integer i = 0; i < aLength; ++i )
2689 {
2690 anY(i) = 1e-6 * aX(i) + anY(i);
2691 }
2692
2693 aTimer.Stop();
2694 cout << "Processing time (sequential mode):\n";
2695 aTimer.Show();
2696
2697 const ParallelTest_Saxpy aFunctor(aX, anY, 1e-6);
2698
2699 aTimer.Reset();
2700 aTimer.Start();
2701
2702 // Parallel processing
2703 OSD_Parallel::For(0, aLength, aFunctor);
2704
2705 aTimer.Stop();
2706 cout << "Processing time (parallel mode):\n";
2707 aTimer.Show();
2708
2709 return 0;
2710}
2711
b6c0b841 2712/*****************************************************************************/
8696d65d 2713
058f130e 2714#include <GeomAPI_IntSS.hxx>
2715//=======================================================================
2716//function : OCC25100
2717//purpose :
2718//=======================================================================
2719static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2720{
2721 if (argc < 2)
2722 {
2723 di << "the method requires a shape name\n";
2724 return 1;
2725 }
2726
2727 TopoDS_Shape S = DBRep::Get(argv[1]);
2728 if ( S.IsNull() )
2729 {
586db386 2730 di << "Shape is empty\n";
058f130e 2731 return 1;
2732 }
2733
2734 TopExp_Explorer aFaceExp(S, TopAbs_FACE);
2735 const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current()));
2736
2737 GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion());
2738
2739 if (!anIntersector.IsDone())
2740 {
2741 di << "Error. Intersection is not done\n";
2742 return 1;
2743 }
2744
2745 di << "Test complete\n";
2746
2747 return 0;
2748}
2749
5e452c37 2750//=======================================================================
2751//function : OCC25348
2752//purpose :
2753//=======================================================================
2754static Standard_Integer OCC25348 (Draw_Interpretor& theDI,
2755 Standard_Integer /*theArgNb*/,
2756 const char** /*theArgVec*/)
2757{
2758 Handle(NCollection_IncAllocator) anAlloc1;
2759 NCollection_List<int> aList1(anAlloc1);
2760 for (int i=0; i < 10; i++)
2761 {
2762 Handle(NCollection_IncAllocator) anAlloc2;
2763 NCollection_List<int> aList2(anAlloc2);
2764 aList2.Append(i);
2765 aList1.Assign(aList2);
2766 }
2767 theDI << "Test complete\n";
2768 return 0;
2769}
2770
6fb3418e 2771#include <IntCurvesFace_ShapeIntersector.hxx>
2772#include <BRepBndLib.hxx>
2773//=======================================================================
2774//function : OCC25413
2775//purpose :
2776//=======================================================================
2777static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
2778{
2779 if (narg != 2) {
586db386 2780 di << "Usage: " << a[0] << " invalid number of arguments\n";
6fb3418e 2781 return 1;
2782 }
2783 TopoDS_Shape aShape = DBRep::Get (a[1]);
2784
2785 IntCurvesFace_ShapeIntersector Inter;
2786 Inter.Load(aShape, Precision::Confusion());
2787
2788 Bnd_Box aBndBox;
2789 BRepBndLib::Add(aShape, aBndBox);
2790
2791 gp_Dir aDir(0., 1., 0.);
2792 const int N = 250;
2793 Standard_Real xMin = aBndBox.CornerMin().X();
2794 Standard_Real zMin = aBndBox.CornerMin().Z();
2795 Standard_Real xMax = aBndBox.CornerMax().X();
2796 Standard_Real zMax = aBndBox.CornerMax().Z();
2797 Standard_Real xStep = (xMax - xMin) / N;
2798 Standard_Real zStep = (zMax - zMin) / N;
2799
2800 for (Standard_Real x = xMin; x <= xMax; x += xStep)
2801 for (Standard_Real z = zMin; z <= zMax; z += zStep)
2802 {
2803 gp_Pnt aPoint(x, 0.0, z);
2804 gp_Lin aLine(aPoint, aDir);
2805 Inter.PerformNearest(aLine, -100., 100.);
2806 }
2807 return 0;
2808}
058f130e 2809
c088aa93 2810
2811#include <BOPAlgo_PaveFiller.hxx>
2812//
2813#include <BRepAlgoAPI_BooleanOperation.hxx>
2814#include <BRepAlgoAPI_Common.hxx>
2815#include <BRepAlgoAPI_Fuse.hxx>
2816#include <BRepAlgoAPI_Cut.hxx>
2817#include <BRepAlgoAPI_Section.hxx>
2818//
2819#include <BOPTools.hxx>
2820//
2821#include <BOPCol_MapOfShape.hxx>
2822#include <BOPCol_ListOfShape.hxx>
2823//=======================================================================
2824//function : OCC25446
2825//purpose :
2826//=======================================================================
2827static Standard_Integer OCC25446 (Draw_Interpretor& theDI,
2828 Standard_Integer argc,
2829 const char ** argv)
2830{
2831 if (argc != 5) {
2832 theDI << "Usage: OCC25446 res b1 b2 op\n";
2833 return 1;
2834 }
2835 //
2836 TopoDS_Shape aS1 = DBRep::Get(argv[2]);
2837 if (aS1.IsNull()) {
2838 theDI << argv[2] << " shape is NULL\n";
2839 return 1;
2840 }
2841 //
2842 TopoDS_Shape aS2 = DBRep::Get(argv[3]);
2843 if (aS2.IsNull()) {
2844 theDI << argv[3] << " shape is NULL\n";
2845 return 1;
2846 }
2847 //
2848 Standard_Integer iOp;
2849 BOPAlgo_Operation aOp;
2850 //
2851 iOp = Draw::Atoi(argv[4]);
2852 if (iOp < 0 || iOp > 4) {
2853 theDI << "Invalid operation type\n";
2854 return 1;
2855 }
2856 aOp = (BOPAlgo_Operation)iOp;
2857 //
2858 Standard_Integer iErr;
2859 BOPCol_ListOfShape aLS;
2860 BOPAlgo_PaveFiller aPF;
2861 //
2862 aLS.Append(aS1);
2863 aLS.Append(aS2);
2864 aPF.SetArguments(aLS);
2865 //
2866 aPF.Perform();
2867 iErr = aPF.ErrorStatus();
2868 if (iErr) {
2869 theDI << "Intersection failed with error status: " << iErr << "\n";
2870 return 1;
2871 }
2872 //
2873 BRepAlgoAPI_BooleanOperation* pBuilder = NULL;
2874 //
2875 switch (aOp) {
2876 case BOPAlgo_COMMON:
2877 pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF);
2878 break;
2879 case BOPAlgo_FUSE:
2880 pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
2881 break;
2882 case BOPAlgo_CUT:
2883 pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF);
2884 break;
2885 case BOPAlgo_CUT21:
2886 pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
2887 break;
2888 case BOPAlgo_SECTION:
2889 pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF);
2890 break;
2891 default:
2892 break;
2893 }
2894 //
2895 iErr = pBuilder->ErrorStatus();
2896 if (!pBuilder->IsDone()) {
2897 theDI << "BOP failed with error status: " << iErr << "\n";
2898 return 1;
2899 }
2900 //
2901 const TopoDS_Shape& aRes = pBuilder->Shape();
2902 DBRep::Set(argv[1], aRes);
2903 //
2904 BOPCol_MapOfShape aMapArgs, aMapShape;
2905 BOPCol_MapIteratorOfMapOfShape aIt;
2906 Standard_Boolean bIsDeletedHist, bIsDeletedMap;
2907 TopAbs_ShapeEnum aType;
2908 //
2909 BOPTools::MapShapes(aS1, aMapArgs);
2910 BOPTools::MapShapes(aS2, aMapArgs);
2911 BOPTools::MapShapes(aRes, aMapShape);
2912 //
2913 aIt.Initialize(aMapArgs);
2914 for (; aIt.More(); aIt.Next()) {
2915 const TopoDS_Shape& aS = aIt.Value();
2916 aType = aS.ShapeType();
2917 if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
2918 aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
2919 continue;
2920 }
2921 //
2922 bIsDeletedHist = pBuilder->IsDeleted(aS);
2923 bIsDeletedMap = !aMapShape.Contains(aS) &&
2924 (pBuilder->Modified(aS).Extent() == 0);
2925 //
2926 if (bIsDeletedHist != bIsDeletedMap) {
2927 theDI << "Error. Wrong value of IsDeleted flag.\n";
2928 return 1;
2929 }
2930 }
2931 //
2932 theDI << "Test complete\n";
2933 return 0;
2934}
2935
ee6bb37b 2936//====================================================
2937// Auxiliary functor class for the command OCC25545;
2938// it gets access to a vertex with the given index and
2939// checks that X coordinate of the point is equal to index;
2940// if it is not so then a data race is reported.
2941//====================================================
2942struct OCC25545_Functor
2943{
2944 OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
2945 : myShapeVec(&theShapeVec),
2946 myIsRaceDetected(0)
2947 {}
2948
2949 void operator()(size_t i) const
2950 {
2951 if (!myIsRaceDetected) {
2952 const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i));
2953 gp_Pnt aP = BRep_Tool::Pnt (aV);
2954 if (aP.X () != static_cast<double> (i)) {
2955 Standard_Atomic_Increment(&myIsRaceDetected);
2956 }
2957 }
2958 }
2959
2960 const std::vector<TopoDS_Shape>* myShapeVec;
2961 mutable volatile int myIsRaceDetected;
2962};
2963
2964//=======================================================================
2965//function : OCC25545
2966//purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation()
2967//=======================================================================
2968#ifdef HAVE_TBB
2969static Standard_Integer OCC25545 (Draw_Interpretor& di,
2970 Standard_Integer,
2971 const char **)
2972{
2973 // Place vertices in a vector, giving the i-th vertex the
2974 // transformation that translates it on the vector (i,0,0) from the origin.
2975 size_t n = 1000;
2976 std::vector<TopoDS_Shape> aShapeVec (n);
2977 std::vector<TopLoc_Location> aLocVec (n);
2978 TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ());
2979 aShapeVec[0] = aShape;
2980 for (size_t i = 1; i < n; ++i) {
2981 gp_Trsf aT;
2982 aT.SetTranslation (gp_Vec (1, 0, 0));
2983 aLocVec[i] = aLocVec[i - 1] * aT;
2984 aShapeVec[i] = aShape.Moved (aLocVec[i]);
2985 }
2986
2987 // Evaluator function will access vertices geometry
2988 // concurrently
2989 OCC25545_Functor aFunc(aShapeVec);
2990
2991 //concurrently process
2992 tbb::parallel_for (size_t (0), n, aFunc, tbb::simple_partitioner ());
2993 QVERIFY (!aFunc.myIsRaceDetected);
2994 return 0;
2995}
2996#else
2997static Standard_Integer OCC25545 (Draw_Interpretor&,
2998 Standard_Integer,
2999 const char **argv)
3000{
3001 cout << "Test skipped: command " << argv[0] << " requires TBB library" << endl;
3002 return 0;
3003}
3004#endif
3005
d315303d 3006//=======================================================================
3007//function : OCC25547
3008//purpose :
3009//=======================================================================
3010#include <BRepMesh_GeomTool.hxx>
3011#include <BRepAdaptor_Curve.hxx>
3012#include <Geom_TrimmedCurve.hxx>
3013#include <BRepBuilderAPI_MakeFace.hxx>
3014#include <BRepAdaptor_HSurface.hxx>
3015#include <BRepAdaptor_Surface.hxx>
3016static Standard_Integer OCC25547(
3017 Draw_Interpretor& theDI,
3018 Standard_Integer /*argc*/,
3019 const char ** /*argv*/)
3020{
3021 // The general aim of this test is to prevent linkage errors due to missed
3022 // Standard_EXPORT attribute for static methods.
3023
3024 // However, start checking the main functionality at first.
3025 const Standard_Real aFirstP = 0., aLastP = M_PI;
3026 Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
3027 Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
3028 TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf);
3029 BRepAdaptor_Curve aAdaptor(aEdge);
3030 BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5);
3031
3032 if (aGeomTool.NbPoints() == 0)
3033 {
3034 theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
3035 return 1;
3036 }
3037
3038 // Test static methods.
3039 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
3040 BRepAdaptor_Surface aSurf(aFace);
3041 Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf);
3042
3043 gp_Pnt aPnt;
3044 gp_Dir aNormal;
3045 if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
3046 {
3047 theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
3048 return 1;
3049 }
3050
3051 gp_XY aRefPnts[4] = {
3052 gp_XY(-10., -10.), gp_XY(10., 10.),
3053 gp_XY(-10., 10.), gp_XY(10., -10.)
3054 };
3055
3056 gp_Pnt2d aIntPnt;
3057 Standard_Real aParams[2];
3058 BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin(
3059 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3060 aIntPnt.ChangeCoord(), aParams);
3061
3062 Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
3063 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3064 {
3065 theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
3066 return 1;
3067 }
3068
3069 aIntFlag = BRepMesh_GeomTool::IntSegSeg(
3070 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3071 Standard_False, Standard_False, aIntPnt);
3072
3073 aDiff = aIntPnt.Distance(gp::Origin2d());
3074 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3075 {
3076 theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
3077 return 1;
3078 }
3079
3080
3081 theDI << "Test complete\n";
3082 return 0;
3083}
3084
ec81011f 3085static Standard_Integer OCC26139 (Draw_Interpretor& theDI,
3086 Standard_Integer argc,
3087 const char ** argv)
3088{
3089
3090 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
3091 if (aCtx.IsNull())
3092 {
3093 theDI << "Use 'vinit' command before " << argv[0] << "\n";
3094 return 1;
3095 }
3096
3097 Standard_Integer aBoxGridSize = 100;
3098 Standard_Integer aCompGridSize = 3;
3099 Standard_Real aBoxSize = 5.0;
3100
3101 if (argc > 1)
3102 {
3103 for (Standard_Integer anArgIdx = 1; anArgIdx < argc; ++anArgIdx)
3104 {
3105 TCollection_AsciiString anArg (argv[anArgIdx]);
3106 anArg.LowerCase();
3107 if (anArg == "-boxgrid")
3108 {
3109 aBoxGridSize = Draw::Atoi (argv[++anArgIdx]);
3110 }
3111 else if (anArg == "-compgrid")
3112 {
3113 aCompGridSize = Draw::Atoi (argv[++anArgIdx]);
3114 }
3115 else if (anArg == "-boxsize")
3116 {
3117 aBoxSize = Draw::Atof (argv[++anArgIdx]);
3118 }
3119 }
3120 }
3121
3122 NCollection_List<Handle(AIS_Shape)> aCompounds;
3123 for (Standard_Integer aCompGridX = 0; aCompGridX < aCompGridSize; ++aCompGridX)
3124 {
3125 for (Standard_Integer aCompGridY = 0; aCompGridY < aCompGridSize; ++aCompGridY)
3126 {
3127 BRep_Builder aBuilder;
3128 TopoDS_Compound aComp;
3129 aBuilder.MakeCompound (aComp);
3130 for (Standard_Integer aBoxGridX = 0; aBoxGridX < aBoxGridSize; ++aBoxGridX)
3131 {
3132 for (Standard_Integer aBoxGridY = 0; aBoxGridY < aBoxGridSize; ++aBoxGridY)
3133 {
3134 BRepPrimAPI_MakeBox aBox (gp_Pnt (aBoxGridX * aBoxSize, aBoxGridY * aBoxSize, 0.0),
3135 aBoxSize, aBoxSize, aBoxSize);
3136 aBuilder.Add (aComp, aBox.Shape());
3137 }
3138 }
3139 gp_Trsf aTrsf;
3140 aTrsf.SetTranslation (gp_Vec (aBoxGridSize * aBoxSize * aCompGridX,
3141 aBoxGridSize * aBoxSize * aCompGridY,
3142 0.0));
3143 TopLoc_Location aLoc (aTrsf);
3144 aComp.Located (aLoc);
3145 aCompounds.Append (new AIS_Shape (aComp));
3146 }
3147 }
3148
3149 OSD_Timer aTimer;
3150 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3151 {
3152 aTimer.Start();
3153 aCtx->Display (aCompIter.Value(), Standard_False);
3154 aTimer.Stop();
3155 theDI << "Display time: " << aTimer.ElapsedTime() << "\n";
3156 aTimer.Reset();
3157 }
3158
3159 aTimer.Reset();
3160 aTimer.Start();
3161 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3162 {
3163 aCtx->Remove (aCompIter.Value(), Standard_False);
3164 }
3165 aTimer.Stop();
3166 theDI << "Remove time: " << aTimer.ElapsedTime() << "\n";
3167
3168 return 0;
3169}
3170
2bfe59b6 3171#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
3172#include <TColStd_DataMapOfIntegerInteger.hxx>
3173#include <OSD.hxx>
3174#include <ShapeFix_Wire.hxx>
3175#include <ShapeExtend_Status.hxx>
57c28b61 3176#ifdef _WIN32
2bfe59b6 3177#define EXCEPTION ...
3178#else
3179#define EXCEPTION Standard_Failure
3180#endif
3181
3182static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)& theFix,
3183 const Standard_Boolean theIs3d)
3184{
3185 for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++)
3186 {
3187 Standard_Boolean isFound;
3188 if (theIs3d)
3189 isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i );
3190 else
3191 isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i );
3192 if (isFound) return ShapeExtend_Status(i);
3193 }
3194 return ShapeExtend_OK;
3195}
3196
3197//===================
3198//function : OCC24881
3199//purpose :
3200//===================
3201static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
3202{
3203 if (narg < 2) {
586db386 3204 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
2bfe59b6 3205 return 1;
3206 }
3207// cout <<"FileName1: " << argv[1] <<endl;
3208
3209 TopoDS_Shape aShape = DBRep::Get (a[1]);
3210
3211 OSD::SetSignal();
3212 Handle(ShapeFix_Wire) aWireFix = new ShapeFix_Wire;
3213
3214 // map FixStatus - NbSuchStatuses
3215 TColStd_DataMapOfIntegerInteger aStatusNbDMap;
3216 Standard_Integer nbFixed=0, nbOk=0;
3217
3218//Begin: STEP 7
3219 ShapeExtend_Status aStatus=ShapeExtend_OK;
3220 try {
3221 TopExp_Explorer aFaceExplorer(aShape, TopAbs_FACE);
3222 for (; aFaceExplorer.More(); aFaceExplorer.Next())
3223 {
3224 TopoDS_Shape aFace = aFaceExplorer.Current();
3225 // loop on wires
3226 TopoDS_Iterator aWireItr(aFace);
3227 for (; aWireItr.More(); aWireItr.Next() )
3228 {
3229 Standard_Boolean wasOk = Standard_False;
3230 TopoDS_Wire aSrcWire = TopoDS::Wire(aWireItr.Value());
3231
3232 aWireFix->Load (aSrcWire);
3233 aWireFix->SetFace (TopoDS::Face(aFace));
3234 aWireFix->FixReorder(); //correct order is a prerequisite
3235 // fix 3d
3236 if (!aWireFix->FixGaps3d())
3237 {
3238 // not fixed, why?
3239 aStatus = getStatusGap(aWireFix, Standard_True);
3240 if (aStatus == ShapeExtend_OK)
3241 wasOk = Standard_True;
3242 else
3243 {
3244 // keep 3d fail status
3245 if (aStatusNbDMap.IsBound (aStatus))
3246 aStatusNbDMap(aStatus)++;
3247 else
3248 aStatusNbDMap.Bind(aStatus,1);
3249 continue;
3250 }
3251 }
3252
3253 // fix 2d
3254 if (aWireFix->FixGaps2d())
3255 nbFixed++;
3256 else
3257 {
3258 aStatus = getStatusGap(aWireFix, Standard_False);
3259 if (aStatus == ShapeExtend_OK)
3260 {
3261 if (wasOk)
3262 {
3263 nbOk++;
3264 continue;
3265 }
3266 else
3267 nbFixed++;
3268 }
3269 else
3270 {
3271 // keep 2d fail status
3272 Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL;
3273 if (aStatusNbDMap.IsBound (aStatus2d))
3274 aStatusNbDMap(aStatus2d)++;
3275 else
3276 aStatusNbDMap.Bind(aStatus2d,1);
3277 continue;
3278 }
3279 }
3280 }
3281 }
3282//End: STEP 7
3283 } catch (EXCEPTION) {
3284 di << "Exception is raised = " <<aStatus << "\n";
3285 return 1;
3286
3287 }
3288// report what is done
3289
3290 if (nbFixed)
3291 {
3292 di <<"Fix_FillGaps_Fixed: nbFixed = "<<nbFixed <<"\n";
3293
3294 }
3295 if (nbOk)
3296 {
586db386 3297 di << "Fix_FillGaps_NothingToDo\n";
2bfe59b6 3298
3299 }
3300 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aStatusItr(aStatusNbDMap);
3301 for (; aStatusItr.More(); aStatusItr.Next())
3302 {
3303 switch ((ShapeExtend_Status) aStatusItr.Key())
3304 {
3305 // treat 3d status
3306 case ShapeExtend_FAIL1:
3307 di <<"Fix_FillGaps_3dNoCurveFail, nb failed = ";
3308 break;
3309 case ShapeExtend_FAIL2:
3310 di <<"Fix_FillGaps_3dSomeGapsFail, nb failed = ";
3311 break;
3312 default:
3313 // treat 2d status
3314 switch ((ShapeExtend_Status) (aStatusItr.Key() - ShapeExtend_FAIL))
3315 {
3316 case ShapeExtend_FAIL1:
3317 di <<"Fix_FillGaps_2dNoPCurveFail, nb failed = ";
3318 break;
3319 case ShapeExtend_FAIL2:
3320 di <<"Fix_FillGaps_2dSomeGapsFail, nb failed = ";
3321 break;
3322 default:
3323 break;
3324 }
3325 }
3326 di <<aStatusItr.Value()<< "\n";
3327 }
3328 di << ("__________________________________") <<"\n";
3329
3330 return 0;
3331}
3332
c070aa39 3333//=======================================================================
3334//function : OCC26172
3335//purpose :
3336//=======================================================================
3337static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3338{
3339 if (theArgNb != 1)
3340 {
3341 std::cerr << "Error: wrong number of arguments! See usage:\n";
3342 theDI.PrintHelp (theArgVec[0]);
3343 return 1;
3344 }
3345
3346 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
3347 if(anAISContext.IsNull())
3348 {
3349 std::cerr << "Error: no active view. Please call vinit.\n";
3350 return 1;
3351 }
3352
3353 gp_Pnt aStart (100, 100, 100);
3354 gp_Pnt anEnd (300, 400, 600);
3355 BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
3356 TopoDS_Edge anEdge = anEdgeBuilder.Edge();
3357 Handle(AIS_Shape) aTestAISShape = new AIS_Shape (anEdge);
3358 anAISContext->Display (aTestAISShape);
3359
3360 // 2. activate it in selection modes
3361 TColStd_SequenceOfInteger aModes;
3362 aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX));
3363 aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_EDGE));
3364
3365 anAISContext->OpenLocalContext();
3366 anAISContext->Deactivate (aTestAISShape);
3367 anAISContext->Load (aTestAISShape, -1, true);
3368 for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt)
3369 {
3370 anAISContext->Activate (aTestAISShape, aModes (anIt));
3371 }
3372
3373 // select entities in vertex selection mode
3374 Handle(SelectMgr_Selection) aSelection = aTestAISShape->Selection (aModes (1));
3375 for (aSelection->Init(); aSelection->More(); aSelection->Next())
3376 {
3377 Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
3378 if (anEntity.IsNull())
3379 {
3380 continue;
3381 }
3382
3383 Handle(SelectMgr_EntityOwner) anOwner =
3384 Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
3385
3386 if (anOwner.IsNull())
3387 {
3388 continue;
3389 }
3390
3391 anAISContext->LocalContext()->AddOrRemoveSelected (anOwner);
3392 }
3393
3394 // select entities in edge selection mode
3395 aSelection = aTestAISShape->Selection (aModes (2));
3396 for (aSelection->Init(); aSelection->More(); aSelection->Next())
3397 {
3398 Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
3399 if (anEntity.IsNull())
3400 {
3401 continue;
3402 }
3403
3404 Handle(SelectMgr_EntityOwner) anOwner =
3405 Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
3406
3407 if (anOwner.IsNull())
3408 {
3409 continue;
3410 }
3411
3412 anAISContext->LocalContext()->AddOrRemoveSelected (anOwner);
3413 }
3414
3415 // deactivate vertex mode and check clearing of outdated selection
3416 anAISContext->Deactivate (aTestAISShape, aModes (1));
3417 anAISContext->LocalContext()->ClearOutdatedSelection (aTestAISShape, true);
3418
3419 return 0;
3420}
3421
e11850fd 3422//=======================================================================
3423//function : OCC26284
3424//purpose :
3425//=======================================================================
3426static Standard_Integer OCC26284 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3427{
3428 if (theArgNb != 1)
3429 {
3430 std::cerr << "Error: wrong number of arguments! See usage:\n";
3431 theDI.PrintHelp (theArgVec[0]);
3432 return 1;
3433 }
3434
3435 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
3436 if (anAISContext.IsNull())
3437 {
3438 std::cerr << "Error: no active view. Please call vinit.\n";
3439 return 1;
3440 }
3441
3442 BRepPrimAPI_MakeSphere aSphereBuilder (gp_Pnt (0.0, 0.0, 0.0), 1.0);
3443 Handle(AIS_Shape) aSphere = new AIS_Shape (aSphereBuilder.Shape());
3444 anAISContext->Display (aSphere);
3445 for (Standard_Integer aChildIdx = 0; aChildIdx < 5; ++aChildIdx)
3446 {
3447 BRepPrimAPI_MakeSphere aBuilder (gp_Pnt (1.0 + aChildIdx, 1.0 + aChildIdx, 1.0 + aChildIdx), 1.0);
3448 Handle(AIS_Shape) aChild = new AIS_Shape (aBuilder.Shape());
3449 aSphere->AddChild (aChild);
3450 anAISContext->Display (aChild);
3451 }
3452
3453 anAISContext->RecomputeSelectionOnly (aSphere);
3454
3455 return 0;
3456}
3457
9bf3177f 3458#include <IntTools_Context.hxx>
3459#include <GeomAPI_ProjectPointOnSurf.hxx>
3460
3461//=======================================================================
3462//function : xprojponf
3463//purpose :
3464//=======================================================================
3465Standard_Integer xprojponf (Draw_Interpretor& di,
3466 Standard_Integer n,
3467 const char** a)
3468{
3469 if (n!=3) {
3470 di<<" use xprojponf p f \n";
3471 return 0;
3472 }
3473 //
3474 gp_Pnt aP, aPS;
3475 TopoDS_Shape aS;
3476 TopoDS_Face aF;
3477 Handle(IntTools_Context) aCtx;
3478 //
3479 DrawTrSurf::GetPoint(a[1], aP);
3480 aS=DBRep::Get(a[2]);
3481 //
3482 if (aS.IsNull()) {
3483 di<<" null shape is not allowed\n";
3484 return 0;
3485 }
3486 //
3487 if (aS.ShapeType()!=TopAbs_FACE) {
3488 di << a[2] << " not a face\n";
3489 return 0;
3490 }
3491 //
3492 aCtx=new IntTools_Context;
3493 //
3494 aF=TopoDS::Face(aS);
3495 GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF);
3496 //
3497 aPPS.Perform(aP);
3498 if (!aPPS.IsDone()) {
3499 di<<" projection failed\n";
3500 return 0;
3501 }
3502 //
3503 aPS=aPPS.NearestPoint();
3504 di<< " point px " << aPS.X() << " " << aPS.Y() << " " << aPS.Z() << "\n";
3505 //
3506 return 0;
3507}
3508
ec26bf88 3509//=======================================================================
3510//function : OCC25547
3511//purpose :
3512//=======================================================================
3513#include <BRepMesh_CircleTool.hxx>
ec357c5c 3514#include <SelectMgr_EntityOwner.hxx>
ec26bf88 3515
3516static Standard_Boolean inspect_point(const gp_XY& thePoint,
3517 const gp_XY& theCenter,
3518 const Standard_Real theRadius)
3519{
3520 static Standard_Real aPrecision = Precision::PConfusion();
3521 static Standard_Real aSqPrecision = aPrecision * aPrecision;
3522 const gp_XY aDistVec = thePoint - theCenter;
3523 if (aDistVec.SquareModulus() - (theRadius * theRadius) < aSqPrecision)
3524 return Standard_True;
3525 else
3526 return Standard_False;
3527}
3528
3529static Standard_Integer OCC24923(
3530 Draw_Interpretor& theDI,
3531 Standard_Integer argc,
3532 const char ** argv)
3533{
3534 srand(static_cast<unsigned int>(time(NULL)));
3535
3536 const Standard_Real aMaxDeviation = (argc > 1) ? Draw::Atof(argv[1]) : 0.01;
3537 const Standard_Integer aPointsNb = 10000000;
3538 const Standard_Real aMinAngle = 5 * M_PI / 180.;
3539 static Standard_Real aSqPrecision = Precision::PConfusion() * Precision::PConfusion();
3540
3541 Standard_Integer aFailedNb = 0;
3542 for (Standard_Integer i = 0; i < aPointsNb; ++i)
3543 {
3544 gp_XY p[3];
3545 for (Standard_Integer j = 0; j < 3; ++j)
3546 p[j].SetCoord(((Standard_Real)rand())/RAND_MAX, ((Standard_Real)rand())/RAND_MAX);
3547
3548 // Check that points do not compose degenerated triangle.
3549 gp_XY aVec1 = p[1] - p[0];
3550 gp_XY aVec2 = p[2] - p[0];
3551 if (aVec1.SquareModulus() > aSqPrecision &&
3552 aVec2.SquareModulus() > aSqPrecision &&
3553 (aVec1 ^ aVec2) > aMinAngle)
3554 {
3555 gp_XY aCenter;
3556 Standard_Real aRadius;
3557 if (BRepMesh_CircleTool::MakeCircle(p[0], p[1], p[2], aCenter, aRadius))
3558 {
3559 if (!inspect_point(p[0], aCenter, aRadius) ||
3560 !inspect_point(p[1], aCenter, aRadius) ||
3561 !inspect_point(p[2], aCenter, aRadius))
3562 {
3563 /* theDI << "Missed: " <<
3564 "p1=(" << p1.X() << ", " << p1.Y() << "), " <<
3565 "p2=(" << p2.X() << ", " << p2.Y() << "), " <<
3566 "p3=(" << p3.X() << ", " << p3.Y() << "), " <<
3567 "c=(" << aCenter.X() << ", " << aCenter.Y() << "), " <<
3568 "r=" << aRadius << "\n";*/
3569
3570 ++aFailedNb;
3571 }
3572
3573 continue;
3574 }
3575 }
3576
3577 // Ensure that aPointsNb suitable for tests are generated
3578 --i;
3579 }
3580
3581 const Standard_Real aDeviation =
3582 1. - (Standard_Real)(aPointsNb - aFailedNb) / (Standard_Real)aPointsNb;
3583
3584 theDI << "Number of failed cases: " << aFailedNb << " (Total " << aPointsNb << ")\n";
3585 if (aDeviation > aMaxDeviation)
3586 {
3587 theDI << "Failed. Number of incorrect results is too huge: " <<
586db386 3588 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
ec26bf88 3589 return 1;
3590 }
3591
3592 theDI << "Deviation of incorrect results is: " <<
586db386 3593 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
ec26bf88 3594 theDI << "Test completed\n";
3595 return 0;
3596}
3597
4f5ad416 3598//=======================================================================
3599//function : OCC25574
3600//purpose : check implementation of Euler angles in gp_Quaternion
3601//=======================================================================
3602
3603static Standard_Integer OCC25574 (Draw_Interpretor& theDI, Standard_Integer /*argc*/, const char** /*argv*/)
3604{
3605 Standard_Boolean isTestOk = Standard_True;
3606
3607 // Check consistency of Get and Set operations for Euler angles
3608 gp_Quaternion aQuat;
3609 aQuat.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637);
3610 Standard_Real alpha,beta,gamma;
3611 gp_Mat aRinv = aQuat.GetMatrix().Inverted();
3612 gp_Mat aI;
3613 aI.SetIdentity();
3614 const char* names[] = { "Extrinsic_XYZ", "Extrinsic_XZY", "Extrinsic_YZX", "Extrinsic_YXZ", "Extrinsic_ZXY", "Extrinsic_ZYX",
3615 "Intrinsic_XYZ", "Intrinsic_XZY", "Intrinsic_YZX", "Intrinsic_YXZ", "Intrinsic_ZXY", "Intrinsic_ZYX",
3616 "Extrinsic_XYX", "Extrinsic_XZX", "Extrinsic_YZY", "Extrinsic_YXY", "Extrinsic_ZYZ", "Extrinsic_ZXZ",
3617 "Intrinsic_XYX", "Intrinsic_XZX", "Intrinsic_YZY", "Intrinsic_YXY", "Intrinsic_ZXZ", "Intrinsic_ZYZ" };
3618 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3619 {
3620 aQuat.GetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma);
3621
3622 gp_Quaternion aQuat2;
3623 aQuat2.SetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma);
3624
3625 gp_Mat aR = aQuat2.GetMatrix();
3626 gp_Mat aDiff = aR * aRinv - aI;
3627 if (aDiff.Determinant() > 1e-5)
3628 {
3629 theDI << "Error: Euler angles conversion incorrect for sequence " << names[i - gp_Extrinsic_XYZ] << "\n";
3630 isTestOk = Standard_False;
3631 }
3632 }
3633
3634 // Check conversion between intrinsic and extrinsic rotations
3635 // Any extrinsic rotation is equivalent to an intrinsic rotation
3636 // by the same angles but with inverted order of elemental rotations, and vice versa
3637 // For instance:
3638 // Extrinsic_XZY = Incrinsic_XZY
3639 // R = X(A)Z(B)Y(G) --> R = Y(G)Z(B)X(A)
3640 alpha = 0.1517461713131;
3641 beta = 1.5162198410141;
3642 gamma = 1.9313156236541;
3643 Standard_Real alpha2, beta2, gamma2;
3644 gp_EulerSequence pairs[][2] = { {gp_Extrinsic_XYZ, gp_Intrinsic_ZYX},
3645 {gp_Extrinsic_XZY, gp_Intrinsic_YZX},
3646 {gp_Extrinsic_YZX, gp_Intrinsic_XZY},
3647 {gp_Extrinsic_YXZ, gp_Intrinsic_ZXY},
3648 {gp_Extrinsic_ZXY, gp_Intrinsic_YXZ},
3649 {gp_Extrinsic_ZYX, gp_Intrinsic_XYZ} };
3650 for (int i = 0; i < 6; i++)
3651 {
3652 aQuat.SetEulerAngles(pairs[i][0], alpha, beta, gamma);
3653 aQuat.GetEulerAngles(pairs[i][1], gamma2, beta2, alpha2);
3654
3655 if (Abs(alpha - alpha2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - gamma2) > 1e-5)
3656 {
3657 theDI << "Error: intrinsic and extrinsic conversion incorrect for sequence " << names[i] << "\n";
3658 isTestOk = Standard_False;
3659 }
3660 }
3661
3662 // Check correspondence of enumeration and actual rotation it defines,
3663 // by rotation by one axis and checking that it does not change a point on that axis
3664 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3665 {
3666 // Iterate over rotations R(A)R(B)R(G) for each Euler angle Alpha, Beta, Gamma
3667 // There are three ordered axes corresponding to three rotations.
3668 // Each rotation applyed with current angle around current axis.
3669 for (int j=0; j < 3; j++)
3670 {
3671 // note that current axis index is obtained by parsing of enumeration name!
3672 int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X';
3673 Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1);
3674
3675 // Set 90 degrees to current Euler angle
3676 double anAngles[3] = {0., 0., 0.};
3677 anAngles[j] = 0.5 * M_PI;
3678
3679 gp_Quaternion q2;
3680 q2.SetEulerAngles (gp_EulerSequence(i), anAngles[0], anAngles[1], anAngles[2]);
3681
3682 // Set point on axis corresponding to current rotation
3683 // We will apply rotation around this axis
3684 gp_XYZ v (0., 0., 0.);
3685 v.SetCoord (anAxis + 1, 1.);
3686
3687 // Apply rotation to point
3688 gp_Trsf aT;
3689 aT.SetRotation (q2);
3690 gp_XYZ v2 = v;
3691 aT.Transforms (v2);
3692
3693 // Check that point is still on origin position
3694 if ((v - v2).SquareModulus() > Precision::SquareConfusion())
3695 {
3696 // avoid reporting small coordinates
3697 for (int k=1; k <= 3; k++)
3698 if (Abs (v2.Coord(k)) < Precision::Confusion())
3699 v2.SetCoord (k, 0.);
3700
3701 isTestOk = Standard_False;
3702 theDI << "Error: Euler sequence " << names[i - gp_Extrinsic_XYZ] << " is incorrect:\n";
3703 theDI << "rotating by angle 90 deg around " << (anAxis == 0 ? "X" : anAxis == 1 ? "Y" : "Z") <<
3704 " converts vector (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") to ("
3705 << v2.X() << ", " << v2.Y() << ", " << v2.Z() << ")\n";
3706 }
3707 }
3708 }
3709
3710 // Check correspondence of enumeration and actual rotation it defines,
3711 // by comparing cumulative rotation matrix with sequence of rotations by axes
3712 const Standard_Real anAngle[3] = { 0.1, 0.2, 0.3 };
3713 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3714 {
3715 // Sequence of rotations
3716 gp_Mat aR[3];
3717 for (int j=0; j < 3; j++)
3718 {
3719 // note that current axis index is obtained by parsing of enumeration name!
3720 int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X';
3721 Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1);
3722
3723 // Set point on axis corresponding to current rotation
3724 // We will apply rotation around this axis
3725 gp_XYZ v (0., 0., 0.);
3726 v.SetCoord (anAxis + 1, 1.);
3727 aR[j].SetRotation (v, anAngle[j]);
3728 }
3729
3730 // construct cumulative transformation (differently for extrinsic and intrinsic rotations);
3731 // note that we parse first symbol of the enum name to identify its type
3732 gp_Mat aRot;
3733 if (names[i - gp_Extrinsic_XYZ][0] == 'E') // extrinsic
3734 {
3735 aRot = aR[2] * aR[1] * aR[0];
3736 }
3737 else // intrinsic
3738 {
3739 aRot = aR[0] * aR[1] * aR[2];
3740 }
3741
3742 // set the same angles in quaternion
4f5ad416 3743 aQuat.SetEulerAngles (gp_EulerSequence(i), anAngle[0], anAngle[1], anAngle[2]);
3744
3745 gp_Mat aRQ = aQuat.GetMatrix();
3746 gp_Mat aDiff = aRQ * aRot.Inverted() - aI;
3747 if (aDiff.Determinant() > 1e-5)
3748 {
3749 theDI << "Error: Euler angles conversion does not correspond to sequential rotations for " << names[i - gp_Extrinsic_XYZ] << "\n";
3750 isTestOk = Standard_False;
3751 }
3752 }
3753
3754 // similar checkfor YawPitchRoll sequence as defined in description of #25574
3755 {
3756 // Start with world coordinate system
3757 gp_Ax2 world;
3758
3759 // Perform three rotations using the yaw-pitch-roll convention.
3760 // This means: rotate around the original z axis with angle alpha,
3761 // then rotate around the new y axis with angle beta,
3762 // then rotate around the new x axis with angle gamma.
3763 alpha = 0.0 / 180.0 * M_PI;
3764 beta = -35.0 / 180.0 * M_PI;
3765 gamma = 90.0 / 180.0 * M_PI;
3766
3767 const gp_Quaternion rotationZ(world.Direction(), alpha);
3768 const gp_Vec rotY = rotationZ.Multiply(world.YDirection());
3769 const gp_Vec rotX = rotationZ.Multiply(world.XDirection());
3770
3771 const gp_Quaternion rotationY(rotY, beta);
3772 const gp_Vec rotZ = rotationY.Multiply(world.Direction());
3773 const gp_Vec rotRotX = rotationY.Multiply(rotX);
3774
3775 const gp_Quaternion rotationX(rotRotX, gamma);
3776 const gp_Vec rotRotZ = rotationX.Multiply(rotZ);
3777
3778 gp_Ax2 result(gp_Pnt(0.0, 0.0, 0.0), rotRotZ, rotRotX);
3779
3780 // Now compute the Euler angles
3781 gp_Trsf transformation;
3782 transformation.SetDisplacement(gp_Ax2(), result);
3783
3784 Standard_Real computedAlpha;
3785 Standard_Real computedBeta;
3786 Standard_Real computedGamma;
3787
3788 transformation.GetRotation().GetEulerAngles(gp_YawPitchRoll, computedAlpha, computedBeta, computedGamma);
3789
3790 // We expect now to get the same angles as we have used for our rotations
3791 if (Abs(alpha - computedAlpha) > 1e-5 || Abs(beta - computedBeta) > 1e-5 || Abs(gamma - computedGamma) > 1e-5)
3792 {
3793 theDI << "Error: unexpected values of Euler angles for YawPitchRoll sequence:\n";
3794 theDI << "alpha: " << alpha / M_PI * 180.0 << " and computed alpha: "
3795 << computedAlpha / M_PI * 180.0 << "\n";
3796 theDI << "beta: " << beta / M_PI * 180.0 << " and computed beta: "
3797 << computedBeta / M_PI * 180.0 << "\n";
3798 theDI << "gamma: " << gamma / M_PI * 180.0 << " and computed gamma: "
3799 << computedGamma / M_PI * 180.0 << "\n";
3800 isTestOk = Standard_False;
3801 }
3802 }
3803
3804 // test from #25946
3805 {
3806 gp_Quaternion q;
3807 q.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637);
3808
3809 q.GetEulerAngles(gp_Intrinsic_ZYX, alpha,beta, gamma);
4f5ad416 3810 q.GetEulerAngles(gp_Extrinsic_XYZ, alpha2,beta2,gamma2);
3811
3812 // gp_Intrinsic_ZYX and gp_Extrinsic_XYZ should produce the same values of angles but in opposite order
3813 if (Abs(alpha - gamma2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - alpha2) > 1e-5)
3814 {
3815 theDI << "Error: Euler angles computed for gp_Intrinsic_ZYX and gp_Extrinsic_XYZ do not match:\n";
3816 theDI << "alpha: " << alpha / M_PI * 180.0 << " and " << alpha2 / M_PI * 180.0 << "\n";
3817 theDI << "beta: " << beta / M_PI * 180.0 << " and " << beta2 / M_PI * 180.0 << "\n";
3818 theDI << "gamma: " << gamma / M_PI * 180.0 << " and " << gamma2 / M_PI * 180.0 << "\n";
3819 isTestOk = Standard_False;
3820 }
3821 }
3822
3823 theDI << (isTestOk ? "Test completed" : "Test failed") << "\n";
3824 return 0;
3825}
3826
3ceb4c3c 3827#include <TColGeom_Array1OfBSplineCurve.hxx>
3828#include <TColStd_Array1OfReal.hxx>
3829#include <TColGeom_HArray1OfBSplineCurve.hxx>
3830#include <GeomConvert.hxx>
3831
3832//=======================================================================
3833//function : OCC26446
3834//purpose :
3835//=======================================================================
3836Standard_Integer OCC26446 (Draw_Interpretor& di,
3837 Standard_Integer n,
3838 const char** a)
3839{
3840 if (n != 4) {
586db386 3841 di << "Usage: OCC26446 r c1 c2\n";
3ceb4c3c 3842 return 1;
3843 }
3844
3845 Handle(Geom_BSplineCurve) aCurve1 =
3846 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[2]));
3847 Handle(Geom_BSplineCurve) aCurve2 =
3848 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[3]));
3849
3850 if (aCurve1.IsNull()) {
586db386 3851 di << a[2] << " is not a BSpline curve\n";
3ceb4c3c 3852 return 1;
3853 }
3854
3855 if (aCurve2.IsNull()) {
586db386 3856 di << a[3] << " is not a BSpline curve\n";
3ceb4c3c 3857 return 1;
3858 }
3859
3860 TColGeom_Array1OfBSplineCurve aCurves (0, 1);
3861 TColStd_Array1OfReal aTolerances (0, 0);
3862 Standard_Real aTolConf = 1.e-3;
3863 Standard_Real aTolClosure = Precision::Confusion();
3864 Handle(TColGeom_HArray1OfBSplineCurve) aConcatCurves;
3865 Handle(TColStd_HArray1OfInteger) anIndices;
3866
3867 aCurves.SetValue(0, aCurve1);
3868 aCurves.SetValue(1, aCurve2);
3869 aTolerances.SetValue(0, aTolConf);
3870
3871 GeomConvert::ConcatC1(aCurves,
3872 aTolerances,
3873 anIndices,
3874 aConcatCurves,
3875 Standard_False,
3876 aTolClosure);
3877
3878 Handle(Geom_BSplineCurve) aResult =
3879 aConcatCurves->Value(aConcatCurves->Lower());
3880
3881 DrawTrSurf::Set(a[1], aResult);
3882 return 0;
3883}
3884
fac9298e 3885static Standard_Integer OCC26448 (Draw_Interpretor& theDI, Standard_Integer, const char **)
3886{
3887 TColStd_SequenceOfReal aSeq1, aSeq2;
3888 aSeq1.Append(11.);
3889 aSeq1.Prepend (aSeq2);
3890 theDI << "TCollection: 11 -> " << aSeq1.First() << "\n";
3891
3892 NCollection_Sequence<Standard_Real> nSeq1, nSeq2;
3893 nSeq1.Append(11.);
3894 nSeq1.Prepend (nSeq2);
3895 theDI << "NCollection: 11 -> " << nSeq1.First() << "\n";