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