0027466: The algorithm Extrema_GenLocateExtPS gives incorrect result
[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
e5260e1d 1367#include <Extrema_FuncPSNorm.hxx>
89d8607f 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
e5260e1d 1404 Extrema_FuncPSNorm anExtFunc;
89d8607f 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
0c674248 1752//=======================================================================
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
f376ac72 1793//=======================================================================
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
a967f104 2371//=======================================================================
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
4a350f94 2434//=======================================================================
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
e4b5c45a 2462//=======================================================================
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";
3896
3897 theDI << "OK";
3898 return 0;
3899}
3900
71316196 3901//=======================================================================
3902//function : OCC26407
3903//purpose :
3904//=======================================================================
3905#include <BRepBuilderAPI_MakeWire.hxx>
3906#include <BRepBuilderAPI_MakeEdge.hxx>
3907#include <BRepMesh_IncrementalMesh.hxx>
3908#include <TCollection_AsciiString.hxx>
3909static Standard_Integer OCC26407 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3910{
3911 if (theArgNb != 2)
3912 {
3913 std::cerr << "Error: wrong number of arguments! See usage:\n";
3914 theDI.PrintHelp (theArgVec[0]);
3915 return 1;
3916 }
3917
3918 // Construct vertices.
3919 std::vector<TopoDS_Vertex> wire_vertices;
3920 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.90000000000009094947, 40.6758179230516248026106, 88.5)));
3921 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(807.824182076948432040808, 260.599999999999965893949, 88.5)));
3922 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(644.174182076948454778176, 424.249999999999943156581, 88.5000000000000142108547)));
3923 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(629.978025792618950617907, 424.25, 88.5)));
3924 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(793.628025792618700506864, 260.599999999999852207111, 88.5)));
3925 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.900000000000204636308, 54.8719742073813492311274, 88.5)));
3926 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(218.521974207381418864315, 424.250000000000056843419, 88.5)));
3927 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(204.325817923051886282337, 424.249999999999943156581, 88.5)));
3928
3929 // Construct wire.
3930 BRepBuilderAPI_MakeWire wire_builder;
3931 for (size_t i = 0; i < wire_vertices.size(); i++)
3932 {
3933 const TopoDS_Vertex &v = wire_vertices[i];
3934 const TopoDS_Vertex &w = wire_vertices[(i+1) % wire_vertices.size()];
3935
3936 wire_builder.Add(BRepBuilderAPI_MakeEdge(v, w));
3937 }
3938
3939 // Create face and triangulate it.
3940 // Construct face.
3941 gp_Pnt v0 = BRep_Tool::Pnt(wire_vertices[0]);
3942 gp_Pnt v1 = BRep_Tool::Pnt(wire_vertices[1]);
3943 gp_Pnt v2 = BRep_Tool::Pnt(wire_vertices[wire_vertices.size() - 1]);
3944
3945 gp_Vec face_normal = gp_Vec(v0, v1).Crossed(gp_Vec(v0, v2));
3946
3947 TopoDS_Face face = BRepBuilderAPI_MakeFace(gp_Pln(v0, face_normal), wire_builder);
3948 BRepMesh_IncrementalMesh m(face, 1e-7);
3949
3950 if (m.GetStatusFlags() != 0)
3951 {
3952 theDI << "Failed. Status for face constructed from vertices: " << m.GetStatusFlags() << "\n";
3953 return 1;
3954 }
3955 DBRep::Set(theArgVec[1], face);
3956 char buf[256];
3957 sprintf(buf, "isos %s 0", theArgVec[1]);
3958 theDI.Eval(buf);
3959
3960 sprintf(buf, "triangles %s", theArgVec[1]);
3961 theDI.Eval(buf);
3962
3963 theDI.Eval("smallview; fit");
3964
3965 theDI << "Test completed\n";
3966 return 0;
3967}
3968
db6c6404 3969//=======================================================================
3970//function : OCC26485
3971//purpose :
3972//=======================================================================
3973#include <Poly.hxx>
3974static Standard_Integer OCC26485 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3975{
3976 if (theArgNb != 2)
3977 {
3978 std::cerr << "Error: wrong number of arguments! See usage:\n";
3979 theDI.PrintHelp (theArgVec[0]);
3980 return 1;
3981 }
3982
3983 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
3984 if (aShape.IsNull())
3985 {
3986 theDI << "Failed. Null shape\n";
3987 return 1;
3988 }
3989
3990 Standard_Boolean isFailed = Standard_False;
3991 TopExp_Explorer aExplorer(aShape, TopAbs_FACE);
3992 for (; aExplorer.More(); aExplorer.Next())
3993 {
3994 const TopoDS_Face& aFace = TopoDS::Face( aExplorer.Current() );
3995 TopLoc_Location L = TopLoc_Location();
3996 const Handle(Poly_Triangulation)& aT = BRep_Tool::Triangulation( aFace , L );
3997
3998 if(aT.IsNull())
3999 continue;
4000
4001 Poly::ComputeNormals(aT);
4002 const TColgp_Array1OfPnt& aVertices = aT->Nodes();
4003 const TShort_Array1OfShortReal& aNormals = aT->Normals();
4004
4005 // Number of nodes in the triangulation
4006 int aVertexNb = aT->Nodes().Length();
4007 if (aVertexNb*3 != aNormals.Length())
4008 {
4009 theDI << "Failed. Different number of normals vs. vertices\n";
4010 return 1;
4011 }
4012
4013 // Get each vertex index, checking common vertexes between shapes
4014 for( int i=0; i < aVertexNb; i++ )
4015 {
4016 gp_Pnt aPoint = aVertices.Value( i+1 );
4017 gp_Vec aNormal = gp_Vec(
4018 aNormals.Value( i*3 + 1 ),
4019 aNormals.Value( i*3 + 2 ),
4020 aNormals.Value( i*3 + 3 ) );
4021
4022 if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
4023 {
4024 char buf[256];
4025 sprintf(buf, "fail_%d", i+1);
4026 theDI << "Failed. Point " << buf << ": "
4027 << aPoint.X() << " "
4028 << aPoint.Y() << " "
4029 << aPoint.Z() << "\n";
4030
4031 DrawTrSurf::Set (buf, aPoint);
4032 }
4033 }
4034 }
4035
4036 theDI << (isFailed ? "Test failed" : "Test completed") << "\n";
4037 return 0;
4038}
4039
5a8dc41a 4040//=======================================================================
4041//function : OCC26553
4042//purpose :
4043//=======================================================================
4044#include <BRepBuilderAPI_MakeWire.hxx>
4045
4046static Standard_Integer OCC26553 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4047{
4048 if (theArgc < 2)
4049 {
4050 theDI << "Error: path to file with shell is missing\n";
4051 return 1;
4052 }
4053
4054 BRep_Builder aBuilder;
4055 TopoDS_Shape aShell;
4056 BRepTools::Read(aShell, theArgv[1], aBuilder);
4057
4058 if (aShell.IsNull())
4059 {
4060 theDI << "Error: shell not loaded\n";
4061 return 1;
4062 }
4063
4064 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge (gp_Pnt (0, 0, 0), gp_Pnt (0, 0, 10));
4065 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
4066
4067 BRepOffsetAPI_MakePipe aPipeBuilder(aPipeWire, aShell);
4068 if (!aPipeBuilder.IsDone())
4069 {
4070 theDI << "Error: failed to create pipe\n";
4071 return 1;
4072 }
4073
4074 for (TopExp_Explorer aShapeExplorer(aShell, TopAbs_EDGE); aShapeExplorer.More(); aShapeExplorer.Next ()) {
4075 const TopoDS_Shape& aGeneratedShape = aPipeBuilder.Generated(aPipeEdge, aShapeExplorer.Current());
4076 if (aGeneratedShape.IsNull())
4077 {
4078 theDI << "Error: null shape\n";
4079 return 1;
4080 }
4081 }
4082
4083 theDI << "History returned successfully\n";
4084 return 0;
4085}
4086
3bf9a45f 4087//=======================================================================
4088//function : OCC26195
4089//purpose :
4090//=======================================================================
4091#include <SelectMgr_SelectingVolumeManager.hxx>
4092#include <BRepBuilderAPI_MakePolygon.hxx>
4093#include <Geom_CartesianPoint.hxx>
4094#include <AIS_Line.hxx>
4095#include <Aspect_Window.hxx>
4096static Standard_Integer OCC26195 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
4097{
4098 if (theArgNb < 3)
4099 {
4100 std::cerr << "Error: wrong number of arguments! See usage:\n";
4101 theDI.PrintHelp (theArgVec[0]);
4102 return 1;
4103 }
4104
4105 if (ViewerTest::GetAISContext().IsNull())
4106 {
4107 std::cerr << "Error: No opened context!\n";
4108 return 1;
4109 }
4110
4111 gp_Pnt2d aPxPnt1, aPxPnt2;
4112 aPxPnt1.SetX (Draw::Atof (theArgVec[1]));
4113 aPxPnt1.SetY (Draw::Atof (theArgVec[2]));
4114 if (theArgNb > 4)
4115 {
4116 aPxPnt2.SetX (Draw::Atof (theArgVec[3]));
4117 aPxPnt2.SetY (Draw::Atof (theArgVec[4]));
4118 }
4119 Standard_Boolean toPrint = Standard_False;
4120 if (theArgNb % 2 == 0)
4121 {
4122 toPrint = Draw::Atoi (theArgVec[theArgNb - 1]);
4123 }
4124
4125 SelectMgr_SelectingVolumeManager* aMgr = new SelectMgr_SelectingVolumeManager();
4126 aMgr->SetActiveSelectionType (theArgNb > 4 ?
4127 SelectMgr_SelectingVolumeManager::Box : SelectMgr_SelectingVolumeManager::Point);
4128 aMgr->SetCamera (ViewerTest::CurrentView()->Camera());
4129 aMgr->SetPixelTolerance (ViewerTest::GetAISContext()->PixelTolerance());
4130 Standard_Integer aWidth, aHeight;
4131 ViewerTest::CurrentView()->View()->Window()->Size (aWidth, aHeight);
4132 aMgr->SetWindowSize (aWidth, aHeight);
4133 if (theArgNb > 4)
4134 {
4135 aMgr->BuildSelectingVolume (aPxPnt1, aPxPnt2);
4136 }
4137 else
4138 {
4139 aMgr->BuildSelectingVolume (aPxPnt1);
4140 }
4141 const gp_Pnt* aVerts = aMgr->GetVertices();
4142 gp_Pnt aNearPnt = aMgr->GetNearPnt();
4143 gp_Pnt aFarPnt = aMgr->GetFarPnt();
4144 BRepBuilderAPI_MakePolygon aWireBldrs[4];
4145
4146 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4147 aWireBldrs[0].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
4148 aWireBldrs[0].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
4149 aWireBldrs[0].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
4150 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4151
4152 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
4153 aWireBldrs[1].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
4154 aWireBldrs[1].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
4155 aWireBldrs[1].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
4156 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
4157
4158 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
4159 aWireBldrs[2].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
4160 aWireBldrs[2].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
4161 aWireBldrs[2].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
4162 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
4163
4164 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4165 aWireBldrs[3].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
4166 aWireBldrs[3].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
4167 aWireBldrs[3].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
4168 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4169
4170 TopoDS_Compound aComp;
4171 BRep_Builder aCompBuilder;
4172 aCompBuilder.MakeCompound (aComp);
4173 for (Standard_Integer aWireIdx = 0; aWireIdx < 4; ++aWireIdx)
4174 {
4175 aCompBuilder.Add (aComp, aWireBldrs[aWireIdx].Shape());
4176 }
4177 DBRep::Set ("c", aComp);
4178
4179 Handle(AIS_InteractiveObject) aCmp = new AIS_Shape (aComp);
4180 aCmp->SetColor (Quantity_NOC_GREEN);
4181 ViewerTest::Display ("c", aCmp, Standard_True, Standard_True);
4182
4183 Handle(Geom_CartesianPoint) aPnt1 = new Geom_CartesianPoint (aNearPnt);
4184 Handle(Geom_CartesianPoint) aPnt2 = new Geom_CartesianPoint (aFarPnt);
4185
4186 Handle(AIS_Line) aLine = new AIS_Line (aPnt1, aPnt2);
4187 ViewerTest::Display ("l", aLine, Standard_True, Standard_True);
4188
4189 if (toPrint)
4190 {
4191 theDI << "Near: " << aNearPnt.X() << " " << aNearPnt.Y() << " " << aNearPnt.Z() << "\n";
4192 theDI << "Far: " << aFarPnt.X() << " " << aFarPnt.Y() << " " << aFarPnt.Z() << "\n";
4193 }
4194
4195 return 0;
4196}
4197
8a1170ad 4198//=======================================================================
4199//function : OCC26462
4200//purpose :
4201//=======================================================================
4202static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
4203{
4204 if (ViewerTest::GetAISContext().IsNull())
4205 {
4206 std::cerr << "Error: No opened context!\n";
4207 return 1;
4208 }
4209
4210 BRepPrimAPI_MakeBox aBuilder1 (gp_Pnt (10.0, 10.0, 0.0), 10.0, 10.0, 10.0);
4211 BRepPrimAPI_MakeBox aBuilder2 (10.0, 10.0, 10.0);
4212 Handle(AIS_InteractiveObject) aBox1 = new AIS_Shape (aBuilder1.Shape());
4213 Handle(AIS_InteractiveObject) aBox2 = new AIS_Shape (aBuilder2.Shape());
4214
4215 const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
4216 aCtx->OpenLocalContext();
4217 aCtx->Display (aBox1, 0, 2);
4218 aCtx->Display (aBox2, 0, 2);
4219 ViewerTest::CurrentView()->FitAll();
4220 aCtx->SetWidth (aBox1, 3);
4221 aCtx->SetWidth (aBox2, 3);
4222
4223 aCtx->MoveTo (305, 322, ViewerTest::CurrentView());
4224 aCtx->ShiftSelect();
4225 aCtx->MoveTo (103, 322, ViewerTest::CurrentView());
4226 aCtx->ShiftSelect();
4227 if (aCtx->NbSelected() != 0)
4228 {
4229 theDI << "ERROR: no boxes must be selected!\n";
4230 return 1;
4231 }
4232
4233 aCtx->SetSelectionSensitivity (aBox1, 2, 5);
4234
4235 aCtx->MoveTo (305, 322, ViewerTest::CurrentView());
4236 aCtx->ShiftSelect();
4237 if (aCtx->NbSelected() != 1)
4238 {
4239 theDI << "ERROR: b1 was not selected\n";
4240 return 1;
4241 }
4242 aCtx->MoveTo (103, 322, ViewerTest::CurrentView());
4243 aCtx->ShiftSelect();
4244 if (aCtx->NbSelected() != 1)
4245 {
4246 theDI << "ERROR: b2 is selected after b1's tolerance increased\n";
4247 return 1;
4248 }
4249
4250 return 0;
4251}
4252
43940380 4253
4254#include <BRepBuilderAPI_GTransform.hxx>
4255static Standard_Integer OCC26313(Draw_Interpretor& di,Standard_Integer n,const char** a)
4256{
4257 if (n <= 1) return 1;
4258
4259 gp_Trsf T;
4260 gp_GTrsf GT(T);
4261
4262 gp_Mat rot( 1.0, 0.0, 0.0,
4263 0.0, 2.0, 0.0,
4264 0.0, 0.0, 3.0);
4265
4266 GT.SetVectorialPart(rot);
4267 BRepBuilderAPI_GTransform gtrf(GT);
4268
4269 TopoDS_Shape aSrcShape = DBRep::Get(a[2]);
4270 if (aSrcShape.IsNull()) {
586db386 4271 di << a[2] << " is not a valid shape\n";
43940380 4272 return 1;
4273 }
4274
4275
4276 gtrf.Perform(aSrcShape);
4277 if (gtrf.IsDone())
4278 {
4279 try
4280 {
4281 DBRep::Set(a[1], gtrf.ModifiedShape(aSrcShape));
4282 }
4283 catch(Standard_Failure)
4284 {
4285 di << "Error: Exception is thrown\n";
4286 }
4287 }
4288 else
4289 {
4290 di << "Error: Result is not done\n";
4291 return 1;
4292 }
4293
4294 return 0;
4295}
4296
81b47143 4297//=======================================================================
4298//function : OCC26525
4299//purpose : check number of intersection points
4300//=======================================================================
4301#include <BRepAdaptor_Curve.hxx>
4302#include <BRepAdaptor_Surface.hxx>
4303#include <BRepAdaptor_HCurve.hxx>
4304#include <BRepAdaptor_HSurface.hxx>
4305#include <IntCurveSurface_HInter.hxx>
4306Standard_Integer OCC26525 (Draw_Interpretor& di,
4307 Standard_Integer n,
4308 const char** a)
4309{
4310 TopoDS_Shape aS1, aS2;
4311 TopoDS_Edge aE;
4312 TopoDS_Face aF;
4313
4314 if (n<4)
4315 {
4316 di << " use OCC26525 r edge face \n";
4317 return 1;
4318 }
4319
4320 aS1 = DBRep::Get(a[2]);
4321 aS2 = DBRep::Get(a[3]);
4322
4323 if (aS1.IsNull() || aS2.IsNull())
4324 {
4325 di << " Null shapes are not allowed \n";
4326 return 0;
4327 }
4328 if (aS1.ShapeType()!=TopAbs_EDGE)
4329 {
4330 di << " Shape" << a[2] << " should be of type EDGE\n";
4331 return 0;
4332 }
4333 if (aS2.ShapeType()!=TopAbs_FACE)
4334 {
4335 di << " Shape" << a[3] << " should be of type FACE\n";
4336 return 0;
4337 }
4338
4339 aE=TopoDS::Edge(aS1);
4340 aF=TopoDS::Face(aS2);
4341
4342 char buf[128];
4343 Standard_Boolean bIsDone;
4344 Standard_Integer i, aNbPoints;
4345 Standard_Real aU, aV, aT;
4346 gp_Pnt aP;
4347 BRepAdaptor_Curve aBAC;
4348 BRepAdaptor_Surface aBAS;
4349 IntCurveSurface_TransitionOnCurve aTC;
4350 IntCurveSurface_HInter aHInter;
4351
4352 aBAC.Initialize(aE);
4353 aBAS.Initialize(aF);
4354
4355 Handle(BRepAdaptor_HCurve) aHBAC=new BRepAdaptor_HCurve(aBAC);
4356 Handle(BRepAdaptor_HSurface) aHBAS = new BRepAdaptor_HSurface(aBAS);
4357
4358 aHInter.Perform(aHBAC, aHBAS);
4359 bIsDone=aHInter.IsDone();
4360 if (!bIsDone)
4361 {
4362 di << " intersection is not done\n";
4363 return 0;
4364 }
4365
4366 aNbPoints=aHInter.NbPoints();
4367 sprintf (buf, " Number of intersection points found: %d", aNbPoints);
4368 di << buf << "\n";
4369 for (i=1; i<=aNbPoints; ++i)
4370 {
4371 const IntCurveSurface_IntersectionPoint& aIP=aHInter.Point(i);
4372 aIP.Values(aP, aU, aV, aT, aTC);
4373 //
4374 sprintf (buf, "point %s_%d %lg %lg %lg ", a[1], i, aP.X(), aP.Y(), aP.Z());
4375 di << buf << "\n";
4376 }
4377
4378 return 0;
4379}
4380
10a4116e 4381//=======================================================================
4382//function : OCC24537
4383//purpose : Puts inverted numbers (in the sense of little/big endian inversion)
4384// from predefined arrays.
4385//=======================================================================
4386#include <FSD_BinaryFile.hxx>
4387
4388template<int size>
4389inline const unsigned char* SizeRef ();
4390
4391template<>
4392inline const unsigned char* SizeRef <8> ()
4393{
4394 static const unsigned char aSizeRef[] = {
4395 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4396 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
4397 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
4398 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,
4399 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,
4400 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,
4401 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
4402 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
4403 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,
4404 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4405 return aSizeRef;
4406}
4407
4408template<>
4409inline const unsigned char* SizeRef <4> ()
4410{
4411 static const unsigned char aSizeRef[] = {
4412 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4413 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4414 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4415 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4416 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4417 return aSizeRef;
4418}
4419
4420static Standard_Integer OCC24537(
4421 Draw_Interpretor& theDI,
4422 Standard_Integer argc,
4423 const char ** argv)
4424{
4425 std::ofstream aF;
4426 if (argc > 1)
4427 {
4428 aF.open(argv[1]);
4429 if (!aF.is_open())
4430 {
4431 cout << "cannot create file " << argv[1] << endl;
4432 return 1;
4433 }
4434 }
4435 Standard_Boolean isErr = Standard_False;
4436 // 1. InverseInt
4437 const unsigned char anIntRef[] = {
4438 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4439 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4440 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4441 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4442 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4443 Standard_Integer anIntArr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
4444 if (aF.is_open())
4445 {
4446 for(int i = 0; i < 10; ++i)
4447 {
4448 Standard_Integer anInv = FSD_BinaryFile::InverseInt(anIntArr[i]);
4449 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4450 }
4451 }
4452 else
4453 {
4454 Standard_Integer anInv[10];
4455 for(int i = 0; i < 10; ++i)
4456 anInv[i] = FSD_BinaryFile::InverseInt(anIntArr[i]);
4457 if (memcmp(anInv, anIntRef, sizeof(anIntRef)) != 0)
4458 {
4459 theDI << "Error: incorrect conversion of an integer value\n";
4460 isErr = Standard_True;
4461 }
4462 }
4463
4464 // 1a. Random InverseInt
4465 const unsigned char aRndIntRef[] = {
4466 0xFF,0xC2,0xF7,0x00,0xFF,0xFF,0xFB,0x2E,
4467 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4468 0x00,0x00,0x04,0xD2,0x00,0x00,0x04,0xD3,
4469 0xFF,0xFF,0xFD,0x1E,0xFF,0xFF,0xFF,0xFB,
4470 0x00,0x00,0x03,0x8D,0x00,0x3D,0x09,0x00};
4471 Standard_Integer aRndIntArr[] = {-4000000, -1234, 0, 1, 1234, 1235, -738, -5, 909, 4000000};
4472 if (aF.is_open())
4473 {
4474 for(int i = 0; i < 10; ++i)
4475 {
4476 Standard_Integer anInv = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4477 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4478 }
4479 }
4480 else
4481 {
4482 Standard_Integer anInv[10];
4483 for(int i = 0; i < 10; ++i)
4484 anInv[i] = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4485 if (memcmp(anInv, aRndIntRef, sizeof(aRndIntRef)) != 0)
4486 {
4487 theDI << "Error: incorrect conversion of a dispersed integer value\n";
4488 isErr = Standard_True;
4489 }
4490 }
4491
4492 // 2. InverseReal
4493 const unsigned char aRealRef[] = {
4494 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4495 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4496 0x40,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
4497 0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
4498 0x40,0x14,0x00,0x00,0x00,0x00,0x00,0x00,
4499 0x40,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
4500 0x40,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
4501 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4502 0x40,0x22,0x00,0x00,0x00,0x00,0x00,0x00,
4503 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4504 const Standard_Real aRealArr[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0};
4505 if (aF.is_open())
4506 {
4507 for(int i = 0; i < 10; ++i)
4508 {
4509 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRealArr[i]);
4510 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4511 }
4512 }
4513 else
4514 {
4515 Standard_Real anInv[10];
4516 for(int i = 0; i < 10; ++i)
4517 anInv[i] = FSD_BinaryFile::InverseReal(aRealArr[i]);
4518 if (memcmp(anInv, aRealRef, sizeof(aRealRef)) != 0)
4519 {
4520 theDI << "Error: incorrect conversion of a real value\n";
4521 isErr = Standard_True;
4522 }
4523 }
4524
4525 // 2a. Random InverseReal
4526 const unsigned char aRndRealRef[] = {
4527 0xFE,0x37,0xE4,0x3C,0x88,0x00,0x75,0x9C,
4528 0xBE,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4529 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4530 0x3E,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4531 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4532 0x40,0x09,0x21,0xDA,0x45,0x5B,0x53,0xE4,
4533 0x54,0xB2,0x49,0xAD,0x25,0x94,0xC3,0x7D,
4534 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4535 0xC0,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD,
4536 0x40,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD};
4537 const Standard_Real aRndRealArr[] = {-1e300, -1.e-9, 0., 1.e-9, 1., 3.1415296, 1.e100, 8.0, -9.9, 9.9};
4538 if (aF.is_open())
4539 {
4540 for(int i = 0; i < 10; ++i)
4541 {
4542 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4543 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4544 }
4545 }
4546 else
4547 {
4548 Standard_Real anInv[10];
4549 for(int i = 0; i < 10; ++i)
4550 anInv[i] = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4551 if (memcmp(anInv, aRndRealRef, sizeof(aRndRealRef)) != 0)
4552 {
4553 theDI << "Error: incorrect conversion of a dispersed real value\n";
4554 isErr = Standard_True;
4555 }
4556 }
4557
4558 // 3. InverseShortReal
4559 const unsigned char aShortRealRef[] = {
4560 0x3F,0x80,0x00,0x00,0x40,0x00,0x00,0x00,
4561 0x40,0x40,0x00,0x00,0x40,0x80,0x00,0x00,
4562 0x40,0xA0,0x00,0x00,0x40,0xC0,0x00,0x00,
4563 0x40,0xE0,0x00,0x00,0x41,0x00,0x00,0x00,
4564 0x41,0x10,0x00,0x00,0x00,0x00,0x00,0x00};
4565 const Standard_ShortReal aShortRealArr[] = {
4566 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 0.0f};
4567 if (aF.is_open())
4568 {
4569 for(int i = 0; i < 10; ++i)
4570 {
4571 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4572 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4573 }
4574 }
4575 else
4576 {
4577 Standard_ShortReal anInv[10];
4578 for(int i = 0; i < 10; ++i)
4579 anInv[i] = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4580 if (memcmp(anInv, aShortRealRef, sizeof(aShortRealRef)) != 0)
4581 {
4582 theDI << "Error: incorrect conversion of a short real value\n";
4583 isErr = Standard_True;
4584 }
4585 }
4586
4587 // 3a. Random InverseShortReal
4588 const unsigned char aRndShortRealRef[] = {
4589 0xB0,0x89,0x70,0x5F,0x00,0x00,0x00,0x00,
4590 0x30,0x89,0x70,0x5F,0x3F,0x80,0x00,0x00,
4591 0x40,0x49,0x0E,0x56,0xC0,0xD6,0x66,0x66,
4592 0x40,0xD6,0x66,0x66,0x42,0xC5,0xCC,0xCD,
4593 0xC2,0xC7,0xCC,0xCD,0x42,0xC7,0xCC,0xCD};
4594 const Standard_ShortReal aRndShortRealArr[] = {
4595 -1.e-9f, 0.f, 1.e-9f, 1.f, 3.1415f, -6.7f, 6.7f, 98.9f, -99.9f, 99.9f};
4596 if (aF.is_open())
4597 {
4598 for(int i = 0; i < 10; ++i)
4599 {
4600 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4601 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4602 }
4603 }
4604 else
4605 {
4606 Standard_ShortReal anInv[10];
4607 for(int i = 0; i < 10; ++i)
4608 anInv[i] = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4609 if (memcmp(anInv, aRndShortRealRef, sizeof(aRndShortRealRef)) != 0)
4610 {
4611 theDI << "Error: incorrect conversion of a dispersed short real value\n";
4612 isErr = Standard_True;
4613 }
4614 }
4615
4616 // 4. InverseSize
4617 const Standard_Size aSizeArr[] = {1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul, 8ul, 9ul, 0ul};
4618 if (aF.is_open())
4619 {
4620 for(int i = 0; i < 10; ++i)
4621 {
4622 Standard_Size anInv = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4623 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4624 }
4625 }
4626 else
4627 {
4628 Standard_Size anInv[10];
4629 const unsigned char* aSizeRef = SizeRef<sizeof(Standard_Size)>();
4630 for(int i = 0; i < 10; ++i)
4631 anInv[i] = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4632 if (memcmp(anInv, aSizeRef, sizeof(Standard_Size)*10) != 0)
4633 {
4634 theDI << "Error: incorrect conversion of a size value\n";
4635 isErr = Standard_True;
4636 }
4637 }
4638
4639 if (!aF.is_open() && !isErr)
4640 theDI << "Conversion was done OK";
4641 if (aF.is_open())
4642 {
4643 cout << "the file " << argv[1] << " has been created" << endl;
4644 aF.close();
4645 }
4646 return 0;
4647}
4648
8cc2a23a 4649
4650#include <TopExp.hxx>
4651#include <BRepOffsetAPI_DraftAngle.hxx>
4652#include <vector>
4653static TopoDS_Shape taper(const TopoDS_Shape &shape, const TopoDS_Face &face_a, const TopoDS_Face &face_b, Standard_Real angle)
4654{
4655 // Use maximum face-to-taper z-offset.
4656 const gp_Pln neutral_plane(gp_Ax3(gp_Pnt(0.0, 0.0, 140.0), gp_Dir(0.0, 0.0, 1.0)));
4657
4658 // Draft angle needs to be in radians, and flipped to adhere to our own (arbitrary) draft
4659 // angle definition.
4660 const Standard_Real draft_angle = -(angle / 180.0) * M_PI;
4661
4662 // Add face to draft. The first argument indicates that all material added/removed during
4663 // drafting is located below the neutral plane
4664 BRepOffsetAPI_DraftAngle drafter(shape);
4665 drafter.Add(face_a, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4666 drafter.Add(face_b, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4667 drafter.Build();
4668
4669 return drafter.Shape();
4670}
4671
4672static void dumpShapeVertices(const TopoDS_Shape &shape, std::vector<Standard_Real>& coords)
4673{
4674 TopTools_IndexedMapOfShape shape_vertices;
4675 TopExp::MapShapes(shape, TopAbs_VERTEX, shape_vertices);
4676
4677 for (Standard_Integer i = 1; i <= shape_vertices.Extent(); i++)
4678 {
4679 gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(shape_vertices(i)));
4680 coords.push_back(p.X());
4681 coords.push_back(p.Y());
4682 coords.push_back(p.Z());
4683 }
4684}
4685
4686static void GetCoords(const Standard_CString& path_to_file, std::vector<Standard_Real>& coords)
4687{
4688 TopoDS_Shape shape;
4689 BRep_Builder builder;
4690 BRepTools::Read(shape, path_to_file, builder);
4691 TopTools_IndexedMapOfShape shape_faces;
4692 TopExp::MapShapes(shape, TopAbs_FACE, shape_faces);
4693 TopoDS_Face face_a = TopoDS::Face(shape_faces(1));
4694 TopoDS_Face face_b = TopoDS::Face(shape_faces(5));
4695 dumpShapeVertices(taper(shape, face_a, face_b, 5.0), coords);
4696}
4697
4698static Standard_Integer OCC26396 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4699{
4700 if (theArgc < 2)
4701 {
4702 theDI << "Error: path to file is missing\n";
4703 return 1;
4704 }
4705
4706 const int maxInd = 50;
4707
4708 std::vector<Standard_Real> ref_coords;
4709 ref_coords.reserve(100);
4710 Standard_Boolean Stat = Standard_True;
4711
4712 GetCoords(theArgv[1], ref_coords);
4713
4714 std::vector<Standard_Real> coords;
4715 coords.reserve(100);
4716 for (int i = 1; i < maxInd; i++)
4717 {
4718 GetCoords(theArgv[1], coords);
4719 if (coords.size() != ref_coords.size())
4720 {
4721 Stat = Standard_False;
4722 break;
4723 }
4724 for (size_t j = 0; j < coords.size(); j++)
4725 if (Abs(ref_coords[j] - coords[j]) > RealEpsilon())
4726 {
4727 Stat = Standard_False;
4728 break;
4729 }
4730 coords.clear();
4731 }
4732 if (!Stat)
4733 theDI << "Error: unstable results";
4734 else
4735 theDI << "test OK";
4736
4737 return 0;
4738}
4739
d0fcf95a 4740//=======================================================================
4741//function : OCC26750
4742//purpose :
4743//=======================================================================
4744static Standard_Integer OCC26750( Draw_Interpretor& theDI,
4745 Standard_Integer /*theNArg*/,
4746 const char ** /*theArgVal*/)
4747{
4748 const gp_Vec2d aVec1(1.0, 0.0);
4749 const gp_Vec2d aVec2(0.0, -1.0);
4750
4751 if(aVec1.IsNormal(aVec2, Precision::Angular()))
4752 {
4753 theDI << "gp_Vec2d OK. Vectors are normal.\n";
4754 }
4755 else
4756 {
4757 theDI << "Error in gp_Vec2d. Vectors should be normal.\n";
4758 }
4759
4760 const gp_Dir2d aD1(1.0, 0.0);
4761 const gp_Dir2d aD2(0.0, -1.0);
4762
4763 if(aD1.IsNormal(aD2, Precision::Angular()))
4764 {
4765 theDI << "gp_Dir2d OK. Vectors are normal.\n";
4766 }
4767 else
4768 {
4769 theDI << "Error in gp_Dir2d. Vectors should be normal.\n";
4770 }
4771
4772 return 0;
4773}
4774
0b4abfb9 4775//=======================================================================
4776//function : OCC26746
4777//purpose : Checks if coefficients of the torus are computed properly.
4778//=======================================================================
4779#include <Geom_ToroidalSurface.hxx>
92efcf78 4780#include <Geom_BSplineCurve.hxx>
0b4abfb9 4781static Standard_Integer OCC26746(
4782 Draw_Interpretor& theDI,
4783 Standard_Integer theNArg,
4784 const char ** theArgVal)
4785{
4786 if(theNArg < 2)
4787 {
4788 theDI << "Use: OCC26746 torus [toler NbCheckedPoints]\n";
4789 return 1;
4790 }
4791
4792 const Handle(Geom_ToroidalSurface) aGtor =
4793 Handle(Geom_ToroidalSurface)::DownCast(DrawTrSurf::GetSurface(theArgVal[1]));
4794
4795 const Standard_Real aToler = (theNArg >= 3)? Draw::Atof(theArgVal[2]) : 1.0e-7;
4796 const Standard_Integer aNbPntsMax = (theNArg >= 4)? Draw::Atoi(theArgVal[3]) : 5;
4797
4798 const Standard_Integer aLowIndex = 5;
4799 const Standard_Real aStep = 2.0*M_PI/aNbPntsMax;
4800
4801 TColStd_Array1OfReal anArrCoeffs(aLowIndex, aLowIndex+34);
4802 aGtor->Torus().Coefficients(anArrCoeffs);
4803
4804 Standard_Real aUpar = 0.0, aVpar = 0.0;
4805 for(Standard_Integer aUind = 0; aUind <= aNbPntsMax; aUind++)
4806 {
4807 for(Standard_Integer aVind = 0; aVind <= aNbPntsMax; aVind++)
4808 {
4809 const gp_Pnt aPt(aGtor->Value(aUpar, aVpar));
4810 const Standard_Real aX1 = aPt.X();
4811 const Standard_Real aX2 = aX1*aX1;
4812 const Standard_Real aX3 = aX2*aX1;
4813 const Standard_Real aX4 = aX2*aX2;
4814 const Standard_Real aY1 = aPt.Y();
4815 const Standard_Real aY2 = aY1*aY1;
4816 const Standard_Real aY3 = aY2*aY1;
4817 const Standard_Real aY4 = aY2*aY2;
4818 const Standard_Real aZ1 = aPt.Z();
4819 const Standard_Real aZ2 = aZ1*aZ1;
4820 const Standard_Real aZ3 = aZ2*aZ1;
4821 const Standard_Real aZ4 = aZ2*aZ2;
4822
4823 Standard_Integer i = aLowIndex;
4824
4825 Standard_Real aDelta = anArrCoeffs(i++) * aX4; //1
4826 aDelta+= anArrCoeffs(i++) * aY4; //2
4827 aDelta+= anArrCoeffs(i++) * aZ4; //3
4828 aDelta+= anArrCoeffs(i++) * aX3 * aY1; //4
4829 aDelta+= anArrCoeffs(i++) * aX3 * aZ1; //5
4830 aDelta+= anArrCoeffs(i++) * aY3 * aX1; //6
4831 aDelta+= anArrCoeffs(i++) * aY3 * aZ1; //7
4832 aDelta+= anArrCoeffs(i++) * aZ3 * aX1; //8
4833 aDelta+= anArrCoeffs(i++) * aZ3 * aY1; //9
4834 aDelta+= anArrCoeffs(i++) * aX2 * aY2; //10
4835 aDelta+= anArrCoeffs(i++) * aX2 * aZ2; //11
4836 aDelta+= anArrCoeffs(i++) * aY2 * aZ2; //12
4837 aDelta+= anArrCoeffs(i++) * aX2 * aY1 * aZ1; //13
4838 aDelta+= anArrCoeffs(i++) * aX1 * aY2 * aZ1; //14
4839 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ2; //15
4840 aDelta+= anArrCoeffs(i++) * aX3; //16
4841 aDelta+= anArrCoeffs(i++) * aY3; //17
4842 aDelta+= anArrCoeffs(i++) * aZ3; //18
4843 aDelta+= anArrCoeffs(i++) * aX2 * aY1; //19
4844 aDelta+= anArrCoeffs(i++) * aX2 * aZ1; //20
4845 aDelta+= anArrCoeffs(i++) * aY2 * aX1; //21
4846 aDelta+= anArrCoeffs(i++) * aY2 * aZ1; //22
4847 aDelta+= anArrCoeffs(i++) * aZ2 * aX1; //23
4848 aDelta+= anArrCoeffs(i++) * aZ2 * aY1; //24
4849 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ1; //25
4850 aDelta+= anArrCoeffs(i++) * aX2; //26
4851 aDelta+= anArrCoeffs(i++) * aY2; //27
4852 aDelta+= anArrCoeffs(i++) * aZ2; //28
4853 aDelta+= anArrCoeffs(i++) * aX1 * aY1; //29
4854 aDelta+= anArrCoeffs(i++) * aX1 * aZ1; //30
4855 aDelta+= anArrCoeffs(i++) * aY1 * aZ1; //31
4856 aDelta+= anArrCoeffs(i++) * aX1; //32
4857 aDelta+= anArrCoeffs(i++) * aY1; //33
4858 aDelta+= anArrCoeffs(i++) * aZ1; //34
4859 aDelta+= anArrCoeffs(i++); //35
4860
4861 if(Abs(aDelta) > aToler)
4862 {
4863 theDI << "(" << aUpar << ", " << aVpar << "): Error in torus coefficients computation (Delta = " << aDelta << ").\n";
4864 }
4865 else
4866 {
4867 theDI << "(" << aUpar << ", " << aVpar << "): OK (Delta = " << aDelta << ").\n";
4868 }
4869
4870 aVpar = (aVind == aNbPntsMax)? 2.0*M_PI : aVpar + aStep;
4871 }
4872
4873 aVpar = 0.0;
4874 aUpar = (aUind == aNbPntsMax)? 2.0*M_PI : aUpar + aStep;
4875 }
4876
4877 return 0;
4878}
4879
a3f6f591 4880DEFINE_STANDARD_HANDLE(QABugs_VertexFilter, SelectMgr_Filter)
badc9305 4881class QABugs_VertexFilter: public SelectMgr_Filter
4882{
4883public:
4884 Standard_EXPORT QABugs_VertexFilter() : SelectMgr_Filter() {}
4885
4886 Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)&) const
4887 {
4888 return Standard_False;
4889 }
4890};
4891
4892//=======================================================================
4893//function : BUC26658
4894//purpose : Checks selection in the context after using a selection filter
4895//=======================================================================
4896static Standard_Integer BUC26658 (Draw_Interpretor& theDI,
4897 Standard_Integer /*theNArg*/,
4898 const char ** theArgVal)
4899{
4900 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4901 if(aContext.IsNull()) {
4902 theDI << "use 'vinit' command before " << theArgVal[0] << "\n";
4903 return 1;
4904 }
4905
4906 TopoDS_Shape aBoxShape = BRepPrimAPI_MakeBox(20,20,20).Shape();
4907 Handle(AIS_Shape) anAISIO = new AIS_Shape(aBoxShape);
4908
4909 // visualization of the box in the local mode with possibility to
4910 // select box vertices
4911 aContext->OpenLocalContext();
4912
4913 int aDispMode = 0;// wireframe
4914 anAISIO->SetDisplayMode(aDispMode);
4915 aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed);
4916 theDI.Eval(" vfit");
4917
4918 aContext->Load(anAISIO, -1, true); /// load allowing decomposition
4919 aContext->Deactivate(anAISIO);
4920 aContext->Activate(anAISIO, AIS_Shape::SelectionMode(TopAbs_VERTEX), false);
4921 aContext->UpdateCurrentViewer();
4922
4923 // select a point on the box
4924 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
4925 double Xv,Yv;
4926 myV3dView->Project(20,20,0,Xv,Yv);
4927 Standard_Integer Xp,Yp;
4928 myV3dView->Convert(Xv,Yv,Xp,Yp);
4929
4930 aContext->MoveTo(Xp,Yp, myV3dView);
4931 aContext->Select();
4932 bool aHasSelected = false;
4933 for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) {
4934 Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
4935 if (!anIO.IsNull()) {
4936 const TopoDS_Shape aShape = aContext->SelectedShape();
4937 if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX)
4938 aHasSelected = true;
4939 }
4940 }
4941 if (aHasSelected)
4942 cout << "has selected vertex : OK" << endl;
4943 else {
4944 theDI << "has selected vertex : bugged - Faulty\n";
4945 return 1;
4946 }
4947 // filter to deny any selection in the viewer
4948 Handle(QABugs_VertexFilter) aFilter = new QABugs_VertexFilter();
4949 aContext->AddFilter(aFilter);
4950
4951 // update previous selection by hand
4952 aContext->LocalContext()->ClearOutdatedSelection(anAISIO, true);
4953
4954 // check that there are no selected vertices
4955 aContext->Select();
4956 aHasSelected = false;
4957 for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) {
4958 Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
4959 if (!anIO.IsNull()) {
4960 const TopoDS_Shape aShape = aContext->SelectedShape();
4961 if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX)
4962 aHasSelected = true;
4963 }
4964 }
4965 if (!aHasSelected) cout << "has no selected vertex after filter : OK" << endl;
4966 else {
4967 theDI << "has no selected vertex after filter : bugged - Faulty\n";
4968 return 1;
4969 }
4970
4971 return 0;
4972}
4973
325e442b 4974//=======================================================================
4975//function : OCC26945_open
4976//purpose : Opens local context and activates given standard selection mode
4977//=======================================================================
4978static Standard_Integer OCC26945_open (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4979{
4980 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
4981 if (aCtx.IsNull())
4982 {
4983 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
4984 return 1;
4985 }
4986
4987 if (theArgc < 2)
4988 {
4989 std::cout << "Not enough arguments. See usage:\n";
4990 theDI.PrintHelp (theArgv[0]);
4991 return 1;
4992 }
4993
4994 const TopAbs_ShapeEnum aSelType = AIS_Shape::SelectionType (Draw::Atoi (theArgv[1]));
4995 Standard_Integer aLocalCtxIdx = aCtx->OpenLocalContext();
4996 aCtx->ActivateStandardMode (aSelType);
4997 theDI << aLocalCtxIdx;
4998
4999 return 0;
5000}
5001
5002//=======================================================================
5003//function : OCC26945_close
5004//purpose : Closes local context with the id given
5005//=======================================================================
5006static Standard_Integer OCC26945_close (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
5007{
5008 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5009 if (aCtx.IsNull())
5010 {
5011 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5012 return 1;
5013 }
5014
5015 if (theArgc < 2)
5016 {
5017 std::cout << "Not enough arguments. See usage:\n";
5018 theDI.PrintHelp (theArgv[0]);
5019 return 1;
5020 }
5021
5022 const Standard_Integer aCtxToClose = Draw::Atoi (theArgv[1]);
5023 aCtx->CloseLocalContext (aCtxToClose);
5024
5025 return 0;
5026}
5027
f3a1c0cb 5028//=======================================================================
5029//function : OCC27048
5030//purpose : Calculate value of B-spline surface N times
5031//=======================================================================
5032static Standard_Integer OCC27048(Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
5033{
5034 if (theArgc != 5)
5035 {
5036 std::cout << "Incorrect number of arguments. See usage:" << std::endl;
5037 theDI.PrintHelp(theArgv[0]);
5038 return 1;
5039 }
5040
5041 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theArgv[1]);
5042 GeomAdaptor_Surface anAdaptor(aSurf);
5043
5044 Standard_Real aU = Draw::Atof(theArgv[2]);
5045 Standard_Real aV = Draw::Atof(theArgv[3]);
5046 Standard_Integer aN = Draw::Atoi(theArgv[4]);
5047
5048 for (; aN > 0; --aN)
5049 anAdaptor.Value(aU, aV);
5050
5051 return 0;
5052}
5053
5e9548e7 5054//========================================================================
5055//function : OCC27065
5056//purpose : Tests overloaded method "Generated" of BRepOffsetAPI_MakePipe
5057//========================================================================
5058static Standard_Integer OCC27065(Draw_Interpretor& di,
5059 Standard_Integer n, const char** a)
5060{
5061 if (n < 3) return 1;
5062 BRep_Builder BB;
5063
5064 TopoDS_Shape SpineShape = DBRep::Get(a[1],TopAbs_WIRE);
5065 if ( SpineShape.IsNull()) return 1;
5066 TopoDS_Wire Spine = TopoDS::Wire(SpineShape);
5067
5068 TopoDS_Shape Profile = DBRep::Get(a[2]);
5069 if ( Profile.IsNull()) return 1;
5070
5071 BRepOffsetAPI_MakePipe aPipeBuilder(Spine, Profile);
5072 if (!aPipeBuilder.IsDone())
5073 {
5074 di << "Error: failed to create pipe\n";
5075 return 1;
5076 }
5077
5078 TopExp_Explorer Explo(Profile, TopAbs_SHELL);
5079 TopoDS_Shape aShape;
5080 TopTools_ListIteratorOfListOfShape itl;
5081 if (Explo.More())
5082 {
5083 aShape = Explo.Current();
5084 TopoDS_Compound res1;
5085 BB.MakeCompound(res1);
5086 itl.Initialize(aPipeBuilder.Generated(aShape));
5087 for (; itl.More(); itl.Next())
5088 BB.Add(res1, itl.Value());
5089 DBRep::Set("res_shell", res1);
5090 }
5091
5092 Explo.Init(Profile, TopAbs_FACE);
5093 if (Explo.More())
5094 {
5095 aShape = Explo.Current();
5096 TopoDS_Compound res2;
5097 BB.MakeCompound(res2);
5098 itl.Initialize(aPipeBuilder.Generated(aShape));
5099 for (; itl.More(); itl.Next())
5100 BB.Add(res2, itl.Value());
5101 DBRep::Set("res_face", res2);
5102 }
5103
5104 Explo.Init(Profile, TopAbs_WIRE);
5105 if (Explo.More())
5106 {
5107 aShape = Explo.Current();
5108 TopoDS_Compound res3;
5109 BB.MakeCompound(res3);
5110 itl.Initialize(aPipeBuilder.Generated(aShape));
5111 for (; itl.More(); itl.Next())
5112 BB.Add(res3, itl.Value());
5113 DBRep::Set("res_wire", res3);
5114 }
5115
5116 Explo.Init(Profile, TopAbs_EDGE);
5117 if (Explo.More())
5118 {
5119 aShape = Explo.Current();
5120 TopoDS_Compound res4;
5121 BB.MakeCompound(res4);
5122 itl.Initialize(aPipeBuilder.Generated(aShape));
5123 for (; itl.More(); itl.Next())
5124 BB.Add(res4, itl.Value());
5125 DBRep::Set("res_edge", res4);
5126 }
5127
5128 Explo.Init(Profile, TopAbs_VERTEX);
5129 if (Explo.More())
5130 {
5131 aShape = Explo.Current();
5132 TopoDS_Compound res5;
5133 BB.MakeCompound(res5);
5134 itl.Initialize(aPipeBuilder.Generated(aShape));
5135 for (; itl.More(); itl.Next())
5136 BB.Add(res5, itl.Value());
5137 DBRep::Set("res_vertex", res5);
5138 }
5139
5140 return 0;
5141}
5142
4c0d97ac 5143//========================================================================
5144//function : OCC27318
5145//purpose : Creates a box that is not listed in map of AIS objects of ViewerTest
5146//========================================================================
5147static Standard_Integer OCC27318 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5148{
5149 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5150 if (aCtx.IsNull())
5151 {
5152 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5153 return 1;
5154 }
5155
5156 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20, 20, 20).Shape();
5157 Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
5158 aCtx->Display (aBoxObj, Standard_True);
5159
5160 return 0;
5161}
5162
1cd84fee 5163void QABugs::Commands_19(Draw_Interpretor& theCommands) {
1365140b 5164 const char *group = "QABugs";
7fd59977 5165
dda67c1c 5166 Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass();
5167 theCommands.Add ("OCC24202_1", "Test Handle-based procedure",
5168 __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group);
5169 NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass();
5170 theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure",
5171 __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group);
5172
7fd59977 5173 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
f6f03db9 5174 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
1365140b
RL
5175 theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
5176 theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
e6aad0ee 5177 theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
5d1833ef 5178 theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
e187cc0a 5179 theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
bead40f2 5180 theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
06be28a4 5181 theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
1ef32e96
RL
5182 theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
5183 theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
1939140c 5184 theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
05d7de53 5185 theCommands.Add ("OCC23945", "OCC23945 surfname U V X Y Z [DUX DUY DUZ DVX DVY DVZ [D2UX D2UY D2UZ D2VX D2VY D2VZ D2UVX D2UVY D2UVZ]]", __FILE__, OCC23945,group);
2e9fd4bc 5186 theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
29cb310a 5187 theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
788cbaf4 5188 theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
89d8607f 5189 theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
ab2db9a5 5190 theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
e6c9f595 5191 theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group);
e3096dec 5192 theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group);
05d7de53 5193 theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group);
1b7602c8 5194 theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group);
69fd2d1b 5195 theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group);
2cd138b8 5196 theCommands.Add ("OCC24622", "OCC24622 texture={1D|2D}\n Tests sourcing of 1D/2D pixmaps for AIS_TexturedShape", __FILE__, OCC24622, group);
5197 theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group);
d01cc61d 5198 theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group);
a73267f2 5199 theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group);
8696d65d 5200 theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group);
7a7e8cf1 5201 theCommands.Add ("OCC23951", "OCC23951 path to saved step file", __FILE__, OCC23951, group);
5202 theCommands.Add ("OCC24931", "OCC24931 path to saved xml file", __FILE__, OCC24931, group);
c764e804 5203 theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group);
1fa7cb8c 5204 theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
5493d334 5205 theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group);
b6c0b841
RL
5206 theCommands.Add ("OCC24925",
5207 "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]"
5208 "\nOCAF persistence without setting environment variables",
5209 __FILE__, OCC24925, group);
e4b5c45a 5210 theCommands.Add ("OCC23010", "OCC23010 STEP_file", __FILE__, OCC23010, group);
a967f104 5211 theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group);
c7b59798 5212 theCommands.Add ("OCC24826,", "This test performs simple saxpy test.\n Usage: OCC24826 length", __FILE__, OCC24826, group);
4a350f94 5213 theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group);
ab860031 5214 theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group);
c6037065 5215 theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
058f130e 5216 theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
54a16ee4 5217 theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group);
5e452c37 5218 theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group);
6fb3418e 5219 theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
c088aa93 5220 theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
ee6bb37b 5221 theCommands.Add ("OCC25545",
5222 "no args; tests data race when concurrently accessing \n"
5223 "\t\tTopLoc_Location::Transformation()",
5224 __FILE__, OCC25545, group);
d315303d 5225 theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
2bfe59b6 5226 theCommands.Add ("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group);
c070aa39 5227 theCommands.Add ("OCC26172", "OCC26172", __FILE__, OCC26172, group);
9bf3177f 5228 theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);
ec26bf88 5229 theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group);
ec81011f 5230 theCommands.Add ("OCC26139", "OCC26139 [-boxsize value] [-boxgrid value] [-compgrid value]", __FILE__, OCC26139, group);
e11850fd 5231 theCommands.Add ("OCC26284", "OCC26284", __FILE__, OCC26284, group);
3ceb4c3c 5232 theCommands.Add ("OCC26446", "OCC26446 r c1 c2", __FILE__, OCC26446, group);
fac9298e 5233 theCommands.Add ("OCC26448", "OCC26448: check method Prepend() of sequence", __FILE__, OCC26448, group);
71316196 5234 theCommands.Add ("OCC26407", "OCC26407 result_name", __FILE__, OCC26407, group);
db6c6404 5235 theCommands.Add ("OCC26485", "OCC26485 shape", __FILE__, OCC26485, group);
5a8dc41a 5236 theCommands.Add ("OCC26553", "OCC26553 file_path", __FILE__, OCC26553, group);
3bf9a45f 5237 theCommands.Add ("OCC26195",
5238 "OCC26195: x1_pix y1_pix [x2_pix y2_pix] [toPrintPixelCoord 0|1]"
5239 "\n\t\t: Draws rectangular selecting frustum defined by point selection in pixel coordinates"
5240 "\n\t\t: [x1_pix, y1_pix] or rectangular selection in pixel coordinates [x1_pix, y1_pix,"
5241 "\n\t\t: x2_pix, y2_pix]."
5242 "\n\t\t: [toPrintPixelCoord 0|1] - prints 3d projection of pixel coordinate or center of"
5243 "\n\t\t: selecting rectangle onto near and far view frustum planes",
5244 __FILE__, OCC26195, group);
8a1170ad 5245 theCommands.Add ("OCC26462",
5246 "OCC26462: Checks the ability to manage sensitivity of a particular selection mode in local context",
5247 __FILE__, OCC26462, group);
43940380 5248
5249 theCommands.Add ("OCC26313", "OCC26313 result shape", __FILE__, OCC26313, group);
8cc2a23a 5250 theCommands.Add ("OCC26396", "OCC26396 shape_file_path", __FILE__, OCC26396, group);
81b47143 5251 theCommands.Add ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group);
43940380 5252
10a4116e 5253 theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group);
d0fcf95a 5254 theCommands.Add ("OCC26750", "OCC26750", __FILE__, OCC26750, group);
4f5ad416 5255 theCommands.Add ("OCC25574", "OCC25574", __FILE__, OCC25574, group);
0b4abfb9 5256 theCommands.Add ("OCC26746", "OCC26746 torus [toler NbCheckedPoints] ", __FILE__, OCC26746, group);
5257
badc9305 5258 theCommands.Add ("BUC26658", "BUC26658 unexpected selection in the context using a selection filter", __FILE__, BUC26658, group);
325e442b 5259 theCommands.Add ("OCC26945_open",
5260 "OCC26945 selectionModeToActivate"
5261 "\n\t\t: Opens a new local context with selectionModeToActivate activated."
5262 "\n\t\t: Prints the ID of newely opened local context in case of success.",
5263 __FILE__, OCC26945_open, group);
5264 theCommands.Add ("OCC26945_close",
5265 "OCC26945 localCtxToClose"
5266 "\n\t\t: Closes local context with the ID localCtxToClose",
5267 __FILE__, OCC26945_close, group);
f3a1c0cb 5268
5269 theCommands.Add ("OCC27048",
5270 "OCC27048 surf U V N\nCalculate value of surface N times in the point (U, V)",
5271 __FILE__, OCC27048, group);
badc9305 5272
5e9548e7 5273 theCommands.Add ("OCC27065",
5274 "OCC27065 spine profile",
5275 __FILE__, OCC27065, group);
4c0d97ac 5276
5277 theCommands.Add ("OCC27318",
5278 "OCC27318: Creates a box that is not listed in map of AIS objects of ViewerTest",
5279 __FILE__, OCC27318, group);
5280
7fd59977 5281 return;
5282}