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 <AIS_InteractiveContext.hxx>
19 #include <AIS_LocalContext.hxx>
20 #include <AIS_TexturedShape.hxx>
21 #include <BRepAlgo_Cut.hxx>
22 #include <BRepOffsetAPI_MakePipe.hxx>
23 #include <BRepPrimAPI_MakeBox.hxx>
24 #include <BRepPrimAPI_MakeSphere.hxx>
26 #include <Draw_Interpretor.hxx>
27 #include <DrawTrSurf.hxx>
28 #include <GCE2d_MakeSegment.hxx>
29 #include <Geom2d_TrimmedCurve.hxx>
30 #include <GeomFill_Trihedron.hxx>
31 #include <Graphic3d_ArrayOfTriangles.hxx>
33 #include <gp_Pnt2d.hxx>
34 #include <gp_Quaternion.hxx>
35 #include <Image_Color.hxx>
36 #include <Image_PixMap.hxx>
37 #include <NCollection_Handle.hxx>
38 #include <NCollection_IncAllocator.hxx>
39 #include <NCollection_Map.hxx>
40 #include <OSD_Parallel.hxx>
41 #include <OSD_PerfMeter.hxx>
42 #include <OSD_Timer.hxx>
43 #include <Precision.hxx>
44 #include <Prs3d_ShadingAspect.hxx>
45 #include <Prs3d_Text.hxx>
46 #include <SelectMgr_Filter.hxx>
47 #include <Standard_Version.hxx>
48 #include <StdSelect_BRepOwner.hxx>
49 #include <TCollection_HAsciiString.hxx>
50 #include <TopExp_Explorer.hxx>
51 #include <TopoDS_Shape.hxx>
52 #include <V3d_View.hxx>
53 #include <ViewerTest.hxx>
54 #include <XmlDrivers_DocumentRetrievalDriver.hxx>
55 #include <XmlDrivers_DocumentStorageDriver.hxx>
61 #define QCOMPARE(val1, val2) \
62 di << "Checking " #val1 " == " #val2 << \
63 ((val1) == (val2) ? ": OK\n" : ": Error\n")
65 static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
68 di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d\n";
73 if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
74 di << "ERROR OCC230: " << argv[2] << " is not Pnt2d\n";
77 if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
78 di << "ERROR OCC230: " << argv[3] << " is not Pnt2d\n";
82 GCE2d_MakeSegment MakeSegment(P1,P2);
83 Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
84 DrawTrSurf::Set(argv[1], TrimmedCurve);
88 static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
93 t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267);
94 t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880);
96 gp_Trsf tComp = t2 * t1;
99 gp_Pnt p2 = p1.Transformed(tComp);
100 gp_Pnt p3 = p1.Transformed(t1);
103 // points must be equal
104 if ( ! p2.IsEqual(p3, Precision::Confusion()) )
105 di << "ERROR OCC23361: equivalent transformations does not produce equal points\n";
107 di << "OCC23361: OK\n";
112 static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
114 OSD_PerfMeter aPM("TestMeter",0);
117 // run some operation in cycle for about 2 seconds to have good values of times to compare
119 printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n");
120 for (; aTM.ElapsedTime() < 2.; count++)
125 // do some operation that will take considerable time compared with time of starting / stopping timers
126 BRepPrimAPI_MakeBox aBox (10., 10., 10.);
127 BRepPrimAPI_MakeSphere aSphere (10.);
128 BRepAlgo_Cut aCutter (aBox.Shape(), aSphere.Shape());
135 Standard_Real aPerfMeter_CPUtime = 0., aTimer_CPUTime = 0., aS;
136 Standard_Integer aM, aH;
137 aTM.Show(aS, aM, aH, aTimer_CPUTime);
139 perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
140 perf_init_meter("TestMeter");
142 Standard_Real aTimeDiff = (fabs(aTimer_CPUTime - aPerfMeter_CPUtime) / aTimer_CPUTime);
144 printf("\nMeasurement results (%d cycles):\n", count);
145 printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer CPU time: %lf\n",
146 aPerfMeter_CPUtime, aTimer_CPUTime);
147 printf("Time delta is: %.3lf %%\n", aTimeDiff * 100);
150 di << "OCC23237: Error: too much difference between CPU and elapsed times";
151 else if (aNbEnters != count)
152 di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles";
154 di << "OCC23237: OK";
159 class IncrementerDecrementer
162 IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
164 void operator() (const size_t) const
167 Standard_Atomic_Increment(myVal);
169 Standard_Atomic_Decrement(myVal);
172 Standard_Integer* myVal;
173 Standard_Boolean myPositive;
176 static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
180 //check returned value
181 QCOMPARE (Standard_Atomic_Decrement (&aSum), -1);
182 QCOMPARE (Standard_Atomic_Increment (&aSum), 0);
183 QCOMPARE (Standard_Atomic_Increment (&aSum), 1);
184 QCOMPARE (Standard_Atomic_Increment (&aSum), 2);
185 // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0);
186 // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1);
190 const int N = 1 << 24; //big enough to ensure concurrency
193 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, true));
197 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, false));
203 #include <TDocStd_Application.hxx>
204 #include <TDocStd_Document.hxx>
205 #include <XCAFDoc_ShapeTool.hxx>
206 #include <XCAFDoc_DocumentTool.hxx>
207 #include <TDF_Label.hxx>
208 #include <TDataStd_Name.hxx>
209 #include <DDocStd.hxx>
211 static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
213 Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
214 Handle(TDocStd_Document) aDoc;
215 anApp->NewDocument ("XmlXCAF", aDoc);
216 QCOMPARE (!aDoc.IsNull(), Standard_True);
218 Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
220 //check default value
221 Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
222 QCOMPARE (aValue, Standard_True);
225 XCAFDoc_ShapeTool::SetAutoNaming (Standard_True);
226 TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape();
227 TDF_Label aLabel = aShTool->AddShape (aShape);
228 Handle(TDataStd_Name) anAttr;
229 QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
232 XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
233 aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape();
234 aLabel = aShTool->AddShape (aShape);
235 QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
238 XCAFDoc_ShapeTool::SetAutoNaming (aValue);
243 #include <ExprIntrp_GenExp.hxx>
244 Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
248 di << "Usage : " << argv[0] << " string nb\n";
252 TCollection_AsciiString aToken = argv[1];
253 Standard_Integer aNb = atoi(argv[2]);
255 Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create();
256 for (Standard_Integer i=0; i < aNb; i++)
258 aGen->Process(aToken);
259 Handle(Expr_GeneralExpression) aExpr = aGen->Expression();
265 Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
269 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"
270 << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}"
271 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}";
275 #include <TopoDS_Face.hxx>
276 #include <TopoDS_Face.hxx>
277 #include <TopoDS.hxx>
278 #include <BRepBuilderAPI_Transform.hxx>
279 #include <BRepExtrema_DistShapeShape.hxx>
280 #include <BRepTools.hxx>
282 static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di)
284 BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN);
285 if(!distShapeShape.IsDone()) {
286 di <<"Distance ShapeShape is Not Done\n";
287 return Standard_False;
290 if(distShapeShape.Value() > 0.01) {
291 di << "Wrong Dist = " <<distShapeShape.Value() << "\n";
292 return Standard_False;
294 di << "Dist0 = " <<distShapeShape.Value() <<"\n";
296 //////////////////////////////////////////////////////////////////////////
298 const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970);
299 const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970);
301 gp_Vec2d mirrorVector1(axis1P1,axis1P2);
304 mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1));
306 BRepBuilderAPI_Transform transformer1(mirror1);
307 transformer1.Perform(originalWire);
308 if(!transformer1.IsDone()) {
309 di << "Not Done1 \n";
310 return Standard_False;
312 TopoDS_Shape step1ModifiedShape = transformer1.ModifiedShape(originalWire);
314 BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN);
315 if(!distShapeShape1.IsDone())
316 return Standard_False;
317 if(distShapeShape1.Value() > 0.01) {
318 di << "Dist = " <<distShapeShape1.Value() <<"\n";
319 return Standard_False;
321 di << "Dist1 = " <<distShapeShape1.Value() <<"\n";
323 //////////////////////////////////////////////////////////////////////////
325 transformer1.Perform(step1ModifiedShape);
326 if(!transformer1.IsDone()) {
327 di << "Not Done1 \n";
328 return Standard_False;
330 TopoDS_Shape step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
332 //This is identity matrix for values but for type is gp_Rotation ?!
333 gp_Trsf2d mirror11 = mirror1;
334 mirror11.PreMultiply(mirror1);
336 BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN);
337 if(!distShapeShape2.IsDone())
338 return Standard_False;
340 //This last test case give error (the value is 1008.8822038689706)
341 if(distShapeShape2.Value() > 0.01) {
342 di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n";
343 Standard_Integer N = distShapeShape2.NbSolution();
344 di << "Nb = " <<N <<"\n";
345 for (Standard_Integer i=1;i <= N;i++)
346 di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n";
347 return Standard_False;
349 di << "Distance2 = " <<distShapeShape2.Value() <<"\n";
351 return Standard_True;
353 static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a)
357 di <<"OCC23774: invalid number of input parameters\n";
361 const char *ns1 = (a[1]), *ns2 = (a[2]);
362 TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2));
363 if (S1.IsNull() || S2.IsNull()) {
364 di <<"OCC23774: Null input shapes\n";
367 const TopoDS_Face& aFace = TopoDS::Face(S1);
368 if(!OCC23774Test(aFace, S2, di))
369 di << "Something is wrong\n";
374 #include <GeomConvert_ApproxSurface.hxx>
375 #include <Geom_BSplineSurface.hxx>
377 #include <OSD_Thread.hxx>
379 struct GeomConvertTest_Data
381 Standard_Integer nbupoles;
382 Handle(Geom_Surface) surf;
385 static Standard_Address GeomConvertTest (Standard_Address data)
387 GeomConvertTest_Data* info = (GeomConvertTest_Data*)data;
389 GeomConvert_ApproxSurface aGAS (info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
390 if (!aGAS.IsDone()) {
391 cout << "Error: ApproxSurface is not done!" << endl;
394 const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
395 if (aBSurf.IsNull()) {
396 cout << "Error: BSplineSurface is not created!" << endl;
399 cout << "Number of UPoles:" << aBSurf->NbUPoles();
400 if (aBSurf->NbUPoles() == info->nbupoles)
402 cout << ": OK" << endl;
403 return data; // any non-null pointer
407 cout << ": Error, must be " << info->nbupoles << endl;
412 static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
415 cout << "Error: invalid number of arguments" << endl;
419 struct GeomConvertTest_Data aStorage;
420 aStorage.nbupoles = Draw::Atoi(argv[1]);
421 aStorage.surf = DrawTrSurf::GetSurface(argv[2]);
422 if (aStorage.surf.IsNull())
424 cout << "Error: " << argv[2] << " is not a DRAW surface!" << endl;
428 // start conversion in several threads
429 const int NBTHREADS = 100;
430 OSD_Thread aThread[NBTHREADS];
431 for (int i=0; i < NBTHREADS; i++)
433 aThread[i].SetFunction (GeomConvertTest);
434 if (!aThread[i].Run(&aStorage))
435 di << "Error: Cannot start thread << " << i << "\n";
439 for (int i=0; i < NBTHREADS; i++)
441 Standard_Address aResult = 0;
442 if (!aThread[i].Wait(aResult))
443 di << "Error: Failed waiting for thread << " << i << "\n";
445 di << "Error: wrong number of poles in thread " << i << "!\n";
451 #include <GeomInt_IntSS.hxx>
453 struct GeomIntSSTest_Data
455 Standard_Integer nbsol;
456 Handle(Geom_Surface) surf1, surf2;
459 static Standard_Address GeomIntSSTest (Standard_Address data)
461 GeomIntSSTest_Data* info = (GeomIntSSTest_Data*)data;
462 GeomInt_IntSS anInter;
463 anInter.Perform (info->surf1, info->surf2, Precision::Confusion(), Standard_True);
464 if (!anInter.IsDone()) {
465 cout << "An intersection is not done!" << endl;
469 cout << "Number of Lines:" << anInter.NbLines();
470 if (anInter.NbLines() == info->nbsol)
472 cout << ": OK" << endl;
473 return data; // any non-null pointer
477 cout << ": Error, must be " << info->nbsol << endl;
482 static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
485 cout << "Error: invalid number of arguments" << endl;
489 struct GeomIntSSTest_Data aStorage;
490 aStorage.nbsol = Draw::Atoi(argv[1]);
491 aStorage.surf1 = DrawTrSurf::GetSurface(argv[2]);
492 aStorage.surf2 = DrawTrSurf::GetSurface(argv[3]);
493 if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull())
495 cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" << endl;
499 // start conversion in several threads
500 const int NBTHREADS = 100;
501 OSD_Thread aThread[NBTHREADS];
502 for (int i=0; i < NBTHREADS; i++)
504 aThread[i].SetFunction (GeomIntSSTest);
505 if (!aThread[i].Run(&aStorage))
506 di << "Error: Cannot start thread << " << i << "\n";
510 for (int i=0; i < NBTHREADS; i++)
512 Standard_Address aResult = 0;
513 if (!aThread[i].Wait(aResult))
514 di << "Error: Failed waiting for thread << " << i << "\n";
516 di << "Error: wrong number of intersections in thread " << i << "!\n";
522 #include <Geom_SurfaceOfRevolution.hxx>
523 static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
526 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
530 Standard_Integer ucontinuity = 1;
531 Standard_Integer vcontinuity = 1;
532 Standard_Boolean iscnu = false;
533 Standard_Boolean iscnv = false;
535 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
537 QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
538 QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
543 #include <gp_Ax1.hxx>
544 #include <gp_Ax22d.hxx>
545 #include <Geom_Plane.hxx>
546 #include <Geom2d_Circle.hxx>
547 #include <Geom2d_TrimmedCurve.hxx>
548 #include <BRepBuilderAPI_MakeEdge.hxx>
549 #include <BRepPrimAPI_MakeRevol.hxx>
550 #include <Geom2d_OffsetCurve.hxx>
552 static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
554 // Check the command arguments
557 di << "Error: " << argv[0] << " - invalid number of arguments\n";
558 di << "Usage: type help " << argv[0] << "\n";
559 return 1; // TCL_ERROR
562 gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
563 gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
564 Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
566 di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>\n";
567 di << "-----------------------------------------------------------------------\n";
569 Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
570 Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
571 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
573 DBRep::Set("e1", E1);
575 BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
576 TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
578 DBRep::Set("f1", F1);
580 di << "Result: f1\n";
582 di << "<<<< Preparing sample surface of revolution based on offset curve >>>>\n";
583 di << "-----------------------------------------------------------------------\n";
585 Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
586 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
588 DBRep::Set("e2", E2);
590 BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
591 TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
593 DBRep::Set("f2", F2);
595 di << "Result: f2\n";
600 #include <Geom_Curve.hxx>
601 #include <Geom_Surface.hxx>
602 #include <Precision.hxx>
603 #include <ShapeConstruct_ProjectCurveOnSurface.hxx>
604 //=======================================================================
605 //function : OCC24008
607 //=======================================================================
608 static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
611 di << "Usage: " << argv[0] << " invalid number of arguments\n";
614 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]);
615 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]);
616 if (aCurve.IsNull()) {
617 di << "Curve was not read\n";
620 if (aSurf.IsNull()) {
621 di << "Surface was not read\n";
624 ShapeConstruct_ProjectCurveOnSurface aProj;
625 aProj.Init (aSurf, Precision::Confusion());
627 Handle(Geom2d_Curve) aPCurve;
628 aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve);
629 if (aPCurve.IsNull()) {
630 di << "PCurve was not created\n";
634 di << "Exception was caught\n";
639 #include <GeomAdaptor_Surface.hxx>
641 //=======================================================================
642 //function : OCC23945
644 //=======================================================================
646 static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
650 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
651 if (aS.IsNull()) return 1;
653 GeomAdaptor_Surface GS(aS);
655 Standard_Real U = Draw::Atof(a[2]);
656 Standard_Real V = Draw::Atof(a[3]);
658 Standard_Boolean DrawPoint = ( n%3 == 2);
666 GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
667 Draw::Set(a[13],D2U.X());
668 Draw::Set(a[14],D2U.Y());
669 Draw::Set(a[15],D2U.Z());
670 Draw::Set(a[16],D2V.X());
671 Draw::Set(a[17],D2V.Y());
672 Draw::Set(a[18],D2V.Z());
673 Draw::Set(a[19],D2UV.X());
674 Draw::Set(a[20],D2UV.Y());
675 Draw::Set(a[21],D2UV.Z());
680 Draw::Set(a[7],DU.X());
681 Draw::Set(a[8],DU.Y());
682 Draw::Set(a[9],DU.Z());
683 Draw::Set(a[10],DV.X());
684 Draw::Set(a[11],DV.Y());
685 Draw::Set(a[12],DV.Z());
691 Draw::Set(a[4],P.X());
692 Draw::Set(a[5],P.Y());
693 Draw::Set(a[6],P.Z());
696 DrawTrSurf::Set(a[n],P);
702 //=======================================================================
703 //function : OCC11758
705 //=======================================================================
706 static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
708 if (n != 1) return 1;
710 const char* theStr = "0123456789";
711 Standard_Integer i, j;
712 for ( i = 0; i < 5; ++i ) {
713 // TCollection_AsciiString(const Standard_CString astring)
714 TCollection_AsciiString a(theStr+i);
715 // IsEqual (const Standard_CString other)const
716 //assert( a == theStr+i );
717 QCOMPARE ( a , theStr+i );
719 //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen )
720 TCollection_AsciiString b(theStr+i, 3);
721 //assert( b.Length() == 3 );
722 //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 );
723 //assert( strlen( b.ToCString() ) == 3 );
724 QCOMPARE ( b.Length() , 3 );
725 QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 );
726 QCOMPARE ( b.Length() , 3 );
728 //TCollection_AsciiString(const Standard_Integer aValue)
729 TCollection_AsciiString c(i);
730 //assert( c.IsIntegerValue() );
731 //assert( c.IntegerValue() == i );
732 QCOMPARE ( c.IsIntegerValue() , Standard_True );
733 QCOMPARE ( c.IntegerValue() , i );
735 //TCollection_AsciiString(const Standard_Real aValue)
736 TCollection_AsciiString d( 0.1*i );
737 //assert( d.IsRealValue() );
738 //assert( TCollection_AsciiString(3.3) == "3.3");
739 QCOMPARE ( d.IsRealValue() , Standard_True );
740 QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" );
742 //TCollection_AsciiString(const TCollection_AsciiString& astring)
743 TCollection_AsciiString e(d);
745 //assert( e.Length() == d.Length() );
746 //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
748 QCOMPARE ( e.Length() , d.Length() );
749 QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
751 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
752 // const Standard_Character other )
753 TCollection_AsciiString f(e,'\a');
754 //assert( f.Length() == e.Length() + 1 );
755 //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 );
756 //assert( f.Value( f.Length() ) == '\a');
757 QCOMPARE ( f.Length() , e.Length() + 1 );
758 QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 );
759 QCOMPARE ( f.Value( f.Length() ) , '\a' );
761 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
762 // const Standard_CString other )
763 TCollection_AsciiString g(f, theStr);
764 //assert( g.Length() == f.Length() + strlen( theStr ));
765 //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 );
766 //assert( g.Search( theStr ) == f.Length() + 1 );
767 QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) );
768 QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 );
769 QCOMPARE ( g.Search( theStr ) , f.Length() + 1 );
771 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
772 // const TCollection_AsciiString& other )
773 TCollection_AsciiString h(d,a);
774 //assert( h.Length() == d.Length() + a.Length() );
775 //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 );
776 //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 );
777 QCOMPARE ( h.Length() , d.Length() + a.Length() );
778 QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 );
779 QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 );
781 // AssignCat(const Standard_CString other)
782 c.AssignCat( a.ToCString() );
783 //assert( c.Length() == 1 + a.Length() );
784 //assert( c.Search( a ) == 2 );
785 QCOMPARE ( c.Length() , 1 + a.Length() );
786 QCOMPARE ( c.Search( a ) , 2 );
788 // AssignCat(const TCollection_AsciiString& other)
789 Standard_Integer dl = d.Length();
791 //assert( d.Length() == dl + a.Length() );
792 //assert( d.Search( a ) == dl + 1 );
793 QCOMPARE ( d.Length() , dl + a.Length() );
794 QCOMPARE ( d.Search( a ) , dl + 1 );
797 TCollection_AsciiString capitalize("aBC");
798 capitalize.Capitalize();
799 //assert( capitalize == "Abc" );
800 QCOMPARE ( capitalize , "Abc" );
802 // Copy(const Standard_CString fromwhere)
804 //assert( d == theStr+i );
805 QCOMPARE ( d , theStr+i );
807 // Copy(const TCollection_AsciiString& fromwhere)
809 // IsEqual (const TCollection_AsciiString& other)const
813 // Insert(const Standard_Integer where, const Standard_CString what)
815 d.Insert( 2, theStr );
816 //assert( d.Length() == dl + strlen( theStr ));
817 //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 );
818 QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) );
819 QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 );
821 //Insert(const Standard_Integer where,const Standard_Character what)
823 d.Insert( i+1, 'i' );
824 //assert( d.Length() == strlen( theStr ) + 1 );
825 //assert( d.Value( i+1 ) == 'i');
826 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
827 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
828 QCOMPARE ( d.Value( i+1 ) , 'i' );
829 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
831 //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
833 d.Insert( i+1, TCollection_AsciiString( "i" ));
834 //assert( d.Length() == strlen( theStr ) + 1 );
835 //assert( d.Value( i+1 ) == 'i');
836 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
837 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
838 QCOMPARE ( d.Value( i+1 ) , 'i' );
839 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
841 // IsDifferent (const Standard_CString other)const
842 //assert( d.IsDifferent( theStr ));
843 //assert( d.IsDifferent( "theStr" ));
844 //assert( d.IsDifferent( "" ));
845 //assert( !d.IsDifferent( d.ToCString() ));
846 QCOMPARE ( d.IsDifferent( theStr ) , Standard_True );
847 QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True );
848 QCOMPARE ( d.IsDifferent( "" ) , Standard_True );
849 QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True );
851 // IsDifferent (const TCollection_AsciiString& other)const
852 //assert( d.IsDifferent( TCollection_AsciiString() ));
853 //assert( d.IsDifferent( a ));
854 //assert( d.IsDifferent( h ));
855 //assert( !d.IsDifferent( d ));
856 QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True );
857 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
858 QCOMPARE ( d.IsDifferent( h ) , Standard_True );
859 QCOMPARE ( !d.IsDifferent( d ) , Standard_True );
861 // IsLess (const Standard_CString other)const
862 //assert( TCollection_AsciiString ("0"). IsLess("1"));
863 //assert( TCollection_AsciiString ("0"). IsLess("00"));
864 //assert( TCollection_AsciiString (""). IsLess("0"));
865 //assert( !TCollection_AsciiString("1"). IsLess("0"));
866 //assert( !TCollection_AsciiString("00").IsLess("0"));
867 //assert( !TCollection_AsciiString("0"). IsLess(""));
868 //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1));
869 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True );
870 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True );
871 QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True );
872 QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True );
873 QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True );
874 QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True );
875 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True );
877 // IsLess (const TCollection_AsciiString& other)const
878 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )));
879 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")));
880 //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )));
881 //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )));
882 //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )));
883 //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )));
884 //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)));
885 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True );
886 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True );
887 QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True );
888 QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True );
889 QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True );
890 QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True );
891 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True );
893 // IsGreater (const Standard_CString other)const
894 //assert( !TCollection_AsciiString("0"). IsGreater("1"));
895 //assert( !TCollection_AsciiString("0"). IsGreater("00"));
896 //assert( !TCollection_AsciiString(""). IsGreater("0"));
897 //assert( TCollection_AsciiString ("1"). IsGreater("0"));
898 //assert( TCollection_AsciiString ("00").IsGreater("0"));
899 //assert( TCollection_AsciiString ("0"). IsGreater(""));
900 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i));
901 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True );
902 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True );
903 QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True );
904 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True );
905 QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True );
906 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True );
907 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True );
909 // IsGreater (const TCollection_AsciiString& other)const
910 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )));
911 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")));
912 //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )));
913 //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )));
914 //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )));
915 //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )));
916 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)));
917 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True );
918 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True );
919 QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
920 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
921 QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True );
922 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True );
923 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True );
925 // void Read(Standard_IStream& astream)
926 std::istringstream is( theStr );
928 //assert( e == theStr );
929 QCOMPARE ( e , theStr );
931 // Standard_Integer SearchFromEnd (const Standard_CString what)const
932 //assert( e.SearchFromEnd( theStr + i ) == i + 1 );
933 QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 );
935 // SetValue(const Standard_Integer where, const Standard_CString what)
936 e.SetValue( i+1, "what");
937 //assert( e.Search( "what" ) == i+1 );
938 //assert( e.Length() == strlen( theStr ));
939 QCOMPARE ( e.Search( "what" ) , i+1 );
940 QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) );
942 // TCollection_AsciiString Split (const Standard_Integer where)
945 //assert( d.Length() + e.Length() == strlen( theStr ));
946 QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
948 // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
949 // const Standard_Integer ToIndex) const
951 d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 );
952 //assert( d.Length() == 3 );
953 //assert( d.Value(1) == theStr[ i ]);
954 QCOMPARE ( d.Length() , 3 );
955 QCOMPARE ( d.Value(1) , theStr[ i ] );
957 // TCollection_AsciiString Token (const Standard_CString separators,
958 // const Standard_Integer whichone) const
960 for ( j = 0; j < i; ++j ) {
961 e += TCollection_AsciiString( theStr[j] ) + " ";
962 //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 ));
963 QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) );
966 for ( i = 0; i < 5; ++i )
968 // TCollection_ExtendedString (const Standard_CString astring,
969 // const Standard_Boolean isMultiByte)
970 const TCollection_ExtendedString a( theStr+i );
971 //assert( TCollection_AsciiString( a ) == theStr+i );
972 QCOMPARE ( TCollection_AsciiString( a ) , theStr+i );
974 //TCollection_ExtendedString (const Standard_ExtString astring)
975 const TCollection_ExtendedString b( a.ToExtString() );
979 // TCollection_ExtendedString (const Standard_Integer length,
980 // const Standard_ExtCharacter filler )
981 const TCollection_ExtendedString c( i, 1 );
982 //assert( c.Length() == i );
983 QCOMPARE ( c.Length() , i );
984 if ( c.Length() > 0 ) {
985 //assert( c.Value( i ) == 1 );
986 QCOMPARE ( c.Value( i ) , 1 );
989 // TCollection_ExtendedString (const Standard_Integer aValue)
990 TCollection_ExtendedString d( i );
991 const TCollection_AsciiString da( d );
992 //assert( da.IsIntegerValue() );
993 //assert( da.IntegerValue() == i );
994 QCOMPARE ( da.IsIntegerValue() , Standard_True );
995 QCOMPARE ( da.IntegerValue(), i );
997 // TCollection_ExtendedString (const Standard_Real aValue)
998 const TCollection_ExtendedString e( 0.1 * i );
999 const TCollection_AsciiString ea( e );
1000 //assert( ea.IsRealValue() );
1001 //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 );
1002 QCOMPARE ( ea.IsRealValue() , Standard_True );
1003 QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True );
1005 // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1006 const TCollection_ExtendedString f(e);
1007 //assert( f.Length() == e.Length());
1009 QCOMPARE ( f.Length() , e.Length() );
1012 // TCollection_ExtendedString (const TCollection_AsciiString& astring)
1013 const TCollection_ExtendedString g( ea );
1014 //assert( g.Length() == ea.Length() );
1015 //assert( TCollection_AsciiString( g ) == ea );
1016 QCOMPARE ( g.Length() , ea.Length() );
1017 QCOMPARE ( TCollection_AsciiString( g ) , ea );
1019 // AssignCat (const TCollection_ExtendedString& other)
1020 const TCollection_ExtendedString sep(",");
1023 //assert( d.Length() == 2 + g.Length() );
1024 //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i ));
1025 //assert( d.Token( sep.ToExtString(), 2 ) == g );
1026 QCOMPARE ( d.Length() , 2 + g.Length() );
1027 QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) );
1028 QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g );
1030 // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const
1031 const TCollection_ExtendedString cat = a.Cat( sep );
1032 //assert( cat.Length() == a.Length() + sep.Length() );
1033 //assert( cat.Search( a ) == 1 );
1034 //assert( cat.Search( sep ) == a.Length() + 1 );
1035 QCOMPARE ( cat.Length() , a.Length() + sep.Length() );
1036 QCOMPARE ( cat.Search( a ) , 1 );
1037 QCOMPARE ( cat.Search( sep ) , a.Length() + 1 );
1039 // Copy (const TCollection_ExtendedString& fromwhere)
1041 //assert( d.Length() == cat.Length() );
1042 //assert( d == cat );
1043 QCOMPARE ( d.Length() , cat.Length() );
1044 QCOMPARE ( d , cat );
1046 // IsEqual (const Standard_ExtString other) const
1047 //assert( d.IsEqual( d.ToExtString() ));
1048 QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1050 // IsDifferent (const Standard_ExtString other ) const
1051 //assert( d.IsDifferent( a.ToExtString() ));
1052 QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1054 // IsDifferent (const TCollection_ExtendedString& other) const
1055 //assert( d.IsDifferent( a ));
1056 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
1058 // IsLess (const Standard_ExtString other) const
1059 const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1);
1060 //assert( l0. IsLess( l1.ToExtString() ));
1061 //assert( l0. IsLess( l00.ToExtString() ));
1062 //assert( l. IsLess( l0.ToExtString() ));
1063 //assert( ! l1. IsLess( l0.ToExtString() ));
1064 //assert( ! l00.IsLess( l0.ToExtString() ));
1065 //assert( ! l0. IsLess( l.ToExtString() ));
1066 //assert( ls.IsLess( ls1.ToExtString() ));
1067 QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True );
1068 QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True );
1069 QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True );
1070 QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True );
1071 QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True );
1072 QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True );
1073 QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True );
1075 // IsLess (const TCollection_ExtendedString& other) const
1076 //assert( l0. IsLess( l1 ));
1077 //assert( l0. IsLess( l00 ));
1078 //assert( l. IsLess( l0 ));
1079 //assert( ! l1. IsLess( l0 ));
1080 //assert( ! l00.IsLess( l0 ));
1081 //assert( ! l0. IsLess( l ));
1082 //assert( ls.IsLess( ls1 ));
1083 QCOMPARE ( l0. IsLess( l1 ) , Standard_True );
1084 QCOMPARE ( l0. IsLess( l00 ) , Standard_True );
1085 QCOMPARE ( l. IsLess( l0 ) , Standard_True );
1086 QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True );
1087 QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True );
1088 QCOMPARE ( ! l0. IsLess( l ) , Standard_True );
1089 QCOMPARE ( ls.IsLess( ls1 ) , Standard_True );
1091 // IsGreater (const Standard_ExtString other) const
1092 //assert( ! l0.IsGreater( l1.ToExtString() ));
1093 //assert( ! l0.IsGreater( l00.ToExtString() ));
1094 //assert( ! l. IsGreater( l0.ToExtString() ));
1095 //assert( l1. IsGreater( l0.ToExtString() ));
1096 //assert( l00.IsGreater( l0.ToExtString() ));
1097 //assert( l0. IsGreater( l.ToExtString() ));
1098 //assert( ls1.IsGreater( ls.ToExtString() ));
1099 QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True );
1100 QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True );
1101 QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True );
1102 QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True );
1103 QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True );
1104 QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True );
1105 QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True );
1107 // IsGreater (const TCollection_ExtendedString& other) const
1108 //assert( ! l0.IsGreater( l1));
1109 //assert( ! l0.IsGreater( l00));
1110 //assert( ! l. IsGreater( l0));
1111 //assert( l1. IsGreater( l0));
1112 //assert( l00.IsGreater( l0));
1113 //assert( l0. IsGreater( l));
1114 //assert( ls1.IsGreater( ls));
1115 QCOMPARE ( ! l0.IsGreater( l1) , Standard_True );
1116 QCOMPARE ( ! l0.IsGreater( l00) , Standard_True );
1117 QCOMPARE ( ! l. IsGreater( l0) , Standard_True );
1118 QCOMPARE ( l1. IsGreater( l0) , Standard_True );
1119 QCOMPARE ( l00.IsGreater( l0) , Standard_True );
1120 QCOMPARE ( l0. IsGreater( l) , Standard_True );
1121 QCOMPARE ( ls1.IsGreater( ls) , Standard_True );
1123 // ==========================
1124 //TCollection_HAsciiString::
1125 // ==========================
1127 // IsDifferent(const Handle(TCollection_HAsciiString)& S)
1128 Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i );
1129 Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 );
1130 //assert( ha1->IsDifferent( ha2 ));
1131 //assert( !ha1->IsDifferent( ha1 ));
1132 QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True );
1133 QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True );
1135 // IsSameString (const Handle(TCollection_HAsciiString)& S)
1136 //assert( !ha1->IsSameString( ha2 ));
1137 //assert( ha1->IsSameString( ha1 ));
1138 QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True );
1139 QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True );
1141 // IsSameState (const Handle(TCollection_HAsciiString)& other) const
1142 //assert( !ha1->IsSameState( ha2 ));
1143 //assert( ha1->IsSameState( ha1 ));
1144 QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True );
1145 QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True );
1147 // IsSameString (const Handle(TCollection_HAsciiString)& S ,
1148 // const Standard_Boolean CaseSensitive) const
1149 //assert( !ha1->IsSameString( ha2, true ));
1150 //assert( ha1->IsSameString( ha1, true ));
1151 //assert( !ha1->IsSameString( ha2, false ));
1152 //assert( ha1->IsSameString( ha1, false ));
1153 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1154 QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True );
1155 QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True );
1156 QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True );
1158 ha1->SetValue( 1, "AbC0000000");
1159 ha2->SetValue( 1, "aBc0000000");
1160 //assert( !ha1->IsSameString( ha2, true ));
1161 //assert( ha1->IsSameString( ha2, false ));
1162 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1163 QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True );
1168 #include <Geom_CylindricalSurface.hxx>
1169 #include <IntTools_FaceFace.hxx>
1170 #include <IntTools_Curve.hxx>
1171 #include <IntTools_PntOn2Faces.hxx>
1173 static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1177 theDI << "Wrong a number of arguments!\n";
1181 Handle(Geom_Plane) plane(new Geom_Plane(
1182 gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
1183 gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
1184 gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000))));
1185 Handle(Geom_CylindricalSurface) cylinder(
1186 new Geom_CylindricalSurface(
1187 gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
1188 gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
1189 gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
1190 19.712534607908712));
1192 DrawTrSurf::Set("pln", plane);
1194 DrawTrSurf::Set("cyl", cylinder);
1197 BRep_Builder builder;
1198 TopoDS_Face face1, face2;
1199 builder.MakeFace(face1, plane, Precision::Confusion());
1200 builder.MakeFace(face2, cylinder, Precision::Confusion());
1201 IntTools_FaceFace anInters;
1202 anInters.SetParameters(false, true, true, Precision::Confusion());
1203 anInters.Perform(face1, face2);
1205 if (!anInters.IsDone())
1207 theDI<<"No intersections found!\n";
1212 //Handle(Geom_Curve) aResult;
1215 const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1216 const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1219 Standard_Integer aNbCurves, aNbPoints;
1221 aNbCurves=aCvsX.Length();
1222 aNbPoints=aPntsX.Length();
1226 for (Standard_Integer i=1; i<=aNbCurves; ++i)
1228 Sprintf(buf, "%s_%d",theArgv[1],i);
1229 theDI << buf << " ";
1231 const IntTools_Curve& aIC = aCvsX(i);
1232 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1233 DrawTrSurf::Set(buf,aC3D);
1236 else if (aNbCurves == 1)
1238 const IntTools_Curve& aIC = aCvsX(1);
1239 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1240 Sprintf(buf, "%s",theArgv[1]);
1241 theDI << buf << " ";
1242 DrawTrSurf::Set(buf,aC3D);
1245 for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1247 const IntTools_PntOn2Faces& aPi=aPntsX(i);
1248 const gp_Pnt& aP=aPi.P1().Pnt();
1250 Sprintf(buf,"%s_p_%d",theArgv[1],i);
1251 theDI << buf << " ";
1252 DrawTrSurf::Set(buf, aP);
1258 #include <BRepAlgo_NormalProjection.hxx>
1259 static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1262 di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)";
1266 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1267 if(myAISContext.IsNull()) {
1268 di << "use 'vinit' command before " << argv[0] << "\n";
1272 TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1]));
1273 TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2]));
1275 BRepAlgo_NormalProjection anormpro(m_Face1);
1276 anormpro.Add(m_Edge);
1277 anormpro.SetDefaultParams();
1279 //anormpro.Compute3d();
1280 //anormpro.SetLimit();
1284 if (anormpro.IsDone())
1286 TopoDS_Shape rshape = anormpro.Projection();
1287 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape);
1288 myAISContext->SetColor(myShape, Quantity_Color(Quantity_NOC_YELLOW));
1289 myAISContext->Display(myShape, Standard_True);
1295 #include <BRepFeat_SplitShape.hxx>
1296 #include <ShapeAnalysis_ShapeContents.hxx>
1297 #include <BRepAlgo.hxx>
1298 static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1301 di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)";
1305 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1306 if(myAISContext.IsNull()) {
1307 di << "use 'vinit' command before " << argv[0] << "\n";
1311 TopoDS_Shape result;
1312 TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1]));
1313 TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2]));
1315 BRepFeat_SplitShape asplit(face);
1316 asplit.Add(wire, face);
1318 result = asplit.Shape();
1319 ShapeAnalysis_ShapeContents ana;
1320 ana.Perform(result);
1323 if (!(BRepAlgo::IsValid(result))) {
1324 di << "Result was checked and it is INVALID\n";
1326 di << "Result was checked and it is VALID\n";
1329 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result);
1330 myAISContext->Display(myShape, Standard_True);
1335 #include <Geom_Circle.hxx>
1336 #include <GeomAdaptor_Curve.hxx>
1337 #include <Extrema_ExtPC.hxx>
1338 #include <gp_Cylinder.hxx>
1339 #include <ElSLib.hxx>
1340 static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1343 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1347 gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 );
1348 gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() );
1349 Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 );
1350 GeomAdaptor_Curve aC3D( aCircle );
1352 Extrema_ExtPC aExtPC( aP3D, aC3D );
1353 //Standard_Real aParam = (aExtPC.Point(1)).Parameter();
1354 gp_Pnt aProj = (aExtPC.Point(1)).Value();
1355 di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n";
1357 // Result of deviation
1358 gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() );
1359 gp_Cylinder aCylinder( aCylAxis, 1890. );
1361 Standard_Real aU = 0., aV = 0.;
1362 ElSLib::Parameters( aCylinder, aProj, aU, aV );
1363 di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n";
1368 #include <Extrema_FuncPSNorm.hxx>
1369 #include <math_FunctionSetRoot.hxx>
1370 #include <math_Vector.hxx>
1371 #include <BRepBuilderAPI_MakeVertex.hxx>
1372 static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1374 Standard_Integer anArgIter = 1;
1377 theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]\n";
1382 Standard_CString aFaceName = theArgv[anArgIter++];
1383 Standard_CString aVertName = theArgv[anArgIter++];
1384 const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
1385 const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
1386 const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
1387 const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
1388 const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
1389 if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
1391 std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1394 if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1396 std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1399 const TopoDS_Face aFace = TopoDS::Face (aShapeF);
1400 const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1401 GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1403 gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1405 Extrema_FuncPSNorm anExtFunc;
1406 math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
1408 math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2);
1409 aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion();
1410 aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite();
1411 aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite();
1412 aFromUV(1) = aUFrom; aFromUV(2) = aVFrom;
1414 anExtFunc.Initialize (aSurf);
1415 anExtFunc.SetPoint (aPnt);
1416 aRoot.SetTolerance (aTolUV);
1417 aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1418 if (!aRoot.IsDone())
1420 std::cerr << "No results!\n";
1424 theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1426 aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1427 DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1431 //! Check boolean operations on NCollection_Map
1432 static Standard_Integer OCC24271 (Draw_Interpretor& di,
1433 Standard_Integer /*theArgNb*/,
1434 const char** /*theArgVec*/)
1437 const Standard_Integer aLeftLower = 1;
1438 const Standard_Integer aLeftUpper = 10;
1439 const Standard_Integer aRightLower = 5;
1440 const Standard_Integer aRightUpper = 15;
1443 NCollection_Map<Standard_Integer> aMapLeft;
1444 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1446 aMapLeft.Add (aKeyIter);
1449 NCollection_Map<Standard_Integer> aMapRight;
1450 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1452 aMapRight.Add (aKeyIter);
1455 QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1456 QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False);
1458 // validate Union operation
1459 NCollection_Map<Standard_Integer> aMapUnion;
1460 aMapUnion.Union (aMapLeft, aMapRight);
1461 QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1);
1462 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter)
1464 QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
1467 // validate Intersection operation
1468 NCollection_Map<Standard_Integer> aMapSect;
1469 aMapSect.Intersection (aMapLeft, aMapRight);
1470 QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1);
1471 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1473 QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1475 QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1476 QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
1478 // validate Substruction operation
1479 NCollection_Map<Standard_Integer> aMapSubsLR;
1480 aMapSubsLR.Subtraction (aMapLeft, aMapRight);
1481 QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower);
1482 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1484 QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
1487 NCollection_Map<Standard_Integer> aMapSubsRL;
1488 aMapSubsRL.Subtraction (aMapRight, aMapLeft);
1489 QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper);
1490 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1492 QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
1495 // validate Difference operation
1496 NCollection_Map<Standard_Integer> aMapDiff;
1497 aMapDiff.Difference (aMapLeft, aMapRight);
1498 QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper);
1499 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1501 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1503 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1505 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1508 // validate Exchange operation
1509 NCollection_Map<Standard_Integer> aMapSwap;
1510 aMapSwap.Exchange (aMapSect);
1511 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1513 QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1515 QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1519 NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1520 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1521 aMapCopy.Remove (34);
1523 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1528 #define QVERIFY(val1) \
1529 di << "Checking " #val1 " == Standard_True" << \
1530 ((val1) == Standard_True ? ": OK\n" : ": Error\n")
1532 #include <GeomInt_IntSS.hxx>
1533 #include <Geom_ConicalSurface.hxx>
1534 #include <Standard_ErrorHandler.hxx>
1535 //=======================================================================
1536 //function : OCC23972
1538 //=======================================================================
1539 static void DoGeomIntSSTest (const Handle(Geom_Surface)& theSurf1,
1540 const Handle(Geom_Surface)& theSurf2,
1541 const Standard_Integer theNbSol,
1542 Draw_Interpretor& di)
1546 GeomInt_IntSS anInter;
1547 anInter.Perform (theSurf1, theSurf2, Precision::Confusion(), Standard_True);
1548 QVERIFY (anInter.IsDone());
1549 QCOMPARE (anInter.NbLines(), theNbSol);
1551 QVERIFY (Standard_False);
1556 static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc,
1557 const gp_Dir& theDir,
1558 const gp_Dir& theXDir,
1559 const Standard_Real theRad,
1560 const Standard_Real theSin,
1561 const Standard_Real theCos)
1563 const Standard_Real anA = atan (theSin / theCos);
1564 gp_Ax3 anAxis (theLoc, theDir, theXDir);
1565 Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad);
1570 static Standard_Integer OCC23972 (Draw_Interpretor& di,Standard_Integer n, const char**)
1572 if (n != 1) return 1;
1574 //process specific cones, cannot read them from files because due to rounding the original error
1575 //in math_FunctionRoots gets hidden
1576 Handle(Geom_Surface) aS1 = CreateCone (
1577 gp_Pnt (123.694345356663, 789.9, 68.15),
1578 gp_Dir (-1, 3.48029791472957e-016, -8.41302743359754e-017),
1579 gp_Dir (-3.48029791472957e-016, -1, -3.17572289932207e-016),
1583 Handle(Geom_Surface) aS2 = CreateCone (
1584 gp_Pnt (123.694345356663, 784.9, 68.15),
1585 gp_Dir (-1, -2.5209507537117e-016, -1.49772808948866e-016),
1586 gp_Dir (1.49772808948866e-016, 3.17572289932207e-016, -1),
1591 DoGeomIntSSTest (aS1, aS2, 2, di);
1596 #include <ShapeFix_EdgeProjAux.hxx>
1597 static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1600 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
1604 TopoDS_Shape aSh = DBRep::Get(argv[1]);
1606 di << argv[0] << " Error: Null input edge\n";
1609 const TopoDS_Edge& anEdge = TopoDS::Edge (aSh);
1611 Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]);
1613 di << argv[0] << " Error: Null input curve\n";
1617 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]);
1619 di << argv[0] << " Error: Null input surface\n";
1623 Standard_Real prec = Draw::Atof(argv[4]);
1628 aB.MakeFace (aFace, aS, Precision::Confusion());
1629 aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion());
1630 aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter());
1633 ShapeFix_EdgeProjAux aProj (aFace, anEdge);
1634 aProj.Compute (prec);
1636 Standard_Boolean isfirstdone = aProj.IsFirstDone();
1637 Standard_Boolean islastdone = aProj.IsLastDone();
1639 Standard_Real first = 0.;
1640 Standard_Real last = 0.;
1641 Standard_Integer isfirstdoneInteger = 0;
1642 Standard_Integer islastdoneInteger = 0;
1646 first = aProj.FirstParam();
1647 isfirstdoneInteger = 1;
1651 last= aProj.LastParam();
1652 islastdoneInteger = 1;
1655 di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n";
1660 template<typename T, typename HT>
1661 static void DoIsNull(Draw_Interpretor& di)
1664 // QVERIFY (aHandle.IsNull());
1665 QCOMPARE (aHandle.IsNull(), Standard_True);
1666 const T* p = aHandle.get();
1667 #if OCC_VERSION_HEX > 0x060700
1670 QCOMPARE (!p, Standard_True);
1671 QCOMPARE (p == 0, Standard_True);
1675 //QVERIFY (!aHandle.IsNull());
1676 QCOMPARE (!aHandle.IsNull(), Standard_True);
1680 QCOMPARE (p != NULL, Standard_True);
1681 QCOMPARE (p != 0, Standard_True);
1684 //=======================================================================
1685 //function : OCC24533
1687 //=======================================================================
1688 static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**)
1690 if (n != 1) return 1;
1692 DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di);
1697 // Dummy class to test interface for compilation issues
1698 class QABugs_HandleClass : public Standard_Transient
1701 Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1703 std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n";
1706 DEFINE_STANDARD_RTTI_INLINE(QABugs_HandleClass,Standard_Transient) // Type definition
1708 DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1711 // Dummy class to test interface for compilation issues
1712 struct QABugs_NHandleClass
1714 Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1716 std::cerr << "QABugs_NHandleClass[" << this << "] " << theArgVec[0] << "\n";
1721 #include <XCAFDoc_ColorTool.hxx>
1722 #include <STEPControl_StepModelType.hxx>
1723 #include <STEPCAFControl_Writer.hxx>
1724 static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1727 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1730 Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");;
1731 TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape();
1732 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape();
1733 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1);
1734 TDataStd_Name::Set(lab1, "Box1");
1736 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1737 XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen);
1738 XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0);
1740 STEPControl_StepModelType mode = STEPControl_AsIs;
1741 STEPCAFControl_Writer writer;
1742 if ( ! writer.Transfer (aDoc, mode ) )
1744 di << "The document cannot be translated or gives no result" << "\n";
1748 writer.Write(argv[1]);
1753 //=======================================================================
1754 //function : OCC23950
1756 //=======================================================================
1757 static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1760 di << "Usage : " << argv[0] << " step_file\n";
1764 Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy");
1765 TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
1767 TopLoc_Location location0 (t0);
1769 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1770 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6);
1771 TDataStd_Name::Set(lab1, "Point1");
1773 TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1774 TDataStd_Name::Set(labelA0, "ASSEMBLY");
1776 TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
1778 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1779 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
1780 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
1782 STEPControl_StepModelType mode = STEPControl_AsIs;
1783 STEPCAFControl_Writer writer;
1784 if (! writer.Transfer (aDoc, mode))
1786 di << "The document cannot be translated or gives no result\n";
1790 writer.Write (argv[1]);
1794 //=======================================================================
1795 //function : OCC24622
1796 //purpose : The command tests sourcing Image_PixMap to AIS_TexturedShape
1797 //=======================================================================
1798 static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
1802 std::cout << "Usage : " << theArgVec[0] << " texture={1D|2D}";
1806 const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
1807 if (anAISContext.IsNull())
1809 std::cout << "Please initialize view with \"vinit\".\n";
1813 Handle(Image_PixMap) anImage = new Image_PixMap();
1815 static const Image_ColorRGB aBitmap[8] =
1817 {{255, 0, 0}}, {{0, 148, 255}}, {{ 0, 148, 255}}, {{255, 94, 0}},
1818 {{255, 121, 0}}, {{76, 255, 0}}, {{76, 255, 0}}, {{255, 202, 0}}
1821 TCollection_AsciiString aTextureTypeArg (theArgVec[1]);
1822 aTextureTypeArg.UpperCase();
1823 if (aTextureTypeArg == "1D")
1825 anImage->InitWrapper (Image_PixMap::ImgRGB, (Standard_Byte*)aBitmap, 8, 1);
1827 else if (aTextureTypeArg == "2D")
1829 anImage->InitTrash (Image_PixMap::ImgRGB, 8, 8);
1830 for (Standard_Integer aRow = 0; aRow < 8; ++aRow)
1832 for (Standard_Integer aCol = 0; aCol < 8; ++aCol)
1834 anImage->ChangeValue<Image_ColorRGB> (aRow, aCol) = aBitmap[aRow];
1840 std::cout << "Please specify type of texture to test {1D|2D}.\n";
1844 TopoDS_Shape aBlankShape = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
1846 Handle(AIS_TexturedShape) aTexturedShape = new AIS_TexturedShape (aBlankShape);
1847 aTexturedShape->SetTexturePixMap (anImage);
1848 anAISContext->Display (aTexturedShape, 3, 0);
1853 //=======================================================================
1854 //function : OCC24667
1856 //=======================================================================
1857 static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1861 di << "OCC24667 result Wire_spine Profile [Mode [Approx]]\n";
1862 di << "Mode = 0 - CorrectedFrenet,\n";
1863 di << " = 1 - Frenet,\n";
1864 di << " = 2 - DiscreteTrihedron\n";
1865 di << "Approx - force C1-approximation if result is C0\n";
1869 if (n > 1 && n < 4) return 1;
1871 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
1872 if ( Spine.IsNull()) return 1;
1874 TopoDS_Shape Profile = DBRep::Get(a[3]);
1875 if ( Profile.IsNull()) return 1;
1877 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
1880 Standard_Integer iMode = atoi(a[4]);
1882 Mode = GeomFill_IsFrenet;
1883 else if (iMode == 2)
1884 Mode = GeomFill_IsDiscreteTrihedron;
1887 Standard_Boolean ForceApproxC1 = Standard_False;
1889 ForceApproxC1 = Standard_True;
1891 BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine),
1896 TopoDS_Shape S = aPipe.Shape();
1897 TopoDS_Shape aSF = aPipe.FirstShape();
1898 TopoDS_Shape aSL = aPipe.LastShape();
1902 TCollection_AsciiString aStrF(a[1], "_f");
1903 TCollection_AsciiString aStrL(a[1], "_l");
1905 DBRep::Set(aStrF.ToCString(), aSF);
1906 DBRep::Set(aStrL.ToCString(), aSL);
1911 #include <BRepPrimAPI_MakeCylinder.hxx>
1912 #include <BRepBuilderAPI_Copy.hxx>
1913 #include <BRepTools_NurbsConvertModification.hxx>
1914 static TopoDS_Shape CreateTestShape (int& theShapeNb)
1916 TopoDS_Compound aComp;
1917 BRep_Builder aBuilder;
1918 aBuilder.MakeCompound (aComp);
1919 //NURBS modifier is used to increase footprint of each shape
1920 Handle(BRepTools_NurbsConvertModification) aNurbsModif = new BRepTools_NurbsConvertModification;
1921 TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid();
1922 BRepTools_Modifier aModifier (aRefShape, aNurbsModif);
1923 if (aModifier.IsDone()) {
1924 aRefShape = aModifier.ModifiedShape (aRefShape);
1927 for (; theShapeNb > 0; --theShapeNb) {
1928 TopoDS_Shape aShape;
1929 if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists
1930 aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape();
1932 aShape = CreateTestShape (theShapeNb);
1934 aBuilder.Add (aComp, aShape);
1939 #include <TDataStd_Integer.hxx>
1940 #include <TNaming_Builder.hxx>
1941 static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1944 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1947 TCollection_ExtendedString aFileName (argv[1]);
1948 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
1950 Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
1952 Handle(TDocStd_Document) aDoc;
1953 anApp->NewDocument ("XmlOcaf", aDoc);
1954 TDF_Label aLab = aDoc->Main();
1955 TDataStd_Integer::Set (aLab, 0);
1956 int n = 10000; //must be big enough
1957 TopoDS_Shape aShape = CreateTestShape (n);
1958 TNaming_Builder aBuilder (aLab);
1959 aBuilder.Generated (aShape);
1961 aSStatus = anApp->SaveAs (aDoc, aFileName);
1962 anApp->Close (aDoc);
1964 QCOMPARE (aSStatus, PCDM_SS_OK);
1968 #include <TDF_AttributeIterator.hxx>
1969 //=======================================================================
1970 //function : OCC24755
1972 //=======================================================================
1973 static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1977 std::cout << "Usage : " << a[0] << "\n";
1981 Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
1982 Handle(TDocStd_Document) aDoc;
1983 anApp->NewDocument ("BinOcaf", aDoc);
1984 TDF_Label aLab = aDoc->Main();
1985 TDataStd_Integer::Set (aLab, 0);
1986 TDataStd_Name::Set (aLab, "test");
1988 TDF_AttributeIterator i (aLab);
1989 Handle(TDF_Attribute) anAttr = i.Value();
1990 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True);
1993 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True);
2000 MyStubObject() : ptr(0L) {}
2001 MyStubObject(void* thePtr) : ptr(thePtr) {}
2006 //=======================================================================
2007 //function : OCC24834
2009 //=======================================================================
2010 static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2014 std::cout << "Usage : " << a[0] << "\n";
2018 int i = sizeof (char*);
2020 std::cout << "64-bit architecture is not supported.\n";
2024 NCollection_List<MyStubObject> aList;
2025 const Standard_Integer aSmallBlockSize = 40;
2026 const Standard_Integer aLargeBlockSize = 1500000;
2028 // quick populate memory with large blocks
2033 aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize)));
2036 catch (Standard_Failure)
2038 di << "caught out of memory for large blocks: OK\n";
2042 di << "skept out of memory for large blocks: Error\n";
2045 // allocate small blocks
2050 aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize)));
2053 catch (Standard_Failure)
2055 di << "caught out of memory for small blocks: OK\n";
2059 di << "skept out of memory for small blocks: Error\n";
2062 // release all allocated blocks
2063 for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next())
2065 Standard::Free(it.Value().ptr);
2071 #include <Geom2dAPI_InterCurveCurve.hxx>
2072 #include <IntRes2d_IntersectionPoint.hxx>
2073 //=======================================================================
2074 //function : OCC24889
2076 //=======================================================================
2077 static Standard_Integer OCC24889 (Draw_Interpretor& theDI,
2078 Standard_Integer /*theNArg*/,
2079 const char** /*theArgs*/)
2082 Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle(
2083 gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2085 Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle(
2086 gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2088 Handle( Geom2d_TrimmedCurve ) aTrim[2] = {
2089 new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ),
2090 new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 )
2093 DrawTrSurf::Set("c_1", aTrim[0]);
2094 DrawTrSurf::Set("c_2", aTrim[1]);
2097 const Standard_Real aTol = Precision::Confusion();
2098 Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol );
2100 const IntRes2d_IntersectionPoint& aIntPnt =
2101 aIntTool.Intersector().Point( 1 );
2103 gp_Pnt2d aIntRes = aIntTool.Point( 1 );
2104 Standard_Real aPar[2] = {
2105 aIntPnt.ParamOnFirst(),
2106 aIntPnt.ParamOnSecond()
2109 //theDI.precision( 5 );
2110 theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n";
2111 for (int i = 0; i < 2; ++i)
2113 theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() <<
2114 "; LastParam = " << aTrim[i]->LastParameter() <<
2115 "; IntParameter = " << aPar[i] << "\n";
2121 #include <math_GlobOptMin.hxx>
2122 #include <math_MultipleVarFunctionWithHessian.hxx>
2123 //=======================================================================
2124 //function : OCC25004
2125 //purpose : Check extremaCC on Branin function.
2126 //=======================================================================
2128 // f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s
2129 // Standard borders are:
2132 class BraninFunction : public math_MultipleVarFunctionWithHessian
2138 b = 5.1 / (4.0 * M_PI * M_PI);
2142 t = 1.0 / (8.0 * M_PI);
2144 virtual Standard_Integer NbVariables() const
2148 virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F)
2150 Standard_Real u = X(1);
2151 Standard_Real v = X(2);
2153 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2154 Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion.
2155 F = a * aSqPt * aSqPt + aLnPt + s;
2156 return Standard_True;
2158 virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G)
2160 Standard_Real u = X(1);
2161 Standard_Real v = X(2);
2163 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2164 G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u);
2165 G(2) = 2 * a * aSqPt;
2167 return Standard_True;
2169 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
2174 return Standard_True;
2176 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H)
2181 Standard_Real u = X(1);
2182 Standard_Real v = X(2);
2184 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2185 Standard_Real aTmpPt = c - 2 * b *u; // Tmp part.
2186 H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u);
2187 H(1,2) = 2 * a * aTmpPt;
2191 return Standard_True;
2195 // Standard parameters.
2196 Standard_Real a, b, c, r, s, t;
2199 static Standard_Integer OCC25004 (Draw_Interpretor& theDI,
2200 Standard_Integer /*theNArg*/,
2201 const char** /*theArgs*/)
2203 BraninFunction aFunc;
2205 math_Vector aLower(1,2), aUpper(1,2);
2211 Standard_Integer aGridOrder = 16;
2212 math_Vector aFuncValues(1, aGridOrder * aGridOrder);
2214 Standard_Real aLipConst = 0;
2215 math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2);
2217 // Get Lipshitz constant estimation on regular grid.
2218 Standard_Integer i, j, idx = 1;
2219 for(i = 1; i <= aGridOrder; i++)
2221 for(j = 1; j <= aGridOrder; j++)
2223 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2224 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2226 aFunc.Value(aCurrPnt1, aFuncValues(idx));
2231 Standard_Integer k, l;
2232 Standard_Integer idx1, idx2;
2233 for(i = 1; i <= aGridOrder; i++)
2234 for(j = 1; j <= aGridOrder; j++)
2235 for(k = 1; k <= aGridOrder; k++)
2236 for(l = 1; l <= aGridOrder; l++)
2238 if (i == k && j == l)
2241 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2242 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2243 idx1 = (i - 1) * aGridOrder + j;
2245 aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0);
2246 aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0);
2247 idx2 = (k - 1) * aGridOrder + l;
2249 aCurrPnt1.Add(-aCurrPnt2);
2250 Standard_Real dist = aCurrPnt1.Norm();
2252 Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist;
2257 math_GlobOptMin aFinder(&aFunc, aLower, aUpper, aLipConst);
2259 //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475)
2261 Standard_Real anExtValue = aFinder.GetF();
2262 theDI << "F = " << anExtValue << "\n";
2264 Standard_Integer aNbExt = aFinder.NbExtrema();
2265 theDI << "NbExtrema = " << aNbExt << "\n";
2270 #include <OSD_Environment.hxx>
2271 #include <Plugin.hxx>
2272 #include <Plugin_Macro.hxx>
2273 #include <Resource_Manager.hxx>
2275 #define THE_QATEST_DOC_FORMAT "My Proprietary Format"
2277 #define QA_CHECK(theDesc, theExpr, theValue) \
2279 const bool isTrue = !!(theExpr); \
2280 std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \
2283 class Test_TDocStd_Application : public TDocStd_Application
2287 Test_TDocStd_Application ()
2289 // explicitly initialize resource manager
2290 myResources = new Resource_Manager ("");
2291 myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT);
2292 myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document");
2293 myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml");
2296 virtual Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString&) Standard_OVERRIDE
2298 return new XmlDrivers_DocumentRetrievalDriver ();
2300 virtual Handle(PCDM_StorageDriver) WriterFromFormat (const TCollection_ExtendedString&) Standard_OVERRIDE
2302 return new XmlDrivers_DocumentStorageDriver ("Test");
2304 virtual Standard_CString ResourcesName() Standard_OVERRIDE { return ""; }
2307 //=======================================================================
2308 //function : OCC24925
2310 //=======================================================================
2311 static Standard_Integer OCC24925 (Draw_Interpretor& theDI,
2312 Standard_Integer theArgNb,
2313 const char** theArgVec)
2318 std::cout << "Error: wrong syntax! See usage:\n";
2319 theDI.PrintHelp (theArgVec[0]);
2323 Standard_Integer anArgIter = 1;
2324 TCollection_ExtendedString aFileName = theArgVec[anArgIter++];
2325 TCollection_AsciiString aPlugin = "TKXml";
2326 TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx
2327 TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx
2328 if (anArgIter < theArgNb)
2330 aPlugin = theArgVec[anArgIter++];
2331 aSaver = theArgVec[anArgIter++];
2332 aLoader = theArgVec[anArgIter++];
2335 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2336 PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError;
2338 Handle(TDocStd_Application) anApp = new Test_TDocStd_Application ();
2340 Handle(TDocStd_Document) aDoc;
2341 anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc);
2342 TDF_Label aLab = aDoc->Main();
2343 TDataStd_Integer::Set (aLab, 0);
2344 TDataStd_Name::Set (aLab, "QABugs_19.cxx");
2346 aSStatus = anApp->SaveAs (aDoc, aFileName);
2347 anApp->Close (aDoc);
2349 QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true);
2352 Handle(TDocStd_Document) aDoc;
2353 aRStatus = anApp->Open (aFileName, aDoc);
2354 anApp->Close (aDoc);
2356 QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true);
2360 //=======================================================================
2361 //function : OCC25043
2363 //=======================================================================
2364 #include <BRepAlgoAPI_Check.hxx>
2365 static Standard_Integer OCC25043 (Draw_Interpretor& theDI,
2366 Standard_Integer theArgNb,
2367 const char** theArgVec)
2369 if (theArgNb != 2) {
2370 theDI << "Usage: " << theArgVec[0] << " shape\n";
2374 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
2375 if (aShape.IsNull())
2377 theDI << theArgVec[1] << " shape is NULL\n";
2381 BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True);
2383 if (!anAlgoApiCheck.IsValid())
2385 BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result());
2386 for (; anCheckIter.More(); anCheckIter.Next())
2388 const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value();
2389 const BOPCol_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1();
2390 BOPCol_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes);
2391 for (; aFaultyIter.More(); aFaultyIter.Next())
2393 const TopoDS_Shape& aFaultyShape = aFaultyIter.Value();
2395 Standard_Boolean anIsFaultyShapeFound = Standard_False;
2396 TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType());
2397 for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next())
2399 if (anExp.Current().IsEqual(aFaultyShape))
2400 anIsFaultyShapeFound = Standard_True;
2403 if (!anIsFaultyShapeFound)
2405 theDI << "Error. Faulty Shape is NOT found in source shape.\n";
2410 theDI << "Info. Faulty shape is found in source shape\n";
2417 theDI << "Problems are not detected. Test is not performed.";
2423 //=======================================================================
2424 //function : OCC24606
2426 //=======================================================================
2427 static Standard_Integer OCC24606 (Draw_Interpretor& theDI,
2428 Standard_Integer theArgNb,
2429 const char** theArgVec)
2433 std::cerr << "Error: incorrect number of arguments.\n";
2434 theDI << "Usage : " << theArgVec[0] << "\n";
2438 Handle(V3d_View) aView = ViewerTest::CurrentView();
2441 std::cerr << "Errro: no active view, please call 'vinit'.\n";
2445 aView->DepthFitAll();
2451 //=======================================================================
2452 //function : OCC25202
2454 //=======================================================================
2455 #include <ShapeBuild_ReShape.hxx>
2456 static Standard_Integer OCC25202 ( Draw_Interpretor& theDI,
2457 Standard_Integer theArgN,
2458 const char** theArgVal)
2461 //reshape res shape numF1 face1 numF2 face2
2464 theDI << "Use: reshape res shape numF1 face1 numF2 face2\n";
2468 TopoDS_Shape aShape = DBRep::Get(theArgVal[2]);
2469 const Standard_Integer aNumOfRE1 = Draw::Atoi(theArgVal[3]),
2470 aNumOfRE2 = Draw::Atoi(theArgVal[5]);
2471 TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])),
2472 aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6]));
2476 theDI << theArgVal[2] << " is null shape\n";
2480 if(aShapeForRepl1.IsNull())
2482 theDI << theArgVal[4] << " is not a replaced type\n";
2486 if(aShapeForRepl2.IsNull())
2488 theDI << theArgVal[6] << " is not a replaced type\n";
2493 TopoDS_Shape aReplacedShape;
2494 ShapeBuild_ReShape aReshape;
2496 //////////////////// explode (begin)
2497 TopTools_MapOfShape M;
2499 Standard_Integer aNbShapes = 0;
2500 for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next())
2502 const TopoDS_Shape& Sx = ex.Current();
2503 Standard_Boolean added = M.Add(Sx);
2507 if(aNbShapes == aNumOfRE1)
2509 aReplacedShape = Sx;
2511 aReshape.Replace(aReplacedShape, aShapeForRepl1);
2514 if(aNbShapes == aNumOfRE2)
2516 aReplacedShape = Sx;
2518 aReshape.Replace(aReplacedShape, aShapeForRepl2);
2522 //////////////////// explode (end)
2524 if(aReplacedShape.IsNull())
2526 theDI << "There is not any shape for replacing.\n";
2529 DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2));
2534 #include <ShapeFix_Wireframe.hxx>
2535 //=======================================================================
2536 //function : OCC7570
2538 //=======================================================================
2539 static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2542 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
2545 TopoDS_Shape in_shape (DBRep::Get (a[1]));
2546 ShapeFix_Wireframe fix_tool (in_shape);
2547 fix_tool.ModeDropSmallEdges () = Standard_True;
2548 fix_tool.SetPrecision (1.e+6);
2549 fix_tool.SetLimitAngle (0.01);
2550 fix_tool.FixSmallEdges ();
2551 TopoDS_Shape new_shape = fix_tool.Shape ();
2555 #include <AIS_TypeFilter.hxx>
2556 //=======================================================================
2557 //function : OCC25340
2559 //=======================================================================
2560 static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/,
2561 Standard_Integer /*theArgNb*/,
2562 const char** /*theArgVec*/)
2564 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2567 std::cerr << "Error: No opened viewer!\n";
2570 Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
2571 aCtx->AddFilter (aFilter);
2575 //=======================================================================
2576 //function : OCC24826
2578 //=======================================================================
2579 class ParallelTest_Saxpy
2582 typedef NCollection_Array1<Standard_Real> Vector;
2585 ParallelTest_Saxpy(const Vector& theX, Vector& theY, Standard_Real theScalar)
2592 //! Dummy calculation
2593 void operator() (const Standard_Integer theIndex) const
2595 myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex);
2599 ParallelTest_Saxpy( const ParallelTest_Saxpy& );
2600 ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& );
2605 const Standard_Real myScalar;
2608 //---------------------------------------------------------------------
2609 static Standard_Integer OCC24826(Draw_Interpretor& theDI,
2610 Standard_Integer trheArgc,
2611 const char** theArgv)
2613 if ( trheArgc != 2 )
2622 Standard_Integer aLength = Draw::Atoi(theArgv[1]);
2624 NCollection_Array1<Standard_Real> aX (0, aLength - 1);
2625 NCollection_Array1<Standard_Real> anY(0, aLength - 1);
2627 for ( Standard_Integer i = 0; i < aLength; ++i )
2629 aX(i) = anY(i) = (Standard_Real) i;
2636 //! Serial proccesing
2637 for ( Standard_Integer i = 0; i < aLength; ++i )
2639 anY(i) = 1e-6 * aX(i) + anY(i);
2643 cout << "Processing time (sequential mode):\n";
2646 const ParallelTest_Saxpy aFunctor(aX, anY, 1e-6);
2651 // Parallel processing
2652 OSD_Parallel::For(0, aLength, aFunctor);
2655 cout << "Processing time (parallel mode):\n";
2661 /*****************************************************************************/
2663 #include <GeomAPI_IntSS.hxx>
2664 //=======================================================================
2665 //function : OCC25100
2667 //=======================================================================
2668 static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2672 di << "the method requires a shape name\n";
2676 TopoDS_Shape S = DBRep::Get(argv[1]);
2679 di << "Shape is empty\n";
2683 TopExp_Explorer aFaceExp(S, TopAbs_FACE);
2684 const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current()));
2686 GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion());
2688 if (!anIntersector.IsDone())
2690 di << "Error. Intersection is not done\n";
2694 di << "Test complete\n";
2699 //=======================================================================
2700 //function : OCC25348
2702 //=======================================================================
2703 static Standard_Integer OCC25348 (Draw_Interpretor& theDI,
2704 Standard_Integer /*theArgNb*/,
2705 const char** /*theArgVec*/)
2707 Handle(NCollection_IncAllocator) anAlloc1;
2708 NCollection_List<int> aList1(anAlloc1);
2709 for (int i=0; i < 10; i++)
2711 Handle(NCollection_IncAllocator) anAlloc2;
2712 NCollection_List<int> aList2(anAlloc2);
2714 aList1.Assign(aList2);
2716 theDI << "Test complete\n";
2720 #include <IntCurvesFace_ShapeIntersector.hxx>
2721 #include <BRepBndLib.hxx>
2722 //=======================================================================
2723 //function : OCC25413
2725 //=======================================================================
2726 static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
2729 di << "Usage: " << a[0] << " invalid number of arguments\n";
2732 TopoDS_Shape aShape = DBRep::Get (a[1]);
2734 IntCurvesFace_ShapeIntersector Inter;
2735 Inter.Load(aShape, Precision::Confusion());
2738 BRepBndLib::Add(aShape, aBndBox);
2740 gp_Dir aDir(0., 1., 0.);
2742 Standard_Real xMin = aBndBox.CornerMin().X();
2743 Standard_Real zMin = aBndBox.CornerMin().Z();
2744 Standard_Real xMax = aBndBox.CornerMax().X();
2745 Standard_Real zMax = aBndBox.CornerMax().Z();
2746 Standard_Real xStep = (xMax - xMin) / N;
2747 Standard_Real zStep = (zMax - zMin) / N;
2749 for (Standard_Real x = xMin; x <= xMax; x += xStep)
2750 for (Standard_Real z = zMin; z <= zMax; z += zStep)
2752 gp_Pnt aPoint(x, 0.0, z);
2753 gp_Lin aLine(aPoint, aDir);
2754 Inter.PerformNearest(aLine, -100., 100.);
2760 #include <BOPAlgo_PaveFiller.hxx>
2762 #include <BRepAlgoAPI_BooleanOperation.hxx>
2763 #include <BRepAlgoAPI_Common.hxx>
2764 #include <BRepAlgoAPI_Fuse.hxx>
2765 #include <BRepAlgoAPI_Cut.hxx>
2766 #include <BRepAlgoAPI_Section.hxx>
2768 #include <BOPTools.hxx>
2770 #include <BOPCol_MapOfShape.hxx>
2771 #include <BOPCol_ListOfShape.hxx>
2772 //=======================================================================
2773 //function : OCC25446
2775 //=======================================================================
2776 static Standard_Integer OCC25446 (Draw_Interpretor& theDI,
2777 Standard_Integer argc,
2781 theDI << "Usage: OCC25446 res b1 b2 op\n";
2785 TopoDS_Shape aS1 = DBRep::Get(argv[2]);
2787 theDI << argv[2] << " shape is NULL\n";
2791 TopoDS_Shape aS2 = DBRep::Get(argv[3]);
2793 theDI << argv[3] << " shape is NULL\n";
2797 Standard_Integer iOp;
2798 BOPAlgo_Operation aOp;
2800 iOp = Draw::Atoi(argv[4]);
2801 if (iOp < 0 || iOp > 4) {
2802 theDI << "Invalid operation type\n";
2805 aOp = (BOPAlgo_Operation)iOp;
2807 Standard_Integer iErr;
2808 BOPCol_ListOfShape aLS;
2809 BOPAlgo_PaveFiller aPF;
2813 aPF.SetArguments(aLS);
2816 iErr = aPF.ErrorStatus();
2818 theDI << "Intersection failed with error status: " << iErr << "\n";
2822 BRepAlgoAPI_BooleanOperation* pBuilder = NULL;
2825 case BOPAlgo_COMMON:
2826 pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF);
2829 pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
2832 pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF);
2835 pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
2837 case BOPAlgo_SECTION:
2838 pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF);
2844 iErr = pBuilder->ErrorStatus();
2845 if (!pBuilder->IsDone()) {
2846 theDI << "BOP failed with error status: " << iErr << "\n";
2850 const TopoDS_Shape& aRes = pBuilder->Shape();
2851 DBRep::Set(argv[1], aRes);
2853 BOPCol_MapOfShape aMapArgs, aMapShape;
2854 BOPCol_MapIteratorOfMapOfShape aIt;
2855 Standard_Boolean bIsDeletedHist, bIsDeletedMap;
2856 TopAbs_ShapeEnum aType;
2858 BOPTools::MapShapes(aS1, aMapArgs);
2859 BOPTools::MapShapes(aS2, aMapArgs);
2860 BOPTools::MapShapes(aRes, aMapShape);
2862 aIt.Initialize(aMapArgs);
2863 for (; aIt.More(); aIt.Next()) {
2864 const TopoDS_Shape& aS = aIt.Value();
2865 aType = aS.ShapeType();
2866 if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
2867 aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
2871 bIsDeletedHist = pBuilder->IsDeleted(aS);
2872 bIsDeletedMap = !aMapShape.Contains(aS) &&
2873 (pBuilder->Modified(aS).Extent() == 0);
2875 if (bIsDeletedHist != bIsDeletedMap) {
2876 theDI << "Error. Wrong value of IsDeleted flag.\n";
2881 theDI << "Test complete\n";
2885 //====================================================
2886 // Auxiliary functor class for the command OCC25545;
2887 // it gets access to a vertex with the given index and
2888 // checks that X coordinate of the point is equal to index;
2889 // if it is not so then a data race is reported.
2890 //====================================================
2891 struct OCC25545_Functor
2893 OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
2894 : myShapeVec(&theShapeVec),
2898 void operator()(size_t i) const
2900 if (!myIsRaceDetected) {
2901 const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i));
2902 gp_Pnt aP = BRep_Tool::Pnt (aV);
2903 if (aP.X () != static_cast<double> (i)) {
2904 Standard_Atomic_Increment(&myIsRaceDetected);
2909 const std::vector<TopoDS_Shape>* myShapeVec;
2910 mutable volatile int myIsRaceDetected;
2913 //=======================================================================
2914 //function : OCC25545
2915 //purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation()
2916 //=======================================================================
2918 static Standard_Integer OCC25545 (Draw_Interpretor& di,
2922 // Place vertices in a vector, giving the i-th vertex the
2923 // transformation that translates it on the vector (i,0,0) from the origin.
2925 std::vector<TopoDS_Shape> aShapeVec (n);
2926 std::vector<TopLoc_Location> aLocVec (n);
2927 TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ());
2928 aShapeVec[0] = aShape;
2929 for (size_t i = 1; i < n; ++i) {
2931 aT.SetTranslation (gp_Vec (1, 0, 0));
2932 aLocVec[i] = aLocVec[i - 1] * aT;
2933 aShapeVec[i] = aShape.Moved (aLocVec[i]);
2936 // Evaluator function will access vertices geometry
2938 OCC25545_Functor aFunc(aShapeVec);
2940 //concurrently process
2941 tbb::parallel_for (size_t (0), n, aFunc, tbb::simple_partitioner ());
2942 QVERIFY (!aFunc.myIsRaceDetected);
2946 static Standard_Integer OCC25545 (Draw_Interpretor&,
2950 cout << "Test skipped: command " << argv[0] << " requires TBB library" << endl;
2955 //=======================================================================
2956 //function : OCC25547
2958 //=======================================================================
2959 #include <BRepMesh_GeomTool.hxx>
2960 #include <BRepAdaptor_Curve.hxx>
2961 #include <Geom_TrimmedCurve.hxx>
2962 #include <BRepBuilderAPI_MakeFace.hxx>
2963 #include <BRepAdaptor_HSurface.hxx>
2964 #include <BRepAdaptor_Surface.hxx>
2965 static Standard_Integer OCC25547(
2966 Draw_Interpretor& theDI,
2967 Standard_Integer /*argc*/,
2968 const char ** /*argv*/)
2970 // The general aim of this test is to prevent linkage errors due to missed
2971 // Standard_EXPORT attribute for static methods.
2973 // However, start checking the main functionality at first.
2974 const Standard_Real aFirstP = 0., aLastP = M_PI;
2975 Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
2976 Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
2977 TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf);
2978 BRepAdaptor_Curve aAdaptor(aEdge);
2979 BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5);
2981 if (aGeomTool.NbPoints() == 0)
2983 theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
2987 // Test static methods.
2988 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
2989 BRepAdaptor_Surface aSurf(aFace);
2990 Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf);
2994 if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
2996 theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
3000 gp_XY aRefPnts[4] = {
3001 gp_XY(-10., -10.), gp_XY(10., 10.),
3002 gp_XY(-10., 10.), gp_XY(10., -10.)
3006 Standard_Real aParams[2];
3007 BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin(
3008 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3009 aIntPnt.ChangeCoord(), aParams);
3011 Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
3012 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3014 theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
3018 aIntFlag = BRepMesh_GeomTool::IntSegSeg(
3019 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3020 Standard_False, Standard_False, aIntPnt);
3022 aDiff = aIntPnt.Distance(gp::Origin2d());
3023 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3025 theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
3030 theDI << "Test complete\n";
3034 static Standard_Integer OCC26139 (Draw_Interpretor& theDI,
3035 Standard_Integer argc,
3039 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
3042 theDI << "Use 'vinit' command before " << argv[0] << "\n";
3046 Standard_Integer aBoxGridSize = 100;
3047 Standard_Integer aCompGridSize = 3;
3048 Standard_Real aBoxSize = 5.0;
3052 for (Standard_Integer anArgIdx = 1; anArgIdx < argc; ++anArgIdx)
3054 TCollection_AsciiString anArg (argv[anArgIdx]);
3056 if (anArg == "-boxgrid")
3058 aBoxGridSize = Draw::Atoi (argv[++anArgIdx]);
3060 else if (anArg == "-compgrid")
3062 aCompGridSize = Draw::Atoi (argv[++anArgIdx]);
3064 else if (anArg == "-boxsize")
3066 aBoxSize = Draw::Atof (argv[++anArgIdx]);
3071 NCollection_List<Handle(AIS_Shape)> aCompounds;
3072 for (Standard_Integer aCompGridX = 0; aCompGridX < aCompGridSize; ++aCompGridX)
3074 for (Standard_Integer aCompGridY = 0; aCompGridY < aCompGridSize; ++aCompGridY)
3076 BRep_Builder aBuilder;
3077 TopoDS_Compound aComp;
3078 aBuilder.MakeCompound (aComp);
3079 for (Standard_Integer aBoxGridX = 0; aBoxGridX < aBoxGridSize; ++aBoxGridX)
3081 for (Standard_Integer aBoxGridY = 0; aBoxGridY < aBoxGridSize; ++aBoxGridY)
3083 BRepPrimAPI_MakeBox aBox (gp_Pnt (aBoxGridX * aBoxSize, aBoxGridY * aBoxSize, 0.0),
3084 aBoxSize, aBoxSize, aBoxSize);
3085 aBuilder.Add (aComp, aBox.Shape());
3089 aTrsf.SetTranslation (gp_Vec (aBoxGridSize * aBoxSize * aCompGridX,
3090 aBoxGridSize * aBoxSize * aCompGridY,
3092 TopLoc_Location aLoc (aTrsf);
3093 aComp.Located (aLoc);
3094 aCompounds.Append (new AIS_Shape (aComp));
3099 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3102 aCtx->Display (aCompIter.Value(), Standard_False);
3104 theDI << "Display time: " << aTimer.ElapsedTime() << "\n";
3110 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3112 aCtx->Remove (aCompIter.Value(), Standard_False);
3115 theDI << "Remove time: " << aTimer.ElapsedTime() << "\n";
3120 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
3121 #include <TColStd_DataMapOfIntegerInteger.hxx>
3123 #include <ShapeFix_Wire.hxx>
3124 #include <ShapeExtend_Status.hxx>
3126 #define EXCEPTION ...
3128 #define EXCEPTION Standard_Failure
3131 static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)& theFix,
3132 const Standard_Boolean theIs3d)
3134 for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++)
3136 Standard_Boolean isFound;
3138 isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i );
3140 isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i );
3141 if (isFound) return ShapeExtend_Status(i);
3143 return ShapeExtend_OK;
3146 //===================
3147 //function : OCC24881
3149 //===================
3150 static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
3153 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
3156 // cout <<"FileName1: " << argv[1] <<endl;
3158 TopoDS_Shape aShape = DBRep::Get (a[1]);
3161 Handle(ShapeFix_Wire) aWireFix = new ShapeFix_Wire;
3163 // map FixStatus - NbSuchStatuses
3164 TColStd_DataMapOfIntegerInteger aStatusNbDMap;
3165 Standard_Integer nbFixed=0, nbOk=0;
3168 ShapeExtend_Status aStatus=ShapeExtend_OK;
3170 TopExp_Explorer aFaceExplorer(aShape, TopAbs_FACE);
3171 for (; aFaceExplorer.More(); aFaceExplorer.Next())
3173 TopoDS_Shape aFace = aFaceExplorer.Current();
3175 TopoDS_Iterator aWireItr(aFace);
3176 for (; aWireItr.More(); aWireItr.Next() )
3178 Standard_Boolean wasOk = Standard_False;
3179 TopoDS_Wire aSrcWire = TopoDS::Wire(aWireItr.Value());
3181 aWireFix->Load (aSrcWire);
3182 aWireFix->SetFace (TopoDS::Face(aFace));
3183 aWireFix->FixReorder(); //correct order is a prerequisite
3185 if (!aWireFix->FixGaps3d())
3188 aStatus = getStatusGap(aWireFix, Standard_True);
3189 if (aStatus == ShapeExtend_OK)
3190 wasOk = Standard_True;
3193 // keep 3d fail status
3194 if (aStatusNbDMap.IsBound (aStatus))
3195 aStatusNbDMap(aStatus)++;
3197 aStatusNbDMap.Bind(aStatus,1);
3203 if (aWireFix->FixGaps2d())
3207 aStatus = getStatusGap(aWireFix, Standard_False);
3208 if (aStatus == ShapeExtend_OK)
3220 // keep 2d fail status
3221 Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL;
3222 if (aStatusNbDMap.IsBound (aStatus2d))
3223 aStatusNbDMap(aStatus2d)++;
3225 aStatusNbDMap.Bind(aStatus2d,1);
3232 } catch (EXCEPTION) {
3233 di << "Exception is raised = " <<aStatus << "\n";
3237 // report what is done
3241 di <<"Fix_FillGaps_Fixed: nbFixed = "<<nbFixed <<"\n";
3246 di << "Fix_FillGaps_NothingToDo\n";
3249 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aStatusItr(aStatusNbDMap);
3250 for (; aStatusItr.More(); aStatusItr.Next())
3252 switch ((ShapeExtend_Status) aStatusItr.Key())
3255 case ShapeExtend_FAIL1:
3256 di <<"Fix_FillGaps_3dNoCurveFail, nb failed = ";
3258 case ShapeExtend_FAIL2:
3259 di <<"Fix_FillGaps_3dSomeGapsFail, nb failed = ";
3263 switch ((ShapeExtend_Status) (aStatusItr.Key() - ShapeExtend_FAIL))
3265 case ShapeExtend_FAIL1:
3266 di <<"Fix_FillGaps_2dNoPCurveFail, nb failed = ";
3268 case ShapeExtend_FAIL2:
3269 di <<"Fix_FillGaps_2dSomeGapsFail, nb failed = ";
3275 di <<aStatusItr.Value()<< "\n";
3277 di << ("__________________________________") <<"\n";
3282 //=======================================================================
3283 //function : OCC26172
3285 //=======================================================================
3286 static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3290 std::cerr << "Error: wrong number of arguments! See usage:\n";
3291 theDI.PrintHelp (theArgVec[0]);
3295 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
3296 if(anAISContext.IsNull())
3298 std::cerr << "Error: no active view. Please call vinit.\n";
3302 gp_Pnt aStart (100, 100, 100);
3303 gp_Pnt anEnd (300, 400, 600);
3304 BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
3305 TopoDS_Edge anEdge = anEdgeBuilder.Edge();
3306 Handle(AIS_Shape) aTestAISShape = new AIS_Shape (anEdge);
3307 anAISContext->Display (aTestAISShape);
3309 // 2. activate it in selection modes
3310 TColStd_SequenceOfInteger aModes;
3311 aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX));
3312 aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_EDGE));
3314 Standard_DISABLE_DEPRECATION_WARNINGS
3315 anAISContext->OpenLocalContext();
3316 Standard_ENABLE_DEPRECATION_WARNINGS
3317 anAISContext->Deactivate (aTestAISShape);
3318 anAISContext->Load (aTestAISShape, -1, true);
3319 for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt)
3321 anAISContext->Activate (aTestAISShape, aModes (anIt));
3324 // select entities in vertex selection mode
3325 Handle(SelectMgr_Selection) aSelection = aTestAISShape->Selection (aModes (1));
3326 Standard_DISABLE_DEPRECATION_WARNINGS
3327 for (aSelection->Init(); aSelection->More(); aSelection->Next())
3329 Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
3330 if (anEntity.IsNull())
3335 Handle(SelectMgr_EntityOwner) anOwner =
3336 Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
3338 if (anOwner.IsNull())
3343 anAISContext->LocalContext()->AddOrRemoveSelected (anOwner);
3345 Standard_ENABLE_DEPRECATION_WARNINGS
3347 // select entities in edge selection mode
3348 aSelection = aTestAISShape->Selection (aModes (2));
3349 Standard_DISABLE_DEPRECATION_WARNINGS
3350 for (aSelection->Init(); aSelection->More(); aSelection->Next())
3352 Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
3353 if (anEntity.IsNull())
3358 Handle(SelectMgr_EntityOwner) anOwner =
3359 Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
3361 if (anOwner.IsNull())
3366 anAISContext->LocalContext()->AddOrRemoveSelected (anOwner);
3368 Standard_ENABLE_DEPRECATION_WARNINGS
3370 // deactivate vertex mode and check clearing of outdated selection
3371 anAISContext->Deactivate (aTestAISShape, aModes (1));
3372 Standard_DISABLE_DEPRECATION_WARNINGS
3373 anAISContext->LocalContext()->ClearOutdatedSelection (aTestAISShape, true);
3374 Standard_ENABLE_DEPRECATION_WARNINGS
3379 //=======================================================================
3380 //function : OCC26284
3382 //=======================================================================
3383 static Standard_Integer OCC26284 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3387 std::cerr << "Error: wrong number of arguments! See usage:\n";
3388 theDI.PrintHelp (theArgVec[0]);
3392 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
3393 if (anAISContext.IsNull())
3395 std::cerr << "Error: no active view. Please call vinit.\n";
3399 BRepPrimAPI_MakeSphere aSphereBuilder (gp_Pnt (0.0, 0.0, 0.0), 1.0);
3400 Handle(AIS_Shape) aSphere = new AIS_Shape (aSphereBuilder.Shape());
3401 anAISContext->Display (aSphere);
3402 for (Standard_Integer aChildIdx = 0; aChildIdx < 5; ++aChildIdx)
3404 BRepPrimAPI_MakeSphere aBuilder (gp_Pnt (1.0 + aChildIdx, 1.0 + aChildIdx, 1.0 + aChildIdx), 1.0);
3405 Handle(AIS_Shape) aChild = new AIS_Shape (aBuilder.Shape());
3406 aSphere->AddChild (aChild);
3407 anAISContext->Display (aChild);
3410 anAISContext->RecomputeSelectionOnly (aSphere);
3415 #include <IntTools_Context.hxx>
3416 #include <GeomAPI_ProjectPointOnSurf.hxx>
3418 //=======================================================================
3419 //function : xprojponf
3421 //=======================================================================
3422 Standard_Integer xprojponf (Draw_Interpretor& di,
3427 di<<" use xprojponf p f \n";
3434 Handle(IntTools_Context) aCtx;
3436 DrawTrSurf::GetPoint(a[1], aP);
3437 aS=DBRep::Get(a[2]);
3440 di<<" null shape is not allowed\n";
3444 if (aS.ShapeType()!=TopAbs_FACE) {
3445 di << a[2] << " not a face\n";
3449 aCtx=new IntTools_Context;
3451 aF=TopoDS::Face(aS);
3452 GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF);
3455 if (!aPPS.IsDone()) {
3456 di<<" projection failed\n";
3460 aPS=aPPS.NearestPoint();
3461 di<< " point px " << aPS.X() << " " << aPS.Y() << " " << aPS.Z() << "\n";
3466 //=======================================================================
3467 //function : OCC25547
3469 //=======================================================================
3470 #include <BRepMesh_CircleTool.hxx>
3471 #include <SelectMgr_EntityOwner.hxx>
3473 static Standard_Boolean inspect_point(const gp_XY& thePoint,
3474 const gp_XY& theCenter,
3475 const Standard_Real theRadius)
3477 static Standard_Real aPrecision = Precision::PConfusion();
3478 static Standard_Real aSqPrecision = aPrecision * aPrecision;
3479 const gp_XY aDistVec = thePoint - theCenter;
3480 if (aDistVec.SquareModulus() - (theRadius * theRadius) < aSqPrecision)
3481 return Standard_True;
3483 return Standard_False;
3486 static Standard_Integer OCC24923(
3487 Draw_Interpretor& theDI,
3488 Standard_Integer argc,
3491 srand(static_cast<unsigned int>(time(NULL)));
3493 const Standard_Real aMaxDeviation = (argc > 1) ? Draw::Atof(argv[1]) : 0.01;
3494 const Standard_Integer aPointsNb = 10000000;
3495 const Standard_Real aMinAngle = 5 * M_PI / 180.;
3496 static Standard_Real aSqPrecision = Precision::PConfusion() * Precision::PConfusion();
3498 Standard_Integer aFailedNb = 0;
3499 for (Standard_Integer i = 0; i < aPointsNb; ++i)
3502 for (Standard_Integer j = 0; j < 3; ++j)
3503 p[j].SetCoord(((Standard_Real)rand())/RAND_MAX, ((Standard_Real)rand())/RAND_MAX);
3505 // Check that points do not compose degenerated triangle.
3506 gp_XY aVec1 = p[1] - p[0];
3507 gp_XY aVec2 = p[2] - p[0];
3508 if (aVec1.SquareModulus() > aSqPrecision &&
3509 aVec2.SquareModulus() > aSqPrecision &&
3510 (aVec1 ^ aVec2) > aMinAngle)
3513 Standard_Real aRadius;
3514 if (BRepMesh_CircleTool::MakeCircle(p[0], p[1], p[2], aCenter, aRadius))
3516 if (!inspect_point(p[0], aCenter, aRadius) ||
3517 !inspect_point(p[1], aCenter, aRadius) ||
3518 !inspect_point(p[2], aCenter, aRadius))
3520 /* theDI << "Missed: " <<
3521 "p1=(" << p1.X() << ", " << p1.Y() << "), " <<
3522 "p2=(" << p2.X() << ", " << p2.Y() << "), " <<
3523 "p3=(" << p3.X() << ", " << p3.Y() << "), " <<
3524 "c=(" << aCenter.X() << ", " << aCenter.Y() << "), " <<
3525 "r=" << aRadius << "\n";*/
3534 // Ensure that aPointsNb suitable for tests are generated
3538 const Standard_Real aDeviation =
3539 1. - (Standard_Real)(aPointsNb - aFailedNb) / (Standard_Real)aPointsNb;
3541 theDI << "Number of failed cases: " << aFailedNb << " (Total " << aPointsNb << ")\n";
3542 if (aDeviation > aMaxDeviation)
3544 theDI << "Failed. Number of incorrect results is too huge: " <<
3545 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
3549 theDI << "Deviation of incorrect results is: " <<
3550 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
3551 theDI << "Test completed\n";
3555 //=======================================================================
3556 //function : OCC25574
3557 //purpose : check implementation of Euler angles in gp_Quaternion
3558 //=======================================================================
3560 static Standard_Integer OCC25574 (Draw_Interpretor& theDI, Standard_Integer /*argc*/, const char** /*argv*/)
3562 Standard_Boolean isTestOk = Standard_True;
3564 // Check consistency of Get and Set operations for Euler angles
3565 gp_Quaternion aQuat;
3566 aQuat.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637);
3567 Standard_Real alpha,beta,gamma;
3568 gp_Mat aRinv = aQuat.GetMatrix().Inverted();
3571 const char* names[] = { "Extrinsic_XYZ", "Extrinsic_XZY", "Extrinsic_YZX", "Extrinsic_YXZ", "Extrinsic_ZXY", "Extrinsic_ZYX",
3572 "Intrinsic_XYZ", "Intrinsic_XZY", "Intrinsic_YZX", "Intrinsic_YXZ", "Intrinsic_ZXY", "Intrinsic_ZYX",
3573 "Extrinsic_XYX", "Extrinsic_XZX", "Extrinsic_YZY", "Extrinsic_YXY", "Extrinsic_ZYZ", "Extrinsic_ZXZ",
3574 "Intrinsic_XYX", "Intrinsic_XZX", "Intrinsic_YZY", "Intrinsic_YXY", "Intrinsic_ZXZ", "Intrinsic_ZYZ" };
3575 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3577 aQuat.GetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma);
3579 gp_Quaternion aQuat2;
3580 aQuat2.SetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma);
3582 gp_Mat aR = aQuat2.GetMatrix();
3583 gp_Mat aDiff = aR * aRinv - aI;
3584 if (aDiff.Determinant() > 1e-5)
3586 theDI << "Error: Euler angles conversion incorrect for sequence " << names[i - gp_Extrinsic_XYZ] << "\n";
3587 isTestOk = Standard_False;
3591 // Check conversion between intrinsic and extrinsic rotations
3592 // Any extrinsic rotation is equivalent to an intrinsic rotation
3593 // by the same angles but with inverted order of elemental rotations, and vice versa
3595 // Extrinsic_XZY = Incrinsic_XZY
3596 // R = X(A)Z(B)Y(G) --> R = Y(G)Z(B)X(A)
3597 alpha = 0.1517461713131;
3598 beta = 1.5162198410141;
3599 gamma = 1.9313156236541;
3600 Standard_Real alpha2, beta2, gamma2;
3601 gp_EulerSequence pairs[][2] = { {gp_Extrinsic_XYZ, gp_Intrinsic_ZYX},
3602 {gp_Extrinsic_XZY, gp_Intrinsic_YZX},
3603 {gp_Extrinsic_YZX, gp_Intrinsic_XZY},
3604 {gp_Extrinsic_YXZ, gp_Intrinsic_ZXY},
3605 {gp_Extrinsic_ZXY, gp_Intrinsic_YXZ},
3606 {gp_Extrinsic_ZYX, gp_Intrinsic_XYZ} };
3607 for (int i = 0; i < 6; i++)
3609 aQuat.SetEulerAngles(pairs[i][0], alpha, beta, gamma);
3610 aQuat.GetEulerAngles(pairs[i][1], gamma2, beta2, alpha2);
3612 if (Abs(alpha - alpha2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - gamma2) > 1e-5)
3614 theDI << "Error: intrinsic and extrinsic conversion incorrect for sequence " << names[i] << "\n";
3615 isTestOk = Standard_False;
3619 // Check correspondence of enumeration and actual rotation it defines,
3620 // by rotation by one axis and checking that it does not change a point on that axis
3621 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3623 // Iterate over rotations R(A)R(B)R(G) for each Euler angle Alpha, Beta, Gamma
3624 // There are three ordered axes corresponding to three rotations.
3625 // Each rotation applyed with current angle around current axis.
3626 for (int j=0; j < 3; j++)
3628 // note that current axis index is obtained by parsing of enumeration name!
3629 int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X';
3630 Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1);
3632 // Set 90 degrees to current Euler angle
3633 double anAngles[3] = {0., 0., 0.};
3634 anAngles[j] = 0.5 * M_PI;
3637 q2.SetEulerAngles (gp_EulerSequence(i), anAngles[0], anAngles[1], anAngles[2]);
3639 // Set point on axis corresponding to current rotation
3640 // We will apply rotation around this axis
3641 gp_XYZ v (0., 0., 0.);
3642 v.SetCoord (anAxis + 1, 1.);
3644 // Apply rotation to point
3646 aT.SetRotation (q2);
3650 // Check that point is still on origin position
3651 if ((v - v2).SquareModulus() > Precision::SquareConfusion())
3653 // avoid reporting small coordinates
3654 for (int k=1; k <= 3; k++)
3655 if (Abs (v2.Coord(k)) < Precision::Confusion())
3656 v2.SetCoord (k, 0.);
3658 isTestOk = Standard_False;
3659 theDI << "Error: Euler sequence " << names[i - gp_Extrinsic_XYZ] << " is incorrect:\n";
3660 theDI << "rotating by angle 90 deg around " << (anAxis == 0 ? "X" : anAxis == 1 ? "Y" : "Z") <<
3661 " converts vector (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") to ("
3662 << v2.X() << ", " << v2.Y() << ", " << v2.Z() << ")\n";
3667 // Check correspondence of enumeration and actual rotation it defines,
3668 // by comparing cumulative rotation matrix with sequence of rotations by axes
3669 const Standard_Real anAngle[3] = { 0.1, 0.2, 0.3 };
3670 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3672 // Sequence of rotations
3674 for (int j=0; j < 3; j++)
3676 // note that current axis index is obtained by parsing of enumeration name!
3677 int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X';
3678 Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1);
3680 // Set point on axis corresponding to current rotation
3681 // We will apply rotation around this axis
3682 gp_XYZ v (0., 0., 0.);
3683 v.SetCoord (anAxis + 1, 1.);
3684 aR[j].SetRotation (v, anAngle[j]);
3687 // construct cumulative transformation (differently for extrinsic and intrinsic rotations);
3688 // note that we parse first symbol of the enum name to identify its type
3690 if (names[i - gp_Extrinsic_XYZ][0] == 'E') // extrinsic
3692 aRot = aR[2] * aR[1] * aR[0];
3696 aRot = aR[0] * aR[1] * aR[2];
3699 // set the same angles in quaternion
3700 aQuat.SetEulerAngles (gp_EulerSequence(i), anAngle[0], anAngle[1], anAngle[2]);
3702 gp_Mat aRQ = aQuat.GetMatrix();
3703 gp_Mat aDiff = aRQ * aRot.Inverted() - aI;
3704 if (aDiff.Determinant() > 1e-5)
3706 theDI << "Error: Euler angles conversion does not correspond to sequential rotations for " << names[i - gp_Extrinsic_XYZ] << "\n";
3707 isTestOk = Standard_False;
3711 // similar checkfor YawPitchRoll sequence as defined in description of #25574
3713 // Start with world coordinate system
3716 // Perform three rotations using the yaw-pitch-roll convention.
3717 // This means: rotate around the original z axis with angle alpha,
3718 // then rotate around the new y axis with angle beta,
3719 // then rotate around the new x axis with angle gamma.
3720 alpha = 0.0 / 180.0 * M_PI;
3721 beta = -35.0 / 180.0 * M_PI;
3722 gamma = 90.0 / 180.0 * M_PI;
3724 const gp_Quaternion rotationZ(world.Direction(), alpha);
3725 const gp_Vec rotY = rotationZ.Multiply(world.YDirection());
3726 const gp_Vec rotX = rotationZ.Multiply(world.XDirection());
3728 const gp_Quaternion rotationY(rotY, beta);
3729 const gp_Vec rotZ = rotationY.Multiply(world.Direction());
3730 const gp_Vec rotRotX = rotationY.Multiply(rotX);
3732 const gp_Quaternion rotationX(rotRotX, gamma);
3733 const gp_Vec rotRotZ = rotationX.Multiply(rotZ);
3735 gp_Ax2 result(gp_Pnt(0.0, 0.0, 0.0), rotRotZ, rotRotX);
3737 // Now compute the Euler angles
3738 gp_Trsf transformation;
3739 transformation.SetDisplacement(gp_Ax2(), result);
3741 Standard_Real computedAlpha;
3742 Standard_Real computedBeta;
3743 Standard_Real computedGamma;
3745 transformation.GetRotation().GetEulerAngles(gp_YawPitchRoll, computedAlpha, computedBeta, computedGamma);
3747 // We expect now to get the same angles as we have used for our rotations
3748 if (Abs(alpha - computedAlpha) > 1e-5 || Abs(beta - computedBeta) > 1e-5 || Abs(gamma - computedGamma) > 1e-5)
3750 theDI << "Error: unexpected values of Euler angles for YawPitchRoll sequence:\n";
3751 theDI << "alpha: " << alpha / M_PI * 180.0 << " and computed alpha: "
3752 << computedAlpha / M_PI * 180.0 << "\n";
3753 theDI << "beta: " << beta / M_PI * 180.0 << " and computed beta: "
3754 << computedBeta / M_PI * 180.0 << "\n";
3755 theDI << "gamma: " << gamma / M_PI * 180.0 << " and computed gamma: "
3756 << computedGamma / M_PI * 180.0 << "\n";
3757 isTestOk = Standard_False;
3764 q.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637);
3766 q.GetEulerAngles(gp_Intrinsic_ZYX, alpha,beta, gamma);
3767 q.GetEulerAngles(gp_Extrinsic_XYZ, alpha2,beta2,gamma2);
3769 // gp_Intrinsic_ZYX and gp_Extrinsic_XYZ should produce the same values of angles but in opposite order
3770 if (Abs(alpha - gamma2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - alpha2) > 1e-5)
3772 theDI << "Error: Euler angles computed for gp_Intrinsic_ZYX and gp_Extrinsic_XYZ do not match:\n";
3773 theDI << "alpha: " << alpha / M_PI * 180.0 << " and " << alpha2 / M_PI * 180.0 << "\n";
3774 theDI << "beta: " << beta / M_PI * 180.0 << " and " << beta2 / M_PI * 180.0 << "\n";
3775 theDI << "gamma: " << gamma / M_PI * 180.0 << " and " << gamma2 / M_PI * 180.0 << "\n";
3776 isTestOk = Standard_False;
3780 theDI << (isTestOk ? "Test completed" : "Test failed") << "\n";
3784 #include <TColGeom_Array1OfBSplineCurve.hxx>
3785 #include <TColStd_Array1OfReal.hxx>
3786 #include <TColGeom_HArray1OfBSplineCurve.hxx>
3787 #include <GeomConvert.hxx>
3789 //=======================================================================
3790 //function : OCC26446
3792 //=======================================================================
3793 Standard_Integer OCC26446 (Draw_Interpretor& di,
3798 di << "Usage: OCC26446 r c1 c2\n";
3802 Handle(Geom_BSplineCurve) aCurve1 =
3803 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[2]));
3804 Handle(Geom_BSplineCurve) aCurve2 =
3805 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[3]));
3807 if (aCurve1.IsNull()) {
3808 di << a[2] << " is not a BSpline curve\n";
3812 if (aCurve2.IsNull()) {
3813 di << a[3] << " is not a BSpline curve\n";
3817 TColGeom_Array1OfBSplineCurve aCurves (0, 1);
3818 TColStd_Array1OfReal aTolerances (0, 0);
3819 Standard_Real aTolConf = 1.e-3;
3820 Standard_Real aTolClosure = Precision::Confusion();
3821 Handle(TColGeom_HArray1OfBSplineCurve) aConcatCurves;
3822 Handle(TColStd_HArray1OfInteger) anIndices;
3824 aCurves.SetValue(0, aCurve1);
3825 aCurves.SetValue(1, aCurve2);
3826 aTolerances.SetValue(0, aTolConf);
3828 GeomConvert::ConcatC1(aCurves,
3835 Handle(Geom_BSplineCurve) aResult =
3836 aConcatCurves->Value(aConcatCurves->Lower());
3838 DrawTrSurf::Set(a[1], aResult);
3842 static Standard_Integer OCC26448 (Draw_Interpretor& theDI, Standard_Integer, const char **)
3844 TColStd_SequenceOfReal aSeq1, aSeq2;
3846 aSeq1.Prepend (aSeq2);
3847 theDI << "TCollection: 11 -> " << aSeq1.First() << "\n";
3849 NCollection_Sequence<Standard_Real> nSeq1, nSeq2;
3851 nSeq1.Prepend (nSeq2);
3852 theDI << "NCollection: 11 -> " << nSeq1.First() << "\n";
3858 //=======================================================================
3859 //function : OCC26407
3861 //=======================================================================
3862 #include <BRepBuilderAPI_MakeWire.hxx>
3863 #include <BRepBuilderAPI_MakeEdge.hxx>
3864 #include <BRepMesh_IncrementalMesh.hxx>
3865 #include <TCollection_AsciiString.hxx>
3866 static Standard_Integer OCC26407 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3870 std::cerr << "Error: wrong number of arguments! See usage:\n";
3871 theDI.PrintHelp (theArgVec[0]);
3875 // Construct vertices.
3876 std::vector<TopoDS_Vertex> wire_vertices;
3877 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.90000000000009094947, 40.6758179230516248026106, 88.5)));
3878 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(807.824182076948432040808, 260.599999999999965893949, 88.5)));
3879 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(644.174182076948454778176, 424.249999999999943156581, 88.5000000000000142108547)));
3880 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(629.978025792618950617907, 424.25, 88.5)));
3881 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(793.628025792618700506864, 260.599999999999852207111, 88.5)));
3882 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.900000000000204636308, 54.8719742073813492311274, 88.5)));
3883 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(218.521974207381418864315, 424.250000000000056843419, 88.5)));
3884 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(204.325817923051886282337, 424.249999999999943156581, 88.5)));
3887 BRepBuilderAPI_MakeWire wire_builder;
3888 for (size_t i = 0; i < wire_vertices.size(); i++)
3890 const TopoDS_Vertex &v = wire_vertices[i];
3891 const TopoDS_Vertex &w = wire_vertices[(i+1) % wire_vertices.size()];
3893 wire_builder.Add(BRepBuilderAPI_MakeEdge(v, w));
3896 // Create face and triangulate it.
3898 gp_Pnt v0 = BRep_Tool::Pnt(wire_vertices[0]);
3899 gp_Pnt v1 = BRep_Tool::Pnt(wire_vertices[1]);
3900 gp_Pnt v2 = BRep_Tool::Pnt(wire_vertices[wire_vertices.size() - 1]);
3902 gp_Vec face_normal = gp_Vec(v0, v1).Crossed(gp_Vec(v0, v2));
3904 TopoDS_Face face = BRepBuilderAPI_MakeFace(gp_Pln(v0, face_normal), wire_builder);
3905 BRepMesh_IncrementalMesh m(face, 1e-7);
3907 if (m.GetStatusFlags() != 0)
3909 theDI << "Failed. Status for face constructed from vertices: " << m.GetStatusFlags() << "\n";
3912 DBRep::Set(theArgVec[1], face);
3914 sprintf(buf, "isos %s 0", theArgVec[1]);
3917 sprintf(buf, "triangles %s", theArgVec[1]);
3920 theDI.Eval("smallview; fit");
3922 theDI << "Test completed\n";
3926 //=======================================================================
3927 //function : OCC26485
3929 //=======================================================================
3931 static Standard_Integer OCC26485 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3935 std::cerr << "Error: wrong number of arguments! See usage:\n";
3936 theDI.PrintHelp (theArgVec[0]);
3940 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
3941 if (aShape.IsNull())
3943 theDI << "Failed. Null shape\n";
3947 Standard_Boolean isFailed = Standard_False;
3948 TopExp_Explorer aExplorer(aShape, TopAbs_FACE);
3949 for (; aExplorer.More(); aExplorer.Next())
3951 const TopoDS_Face& aFace = TopoDS::Face( aExplorer.Current() );
3952 TopLoc_Location L = TopLoc_Location();
3953 const Handle(Poly_Triangulation)& aT = BRep_Tool::Triangulation( aFace , L );
3958 Poly::ComputeNormals(aT);
3959 const TColgp_Array1OfPnt& aVertices = aT->Nodes();
3960 const TShort_Array1OfShortReal& aNormals = aT->Normals();
3962 // Number of nodes in the triangulation
3963 int aVertexNb = aT->Nodes().Length();
3964 if (aVertexNb*3 != aNormals.Length())
3966 theDI << "Failed. Different number of normals vs. vertices\n";
3970 // Get each vertex index, checking common vertexes between shapes
3971 for( int i=0; i < aVertexNb; i++ )
3973 gp_Pnt aPoint = aVertices.Value( i+1 );
3974 gp_Vec aNormal = gp_Vec(
3975 aNormals.Value( i*3 + 1 ),
3976 aNormals.Value( i*3 + 2 ),
3977 aNormals.Value( i*3 + 3 ) );
3979 if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
3982 sprintf(buf, "fail_%d", i+1);
3983 theDI << "Failed. Point " << buf << ": "
3984 << aPoint.X() << " "
3985 << aPoint.Y() << " "
3986 << aPoint.Z() << "\n";
3988 DrawTrSurf::Set (buf, aPoint);
3993 theDI << (isFailed ? "Test failed" : "Test completed") << "\n";
3997 //=======================================================================
3998 //function : OCC26553
4000 //=======================================================================
4001 #include <BRepBuilderAPI_MakeWire.hxx>
4003 static Standard_Integer OCC26553 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4007 theDI << "Error: path to file with shell is missing\n";
4011 BRep_Builder aBuilder;
4012 TopoDS_Shape aShell;
4013 BRepTools::Read(aShell, theArgv[1], aBuilder);
4015 if (aShell.IsNull())
4017 theDI << "Error: shell not loaded\n";
4021 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge (gp_Pnt (0, 0, 0), gp_Pnt (0, 0, 10));
4022 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
4024 BRepOffsetAPI_MakePipe aPipeBuilder(aPipeWire, aShell);
4025 if (!aPipeBuilder.IsDone())
4027 theDI << "Error: failed to create pipe\n";
4031 for (TopExp_Explorer aShapeExplorer(aShell, TopAbs_EDGE); aShapeExplorer.More(); aShapeExplorer.Next ()) {
4032 const TopoDS_Shape& aGeneratedShape = aPipeBuilder.Generated(aPipeEdge, aShapeExplorer.Current());
4033 if (aGeneratedShape.IsNull())
4035 theDI << "Error: null shape\n";
4040 theDI << "History returned successfully\n";
4044 //=======================================================================
4045 //function : OCC26195
4047 //=======================================================================
4048 #include <SelectMgr_SelectingVolumeManager.hxx>
4049 #include <BRepBuilderAPI_MakePolygon.hxx>
4050 #include <Geom_CartesianPoint.hxx>
4051 #include <AIS_Line.hxx>
4052 #include <Aspect_Window.hxx>
4053 static Standard_Integer OCC26195 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
4057 std::cerr << "Error: wrong number of arguments! See usage:\n";
4058 theDI.PrintHelp (theArgVec[0]);
4062 if (ViewerTest::GetAISContext().IsNull())
4064 std::cerr << "Error: No opened context!\n";
4068 gp_Pnt2d aPxPnt1, aPxPnt2;
4069 aPxPnt1.SetX (Draw::Atof (theArgVec[1]));
4070 aPxPnt1.SetY (Draw::Atof (theArgVec[2]));
4073 aPxPnt2.SetX (Draw::Atof (theArgVec[3]));
4074 aPxPnt2.SetY (Draw::Atof (theArgVec[4]));
4076 Standard_Boolean toPrint = Standard_False;
4077 if (theArgNb % 2 == 0)
4079 toPrint = Draw::Atoi (theArgVec[theArgNb - 1]) != 0;
4082 SelectMgr_SelectingVolumeManager* aMgr = new SelectMgr_SelectingVolumeManager();
4083 aMgr->SetActiveSelectionType (theArgNb > 4 ?
4084 SelectMgr_SelectingVolumeManager::Box : SelectMgr_SelectingVolumeManager::Point);
4085 aMgr->SetCamera (ViewerTest::CurrentView()->Camera());
4086 aMgr->SetPixelTolerance (ViewerTest::GetAISContext()->PixelTolerance());
4087 Standard_Integer aWidth, aHeight;
4088 ViewerTest::CurrentView()->View()->Window()->Size (aWidth, aHeight);
4089 aMgr->SetWindowSize (aWidth, aHeight);
4092 aMgr->BuildSelectingVolume (aPxPnt1, aPxPnt2);
4096 aMgr->BuildSelectingVolume (aPxPnt1);
4098 const gp_Pnt* aVerts = aMgr->GetVertices();
4099 gp_Pnt aNearPnt = aMgr->GetNearPickedPnt();
4100 gp_Pnt aFarPnt = aMgr->GetFarPickedPnt();
4101 BRepBuilderAPI_MakePolygon aWireBldrs[4];
4103 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4104 aWireBldrs[0].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
4105 aWireBldrs[0].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
4106 aWireBldrs[0].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
4107 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4109 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
4110 aWireBldrs[1].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
4111 aWireBldrs[1].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
4112 aWireBldrs[1].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
4113 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
4115 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
4116 aWireBldrs[2].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
4117 aWireBldrs[2].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
4118 aWireBldrs[2].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
4119 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
4121 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4122 aWireBldrs[3].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
4123 aWireBldrs[3].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
4124 aWireBldrs[3].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
4125 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4127 TopoDS_Compound aComp;
4128 BRep_Builder aCompBuilder;
4129 aCompBuilder.MakeCompound (aComp);
4130 for (Standard_Integer aWireIdx = 0; aWireIdx < 4; ++aWireIdx)
4132 aCompBuilder.Add (aComp, aWireBldrs[aWireIdx].Shape());
4134 DBRep::Set ("c", aComp);
4136 Handle(AIS_InteractiveObject) aCmp = new AIS_Shape (aComp);
4137 aCmp->SetColor (Quantity_NOC_GREEN);
4138 ViewerTest::Display ("c", aCmp, Standard_True, Standard_True);
4140 Handle(Geom_CartesianPoint) aPnt1 = new Geom_CartesianPoint (aNearPnt);
4141 Handle(Geom_CartesianPoint) aPnt2 = new Geom_CartesianPoint (aFarPnt);
4143 Handle(AIS_Line) aLine = new AIS_Line (aPnt1, aPnt2);
4144 ViewerTest::Display ("l", aLine, Standard_True, Standard_True);
4148 theDI << "Near: " << aNearPnt.X() << " " << aNearPnt.Y() << " " << aNearPnt.Z() << "\n";
4149 theDI << "Far: " << aFarPnt.X() << " " << aFarPnt.Y() << " " << aFarPnt.Z() << "\n";
4155 //=======================================================================
4156 //function : OCC26462
4158 //=======================================================================
4159 static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
4161 if (ViewerTest::GetAISContext().IsNull())
4163 std::cerr << "Error: No opened context!\n";
4167 BRepPrimAPI_MakeBox aBuilder1 (gp_Pnt (10.0, 10.0, 0.0), 10.0, 10.0, 10.0);
4168 BRepPrimAPI_MakeBox aBuilder2 (10.0, 10.0, 10.0);
4169 Handle(AIS_InteractiveObject) aBox1 = new AIS_Shape (aBuilder1.Shape());
4170 Handle(AIS_InteractiveObject) aBox2 = new AIS_Shape (aBuilder2.Shape());
4172 const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
4173 aCtx->Display (aBox1, 0, 2);
4174 aCtx->Display (aBox2, 0, 2);
4175 ViewerTest::CurrentView()->FitAll();
4176 aCtx->SetWidth (aBox1, 3);
4177 aCtx->SetWidth (aBox2, 3);
4179 aCtx->MoveTo (305, 322, ViewerTest::CurrentView());
4180 aCtx->ShiftSelect();
4181 aCtx->MoveTo (103, 322, ViewerTest::CurrentView());
4182 aCtx->ShiftSelect();
4183 if (aCtx->NbSelected() != 0)
4185 theDI << "ERROR: no boxes must be selected!\n";
4189 aCtx->SetSelectionSensitivity (aBox1, 2, 5);
4191 aCtx->MoveTo (305, 322, ViewerTest::CurrentView());
4192 aCtx->ShiftSelect();
4193 if (aCtx->NbSelected() != 1)
4195 theDI << "ERROR: b1 was not selected\n";
4198 aCtx->MoveTo (103, 322, ViewerTest::CurrentView());
4199 aCtx->ShiftSelect();
4200 if (aCtx->NbSelected() != 1)
4202 theDI << "ERROR: b2 is selected after b1's tolerance increased\n";
4210 #include <BRepBuilderAPI_GTransform.hxx>
4211 static Standard_Integer OCC26313(Draw_Interpretor& di,Standard_Integer n,const char** a)
4213 if (n <= 1) return 1;
4218 gp_Mat rot( 1.0, 0.0, 0.0,
4222 GT.SetVectorialPart(rot);
4223 BRepBuilderAPI_GTransform gtrf(GT);
4225 TopoDS_Shape aSrcShape = DBRep::Get(a[2]);
4226 if (aSrcShape.IsNull()) {
4227 di << a[2] << " is not a valid shape\n";
4232 gtrf.Perform(aSrcShape);
4237 DBRep::Set(a[1], gtrf.ModifiedShape(aSrcShape));
4239 catch(Standard_Failure)
4241 di << "Error: Exception is thrown\n";
4246 di << "Error: Result is not done\n";
4253 //=======================================================================
4254 //function : OCC26525
4255 //purpose : check number of intersection points
4256 //=======================================================================
4257 #include <BRepAdaptor_Curve.hxx>
4258 #include <BRepAdaptor_Surface.hxx>
4259 #include <BRepAdaptor_HCurve.hxx>
4260 #include <BRepAdaptor_HSurface.hxx>
4261 #include <IntCurveSurface_HInter.hxx>
4262 Standard_Integer OCC26525 (Draw_Interpretor& di,
4266 TopoDS_Shape aS1, aS2;
4272 di << " use OCC26525 r edge face \n";
4276 aS1 = DBRep::Get(a[2]);
4277 aS2 = DBRep::Get(a[3]);
4279 if (aS1.IsNull() || aS2.IsNull())
4281 di << " Null shapes are not allowed \n";
4284 if (aS1.ShapeType()!=TopAbs_EDGE)
4286 di << " Shape" << a[2] << " should be of type EDGE\n";
4289 if (aS2.ShapeType()!=TopAbs_FACE)
4291 di << " Shape" << a[3] << " should be of type FACE\n";
4295 aE=TopoDS::Edge(aS1);
4296 aF=TopoDS::Face(aS2);
4299 Standard_Boolean bIsDone;
4300 Standard_Integer i, aNbPoints;
4301 Standard_Real aU, aV, aT;
4303 BRepAdaptor_Curve aBAC;
4304 BRepAdaptor_Surface aBAS;
4305 IntCurveSurface_TransitionOnCurve aTC;
4306 IntCurveSurface_HInter aHInter;
4308 aBAC.Initialize(aE);
4309 aBAS.Initialize(aF);
4311 Handle(BRepAdaptor_HCurve) aHBAC=new BRepAdaptor_HCurve(aBAC);
4312 Handle(BRepAdaptor_HSurface) aHBAS = new BRepAdaptor_HSurface(aBAS);
4314 aHInter.Perform(aHBAC, aHBAS);
4315 bIsDone=aHInter.IsDone();
4318 di << " intersection is not done\n";
4322 aNbPoints=aHInter.NbPoints();
4323 sprintf (buf, " Number of intersection points found: %d", aNbPoints);
4325 for (i=1; i<=aNbPoints; ++i)
4327 const IntCurveSurface_IntersectionPoint& aIP=aHInter.Point(i);
4328 aIP.Values(aP, aU, aV, aT, aTC);
4330 sprintf (buf, "point %s_%d %lg %lg %lg ", a[1], i, aP.X(), aP.Y(), aP.Z());
4337 //=======================================================================
4338 //function : OCC24537
4339 //purpose : Puts inverted numbers (in the sense of little/big endian inversion)
4340 // from predefined arrays.
4341 //=======================================================================
4342 #include <FSD_BinaryFile.hxx>
4345 inline const unsigned char* SizeRef ();
4348 inline const unsigned char* SizeRef <8> ()
4350 static const unsigned char aSizeRef[] = {
4351 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4352 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
4353 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
4354 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,
4355 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,
4356 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,
4357 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
4358 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
4359 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,
4360 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4365 inline const unsigned char* SizeRef <4> ()
4367 static const unsigned char aSizeRef[] = {
4368 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4369 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4370 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4371 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4372 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4376 static Standard_Integer OCC24537(
4377 Draw_Interpretor& theDI,
4378 Standard_Integer argc,
4387 cout << "cannot create file " << argv[1] << endl;
4391 Standard_Boolean isErr = Standard_False;
4393 const unsigned char anIntRef[] = {
4394 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4395 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4396 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4397 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4398 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4399 Standard_Integer anIntArr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
4402 for(int i = 0; i < 10; ++i)
4404 Standard_Integer anInv = FSD_BinaryFile::InverseInt(anIntArr[i]);
4405 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4410 Standard_Integer anInv[10];
4411 for(int i = 0; i < 10; ++i)
4412 anInv[i] = FSD_BinaryFile::InverseInt(anIntArr[i]);
4413 if (memcmp(anInv, anIntRef, sizeof(anIntRef)) != 0)
4415 theDI << "Error: incorrect conversion of an integer value\n";
4416 isErr = Standard_True;
4420 // 1a. Random InverseInt
4421 const unsigned char aRndIntRef[] = {
4422 0xFF,0xC2,0xF7,0x00,0xFF,0xFF,0xFB,0x2E,
4423 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4424 0x00,0x00,0x04,0xD2,0x00,0x00,0x04,0xD3,
4425 0xFF,0xFF,0xFD,0x1E,0xFF,0xFF,0xFF,0xFB,
4426 0x00,0x00,0x03,0x8D,0x00,0x3D,0x09,0x00};
4427 Standard_Integer aRndIntArr[] = {-4000000, -1234, 0, 1, 1234, 1235, -738, -5, 909, 4000000};
4430 for(int i = 0; i < 10; ++i)
4432 Standard_Integer anInv = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4433 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4438 Standard_Integer anInv[10];
4439 for(int i = 0; i < 10; ++i)
4440 anInv[i] = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4441 if (memcmp(anInv, aRndIntRef, sizeof(aRndIntRef)) != 0)
4443 theDI << "Error: incorrect conversion of a dispersed integer value\n";
4444 isErr = Standard_True;
4449 const unsigned char aRealRef[] = {
4450 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4451 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4452 0x40,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
4453 0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
4454 0x40,0x14,0x00,0x00,0x00,0x00,0x00,0x00,
4455 0x40,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
4456 0x40,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
4457 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4458 0x40,0x22,0x00,0x00,0x00,0x00,0x00,0x00,
4459 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4460 const Standard_Real aRealArr[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0};
4463 for(int i = 0; i < 10; ++i)
4465 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRealArr[i]);
4466 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4471 Standard_Real anInv[10];
4472 for(int i = 0; i < 10; ++i)
4473 anInv[i] = FSD_BinaryFile::InverseReal(aRealArr[i]);
4474 if (memcmp(anInv, aRealRef, sizeof(aRealRef)) != 0)
4476 theDI << "Error: incorrect conversion of a real value\n";
4477 isErr = Standard_True;
4481 // 2a. Random InverseReal
4482 const unsigned char aRndRealRef[] = {
4483 0xFE,0x37,0xE4,0x3C,0x88,0x00,0x75,0x9C,
4484 0xBE,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4485 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4486 0x3E,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4487 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4488 0x40,0x09,0x21,0xDA,0x45,0x5B,0x53,0xE4,
4489 0x54,0xB2,0x49,0xAD,0x25,0x94,0xC3,0x7D,
4490 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4491 0xC0,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD,
4492 0x40,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD};
4493 const Standard_Real aRndRealArr[] = {-1e300, -1.e-9, 0., 1.e-9, 1., 3.1415296, 1.e100, 8.0, -9.9, 9.9};
4496 for(int i = 0; i < 10; ++i)
4498 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4499 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4504 Standard_Real anInv[10];
4505 for(int i = 0; i < 10; ++i)
4506 anInv[i] = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4507 if (memcmp(anInv, aRndRealRef, sizeof(aRndRealRef)) != 0)
4509 theDI << "Error: incorrect conversion of a dispersed real value\n";
4510 isErr = Standard_True;
4514 // 3. InverseShortReal
4515 const unsigned char aShortRealRef[] = {
4516 0x3F,0x80,0x00,0x00,0x40,0x00,0x00,0x00,
4517 0x40,0x40,0x00,0x00,0x40,0x80,0x00,0x00,
4518 0x40,0xA0,0x00,0x00,0x40,0xC0,0x00,0x00,
4519 0x40,0xE0,0x00,0x00,0x41,0x00,0x00,0x00,
4520 0x41,0x10,0x00,0x00,0x00,0x00,0x00,0x00};
4521 const Standard_ShortReal aShortRealArr[] = {
4522 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 0.0f};
4525 for(int i = 0; i < 10; ++i)
4527 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4528 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4533 Standard_ShortReal anInv[10];
4534 for(int i = 0; i < 10; ++i)
4535 anInv[i] = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4536 if (memcmp(anInv, aShortRealRef, sizeof(aShortRealRef)) != 0)
4538 theDI << "Error: incorrect conversion of a short real value\n";
4539 isErr = Standard_True;
4543 // 3a. Random InverseShortReal
4544 const unsigned char aRndShortRealRef[] = {
4545 0xB0,0x89,0x70,0x5F,0x00,0x00,0x00,0x00,
4546 0x30,0x89,0x70,0x5F,0x3F,0x80,0x00,0x00,
4547 0x40,0x49,0x0E,0x56,0xC0,0xD6,0x66,0x66,
4548 0x40,0xD6,0x66,0x66,0x42,0xC5,0xCC,0xCD,
4549 0xC2,0xC7,0xCC,0xCD,0x42,0xC7,0xCC,0xCD};
4550 const Standard_ShortReal aRndShortRealArr[] = {
4551 -1.e-9f, 0.f, 1.e-9f, 1.f, 3.1415f, -6.7f, 6.7f, 98.9f, -99.9f, 99.9f};
4554 for(int i = 0; i < 10; ++i)
4556 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4557 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4562 Standard_ShortReal anInv[10];
4563 for(int i = 0; i < 10; ++i)
4564 anInv[i] = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4565 if (memcmp(anInv, aRndShortRealRef, sizeof(aRndShortRealRef)) != 0)
4567 theDI << "Error: incorrect conversion of a dispersed short real value\n";
4568 isErr = Standard_True;
4573 const Standard_Size aSizeArr[] = {1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul, 8ul, 9ul, 0ul};
4576 for(int i = 0; i < 10; ++i)
4578 Standard_Size anInv = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4579 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4584 Standard_Size anInv[10];
4585 const unsigned char* aSizeRef = SizeRef<sizeof(Standard_Size)>();
4586 for(int i = 0; i < 10; ++i)
4587 anInv[i] = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4588 if (memcmp(anInv, aSizeRef, sizeof(Standard_Size)*10) != 0)
4590 theDI << "Error: incorrect conversion of a size value\n";
4591 isErr = Standard_True;
4595 if (!aF.is_open() && !isErr)
4596 theDI << "Conversion was done OK";
4599 cout << "the file " << argv[1] << " has been created" << endl;
4606 #include <TopExp.hxx>
4607 #include <BRepOffsetAPI_DraftAngle.hxx>
4609 static TopoDS_Shape taper(const TopoDS_Shape &shape, const TopoDS_Face &face_a, const TopoDS_Face &face_b, Standard_Real angle)
4611 // Use maximum face-to-taper z-offset.
4612 const gp_Pln neutral_plane(gp_Ax3(gp_Pnt(0.0, 0.0, 140.0), gp_Dir(0.0, 0.0, 1.0)));
4614 // Draft angle needs to be in radians, and flipped to adhere to our own (arbitrary) draft
4615 // angle definition.
4616 const Standard_Real draft_angle = -(angle / 180.0) * M_PI;
4618 // Add face to draft. The first argument indicates that all material added/removed during
4619 // drafting is located below the neutral plane
4620 BRepOffsetAPI_DraftAngle drafter(shape);
4621 drafter.Add(face_a, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4622 drafter.Add(face_b, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4625 return drafter.Shape();
4628 static void dumpShapeVertices(const TopoDS_Shape &shape, std::vector<Standard_Real>& coords)
4630 TopTools_IndexedMapOfShape shape_vertices;
4631 TopExp::MapShapes(shape, TopAbs_VERTEX, shape_vertices);
4633 for (Standard_Integer i = 1; i <= shape_vertices.Extent(); i++)
4635 gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(shape_vertices(i)));
4636 coords.push_back(p.X());
4637 coords.push_back(p.Y());
4638 coords.push_back(p.Z());
4642 static void GetCoords(const Standard_CString& path_to_file, std::vector<Standard_Real>& coords)
4645 BRep_Builder builder;
4646 BRepTools::Read(shape, path_to_file, builder);
4647 TopTools_IndexedMapOfShape shape_faces;
4648 TopExp::MapShapes(shape, TopAbs_FACE, shape_faces);
4649 TopoDS_Face face_a = TopoDS::Face(shape_faces(1));
4650 TopoDS_Face face_b = TopoDS::Face(shape_faces(5));
4651 dumpShapeVertices(taper(shape, face_a, face_b, 5.0), coords);
4654 static Standard_Integer OCC26396 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4658 theDI << "Error: path to file is missing\n";
4662 const int maxInd = 50;
4664 std::vector<Standard_Real> ref_coords;
4665 ref_coords.reserve(100);
4666 Standard_Boolean Stat = Standard_True;
4668 GetCoords(theArgv[1], ref_coords);
4670 std::vector<Standard_Real> coords;
4671 coords.reserve(100);
4672 for (int i = 1; i < maxInd; i++)
4674 GetCoords(theArgv[1], coords);
4675 if (coords.size() != ref_coords.size())
4677 Stat = Standard_False;
4680 for (size_t j = 0; j < coords.size(); j++)
4681 if (Abs(ref_coords[j] - coords[j]) > RealEpsilon())
4683 Stat = Standard_False;
4689 theDI << "Error: unstable results";
4696 //=======================================================================
4697 //function : OCC26750
4699 //=======================================================================
4700 static Standard_Integer OCC26750( Draw_Interpretor& theDI,
4701 Standard_Integer /*theNArg*/,
4702 const char ** /*theArgVal*/)
4704 const gp_Vec2d aVec1(1.0, 0.0);
4705 const gp_Vec2d aVec2(0.0, -1.0);
4707 if(aVec1.IsNormal(aVec2, Precision::Angular()))
4709 theDI << "gp_Vec2d OK. Vectors are normal.\n";
4713 theDI << "Error in gp_Vec2d. Vectors should be normal.\n";
4716 const gp_Dir2d aD1(1.0, 0.0);
4717 const gp_Dir2d aD2(0.0, -1.0);
4719 if(aD1.IsNormal(aD2, Precision::Angular()))
4721 theDI << "gp_Dir2d OK. Vectors are normal.\n";
4725 theDI << "Error in gp_Dir2d. Vectors should be normal.\n";
4731 //=======================================================================
4732 //function : OCC26746
4733 //purpose : Checks if coefficients of the torus are computed properly.
4734 //=======================================================================
4735 #include <Geom_ToroidalSurface.hxx>
4736 #include <Geom_BSplineCurve.hxx>
4737 static Standard_Integer OCC26746(
4738 Draw_Interpretor& theDI,
4739 Standard_Integer theNArg,
4740 const char ** theArgVal)
4744 theDI << "Use: OCC26746 torus [toler NbCheckedPoints]\n";
4748 const Handle(Geom_ToroidalSurface) aGtor =
4749 Handle(Geom_ToroidalSurface)::DownCast(DrawTrSurf::GetSurface(theArgVal[1]));
4751 const Standard_Real aToler = (theNArg >= 3)? Draw::Atof(theArgVal[2]) : 1.0e-7;
4752 const Standard_Integer aNbPntsMax = (theNArg >= 4)? Draw::Atoi(theArgVal[3]) : 5;
4754 const Standard_Integer aLowIndex = 5;
4755 const Standard_Real aStep = 2.0*M_PI/aNbPntsMax;
4757 TColStd_Array1OfReal anArrCoeffs(aLowIndex, aLowIndex+34);
4758 aGtor->Torus().Coefficients(anArrCoeffs);
4760 Standard_Real aUpar = 0.0, aVpar = 0.0;
4761 for(Standard_Integer aUind = 0; aUind <= aNbPntsMax; aUind++)
4763 for(Standard_Integer aVind = 0; aVind <= aNbPntsMax; aVind++)
4765 const gp_Pnt aPt(aGtor->Value(aUpar, aVpar));
4766 const Standard_Real aX1 = aPt.X();
4767 const Standard_Real aX2 = aX1*aX1;
4768 const Standard_Real aX3 = aX2*aX1;
4769 const Standard_Real aX4 = aX2*aX2;
4770 const Standard_Real aY1 = aPt.Y();
4771 const Standard_Real aY2 = aY1*aY1;
4772 const Standard_Real aY3 = aY2*aY1;
4773 const Standard_Real aY4 = aY2*aY2;
4774 const Standard_Real aZ1 = aPt.Z();
4775 const Standard_Real aZ2 = aZ1*aZ1;
4776 const Standard_Real aZ3 = aZ2*aZ1;
4777 const Standard_Real aZ4 = aZ2*aZ2;
4779 Standard_Integer i = aLowIndex;
4781 Standard_Real aDelta = anArrCoeffs(i++) * aX4; //1
4782 aDelta+= anArrCoeffs(i++) * aY4; //2
4783 aDelta+= anArrCoeffs(i++) * aZ4; //3
4784 aDelta+= anArrCoeffs(i++) * aX3 * aY1; //4
4785 aDelta+= anArrCoeffs(i++) * aX3 * aZ1; //5
4786 aDelta+= anArrCoeffs(i++) * aY3 * aX1; //6
4787 aDelta+= anArrCoeffs(i++) * aY3 * aZ1; //7
4788 aDelta+= anArrCoeffs(i++) * aZ3 * aX1; //8
4789 aDelta+= anArrCoeffs(i++) * aZ3 * aY1; //9
4790 aDelta+= anArrCoeffs(i++) * aX2 * aY2; //10
4791 aDelta+= anArrCoeffs(i++) * aX2 * aZ2; //11
4792 aDelta+= anArrCoeffs(i++) * aY2 * aZ2; //12
4793 aDelta+= anArrCoeffs(i++) * aX2 * aY1 * aZ1; //13
4794 aDelta+= anArrCoeffs(i++) * aX1 * aY2 * aZ1; //14
4795 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ2; //15
4796 aDelta+= anArrCoeffs(i++) * aX3; //16
4797 aDelta+= anArrCoeffs(i++) * aY3; //17
4798 aDelta+= anArrCoeffs(i++) * aZ3; //18
4799 aDelta+= anArrCoeffs(i++) * aX2 * aY1; //19
4800 aDelta+= anArrCoeffs(i++) * aX2 * aZ1; //20
4801 aDelta+= anArrCoeffs(i++) * aY2 * aX1; //21
4802 aDelta+= anArrCoeffs(i++) * aY2 * aZ1; //22
4803 aDelta+= anArrCoeffs(i++) * aZ2 * aX1; //23
4804 aDelta+= anArrCoeffs(i++) * aZ2 * aY1; //24
4805 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ1; //25
4806 aDelta+= anArrCoeffs(i++) * aX2; //26
4807 aDelta+= anArrCoeffs(i++) * aY2; //27
4808 aDelta+= anArrCoeffs(i++) * aZ2; //28
4809 aDelta+= anArrCoeffs(i++) * aX1 * aY1; //29
4810 aDelta+= anArrCoeffs(i++) * aX1 * aZ1; //30
4811 aDelta+= anArrCoeffs(i++) * aY1 * aZ1; //31
4812 aDelta+= anArrCoeffs(i++) * aX1; //32
4813 aDelta+= anArrCoeffs(i++) * aY1; //33
4814 aDelta+= anArrCoeffs(i++) * aZ1; //34
4815 aDelta+= anArrCoeffs(i++); //35
4817 if(Abs(aDelta) > aToler)
4819 theDI << "(" << aUpar << ", " << aVpar << "): Error in torus coefficients computation (Delta = " << aDelta << ").\n";
4823 theDI << "(" << aUpar << ", " << aVpar << "): OK (Delta = " << aDelta << ").\n";
4826 aVpar = (aVind == aNbPntsMax)? 2.0*M_PI : aVpar + aStep;
4830 aUpar = (aUind == aNbPntsMax)? 2.0*M_PI : aUpar + aStep;
4836 DEFINE_STANDARD_HANDLE(QABugs_VertexFilter, SelectMgr_Filter)
4837 class QABugs_VertexFilter: public SelectMgr_Filter
4840 Standard_EXPORT QABugs_VertexFilter() : SelectMgr_Filter() {}
4842 Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)&) const
4844 return Standard_False;
4848 //=======================================================================
4849 //function : BUC26658
4850 //purpose : Checks selection in the context after using a selection filter
4851 //=======================================================================
4852 static Standard_Integer BUC26658 (Draw_Interpretor& theDI,
4853 Standard_Integer /*theNArg*/,
4854 const char ** theArgVal)
4856 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4857 if(aContext.IsNull()) {
4858 theDI << "use 'vinit' command before " << theArgVal[0] << "\n";
4862 TopoDS_Shape aBoxShape = BRepPrimAPI_MakeBox(20,20,20).Shape();
4863 Handle(AIS_Shape) anAISIO = new AIS_Shape(aBoxShape);
4865 // visualization of the box in the local mode with possibility to
4866 // select box vertices
4867 Standard_DISABLE_DEPRECATION_WARNINGS
4868 aContext->OpenLocalContext();
4869 Standard_ENABLE_DEPRECATION_WARNINGS
4871 int aDispMode = 0;// wireframe
4872 anAISIO->SetDisplayMode(aDispMode);
4873 aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed);
4874 theDI.Eval(" vfit");
4876 aContext->Load(anAISIO, -1, true); /// load allowing decomposition
4877 aContext->Deactivate(anAISIO);
4878 aContext->Activate(anAISIO, AIS_Shape::SelectionMode(TopAbs_VERTEX), false);
4879 aContext->UpdateCurrentViewer();
4881 // select a point on the box
4882 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
4884 myV3dView->Project(20,20,0,Xv,Yv);
4885 Standard_Integer Xp,Yp;
4886 myV3dView->Convert(Xv,Yv,Xp,Yp);
4888 aContext->MoveTo(Xp,Yp, myV3dView);
4890 bool aHasSelected = false;
4891 for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) {
4892 Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
4893 if (!anIO.IsNull()) {
4894 const TopoDS_Shape aShape = aContext->SelectedShape();
4895 if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX)
4896 aHasSelected = true;
4900 cout << "has selected vertex : OK" << endl;
4902 theDI << "has selected vertex : bugged - Faulty\n";
4905 // filter to deny any selection in the viewer
4906 Handle(QABugs_VertexFilter) aFilter = new QABugs_VertexFilter();
4907 aContext->AddFilter(aFilter);
4909 // update previous selection by hand
4910 Standard_DISABLE_DEPRECATION_WARNINGS
4911 aContext->LocalContext()->ClearOutdatedSelection(anAISIO, true);
4912 Standard_ENABLE_DEPRECATION_WARNINGS
4914 // check that there are no selected vertices
4916 aHasSelected = false;
4917 for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) {
4918 Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
4919 if (!anIO.IsNull()) {
4920 const TopoDS_Shape aShape = aContext->SelectedShape();
4921 if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX)
4922 aHasSelected = true;
4925 if (!aHasSelected) cout << "has no selected vertex after filter : OK" << endl;
4927 theDI << "has no selected vertex after filter : bugged - Faulty\n";
4934 //=======================================================================
4935 //function : OCC26945_open
4936 //purpose : Opens local context and activates given standard selection mode
4937 //=======================================================================
4938 static Standard_Integer OCC26945_open (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4940 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
4943 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
4949 std::cout << "Not enough arguments. See usage:\n";
4950 theDI.PrintHelp (theArgv[0]);
4954 const TopAbs_ShapeEnum aSelType = AIS_Shape::SelectionType (Draw::Atoi (theArgv[1]));
4955 Standard_DISABLE_DEPRECATION_WARNINGS
4956 Standard_Integer aLocalCtxIdx = aCtx->OpenLocalContext();
4957 aCtx->ActivateStandardMode (aSelType);
4958 Standard_ENABLE_DEPRECATION_WARNINGS
4959 theDI << aLocalCtxIdx;
4964 //=======================================================================
4965 //function : OCC26945_close
4966 //purpose : Closes local context with the id given
4967 //=======================================================================
4968 static Standard_Integer OCC26945_close (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4970 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
4973 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
4979 std::cout << "Not enough arguments. See usage:\n";
4980 theDI.PrintHelp (theArgv[0]);
4984 const Standard_Integer aCtxToClose = Draw::Atoi (theArgv[1]);
4985 Standard_DISABLE_DEPRECATION_WARNINGS
4986 aCtx->CloseLocalContext (aCtxToClose);
4987 Standard_ENABLE_DEPRECATION_WARNINGS
4992 //=======================================================================
4993 //function : OCC27048
4994 //purpose : Calculate value of B-spline surface N times
4995 //=======================================================================
4996 static Standard_Integer OCC27048(Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
5000 std::cout << "Incorrect number of arguments. See usage:" << std::endl;
5001 theDI.PrintHelp(theArgv[0]);
5005 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theArgv[1]);
5006 GeomAdaptor_Surface anAdaptor(aSurf);
5008 Standard_Real aU = Draw::Atof(theArgv[2]);
5009 Standard_Real aV = Draw::Atof(theArgv[3]);
5010 Standard_Integer aN = Draw::Atoi(theArgv[4]);
5012 for (; aN > 0; --aN)
5013 anAdaptor.Value(aU, aV);
5018 //========================================================================
5019 //function : OCC27065
5020 //purpose : Tests overloaded method "Generated" of BRepOffsetAPI_MakePipe
5021 //========================================================================
5022 static Standard_Integer OCC27065(Draw_Interpretor& di,
5023 Standard_Integer n, const char** a)
5025 if (n < 3) return 1;
5028 TopoDS_Shape SpineShape = DBRep::Get(a[1],TopAbs_WIRE);
5029 if ( SpineShape.IsNull()) return 1;
5030 TopoDS_Wire Spine = TopoDS::Wire(SpineShape);
5032 TopoDS_Shape Profile = DBRep::Get(a[2]);
5033 if ( Profile.IsNull()) return 1;
5035 BRepOffsetAPI_MakePipe aPipeBuilder(Spine, Profile);
5036 if (!aPipeBuilder.IsDone())
5038 di << "Error: failed to create pipe\n";
5042 TopExp_Explorer Explo(Profile, TopAbs_SHELL);
5043 TopoDS_Shape aShape;
5044 TopTools_ListIteratorOfListOfShape itl;
5047 aShape = Explo.Current();
5048 TopoDS_Compound res1;
5049 BB.MakeCompound(res1);
5050 itl.Initialize(aPipeBuilder.Generated(aShape));
5051 for (; itl.More(); itl.Next())
5052 BB.Add(res1, itl.Value());
5053 DBRep::Set("res_shell", res1);
5056 Explo.Init(Profile, TopAbs_FACE);
5059 aShape = Explo.Current();
5060 TopoDS_Compound res2;
5061 BB.MakeCompound(res2);
5062 itl.Initialize(aPipeBuilder.Generated(aShape));
5063 for (; itl.More(); itl.Next())
5064 BB.Add(res2, itl.Value());
5065 DBRep::Set("res_face", res2);
5068 Explo.Init(Profile, TopAbs_WIRE);
5071 aShape = Explo.Current();
5072 TopoDS_Compound res3;
5073 BB.MakeCompound(res3);
5074 itl.Initialize(aPipeBuilder.Generated(aShape));
5075 for (; itl.More(); itl.Next())
5076 BB.Add(res3, itl.Value());
5077 DBRep::Set("res_wire", res3);
5080 Explo.Init(Profile, TopAbs_EDGE);
5083 aShape = Explo.Current();
5084 TopoDS_Compound res4;
5085 BB.MakeCompound(res4);
5086 itl.Initialize(aPipeBuilder.Generated(aShape));
5087 for (; itl.More(); itl.Next())
5088 BB.Add(res4, itl.Value());
5089 DBRep::Set("res_edge", res4);
5092 Explo.Init(Profile, TopAbs_VERTEX);
5095 aShape = Explo.Current();
5096 TopoDS_Compound res5;
5097 BB.MakeCompound(res5);
5098 itl.Initialize(aPipeBuilder.Generated(aShape));
5099 for (; itl.More(); itl.Next())
5100 BB.Add(res5, itl.Value());
5101 DBRep::Set("res_vertex", res5);
5107 //========================================================================
5108 //function : OCC27318
5109 //purpose : Creates a box that is not listed in map of AIS objects of ViewerTest
5110 //========================================================================
5111 static Standard_Integer OCC27318 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5113 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5116 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5120 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20, 20, 20).Shape();
5121 Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
5122 aCtx->Display (aBoxObj, Standard_True);
5127 //========================================================================
5128 //function : OCC27523
5129 //purpose : Checks recomputation of deactivated selection mode after object's redisplaying
5130 //========================================================================
5131 static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
5135 std::cerr << "Error: wrong number of arguments! See usage:\n";
5136 theDI.PrintHelp (theArgVec[0]);
5140 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
5141 if(anAISContext.IsNull())
5143 std::cerr << "Error: no active view. Please call vinit.\n";
5147 gp_Pnt aStart (100, 100, 100);
5148 gp_Pnt anEnd (300, 400, 600);
5149 BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
5150 TopoDS_Edge anEdge = anEdgeBuilder.Edge();
5151 Handle(AIS_InteractiveObject) aTestAISShape = new AIS_Shape (anEdge);
5152 anAISContext->Display (aTestAISShape);
5154 // activate it in selection modes
5155 TColStd_SequenceOfInteger aModes;
5156 aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX));
5158 anAISContext->Deactivate (aTestAISShape);
5159 anAISContext->Load (aTestAISShape, -1, true);
5160 anAISContext->Activate (aTestAISShape, 0);
5161 anAISContext->Deactivate (aTestAISShape, 0);
5163 // activate in vertices mode
5164 for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt)
5166 anAISContext->Activate (aTestAISShape, aModes (anIt));
5169 TopoDS_Shape aVertexShape = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
5170 TopAbs_ShapeEnum aVertexShapeType = aVertexShape.ShapeType();
5171 Handle(AIS_Shape)::DownCast (aTestAISShape)->Set (aVertexShape);
5172 aTestAISShape->Redisplay();
5174 anAISContext->AddOrRemoveSelected (aTestAISShape);
5176 bool aValidShapeType = false;
5177 for (anAISContext->InitSelected(); anAISContext->MoreSelected(); anAISContext->NextSelected())
5179 Handle(SelectMgr_EntityOwner) anOwner = anAISContext->SelectedOwner();
5180 Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
5181 if (!aBRO.IsNull() && aBRO->HasShape())
5183 TopoDS_Shape aShape = aBRO->Shape();
5185 aValidShapeType = aShape.ShapeType() == aVertexShapeType;
5189 if (!aValidShapeType)
5191 std::cerr << "Error: shape type is invalid.\n";
5198 //========================================================================
5199 //function : OCC27700
5200 //purpose : glPolygonMode() used for frame drawing affects label text shading
5201 //========================================================================
5203 class OCC27700_Text : public AIS_InteractiveObject
5207 DEFINE_STANDARD_RTTI_INLINE (OCC27700_Text, AIS_InteractiveObject)
5209 virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
5210 const Handle(Prs3d_Presentation)& thePresentation,
5211 const Standard_Integer /*theMode*/) Standard_OVERRIDE
5213 Handle(Graphic3d_ArrayOfTriangles) aFrame = new Graphic3d_ArrayOfTriangles (6, 6);
5214 aFrame->AddVertex (gp_Pnt (-1, 0, 0));
5215 aFrame->AddVertex (gp_Pnt (-1, 1, 0));
5216 aFrame->AddVertex (gp_Pnt ( 3, 1, 0));
5217 aFrame->AddVertex (gp_Pnt ( 3, 0, 0));
5219 aFrame->AddEdge (1);
5220 aFrame->AddEdge (2);
5221 aFrame->AddEdge (3);
5223 aFrame->AddEdge (2);
5224 aFrame->AddEdge (3);
5225 aFrame->AddEdge (4);
5227 Handle(Graphic3d_AspectFillArea3d) aFillAspect =
5228 new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect().get());
5229 aFillAspect->SetInteriorStyle (Aspect_IS_POINT);
5231 // create separate group for frame elements
5232 Handle(Graphic3d_Group) aFrameGroup = Prs3d_Root::NewGroup (thePresentation);
5233 aFrameGroup->AddPrimitiveArray (aFrame);
5234 aFrameGroup->SetGroupPrimitivesAspect (aFillAspect);
5236 // create separate group for text elements
5237 Handle(Graphic3d_Group) aTextGroup = Prs3d_Root::NewGroup (thePresentation);
5238 TCollection_ExtendedString aString ("YOU SHOULD SEE THIS TEXT", Standard_True);
5239 Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePresentation), myDrawer->TextAspect(), aString, gp_Ax2 (gp::Origin(), gp::DZ()));
5242 virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
5243 const Standard_Integer /*theMode*/) Standard_OVERRIDE {}
5246 static Standard_Integer OCC27700 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
5248 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
5249 if (aContext.IsNull())
5251 std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
5254 Handle(OCC27700_Text) aPresentation = new OCC27700_Text();
5255 aContext->Display (aPresentation);
5259 //========================================================================
5260 //function : OCC27757
5261 //purpose : Creates a box that has a sphere as child object and displays it
5262 //========================================================================
5263 static Standard_Integer OCC27757 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5265 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5268 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5272 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20.0, 20.0, 20.0).Shape();
5273 TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere (10.0).Shape();
5275 aTrsf.SetTranslationPart (gp_Vec (20.0, 20.0, 0.0));
5276 aSphere.Located (TopLoc_Location (aTrsf));
5279 Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
5280 Handle(AIS_Shape) aSphereObj = new AIS_Shape (aSphere);
5281 aBoxObj->AddChild (aSphereObj);
5282 aCtx->Display (aBoxObj, 1, 0, Standard_False);
5283 aCtx->UpdateCurrentViewer();
5288 //========================================================================
5289 //function : OCC27818
5290 //purpose : Creates three boxes and highlights one of them with own style
5291 //========================================================================
5292 static Standard_Integer OCC27818 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5294 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5297 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5301 Handle(AIS_Shape) aBoxObjs[3];
5302 for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx)
5304 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20.0, 20.0, 20.0).Shape();
5305 aBoxObjs[aBoxIdx] = new AIS_Shape (aBox);
5307 aTrsf.SetTranslationPart (gp_Vec (30.0 * aBoxIdx, 30.0 * aBoxIdx, 0.0));
5308 aBoxObjs[aBoxIdx]->SetLocalTransformation (aTrsf);
5309 aBoxObjs[aBoxIdx]->SetHilightMode (AIS_Shaded);
5313 Handle(Prs3d_Drawer) aHiStyle = new Prs3d_Drawer();
5314 aBoxObjs[1]->SetDynamicHilightAttributes (aHiStyle);
5315 aHiStyle->SetDisplayMode (AIS_Shaded);
5316 aHiStyle->SetColor (Quantity_NOC_RED);
5317 aHiStyle->SetTransparency (0.8f);
5320 Handle(Prs3d_Drawer) aSelStyle = new Prs3d_Drawer();
5321 aBoxObjs[2]->SetHilightAttributes (aSelStyle);
5322 aSelStyle->SetDisplayMode (AIS_Shaded);
5323 aSelStyle->SetColor (Quantity_NOC_RED);
5324 aSelStyle->SetTransparency (0.0f);
5325 aSelStyle->SetZLayer (Graphic3d_ZLayerId_Topmost);
5328 for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx)
5330 aCtx->Display (aBoxObjs[aBoxIdx], AIS_Shaded, 0, Standard_False);
5333 aCtx->UpdateCurrentViewer();
5338 //========================================================================
5339 //function : OCC27893
5340 //purpose : Creates a box and selects it via AIS_InteractiveContext API
5341 //========================================================================
5342 static Standard_Integer OCC27893 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5344 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5347 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5351 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
5352 Handle(AIS_InteractiveObject) aBoxObj = new AIS_Shape (aBox);
5353 aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False);
5354 aCtx->SetSelected (aBoxObj, Standard_True);
5359 //========================================================================
5360 //function : Commands_19
5362 //========================================================================
5364 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
5365 const char *group = "QABugs";
5367 Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass();
5368 theCommands.Add ("OCC24202_1", "Test Handle-based procedure",
5369 __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group);
5370 NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass();
5371 theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure",
5372 __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group);
5374 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
5375 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
5376 theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
5377 theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
5378 theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
5379 theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
5380 theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
5381 theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
5382 theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
5383 theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
5384 theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
5385 theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
5386 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);
5387 theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
5388 theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
5389 theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
5390 theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
5391 theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
5392 theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group);
5393 theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group);
5394 theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group);
5395 theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group);
5396 theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group);
5397 theCommands.Add ("OCC24622", "OCC24622 texture={1D|2D}\n Tests sourcing of 1D/2D pixmaps for AIS_TexturedShape", __FILE__, OCC24622, group);
5398 theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group);
5399 theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group);
5400 theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group);
5401 theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group);
5402 theCommands.Add ("OCC23951", "OCC23951 path to saved step file", __FILE__, OCC23951, group);
5403 theCommands.Add ("OCC24931", "OCC24931 path to saved xml file", __FILE__, OCC24931, group);
5404 theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group);
5405 theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
5406 theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group);
5407 theCommands.Add ("OCC24925",
5408 "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]"
5409 "\nOCAF persistence without setting environment variables",
5410 __FILE__, OCC24925, group);
5411 theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group);
5412 theCommands.Add ("OCC24826,", "This test performs simple saxpy test.\n Usage: OCC24826 length", __FILE__, OCC24826, group);
5413 theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group);
5414 theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group);
5415 theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
5416 theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
5417 theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group);
5418 theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group);
5419 theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
5420 theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
5421 theCommands.Add ("OCC25545",
5422 "no args; tests data race when concurrently accessing \n"
5423 "\t\tTopLoc_Location::Transformation()",
5424 __FILE__, OCC25545, group);
5425 theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
5426 theCommands.Add ("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group);
5427 theCommands.Add ("OCC26172", "OCC26172", __FILE__, OCC26172, group);
5428 theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);
5429 theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group);
5430 theCommands.Add ("OCC26139", "OCC26139 [-boxsize value] [-boxgrid value] [-compgrid value]", __FILE__, OCC26139, group);
5431 theCommands.Add ("OCC26284", "OCC26284", __FILE__, OCC26284, group);
5432 theCommands.Add ("OCC26446", "OCC26446 r c1 c2", __FILE__, OCC26446, group);
5433 theCommands.Add ("OCC26448", "OCC26448: check method Prepend() of sequence", __FILE__, OCC26448, group);
5434 theCommands.Add ("OCC26407", "OCC26407 result_name", __FILE__, OCC26407, group);
5435 theCommands.Add ("OCC26485", "OCC26485 shape", __FILE__, OCC26485, group);
5436 theCommands.Add ("OCC26553", "OCC26553 file_path", __FILE__, OCC26553, group);
5437 theCommands.Add ("OCC26195",
5438 "OCC26195: x1_pix y1_pix [x2_pix y2_pix] [toPrintPixelCoord 0|1]"
5439 "\n\t\t: Draws rectangular selecting frustum defined by point selection in pixel coordinates"
5440 "\n\t\t: [x1_pix, y1_pix] or rectangular selection in pixel coordinates [x1_pix, y1_pix,"
5441 "\n\t\t: x2_pix, y2_pix]."
5442 "\n\t\t: [toPrintPixelCoord 0|1] - prints 3d projection of pixel coordinate or center of"
5443 "\n\t\t: selecting rectangle onto near and far view frustum planes",
5444 __FILE__, OCC26195, group);
5445 theCommands.Add ("OCC26462",
5446 "OCC26462: Checks the ability to manage sensitivity of a particular selection mode in local context",
5447 __FILE__, OCC26462, group);
5449 theCommands.Add ("OCC26313", "OCC26313 result shape", __FILE__, OCC26313, group);
5450 theCommands.Add ("OCC26396", "OCC26396 shape_file_path", __FILE__, OCC26396, group);
5451 theCommands.Add ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group);
5453 theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group);
5454 theCommands.Add ("OCC26750", "OCC26750", __FILE__, OCC26750, group);
5455 theCommands.Add ("OCC25574", "OCC25574", __FILE__, OCC25574, group);
5456 theCommands.Add ("OCC26746", "OCC26746 torus [toler NbCheckedPoints] ", __FILE__, OCC26746, group);
5458 theCommands.Add ("BUC26658", "BUC26658 unexpected selection in the context using a selection filter", __FILE__, BUC26658, group);
5459 theCommands.Add ("OCC26945_open",
5460 "OCC26945 selectionModeToActivate"
5461 "\n\t\t: Opens a new local context with selectionModeToActivate activated."
5462 "\n\t\t: Prints the ID of newely opened local context in case of success.",
5463 __FILE__, OCC26945_open, group);
5464 theCommands.Add ("OCC26945_close",
5465 "OCC26945 localCtxToClose"
5466 "\n\t\t: Closes local context with the ID localCtxToClose",
5467 __FILE__, OCC26945_close, group);
5469 theCommands.Add ("OCC27048",
5470 "OCC27048 surf U V N\nCalculate value of surface N times in the point (U, V)",
5471 __FILE__, OCC27048, group);
5473 theCommands.Add ("OCC27065",
5474 "OCC27065 spine profile",
5475 __FILE__, OCC27065, group);
5477 theCommands.Add ("OCC27318",
5478 "OCC27318: Creates a box that is not listed in map of AIS objects of ViewerTest",
5479 __FILE__, OCC27318, group);
5480 theCommands.Add ("OCC27523",
5481 "OCC27523: Checks recomputation of deactivated selection mode after object's redisplaying",
5482 __FILE__, OCC27523, group);
5483 theCommands.Add ("OCC27700",
5484 "OCC27700: Checks drawing text after setting interior style",
5485 __FILE__, OCC27700, group);
5486 theCommands.Add ("OCC27757",
5487 "OCC27757: Creates a box that has a sphere as child object and displays it",
5488 __FILE__, OCC27757, group);
5489 theCommands.Add ("OCC27818",
5490 "OCC27818: Creates three boxes and highlights one of them with own style",
5491 __FILE__, OCC27818, group);
5492 theCommands.Add ("OCC27893",
5493 "OCC27893: Creates a box and selects it via AIS_InteractiveContext API",
5494 __FILE__, OCC27893, group);