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