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