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