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