1 // Created on: 2002-05-21
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
18 #include <Draw_Interpretor.hxx>
20 #include <DrawTrSurf.hxx>
21 #include <ViewerTest.hxx>
22 #include <V3d_View.hxx>
23 #include <TopoDS_Shape.hxx>
24 #include <AIS_InteractiveContext.hxx>
25 #include <AIS_TexturedShape.hxx>
26 #include <Image_PixMap.hxx>
27 #include <Image_Color.hxx>
29 #include <gp_Pnt2d.hxx>
31 #include <GCE2d_MakeSegment.hxx>
32 #include <Geom2d_TrimmedCurve.hxx>
33 #include <DrawTrSurf.hxx>
35 #include <Precision.hxx>
37 #include <PCollection_HAsciiString.hxx>
42 #include <OSD_Timer.hxx>
43 #include <OSD_Parallel.hxx>
44 #include <OSD_PerfMeter.hxx>
45 #include <BRepPrimAPI_MakeBox.hxx>
46 #include <BRepPrimAPI_MakeSphere.hxx>
47 #include <BRepAlgo_Cut.hxx>
48 #include <NCollection_Map.hxx>
49 #include <NCollection_Handle.hxx>
50 #include <TCollection_HAsciiString.hxx>
51 #include <GeomFill_Trihedron.hxx>
52 #include <BRepOffsetAPI_MakePipe.hxx>
53 #include <Standard_Atomic.hxx>
55 #include <Standard_Version.hxx>
57 #define QCOMPARE(val1, val2) \
58 di << "Checking " #val1 " == " #val2 << \
59 ((val1) == (val2) ? ": OK\n" : ": Error\n")
61 static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
64 di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d" << "\n";
69 if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
70 di << "ERROR OCC230: " << argv[2] << " is not Pnt2d" << "\n";
73 if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
74 di << "ERROR OCC230: " << argv[3] << " is not Pnt2d" << "\n";
78 GCE2d_MakeSegment MakeSegment(P1,P2);
79 Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
80 DrawTrSurf::Set(argv[1], TrimmedCurve);
84 static Standard_Integer OCC142 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
86 for(Standard_Integer i= 0;i <= 20;i++){
87 Handle(PCollection_HAsciiString) pstr = new PCollection_HAsciiString("TEST");
90 di << "OCC142: OK" << "\n";
94 static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
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);
102 gp_Trsf tComp = t2 * t1;
105 gp_Pnt p2 = p1.Transformed(tComp);
106 gp_Pnt p3 = p1.Transformed(t1);
109 // points must be equal
110 if ( ! p2.IsEqual(p3, Precision::Confusion()) )
111 di << "ERROR OCC23361: equivalent transformations does not produce equal points" << "\n";
113 di << "OCC23361: OK" << "\n";
118 static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
120 OSD_PerfMeter aPM("TestMeter",0);
123 // run some operation in cycle for about 2 seconds to have good values of times to compare
125 printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n");
126 for (; aTM.ElapsedTime() < 2.; count++)
131 // do some operation that will take considerable time compared with time of starting / stopping timers
132 BRepPrimAPI_MakeBox aBox (10., 10., 10.);
133 BRepPrimAPI_MakeSphere aSphere (10.);
134 BRepAlgo_Cut aCutter (aBox.Shape(), aSphere.Shape());
141 Standard_Real aPerfMeter_CPUtime = 0., aTimer_ElapsedTime = aTM.ElapsedTime();
143 perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
145 Standard_Real aTimeDiff = (fabs(aTimer_ElapsedTime - aPerfMeter_CPUtime) / aTimer_ElapsedTime);
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);
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";
156 di << "OCC23237: OK";
161 class IncrementerDecrementer
164 IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
166 void operator() (const size_t) const
169 Standard_Atomic_Increment(myVal);
171 Standard_Atomic_Decrement(myVal);
174 Standard_Integer* myVal;
175 Standard_Boolean myPositive;
178 static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
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);
192 const int N = 1 << 24; //big enough to ensure concurrency
195 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, true));
199 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, false));
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>
213 static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
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);
220 Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
222 //check default value
223 Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
224 QCOMPARE (aValue, Standard_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);
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);
240 XCAFDoc_ShapeTool::SetAutoNaming (aValue);
245 #include <ExprIntrp_GenExp.hxx>
246 Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
250 di << "Usage : " << argv[0] << " string nb\n";
254 TCollection_AsciiString aToken = argv[1];
255 Standard_Integer aNb = atoi(argv[2]);
257 Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create();
258 for (Standard_Integer i=0; i < aNb; i++)
260 aGen->Process(aToken);
261 Handle(Expr_GeneralExpression) aExpr = aGen->Expression();
267 Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
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) <<"}";
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>
284 static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di)
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;
292 if(distShapeShape.Value() > 0.01) {
293 di << "Wrong Dist = " <<distShapeShape.Value() << "\n";
294 return Standard_False;
296 di << "Dist0 = " <<distShapeShape.Value() <<"\n";
298 //////////////////////////////////////////////////////////////////////////
300 const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970);
301 const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970);
303 gp_Vec2d mirrorVector1(axis1P1,axis1P2);
306 mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1));
308 BRepBuilderAPI_Transform transformer1(mirror1);
309 transformer1.Perform(originalWire);
310 if(!transformer1.IsDone()) {
311 di << "Not Done1 " << "\n";
312 return Standard_False;
314 const TopoDS_Shape& step1ModifiedShape = transformer1.ModifiedShape(originalWire);
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;
323 di << "Dist1 = " <<distShapeShape1.Value() <<"\n";
325 //////////////////////////////////////////////////////////////////////////
327 transformer1.Perform(step1ModifiedShape);
328 if(!transformer1.IsDone()) {
329 di << "Not Done1 \n";
330 return Standard_False;
332 const TopoDS_Shape& step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
334 //This is identity matrix for values but for type is gp_Rotation ?!
335 gp_Trsf2d mirror11 = mirror1;
336 mirror11.PreMultiply(mirror1);
338 BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN);
339 if(!distShapeShape2.IsDone())
340 return Standard_False;
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;
351 di << "Distance2 = " <<distShapeShape2.Value() <<"\n";
353 return Standard_True;
355 static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a)
359 di <<"OCC23774: invalid number of input parameters\n";
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";
369 const TopoDS_Face& aFace = TopoDS::Face(S1);
370 if(!OCC23774Test(aFace, S2, di))
371 di << "Something is wrong\n";
376 #include <GeomConvert_ApproxSurface.hxx>
377 #include <Geom_BSplineSurface.hxx>
379 #include <OSD_Thread.hxx>
380 static void GeomConvertTest (Draw_Interpretor& di, Standard_Integer theTargetNbUPoles, Standard_CString theFileName)
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";
388 const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
389 if (aBSurf.IsNull()) {
390 di << "BSplineSurface is not created!" << "\n";
393 di << "Number of UPoles:" << aBSurf->NbUPoles() << "\n";
394 QCOMPARE (aBSurf->NbUPoles(), theTargetNbUPoles);
398 Draw_Interpretor* di;
399 Standard_Integer nbupoles;
400 Standard_CString filename;
403 Standard_EXPORT Standard_Address convert(Standard_Address data)
405 aData* info = (aData*) data;
406 GeomConvertTest(*(info->di),info->nbupoles,info->filename);
410 static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
413 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
416 struct aData aStorage;
418 aStorage.nbupoles = Draw::Atoi(argv[1]);
419 aStorage.filename = argv[2];
421 OSD_Thread aThread1(convert);
422 aThread1.Run(&aStorage);
423 GeomConvertTest(di,aStorage.nbupoles,aStorage.filename);
424 cout << "result of thread: " << aThread1.Wait() << endl;
429 #include <GeomInt_IntSS.hxx>
430 static void GeomIntSSTest (Draw_Interpretor& di, Standard_Integer theNbSol, Standard_CString theFileName1, Standard_CString theFileName2)
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";
441 di << "Number of Lines:" << anInter.NbLines() << "\n";
442 QCOMPARE (anInter.NbLines(), theNbSol);
446 Draw_Interpretor* di;
447 Standard_Integer nbsol;
448 Standard_CString filename1;
449 Standard_CString filename2;
451 Standard_EXPORT Standard_Address convert_inter(Standard_Address data)
453 aNewData* info = (aNewData*) data;
454 GeomIntSSTest(*(info->di),info->nbsol,info->filename1,info->filename2);
458 static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
461 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
464 struct aNewData aStorage;
466 aStorage.nbsol = Draw::Atoi(argv[1]);
467 aStorage.filename1 = argv[2];
468 aStorage.filename2 = argv[3];
470 OSD_Thread aThread1(convert_inter);
471 aThread1.Run(&aStorage);
472 GeomIntSSTest(di,aStorage.nbsol,aStorage.filename1,aStorage.filename2);
473 cout << "result of thread: " << aThread1.Wait() << endl;
478 #include <Geom_SurfaceOfRevolution.hxx>
479 static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
482 di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n";
486 Standard_Integer ucontinuity = 1;
487 Standard_Integer vcontinuity = 1;
488 Standard_Boolean iscnu = false;
489 Standard_Boolean iscnv = false;
491 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
493 QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
494 QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
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>
508 static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
510 // Check the command arguments
513 di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
514 di << "Usage: type help " << argv[0] << "\n";
515 return 1; // TCL_ERROR
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() );
522 di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>" << "\n";
523 di << "-----------------------------------------------------------------------" << "\n";
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);
529 DBRep::Set("e1", E1);
531 BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
532 TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
534 DBRep::Set("f1", F1);
536 di << "Result: f1" << "\n";
538 di << "<<<< Preparing sample surface of revolution based on offset curve >>>>" << "\n";
539 di << "-----------------------------------------------------------------------" << "\n";
541 Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
542 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
544 DBRep::Set("e2", E2);
546 BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
547 TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
549 DBRep::Set("f2", F2);
551 di << "Result: f2" << "\n";
556 #include <Geom_Curve.hxx>
557 #include <Geom_Surface.hxx>
558 #include <Precision.hxx>
559 #include <ShapeConstruct_ProjectCurveOnSurface.hxx>
560 //=======================================================================
561 //function : OCC24008
563 //=======================================================================
564 static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
567 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
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";
576 if (aSurf.IsNull()) {
577 di << "Surface was not read" << "\n";
580 ShapeConstruct_ProjectCurveOnSurface aProj;
581 aProj.Init (aSurf, Precision::Confusion());
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";
590 di << "Exception was caught" << "\n";
595 #include <GeomAdaptor_Surface.hxx>
597 //=======================================================================
598 //function : OCC23945
600 //=======================================================================
602 static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
606 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
607 if (aS.IsNull()) return 1;
609 GeomAdaptor_Surface GS(aS);
611 Standard_Real U = Draw::Atof(a[2]);
612 Standard_Real V = Draw::Atof(a[3]);
614 Standard_Boolean DrawPoint = ( n%3 == 2);
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());
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());
647 Draw::Set(a[4],P.X());
648 Draw::Set(a[5],P.Y());
649 Draw::Set(a[6],P.Z());
652 DrawTrSurf::Set(a[n],P);
658 #include <Voxel_BoolDS.hxx>
659 #include <Voxel_FastConverter.hxx>
660 #include <Voxel_BooleanOperation.hxx>
661 static Standard_Integer OCC24019 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
664 di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
668 TCollection_AsciiString aFileName = argv[1];
670 BRep_Builder aBuilder;
672 if (!BRepTools::Read(aShape, aFileName.ToCString(), aBuilder)) {
673 di << "Error: Could not read a shape!" << "\n";
677 TopoDS_Solid aShape1 = BRepPrimAPI_MakeSphere(gp_Pnt(20,25,35), 7);
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);
685 Standard_Integer progress = 0;
686 Voxel_FastConverter fcp(aShape, theVoxels, deflection, nbx, nby, nbz, nbThreads);
687 fcp.ConvertUsingSAT(progress, 1);
690 Voxel_FastConverter fcp1(aShape1, theVoxels1, deflection, nbx, nby, nbz, nbThreads);
691 fcp1.ConvertUsingSAT(progress, 1);
692 fcp1.FillInVolume(1);
694 Voxel_BooleanOperation op;
695 Standard_Boolean result = op.Cut(theVoxels1, theVoxels);
697 di << "Error: invalid boolean operation" << "\n";
699 di << "OK: boolean operation is ok" << "\n";
705 //=======================================================================
706 //function : OCC11758
708 //=======================================================================
709 static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
711 if (n != 1) return 1;
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 );
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 );
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 );
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" );
745 //TCollection_AsciiString(const TCollection_AsciiString& astring)
746 TCollection_AsciiString e(d);
748 //assert( e.Length() == d.Length() );
749 //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
751 QCOMPARE ( e.Length() , d.Length() );
752 QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
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' );
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 );
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 );
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 );
791 // AssignCat(const TCollection_AsciiString& other)
792 Standard_Integer dl = d.Length();
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 );
800 TCollection_AsciiString capitalize("aBC");
801 capitalize.Capitalize();
802 //assert( capitalize == "Abc" );
803 QCOMPARE ( capitalize , "Abc" );
805 // Copy(const Standard_CString fromwhere)
807 //assert( d == theStr+i );
808 QCOMPARE ( d , theStr+i );
810 // Copy(const TCollection_AsciiString& fromwhere)
812 // IsEqual (const TCollection_AsciiString& other)const
816 // Insert(const Standard_Integer where, const Standard_CString what)
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 );
824 //Insert(const Standard_Integer where,const Standard_Character what)
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 );
834 //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
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 );
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 );
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 );
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 );
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 );
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 );
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 );
928 // void Read(Standard_IStream& astream)
929 std::istringstream is( theStr );
931 //assert( e == theStr );
932 QCOMPARE ( e , theStr );
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 );
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 ) );
945 // TCollection_AsciiString Split (const Standard_Integer where)
948 //assert( d.Length() + e.Length() == strlen( theStr ));
949 QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
951 // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
952 // const Standard_Integer ToIndex) const
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 ] );
960 // TCollection_AsciiString Token (const Standard_CString separators,
961 // const Standard_Integer whichone) const
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 ) );
969 for ( i = 0; i < 5; ++i )
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 );
977 //TCollection_ExtendedString (const Standard_ExtString astring)
978 const TCollection_ExtendedString b( a.ToExtString() );
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 );
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 );
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 );
1008 // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1009 const TCollection_ExtendedString f(e);
1010 //assert( f.Length() == e.Length());
1012 QCOMPARE ( f.Length() , e.Length() );
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 );
1022 // AssignCat (const TCollection_ExtendedString& other)
1023 const TCollection_ExtendedString sep(",");
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 );
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 );
1042 // Copy (const TCollection_ExtendedString& fromwhere)
1044 //assert( d.Length() == cat.Length() );
1045 //assert( d == cat );
1046 QCOMPARE ( d.Length() , cat.Length() );
1047 QCOMPARE ( d , cat );
1049 // IsEqual (const Standard_ExtString other) const
1050 //assert( d.IsEqual( d.ToExtString() ));
1051 QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1053 // IsDifferent (const Standard_ExtString other ) const
1054 //assert( d.IsDifferent( a.ToExtString() ));
1055 QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1057 // IsDifferent (const TCollection_ExtendedString& other) const
1058 //assert( d.IsDifferent( a ));
1059 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
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 );
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 );
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 );
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 );
1126 // ==========================
1127 //TCollection_HAsciiString::
1128 // ==========================
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 );
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 );
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 );
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 );
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 );
1171 #include <Geom_CylindricalSurface.hxx>
1172 #include <IntTools_FaceFace.hxx>
1173 #include <IntTools_Curve.hxx>
1174 #include <IntTools_PntOn2Faces.hxx>
1176 static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1180 theDI << "Wrong a number of arguments!\n";
1184 Handle(Geom_Plane) plane(new Geom_Plane(
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));
1195 DrawTrSurf::Set("pln", plane);
1197 DrawTrSurf::Set("cyl", cylinder);
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);
1208 if (!anInters.IsDone())
1210 theDI<<"No intersections found!"<<"\n";
1215 //Handle(Geom_Curve) aResult;
1218 const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1219 const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1222 Standard_Integer aNbCurves, aNbPoints;
1224 aNbCurves=aCvsX.Length();
1225 aNbPoints=aPntsX.Length();
1229 for (Standard_Integer i=1; i<=aNbCurves; ++i)
1231 Sprintf(buf, "%s_%d",theArgv[1],i);
1232 theDI << buf << " ";
1234 const IntTools_Curve& aIC = aCvsX(i);
1235 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1236 DrawTrSurf::Set(buf,aC3D);
1239 else if (aNbCurves == 1)
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);
1248 for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1250 const IntTools_PntOn2Faces& aPi=aPntsX(i);
1251 const gp_Pnt& aP=aPi.P1().Pnt();
1253 Sprintf(buf,"%s_p_%d",theArgv[1],i);
1254 theDI << buf << " ";
1255 DrawTrSurf::Set(buf, aP);
1261 #include <BRepAlgo_NormalProjection.hxx>
1262 static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1265 di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)";
1269 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1270 if(myAISContext.IsNull()) {
1271 di << "use 'vinit' command before " << argv[0] << "\n";
1275 TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1]));
1276 TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2]));
1278 BRepAlgo_NormalProjection anormpro(m_Face1);
1279 anormpro.Add(m_Edge);
1280 anormpro.SetDefaultParams();
1282 //anormpro.Compute3d();
1283 //anormpro.SetLimit();
1287 if (anormpro.IsDone())
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);
1298 #include <Voxel_FastConverter.hxx>
1299 static Standard_Integer OCC24051 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1302 di << "Usage : " << argv[0] << " should be one argument (command name only)";
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);
1316 #pragma omp parallel for
1317 for(int i = 0; i < nbThreads; i++)
1318 fcp.ConvertUsingSAT(progress, i+1);
1321 fcp.ConvertUsingSAT(progress);
1326 #include <BRepFeat_SplitShape.hxx>
1327 #include <ShapeAnalysis_ShapeContents.hxx>
1328 #include <BRepAlgo.hxx>
1329 static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1332 di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)";
1336 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1337 if(myAISContext.IsNull()) {
1338 di << "use 'vinit' command before " << argv[0] << "\n";
1342 TopoDS_Shape result;
1343 TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1]));
1344 TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2]));
1346 BRepFeat_SplitShape asplit(face);
1347 asplit.Add(wire, face);
1349 result = asplit.Shape();
1350 ShapeAnalysis_ShapeContents ana;
1351 ana.Perform(result);
1354 if (!(BRepAlgo::IsValid(result))) {
1355 di << "Result was checked and it is INVALID" << "\n";
1357 di << "Result was checked and it is VALID" << "\n";
1360 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result);
1361 myAISContext->Display(myShape, Standard_True);
1366 #include <Geom_Circle.hxx>
1367 #include <GeomAdaptor_Curve.hxx>
1368 #include <Extrema_ExtPC.hxx>
1369 #include <gp_Cylinder.hxx>
1370 #include <ElSLib.hxx>
1371 static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1374 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
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 );
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";
1388 // Result of deviation
1389 gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() );
1390 gp_Cylinder aCylinder( aCylAxis, 1890. );
1392 Standard_Real aU = 0., aV = 0.;
1393 ElSLib::Parameters( aCylinder, aProj, aU, aV );
1394 di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n";
1399 #include <Extrema_FuncExtPS.hxx>
1400 #include <math_FunctionSetRoot.hxx>
1401 #include <math_Vector.hxx>
1402 #include <BRepBuilderAPI_MakeVertex.hxx>
1403 static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1405 Standard_Integer anArgIter = 1;
1408 theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]"<<"\n";
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)
1422 std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1425 if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1427 std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1430 const TopoDS_Face aFace = TopoDS::Face (aShapeF);
1431 const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1432 GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1434 gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1436 Extrema_FuncExtPS anExtFunc;
1437 math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
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;
1445 anExtFunc.Initialize (aSurf);
1446 anExtFunc.SetPoint (aPnt);
1447 aRoot.SetTolerance (aTolUV);
1448 aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1449 if (!aRoot.IsDone())
1451 std::cerr << "No results!\n";
1455 theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1457 aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1458 DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1462 //! Check boolean operations on NCollection_Map
1463 static Standard_Integer OCC24271 (Draw_Interpretor& di,
1464 Standard_Integer /*theArgNb*/,
1465 const char** /*theArgVec*/)
1468 const Standard_Integer aLeftLower = 1;
1469 const Standard_Integer aLeftUpper = 10;
1470 const Standard_Integer aRightLower = 5;
1471 const Standard_Integer aRightUpper = 15;
1474 NCollection_Map<Standard_Integer> aMapLeft;
1475 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1477 aMapLeft.Add (aKeyIter);
1480 NCollection_Map<Standard_Integer> aMapRight;
1481 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1483 aMapRight.Add (aKeyIter);
1486 QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1487 QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False);
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)
1495 QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
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)
1504 QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1506 QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1507 QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
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)
1515 QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
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)
1523 QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
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)
1532 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1534 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1536 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1539 // validate Exchange operation
1540 NCollection_Map<Standard_Integer> aMapSwap;
1541 aMapSwap.Exchange (aMapSect);
1542 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1544 QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1546 QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1550 NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1551 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1552 aMapCopy.Remove (34);
1554 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1559 #define QVERIFY(val1) \
1560 di << "Checking " #val1 " == Standard_True" << \
1561 ((val1) == Standard_True ? ": OK\n" : ": Error\n")
1563 #include <GeomInt_IntSS.hxx>
1564 #include <Geom_ConicalSurface.hxx>
1565 #include <Standard_ErrorHandler.hxx>
1566 //=======================================================================
1567 //function : OCC23972
1569 //=======================================================================
1570 static void DoGeomIntSSTest (const Handle(Geom_Surface)& theSurf1,
1571 const Handle(Geom_Surface)& theSurf2,
1572 const Standard_Integer theNbSol,
1573 Draw_Interpretor& di)
1577 GeomInt_IntSS anInter;
1578 anInter.Perform (theSurf1, theSurf2, Precision::Confusion(), Standard_True);
1579 QVERIFY (anInter.IsDone());
1580 QCOMPARE (anInter.NbLines(), theNbSol);
1582 QVERIFY (Standard_False);
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)
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);
1601 static Standard_Integer OCC23972 (Draw_Interpretor& di,Standard_Integer n, const char**)
1603 if (n != 1) return 1;
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),
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),
1622 DoGeomIntSSTest (aS1, aS2, 2, di);
1627 #include <ShapeFix_EdgeProjAux.hxx>
1628 static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1631 di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n";
1635 TopoDS_Shape aSh = DBRep::Get(argv[1]);
1637 di << argv[0] << " Error: Null input edge\n";
1640 const TopoDS_Edge& anEdge = TopoDS::Edge (aSh);
1642 Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]);
1644 di << argv[0] << " Error: Null input curve\n";
1648 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]);
1650 di << argv[0] << " Error: Null input surface\n";
1654 Standard_Real prec = Draw::Atof(argv[4]);
1659 aB.MakeFace (aFace, aS, Precision::Confusion());
1660 aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion());
1661 aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter());
1664 ShapeFix_EdgeProjAux aProj (aFace, anEdge);
1665 aProj.Compute (prec);
1667 Standard_Boolean isfirstdone = aProj.IsFirstDone();
1668 Standard_Boolean islastdone = aProj.IsLastDone();
1670 Standard_Real first = 0.;
1671 Standard_Real last = 0.;
1672 Standard_Integer isfirstdoneInteger = 0;
1673 Standard_Integer islastdoneInteger = 0;
1677 first = aProj.FirstParam();
1678 isfirstdoneInteger = 1;
1682 last= aProj.LastParam();
1683 islastdoneInteger = 1;
1686 di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n";
1691 template<typename T, typename HT>
1692 static void DoIsNull(Draw_Interpretor& di)
1695 // QVERIFY (aHandle.IsNull());
1696 QCOMPARE (aHandle.IsNull(), Standard_True);
1697 const T* p = aHandle.Access();
1698 #if OCC_VERSION_HEX > 0x060700
1701 QCOMPARE (!p, Standard_True);
1702 QCOMPARE (p == 0, Standard_True);
1706 //QVERIFY (!aHandle.IsNull());
1707 QCOMPARE (!aHandle.IsNull(), Standard_True);
1708 p = aHandle.Access();
1711 QCOMPARE (p != NULL, Standard_True);
1712 QCOMPARE (p != 0, Standard_True);
1715 //=======================================================================
1716 //function : OCC24533
1718 //=======================================================================
1719 static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**)
1721 if (n != 1) return 1;
1723 DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di);
1724 DoIsNull<Standard_Persistent, Handle(Standard_Persistent)>(di);
1729 // Dummy class to test interface for compilation issues
1730 class QABugs_HandleClass : public Standard_Transient
1733 Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1735 std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n";
1738 DEFINE_STANDARD_RTTI(QABugs_HandleClass) // Type definition
1740 DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1741 IMPLEMENT_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1742 IMPLEMENT_STANDARD_RTTIEXT(QABugs_HandleClass, Standard_Transient)
1744 // Dummy class to test interface for compilation issues
1745 struct QABugs_NHandleClass
1747 Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1749 std::cerr << "QABugs_NHandleClass[" << this << "] " << "" << theArgVec[0] << "\n";
1754 #include <XCAFDoc_ColorTool.hxx>
1755 #include <STEPControl_StepModelType.hxx>
1756 #include <STEPCAFControl_Writer.hxx>
1757 static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1760 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
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");
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);
1773 STEPControl_StepModelType mode = STEPControl_AsIs;
1774 STEPCAFControl_Writer writer;
1775 if ( ! writer.Transfer (aDoc, mode ) )
1777 di << "The document cannot be translated or gives no result" << "\n";
1781 writer.Write("test_box.step");
1786 //=======================================================================
1787 //function : OCC23950
1789 //=======================================================================
1790 static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1793 di << "Usage : " << argv[0] << " step_file\n";
1797 Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy");
1798 TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
1800 TopLoc_Location location0 (t0);
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");
1806 TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1807 TDataStd_Name::Set(labelA0, "ASSEMBLY");
1809 TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
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);
1815 STEPControl_StepModelType mode = STEPControl_AsIs;
1816 STEPCAFControl_Writer writer;
1817 if (! writer.Transfer (aDoc, mode))
1819 di << "The document cannot be translated or gives no result" << "\n";
1823 writer.Write (argv[1]);
1827 //=======================================================================
1828 //function : OCC24622
1829 //purpose : The command tests sourcing Image_PixMap to AIS_TexturedShape
1830 //=======================================================================
1831 static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
1835 std::cout << "Usage : " << theArgVec[0] << " texture={1D|2D}";
1839 const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
1840 if (anAISContext.IsNull())
1842 std::cout << "Please initialize view with \"vinit\".\n";
1846 Handle(Image_PixMap) anImage = new Image_PixMap();
1848 static const Image_ColorRGB aBitmap[8] =
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}}
1854 TCollection_AsciiString aTextureTypeArg (theArgVec[1]);
1855 aTextureTypeArg.UpperCase();
1856 if (aTextureTypeArg == "1D")
1858 anImage->InitWrapper (Image_PixMap::ImgRGB, (Standard_Byte*)aBitmap, 8, 1);
1860 else if (aTextureTypeArg == "2D")
1862 anImage->InitTrash (Image_PixMap::ImgRGB, 8, 8);
1863 for (Standard_Integer aRow = 0; aRow < 8; ++aRow)
1865 for (Standard_Integer aCol = 0; aCol < 8; ++aCol)
1867 anImage->ChangeValue<Image_ColorRGB> (aRow, aCol) = aBitmap[aRow];
1873 std::cout << "Please specify type of texture to test {1D|2D}.\n";
1877 TopoDS_Shape aBlankShape = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
1879 Handle(AIS_TexturedShape) aTexturedShape = new AIS_TexturedShape (aBlankShape);
1880 aTexturedShape->SetTexturePixMap (anImage);
1881 anAISContext->Display (aTexturedShape, 3, 0);
1886 //=======================================================================
1887 //function : OCC24667
1889 //=======================================================================
1890 static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a)
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";
1902 if (n > 1 && n < 4) return 1;
1904 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
1905 if ( Spine.IsNull()) return 1;
1907 TopoDS_Shape Profile = DBRep::Get(a[3]);
1908 if ( Profile.IsNull()) return 1;
1910 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
1913 Standard_Integer iMode = atoi(a[4]);
1915 Mode = GeomFill_IsFrenet;
1916 else if (iMode == 2)
1917 Mode = GeomFill_IsDiscreteTrihedron;
1920 Standard_Boolean ForceApproxC1 = Standard_False;
1922 ForceApproxC1 = Standard_True;
1924 BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine),
1929 TopoDS_Shape S = aPipe.Shape();
1930 TopoDS_Shape aSF = aPipe.FirstShape();
1931 TopoDS_Shape aSL = aPipe.LastShape();
1935 TCollection_AsciiString aStrF(a[1], "_f");
1936 TCollection_AsciiString aStrL(a[1], "_l");
1938 DBRep::Set(aStrF.ToCString(), aSF);
1939 DBRep::Set(aStrL.ToCString(), aSL);
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>
1959 static Standard_Integer OCC24565 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1962 di << "Usage : " << argv[0] << " FileNameIGS FileNameSTOR";
1966 Standard_CString sFileNameIGS = argv[1];
1967 Standard_CString sFileNameSTOR = argv[2];
1969 IGESControl_Reader ICReader;
1972 * Read the IGES file and make sure it is valid
1975 IGESControl_Controller::Init();
1977 if (!ICReader.ReadFile(sFileNameIGS)) {
1978 printf("%s:%d - Error reading '%s'\n",__FUNCTION__,__LINE__,sFileNameIGS);fflush(stdout);
1982 int nbShapes = ICReader.NbShapes();
1984 printf("%s:%d - nbShapes = '%d'\n",__FUNCTION__,__LINE__,nbShapes);fflush(stdout);
1989 Handle(TColStd_HSequenceOfTransient) faces=ICReader.GiveList("iges-faces");
1990 Handle(TColStd_HSequenceOfTransient) surfaceList=ICReader.GiveList("xst-transferrable-roots",faces);
1992 if (surfaceList.IsNull())
1994 printf("%s:%d - surfaceList.IsNull()\n",__FUNCTION__,__LINE__);fflush(stdout);
1997 BRep_Builder builder;
1998 TopoDS_Compound* pC = new TopoDS_Compound();
1999 builder.MakeCompound(*pC);
2001 for (int j=1;j<=surfaceList->Length();j++)
2003 Handle(IGESData_IGESEntity) igesEntity=Handle(IGESData_IGESEntity)::DownCast(surfaceList->Value(j));
2004 if (igesEntity.IsNull()) continue;
2005 ICReader.ClearShapes();
2006 Standard_Boolean rv;
2008 rv=ICReader.TransferEntity(igesEntity);
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);
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);
2029 printf("%s:%d - NULL Surface encountered\n",__FUNCTION__,__LINE__);
2039 printf("%s: Exception adding face.\n",__FUNCTION__);
2042 Shape = TopoDS_Shape(*pC);
2046 Shape = ICReader.OneShape();
2049 BRepCheck_Analyzer brca(Shape);
2053 printf("%s: Invalid shape after reading IGES file.\n",__FUNCTION__);
2058 * Write the contents of the Shape to a STOR file
2061 PTColStd_TransientPersistentMap aMapTP;
2062 Handle(PTopoDS_HShape) aPShape_write;
2063 Handle(Storage_Data) d_write=new Storage_Data;
2070 for (i=0,Ex.Init(Shape,TopAbs_FACE);Ex.More();i++,Ex.Next())
2075 aPShape_write=MgtBRep::Translate(Ex.Current(),aMapTP,MgtBRep_WithoutTriangle);
2078 printf("%s: Error translating surface '%d'\n",__FUNCTION__,i);
2081 sprintf(Name,"S%010d",i);
2084 BRepCheck_Analyzer brca(Ex.Current());
2087 printf("INVALID face '%s' in the shape, which will be written to the STOR file.\n",Name);
2091 d_write->AddRoot(Name,aPShape_write);
2094 printf("%s: Error adding surface '%d', RootName = '%s'\n",__FUNCTION__,i,Name);
2097 printf("%s: Going to write %d surfaces.\n",__FUNCTION__,max_i+1);
2100 if(f_write.Open(sFileNameSTOR, Storage_VSWrite)!=Storage_VSOk)
2102 printf("%s: Error opening file: %s\n", __FUNCTION__,sFileNameSTOR);
2105 Handle(ShapeSchema) s_write=new ShapeSchema;
2106 s_write->Write(f_write,d_write);
2108 printf("%s: Wrote to the STOR file.\n",__FUNCTION__);
2111 * Read the contents of the Shape from a STOR file
2115 if(f_read.Open(sFileNameSTOR, Storage_VSRead)!=Storage_VSOk)
2117 printf("%s: Error opening file: %s\n", __FUNCTION__,sFileNameSTOR);
2120 Handle(ShapeSchema) s_read=new ShapeSchema;
2121 Handle(Storage_Data) d_read=s_read->Read(f_read);
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;
2129 printf("%s: Extracting %d faces from the STOR file.\n",__FUNCTION__,max_i+1);
2130 for(int i = 0; i <= max_i; ++i)
2132 sprintf(Name,"S%010d",i);
2133 r=d_read->Find(Name);
2136 printf("%s:%d '%s' IsNull().\n",__FUNCTION__,__LINE__,Name);fflush(stdout);
2140 aPShape_read = Handle(PTopoDS_HShape)::DownCast(p);
2142 MgtBRep::Translate(aPShape_read,aMapPT,S_read,MgtBRep_WithoutTriangle);
2144 catch (Standard_Failure) {
2145 Handle(Standard_Failure) E=Standard_Failure::Caught();
2148 str+=E->DynamicType()->Name();
2150 str+=E->GetMessageString();
2151 printf("%s(1): %s: %s\n",__FUNCTION__,Name,str.c_str());fflush(stdout);
2154 printf("%s(1): Unhandled exception in MgtBRep::Translate\n",__FUNCTION__);
2157 BRepCheck_Analyzer brca(S_read);
2161 printf("%s: Read INVALID face (%s)!\n",__FUNCTION__,Name);
2165 printf("Completed.\n");fflush(stdout);
2170 #include <Handle_BRepTools_NurbsConvertModification.hxx>
2171 #include <BRepPrimAPI_MakeCylinder.hxx>
2172 #include <BRepBuilderAPI_Copy.hxx>
2173 #include <BRepTools_NurbsConvertModification.hxx>
2174 static TopoDS_Shape CreateTestShape (int& theShapeNb)
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);
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();
2192 aShape = CreateTestShape (theShapeNb);
2194 aBuilder.Add (aComp, aShape);
2199 #include <AppStd_Application.hxx>
2200 #include <TDataStd_Integer.hxx>
2201 #include <TNaming_Builder.hxx>
2202 static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2205 di << "Usage: " << argv[0] << " invalid number of arguments"<<"\n";
2208 TCollection_ExtendedString aFileName ("testdocument.xml");
2209 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2211 Handle(TDocStd_Application) anApp = new AppStd_Application;
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);
2222 aSStatus = anApp->SaveAs (aDoc, aFileName);
2223 anApp->Close (aDoc);
2225 QCOMPARE (aSStatus, PCDM_SS_OK);
2229 #include <AppStdL_Application.hxx>
2230 #include <TDocStd_Application.hxx>
2231 #include <TDataStd_Integer.hxx>
2232 #include <TDF_AttributeIterator.hxx>
2233 //=======================================================================
2234 //function : OCC24755
2236 //=======================================================================
2237 static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2241 std::cout << "Usage : " << a[0] << "\n";
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");
2252 TDF_AttributeIterator i (aLab);
2253 Handle(TDF_Attribute) anAttr = i.Value();
2254 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True);
2257 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True);
2264 MyStubObject() : ptr(0L) {}
2265 MyStubObject(void* thePtr) : ptr(thePtr) {}
2270 //=======================================================================
2271 //function : OCC24834
2273 //=======================================================================
2274 static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2278 std::cout << "Usage : " << a[0] << "\n";
2282 int i = sizeof (char*);
2284 std::cout << "64-bit architecture is not supported.\n";
2288 NCollection_List<MyStubObject> aList;
2289 const Standard_Integer aSmallBlockSize = 40;
2290 const Standard_Integer aLargeBlockSize = 1500000;
2292 // quick populate memory with large blocks
2297 aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize)));
2300 catch (Standard_Failure)
2302 di << "caught out of memory for large blocks: OK\n";
2306 di << "skept out of memory for large blocks: Error\n";
2309 // allocate small blocks
2314 aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize)));
2317 catch (Standard_Failure)
2319 di << "caught out of memory for small blocks: OK\n";
2323 di << "skept out of memory for small blocks: Error\n";
2326 // release all allocated blocks
2327 for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next())
2329 Standard::Free(it.Value().ptr);
2335 #include <Geom2dAPI_InterCurveCurve.hxx>
2336 #include <IntRes2d_IntersectionPoint.hxx>
2337 //=======================================================================
2338 //function : OCC24889
2340 //=======================================================================
2341 static Standard_Integer OCC24889 (Draw_Interpretor& theDI,
2342 Standard_Integer /*theNArg*/,
2343 const char** /*theArgs*/)
2346 Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle(
2347 gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2349 Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle(
2350 gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2352 Handle( Geom2d_TrimmedCurve ) aTrim[2] = {
2353 new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ),
2354 new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 )
2357 DrawTrSurf::Set("c_1", aTrim[0]);
2358 DrawTrSurf::Set("c_2", aTrim[1]);
2361 const Standard_Real aTol = Precision::Confusion();
2362 Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol );
2364 const IntRes2d_IntersectionPoint& aIntPnt =
2365 aIntTool.Intersector().Point( 1 );
2367 gp_Pnt2d aIntRes = aIntTool.Point( 1 );
2368 Standard_Real aPar[2] = {
2369 aIntPnt.ParamOnFirst(),
2370 aIntPnt.ParamOnSecond()
2373 //theDI.precision( 5 );
2374 theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n";
2375 for (int i = 0; i < 2; ++i)
2377 theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() <<
2378 "; LastParam = " << aTrim[i]->LastParameter() <<
2379 "; IntParameter = " << aPar[i] << "\n";
2385 #include <math_GlobOptMin.hxx>
2386 #include <math_MultipleVarFunctionWithHessian.hxx>
2387 //=======================================================================
2388 //function : OCC25004
2389 //purpose : Check extremaCC on Branin function.
2390 //=======================================================================
2392 // f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s
2393 // Standard borders are:
2396 class BraninFunction : public math_MultipleVarFunctionWithHessian
2402 b = 5.1 / (4.0 * M_PI * M_PI);
2406 t = 1.0 / (8.0 * M_PI);
2408 virtual Standard_Integer NbVariables() const
2412 virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F)
2414 Standard_Real u = X(1);
2415 Standard_Real v = X(2);
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;
2422 virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G)
2424 Standard_Real u = X(1);
2425 Standard_Real v = X(2);
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;
2431 return Standard_True;
2433 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
2438 return Standard_True;
2440 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H)
2445 Standard_Real u = X(1);
2446 Standard_Real v = X(2);
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;
2455 return Standard_True;
2459 // Standard parameters.
2460 Standard_Real a, b, c, r, s, t;
2463 static Standard_Integer OCC25004 (Draw_Interpretor& theDI,
2464 Standard_Integer /*theNArg*/,
2465 const char** /*theArgs*/)
2467 math_MultipleVarFunction* aFunc = new BraninFunction();
2469 math_Vector aLower(1,2), aUpper(1,2);
2475 Standard_Integer aGridOrder = 16;
2476 math_Vector aFuncValues(1, aGridOrder * aGridOrder);
2478 Standard_Real aLipConst = 0;
2479 math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2);
2481 // Get Lipshitz constant estimation on regular grid.
2482 Standard_Integer i, j, idx = 1;
2483 for(i = 1; i <= aGridOrder; i++)
2485 for(j = 1; j <= aGridOrder; j++)
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);
2490 aFunc->Value(aCurrPnt1, aFuncValues(idx));
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++)
2502 if (i == k && j == l)
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;
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;
2513 aCurrPnt1.Add(-aCurrPnt2);
2514 Standard_Real dist = aCurrPnt1.Norm();
2516 Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist;
2521 math_GlobOptMin aFinder(aFunc, aLower, aUpper, aLipConst);
2523 //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475)
2525 Standard_Real anExtValue = aFinder.GetF();
2526 theDI << "F = " << anExtValue << "\n";
2528 Standard_Integer aNbExt = aFinder.NbExtrema();
2529 theDI << "NbExtrema = " << aNbExt << "\n";
2534 #include <OSD_Environment.hxx>
2535 #include <Plugin.hxx>
2536 #include <Plugin_Macro.hxx>
2537 #include <Resource_Manager.hxx>
2539 #define THE_QATEST_DOC_FORMAT "My Proprietary Format"
2541 #define QA_CHECK(theDesc, theExpr, theValue) \
2543 const bool isTrue = !!(theExpr); \
2544 std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \
2547 class Test_TDocStd_Application : public TDocStd_Application
2551 static void initGlobalPluginMap (const TCollection_AsciiString& thePlugin,
2552 const TCollection_AsciiString& theSaver,
2553 const TCollection_AsciiString& theLoader)
2555 const Handle(Resource_Manager)& aManager = Plugin::AdditionalPluginMap();
2556 aManager->SetResource ((theSaver + ".Location").ToCString(), thePlugin.ToCString());
2557 aManager->SetResource ((theLoader + ".Location").ToCString(), thePlugin.ToCString());
2560 Test_TDocStd_Application (const TCollection_AsciiString& thePlugin,
2561 const TCollection_AsciiString& theSaver,
2562 const TCollection_AsciiString& theLoader)
2564 initGlobalPluginMap (thePlugin, theSaver, theLoader);
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());
2575 virtual Standard_CString ResourcesName() { return ""; }
2576 virtual void Formats (TColStd_SequenceOfExtendedString& theFormats) { theFormats.Clear(); }
2579 //=======================================================================
2580 //function : OCC24925
2582 //=======================================================================
2583 static Standard_Integer OCC24925 (Draw_Interpretor& theDI,
2584 Standard_Integer theArgNb,
2585 const char** theArgVec)
2590 std::cout << "Error: wrong syntax! See usage:\n";
2591 theDI.PrintHelp (theArgVec[0]);
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)
2602 aPlugin = theArgVec[anArgIter++];
2603 aSaver = theArgVec[anArgIter++];
2604 aLoader = theArgVec[anArgIter++];
2607 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2608 PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError;
2610 Handle(TDocStd_Application) anApp = new Test_TDocStd_Application (aPlugin, aSaver, aLoader);
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");
2618 aSStatus = anApp->SaveAs (aDoc, aFileName);
2619 anApp->Close (aDoc);
2621 QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true);
2624 Handle(TDocStd_Document) aDoc;
2625 aRStatus = anApp->Open (aFileName, aDoc);
2626 anApp->Close (aDoc);
2628 QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true);
2632 //=======================================================================
2633 //function : OCC25043
2635 //=======================================================================
2636 #include <BRepAlgoAPI_Check.hxx>
2637 static Standard_Integer OCC25043 (Draw_Interpretor& theDI,
2638 Standard_Integer theArgNb,
2639 const char** theArgVec)
2641 if (theArgNb != 2) {
2642 theDI << "Usage: " << theArgVec[0] << " shape\n";
2646 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
2647 if (aShape.IsNull())
2649 theDI << theArgVec[1] << " shape is NULL\n";
2653 BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True);
2655 if (!anAlgoApiCheck.IsValid())
2657 BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result());
2658 for (; anCheckIter.More(); anCheckIter.Next())
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())
2665 const TopoDS_Shape& aFaultyShape = aFaultyIter.Value();
2667 Standard_Boolean anIsFaultyShapeFound = Standard_False;
2668 TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType());
2669 for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next())
2671 if (anExp.Current().IsEqual(aFaultyShape))
2672 anIsFaultyShapeFound = Standard_True;
2675 if (!anIsFaultyShapeFound)
2677 theDI << "Error. Faulty Shape is NOT found in source shape.\n";
2682 theDI << "Info. Faulty shape if found in source shape\n";
2689 theDI << "Error. Problems are not detected. Test is not performed.";
2695 //=======================================================================
2696 //function : OCC24606
2698 //=======================================================================
2699 static Standard_Integer OCC24606 (Draw_Interpretor& theDI,
2700 Standard_Integer theArgNb,
2701 const char** theArgVec)
2705 std::cerr << "Error: incorrect number of arguments.\n";
2706 theDI << "Usage : " << theArgVec[0] << "\n";
2710 Handle(V3d_View) aView = ViewerTest::CurrentView();
2713 std::cerr << "Errro: no active view, please call 'vinit'.\n";
2717 aView->DepthFitAll();
2723 //=======================================================================
2724 //function : OCC23010
2726 //=======================================================================
2727 #include <STEPCAFControl_Reader.hxx>
2729 class mOcafApplication : public TDocStd_Application
2731 void Formats(TColStd_SequenceOfExtendedString& Formats)
2733 Formats.Append(TCollection_ExtendedString("mOcafApplication"));
2735 Standard_CString ResourcesName()
2737 return Standard_CString("Resources");
2741 static Standard_Integer OCC23010 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2744 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
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)
2755 stepReader.SetColorMode(Standard_True);
2756 stepReader.SetLayerMode(Standard_True);
2757 stepReader.SetNameMode(Standard_True);
2758 stepReader.Transfer(doc); // ERROR HERE!!!
2763 //=======================================================================
2764 //function : OCC25202
2766 //=======================================================================
2767 #include <ShapeBuild_ReShape.hxx>
2768 static Standard_Integer OCC25202 ( Draw_Interpretor& theDI,
2769 Standard_Integer theArgN,
2770 const char** theArgVal)
2773 //reshape res shape numF1 face1 numF2 face2
2776 theDI << "Use: reshape res shape numF1 face1 numF2 face2\n";
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]));
2788 theDI << theArgVal[2] << " is null shape\n";
2792 if(aShapeForRepl1.IsNull())
2794 theDI << theArgVal[4] << " is not a replaced type\n";
2798 if(aShapeForRepl2.IsNull())
2800 theDI << theArgVal[6] << " is not a replaced type\n";
2805 TopoDS_Shape aReplacedShape;
2806 ShapeBuild_ReShape aReshape;
2808 //////////////////// explode (begin)
2809 TopTools_MapOfShape M;
2811 Standard_Integer aNbShapes = 0;
2812 for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next())
2814 const TopoDS_Shape& Sx = ex.Current();
2815 Standard_Boolean added = M.Add(Sx);
2819 if(aNbShapes == aNumOfRE1)
2821 aReplacedShape = Sx;
2823 aReshape.Replace(aReplacedShape, aShapeForRepl1);
2826 if(aNbShapes == aNumOfRE2)
2828 aReplacedShape = Sx;
2830 aReshape.Replace(aReplacedShape, aShapeForRepl2);
2834 //////////////////// explode (end)
2836 if(aReplacedShape.IsNull())
2838 theDI << "There is not any shape for replacing.\n";
2841 DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2));
2846 #include <ShapeFix_Wireframe.hxx>
2847 //=======================================================================
2848 //function : OCC7570
2850 //=======================================================================
2851 static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2854 di<<"Usage: "<<a[0]<<" invalid number of arguments"<<"\n";
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 ();
2867 #include <AIS_TypeFilter.hxx>
2868 //=======================================================================
2869 //function : OCC25340
2871 //=======================================================================
2872 static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/,
2873 Standard_Integer /*theArgNb*/,
2874 const char** /*theArgVec*/)
2876 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2879 std::cerr << "Error: No opened viewer!\n";
2882 Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
2883 aCtx->AddFilter (aFilter);
2887 //=======================================================================
2888 //function : OCC24826
2890 //=======================================================================
2891 class ParallelTest_Saxpy
2894 typedef NCollection_Array1<Standard_Real> Vector;
2897 ParallelTest_Saxpy(const Vector& theX, Vector& theY, Standard_Real theScalar)
2904 //! Dummy calculation
2905 void operator() (const Standard_Integer theIndex) const
2907 myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex);
2911 ParallelTest_Saxpy( const ParallelTest_Saxpy& );
2912 ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& );
2917 const Standard_Real myScalar;
2920 //---------------------------------------------------------------------
2921 static Standard_Integer OCC24826(Draw_Interpretor& theDI,
2922 Standard_Integer trheArgc,
2923 const char** theArgv)
2925 if ( trheArgc != 2 )
2934 Standard_Integer aLength = Draw::Atoi(theArgv[1]);
2936 NCollection_Array1<Standard_Real> aX (0, aLength - 1);
2937 NCollection_Array1<Standard_Real> anY(0, aLength - 1);
2939 for ( Standard_Integer i = 0; i < aLength; ++i )
2941 aX(i) = anY(i) = (Standard_Real) i;
2948 //! Serial proccesing
2949 for ( Standard_Integer i = 0; i < aLength; ++i )
2951 anY(i) = 1e-6 * aX(i) + anY(i);
2955 cout << "Processing time (sequential mode):\n";
2958 const ParallelTest_Saxpy aFunctor(aX, anY, 1e-6);
2963 // Parallel processing
2964 OSD_Parallel::For(0, aLength, aFunctor);
2967 cout << "Processing time (parallel mode):\n";
2973 /*****************************************************************************/
2975 #include <GeomAPI_IntSS.hxx>
2976 //=======================================================================
2977 //function : OCC25100
2979 //=======================================================================
2980 static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2984 di << "the method requires a shape name\n";
2988 TopoDS_Shape S = DBRep::Get(argv[1]);
2991 di << "Shape is empty" << "\n";
2995 TopExp_Explorer aFaceExp(S, TopAbs_FACE);
2996 const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current()));
2998 GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion());
3000 if (!anIntersector.IsDone())
3002 di << "Error. Intersection is not done\n";
3006 di << "Test complete\n";
3011 //=======================================================================
3012 //function : OCC25348
3014 //=======================================================================
3015 static Standard_Integer OCC25348 (Draw_Interpretor& theDI,
3016 Standard_Integer /*theArgNb*/,
3017 const char** /*theArgVec*/)
3019 Handle(NCollection_IncAllocator) anAlloc1;
3020 NCollection_List<int> aList1(anAlloc1);
3021 for (int i=0; i < 10; i++)
3023 Handle(NCollection_IncAllocator) anAlloc2;
3024 NCollection_List<int> aList2(anAlloc2);
3026 aList1.Assign(aList2);
3028 theDI << "Test complete\n";
3032 #include <IntCurvesFace_ShapeIntersector.hxx>
3033 #include <BRepBndLib.hxx>
3034 //=======================================================================
3035 //function : OCC25413
3037 //=======================================================================
3038 static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
3041 di << "Usage: " << a[0] << " invalid number of arguments" << "\n";
3044 TopoDS_Shape aShape = DBRep::Get (a[1]);
3046 IntCurvesFace_ShapeIntersector Inter;
3047 Inter.Load(aShape, Precision::Confusion());
3050 BRepBndLib::Add(aShape, aBndBox);
3052 gp_Dir aDir(0., 1., 0.);
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;
3061 for (Standard_Real x = xMin; x <= xMax; x += xStep)
3062 for (Standard_Real z = zMin; z <= zMax; z += zStep)
3064 gp_Pnt aPoint(x, 0.0, z);
3065 gp_Lin aLine(aPoint, aDir);
3066 Inter.PerformNearest(aLine, -100., 100.);
3072 #include <BOPAlgo_PaveFiller.hxx>
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>
3080 #include <BOPTools.hxx>
3082 #include <BOPCol_MapOfShape.hxx>
3083 #include <BOPCol_ListOfShape.hxx>
3084 //=======================================================================
3085 //function : OCC25446
3087 //=======================================================================
3088 static Standard_Integer OCC25446 (Draw_Interpretor& theDI,
3089 Standard_Integer argc,
3093 theDI << "Usage: OCC25446 res b1 b2 op\n";
3097 TopoDS_Shape aS1 = DBRep::Get(argv[2]);
3099 theDI << argv[2] << " shape is NULL\n";
3103 TopoDS_Shape aS2 = DBRep::Get(argv[3]);
3105 theDI << argv[3] << " shape is NULL\n";
3109 Standard_Integer iOp;
3110 BOPAlgo_Operation aOp;
3112 iOp = Draw::Atoi(argv[4]);
3113 if (iOp < 0 || iOp > 4) {
3114 theDI << "Invalid operation type\n";
3117 aOp = (BOPAlgo_Operation)iOp;
3119 Standard_Integer iErr;
3120 BOPCol_ListOfShape aLS;
3121 BOPAlgo_PaveFiller aPF;
3125 aPF.SetArguments(aLS);
3128 iErr = aPF.ErrorStatus();
3130 theDI << "Intersection failed with error status: " << iErr << "\n";
3134 BRepAlgoAPI_BooleanOperation* pBuilder = NULL;
3137 case BOPAlgo_COMMON:
3138 pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF);
3141 pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
3144 pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF);
3147 pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
3149 case BOPAlgo_SECTION:
3150 pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF);
3156 iErr = pBuilder->ErrorStatus();
3157 if (!pBuilder->IsDone()) {
3158 theDI << "BOP failed with error status: " << iErr << "\n";
3162 const TopoDS_Shape& aRes = pBuilder->Shape();
3163 DBRep::Set(argv[1], aRes);
3165 BOPCol_MapOfShape aMapArgs, aMapShape;
3166 BOPCol_MapIteratorOfMapOfShape aIt;
3167 Standard_Boolean bIsDeletedHist, bIsDeletedMap;
3168 TopAbs_ShapeEnum aType;
3170 BOPTools::MapShapes(aS1, aMapArgs);
3171 BOPTools::MapShapes(aS2, aMapArgs);
3172 BOPTools::MapShapes(aRes, aMapShape);
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)) {
3183 bIsDeletedHist = pBuilder->IsDeleted(aS);
3184 bIsDeletedMap = !aMapShape.Contains(aS) &&
3185 (pBuilder->Modified(aS).Extent() == 0);
3187 if (bIsDeletedHist != bIsDeletedMap) {
3188 theDI << "Error. Wrong value of IsDeleted flag.\n";
3193 theDI << "Test complete\n";
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 //====================================================
3203 struct OCC25545_Functor
3205 OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
3206 : myShapeVec(&theShapeVec),
3210 void operator()(size_t i) const
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);
3221 const std::vector<TopoDS_Shape>* myShapeVec;
3222 mutable volatile int myIsRaceDetected;
3225 //=======================================================================
3226 //function : OCC25545
3227 //purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation()
3228 //=======================================================================
3230 static Standard_Integer OCC25545 (Draw_Interpretor& di,
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.
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) {
3243 aT.SetTranslation (gp_Vec (1, 0, 0));
3244 aLocVec[i] = aLocVec[i - 1] * aT;
3245 aShapeVec[i] = aShape.Moved (aLocVec[i]);
3248 // Evaluator function will access vertices geometry
3250 OCC25545_Functor aFunc(aShapeVec);
3252 //concurrently process
3253 tbb::parallel_for (size_t (0), n, aFunc, tbb::simple_partitioner ());
3254 QVERIFY (!aFunc.myIsRaceDetected);
3258 static Standard_Integer OCC25545 (Draw_Interpretor&,
3262 cout << "Test skipped: command " << argv[0] << " requires TBB library" << endl;
3267 //=======================================================================
3268 //function : OCC25547
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>
3277 static Standard_Integer OCC25547(
3278 Draw_Interpretor& theDI,
3279 Standard_Integer /*argc*/,
3280 const char ** /*argv*/)
3282 // The general aim of this test is to prevent linkage errors due to missed
3283 // Standard_EXPORT attribute for static methods.
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);
3293 if (aGeomTool.NbPoints() == 0)
3295 theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
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);
3306 if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
3308 theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
3312 gp_XY aRefPnts[4] = {
3313 gp_XY(-10., -10.), gp_XY(10., 10.),
3314 gp_XY(-10., 10.), gp_XY(10., -10.)
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);
3323 Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
3324 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3326 theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
3330 aIntFlag = BRepMesh_GeomTool::IntSegSeg(
3331 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3332 Standard_False, Standard_False, aIntPnt);
3334 aDiff = aIntPnt.Distance(gp::Origin2d());
3335 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3337 theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
3342 theDI << "Test complete\n";
3346 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
3347 const char *group = "QABugs";
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);
3356 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
3357 theCommands.Add ("OCC142", "OCC142", __FILE__, OCC142, group);
3358 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
3359 theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
3360 theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
3361 theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
3362 theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
3363 theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
3364 theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
3365 theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
3366 theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
3367 theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
3368 theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
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);
3370 theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
3371 theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group);
3372 theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
3373 theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
3374 theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
3375 theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
3376 theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group);
3377 theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group);
3378 theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group);
3379 theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group);
3380 theCommands.Add ("OCC24051", "OCC24051", __FILE__, OCC24051, group);
3381 theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group);
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);
3384 theCommands.Add ("OCC24565", "OCC24565 FileNameIGS FileNameSTOR", __FILE__, OCC24565, group);
3385 theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group);
3386 theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group);
3387 theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group);
3388 theCommands.Add ("OCC23951", "OCC23951", __FILE__, OCC23951, group);
3389 theCommands.Add ("OCC24931", "OCC24931", __FILE__, OCC24931, group);
3390 theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group);
3391 theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
3392 theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group);
3393 theCommands.Add ("OCC24925",
3394 "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]"
3395 "\nOCAF persistence without setting environment variables",
3396 __FILE__, OCC24925, group);
3397 theCommands.Add ("OCC23010", "OCC23010 STEP_file", __FILE__, OCC23010, group);
3398 theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group);
3399 theCommands.Add ("OCC24826,", "This test performs simple saxpy test.\n Usage: OCC24826 length", __FILE__, OCC24826, group);
3400 theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group);
3401 theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group);
3402 theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
3403 theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
3404 theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group);
3405 theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group);
3406 theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
3407 theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
3408 theCommands.Add ("OCC25545",
3409 "no args; tests data race when concurrently accessing \n"
3410 "\t\tTopLoc_Location::Transformation()",
3411 __FILE__, OCC25545, group);
3412 theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);