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