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>
381 struct GeomConvertTest_Data
383 Standard_Integer nbupoles;
384 Handle(Geom_Surface) surf;
387 static Standard_Address GeomConvertTest (Standard_Address data)
389 GeomConvertTest_Data* info = (GeomConvertTest_Data*)data;
391 GeomConvert_ApproxSurface aGAS (info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
392 if (!aGAS.IsDone()) {
393 cout << "Error: ApproxSurface is not done!" << endl;
394 return Standard_False;
396 const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
397 if (aBSurf.IsNull()) {
398 cout << "Error: BSplineSurface is not created!" << endl;
399 return Standard_False;
401 cout << "Number of UPoles:" << aBSurf->NbUPoles();
402 if (aBSurf->NbUPoles() == info->nbupoles)
404 cout << ": OK" << endl;
405 return data; // any non-null pointer
409 cout << ": Error, must be " << info->nbupoles << endl;
414 static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
417 cout << "Error: invalid number of arguments" << endl;
421 struct GeomConvertTest_Data aStorage;
422 aStorage.nbupoles = Draw::Atoi(argv[1]);
423 aStorage.surf = DrawTrSurf::GetSurface(argv[2]);
424 if (aStorage.surf.IsNull())
426 cout << "Error: " << argv[2] << " is not a DRAW surface!" << endl;
430 // start conversion in several threads
431 const int NBTHREADS = 100;
432 OSD_Thread aThread[NBTHREADS];
433 for (int i=0; i < NBTHREADS; i++)
435 aThread[i].SetFunction (GeomConvertTest);
436 if (!aThread[i].Run(&aStorage))
437 di << "Error: Cannot start thread << " << i << "\n";
441 for (int i=0; i < NBTHREADS; i++)
443 Standard_Address aResult = 0;
444 if (!aThread[i].Wait(aResult))
445 di << "Error: Failed waiting for thread << " << i << "\n";
447 di << "Error: wrong number of poles in thread " << i << "!\n";
453 #include <GeomInt_IntSS.hxx>
455 struct GeomIntSSTest_Data
457 Standard_Integer nbsol;
458 Handle(Geom_Surface) surf1, surf2;
461 static Standard_Address GeomIntSSTest (Standard_Address data)
463 GeomIntSSTest_Data* info = (GeomIntSSTest_Data*)data;
464 GeomInt_IntSS anInter;
465 anInter.Perform (info->surf1, info->surf2, Precision::Confusion(), Standard_True);
466 if (!anInter.IsDone()) {
467 cout << "An intersection is not done!" << endl;
471 cout << "Number of Lines:" << anInter.NbLines();
472 if (anInter.NbLines() == info->nbsol)
474 cout << ": OK" << endl;
475 return data; // any non-null pointer
479 cout << ": Error, must be " << info->nbsol << endl;
484 static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
487 cout << "Error: invalid number of arguments" << endl;
491 struct GeomIntSSTest_Data aStorage;
492 aStorage.nbsol = Draw::Atoi(argv[1]);
493 aStorage.surf1 = DrawTrSurf::GetSurface(argv[2]);
494 aStorage.surf2 = DrawTrSurf::GetSurface(argv[3]);
495 if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull())
497 cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" << endl;
501 // start conversion in several threads
502 const int NBTHREADS = 100;
503 OSD_Thread aThread[NBTHREADS];
504 for (int i=0; i < NBTHREADS; i++)
506 aThread[i].SetFunction (GeomIntSSTest);
507 if (!aThread[i].Run(&aStorage))
508 di << "Error: Cannot start thread << " << i << "\n";
512 for (int i=0; i < NBTHREADS; i++)
514 Standard_Address aResult = 0;
515 if (!aThread[i].Wait(aResult))
516 di << "Error: Failed waiting for thread << " << i << "\n";
518 di << "Error: wrong number of intersections in thread " << i << "!\n";
524 #include <Geom_SurfaceOfRevolution.hxx>
525 static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
528 di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n";
532 Standard_Integer ucontinuity = 1;
533 Standard_Integer vcontinuity = 1;
534 Standard_Boolean iscnu = false;
535 Standard_Boolean iscnv = false;
537 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
539 QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
540 QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
545 #include <gp_Ax1.hxx>
546 #include <gp_Ax22d.hxx>
547 #include <Geom_Plane.hxx>
548 #include <Geom2d_Circle.hxx>
549 #include <Geom2d_TrimmedCurve.hxx>
550 #include <BRepBuilderAPI_MakeEdge.hxx>
551 #include <BRepPrimAPI_MakeRevol.hxx>
552 #include <Geom2d_OffsetCurve.hxx>
554 static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
556 // Check the command arguments
559 di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
560 di << "Usage: type help " << argv[0] << "\n";
561 return 1; // TCL_ERROR
564 gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
565 gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
566 Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
568 di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>" << "\n";
569 di << "-----------------------------------------------------------------------" << "\n";
571 Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
572 Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
573 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
575 DBRep::Set("e1", E1);
577 BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
578 TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
580 DBRep::Set("f1", F1);
582 di << "Result: f1" << "\n";
584 di << "<<<< Preparing sample surface of revolution based on offset curve >>>>" << "\n";
585 di << "-----------------------------------------------------------------------" << "\n";
587 Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
588 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
590 DBRep::Set("e2", E2);
592 BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
593 TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
595 DBRep::Set("f2", F2);
597 di << "Result: f2" << "\n";
602 #include <Geom_Curve.hxx>
603 #include <Geom_Surface.hxx>
604 #include <Precision.hxx>
605 #include <ShapeConstruct_ProjectCurveOnSurface.hxx>
606 //=======================================================================
607 //function : OCC24008
609 //=======================================================================
610 static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
613 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
616 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]);
617 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]);
618 if (aCurve.IsNull()) {
619 di << "Curve was not read" << "\n";
622 if (aSurf.IsNull()) {
623 di << "Surface was not read" << "\n";
626 ShapeConstruct_ProjectCurveOnSurface aProj;
627 aProj.Init (aSurf, Precision::Confusion());
629 Handle(Geom2d_Curve) aPCurve;
630 aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve);
631 if (aPCurve.IsNull()) {
632 di << "PCurve was not created" << "\n";
636 di << "Exception was caught" << "\n";
641 #include <GeomAdaptor_Surface.hxx>
643 //=======================================================================
644 //function : OCC23945
646 //=======================================================================
648 static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
652 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
653 if (aS.IsNull()) return 1;
655 GeomAdaptor_Surface GS(aS);
657 Standard_Real U = Draw::Atof(a[2]);
658 Standard_Real V = Draw::Atof(a[3]);
660 Standard_Boolean DrawPoint = ( n%3 == 2);
668 GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
669 Draw::Set(a[13],D2U.X());
670 Draw::Set(a[14],D2U.Y());
671 Draw::Set(a[15],D2U.Z());
672 Draw::Set(a[16],D2V.X());
673 Draw::Set(a[17],D2V.Y());
674 Draw::Set(a[18],D2V.Z());
675 Draw::Set(a[19],D2UV.X());
676 Draw::Set(a[20],D2UV.Y());
677 Draw::Set(a[21],D2UV.Z());
682 Draw::Set(a[7],DU.X());
683 Draw::Set(a[8],DU.Y());
684 Draw::Set(a[9],DU.Z());
685 Draw::Set(a[10],DV.X());
686 Draw::Set(a[11],DV.Y());
687 Draw::Set(a[12],DV.Z());
693 Draw::Set(a[4],P.X());
694 Draw::Set(a[5],P.Y());
695 Draw::Set(a[6],P.Z());
698 DrawTrSurf::Set(a[n],P);
704 #include <Voxel_BoolDS.hxx>
705 #include <Voxel_FastConverter.hxx>
706 #include <Voxel_BooleanOperation.hxx>
707 static Standard_Integer OCC24019 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
710 di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
714 TCollection_AsciiString aFileName = argv[1];
716 BRep_Builder aBuilder;
718 if (!BRepTools::Read(aShape, aFileName.ToCString(), aBuilder)) {
719 di << "Error: Could not read a shape!" << "\n";
723 TopoDS_Solid aShape1 = BRepPrimAPI_MakeSphere(gp_Pnt(20,25,35), 7);
725 Standard_Real deflection = 0.005;
726 Standard_Integer nbThreads = 1;
727 Standard_Integer nbx = 200, nby = 200, nbz = 200;
728 Voxel_BoolDS theVoxels(0,0,0, 50, 50, 50, nbx, nby, nbz);
729 Voxel_BoolDS theVoxels1(0,0,0, 50, 50, 50, nbx, nby, nbz);
731 Standard_Integer progress = 0;
732 Voxel_FastConverter fcp(aShape, theVoxels, deflection, nbx, nby, nbz, nbThreads);
733 fcp.ConvertUsingSAT(progress, 1);
736 Voxel_FastConverter fcp1(aShape1, theVoxels1, deflection, nbx, nby, nbz, nbThreads);
737 fcp1.ConvertUsingSAT(progress, 1);
738 fcp1.FillInVolume(1);
740 Voxel_BooleanOperation op;
741 Standard_Boolean result = op.Cut(theVoxels1, theVoxels);
743 di << "Error: invalid boolean operation" << "\n";
745 di << "OK: boolean operation is ok" << "\n";
751 //=======================================================================
752 //function : OCC11758
754 //=======================================================================
755 static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
757 if (n != 1) return 1;
759 const char* theStr = "0123456789";
760 Standard_Integer i, j;
761 for ( i = 0; i < 5; ++i ) {
762 // TCollection_AsciiString(const Standard_CString astring)
763 TCollection_AsciiString a(theStr+i);
764 // IsEqual (const Standard_CString other)const
765 //assert( a == theStr+i );
766 QCOMPARE ( a , theStr+i );
768 //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen )
769 TCollection_AsciiString b(theStr+i, 3);
770 //assert( b.Length() == 3 );
771 //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 );
772 //assert( strlen( b.ToCString() ) == 3 );
773 QCOMPARE ( b.Length() , 3 );
774 QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 );
775 QCOMPARE ( b.Length() , 3 );
777 //TCollection_AsciiString(const Standard_Integer aValue)
778 TCollection_AsciiString c(i);
779 //assert( c.IsIntegerValue() );
780 //assert( c.IntegerValue() == i );
781 QCOMPARE ( c.IsIntegerValue() , Standard_True );
782 QCOMPARE ( c.IntegerValue() , i );
784 //TCollection_AsciiString(const Standard_Real aValue)
785 TCollection_AsciiString d( 0.1*i );
786 //assert( d.IsRealValue() );
787 //assert( TCollection_AsciiString(3.3) == "3.3");
788 QCOMPARE ( d.IsRealValue() , Standard_True );
789 QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" );
791 //TCollection_AsciiString(const TCollection_AsciiString& astring)
792 TCollection_AsciiString e(d);
794 //assert( e.Length() == d.Length() );
795 //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
797 QCOMPARE ( e.Length() , d.Length() );
798 QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
800 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
801 // const Standard_Character other )
802 TCollection_AsciiString f(e,'\a');
803 //assert( f.Length() == e.Length() + 1 );
804 //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 );
805 //assert( f.Value( f.Length() ) == '\a');
806 QCOMPARE ( f.Length() , e.Length() + 1 );
807 QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 );
808 QCOMPARE ( f.Value( f.Length() ) , '\a' );
810 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
811 // const Standard_CString other )
812 TCollection_AsciiString g(f, theStr);
813 //assert( g.Length() == f.Length() + strlen( theStr ));
814 //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 );
815 //assert( g.Search( theStr ) == f.Length() + 1 );
816 QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) );
817 QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 );
818 QCOMPARE ( g.Search( theStr ) , f.Length() + 1 );
820 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
821 // const TCollection_AsciiString& other )
822 TCollection_AsciiString h(d,a);
823 //assert( h.Length() == d.Length() + a.Length() );
824 //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 );
825 //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 );
826 QCOMPARE ( h.Length() , d.Length() + a.Length() );
827 QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 );
828 QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 );
830 // AssignCat(const Standard_CString other)
831 c.AssignCat( a.ToCString() );
832 //assert( c.Length() == 1 + a.Length() );
833 //assert( c.Search( a ) == 2 );
834 QCOMPARE ( c.Length() , 1 + a.Length() );
835 QCOMPARE ( c.Search( a ) , 2 );
837 // AssignCat(const TCollection_AsciiString& other)
838 Standard_Integer dl = d.Length();
840 //assert( d.Length() == dl + a.Length() );
841 //assert( d.Search( a ) == dl + 1 );
842 QCOMPARE ( d.Length() , dl + a.Length() );
843 QCOMPARE ( d.Search( a ) , dl + 1 );
846 TCollection_AsciiString capitalize("aBC");
847 capitalize.Capitalize();
848 //assert( capitalize == "Abc" );
849 QCOMPARE ( capitalize , "Abc" );
851 // Copy(const Standard_CString fromwhere)
853 //assert( d == theStr+i );
854 QCOMPARE ( d , theStr+i );
856 // Copy(const TCollection_AsciiString& fromwhere)
858 // IsEqual (const TCollection_AsciiString& other)const
862 // Insert(const Standard_Integer where, const Standard_CString what)
864 d.Insert( 2, theStr );
865 //assert( d.Length() == dl + strlen( theStr ));
866 //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 );
867 QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) );
868 QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 );
870 //Insert(const Standard_Integer where,const Standard_Character what)
872 d.Insert( i+1, 'i' );
873 //assert( d.Length() == strlen( theStr ) + 1 );
874 //assert( d.Value( i+1 ) == 'i');
875 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
876 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
877 QCOMPARE ( d.Value( i+1 ) , 'i' );
878 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
880 //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
882 d.Insert( i+1, TCollection_AsciiString( "i" ));
883 //assert( d.Length() == strlen( theStr ) + 1 );
884 //assert( d.Value( i+1 ) == 'i');
885 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
886 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
887 QCOMPARE ( d.Value( i+1 ) , 'i' );
888 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
890 // IsDifferent (const Standard_CString other)const
891 //assert( d.IsDifferent( theStr ));
892 //assert( d.IsDifferent( "theStr" ));
893 //assert( d.IsDifferent( "" ));
894 //assert( !d.IsDifferent( d.ToCString() ));
895 QCOMPARE ( d.IsDifferent( theStr ) , Standard_True );
896 QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True );
897 QCOMPARE ( d.IsDifferent( "" ) , Standard_True );
898 QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True );
900 // IsDifferent (const TCollection_AsciiString& other)const
901 //assert( d.IsDifferent( TCollection_AsciiString() ));
902 //assert( d.IsDifferent( a ));
903 //assert( d.IsDifferent( h ));
904 //assert( !d.IsDifferent( d ));
905 QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True );
906 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
907 QCOMPARE ( d.IsDifferent( h ) , Standard_True );
908 QCOMPARE ( !d.IsDifferent( d ) , Standard_True );
910 // IsLess (const Standard_CString other)const
911 //assert( TCollection_AsciiString ("0"). IsLess("1"));
912 //assert( TCollection_AsciiString ("0"). IsLess("00"));
913 //assert( TCollection_AsciiString (""). IsLess("0"));
914 //assert( !TCollection_AsciiString("1"). IsLess("0"));
915 //assert( !TCollection_AsciiString("00").IsLess("0"));
916 //assert( !TCollection_AsciiString("0"). IsLess(""));
917 //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1));
918 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True );
919 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True );
920 QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True );
921 QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True );
922 QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True );
923 QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True );
924 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True );
926 // IsLess (const TCollection_AsciiString& other)const
927 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )));
928 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")));
929 //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )));
930 //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )));
931 //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )));
932 //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )));
933 //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)));
934 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True );
935 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True );
936 QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True );
937 QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True );
938 QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True );
939 QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True );
940 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True );
942 // IsGreater (const Standard_CString other)const
943 //assert( !TCollection_AsciiString("0"). IsGreater("1"));
944 //assert( !TCollection_AsciiString("0"). IsGreater("00"));
945 //assert( !TCollection_AsciiString(""). IsGreater("0"));
946 //assert( TCollection_AsciiString ("1"). IsGreater("0"));
947 //assert( TCollection_AsciiString ("00").IsGreater("0"));
948 //assert( TCollection_AsciiString ("0"). IsGreater(""));
949 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i));
950 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True );
951 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True );
952 QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True );
953 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True );
954 QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True );
955 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True );
956 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True );
958 // IsGreater (const TCollection_AsciiString& other)const
959 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )));
960 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")));
961 //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )));
962 //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )));
963 //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )));
964 //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )));
965 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)));
966 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True );
967 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True );
968 QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
969 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
970 QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True );
971 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True );
972 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True );
974 // void Read(Standard_IStream& astream)
975 std::istringstream is( theStr );
977 //assert( e == theStr );
978 QCOMPARE ( e , theStr );
980 // Standard_Integer SearchFromEnd (const Standard_CString what)const
981 //assert( e.SearchFromEnd( theStr + i ) == i + 1 );
982 QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 );
984 // SetValue(const Standard_Integer where, const Standard_CString what)
985 e.SetValue( i+1, "what");
986 //assert( e.Search( "what" ) == i+1 );
987 //assert( e.Length() == strlen( theStr ));
988 QCOMPARE ( e.Search( "what" ) , i+1 );
989 QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) );
991 // TCollection_AsciiString Split (const Standard_Integer where)
994 //assert( d.Length() + e.Length() == strlen( theStr ));
995 QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
997 // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
998 // const Standard_Integer ToIndex) const
1000 d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 );
1001 //assert( d.Length() == 3 );
1002 //assert( d.Value(1) == theStr[ i ]);
1003 QCOMPARE ( d.Length() , 3 );
1004 QCOMPARE ( d.Value(1) , theStr[ i ] );
1006 // TCollection_AsciiString Token (const Standard_CString separators,
1007 // const Standard_Integer whichone) const
1009 for ( j = 0; j < i; ++j ) {
1010 e += TCollection_AsciiString( theStr[j] ) + " ";
1011 //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 ));
1012 QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) );
1015 for ( i = 0; i < 5; ++i )
1017 // TCollection_ExtendedString (const Standard_CString astring,
1018 // const Standard_Boolean isMultiByte)
1019 const TCollection_ExtendedString a( theStr+i );
1020 //assert( TCollection_AsciiString( a ) == theStr+i );
1021 QCOMPARE ( TCollection_AsciiString( a ) , theStr+i );
1023 //TCollection_ExtendedString (const Standard_ExtString astring)
1024 const TCollection_ExtendedString b( a.ToExtString() );
1028 // TCollection_ExtendedString (const Standard_Integer length,
1029 // const Standard_ExtCharacter filler )
1030 const TCollection_ExtendedString c( i, 1 );
1031 //assert( c.Length() == i );
1032 QCOMPARE ( c.Length() , i );
1033 if ( c.Length() > 0 ) {
1034 //assert( c.Value( i ) == 1 );
1035 QCOMPARE ( c.Value( i ) , 1 );
1038 // TCollection_ExtendedString (const Standard_Integer aValue)
1039 TCollection_ExtendedString d( i );
1040 const TCollection_AsciiString da( d );
1041 //assert( da.IsIntegerValue() );
1042 //assert( da.IntegerValue() == i );
1043 QCOMPARE ( da.IsIntegerValue() , Standard_True );
1044 QCOMPARE ( da.IntegerValue(), i );
1046 // TCollection_ExtendedString (const Standard_Real aValue)
1047 const TCollection_ExtendedString e( 0.1 * i );
1048 const TCollection_AsciiString ea( e );
1049 //assert( ea.IsRealValue() );
1050 //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 );
1051 QCOMPARE ( ea.IsRealValue() , Standard_True );
1052 QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True );
1054 // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1055 const TCollection_ExtendedString f(e);
1056 //assert( f.Length() == e.Length());
1058 QCOMPARE ( f.Length() , e.Length() );
1061 // TCollection_ExtendedString (const TCollection_AsciiString& astring)
1062 const TCollection_ExtendedString g( ea );
1063 //assert( g.Length() == ea.Length() );
1064 //assert( TCollection_AsciiString( g ) == ea );
1065 QCOMPARE ( g.Length() , ea.Length() );
1066 QCOMPARE ( TCollection_AsciiString( g ) , ea );
1068 // AssignCat (const TCollection_ExtendedString& other)
1069 const TCollection_ExtendedString sep(",");
1072 //assert( d.Length() == 2 + g.Length() );
1073 //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i ));
1074 //assert( d.Token( sep.ToExtString(), 2 ) == g );
1075 QCOMPARE ( d.Length() , 2 + g.Length() );
1076 QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) );
1077 QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g );
1079 // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const
1080 const TCollection_ExtendedString cat = a.Cat( sep );
1081 //assert( cat.Length() == a.Length() + sep.Length() );
1082 //assert( cat.Search( a ) == 1 );
1083 //assert( cat.Search( sep ) == a.Length() + 1 );
1084 QCOMPARE ( cat.Length() , a.Length() + sep.Length() );
1085 QCOMPARE ( cat.Search( a ) , 1 );
1086 QCOMPARE ( cat.Search( sep ) , a.Length() + 1 );
1088 // Copy (const TCollection_ExtendedString& fromwhere)
1090 //assert( d.Length() == cat.Length() );
1091 //assert( d == cat );
1092 QCOMPARE ( d.Length() , cat.Length() );
1093 QCOMPARE ( d , cat );
1095 // IsEqual (const Standard_ExtString other) const
1096 //assert( d.IsEqual( d.ToExtString() ));
1097 QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1099 // IsDifferent (const Standard_ExtString other ) const
1100 //assert( d.IsDifferent( a.ToExtString() ));
1101 QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1103 // IsDifferent (const TCollection_ExtendedString& other) const
1104 //assert( d.IsDifferent( a ));
1105 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
1107 // IsLess (const Standard_ExtString other) const
1108 const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1);
1109 //assert( l0. IsLess( l1.ToExtString() ));
1110 //assert( l0. IsLess( l00.ToExtString() ));
1111 //assert( l. IsLess( l0.ToExtString() ));
1112 //assert( ! l1. IsLess( l0.ToExtString() ));
1113 //assert( ! l00.IsLess( l0.ToExtString() ));
1114 //assert( ! l0. IsLess( l.ToExtString() ));
1115 //assert( ls.IsLess( ls1.ToExtString() ));
1116 QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True );
1117 QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True );
1118 QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True );
1119 QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True );
1120 QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True );
1121 QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True );
1122 QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True );
1124 // IsLess (const TCollection_ExtendedString& other) const
1125 //assert( l0. IsLess( l1 ));
1126 //assert( l0. IsLess( l00 ));
1127 //assert( l. IsLess( l0 ));
1128 //assert( ! l1. IsLess( l0 ));
1129 //assert( ! l00.IsLess( l0 ));
1130 //assert( ! l0. IsLess( l ));
1131 //assert( ls.IsLess( ls1 ));
1132 QCOMPARE ( l0. IsLess( l1 ) , Standard_True );
1133 QCOMPARE ( l0. IsLess( l00 ) , Standard_True );
1134 QCOMPARE ( l. IsLess( l0 ) , Standard_True );
1135 QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True );
1136 QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True );
1137 QCOMPARE ( ! l0. IsLess( l ) , Standard_True );
1138 QCOMPARE ( ls.IsLess( ls1 ) , Standard_True );
1140 // IsGreater (const Standard_ExtString other) const
1141 //assert( ! l0.IsGreater( l1.ToExtString() ));
1142 //assert( ! l0.IsGreater( l00.ToExtString() ));
1143 //assert( ! l. IsGreater( l0.ToExtString() ));
1144 //assert( l1. IsGreater( l0.ToExtString() ));
1145 //assert( l00.IsGreater( l0.ToExtString() ));
1146 //assert( l0. IsGreater( l.ToExtString() ));
1147 //assert( ls1.IsGreater( ls.ToExtString() ));
1148 QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True );
1149 QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True );
1150 QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True );
1151 QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True );
1152 QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True );
1153 QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True );
1154 QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True );
1156 // IsGreater (const TCollection_ExtendedString& other) const
1157 //assert( ! l0.IsGreater( l1));
1158 //assert( ! l0.IsGreater( l00));
1159 //assert( ! l. IsGreater( l0));
1160 //assert( l1. IsGreater( l0));
1161 //assert( l00.IsGreater( l0));
1162 //assert( l0. IsGreater( l));
1163 //assert( ls1.IsGreater( ls));
1164 QCOMPARE ( ! l0.IsGreater( l1) , Standard_True );
1165 QCOMPARE ( ! l0.IsGreater( l00) , Standard_True );
1166 QCOMPARE ( ! l. IsGreater( l0) , Standard_True );
1167 QCOMPARE ( l1. IsGreater( l0) , Standard_True );
1168 QCOMPARE ( l00.IsGreater( l0) , Standard_True );
1169 QCOMPARE ( l0. IsGreater( l) , Standard_True );
1170 QCOMPARE ( ls1.IsGreater( ls) , Standard_True );
1172 // ==========================
1173 //TCollection_HAsciiString::
1174 // ==========================
1176 // IsDifferent(const Handle(TCollection_HAsciiString)& S)
1177 Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i );
1178 Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 );
1179 //assert( ha1->IsDifferent( ha2 ));
1180 //assert( !ha1->IsDifferent( ha1 ));
1181 QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True );
1182 QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True );
1184 // IsSameString (const Handle(TCollection_HAsciiString)& S)
1185 //assert( !ha1->IsSameString( ha2 ));
1186 //assert( ha1->IsSameString( ha1 ));
1187 QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True );
1188 QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True );
1190 // IsSameState (const Handle(TCollection_HAsciiString)& other) const
1191 //assert( !ha1->IsSameState( ha2 ));
1192 //assert( ha1->IsSameState( ha1 ));
1193 QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True );
1194 QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True );
1196 // IsSameString (const Handle(TCollection_HAsciiString)& S ,
1197 // const Standard_Boolean CaseSensitive) const
1198 //assert( !ha1->IsSameString( ha2, true ));
1199 //assert( ha1->IsSameString( ha1, true ));
1200 //assert( !ha1->IsSameString( ha2, false ));
1201 //assert( ha1->IsSameString( ha1, false ));
1202 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1203 QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True );
1204 QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True );
1205 QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True );
1207 ha1->SetValue( 1, "AbC0000000");
1208 ha2->SetValue( 1, "aBc0000000");
1209 //assert( !ha1->IsSameString( ha2, true ));
1210 //assert( ha1->IsSameString( ha2, false ));
1211 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1212 QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True );
1217 #include <Geom_CylindricalSurface.hxx>
1218 #include <IntTools_FaceFace.hxx>
1219 #include <IntTools_Curve.hxx>
1220 #include <IntTools_PntOn2Faces.hxx>
1222 static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1226 theDI << "Wrong a number of arguments!\n";
1230 Handle(Geom_Plane) plane(new Geom_Plane(
1231 gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
1232 gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
1233 gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000))));
1234 Handle(Geom_CylindricalSurface) cylinder(
1235 new Geom_CylindricalSurface(
1236 gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
1237 gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
1238 gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
1239 19.712534607908712));
1241 DrawTrSurf::Set("pln", plane);
1243 DrawTrSurf::Set("cyl", cylinder);
1246 BRep_Builder builder;
1247 TopoDS_Face face1, face2;
1248 builder.MakeFace(face1, plane, Precision::Confusion());
1249 builder.MakeFace(face2, cylinder, Precision::Confusion());
1250 IntTools_FaceFace anInters;
1251 anInters.SetParameters(false, true, true, Precision::Confusion());
1252 anInters.Perform(face1, face2);
1254 if (!anInters.IsDone())
1256 theDI<<"No intersections found!"<<"\n";
1261 //Handle(Geom_Curve) aResult;
1264 const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1265 const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1268 Standard_Integer aNbCurves, aNbPoints;
1270 aNbCurves=aCvsX.Length();
1271 aNbPoints=aPntsX.Length();
1275 for (Standard_Integer i=1; i<=aNbCurves; ++i)
1277 Sprintf(buf, "%s_%d",theArgv[1],i);
1278 theDI << buf << " ";
1280 const IntTools_Curve& aIC = aCvsX(i);
1281 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1282 DrawTrSurf::Set(buf,aC3D);
1285 else if (aNbCurves == 1)
1287 const IntTools_Curve& aIC = aCvsX(1);
1288 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1289 Sprintf(buf, "%s",theArgv[1]);
1290 theDI << buf << " ";
1291 DrawTrSurf::Set(buf,aC3D);
1294 for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1296 const IntTools_PntOn2Faces& aPi=aPntsX(i);
1297 const gp_Pnt& aP=aPi.P1().Pnt();
1299 Sprintf(buf,"%s_p_%d",theArgv[1],i);
1300 theDI << buf << " ";
1301 DrawTrSurf::Set(buf, aP);
1307 #include <BRepAlgo_NormalProjection.hxx>
1308 static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1311 di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)";
1315 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1316 if(myAISContext.IsNull()) {
1317 di << "use 'vinit' command before " << argv[0] << "\n";
1321 TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1]));
1322 TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2]));
1324 BRepAlgo_NormalProjection anormpro(m_Face1);
1325 anormpro.Add(m_Edge);
1326 anormpro.SetDefaultParams();
1328 //anormpro.Compute3d();
1329 //anormpro.SetLimit();
1333 if (anormpro.IsDone())
1335 TopoDS_Shape rshape = anormpro.Projection();
1336 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape);
1337 myAISContext->SetColor(myShape, Quantity_Color(Quantity_NOC_YELLOW));
1338 myAISContext->Display(myShape, Standard_True);
1344 #include <Voxel_FastConverter.hxx>
1345 static Standard_Integer OCC24051 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1348 di << "Usage : " << argv[0] << " should be one argument (command name only)";
1352 TopoDS_Shape shape = BRepPrimAPI_MakeBox(gp_Pnt(5, 10, 10), 10, 20, 30).Shape();
1353 Standard_Integer progress = 0;
1354 Standard_Real deflection = 0.005;
1355 Standard_Integer nbx = 200, nby = 200, nbz = 200;
1356 Voxel_BoolDS theVoxels(-50,-50,-30, 100, 100, 100, nbx, nby, nbz);
1357 Voxel_BoolDS theVoxels1(-50,-50,-30, 100, 100, 100, nbx, nby, nbz);
1358 Standard_Integer nbThreads = 5;
1359 Voxel_FastConverter fcp(shape, theVoxels, deflection, nbx, nby, nbz, nbThreads, Standard_True);
1362 #pragma omp parallel for
1363 for(int i = 0; i < nbThreads; i++)
1364 fcp.ConvertUsingSAT(progress, i+1);
1367 fcp.ConvertUsingSAT(progress);
1372 #include <BRepFeat_SplitShape.hxx>
1373 #include <ShapeAnalysis_ShapeContents.hxx>
1374 #include <BRepAlgo.hxx>
1375 static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1378 di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)";
1382 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1383 if(myAISContext.IsNull()) {
1384 di << "use 'vinit' command before " << argv[0] << "\n";
1388 TopoDS_Shape result;
1389 TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1]));
1390 TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2]));
1392 BRepFeat_SplitShape asplit(face);
1393 asplit.Add(wire, face);
1395 result = asplit.Shape();
1396 ShapeAnalysis_ShapeContents ana;
1397 ana.Perform(result);
1400 if (!(BRepAlgo::IsValid(result))) {
1401 di << "Result was checked and it is INVALID" << "\n";
1403 di << "Result was checked and it is VALID" << "\n";
1406 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result);
1407 myAISContext->Display(myShape, Standard_True);
1412 #include <Geom_Circle.hxx>
1413 #include <GeomAdaptor_Curve.hxx>
1414 #include <Extrema_ExtPC.hxx>
1415 #include <gp_Cylinder.hxx>
1416 #include <ElSLib.hxx>
1417 static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1420 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
1424 gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 );
1425 gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() );
1426 Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 );
1427 GeomAdaptor_Curve aC3D( aCircle );
1429 Extrema_ExtPC aExtPC( aP3D, aC3D );
1430 //Standard_Real aParam = (aExtPC.Point(1)).Parameter();
1431 gp_Pnt aProj = (aExtPC.Point(1)).Value();
1432 di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n";
1434 // Result of deviation
1435 gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() );
1436 gp_Cylinder aCylinder( aCylAxis, 1890. );
1438 Standard_Real aU = 0., aV = 0.;
1439 ElSLib::Parameters( aCylinder, aProj, aU, aV );
1440 di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n";
1445 #include <Extrema_FuncExtPS.hxx>
1446 #include <math_FunctionSetRoot.hxx>
1447 #include <math_Vector.hxx>
1448 #include <BRepBuilderAPI_MakeVertex.hxx>
1449 static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1451 Standard_Integer anArgIter = 1;
1454 theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]"<<"\n";
1459 Standard_CString aFaceName = theArgv[anArgIter++];
1460 Standard_CString aVertName = theArgv[anArgIter++];
1461 const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
1462 const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
1463 const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
1464 const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
1465 const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
1466 if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
1468 std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1471 if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1473 std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1476 const TopoDS_Face aFace = TopoDS::Face (aShapeF);
1477 const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1478 GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1480 gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1482 Extrema_FuncExtPS anExtFunc;
1483 math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
1485 math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2);
1486 aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion();
1487 aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite();
1488 aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite();
1489 aFromUV(1) = aUFrom; aFromUV(2) = aVFrom;
1491 anExtFunc.Initialize (aSurf);
1492 anExtFunc.SetPoint (aPnt);
1493 aRoot.SetTolerance (aTolUV);
1494 aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1495 if (!aRoot.IsDone())
1497 std::cerr << "No results!\n";
1501 theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1503 aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1504 DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1508 //! Check boolean operations on NCollection_Map
1509 static Standard_Integer OCC24271 (Draw_Interpretor& di,
1510 Standard_Integer /*theArgNb*/,
1511 const char** /*theArgVec*/)
1514 const Standard_Integer aLeftLower = 1;
1515 const Standard_Integer aLeftUpper = 10;
1516 const Standard_Integer aRightLower = 5;
1517 const Standard_Integer aRightUpper = 15;
1520 NCollection_Map<Standard_Integer> aMapLeft;
1521 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1523 aMapLeft.Add (aKeyIter);
1526 NCollection_Map<Standard_Integer> aMapRight;
1527 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1529 aMapRight.Add (aKeyIter);
1532 QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1533 QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False);
1535 // validate Union operation
1536 NCollection_Map<Standard_Integer> aMapUnion;
1537 aMapUnion.Union (aMapLeft, aMapRight);
1538 QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1);
1539 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter)
1541 QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
1544 // validate Intersection operation
1545 NCollection_Map<Standard_Integer> aMapSect;
1546 aMapSect.Intersection (aMapLeft, aMapRight);
1547 QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1);
1548 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1550 QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1552 QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1553 QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
1555 // validate Substruction operation
1556 NCollection_Map<Standard_Integer> aMapSubsLR;
1557 aMapSubsLR.Subtraction (aMapLeft, aMapRight);
1558 QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower);
1559 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1561 QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
1564 NCollection_Map<Standard_Integer> aMapSubsRL;
1565 aMapSubsRL.Subtraction (aMapRight, aMapLeft);
1566 QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper);
1567 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1569 QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
1572 // validate Difference operation
1573 NCollection_Map<Standard_Integer> aMapDiff;
1574 aMapDiff.Difference (aMapLeft, aMapRight);
1575 QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper);
1576 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1578 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1580 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1582 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1585 // validate Exchange operation
1586 NCollection_Map<Standard_Integer> aMapSwap;
1587 aMapSwap.Exchange (aMapSect);
1588 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1590 QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1592 QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1596 NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1597 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1598 aMapCopy.Remove (34);
1600 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1605 #define QVERIFY(val1) \
1606 di << "Checking " #val1 " == Standard_True" << \
1607 ((val1) == Standard_True ? ": OK\n" : ": Error\n")
1609 #include <GeomInt_IntSS.hxx>
1610 #include <Geom_ConicalSurface.hxx>
1611 #include <Standard_ErrorHandler.hxx>
1612 //=======================================================================
1613 //function : OCC23972
1615 //=======================================================================
1616 static void DoGeomIntSSTest (const Handle(Geom_Surface)& theSurf1,
1617 const Handle(Geom_Surface)& theSurf2,
1618 const Standard_Integer theNbSol,
1619 Draw_Interpretor& di)
1623 GeomInt_IntSS anInter;
1624 anInter.Perform (theSurf1, theSurf2, Precision::Confusion(), Standard_True);
1625 QVERIFY (anInter.IsDone());
1626 QCOMPARE (anInter.NbLines(), theNbSol);
1628 QVERIFY (Standard_False);
1633 static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc,
1634 const gp_Dir& theDir,
1635 const gp_Dir& theXDir,
1636 const Standard_Real theRad,
1637 const Standard_Real theSin,
1638 const Standard_Real theCos)
1640 const Standard_Real anA = atan (theSin / theCos);
1641 gp_Ax3 anAxis (theLoc, theDir, theXDir);
1642 Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad);
1647 static Standard_Integer OCC23972 (Draw_Interpretor& di,Standard_Integer n, const char**)
1649 if (n != 1) return 1;
1651 //process specific cones, cannot read them from files because due to rounding the original error
1652 //in math_FunctionRoots gets hidden
1653 Handle(Geom_Surface) aS1 = CreateCone (
1654 gp_Pnt (123.694345356663, 789.9, 68.15),
1655 gp_Dir (-1, 3.48029791472957e-016, -8.41302743359754e-017),
1656 gp_Dir (-3.48029791472957e-016, -1, -3.17572289932207e-016),
1660 Handle(Geom_Surface) aS2 = CreateCone (
1661 gp_Pnt (123.694345356663, 784.9, 68.15),
1662 gp_Dir (-1, -2.5209507537117e-016, -1.49772808948866e-016),
1663 gp_Dir (1.49772808948866e-016, 3.17572289932207e-016, -1),
1668 DoGeomIntSSTest (aS1, aS2, 2, di);
1673 #include <ShapeFix_EdgeProjAux.hxx>
1674 static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1677 di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n";
1681 TopoDS_Shape aSh = DBRep::Get(argv[1]);
1683 di << argv[0] << " Error: Null input edge\n";
1686 const TopoDS_Edge& anEdge = TopoDS::Edge (aSh);
1688 Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]);
1690 di << argv[0] << " Error: Null input curve\n";
1694 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]);
1696 di << argv[0] << " Error: Null input surface\n";
1700 Standard_Real prec = Draw::Atof(argv[4]);
1705 aB.MakeFace (aFace, aS, Precision::Confusion());
1706 aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion());
1707 aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter());
1710 ShapeFix_EdgeProjAux aProj (aFace, anEdge);
1711 aProj.Compute (prec);
1713 Standard_Boolean isfirstdone = aProj.IsFirstDone();
1714 Standard_Boolean islastdone = aProj.IsLastDone();
1716 Standard_Real first = 0.;
1717 Standard_Real last = 0.;
1718 Standard_Integer isfirstdoneInteger = 0;
1719 Standard_Integer islastdoneInteger = 0;
1723 first = aProj.FirstParam();
1724 isfirstdoneInteger = 1;
1728 last= aProj.LastParam();
1729 islastdoneInteger = 1;
1732 di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n";
1737 template<typename T, typename HT>
1738 static void DoIsNull(Draw_Interpretor& di)
1741 // QVERIFY (aHandle.IsNull());
1742 QCOMPARE (aHandle.IsNull(), Standard_True);
1743 const T* p = aHandle.Access();
1744 #if OCC_VERSION_HEX > 0x060700
1747 QCOMPARE (!p, Standard_True);
1748 QCOMPARE (p == 0, Standard_True);
1752 //QVERIFY (!aHandle.IsNull());
1753 QCOMPARE (!aHandle.IsNull(), Standard_True);
1754 p = aHandle.Access();
1757 QCOMPARE (p != NULL, Standard_True);
1758 QCOMPARE (p != 0, Standard_True);
1761 //=======================================================================
1762 //function : OCC24533
1764 //=======================================================================
1765 static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**)
1767 if (n != 1) return 1;
1769 DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di);
1770 DoIsNull<Standard_Persistent, Handle(Standard_Persistent)>(di);
1775 // Dummy class to test interface for compilation issues
1776 class QABugs_HandleClass : public Standard_Transient
1779 Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1781 std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n";
1784 DEFINE_STANDARD_RTTI(QABugs_HandleClass) // Type definition
1786 DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1787 IMPLEMENT_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1788 IMPLEMENT_STANDARD_RTTIEXT(QABugs_HandleClass, Standard_Transient)
1790 // Dummy class to test interface for compilation issues
1791 struct QABugs_NHandleClass
1793 Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1795 std::cerr << "QABugs_NHandleClass[" << this << "] " << "" << theArgVec[0] << "\n";
1800 #include <XCAFDoc_ColorTool.hxx>
1801 #include <STEPControl_StepModelType.hxx>
1802 #include <STEPCAFControl_Writer.hxx>
1803 static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1806 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
1809 Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");;
1810 TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape();
1811 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape();
1812 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1);
1813 TDataStd_Name::Set(lab1, "Box1");
1815 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1816 XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen);
1817 XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0);
1819 STEPControl_StepModelType mode = STEPControl_AsIs;
1820 STEPCAFControl_Writer writer;
1821 if ( ! writer.Transfer (aDoc, mode ) )
1823 di << "The document cannot be translated or gives no result" << "\n";
1827 writer.Write(argv[1]);
1832 //=======================================================================
1833 //function : OCC23950
1835 //=======================================================================
1836 static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1839 di << "Usage : " << argv[0] << " step_file\n";
1843 Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy");
1844 TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
1846 TopLoc_Location location0 (t0);
1848 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1849 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6);
1850 TDataStd_Name::Set(lab1, "Point1");
1852 TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1853 TDataStd_Name::Set(labelA0, "ASSEMBLY");
1855 TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
1857 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1858 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
1859 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
1861 STEPControl_StepModelType mode = STEPControl_AsIs;
1862 STEPCAFControl_Writer writer;
1863 if (! writer.Transfer (aDoc, mode))
1865 di << "The document cannot be translated or gives no result" << "\n";
1869 writer.Write (argv[1]);
1873 //=======================================================================
1874 //function : OCC24622
1875 //purpose : The command tests sourcing Image_PixMap to AIS_TexturedShape
1876 //=======================================================================
1877 static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
1881 std::cout << "Usage : " << theArgVec[0] << " texture={1D|2D}";
1885 const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
1886 if (anAISContext.IsNull())
1888 std::cout << "Please initialize view with \"vinit\".\n";
1892 Handle(Image_PixMap) anImage = new Image_PixMap();
1894 static const Image_ColorRGB aBitmap[8] =
1896 {{255, 0, 0}}, {{0, 148, 255}}, {{ 0, 148, 255}}, {{255, 94, 0}},
1897 {{255, 121, 0}}, {{76, 255, 0}}, {{76, 255, 0}}, {{255, 202, 0}}
1900 TCollection_AsciiString aTextureTypeArg (theArgVec[1]);
1901 aTextureTypeArg.UpperCase();
1902 if (aTextureTypeArg == "1D")
1904 anImage->InitWrapper (Image_PixMap::ImgRGB, (Standard_Byte*)aBitmap, 8, 1);
1906 else if (aTextureTypeArg == "2D")
1908 anImage->InitTrash (Image_PixMap::ImgRGB, 8, 8);
1909 for (Standard_Integer aRow = 0; aRow < 8; ++aRow)
1911 for (Standard_Integer aCol = 0; aCol < 8; ++aCol)
1913 anImage->ChangeValue<Image_ColorRGB> (aRow, aCol) = aBitmap[aRow];
1919 std::cout << "Please specify type of texture to test {1D|2D}.\n";
1923 TopoDS_Shape aBlankShape = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
1925 Handle(AIS_TexturedShape) aTexturedShape = new AIS_TexturedShape (aBlankShape);
1926 aTexturedShape->SetTexturePixMap (anImage);
1927 anAISContext->Display (aTexturedShape, 3, 0);
1932 //=======================================================================
1933 //function : OCC24667
1935 //=======================================================================
1936 static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1940 di << "OCC24667 result Wire_spine Profile [Mode [Approx]]" << "\n";
1941 di << "Mode = 0 - CorrectedFrenet," << "\n";
1942 di << " = 1 - Frenet," << "\n";
1943 di << " = 2 - DiscreteTrihedron" << "\n";
1944 di << "Approx - force C1-approximation if result is C0" << "\n";
1948 if (n > 1 && n < 4) return 1;
1950 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
1951 if ( Spine.IsNull()) return 1;
1953 TopoDS_Shape Profile = DBRep::Get(a[3]);
1954 if ( Profile.IsNull()) return 1;
1956 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
1959 Standard_Integer iMode = atoi(a[4]);
1961 Mode = GeomFill_IsFrenet;
1962 else if (iMode == 2)
1963 Mode = GeomFill_IsDiscreteTrihedron;
1966 Standard_Boolean ForceApproxC1 = Standard_False;
1968 ForceApproxC1 = Standard_True;
1970 BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine),
1975 TopoDS_Shape S = aPipe.Shape();
1976 TopoDS_Shape aSF = aPipe.FirstShape();
1977 TopoDS_Shape aSL = aPipe.LastShape();
1981 TCollection_AsciiString aStrF(a[1], "_f");
1982 TCollection_AsciiString aStrL(a[1], "_l");
1984 DBRep::Set(aStrF.ToCString(), aSF);
1985 DBRep::Set(aStrL.ToCString(), aSL);
1990 #include <IGESControl_Reader.hxx>
1991 #include <IGESControl_Controller.hxx>
1992 #include <IGESData_IGESEntity.hxx>
1993 #include <BRepCheck_Analyzer.hxx>
1994 #include <PTColStd_TransientPersistentMap.hxx>
1995 #include <PTopoDS_HShape.hxx>
1996 #include <Storage_Data.hxx>
1997 #include <TopExp_Explorer.hxx>
1998 #include <MgtBRep.hxx>
1999 #include <FSD_File.hxx>
2000 #include <ShapeSchema.hxx>
2001 #include <TColStd_HSequenceOfTransient.hxx>
2002 #include <PTColStd_PersistentTransientMap.hxx>
2003 #include <Storage_Root.hxx>
2005 static Standard_Integer OCC24565 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2008 di << "Usage : " << argv[0] << " FileNameIGS FileNameSTOR";
2012 Standard_CString sFileNameIGS = argv[1];
2013 Standard_CString sFileNameSTOR = argv[2];
2015 IGESControl_Reader ICReader;
2018 * Read the IGES file and make sure it is valid
2021 IGESControl_Controller::Init();
2023 if (!ICReader.ReadFile(sFileNameIGS)) {
2024 printf("%s:%d - Error reading '%s'\n",__FUNCTION__,__LINE__,sFileNameIGS);fflush(stdout);
2028 int nbShapes = ICReader.NbShapes();
2030 printf("%s:%d - nbShapes = '%d'\n",__FUNCTION__,__LINE__,nbShapes);fflush(stdout);
2035 Handle(TColStd_HSequenceOfTransient) faces=ICReader.GiveList("iges-faces");
2036 Handle(TColStd_HSequenceOfTransient) surfaceList=ICReader.GiveList("xst-transferrable-roots",faces);
2038 if (surfaceList.IsNull())
2040 printf("%s:%d - surfaceList.IsNull()\n",__FUNCTION__,__LINE__);fflush(stdout);
2043 BRep_Builder builder;
2044 TopoDS_Compound* pC = new TopoDS_Compound();
2045 builder.MakeCompound(*pC);
2047 for (int j=1;j<=surfaceList->Length();j++)
2049 Handle(IGESData_IGESEntity) igesEntity=Handle(IGESData_IGESEntity)::DownCast(surfaceList->Value(j));
2050 if (igesEntity.IsNull()) continue;
2051 ICReader.ClearShapes();
2052 Standard_Boolean rv;
2054 rv=ICReader.TransferEntity(igesEntity);
2060 printf("%s:%d - Error transferring IGES entity\n",__FUNCTION__,__LINE__);fflush(stdout);
2061 printf("%s:%d - FormNumber = %d, TypeNumber = %d\n",__FUNCTION__,__LINE__,igesEntity->FormNumber(),igesEntity->TypeNumber());fflush(stdout);
2070 printf("%s:%d - Error reading IGES entity\n",__FUNCTION__,__LINE__);fflush(stdout);
2071 printf("%s:%d - FormNumber = %d, TypeNumber = %d\n",__FUNCTION__,__LINE__,igesEntity->FormNumber(),igesEntity->TypeNumber());fflush(stdout);
2075 printf("%s:%d - NULL Surface encountered\n",__FUNCTION__,__LINE__);
2085 printf("%s: Exception adding face.\n",__FUNCTION__);
2088 Shape = TopoDS_Shape(*pC);
2092 Shape = ICReader.OneShape();
2095 BRepCheck_Analyzer brca(Shape);
2099 printf("%s: Invalid shape after reading IGES file.\n",__FUNCTION__);
2104 * Write the contents of the Shape to a STOR file
2107 PTColStd_TransientPersistentMap aMapTP;
2108 Handle(PTopoDS_HShape) aPShape_write;
2109 Handle(Storage_Data) d_write=new Storage_Data;
2116 for (i=0,Ex.Init(Shape,TopAbs_FACE);Ex.More();i++,Ex.Next())
2121 aPShape_write=MgtBRep::Translate(Ex.Current(),aMapTP,MgtBRep_WithoutTriangle);
2124 printf("%s: Error translating surface '%d'\n",__FUNCTION__,i);
2127 sprintf(Name,"S%010d",i);
2130 BRepCheck_Analyzer brca(Ex.Current());
2133 printf("INVALID face '%s' in the shape, which will be written to the STOR file.\n",Name);
2137 d_write->AddRoot(Name,aPShape_write);
2140 printf("%s: Error adding surface '%d', RootName = '%s'\n",__FUNCTION__,i,Name);
2143 printf("%s: Going to write %d surfaces.\n",__FUNCTION__,max_i+1);
2146 if(f_write.Open(sFileNameSTOR, Storage_VSWrite)!=Storage_VSOk)
2148 printf("%s: Error opening file: %s\n", __FUNCTION__,sFileNameSTOR);
2151 Handle(ShapeSchema) s_write=new ShapeSchema;
2152 s_write->Write(f_write,d_write);
2154 printf("%s: Wrote to the STOR file.\n",__FUNCTION__);
2157 * Read the contents of the Shape from a STOR file
2161 if(f_read.Open(sFileNameSTOR, Storage_VSRead)!=Storage_VSOk)
2163 printf("%s: Error opening file: %s\n", __FUNCTION__,sFileNameSTOR);
2166 Handle(ShapeSchema) s_read=new ShapeSchema;
2167 Handle(Storage_Data) d_read=s_read->Read(f_read);
2169 Handle(Standard_Persistent) p;
2170 Handle(Storage_Root) r;
2171 Handle(PTopoDS_HShape) aPShape_read;
2172 PTColStd_PersistentTransientMap aMapPT;
2173 TopoDS_Shape S_read;
2175 printf("%s: Extracting %d faces from the STOR file.\n",__FUNCTION__,max_i+1);
2176 for(int i = 0; i <= max_i; ++i)
2178 sprintf(Name,"S%010d",i);
2179 r=d_read->Find(Name);
2182 printf("%s:%d '%s' IsNull().\n",__FUNCTION__,__LINE__,Name);fflush(stdout);
2186 aPShape_read = Handle(PTopoDS_HShape)::DownCast(p);
2188 MgtBRep::Translate(aPShape_read,aMapPT,S_read,MgtBRep_WithoutTriangle);
2190 catch (Standard_Failure) {
2191 Handle(Standard_Failure) E=Standard_Failure::Caught();
2194 str+=E->DynamicType()->Name();
2196 str+=E->GetMessageString();
2197 printf("%s(1): %s: %s\n",__FUNCTION__,Name,str.c_str());fflush(stdout);
2200 printf("%s(1): Unhandled exception in MgtBRep::Translate\n",__FUNCTION__);
2203 BRepCheck_Analyzer brca(S_read);
2207 printf("%s: Read INVALID face (%s)!\n",__FUNCTION__,Name);
2211 printf("Completed.\n");fflush(stdout);
2216 #include <Handle_BRepTools_NurbsConvertModification.hxx>
2217 #include <BRepPrimAPI_MakeCylinder.hxx>
2218 #include <BRepBuilderAPI_Copy.hxx>
2219 #include <BRepTools_NurbsConvertModification.hxx>
2220 static TopoDS_Shape CreateTestShape (int& theShapeNb)
2222 TopoDS_Compound aComp;
2223 BRep_Builder aBuilder;
2224 aBuilder.MakeCompound (aComp);
2225 //NURBS modifier is used to increase footprint of each shape
2226 Handle_BRepTools_NurbsConvertModification aNurbsModif = new BRepTools_NurbsConvertModification;
2227 TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid();
2228 BRepTools_Modifier aModifier (aRefShape, aNurbsModif);
2229 if (aModifier.IsDone()) {
2230 aRefShape = aModifier.ModifiedShape (aRefShape);
2233 for (; theShapeNb > 0; --theShapeNb) {
2234 TopoDS_Shape aShape;
2235 if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists
2236 aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape();
2238 aShape = CreateTestShape (theShapeNb);
2240 aBuilder.Add (aComp, aShape);
2245 #include <AppStd_Application.hxx>
2246 #include <TDataStd_Integer.hxx>
2247 #include <TNaming_Builder.hxx>
2248 static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2251 di << "Usage: " << argv[0] << " invalid number of arguments"<<"\n";
2254 TCollection_ExtendedString aFileName (argv[1]);
2255 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2257 Handle(TDocStd_Application) anApp = new AppStd_Application;
2259 Handle(TDocStd_Document) aDoc;
2260 anApp->NewDocument ("XmlOcaf", aDoc);
2261 TDF_Label aLab = aDoc->Main();
2262 TDataStd_Integer::Set (aLab, 0);
2263 int n = 10000; //must be big enough
2264 TopoDS_Shape aShape = CreateTestShape (n);
2265 TNaming_Builder aBuilder (aLab);
2266 aBuilder.Generated (aShape);
2268 aSStatus = anApp->SaveAs (aDoc, aFileName);
2269 anApp->Close (aDoc);
2271 QCOMPARE (aSStatus, PCDM_SS_OK);
2275 #include <AppStdL_Application.hxx>
2276 #include <TDocStd_Application.hxx>
2277 #include <TDataStd_Integer.hxx>
2278 #include <TDF_AttributeIterator.hxx>
2279 //=======================================================================
2280 //function : OCC24755
2282 //=======================================================================
2283 static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2287 std::cout << "Usage : " << a[0] << "\n";
2291 Handle(TDocStd_Application) anApp = new AppStdL_Application;
2292 Handle(TDocStd_Document) aDoc;
2293 anApp->NewDocument ("MDTV-Standard", aDoc);
2294 TDF_Label aLab = aDoc->Main();
2295 TDataStd_Integer::Set (aLab, 0);
2296 TDataStd_Name::Set (aLab, "test");
2298 TDF_AttributeIterator i (aLab);
2299 Handle(TDF_Attribute) anAttr = i.Value();
2300 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True);
2303 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True);
2310 MyStubObject() : ptr(0L) {}
2311 MyStubObject(void* thePtr) : ptr(thePtr) {}
2316 //=======================================================================
2317 //function : OCC24834
2319 //=======================================================================
2320 static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2324 std::cout << "Usage : " << a[0] << "\n";
2328 int i = sizeof (char*);
2330 std::cout << "64-bit architecture is not supported.\n";
2334 NCollection_List<MyStubObject> aList;
2335 const Standard_Integer aSmallBlockSize = 40;
2336 const Standard_Integer aLargeBlockSize = 1500000;
2338 // quick populate memory with large blocks
2343 aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize)));
2346 catch (Standard_Failure)
2348 di << "caught out of memory for large blocks: OK\n";
2352 di << "skept out of memory for large blocks: Error\n";
2355 // allocate small blocks
2360 aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize)));
2363 catch (Standard_Failure)
2365 di << "caught out of memory for small blocks: OK\n";
2369 di << "skept out of memory for small blocks: Error\n";
2372 // release all allocated blocks
2373 for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next())
2375 Standard::Free(it.Value().ptr);
2381 #include <Geom2dAPI_InterCurveCurve.hxx>
2382 #include <IntRes2d_IntersectionPoint.hxx>
2383 //=======================================================================
2384 //function : OCC24889
2386 //=======================================================================
2387 static Standard_Integer OCC24889 (Draw_Interpretor& theDI,
2388 Standard_Integer /*theNArg*/,
2389 const char** /*theArgs*/)
2392 Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle(
2393 gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2395 Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle(
2396 gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2398 Handle( Geom2d_TrimmedCurve ) aTrim[2] = {
2399 new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ),
2400 new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 )
2403 DrawTrSurf::Set("c_1", aTrim[0]);
2404 DrawTrSurf::Set("c_2", aTrim[1]);
2407 const Standard_Real aTol = Precision::Confusion();
2408 Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol );
2410 const IntRes2d_IntersectionPoint& aIntPnt =
2411 aIntTool.Intersector().Point( 1 );
2413 gp_Pnt2d aIntRes = aIntTool.Point( 1 );
2414 Standard_Real aPar[2] = {
2415 aIntPnt.ParamOnFirst(),
2416 aIntPnt.ParamOnSecond()
2419 //theDI.precision( 5 );
2420 theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n";
2421 for (int i = 0; i < 2; ++i)
2423 theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() <<
2424 "; LastParam = " << aTrim[i]->LastParameter() <<
2425 "; IntParameter = " << aPar[i] << "\n";
2431 #include <math_GlobOptMin.hxx>
2432 #include <math_MultipleVarFunctionWithHessian.hxx>
2433 //=======================================================================
2434 //function : OCC25004
2435 //purpose : Check extremaCC on Branin function.
2436 //=======================================================================
2438 // f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s
2439 // Standard borders are:
2442 class BraninFunction : public math_MultipleVarFunctionWithHessian
2448 b = 5.1 / (4.0 * M_PI * M_PI);
2452 t = 1.0 / (8.0 * M_PI);
2454 virtual Standard_Integer NbVariables() const
2458 virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F)
2460 Standard_Real u = X(1);
2461 Standard_Real v = X(2);
2463 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2464 Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion.
2465 F = a * aSqPt * aSqPt + aLnPt + s;
2466 return Standard_True;
2468 virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G)
2470 Standard_Real u = X(1);
2471 Standard_Real v = X(2);
2473 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2474 G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u);
2475 G(2) = 2 * a * aSqPt;
2477 return Standard_True;
2479 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
2484 return Standard_True;
2486 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H)
2491 Standard_Real u = X(1);
2492 Standard_Real v = X(2);
2494 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2495 Standard_Real aTmpPt = c - 2 * b *u; // Tmp part.
2496 H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u);
2497 H(1,2) = 2 * a * aTmpPt;
2501 return Standard_True;
2505 // Standard parameters.
2506 Standard_Real a, b, c, r, s, t;
2509 static Standard_Integer OCC25004 (Draw_Interpretor& theDI,
2510 Standard_Integer /*theNArg*/,
2511 const char** /*theArgs*/)
2513 math_MultipleVarFunction* aFunc = new BraninFunction();
2515 math_Vector aLower(1,2), aUpper(1,2);
2521 Standard_Integer aGridOrder = 16;
2522 math_Vector aFuncValues(1, aGridOrder * aGridOrder);
2524 Standard_Real aLipConst = 0;
2525 math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2);
2527 // Get Lipshitz constant estimation on regular grid.
2528 Standard_Integer i, j, idx = 1;
2529 for(i = 1; i <= aGridOrder; i++)
2531 for(j = 1; j <= aGridOrder; j++)
2533 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2534 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2536 aFunc->Value(aCurrPnt1, aFuncValues(idx));
2541 Standard_Integer k, l;
2542 Standard_Integer idx1, idx2;
2543 for(i = 1; i <= aGridOrder; i++)
2544 for(j = 1; j <= aGridOrder; j++)
2545 for(k = 1; k <= aGridOrder; k++)
2546 for(l = 1; l <= aGridOrder; l++)
2548 if (i == k && j == l)
2551 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2552 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2553 idx1 = (i - 1) * aGridOrder + j;
2555 aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0);
2556 aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0);
2557 idx2 = (k - 1) * aGridOrder + l;
2559 aCurrPnt1.Add(-aCurrPnt2);
2560 Standard_Real dist = aCurrPnt1.Norm();
2562 Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist;
2567 math_GlobOptMin aFinder(aFunc, aLower, aUpper, aLipConst);
2569 //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475)
2571 Standard_Real anExtValue = aFinder.GetF();
2572 theDI << "F = " << anExtValue << "\n";
2574 Standard_Integer aNbExt = aFinder.NbExtrema();
2575 theDI << "NbExtrema = " << aNbExt << "\n";
2580 #include <OSD_Environment.hxx>
2581 #include <Plugin.hxx>
2582 #include <Plugin_Macro.hxx>
2583 #include <Resource_Manager.hxx>
2585 #define THE_QATEST_DOC_FORMAT "My Proprietary Format"
2587 #define QA_CHECK(theDesc, theExpr, theValue) \
2589 const bool isTrue = !!(theExpr); \
2590 std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \
2593 class Test_TDocStd_Application : public TDocStd_Application
2597 static void initGlobalPluginMap (const TCollection_AsciiString& thePlugin,
2598 const TCollection_AsciiString& theSaver,
2599 const TCollection_AsciiString& theLoader)
2601 const Handle(Resource_Manager)& aManager = Plugin::AdditionalPluginMap();
2602 aManager->SetResource ((theSaver + ".Location").ToCString(), thePlugin.ToCString());
2603 aManager->SetResource ((theLoader + ".Location").ToCString(), thePlugin.ToCString());
2606 Test_TDocStd_Application (const TCollection_AsciiString& thePlugin,
2607 const TCollection_AsciiString& theSaver,
2608 const TCollection_AsciiString& theLoader)
2610 initGlobalPluginMap (thePlugin, theSaver, theLoader);
2612 // explicitly initialize resource manager
2613 myResources = new Resource_Manager ("");
2614 myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT);
2615 myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document");
2616 myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml");
2617 myResources->SetResource (THE_QATEST_DOC_FORMAT ".StoragePlugin", theSaver.ToCString());
2618 myResources->SetResource (THE_QATEST_DOC_FORMAT ".RetrievalPlugin", theLoader.ToCString());
2621 virtual Standard_CString ResourcesName() { return ""; }
2622 virtual void Formats (TColStd_SequenceOfExtendedString& theFormats) { theFormats.Clear(); }
2625 //=======================================================================
2626 //function : OCC24925
2628 //=======================================================================
2629 static Standard_Integer OCC24925 (Draw_Interpretor& theDI,
2630 Standard_Integer theArgNb,
2631 const char** theArgVec)
2636 std::cout << "Error: wrong syntax! See usage:\n";
2637 theDI.PrintHelp (theArgVec[0]);
2641 Standard_Integer anArgIter = 1;
2642 TCollection_ExtendedString aFileName = theArgVec[anArgIter++];
2643 TCollection_AsciiString aPlugin = "TKXml";
2644 TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx
2645 TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx
2646 if (anArgIter < theArgNb)
2648 aPlugin = theArgVec[anArgIter++];
2649 aSaver = theArgVec[anArgIter++];
2650 aLoader = theArgVec[anArgIter++];
2653 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2654 PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError;
2656 Handle(TDocStd_Application) anApp = new Test_TDocStd_Application (aPlugin, aSaver, aLoader);
2658 Handle(TDocStd_Document) aDoc;
2659 anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc);
2660 TDF_Label aLab = aDoc->Main();
2661 TDataStd_Integer::Set (aLab, 0);
2662 TDataStd_Name::Set (aLab, "QABugs_19.cxx");
2664 aSStatus = anApp->SaveAs (aDoc, aFileName);
2665 anApp->Close (aDoc);
2667 QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true);
2670 Handle(TDocStd_Document) aDoc;
2671 aRStatus = anApp->Open (aFileName, aDoc);
2672 anApp->Close (aDoc);
2674 QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true);
2678 //=======================================================================
2679 //function : OCC25043
2681 //=======================================================================
2682 #include <BRepAlgoAPI_Check.hxx>
2683 static Standard_Integer OCC25043 (Draw_Interpretor& theDI,
2684 Standard_Integer theArgNb,
2685 const char** theArgVec)
2687 if (theArgNb != 2) {
2688 theDI << "Usage: " << theArgVec[0] << " shape\n";
2692 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
2693 if (aShape.IsNull())
2695 theDI << theArgVec[1] << " shape is NULL\n";
2699 BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True);
2701 if (!anAlgoApiCheck.IsValid())
2703 BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result());
2704 for (; anCheckIter.More(); anCheckIter.Next())
2706 const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value();
2707 const BOPCol_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1();
2708 BOPCol_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes);
2709 for (; aFaultyIter.More(); aFaultyIter.Next())
2711 const TopoDS_Shape& aFaultyShape = aFaultyIter.Value();
2713 Standard_Boolean anIsFaultyShapeFound = Standard_False;
2714 TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType());
2715 for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next())
2717 if (anExp.Current().IsEqual(aFaultyShape))
2718 anIsFaultyShapeFound = Standard_True;
2721 if (!anIsFaultyShapeFound)
2723 theDI << "Error. Faulty Shape is NOT found in source shape.\n";
2728 theDI << "Info. Faulty shape if found in source shape\n";
2735 theDI << "Error. Problems are not detected. Test is not performed.";
2741 //=======================================================================
2742 //function : OCC24606
2744 //=======================================================================
2745 static Standard_Integer OCC24606 (Draw_Interpretor& theDI,
2746 Standard_Integer theArgNb,
2747 const char** theArgVec)
2751 std::cerr << "Error: incorrect number of arguments.\n";
2752 theDI << "Usage : " << theArgVec[0] << "\n";
2756 Handle(V3d_View) aView = ViewerTest::CurrentView();
2759 std::cerr << "Errro: no active view, please call 'vinit'.\n";
2763 aView->DepthFitAll();
2769 //=======================================================================
2770 //function : OCC23010
2772 //=======================================================================
2773 #include <STEPCAFControl_Reader.hxx>
2775 class mOcafApplication : public TDocStd_Application
2777 void Formats(TColStd_SequenceOfExtendedString& Formats)
2779 Formats.Append(TCollection_ExtendedString("mOcafApplication"));
2781 Standard_CString ResourcesName()
2783 return Standard_CString("Resources");
2787 static Standard_Integer OCC23010 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2790 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
2793 std::string fileName=argv[1];
2794 mOcafApplication *mCasApp = new mOcafApplication();
2795 Handle(TDocStd_Document) doc;
2796 mCasApp->NewDocument("MDTV-XCAF", doc);
2797 STEPCAFControl_Reader stepReader;
2798 IFSelect_ReturnStatus status = stepReader.ReadFile (fileName.c_str());
2799 if (status != IFSelect_RetDone)
2801 stepReader.SetColorMode(Standard_True);
2802 stepReader.SetLayerMode(Standard_True);
2803 stepReader.SetNameMode(Standard_True);
2804 stepReader.Transfer(doc); // ERROR HERE!!!
2809 //=======================================================================
2810 //function : OCC25202
2812 //=======================================================================
2813 #include <ShapeBuild_ReShape.hxx>
2814 static Standard_Integer OCC25202 ( Draw_Interpretor& theDI,
2815 Standard_Integer theArgN,
2816 const char** theArgVal)
2819 //reshape res shape numF1 face1 numF2 face2
2822 theDI << "Use: reshape res shape numF1 face1 numF2 face2\n";
2826 TopoDS_Shape aShape = DBRep::Get(theArgVal[2]);
2827 const Standard_Integer aNumOfRE1 = Draw::Atoi(theArgVal[3]),
2828 aNumOfRE2 = Draw::Atoi(theArgVal[5]);
2829 TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])),
2830 aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6]));
2834 theDI << theArgVal[2] << " is null shape\n";
2838 if(aShapeForRepl1.IsNull())
2840 theDI << theArgVal[4] << " is not a replaced type\n";
2844 if(aShapeForRepl2.IsNull())
2846 theDI << theArgVal[6] << " is not a replaced type\n";
2851 TopoDS_Shape aReplacedShape;
2852 ShapeBuild_ReShape aReshape;
2854 //////////////////// explode (begin)
2855 TopTools_MapOfShape M;
2857 Standard_Integer aNbShapes = 0;
2858 for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next())
2860 const TopoDS_Shape& Sx = ex.Current();
2861 Standard_Boolean added = M.Add(Sx);
2865 if(aNbShapes == aNumOfRE1)
2867 aReplacedShape = Sx;
2869 aReshape.Replace(aReplacedShape, aShapeForRepl1);
2872 if(aNbShapes == aNumOfRE2)
2874 aReplacedShape = Sx;
2876 aReshape.Replace(aReplacedShape, aShapeForRepl2);
2880 //////////////////// explode (end)
2882 if(aReplacedShape.IsNull())
2884 theDI << "There is not any shape for replacing.\n";
2887 DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2));
2892 #include <ShapeFix_Wireframe.hxx>
2893 //=======================================================================
2894 //function : OCC7570
2896 //=======================================================================
2897 static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2900 di<<"Usage: "<<a[0]<<" invalid number of arguments"<<"\n";
2903 TopoDS_Shape in_shape (DBRep::Get (a[1]));
2904 ShapeFix_Wireframe fix_tool (in_shape);
2905 fix_tool.ModeDropSmallEdges () = Standard_True;
2906 fix_tool.SetPrecision (1.e+6);
2907 fix_tool.SetLimitAngle (0.01);
2908 fix_tool.FixSmallEdges ();
2909 TopoDS_Shape new_shape = fix_tool.Shape ();
2913 #include <AIS_TypeFilter.hxx>
2914 //=======================================================================
2915 //function : OCC25340
2917 //=======================================================================
2918 static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/,
2919 Standard_Integer /*theArgNb*/,
2920 const char** /*theArgVec*/)
2922 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2925 std::cerr << "Error: No opened viewer!\n";
2928 Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
2929 aCtx->AddFilter (aFilter);
2933 //=======================================================================
2934 //function : OCC24826
2936 //=======================================================================
2937 class ParallelTest_Saxpy
2940 typedef NCollection_Array1<Standard_Real> Vector;
2943 ParallelTest_Saxpy(const Vector& theX, Vector& theY, Standard_Real theScalar)
2950 //! Dummy calculation
2951 void operator() (const Standard_Integer theIndex) const
2953 myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex);
2957 ParallelTest_Saxpy( const ParallelTest_Saxpy& );
2958 ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& );
2963 const Standard_Real myScalar;
2966 //---------------------------------------------------------------------
2967 static Standard_Integer OCC24826(Draw_Interpretor& theDI,
2968 Standard_Integer trheArgc,
2969 const char** theArgv)
2971 if ( trheArgc != 2 )
2980 Standard_Integer aLength = Draw::Atoi(theArgv[1]);
2982 NCollection_Array1<Standard_Real> aX (0, aLength - 1);
2983 NCollection_Array1<Standard_Real> anY(0, aLength - 1);
2985 for ( Standard_Integer i = 0; i < aLength; ++i )
2987 aX(i) = anY(i) = (Standard_Real) i;
2994 //! Serial proccesing
2995 for ( Standard_Integer i = 0; i < aLength; ++i )
2997 anY(i) = 1e-6 * aX(i) + anY(i);
3001 cout << "Processing time (sequential mode):\n";
3004 const ParallelTest_Saxpy aFunctor(aX, anY, 1e-6);
3009 // Parallel processing
3010 OSD_Parallel::For(0, aLength, aFunctor);
3013 cout << "Processing time (parallel mode):\n";
3019 /*****************************************************************************/
3021 #include <GeomAPI_IntSS.hxx>
3022 //=======================================================================
3023 //function : OCC25100
3025 //=======================================================================
3026 static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3030 di << "the method requires a shape name\n";
3034 TopoDS_Shape S = DBRep::Get(argv[1]);
3037 di << "Shape is empty" << "\n";
3041 TopExp_Explorer aFaceExp(S, TopAbs_FACE);
3042 const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current()));
3044 GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion());
3046 if (!anIntersector.IsDone())
3048 di << "Error. Intersection is not done\n";
3052 di << "Test complete\n";
3057 //=======================================================================
3058 //function : OCC25348
3060 //=======================================================================
3061 static Standard_Integer OCC25348 (Draw_Interpretor& theDI,
3062 Standard_Integer /*theArgNb*/,
3063 const char** /*theArgVec*/)
3065 Handle(NCollection_IncAllocator) anAlloc1;
3066 NCollection_List<int> aList1(anAlloc1);
3067 for (int i=0; i < 10; i++)
3069 Handle(NCollection_IncAllocator) anAlloc2;
3070 NCollection_List<int> aList2(anAlloc2);
3072 aList1.Assign(aList2);
3074 theDI << "Test complete\n";
3078 #include <IntCurvesFace_ShapeIntersector.hxx>
3079 #include <BRepBndLib.hxx>
3080 //=======================================================================
3081 //function : OCC25413
3083 //=======================================================================
3084 static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
3087 di << "Usage: " << a[0] << " invalid number of arguments" << "\n";
3090 TopoDS_Shape aShape = DBRep::Get (a[1]);
3092 IntCurvesFace_ShapeIntersector Inter;
3093 Inter.Load(aShape, Precision::Confusion());
3096 BRepBndLib::Add(aShape, aBndBox);
3098 gp_Dir aDir(0., 1., 0.);
3100 Standard_Real xMin = aBndBox.CornerMin().X();
3101 Standard_Real zMin = aBndBox.CornerMin().Z();
3102 Standard_Real xMax = aBndBox.CornerMax().X();
3103 Standard_Real zMax = aBndBox.CornerMax().Z();
3104 Standard_Real xStep = (xMax - xMin) / N;
3105 Standard_Real zStep = (zMax - zMin) / N;
3107 for (Standard_Real x = xMin; x <= xMax; x += xStep)
3108 for (Standard_Real z = zMin; z <= zMax; z += zStep)
3110 gp_Pnt aPoint(x, 0.0, z);
3111 gp_Lin aLine(aPoint, aDir);
3112 Inter.PerformNearest(aLine, -100., 100.);
3118 #include <BOPAlgo_PaveFiller.hxx>
3120 #include <BRepAlgoAPI_BooleanOperation.hxx>
3121 #include <BRepAlgoAPI_Common.hxx>
3122 #include <BRepAlgoAPI_Fuse.hxx>
3123 #include <BRepAlgoAPI_Cut.hxx>
3124 #include <BRepAlgoAPI_Section.hxx>
3126 #include <BOPTools.hxx>
3128 #include <BOPCol_MapOfShape.hxx>
3129 #include <BOPCol_ListOfShape.hxx>
3130 //=======================================================================
3131 //function : OCC25446
3133 //=======================================================================
3134 static Standard_Integer OCC25446 (Draw_Interpretor& theDI,
3135 Standard_Integer argc,
3139 theDI << "Usage: OCC25446 res b1 b2 op\n";
3143 TopoDS_Shape aS1 = DBRep::Get(argv[2]);
3145 theDI << argv[2] << " shape is NULL\n";
3149 TopoDS_Shape aS2 = DBRep::Get(argv[3]);
3151 theDI << argv[3] << " shape is NULL\n";
3155 Standard_Integer iOp;
3156 BOPAlgo_Operation aOp;
3158 iOp = Draw::Atoi(argv[4]);
3159 if (iOp < 0 || iOp > 4) {
3160 theDI << "Invalid operation type\n";
3163 aOp = (BOPAlgo_Operation)iOp;
3165 Standard_Integer iErr;
3166 BOPCol_ListOfShape aLS;
3167 BOPAlgo_PaveFiller aPF;
3171 aPF.SetArguments(aLS);
3174 iErr = aPF.ErrorStatus();
3176 theDI << "Intersection failed with error status: " << iErr << "\n";
3180 BRepAlgoAPI_BooleanOperation* pBuilder = NULL;
3183 case BOPAlgo_COMMON:
3184 pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF);
3187 pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
3190 pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF);
3193 pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
3195 case BOPAlgo_SECTION:
3196 pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF);
3202 iErr = pBuilder->ErrorStatus();
3203 if (!pBuilder->IsDone()) {
3204 theDI << "BOP failed with error status: " << iErr << "\n";
3208 const TopoDS_Shape& aRes = pBuilder->Shape();
3209 DBRep::Set(argv[1], aRes);
3211 BOPCol_MapOfShape aMapArgs, aMapShape;
3212 BOPCol_MapIteratorOfMapOfShape aIt;
3213 Standard_Boolean bIsDeletedHist, bIsDeletedMap;
3214 TopAbs_ShapeEnum aType;
3216 BOPTools::MapShapes(aS1, aMapArgs);
3217 BOPTools::MapShapes(aS2, aMapArgs);
3218 BOPTools::MapShapes(aRes, aMapShape);
3220 aIt.Initialize(aMapArgs);
3221 for (; aIt.More(); aIt.Next()) {
3222 const TopoDS_Shape& aS = aIt.Value();
3223 aType = aS.ShapeType();
3224 if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
3225 aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
3229 bIsDeletedHist = pBuilder->IsDeleted(aS);
3230 bIsDeletedMap = !aMapShape.Contains(aS) &&
3231 (pBuilder->Modified(aS).Extent() == 0);
3233 if (bIsDeletedHist != bIsDeletedMap) {
3234 theDI << "Error. Wrong value of IsDeleted flag.\n";
3239 theDI << "Test complete\n";
3243 //====================================================
3244 // Auxiliary functor class for the command OCC25545;
3245 // it gets access to a vertex with the given index and
3246 // checks that X coordinate of the point is equal to index;
3247 // if it is not so then a data race is reported.
3248 //====================================================
3249 struct OCC25545_Functor
3251 OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
3252 : myShapeVec(&theShapeVec),
3256 void operator()(size_t i) const
3258 if (!myIsRaceDetected) {
3259 const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i));
3260 gp_Pnt aP = BRep_Tool::Pnt (aV);
3261 if (aP.X () != static_cast<double> (i)) {
3262 Standard_Atomic_Increment(&myIsRaceDetected);
3267 const std::vector<TopoDS_Shape>* myShapeVec;
3268 mutable volatile int myIsRaceDetected;
3271 //=======================================================================
3272 //function : OCC25545
3273 //purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation()
3274 //=======================================================================
3276 static Standard_Integer OCC25545 (Draw_Interpretor& di,
3280 // Place vertices in a vector, giving the i-th vertex the
3281 // transformation that translates it on the vector (i,0,0) from the origin.
3283 std::vector<TopoDS_Shape> aShapeVec (n);
3284 std::vector<TopLoc_Location> aLocVec (n);
3285 TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ());
3286 aShapeVec[0] = aShape;
3287 for (size_t i = 1; i < n; ++i) {
3289 aT.SetTranslation (gp_Vec (1, 0, 0));
3290 aLocVec[i] = aLocVec[i - 1] * aT;
3291 aShapeVec[i] = aShape.Moved (aLocVec[i]);
3294 // Evaluator function will access vertices geometry
3296 OCC25545_Functor aFunc(aShapeVec);
3298 //concurrently process
3299 tbb::parallel_for (size_t (0), n, aFunc, tbb::simple_partitioner ());
3300 QVERIFY (!aFunc.myIsRaceDetected);
3304 static Standard_Integer OCC25545 (Draw_Interpretor&,
3308 cout << "Test skipped: command " << argv[0] << " requires TBB library" << endl;
3313 //=======================================================================
3314 //function : OCC25547
3316 //=======================================================================
3317 #include <BRepMesh_GeomTool.hxx>
3318 #include <BRepAdaptor_Curve.hxx>
3319 #include <Geom_TrimmedCurve.hxx>
3320 #include <BRepBuilderAPI_MakeFace.hxx>
3321 #include <BRepAdaptor_HSurface.hxx>
3322 #include <BRepAdaptor_Surface.hxx>
3323 static Standard_Integer OCC25547(
3324 Draw_Interpretor& theDI,
3325 Standard_Integer /*argc*/,
3326 const char ** /*argv*/)
3328 // The general aim of this test is to prevent linkage errors due to missed
3329 // Standard_EXPORT attribute for static methods.
3331 // However, start checking the main functionality at first.
3332 const Standard_Real aFirstP = 0., aLastP = M_PI;
3333 Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
3334 Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
3335 TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf);
3336 BRepAdaptor_Curve aAdaptor(aEdge);
3337 BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5);
3339 if (aGeomTool.NbPoints() == 0)
3341 theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
3345 // Test static methods.
3346 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
3347 BRepAdaptor_Surface aSurf(aFace);
3348 Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf);
3352 if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
3354 theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
3358 gp_XY aRefPnts[4] = {
3359 gp_XY(-10., -10.), gp_XY(10., 10.),
3360 gp_XY(-10., 10.), gp_XY(10., -10.)
3364 Standard_Real aParams[2];
3365 BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin(
3366 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3367 aIntPnt.ChangeCoord(), aParams);
3369 Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
3370 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3372 theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
3376 aIntFlag = BRepMesh_GeomTool::IntSegSeg(
3377 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3378 Standard_False, Standard_False, aIntPnt);
3380 aDiff = aIntPnt.Distance(gp::Origin2d());
3381 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3383 theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
3388 theDI << "Test complete\n";
3392 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
3393 #include <TColStd_DataMapOfIntegerInteger.hxx>
3395 #include <ShapeFix_Wire.hxx>
3396 #include <ShapeExtend_Status.hxx>
3398 #define EXCEPTION ...
3400 #define EXCEPTION Standard_Failure
3403 static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)& theFix,
3404 const Standard_Boolean theIs3d)
3406 for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++)
3408 Standard_Boolean isFound;
3410 isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i );
3412 isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i );
3413 if (isFound) return ShapeExtend_Status(i);
3415 return ShapeExtend_OK;
3418 //===================
3419 //function : OCC24881
3421 //===================
3422 static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
3425 di<<"Usage: "<<a[0]<<" invalid number of arguments"<<"\n";
3428 // cout <<"FileName1: " << argv[1] <<endl;
3430 TopoDS_Shape aShape = DBRep::Get (a[1]);
3433 Handle(ShapeFix_Wire) aWireFix = new ShapeFix_Wire;
3435 // map FixStatus - NbSuchStatuses
3436 TColStd_DataMapOfIntegerInteger aStatusNbDMap;
3437 Standard_Integer nbFixed=0, nbOk=0;
3440 ShapeExtend_Status aStatus=ShapeExtend_OK;
3442 TopExp_Explorer aFaceExplorer(aShape, TopAbs_FACE);
3443 for (; aFaceExplorer.More(); aFaceExplorer.Next())
3445 TopoDS_Shape aFace = aFaceExplorer.Current();
3447 TopoDS_Iterator aWireItr(aFace);
3448 for (; aWireItr.More(); aWireItr.Next() )
3450 Standard_Boolean wasOk = Standard_False;
3451 TopoDS_Wire aSrcWire = TopoDS::Wire(aWireItr.Value());
3453 aWireFix->Load (aSrcWire);
3454 aWireFix->SetFace (TopoDS::Face(aFace));
3455 aWireFix->FixReorder(); //correct order is a prerequisite
3457 if (!aWireFix->FixGaps3d())
3460 aStatus = getStatusGap(aWireFix, Standard_True);
3461 if (aStatus == ShapeExtend_OK)
3462 wasOk = Standard_True;
3465 // keep 3d fail status
3466 if (aStatusNbDMap.IsBound (aStatus))
3467 aStatusNbDMap(aStatus)++;
3469 aStatusNbDMap.Bind(aStatus,1);
3475 if (aWireFix->FixGaps2d())
3479 aStatus = getStatusGap(aWireFix, Standard_False);
3480 if (aStatus == ShapeExtend_OK)
3492 // keep 2d fail status
3493 Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL;
3494 if (aStatusNbDMap.IsBound (aStatus2d))
3495 aStatusNbDMap(aStatus2d)++;
3497 aStatusNbDMap.Bind(aStatus2d,1);
3504 } catch (EXCEPTION) {
3505 di << "Exception is raised = " <<aStatus << "\n";
3509 // report what is done
3513 di <<"Fix_FillGaps_Fixed: nbFixed = "<<nbFixed <<"\n";
3518 di << "Fix_FillGaps_NothingToDo" <<"\n";
3521 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aStatusItr(aStatusNbDMap);
3522 for (; aStatusItr.More(); aStatusItr.Next())
3524 switch ((ShapeExtend_Status) aStatusItr.Key())
3527 case ShapeExtend_FAIL1:
3528 di <<"Fix_FillGaps_3dNoCurveFail, nb failed = ";
3530 case ShapeExtend_FAIL2:
3531 di <<"Fix_FillGaps_3dSomeGapsFail, nb failed = ";
3535 switch ((ShapeExtend_Status) (aStatusItr.Key() - ShapeExtend_FAIL))
3537 case ShapeExtend_FAIL1:
3538 di <<"Fix_FillGaps_2dNoPCurveFail, nb failed = ";
3540 case ShapeExtend_FAIL2:
3541 di <<"Fix_FillGaps_2dSomeGapsFail, nb failed = ";
3547 di <<aStatusItr.Value()<< "\n";
3549 di << ("__________________________________") <<"\n";
3554 #include <IntTools_Context.hxx>
3555 #include <GeomAPI_ProjectPointOnSurf.hxx>
3557 //=======================================================================
3558 //function : xprojponf
3560 //=======================================================================
3561 Standard_Integer xprojponf (Draw_Interpretor& di,
3566 di<<" use xprojponf p f \n";
3573 Handle(IntTools_Context) aCtx;
3575 DrawTrSurf::GetPoint(a[1], aP);
3576 aS=DBRep::Get(a[2]);
3579 di<<" null shape is not allowed\n";
3583 if (aS.ShapeType()!=TopAbs_FACE) {
3584 di << a[2] << " not a face\n";
3588 aCtx=new IntTools_Context;
3590 aF=TopoDS::Face(aS);
3591 GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF);
3594 if (!aPPS.IsDone()) {
3595 di<<" projection failed\n";
3599 aPS=aPPS.NearestPoint();
3600 di<< " point px " << aPS.X() << " " << aPS.Y() << " " << aPS.Z() << "\n";
3605 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
3606 const char *group = "QABugs";
3608 Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass();
3609 theCommands.Add ("OCC24202_1", "Test Handle-based procedure",
3610 __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group);
3611 NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass();
3612 theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure",
3613 __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group);
3615 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
3616 theCommands.Add ("OCC142", "OCC142", __FILE__, OCC142, group);
3617 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
3618 theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
3619 theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
3620 theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
3621 theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
3622 theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
3623 theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
3624 theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
3625 theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
3626 theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
3627 theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
3628 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);
3629 theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
3630 theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group);
3631 theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
3632 theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
3633 theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
3634 theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
3635 theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group);
3636 theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group);
3637 theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group);
3638 theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group);
3639 theCommands.Add ("OCC24051", "OCC24051", __FILE__, OCC24051, group);
3640 theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group);
3641 theCommands.Add ("OCC24622", "OCC24622 texture={1D|2D}\n Tests sourcing of 1D/2D pixmaps for AIS_TexturedShape", __FILE__, OCC24622, group);
3642 theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group);
3643 theCommands.Add ("OCC24565", "OCC24565 FileNameIGS FileNameSTOR", __FILE__, OCC24565, group);
3644 theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group);
3645 theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group);
3646 theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group);
3647 theCommands.Add ("OCC23951", "OCC23951 path to saved step file", __FILE__, OCC23951, group);
3648 theCommands.Add ("OCC24931", "OCC24931 path to saved xml file", __FILE__, OCC24931, group);
3649 theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group);
3650 theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
3651 theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group);
3652 theCommands.Add ("OCC24925",
3653 "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]"
3654 "\nOCAF persistence without setting environment variables",
3655 __FILE__, OCC24925, group);
3656 theCommands.Add ("OCC23010", "OCC23010 STEP_file", __FILE__, OCC23010, group);
3657 theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group);
3658 theCommands.Add ("OCC24826,", "This test performs simple saxpy test.\n Usage: OCC24826 length", __FILE__, OCC24826, group);
3659 theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group);
3660 theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group);
3661 theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
3662 theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
3663 theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group);
3664 theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group);
3665 theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
3666 theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
3667 theCommands.Add ("OCC25545",
3668 "no args; tests data race when concurrently accessing \n"
3669 "\t\tTopLoc_Location::Transformation()",
3670 __FILE__, OCC25545, group);
3671 theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
3672 theCommands.Add ("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group);
3673 theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);