1 // Created on: 2002-05-21
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
18 #include <Draw_Interpretor.hxx>
20 #include <DrawTrSurf.hxx>
21 #include <ViewerTest.hxx>
22 #include <V3d_View.hxx>
23 #include <TopoDS_Shape.hxx>
24 #include <AIS_InteractiveContext.hxx>
25 #include <AIS_LocalContext.hxx>
26 #include <AIS_TexturedShape.hxx>
27 #include <Image_PixMap.hxx>
28 #include <Image_Color.hxx>
30 #include <gp_Pnt2d.hxx>
32 #include <GCE2d_MakeSegment.hxx>
33 #include <Geom2d_TrimmedCurve.hxx>
34 #include <DrawTrSurf.hxx>
36 #include <Precision.hxx>
41 #include <OSD_Timer.hxx>
42 #include <OSD_Parallel.hxx>
43 #include <OSD_PerfMeter.hxx>
44 #include <BRepPrimAPI_MakeBox.hxx>
45 #include <BRepPrimAPI_MakeSphere.hxx>
46 #include <BRepAlgo_Cut.hxx>
47 #include <NCollection_Map.hxx>
48 #include <NCollection_Handle.hxx>
49 #include <NCollection_IncAllocator.hxx>
50 #include <TCollection_HAsciiString.hxx>
51 #include <GeomFill_Trihedron.hxx>
52 #include <BRepOffsetAPI_MakePipe.hxx>
53 #include <TopExp_Explorer.hxx>
55 #include <SelectMgr_Filter.hxx>
57 #include <Standard_Version.hxx>
59 #define QCOMPARE(val1, val2) \
60 di << "Checking " #val1 " == " #val2 << \
61 ((val1) == (val2) ? ": OK\n" : ": Error\n")
63 static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
66 di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d\n";
71 if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
72 di << "ERROR OCC230: " << argv[2] << " is not Pnt2d\n";
75 if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
76 di << "ERROR OCC230: " << argv[3] << " is not Pnt2d\n";
80 GCE2d_MakeSegment MakeSegment(P1,P2);
81 Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
82 DrawTrSurf::Set(argv[1], TrimmedCurve);
86 static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
91 t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267);
92 t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880);
94 gp_Trsf tComp = t2 * t1;
97 gp_Pnt p2 = p1.Transformed(tComp);
98 gp_Pnt p3 = p1.Transformed(t1);
101 // points must be equal
102 if ( ! p2.IsEqual(p3, Precision::Confusion()) )
103 di << "ERROR OCC23361: equivalent transformations does not produce equal points\n";
105 di << "OCC23361: OK\n";
110 static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
112 OSD_PerfMeter aPM("TestMeter",0);
115 // run some operation in cycle for about 2 seconds to have good values of times to compare
117 printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n");
118 for (; aTM.ElapsedTime() < 2.; count++)
123 // do some operation that will take considerable time compared with time of starting / stopping timers
124 BRepPrimAPI_MakeBox aBox (10., 10., 10.);
125 BRepPrimAPI_MakeSphere aSphere (10.);
126 BRepAlgo_Cut aCutter (aBox.Shape(), aSphere.Shape());
133 Standard_Real aPerfMeter_CPUtime = 0., aTimer_ElapsedTime = aTM.ElapsedTime();
135 perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
137 Standard_Real aTimeDiff = (fabs(aTimer_ElapsedTime - aPerfMeter_CPUtime) / aTimer_ElapsedTime);
139 printf("\nMeasurement results (%d cycles):\n", count);
140 printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer elapsed time: %lf\n", aPerfMeter_CPUtime, aTimer_ElapsedTime);
141 printf("Time delta is: %.3lf %%\n", aTimeDiff * 100);
144 di << "OCC23237: Error: too much difference between CPU and elapsed times";
145 else if (aNbEnters != count)
146 di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles";
148 di << "OCC23237: OK";
153 class IncrementerDecrementer
156 IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
158 void operator() (const size_t) const
161 Standard_Atomic_Increment(myVal);
163 Standard_Atomic_Decrement(myVal);
166 Standard_Integer* myVal;
167 Standard_Boolean myPositive;
170 static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
174 //check returned value
175 QCOMPARE (Standard_Atomic_Decrement (&aSum), -1);
176 QCOMPARE (Standard_Atomic_Increment (&aSum), 0);
177 QCOMPARE (Standard_Atomic_Increment (&aSum), 1);
178 QCOMPARE (Standard_Atomic_Increment (&aSum), 2);
179 // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0);
180 // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1);
184 const int N = 1 << 24; //big enough to ensure concurrency
187 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, true));
191 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, false));
197 #include <TDocStd_Application.hxx>
198 #include <XCAFApp_Application.hxx>
199 #include <TDocStd_Document.hxx>
200 #include <XCAFDoc_ShapeTool.hxx>
201 #include <XCAFDoc_DocumentTool.hxx>
202 #include <TDF_Label.hxx>
203 #include <TDataStd_Name.hxx>
205 static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
207 Handle(TDocStd_Application) anApp = XCAFApp_Application::GetApplication();
208 Handle(TDocStd_Document) aDoc;
209 anApp->NewDocument ("XmlXCAF", aDoc);
210 QCOMPARE (!aDoc.IsNull(), Standard_True);
212 Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
214 //check default value
215 Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
216 QCOMPARE (aValue, Standard_True);
219 XCAFDoc_ShapeTool::SetAutoNaming (Standard_True);
220 TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape();
221 TDF_Label aLabel = aShTool->AddShape (aShape);
222 Handle(TDataStd_Name) anAttr;
223 QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
226 XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
227 aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape();
228 aLabel = aShTool->AddShape (aShape);
229 QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
232 XCAFDoc_ShapeTool::SetAutoNaming (aValue);
237 #include <ExprIntrp_GenExp.hxx>
238 Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
242 di << "Usage : " << argv[0] << " string nb\n";
246 TCollection_AsciiString aToken = argv[1];
247 Standard_Integer aNb = atoi(argv[2]);
249 Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create();
250 for (Standard_Integer i=0; i < aNb; i++)
252 aGen->Process(aToken);
253 Handle(Expr_GeneralExpression) aExpr = aGen->Expression();
259 Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
263 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"
264 << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}"
265 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}";
269 #include <TopoDS_Face.hxx>
270 #include <TopoDS_Face.hxx>
271 #include <TopoDS.hxx>
272 #include <BRepBuilderAPI_Transform.hxx>
273 #include <BRepExtrema_DistShapeShape.hxx>
274 #include <BRepTools.hxx>
276 static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di)
278 BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN);
279 if(!distShapeShape.IsDone()) {
280 di <<"Distance ShapeShape is Not Done\n";
281 return Standard_False;
284 if(distShapeShape.Value() > 0.01) {
285 di << "Wrong Dist = " <<distShapeShape.Value() << "\n";
286 return Standard_False;
288 di << "Dist0 = " <<distShapeShape.Value() <<"\n";
290 //////////////////////////////////////////////////////////////////////////
292 const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970);
293 const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970);
295 gp_Vec2d mirrorVector1(axis1P1,axis1P2);
298 mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1));
300 BRepBuilderAPI_Transform transformer1(mirror1);
301 transformer1.Perform(originalWire);
302 if(!transformer1.IsDone()) {
303 di << "Not Done1 \n";
304 return Standard_False;
306 TopoDS_Shape step1ModifiedShape = transformer1.ModifiedShape(originalWire);
308 BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN);
309 if(!distShapeShape1.IsDone())
310 return Standard_False;
311 if(distShapeShape1.Value() > 0.01) {
312 di << "Dist = " <<distShapeShape1.Value() <<"\n";
313 return Standard_False;
315 di << "Dist1 = " <<distShapeShape1.Value() <<"\n";
317 //////////////////////////////////////////////////////////////////////////
319 transformer1.Perform(step1ModifiedShape);
320 if(!transformer1.IsDone()) {
321 di << "Not Done1 \n";
322 return Standard_False;
324 TopoDS_Shape step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
326 //This is identity matrix for values but for type is gp_Rotation ?!
327 gp_Trsf2d mirror11 = mirror1;
328 mirror11.PreMultiply(mirror1);
330 BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN);
331 if(!distShapeShape2.IsDone())
332 return Standard_False;
334 //This last test case give error (the value is 1008.8822038689706)
335 if(distShapeShape2.Value() > 0.01) {
336 di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n";
337 Standard_Integer N = distShapeShape2.NbSolution();
338 di << "Nb = " <<N <<"\n";
339 for (Standard_Integer i=1;i <= N;i++)
340 di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n";
341 return Standard_False;
343 di << "Distance2 = " <<distShapeShape2.Value() <<"\n";
345 return Standard_True;
347 static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a)
351 di <<"OCC23774: invalid number of input parameters\n";
355 const char *ns1 = (a[1]), *ns2 = (a[2]);
356 TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2));
357 if (S1.IsNull() || S2.IsNull()) {
358 di <<"OCC23774: Null input shapes\n";
361 const TopoDS_Face& aFace = TopoDS::Face(S1);
362 if(!OCC23774Test(aFace, S2, di))
363 di << "Something is wrong\n";
368 #include <GeomConvert_ApproxSurface.hxx>
369 #include <Geom_BSplineSurface.hxx>
371 #include <OSD_Thread.hxx>
373 struct GeomConvertTest_Data
375 Standard_Integer nbupoles;
376 Handle(Geom_Surface) surf;
379 static Standard_Address GeomConvertTest (Standard_Address data)
381 GeomConvertTest_Data* info = (GeomConvertTest_Data*)data;
383 GeomConvert_ApproxSurface aGAS (info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
384 if (!aGAS.IsDone()) {
385 cout << "Error: ApproxSurface is not done!" << endl;
388 const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
389 if (aBSurf.IsNull()) {
390 cout << "Error: BSplineSurface is not created!" << endl;
393 cout << "Number of UPoles:" << aBSurf->NbUPoles();
394 if (aBSurf->NbUPoles() == info->nbupoles)
396 cout << ": OK" << endl;
397 return data; // any non-null pointer
401 cout << ": Error, must be " << info->nbupoles << endl;
406 static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
409 cout << "Error: invalid number of arguments" << endl;
413 struct GeomConvertTest_Data aStorage;
414 aStorage.nbupoles = Draw::Atoi(argv[1]);
415 aStorage.surf = DrawTrSurf::GetSurface(argv[2]);
416 if (aStorage.surf.IsNull())
418 cout << "Error: " << argv[2] << " is not a DRAW surface!" << endl;
422 // start conversion in several threads
423 const int NBTHREADS = 100;
424 OSD_Thread aThread[NBTHREADS];
425 for (int i=0; i < NBTHREADS; i++)
427 aThread[i].SetFunction (GeomConvertTest);
428 if (!aThread[i].Run(&aStorage))
429 di << "Error: Cannot start thread << " << i << "\n";
433 for (int i=0; i < NBTHREADS; i++)
435 Standard_Address aResult = 0;
436 if (!aThread[i].Wait(aResult))
437 di << "Error: Failed waiting for thread << " << i << "\n";
439 di << "Error: wrong number of poles in thread " << i << "!\n";
445 #include <GeomInt_IntSS.hxx>
447 struct GeomIntSSTest_Data
449 Standard_Integer nbsol;
450 Handle(Geom_Surface) surf1, surf2;
453 static Standard_Address GeomIntSSTest (Standard_Address data)
455 GeomIntSSTest_Data* info = (GeomIntSSTest_Data*)data;
456 GeomInt_IntSS anInter;
457 anInter.Perform (info->surf1, info->surf2, Precision::Confusion(), Standard_True);
458 if (!anInter.IsDone()) {
459 cout << "An intersection is not done!" << endl;
463 cout << "Number of Lines:" << anInter.NbLines();
464 if (anInter.NbLines() == info->nbsol)
466 cout << ": OK" << endl;
467 return data; // any non-null pointer
471 cout << ": Error, must be " << info->nbsol << endl;
476 static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
479 cout << "Error: invalid number of arguments" << endl;
483 struct GeomIntSSTest_Data aStorage;
484 aStorage.nbsol = Draw::Atoi(argv[1]);
485 aStorage.surf1 = DrawTrSurf::GetSurface(argv[2]);
486 aStorage.surf2 = DrawTrSurf::GetSurface(argv[3]);
487 if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull())
489 cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" << endl;
493 // start conversion in several threads
494 const int NBTHREADS = 100;
495 OSD_Thread aThread[NBTHREADS];
496 for (int i=0; i < NBTHREADS; i++)
498 aThread[i].SetFunction (GeomIntSSTest);
499 if (!aThread[i].Run(&aStorage))
500 di << "Error: Cannot start thread << " << i << "\n";
504 for (int i=0; i < NBTHREADS; i++)
506 Standard_Address aResult = 0;
507 if (!aThread[i].Wait(aResult))
508 di << "Error: Failed waiting for thread << " << i << "\n";
510 di << "Error: wrong number of intersections in thread " << i << "!\n";
516 #include <Geom_SurfaceOfRevolution.hxx>
517 static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
520 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
524 Standard_Integer ucontinuity = 1;
525 Standard_Integer vcontinuity = 1;
526 Standard_Boolean iscnu = false;
527 Standard_Boolean iscnv = false;
529 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
531 QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
532 QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
537 #include <gp_Ax1.hxx>
538 #include <gp_Ax22d.hxx>
539 #include <Geom_Plane.hxx>
540 #include <Geom2d_Circle.hxx>
541 #include <Geom2d_TrimmedCurve.hxx>
542 #include <BRepBuilderAPI_MakeEdge.hxx>
543 #include <BRepPrimAPI_MakeRevol.hxx>
544 #include <Geom2d_OffsetCurve.hxx>
546 static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
548 // Check the command arguments
551 di << "Error: " << argv[0] << " - invalid number of arguments\n";
552 di << "Usage: type help " << argv[0] << "\n";
553 return 1; // TCL_ERROR
556 gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
557 gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
558 Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
560 di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>\n";
561 di << "-----------------------------------------------------------------------\n";
563 Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
564 Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
565 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
567 DBRep::Set("e1", E1);
569 BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
570 TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
572 DBRep::Set("f1", F1);
574 di << "Result: f1\n";
576 di << "<<<< Preparing sample surface of revolution based on offset curve >>>>\n";
577 di << "-----------------------------------------------------------------------\n";
579 Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
580 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
582 DBRep::Set("e2", E2);
584 BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
585 TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
587 DBRep::Set("f2", F2);
589 di << "Result: f2\n";
594 #include <Geom_Curve.hxx>
595 #include <Geom_Surface.hxx>
596 #include <Precision.hxx>
597 #include <ShapeConstruct_ProjectCurveOnSurface.hxx>
598 //=======================================================================
599 //function : OCC24008
601 //=======================================================================
602 static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
605 di << "Usage: " << argv[0] << " invalid number of arguments\n";
608 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]);
609 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]);
610 if (aCurve.IsNull()) {
611 di << "Curve was not read\n";
614 if (aSurf.IsNull()) {
615 di << "Surface was not read\n";
618 ShapeConstruct_ProjectCurveOnSurface aProj;
619 aProj.Init (aSurf, Precision::Confusion());
621 Handle(Geom2d_Curve) aPCurve;
622 aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve);
623 if (aPCurve.IsNull()) {
624 di << "PCurve was not created\n";
628 di << "Exception was caught\n";
633 #include <GeomAdaptor_Surface.hxx>
635 //=======================================================================
636 //function : OCC23945
638 //=======================================================================
640 static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
644 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
645 if (aS.IsNull()) return 1;
647 GeomAdaptor_Surface GS(aS);
649 Standard_Real U = Draw::Atof(a[2]);
650 Standard_Real V = Draw::Atof(a[3]);
652 Standard_Boolean DrawPoint = ( n%3 == 2);
660 GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
661 Draw::Set(a[13],D2U.X());
662 Draw::Set(a[14],D2U.Y());
663 Draw::Set(a[15],D2U.Z());
664 Draw::Set(a[16],D2V.X());
665 Draw::Set(a[17],D2V.Y());
666 Draw::Set(a[18],D2V.Z());
667 Draw::Set(a[19],D2UV.X());
668 Draw::Set(a[20],D2UV.Y());
669 Draw::Set(a[21],D2UV.Z());
674 Draw::Set(a[7],DU.X());
675 Draw::Set(a[8],DU.Y());
676 Draw::Set(a[9],DU.Z());
677 Draw::Set(a[10],DV.X());
678 Draw::Set(a[11],DV.Y());
679 Draw::Set(a[12],DV.Z());
685 Draw::Set(a[4],P.X());
686 Draw::Set(a[5],P.Y());
687 Draw::Set(a[6],P.Z());
690 DrawTrSurf::Set(a[n],P);
696 //=======================================================================
697 //function : OCC11758
699 //=======================================================================
700 static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
702 if (n != 1) return 1;
704 const char* theStr = "0123456789";
705 Standard_Integer i, j;
706 for ( i = 0; i < 5; ++i ) {
707 // TCollection_AsciiString(const Standard_CString astring)
708 TCollection_AsciiString a(theStr+i);
709 // IsEqual (const Standard_CString other)const
710 //assert( a == theStr+i );
711 QCOMPARE ( a , theStr+i );
713 //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen )
714 TCollection_AsciiString b(theStr+i, 3);
715 //assert( b.Length() == 3 );
716 //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 );
717 //assert( strlen( b.ToCString() ) == 3 );
718 QCOMPARE ( b.Length() , 3 );
719 QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 );
720 QCOMPARE ( b.Length() , 3 );
722 //TCollection_AsciiString(const Standard_Integer aValue)
723 TCollection_AsciiString c(i);
724 //assert( c.IsIntegerValue() );
725 //assert( c.IntegerValue() == i );
726 QCOMPARE ( c.IsIntegerValue() , Standard_True );
727 QCOMPARE ( c.IntegerValue() , i );
729 //TCollection_AsciiString(const Standard_Real aValue)
730 TCollection_AsciiString d( 0.1*i );
731 //assert( d.IsRealValue() );
732 //assert( TCollection_AsciiString(3.3) == "3.3");
733 QCOMPARE ( d.IsRealValue() , Standard_True );
734 QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" );
736 //TCollection_AsciiString(const TCollection_AsciiString& astring)
737 TCollection_AsciiString e(d);
739 //assert( e.Length() == d.Length() );
740 //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
742 QCOMPARE ( e.Length() , d.Length() );
743 QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
745 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
746 // const Standard_Character other )
747 TCollection_AsciiString f(e,'\a');
748 //assert( f.Length() == e.Length() + 1 );
749 //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 );
750 //assert( f.Value( f.Length() ) == '\a');
751 QCOMPARE ( f.Length() , e.Length() + 1 );
752 QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 );
753 QCOMPARE ( f.Value( f.Length() ) , '\a' );
755 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
756 // const Standard_CString other )
757 TCollection_AsciiString g(f, theStr);
758 //assert( g.Length() == f.Length() + strlen( theStr ));
759 //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 );
760 //assert( g.Search( theStr ) == f.Length() + 1 );
761 QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) );
762 QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 );
763 QCOMPARE ( g.Search( theStr ) , f.Length() + 1 );
765 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
766 // const TCollection_AsciiString& other )
767 TCollection_AsciiString h(d,a);
768 //assert( h.Length() == d.Length() + a.Length() );
769 //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 );
770 //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 );
771 QCOMPARE ( h.Length() , d.Length() + a.Length() );
772 QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 );
773 QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 );
775 // AssignCat(const Standard_CString other)
776 c.AssignCat( a.ToCString() );
777 //assert( c.Length() == 1 + a.Length() );
778 //assert( c.Search( a ) == 2 );
779 QCOMPARE ( c.Length() , 1 + a.Length() );
780 QCOMPARE ( c.Search( a ) , 2 );
782 // AssignCat(const TCollection_AsciiString& other)
783 Standard_Integer dl = d.Length();
785 //assert( d.Length() == dl + a.Length() );
786 //assert( d.Search( a ) == dl + 1 );
787 QCOMPARE ( d.Length() , dl + a.Length() );
788 QCOMPARE ( d.Search( a ) , dl + 1 );
791 TCollection_AsciiString capitalize("aBC");
792 capitalize.Capitalize();
793 //assert( capitalize == "Abc" );
794 QCOMPARE ( capitalize , "Abc" );
796 // Copy(const Standard_CString fromwhere)
798 //assert( d == theStr+i );
799 QCOMPARE ( d , theStr+i );
801 // Copy(const TCollection_AsciiString& fromwhere)
803 // IsEqual (const TCollection_AsciiString& other)const
807 // Insert(const Standard_Integer where, const Standard_CString what)
809 d.Insert( 2, theStr );
810 //assert( d.Length() == dl + strlen( theStr ));
811 //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 );
812 QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) );
813 QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 );
815 //Insert(const Standard_Integer where,const Standard_Character what)
817 d.Insert( i+1, 'i' );
818 //assert( d.Length() == strlen( theStr ) + 1 );
819 //assert( d.Value( i+1 ) == 'i');
820 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
821 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
822 QCOMPARE ( d.Value( i+1 ) , 'i' );
823 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
825 //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
827 d.Insert( i+1, TCollection_AsciiString( "i" ));
828 //assert( d.Length() == strlen( theStr ) + 1 );
829 //assert( d.Value( i+1 ) == 'i');
830 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
831 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
832 QCOMPARE ( d.Value( i+1 ) , 'i' );
833 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
835 // IsDifferent (const Standard_CString other)const
836 //assert( d.IsDifferent( theStr ));
837 //assert( d.IsDifferent( "theStr" ));
838 //assert( d.IsDifferent( "" ));
839 //assert( !d.IsDifferent( d.ToCString() ));
840 QCOMPARE ( d.IsDifferent( theStr ) , Standard_True );
841 QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True );
842 QCOMPARE ( d.IsDifferent( "" ) , Standard_True );
843 QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True );
845 // IsDifferent (const TCollection_AsciiString& other)const
846 //assert( d.IsDifferent( TCollection_AsciiString() ));
847 //assert( d.IsDifferent( a ));
848 //assert( d.IsDifferent( h ));
849 //assert( !d.IsDifferent( d ));
850 QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True );
851 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
852 QCOMPARE ( d.IsDifferent( h ) , Standard_True );
853 QCOMPARE ( !d.IsDifferent( d ) , Standard_True );
855 // IsLess (const Standard_CString other)const
856 //assert( TCollection_AsciiString ("0"). IsLess("1"));
857 //assert( TCollection_AsciiString ("0"). IsLess("00"));
858 //assert( TCollection_AsciiString (""). IsLess("0"));
859 //assert( !TCollection_AsciiString("1"). IsLess("0"));
860 //assert( !TCollection_AsciiString("00").IsLess("0"));
861 //assert( !TCollection_AsciiString("0"). IsLess(""));
862 //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1));
863 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True );
864 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True );
865 QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True );
866 QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True );
867 QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True );
868 QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True );
869 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True );
871 // IsLess (const TCollection_AsciiString& other)const
872 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )));
873 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")));
874 //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )));
875 //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )));
876 //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )));
877 //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )));
878 //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)));
879 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True );
880 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True );
881 QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True );
882 QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True );
883 QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True );
884 QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True );
885 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True );
887 // IsGreater (const Standard_CString other)const
888 //assert( !TCollection_AsciiString("0"). IsGreater("1"));
889 //assert( !TCollection_AsciiString("0"). IsGreater("00"));
890 //assert( !TCollection_AsciiString(""). IsGreater("0"));
891 //assert( TCollection_AsciiString ("1"). IsGreater("0"));
892 //assert( TCollection_AsciiString ("00").IsGreater("0"));
893 //assert( TCollection_AsciiString ("0"). IsGreater(""));
894 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i));
895 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True );
896 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True );
897 QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True );
898 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True );
899 QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True );
900 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True );
901 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True );
903 // IsGreater (const TCollection_AsciiString& other)const
904 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )));
905 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")));
906 //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )));
907 //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )));
908 //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )));
909 //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )));
910 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)));
911 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True );
912 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True );
913 QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
914 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
915 QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True );
916 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True );
917 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True );
919 // void Read(Standard_IStream& astream)
920 std::istringstream is( theStr );
922 //assert( e == theStr );
923 QCOMPARE ( e , theStr );
925 // Standard_Integer SearchFromEnd (const Standard_CString what)const
926 //assert( e.SearchFromEnd( theStr + i ) == i + 1 );
927 QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 );
929 // SetValue(const Standard_Integer where, const Standard_CString what)
930 e.SetValue( i+1, "what");
931 //assert( e.Search( "what" ) == i+1 );
932 //assert( e.Length() == strlen( theStr ));
933 QCOMPARE ( e.Search( "what" ) , i+1 );
934 QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) );
936 // TCollection_AsciiString Split (const Standard_Integer where)
939 //assert( d.Length() + e.Length() == strlen( theStr ));
940 QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
942 // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
943 // const Standard_Integer ToIndex) const
945 d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 );
946 //assert( d.Length() == 3 );
947 //assert( d.Value(1) == theStr[ i ]);
948 QCOMPARE ( d.Length() , 3 );
949 QCOMPARE ( d.Value(1) , theStr[ i ] );
951 // TCollection_AsciiString Token (const Standard_CString separators,
952 // const Standard_Integer whichone) const
954 for ( j = 0; j < i; ++j ) {
955 e += TCollection_AsciiString( theStr[j] ) + " ";
956 //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 ));
957 QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) );
960 for ( i = 0; i < 5; ++i )
962 // TCollection_ExtendedString (const Standard_CString astring,
963 // const Standard_Boolean isMultiByte)
964 const TCollection_ExtendedString a( theStr+i );
965 //assert( TCollection_AsciiString( a ) == theStr+i );
966 QCOMPARE ( TCollection_AsciiString( a ) , theStr+i );
968 //TCollection_ExtendedString (const Standard_ExtString astring)
969 const TCollection_ExtendedString b( a.ToExtString() );
973 // TCollection_ExtendedString (const Standard_Integer length,
974 // const Standard_ExtCharacter filler )
975 const TCollection_ExtendedString c( i, 1 );
976 //assert( c.Length() == i );
977 QCOMPARE ( c.Length() , i );
978 if ( c.Length() > 0 ) {
979 //assert( c.Value( i ) == 1 );
980 QCOMPARE ( c.Value( i ) , 1 );
983 // TCollection_ExtendedString (const Standard_Integer aValue)
984 TCollection_ExtendedString d( i );
985 const TCollection_AsciiString da( d );
986 //assert( da.IsIntegerValue() );
987 //assert( da.IntegerValue() == i );
988 QCOMPARE ( da.IsIntegerValue() , Standard_True );
989 QCOMPARE ( da.IntegerValue(), i );
991 // TCollection_ExtendedString (const Standard_Real aValue)
992 const TCollection_ExtendedString e( 0.1 * i );
993 const TCollection_AsciiString ea( e );
994 //assert( ea.IsRealValue() );
995 //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 );
996 QCOMPARE ( ea.IsRealValue() , Standard_True );
997 QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True );
999 // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1000 const TCollection_ExtendedString f(e);
1001 //assert( f.Length() == e.Length());
1003 QCOMPARE ( f.Length() , e.Length() );
1006 // TCollection_ExtendedString (const TCollection_AsciiString& astring)
1007 const TCollection_ExtendedString g( ea );
1008 //assert( g.Length() == ea.Length() );
1009 //assert( TCollection_AsciiString( g ) == ea );
1010 QCOMPARE ( g.Length() , ea.Length() );
1011 QCOMPARE ( TCollection_AsciiString( g ) , ea );
1013 // AssignCat (const TCollection_ExtendedString& other)
1014 const TCollection_ExtendedString sep(",");
1017 //assert( d.Length() == 2 + g.Length() );
1018 //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i ));
1019 //assert( d.Token( sep.ToExtString(), 2 ) == g );
1020 QCOMPARE ( d.Length() , 2 + g.Length() );
1021 QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) );
1022 QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g );
1024 // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const
1025 const TCollection_ExtendedString cat = a.Cat( sep );
1026 //assert( cat.Length() == a.Length() + sep.Length() );
1027 //assert( cat.Search( a ) == 1 );
1028 //assert( cat.Search( sep ) == a.Length() + 1 );
1029 QCOMPARE ( cat.Length() , a.Length() + sep.Length() );
1030 QCOMPARE ( cat.Search( a ) , 1 );
1031 QCOMPARE ( cat.Search( sep ) , a.Length() + 1 );
1033 // Copy (const TCollection_ExtendedString& fromwhere)
1035 //assert( d.Length() == cat.Length() );
1036 //assert( d == cat );
1037 QCOMPARE ( d.Length() , cat.Length() );
1038 QCOMPARE ( d , cat );
1040 // IsEqual (const Standard_ExtString other) const
1041 //assert( d.IsEqual( d.ToExtString() ));
1042 QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1044 // IsDifferent (const Standard_ExtString other ) const
1045 //assert( d.IsDifferent( a.ToExtString() ));
1046 QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1048 // IsDifferent (const TCollection_ExtendedString& other) const
1049 //assert( d.IsDifferent( a ));
1050 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
1052 // IsLess (const Standard_ExtString other) const
1053 const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1);
1054 //assert( l0. IsLess( l1.ToExtString() ));
1055 //assert( l0. IsLess( l00.ToExtString() ));
1056 //assert( l. IsLess( l0.ToExtString() ));
1057 //assert( ! l1. IsLess( l0.ToExtString() ));
1058 //assert( ! l00.IsLess( l0.ToExtString() ));
1059 //assert( ! l0. IsLess( l.ToExtString() ));
1060 //assert( ls.IsLess( ls1.ToExtString() ));
1061 QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True );
1062 QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True );
1063 QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True );
1064 QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True );
1065 QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True );
1066 QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True );
1067 QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True );
1069 // IsLess (const TCollection_ExtendedString& other) const
1070 //assert( l0. IsLess( l1 ));
1071 //assert( l0. IsLess( l00 ));
1072 //assert( l. IsLess( l0 ));
1073 //assert( ! l1. IsLess( l0 ));
1074 //assert( ! l00.IsLess( l0 ));
1075 //assert( ! l0. IsLess( l ));
1076 //assert( ls.IsLess( ls1 ));
1077 QCOMPARE ( l0. IsLess( l1 ) , Standard_True );
1078 QCOMPARE ( l0. IsLess( l00 ) , Standard_True );
1079 QCOMPARE ( l. IsLess( l0 ) , Standard_True );
1080 QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True );
1081 QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True );
1082 QCOMPARE ( ! l0. IsLess( l ) , Standard_True );
1083 QCOMPARE ( ls.IsLess( ls1 ) , Standard_True );
1085 // IsGreater (const Standard_ExtString other) const
1086 //assert( ! l0.IsGreater( l1.ToExtString() ));
1087 //assert( ! l0.IsGreater( l00.ToExtString() ));
1088 //assert( ! l. IsGreater( l0.ToExtString() ));
1089 //assert( l1. IsGreater( l0.ToExtString() ));
1090 //assert( l00.IsGreater( l0.ToExtString() ));
1091 //assert( l0. IsGreater( l.ToExtString() ));
1092 //assert( ls1.IsGreater( ls.ToExtString() ));
1093 QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True );
1094 QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True );
1095 QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True );
1096 QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True );
1097 QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True );
1098 QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True );
1099 QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True );
1101 // IsGreater (const TCollection_ExtendedString& other) const
1102 //assert( ! l0.IsGreater( l1));
1103 //assert( ! l0.IsGreater( l00));
1104 //assert( ! l. IsGreater( l0));
1105 //assert( l1. IsGreater( l0));
1106 //assert( l00.IsGreater( l0));
1107 //assert( l0. IsGreater( l));
1108 //assert( ls1.IsGreater( ls));
1109 QCOMPARE ( ! l0.IsGreater( l1) , Standard_True );
1110 QCOMPARE ( ! l0.IsGreater( l00) , Standard_True );
1111 QCOMPARE ( ! l. IsGreater( l0) , Standard_True );
1112 QCOMPARE ( l1. IsGreater( l0) , Standard_True );
1113 QCOMPARE ( l00.IsGreater( l0) , Standard_True );
1114 QCOMPARE ( l0. IsGreater( l) , Standard_True );
1115 QCOMPARE ( ls1.IsGreater( ls) , Standard_True );
1117 // ==========================
1118 //TCollection_HAsciiString::
1119 // ==========================
1121 // IsDifferent(const Handle(TCollection_HAsciiString)& S)
1122 Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i );
1123 Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 );
1124 //assert( ha1->IsDifferent( ha2 ));
1125 //assert( !ha1->IsDifferent( ha1 ));
1126 QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True );
1127 QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True );
1129 // IsSameString (const Handle(TCollection_HAsciiString)& S)
1130 //assert( !ha1->IsSameString( ha2 ));
1131 //assert( ha1->IsSameString( ha1 ));
1132 QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True );
1133 QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True );
1135 // IsSameState (const Handle(TCollection_HAsciiString)& other) const
1136 //assert( !ha1->IsSameState( ha2 ));
1137 //assert( ha1->IsSameState( ha1 ));
1138 QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True );
1139 QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True );
1141 // IsSameString (const Handle(TCollection_HAsciiString)& S ,
1142 // const Standard_Boolean CaseSensitive) const
1143 //assert( !ha1->IsSameString( ha2, true ));
1144 //assert( ha1->IsSameString( ha1, true ));
1145 //assert( !ha1->IsSameString( ha2, false ));
1146 //assert( ha1->IsSameString( ha1, false ));
1147 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1148 QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True );
1149 QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True );
1150 QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True );
1152 ha1->SetValue( 1, "AbC0000000");
1153 ha2->SetValue( 1, "aBc0000000");
1154 //assert( !ha1->IsSameString( ha2, true ));
1155 //assert( ha1->IsSameString( ha2, false ));
1156 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1157 QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True );
1162 #include <Geom_CylindricalSurface.hxx>
1163 #include <IntTools_FaceFace.hxx>
1164 #include <IntTools_Curve.hxx>
1165 #include <IntTools_PntOn2Faces.hxx>
1167 static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1171 theDI << "Wrong a number of arguments!\n";
1175 Handle(Geom_Plane) plane(new Geom_Plane(
1176 gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
1177 gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
1178 gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000))));
1179 Handle(Geom_CylindricalSurface) cylinder(
1180 new Geom_CylindricalSurface(
1181 gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
1182 gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
1183 gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
1184 19.712534607908712));
1186 DrawTrSurf::Set("pln", plane);
1188 DrawTrSurf::Set("cyl", cylinder);
1191 BRep_Builder builder;
1192 TopoDS_Face face1, face2;
1193 builder.MakeFace(face1, plane, Precision::Confusion());
1194 builder.MakeFace(face2, cylinder, Precision::Confusion());
1195 IntTools_FaceFace anInters;
1196 anInters.SetParameters(false, true, true, Precision::Confusion());
1197 anInters.Perform(face1, face2);
1199 if (!anInters.IsDone())
1201 theDI<<"No intersections found!\n";
1206 //Handle(Geom_Curve) aResult;
1209 const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1210 const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1213 Standard_Integer aNbCurves, aNbPoints;
1215 aNbCurves=aCvsX.Length();
1216 aNbPoints=aPntsX.Length();
1220 for (Standard_Integer i=1; i<=aNbCurves; ++i)
1222 Sprintf(buf, "%s_%d",theArgv[1],i);
1223 theDI << buf << " ";
1225 const IntTools_Curve& aIC = aCvsX(i);
1226 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1227 DrawTrSurf::Set(buf,aC3D);
1230 else if (aNbCurves == 1)
1232 const IntTools_Curve& aIC = aCvsX(1);
1233 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1234 Sprintf(buf, "%s",theArgv[1]);
1235 theDI << buf << " ";
1236 DrawTrSurf::Set(buf,aC3D);
1239 for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1241 const IntTools_PntOn2Faces& aPi=aPntsX(i);
1242 const gp_Pnt& aP=aPi.P1().Pnt();
1244 Sprintf(buf,"%s_p_%d",theArgv[1],i);
1245 theDI << buf << " ";
1246 DrawTrSurf::Set(buf, aP);
1252 #include <BRepAlgo_NormalProjection.hxx>
1253 static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1256 di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)";
1260 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1261 if(myAISContext.IsNull()) {
1262 di << "use 'vinit' command before " << argv[0] << "\n";
1266 TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1]));
1267 TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2]));
1269 BRepAlgo_NormalProjection anormpro(m_Face1);
1270 anormpro.Add(m_Edge);
1271 anormpro.SetDefaultParams();
1273 //anormpro.Compute3d();
1274 //anormpro.SetLimit();
1278 if (anormpro.IsDone())
1280 TopoDS_Shape rshape = anormpro.Projection();
1281 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape);
1282 myAISContext->SetColor(myShape, Quantity_Color(Quantity_NOC_YELLOW));
1283 myAISContext->Display(myShape, Standard_True);
1289 #include <BRepFeat_SplitShape.hxx>
1290 #include <ShapeAnalysis_ShapeContents.hxx>
1291 #include <BRepAlgo.hxx>
1292 static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1295 di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)";
1299 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1300 if(myAISContext.IsNull()) {
1301 di << "use 'vinit' command before " << argv[0] << "\n";
1305 TopoDS_Shape result;
1306 TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1]));
1307 TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2]));
1309 BRepFeat_SplitShape asplit(face);
1310 asplit.Add(wire, face);
1312 result = asplit.Shape();
1313 ShapeAnalysis_ShapeContents ana;
1314 ana.Perform(result);
1317 if (!(BRepAlgo::IsValid(result))) {
1318 di << "Result was checked and it is INVALID\n";
1320 di << "Result was checked and it is VALID\n";
1323 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result);
1324 myAISContext->Display(myShape, Standard_True);
1329 #include <Geom_Circle.hxx>
1330 #include <GeomAdaptor_Curve.hxx>
1331 #include <Extrema_ExtPC.hxx>
1332 #include <gp_Cylinder.hxx>
1333 #include <ElSLib.hxx>
1334 static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1337 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1341 gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 );
1342 gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() );
1343 Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 );
1344 GeomAdaptor_Curve aC3D( aCircle );
1346 Extrema_ExtPC aExtPC( aP3D, aC3D );
1347 //Standard_Real aParam = (aExtPC.Point(1)).Parameter();
1348 gp_Pnt aProj = (aExtPC.Point(1)).Value();
1349 di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n";
1351 // Result of deviation
1352 gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() );
1353 gp_Cylinder aCylinder( aCylAxis, 1890. );
1355 Standard_Real aU = 0., aV = 0.;
1356 ElSLib::Parameters( aCylinder, aProj, aU, aV );
1357 di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n";
1362 #include <Extrema_FuncExtPS.hxx>
1363 #include <math_FunctionSetRoot.hxx>
1364 #include <math_Vector.hxx>
1365 #include <BRepBuilderAPI_MakeVertex.hxx>
1366 static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1368 Standard_Integer anArgIter = 1;
1371 theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]\n";
1376 Standard_CString aFaceName = theArgv[anArgIter++];
1377 Standard_CString aVertName = theArgv[anArgIter++];
1378 const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
1379 const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
1380 const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
1381 const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
1382 const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
1383 if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
1385 std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1388 if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1390 std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1393 const TopoDS_Face aFace = TopoDS::Face (aShapeF);
1394 const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1395 GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1397 gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1399 Extrema_FuncExtPS anExtFunc;
1400 math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
1402 math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2);
1403 aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion();
1404 aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite();
1405 aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite();
1406 aFromUV(1) = aUFrom; aFromUV(2) = aVFrom;
1408 anExtFunc.Initialize (aSurf);
1409 anExtFunc.SetPoint (aPnt);
1410 aRoot.SetTolerance (aTolUV);
1411 aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1412 if (!aRoot.IsDone())
1414 std::cerr << "No results!\n";
1418 theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1420 aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1421 DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1425 //! Check boolean operations on NCollection_Map
1426 static Standard_Integer OCC24271 (Draw_Interpretor& di,
1427 Standard_Integer /*theArgNb*/,
1428 const char** /*theArgVec*/)
1431 const Standard_Integer aLeftLower = 1;
1432 const Standard_Integer aLeftUpper = 10;
1433 const Standard_Integer aRightLower = 5;
1434 const Standard_Integer aRightUpper = 15;
1437 NCollection_Map<Standard_Integer> aMapLeft;
1438 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1440 aMapLeft.Add (aKeyIter);
1443 NCollection_Map<Standard_Integer> aMapRight;
1444 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1446 aMapRight.Add (aKeyIter);
1449 QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1450 QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False);
1452 // validate Union operation
1453 NCollection_Map<Standard_Integer> aMapUnion;
1454 aMapUnion.Union (aMapLeft, aMapRight);
1455 QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1);
1456 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter)
1458 QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
1461 // validate Intersection operation
1462 NCollection_Map<Standard_Integer> aMapSect;
1463 aMapSect.Intersection (aMapLeft, aMapRight);
1464 QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1);
1465 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1467 QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1469 QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1470 QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
1472 // validate Substruction operation
1473 NCollection_Map<Standard_Integer> aMapSubsLR;
1474 aMapSubsLR.Subtraction (aMapLeft, aMapRight);
1475 QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower);
1476 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1478 QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
1481 NCollection_Map<Standard_Integer> aMapSubsRL;
1482 aMapSubsRL.Subtraction (aMapRight, aMapLeft);
1483 QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper);
1484 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1486 QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
1489 // validate Difference operation
1490 NCollection_Map<Standard_Integer> aMapDiff;
1491 aMapDiff.Difference (aMapLeft, aMapRight);
1492 QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper);
1493 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1495 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1497 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1499 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1502 // validate Exchange operation
1503 NCollection_Map<Standard_Integer> aMapSwap;
1504 aMapSwap.Exchange (aMapSect);
1505 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1507 QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1509 QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1513 NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1514 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1515 aMapCopy.Remove (34);
1517 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1522 #define QVERIFY(val1) \
1523 di << "Checking " #val1 " == Standard_True" << \
1524 ((val1) == Standard_True ? ": OK\n" : ": Error\n")
1526 #include <GeomInt_IntSS.hxx>
1527 #include <Geom_ConicalSurface.hxx>
1528 #include <Standard_ErrorHandler.hxx>
1529 //=======================================================================
1530 //function : OCC23972
1532 //=======================================================================
1533 static void DoGeomIntSSTest (const Handle(Geom_Surface)& theSurf1,
1534 const Handle(Geom_Surface)& theSurf2,
1535 const Standard_Integer theNbSol,
1536 Draw_Interpretor& di)
1540 GeomInt_IntSS anInter;
1541 anInter.Perform (theSurf1, theSurf2, Precision::Confusion(), Standard_True);
1542 QVERIFY (anInter.IsDone());
1543 QCOMPARE (anInter.NbLines(), theNbSol);
1545 QVERIFY (Standard_False);
1550 static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc,
1551 const gp_Dir& theDir,
1552 const gp_Dir& theXDir,
1553 const Standard_Real theRad,
1554 const Standard_Real theSin,
1555 const Standard_Real theCos)
1557 const Standard_Real anA = atan (theSin / theCos);
1558 gp_Ax3 anAxis (theLoc, theDir, theXDir);
1559 Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad);
1564 static Standard_Integer OCC23972 (Draw_Interpretor& di,Standard_Integer n, const char**)
1566 if (n != 1) return 1;
1568 //process specific cones, cannot read them from files because due to rounding the original error
1569 //in math_FunctionRoots gets hidden
1570 Handle(Geom_Surface) aS1 = CreateCone (
1571 gp_Pnt (123.694345356663, 789.9, 68.15),
1572 gp_Dir (-1, 3.48029791472957e-016, -8.41302743359754e-017),
1573 gp_Dir (-3.48029791472957e-016, -1, -3.17572289932207e-016),
1577 Handle(Geom_Surface) aS2 = CreateCone (
1578 gp_Pnt (123.694345356663, 784.9, 68.15),
1579 gp_Dir (-1, -2.5209507537117e-016, -1.49772808948866e-016),
1580 gp_Dir (1.49772808948866e-016, 3.17572289932207e-016, -1),
1585 DoGeomIntSSTest (aS1, aS2, 2, di);
1590 #include <ShapeFix_EdgeProjAux.hxx>
1591 static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1594 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
1598 TopoDS_Shape aSh = DBRep::Get(argv[1]);
1600 di << argv[0] << " Error: Null input edge\n";
1603 const TopoDS_Edge& anEdge = TopoDS::Edge (aSh);
1605 Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]);
1607 di << argv[0] << " Error: Null input curve\n";
1611 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]);
1613 di << argv[0] << " Error: Null input surface\n";
1617 Standard_Real prec = Draw::Atof(argv[4]);
1622 aB.MakeFace (aFace, aS, Precision::Confusion());
1623 aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion());
1624 aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter());
1627 ShapeFix_EdgeProjAux aProj (aFace, anEdge);
1628 aProj.Compute (prec);
1630 Standard_Boolean isfirstdone = aProj.IsFirstDone();
1631 Standard_Boolean islastdone = aProj.IsLastDone();
1633 Standard_Real first = 0.;
1634 Standard_Real last = 0.;
1635 Standard_Integer isfirstdoneInteger = 0;
1636 Standard_Integer islastdoneInteger = 0;
1640 first = aProj.FirstParam();
1641 isfirstdoneInteger = 1;
1645 last= aProj.LastParam();
1646 islastdoneInteger = 1;
1649 di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n";
1654 template<typename T, typename HT>
1655 static void DoIsNull(Draw_Interpretor& di)
1658 // QVERIFY (aHandle.IsNull());
1659 QCOMPARE (aHandle.IsNull(), Standard_True);
1660 const T* p = aHandle.get();
1661 #if OCC_VERSION_HEX > 0x060700
1664 QCOMPARE (!p, Standard_True);
1665 QCOMPARE (p == 0, Standard_True);
1669 //QVERIFY (!aHandle.IsNull());
1670 QCOMPARE (!aHandle.IsNull(), Standard_True);
1674 QCOMPARE (p != NULL, Standard_True);
1675 QCOMPARE (p != 0, Standard_True);
1678 //=======================================================================
1679 //function : OCC24533
1681 //=======================================================================
1682 static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**)
1684 if (n != 1) return 1;
1686 DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di);
1691 // Dummy class to test interface for compilation issues
1692 class QABugs_HandleClass : public Standard_Transient
1695 Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1697 std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n";
1700 DEFINE_STANDARD_RTTI_INLINE(QABugs_HandleClass,Standard_Transient) // Type definition
1702 DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1705 // Dummy class to test interface for compilation issues
1706 struct QABugs_NHandleClass
1708 Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1710 std::cerr << "QABugs_NHandleClass[" << this << "] " << theArgVec[0] << "\n";
1715 #include <XCAFDoc_ColorTool.hxx>
1716 #include <STEPControl_StepModelType.hxx>
1717 #include <STEPCAFControl_Writer.hxx>
1718 static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1721 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1724 Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");;
1725 TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape();
1726 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape();
1727 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1);
1728 TDataStd_Name::Set(lab1, "Box1");
1730 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1731 XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen);
1732 XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0);
1734 STEPControl_StepModelType mode = STEPControl_AsIs;
1735 STEPCAFControl_Writer writer;
1736 if ( ! writer.Transfer (aDoc, mode ) )
1738 di << "The document cannot be translated or gives no result" << "\n";
1742 writer.Write(argv[1]);
1747 //=======================================================================
1748 //function : OCC23950
1750 //=======================================================================
1751 static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1754 di << "Usage : " << argv[0] << " step_file\n";
1758 Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy");
1759 TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
1761 TopLoc_Location location0 (t0);
1763 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1764 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6);
1765 TDataStd_Name::Set(lab1, "Point1");
1767 TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1768 TDataStd_Name::Set(labelA0, "ASSEMBLY");
1770 TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
1772 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1773 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
1774 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
1776 STEPControl_StepModelType mode = STEPControl_AsIs;
1777 STEPCAFControl_Writer writer;
1778 if (! writer.Transfer (aDoc, mode))
1780 di << "The document cannot be translated or gives no result\n";
1784 writer.Write (argv[1]);
1788 //=======================================================================
1789 //function : OCC24622
1790 //purpose : The command tests sourcing Image_PixMap to AIS_TexturedShape
1791 //=======================================================================
1792 static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec)
1796 std::cout << "Usage : " << theArgVec[0] << " texture={1D|2D}";
1800 const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
1801 if (anAISContext.IsNull())
1803 std::cout << "Please initialize view with \"vinit\".\n";
1807 Handle(Image_PixMap) anImage = new Image_PixMap();
1809 static const Image_ColorRGB aBitmap[8] =
1811 {{255, 0, 0}}, {{0, 148, 255}}, {{ 0, 148, 255}}, {{255, 94, 0}},
1812 {{255, 121, 0}}, {{76, 255, 0}}, {{76, 255, 0}}, {{255, 202, 0}}
1815 TCollection_AsciiString aTextureTypeArg (theArgVec[1]);
1816 aTextureTypeArg.UpperCase();
1817 if (aTextureTypeArg == "1D")
1819 anImage->InitWrapper (Image_PixMap::ImgRGB, (Standard_Byte*)aBitmap, 8, 1);
1821 else if (aTextureTypeArg == "2D")
1823 anImage->InitTrash (Image_PixMap::ImgRGB, 8, 8);
1824 for (Standard_Integer aRow = 0; aRow < 8; ++aRow)
1826 for (Standard_Integer aCol = 0; aCol < 8; ++aCol)
1828 anImage->ChangeValue<Image_ColorRGB> (aRow, aCol) = aBitmap[aRow];
1834 std::cout << "Please specify type of texture to test {1D|2D}.\n";
1838 TopoDS_Shape aBlankShape = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
1840 Handle(AIS_TexturedShape) aTexturedShape = new AIS_TexturedShape (aBlankShape);
1841 aTexturedShape->SetTexturePixMap (anImage);
1842 anAISContext->Display (aTexturedShape, 3, 0);
1847 //=======================================================================
1848 //function : OCC24667
1850 //=======================================================================
1851 static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1855 di << "OCC24667 result Wire_spine Profile [Mode [Approx]]\n";
1856 di << "Mode = 0 - CorrectedFrenet,\n";
1857 di << " = 1 - Frenet,\n";
1858 di << " = 2 - DiscreteTrihedron\n";
1859 di << "Approx - force C1-approximation if result is C0\n";
1863 if (n > 1 && n < 4) return 1;
1865 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
1866 if ( Spine.IsNull()) return 1;
1868 TopoDS_Shape Profile = DBRep::Get(a[3]);
1869 if ( Profile.IsNull()) return 1;
1871 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
1874 Standard_Integer iMode = atoi(a[4]);
1876 Mode = GeomFill_IsFrenet;
1877 else if (iMode == 2)
1878 Mode = GeomFill_IsDiscreteTrihedron;
1881 Standard_Boolean ForceApproxC1 = Standard_False;
1883 ForceApproxC1 = Standard_True;
1885 BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine),
1890 TopoDS_Shape S = aPipe.Shape();
1891 TopoDS_Shape aSF = aPipe.FirstShape();
1892 TopoDS_Shape aSL = aPipe.LastShape();
1896 TCollection_AsciiString aStrF(a[1], "_f");
1897 TCollection_AsciiString aStrL(a[1], "_l");
1899 DBRep::Set(aStrF.ToCString(), aSF);
1900 DBRep::Set(aStrL.ToCString(), aSL);
1905 #include <BRepPrimAPI_MakeCylinder.hxx>
1906 #include <BRepBuilderAPI_Copy.hxx>
1907 #include <BRepTools_NurbsConvertModification.hxx>
1908 static TopoDS_Shape CreateTestShape (int& theShapeNb)
1910 TopoDS_Compound aComp;
1911 BRep_Builder aBuilder;
1912 aBuilder.MakeCompound (aComp);
1913 //NURBS modifier is used to increase footprint of each shape
1914 Handle(BRepTools_NurbsConvertModification) aNurbsModif = new BRepTools_NurbsConvertModification;
1915 TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid();
1916 BRepTools_Modifier aModifier (aRefShape, aNurbsModif);
1917 if (aModifier.IsDone()) {
1918 aRefShape = aModifier.ModifiedShape (aRefShape);
1921 for (; theShapeNb > 0; --theShapeNb) {
1922 TopoDS_Shape aShape;
1923 if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists
1924 aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape();
1926 aShape = CreateTestShape (theShapeNb);
1928 aBuilder.Add (aComp, aShape);
1933 #include <AppStd_Application.hxx>
1934 #include <TDataStd_Integer.hxx>
1935 #include <TNaming_Builder.hxx>
1936 static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1939 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1942 TCollection_ExtendedString aFileName (argv[1]);
1943 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
1945 Handle(TDocStd_Application) anApp = new AppStd_Application;
1947 Handle(TDocStd_Document) aDoc;
1948 anApp->NewDocument ("XmlOcaf", aDoc);
1949 TDF_Label aLab = aDoc->Main();
1950 TDataStd_Integer::Set (aLab, 0);
1951 int n = 10000; //must be big enough
1952 TopoDS_Shape aShape = CreateTestShape (n);
1953 TNaming_Builder aBuilder (aLab);
1954 aBuilder.Generated (aShape);
1956 aSStatus = anApp->SaveAs (aDoc, aFileName);
1957 anApp->Close (aDoc);
1959 QCOMPARE (aSStatus, PCDM_SS_OK);
1963 #include <AppStdL_Application.hxx>
1964 #include <TDocStd_Application.hxx>
1965 #include <TDataStd_Integer.hxx>
1966 #include <TDF_AttributeIterator.hxx>
1967 //=======================================================================
1968 //function : OCC24755
1970 //=======================================================================
1971 static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1975 std::cout << "Usage : " << a[0] << "\n";
1979 Handle(TDocStd_Application) anApp = new AppStdL_Application;
1980 Handle(TDocStd_Document) aDoc;
1981 anApp->NewDocument ("BinOcaf", aDoc);
1982 TDF_Label aLab = aDoc->Main();
1983 TDataStd_Integer::Set (aLab, 0);
1984 TDataStd_Name::Set (aLab, "test");
1986 TDF_AttributeIterator i (aLab);
1987 Handle(TDF_Attribute) anAttr = i.Value();
1988 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True);
1991 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True);
1998 MyStubObject() : ptr(0L) {}
1999 MyStubObject(void* thePtr) : ptr(thePtr) {}
2004 //=======================================================================
2005 //function : OCC24834
2007 //=======================================================================
2008 static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2012 std::cout << "Usage : " << a[0] << "\n";
2016 int i = sizeof (char*);
2018 std::cout << "64-bit architecture is not supported.\n";
2022 NCollection_List<MyStubObject> aList;
2023 const Standard_Integer aSmallBlockSize = 40;
2024 const Standard_Integer aLargeBlockSize = 1500000;
2026 // quick populate memory with large blocks
2031 aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize)));
2034 catch (Standard_Failure)
2036 di << "caught out of memory for large blocks: OK\n";
2040 di << "skept out of memory for large blocks: Error\n";
2043 // allocate small blocks
2048 aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize)));
2051 catch (Standard_Failure)
2053 di << "caught out of memory for small blocks: OK\n";
2057 di << "skept out of memory for small blocks: Error\n";
2060 // release all allocated blocks
2061 for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next())
2063 Standard::Free(it.Value().ptr);
2069 #include <Geom2dAPI_InterCurveCurve.hxx>
2070 #include <IntRes2d_IntersectionPoint.hxx>
2071 //=======================================================================
2072 //function : OCC24889
2074 //=======================================================================
2075 static Standard_Integer OCC24889 (Draw_Interpretor& theDI,
2076 Standard_Integer /*theNArg*/,
2077 const char** /*theArgs*/)
2080 Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle(
2081 gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2083 Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle(
2084 gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2086 Handle( Geom2d_TrimmedCurve ) aTrim[2] = {
2087 new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ),
2088 new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 )
2091 DrawTrSurf::Set("c_1", aTrim[0]);
2092 DrawTrSurf::Set("c_2", aTrim[1]);
2095 const Standard_Real aTol = Precision::Confusion();
2096 Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol );
2098 const IntRes2d_IntersectionPoint& aIntPnt =
2099 aIntTool.Intersector().Point( 1 );
2101 gp_Pnt2d aIntRes = aIntTool.Point( 1 );
2102 Standard_Real aPar[2] = {
2103 aIntPnt.ParamOnFirst(),
2104 aIntPnt.ParamOnSecond()
2107 //theDI.precision( 5 );
2108 theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n";
2109 for (int i = 0; i < 2; ++i)
2111 theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() <<
2112 "; LastParam = " << aTrim[i]->LastParameter() <<
2113 "; IntParameter = " << aPar[i] << "\n";
2119 #include <math_GlobOptMin.hxx>
2120 #include <math_MultipleVarFunctionWithHessian.hxx>
2121 //=======================================================================
2122 //function : OCC25004
2123 //purpose : Check extremaCC on Branin function.
2124 //=======================================================================
2126 // f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s
2127 // Standard borders are:
2130 class BraninFunction : public math_MultipleVarFunctionWithHessian
2136 b = 5.1 / (4.0 * M_PI * M_PI);
2140 t = 1.0 / (8.0 * M_PI);
2142 virtual Standard_Integer NbVariables() const
2146 virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F)
2148 Standard_Real u = X(1);
2149 Standard_Real v = X(2);
2151 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2152 Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion.
2153 F = a * aSqPt * aSqPt + aLnPt + s;
2154 return Standard_True;
2156 virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G)
2158 Standard_Real u = X(1);
2159 Standard_Real v = X(2);
2161 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2162 G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u);
2163 G(2) = 2 * a * aSqPt;
2165 return Standard_True;
2167 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
2172 return Standard_True;
2174 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H)
2179 Standard_Real u = X(1);
2180 Standard_Real v = X(2);
2182 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2183 Standard_Real aTmpPt = c - 2 * b *u; // Tmp part.
2184 H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u);
2185 H(1,2) = 2 * a * aTmpPt;
2189 return Standard_True;
2193 // Standard parameters.
2194 Standard_Real a, b, c, r, s, t;
2197 static Standard_Integer OCC25004 (Draw_Interpretor& theDI,
2198 Standard_Integer /*theNArg*/,
2199 const char** /*theArgs*/)
2201 BraninFunction aFunc;
2203 math_Vector aLower(1,2), aUpper(1,2);
2209 Standard_Integer aGridOrder = 16;
2210 math_Vector aFuncValues(1, aGridOrder * aGridOrder);
2212 Standard_Real aLipConst = 0;
2213 math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2);
2215 // Get Lipshitz constant estimation on regular grid.
2216 Standard_Integer i, j, idx = 1;
2217 for(i = 1; i <= aGridOrder; i++)
2219 for(j = 1; j <= aGridOrder; j++)
2221 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2222 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2224 aFunc.Value(aCurrPnt1, aFuncValues(idx));
2229 Standard_Integer k, l;
2230 Standard_Integer idx1, idx2;
2231 for(i = 1; i <= aGridOrder; i++)
2232 for(j = 1; j <= aGridOrder; j++)
2233 for(k = 1; k <= aGridOrder; k++)
2234 for(l = 1; l <= aGridOrder; l++)
2236 if (i == k && j == l)
2239 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2240 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2241 idx1 = (i - 1) * aGridOrder + j;
2243 aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0);
2244 aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0);
2245 idx2 = (k - 1) * aGridOrder + l;
2247 aCurrPnt1.Add(-aCurrPnt2);
2248 Standard_Real dist = aCurrPnt1.Norm();
2250 Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist;
2255 math_GlobOptMin aFinder(&aFunc, aLower, aUpper, aLipConst);
2257 //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475)
2259 Standard_Real anExtValue = aFinder.GetF();
2260 theDI << "F = " << anExtValue << "\n";
2262 Standard_Integer aNbExt = aFinder.NbExtrema();
2263 theDI << "NbExtrema = " << aNbExt << "\n";
2268 #include <OSD_Environment.hxx>
2269 #include <Plugin.hxx>
2270 #include <Plugin_Macro.hxx>
2271 #include <Resource_Manager.hxx>
2273 #define THE_QATEST_DOC_FORMAT "My Proprietary Format"
2275 #define QA_CHECK(theDesc, theExpr, theValue) \
2277 const bool isTrue = !!(theExpr); \
2278 std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \
2281 class Test_TDocStd_Application : public TDocStd_Application
2285 static void initGlobalPluginMap (const TCollection_AsciiString& thePlugin,
2286 const TCollection_AsciiString& theSaver,
2287 const TCollection_AsciiString& theLoader)
2289 const Handle(Resource_Manager)& aManager = Plugin::AdditionalPluginMap();
2290 aManager->SetResource ((theSaver + ".Location").ToCString(), thePlugin.ToCString());
2291 aManager->SetResource ((theLoader + ".Location").ToCString(), thePlugin.ToCString());
2294 Test_TDocStd_Application (const TCollection_AsciiString& thePlugin,
2295 const TCollection_AsciiString& theSaver,
2296 const TCollection_AsciiString& theLoader)
2298 initGlobalPluginMap (thePlugin, theSaver, theLoader);
2300 // explicitly initialize resource manager
2301 myResources = new Resource_Manager ("");
2302 myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT);
2303 myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document");
2304 myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml");
2305 myResources->SetResource (THE_QATEST_DOC_FORMAT ".StoragePlugin", theSaver.ToCString());
2306 myResources->SetResource (THE_QATEST_DOC_FORMAT ".RetrievalPlugin", theLoader.ToCString());
2309 virtual Standard_CString ResourcesName() { return ""; }
2310 virtual void Formats (TColStd_SequenceOfExtendedString& theFormats) { theFormats.Clear(); }
2313 //=======================================================================
2314 //function : OCC24925
2316 //=======================================================================
2317 static Standard_Integer OCC24925 (Draw_Interpretor& theDI,
2318 Standard_Integer theArgNb,
2319 const char** theArgVec)
2324 std::cout << "Error: wrong syntax! See usage:\n";
2325 theDI.PrintHelp (theArgVec[0]);
2329 Standard_Integer anArgIter = 1;
2330 TCollection_ExtendedString aFileName = theArgVec[anArgIter++];
2331 TCollection_AsciiString aPlugin = "TKXml";
2332 TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx
2333 TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx
2334 if (anArgIter < theArgNb)
2336 aPlugin = theArgVec[anArgIter++];
2337 aSaver = theArgVec[anArgIter++];
2338 aLoader = theArgVec[anArgIter++];
2341 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2342 PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError;
2344 Handle(TDocStd_Application) anApp = new Test_TDocStd_Application (aPlugin, aSaver, aLoader);
2346 Handle(TDocStd_Document) aDoc;
2347 anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc);
2348 TDF_Label aLab = aDoc->Main();
2349 TDataStd_Integer::Set (aLab, 0);
2350 TDataStd_Name::Set (aLab, "QABugs_19.cxx");
2352 aSStatus = anApp->SaveAs (aDoc, aFileName);
2353 anApp->Close (aDoc);
2355 QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true);
2358 Handle(TDocStd_Document) aDoc;
2359 aRStatus = anApp->Open (aFileName, aDoc);
2360 anApp->Close (aDoc);
2362 QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true);
2366 //=======================================================================
2367 //function : OCC25043
2369 //=======================================================================
2370 #include <BRepAlgoAPI_Check.hxx>
2371 static Standard_Integer OCC25043 (Draw_Interpretor& theDI,
2372 Standard_Integer theArgNb,
2373 const char** theArgVec)
2375 if (theArgNb != 2) {
2376 theDI << "Usage: " << theArgVec[0] << " shape\n";
2380 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
2381 if (aShape.IsNull())
2383 theDI << theArgVec[1] << " shape is NULL\n";
2387 BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True);
2389 if (!anAlgoApiCheck.IsValid())
2391 BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result());
2392 for (; anCheckIter.More(); anCheckIter.Next())
2394 const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value();
2395 const BOPCol_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1();
2396 BOPCol_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes);
2397 for (; aFaultyIter.More(); aFaultyIter.Next())
2399 const TopoDS_Shape& aFaultyShape = aFaultyIter.Value();
2401 Standard_Boolean anIsFaultyShapeFound = Standard_False;
2402 TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType());
2403 for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next())
2405 if (anExp.Current().IsEqual(aFaultyShape))
2406 anIsFaultyShapeFound = Standard_True;
2409 if (!anIsFaultyShapeFound)
2411 theDI << "Error. Faulty Shape is NOT found in source shape.\n";
2416 theDI << "Info. Faulty shape if found in source shape\n";
2423 theDI << "Error. Problems are not detected. Test is not performed.";
2429 //=======================================================================
2430 //function : OCC24606
2432 //=======================================================================
2433 static Standard_Integer OCC24606 (Draw_Interpretor& theDI,
2434 Standard_Integer theArgNb,
2435 const char** theArgVec)
2439 std::cerr << "Error: incorrect number of arguments.\n";
2440 theDI << "Usage : " << theArgVec[0] << "\n";
2444 Handle(V3d_View) aView = ViewerTest::CurrentView();
2447 std::cerr << "Errro: no active view, please call 'vinit'.\n";
2451 aView->DepthFitAll();
2457 //=======================================================================
2458 //function : OCC23010
2460 //=======================================================================
2461 #include <STEPCAFControl_Reader.hxx>
2463 class mOcafApplication : public TDocStd_Application
2465 void Formats(TColStd_SequenceOfExtendedString& Formats)
2467 Formats.Append(TCollection_ExtendedString("mOcafApplication"));
2469 Standard_CString ResourcesName()
2471 return Standard_CString("Resources");
2475 static Standard_Integer OCC23010 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2478 di << "Usage: " << argv[0] << " invalid number of arguments\n";
2481 std::string fileName=argv[1];
2482 mOcafApplication *mCasApp = new mOcafApplication();
2483 Handle(TDocStd_Document) doc;
2484 mCasApp->NewDocument("BinXCAF", doc);
2485 STEPCAFControl_Reader stepReader;
2486 IFSelect_ReturnStatus status = stepReader.ReadFile (fileName.c_str());
2487 if (status != IFSelect_RetDone)
2489 stepReader.SetColorMode(Standard_True);
2490 stepReader.SetLayerMode(Standard_True);
2491 stepReader.SetNameMode(Standard_True);
2492 stepReader.Transfer(doc); // ERROR HERE!!!
2497 //=======================================================================
2498 //function : OCC25202
2500 //=======================================================================
2501 #include <ShapeBuild_ReShape.hxx>
2502 static Standard_Integer OCC25202 ( Draw_Interpretor& theDI,
2503 Standard_Integer theArgN,
2504 const char** theArgVal)
2507 //reshape res shape numF1 face1 numF2 face2
2510 theDI << "Use: reshape res shape numF1 face1 numF2 face2\n";
2514 TopoDS_Shape aShape = DBRep::Get(theArgVal[2]);
2515 const Standard_Integer aNumOfRE1 = Draw::Atoi(theArgVal[3]),
2516 aNumOfRE2 = Draw::Atoi(theArgVal[5]);
2517 TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])),
2518 aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6]));
2522 theDI << theArgVal[2] << " is null shape\n";
2526 if(aShapeForRepl1.IsNull())
2528 theDI << theArgVal[4] << " is not a replaced type\n";
2532 if(aShapeForRepl2.IsNull())
2534 theDI << theArgVal[6] << " is not a replaced type\n";
2539 TopoDS_Shape aReplacedShape;
2540 ShapeBuild_ReShape aReshape;
2542 //////////////////// explode (begin)
2543 TopTools_MapOfShape M;
2545 Standard_Integer aNbShapes = 0;
2546 for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next())
2548 const TopoDS_Shape& Sx = ex.Current();
2549 Standard_Boolean added = M.Add(Sx);
2553 if(aNbShapes == aNumOfRE1)
2555 aReplacedShape = Sx;
2557 aReshape.Replace(aReplacedShape, aShapeForRepl1);
2560 if(aNbShapes == aNumOfRE2)
2562 aReplacedShape = Sx;
2564 aReshape.Replace(aReplacedShape, aShapeForRepl2);
2568 //////////////////// explode (end)
2570 if(aReplacedShape.IsNull())
2572 theDI << "There is not any shape for replacing.\n";
2575 DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2));
2580 #include <ShapeFix_Wireframe.hxx>
2581 //=======================================================================
2582 //function : OCC7570
2584 //=======================================================================
2585 static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2588 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
2591 TopoDS_Shape in_shape (DBRep::Get (a[1]));
2592 ShapeFix_Wireframe fix_tool (in_shape);
2593 fix_tool.ModeDropSmallEdges () = Standard_True;
2594 fix_tool.SetPrecision (1.e+6);
2595 fix_tool.SetLimitAngle (0.01);
2596 fix_tool.FixSmallEdges ();
2597 TopoDS_Shape new_shape = fix_tool.Shape ();
2601 #include <AIS_TypeFilter.hxx>
2602 //=======================================================================
2603 //function : OCC25340
2605 //=======================================================================
2606 static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/,
2607 Standard_Integer /*theArgNb*/,
2608 const char** /*theArgVec*/)
2610 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2613 std::cerr << "Error: No opened viewer!\n";
2616 Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
2617 aCtx->AddFilter (aFilter);
2621 //=======================================================================
2622 //function : OCC24826
2624 //=======================================================================
2625 class ParallelTest_Saxpy
2628 typedef NCollection_Array1<Standard_Real> Vector;
2631 ParallelTest_Saxpy(const Vector& theX, Vector& theY, Standard_Real theScalar)
2638 //! Dummy calculation
2639 void operator() (const Standard_Integer theIndex) const
2641 myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex);
2645 ParallelTest_Saxpy( const ParallelTest_Saxpy& );
2646 ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& );
2651 const Standard_Real myScalar;
2654 //---------------------------------------------------------------------
2655 static Standard_Integer OCC24826(Draw_Interpretor& theDI,
2656 Standard_Integer trheArgc,
2657 const char** theArgv)
2659 if ( trheArgc != 2 )
2668 Standard_Integer aLength = Draw::Atoi(theArgv[1]);
2670 NCollection_Array1<Standard_Real> aX (0, aLength - 1);
2671 NCollection_Array1<Standard_Real> anY(0, aLength - 1);
2673 for ( Standard_Integer i = 0; i < aLength; ++i )
2675 aX(i) = anY(i) = (Standard_Real) i;
2682 //! Serial proccesing
2683 for ( Standard_Integer i = 0; i < aLength; ++i )
2685 anY(i) = 1e-6 * aX(i) + anY(i);
2689 cout << "Processing time (sequential mode):\n";
2692 const ParallelTest_Saxpy aFunctor(aX, anY, 1e-6);
2697 // Parallel processing
2698 OSD_Parallel::For(0, aLength, aFunctor);
2701 cout << "Processing time (parallel mode):\n";
2707 /*****************************************************************************/
2709 #include <GeomAPI_IntSS.hxx>
2710 //=======================================================================
2711 //function : OCC25100
2713 //=======================================================================
2714 static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2718 di << "the method requires a shape name\n";
2722 TopoDS_Shape S = DBRep::Get(argv[1]);
2725 di << "Shape is empty\n";
2729 TopExp_Explorer aFaceExp(S, TopAbs_FACE);
2730 const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current()));
2732 GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion());
2734 if (!anIntersector.IsDone())
2736 di << "Error. Intersection is not done\n";
2740 di << "Test complete\n";
2745 //=======================================================================
2746 //function : OCC25348
2748 //=======================================================================
2749 static Standard_Integer OCC25348 (Draw_Interpretor& theDI,
2750 Standard_Integer /*theArgNb*/,
2751 const char** /*theArgVec*/)
2753 Handle(NCollection_IncAllocator) anAlloc1;
2754 NCollection_List<int> aList1(anAlloc1);
2755 for (int i=0; i < 10; i++)
2757 Handle(NCollection_IncAllocator) anAlloc2;
2758 NCollection_List<int> aList2(anAlloc2);
2760 aList1.Assign(aList2);
2762 theDI << "Test complete\n";
2766 #include <IntCurvesFace_ShapeIntersector.hxx>
2767 #include <BRepBndLib.hxx>
2768 //=======================================================================
2769 //function : OCC25413
2771 //=======================================================================
2772 static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
2775 di << "Usage: " << a[0] << " invalid number of arguments\n";
2778 TopoDS_Shape aShape = DBRep::Get (a[1]);
2780 IntCurvesFace_ShapeIntersector Inter;
2781 Inter.Load(aShape, Precision::Confusion());
2784 BRepBndLib::Add(aShape, aBndBox);
2786 gp_Dir aDir(0., 1., 0.);
2788 Standard_Real xMin = aBndBox.CornerMin().X();
2789 Standard_Real zMin = aBndBox.CornerMin().Z();
2790 Standard_Real xMax = aBndBox.CornerMax().X();
2791 Standard_Real zMax = aBndBox.CornerMax().Z();
2792 Standard_Real xStep = (xMax - xMin) / N;
2793 Standard_Real zStep = (zMax - zMin) / N;
2795 for (Standard_Real x = xMin; x <= xMax; x += xStep)
2796 for (Standard_Real z = zMin; z <= zMax; z += zStep)
2798 gp_Pnt aPoint(x, 0.0, z);
2799 gp_Lin aLine(aPoint, aDir);
2800 Inter.PerformNearest(aLine, -100., 100.);
2806 #include <BOPAlgo_PaveFiller.hxx>
2808 #include <BRepAlgoAPI_BooleanOperation.hxx>
2809 #include <BRepAlgoAPI_Common.hxx>
2810 #include <BRepAlgoAPI_Fuse.hxx>
2811 #include <BRepAlgoAPI_Cut.hxx>
2812 #include <BRepAlgoAPI_Section.hxx>
2814 #include <BOPTools.hxx>
2816 #include <BOPCol_MapOfShape.hxx>
2817 #include <BOPCol_ListOfShape.hxx>
2818 //=======================================================================
2819 //function : OCC25446
2821 //=======================================================================
2822 static Standard_Integer OCC25446 (Draw_Interpretor& theDI,
2823 Standard_Integer argc,
2827 theDI << "Usage: OCC25446 res b1 b2 op\n";
2831 TopoDS_Shape aS1 = DBRep::Get(argv[2]);
2833 theDI << argv[2] << " shape is NULL\n";
2837 TopoDS_Shape aS2 = DBRep::Get(argv[3]);
2839 theDI << argv[3] << " shape is NULL\n";
2843 Standard_Integer iOp;
2844 BOPAlgo_Operation aOp;
2846 iOp = Draw::Atoi(argv[4]);
2847 if (iOp < 0 || iOp > 4) {
2848 theDI << "Invalid operation type\n";
2851 aOp = (BOPAlgo_Operation)iOp;
2853 Standard_Integer iErr;
2854 BOPCol_ListOfShape aLS;
2855 BOPAlgo_PaveFiller aPF;
2859 aPF.SetArguments(aLS);
2862 iErr = aPF.ErrorStatus();
2864 theDI << "Intersection failed with error status: " << iErr << "\n";
2868 BRepAlgoAPI_BooleanOperation* pBuilder = NULL;
2871 case BOPAlgo_COMMON:
2872 pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF);
2875 pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
2878 pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF);
2881 pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
2883 case BOPAlgo_SECTION:
2884 pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF);
2890 iErr = pBuilder->ErrorStatus();
2891 if (!pBuilder->IsDone()) {
2892 theDI << "BOP failed with error status: " << iErr << "\n";
2896 const TopoDS_Shape& aRes = pBuilder->Shape();
2897 DBRep::Set(argv[1], aRes);
2899 BOPCol_MapOfShape aMapArgs, aMapShape;
2900 BOPCol_MapIteratorOfMapOfShape aIt;
2901 Standard_Boolean bIsDeletedHist, bIsDeletedMap;
2902 TopAbs_ShapeEnum aType;
2904 BOPTools::MapShapes(aS1, aMapArgs);
2905 BOPTools::MapShapes(aS2, aMapArgs);
2906 BOPTools::MapShapes(aRes, aMapShape);
2908 aIt.Initialize(aMapArgs);
2909 for (; aIt.More(); aIt.Next()) {
2910 const TopoDS_Shape& aS = aIt.Value();
2911 aType = aS.ShapeType();
2912 if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
2913 aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
2917 bIsDeletedHist = pBuilder->IsDeleted(aS);
2918 bIsDeletedMap = !aMapShape.Contains(aS) &&
2919 (pBuilder->Modified(aS).Extent() == 0);
2921 if (bIsDeletedHist != bIsDeletedMap) {
2922 theDI << "Error. Wrong value of IsDeleted flag.\n";
2927 theDI << "Test complete\n";
2931 //====================================================
2932 // Auxiliary functor class for the command OCC25545;
2933 // it gets access to a vertex with the given index and
2934 // checks that X coordinate of the point is equal to index;
2935 // if it is not so then a data race is reported.
2936 //====================================================
2937 struct OCC25545_Functor
2939 OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
2940 : myShapeVec(&theShapeVec),
2944 void operator()(size_t i) const
2946 if (!myIsRaceDetected) {
2947 const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i));
2948 gp_Pnt aP = BRep_Tool::Pnt (aV);
2949 if (aP.X () != static_cast<double> (i)) {
2950 Standard_Atomic_Increment(&myIsRaceDetected);
2955 const std::vector<TopoDS_Shape>* myShapeVec;
2956 mutable volatile int myIsRaceDetected;
2959 //=======================================================================
2960 //function : OCC25545
2961 //purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation()
2962 //=======================================================================
2964 static Standard_Integer OCC25545 (Draw_Interpretor& di,
2968 // Place vertices in a vector, giving the i-th vertex the
2969 // transformation that translates it on the vector (i,0,0) from the origin.
2971 std::vector<TopoDS_Shape> aShapeVec (n);
2972 std::vector<TopLoc_Location> aLocVec (n);
2973 TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ());
2974 aShapeVec[0] = aShape;
2975 for (size_t i = 1; i < n; ++i) {
2977 aT.SetTranslation (gp_Vec (1, 0, 0));
2978 aLocVec[i] = aLocVec[i - 1] * aT;
2979 aShapeVec[i] = aShape.Moved (aLocVec[i]);
2982 // Evaluator function will access vertices geometry
2984 OCC25545_Functor aFunc(aShapeVec);
2986 //concurrently process
2987 tbb::parallel_for (size_t (0), n, aFunc, tbb::simple_partitioner ());
2988 QVERIFY (!aFunc.myIsRaceDetected);
2992 static Standard_Integer OCC25545 (Draw_Interpretor&,
2996 cout << "Test skipped: command " << argv[0] << " requires TBB library" << endl;
3001 //=======================================================================
3002 //function : OCC25547
3004 //=======================================================================
3005 #include <BRepMesh_GeomTool.hxx>
3006 #include <BRepAdaptor_Curve.hxx>
3007 #include <Geom_TrimmedCurve.hxx>
3008 #include <BRepBuilderAPI_MakeFace.hxx>
3009 #include <BRepAdaptor_HSurface.hxx>
3010 #include <BRepAdaptor_Surface.hxx>
3011 static Standard_Integer OCC25547(
3012 Draw_Interpretor& theDI,
3013 Standard_Integer /*argc*/,
3014 const char ** /*argv*/)
3016 // The general aim of this test is to prevent linkage errors due to missed
3017 // Standard_EXPORT attribute for static methods.
3019 // However, start checking the main functionality at first.
3020 const Standard_Real aFirstP = 0., aLastP = M_PI;
3021 Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
3022 Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
3023 TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf);
3024 BRepAdaptor_Curve aAdaptor(aEdge);
3025 BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5);
3027 if (aGeomTool.NbPoints() == 0)
3029 theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
3033 // Test static methods.
3034 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
3035 BRepAdaptor_Surface aSurf(aFace);
3036 Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf);
3040 if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
3042 theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
3046 gp_XY aRefPnts[4] = {
3047 gp_XY(-10., -10.), gp_XY(10., 10.),
3048 gp_XY(-10., 10.), gp_XY(10., -10.)
3052 Standard_Real aParams[2];
3053 BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin(
3054 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3055 aIntPnt.ChangeCoord(), aParams);
3057 Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
3058 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3060 theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
3064 aIntFlag = BRepMesh_GeomTool::IntSegSeg(
3065 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3066 Standard_False, Standard_False, aIntPnt);
3068 aDiff = aIntPnt.Distance(gp::Origin2d());
3069 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3071 theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
3076 theDI << "Test complete\n";
3080 static Standard_Integer OCC26139 (Draw_Interpretor& theDI,
3081 Standard_Integer argc,
3085 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
3088 theDI << "Use 'vinit' command before " << argv[0] << "\n";
3092 Standard_Integer aBoxGridSize = 100;
3093 Standard_Integer aCompGridSize = 3;
3094 Standard_Real aBoxSize = 5.0;
3098 for (Standard_Integer anArgIdx = 1; anArgIdx < argc; ++anArgIdx)
3100 TCollection_AsciiString anArg (argv[anArgIdx]);
3102 if (anArg == "-boxgrid")
3104 aBoxGridSize = Draw::Atoi (argv[++anArgIdx]);
3106 else if (anArg == "-compgrid")
3108 aCompGridSize = Draw::Atoi (argv[++anArgIdx]);
3110 else if (anArg == "-boxsize")
3112 aBoxSize = Draw::Atof (argv[++anArgIdx]);
3117 NCollection_List<Handle(AIS_Shape)> aCompounds;
3118 for (Standard_Integer aCompGridX = 0; aCompGridX < aCompGridSize; ++aCompGridX)
3120 for (Standard_Integer aCompGridY = 0; aCompGridY < aCompGridSize; ++aCompGridY)
3122 BRep_Builder aBuilder;
3123 TopoDS_Compound aComp;
3124 aBuilder.MakeCompound (aComp);
3125 for (Standard_Integer aBoxGridX = 0; aBoxGridX < aBoxGridSize; ++aBoxGridX)
3127 for (Standard_Integer aBoxGridY = 0; aBoxGridY < aBoxGridSize; ++aBoxGridY)
3129 BRepPrimAPI_MakeBox aBox (gp_Pnt (aBoxGridX * aBoxSize, aBoxGridY * aBoxSize, 0.0),
3130 aBoxSize, aBoxSize, aBoxSize);
3131 aBuilder.Add (aComp, aBox.Shape());
3135 aTrsf.SetTranslation (gp_Vec (aBoxGridSize * aBoxSize * aCompGridX,
3136 aBoxGridSize * aBoxSize * aCompGridY,
3138 TopLoc_Location aLoc (aTrsf);
3139 aComp.Located (aLoc);
3140 aCompounds.Append (new AIS_Shape (aComp));
3145 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3148 aCtx->Display (aCompIter.Value(), Standard_False);
3150 theDI << "Display time: " << aTimer.ElapsedTime() << "\n";
3156 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3158 aCtx->Remove (aCompIter.Value(), Standard_False);
3161 theDI << "Remove time: " << aTimer.ElapsedTime() << "\n";
3166 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
3167 #include <TColStd_DataMapOfIntegerInteger.hxx>
3169 #include <ShapeFix_Wire.hxx>
3170 #include <ShapeExtend_Status.hxx>
3172 #define EXCEPTION ...
3174 #define EXCEPTION Standard_Failure
3177 static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)& theFix,
3178 const Standard_Boolean theIs3d)
3180 for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++)
3182 Standard_Boolean isFound;
3184 isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i );
3186 isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i );
3187 if (isFound) return ShapeExtend_Status(i);
3189 return ShapeExtend_OK;
3192 //===================
3193 //function : OCC24881
3195 //===================
3196 static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
3199 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
3202 // cout <<"FileName1: " << argv[1] <<endl;
3204 TopoDS_Shape aShape = DBRep::Get (a[1]);
3207 Handle(ShapeFix_Wire) aWireFix = new ShapeFix_Wire;
3209 // map FixStatus - NbSuchStatuses
3210 TColStd_DataMapOfIntegerInteger aStatusNbDMap;
3211 Standard_Integer nbFixed=0, nbOk=0;
3214 ShapeExtend_Status aStatus=ShapeExtend_OK;
3216 TopExp_Explorer aFaceExplorer(aShape, TopAbs_FACE);
3217 for (; aFaceExplorer.More(); aFaceExplorer.Next())
3219 TopoDS_Shape aFace = aFaceExplorer.Current();
3221 TopoDS_Iterator aWireItr(aFace);
3222 for (; aWireItr.More(); aWireItr.Next() )
3224 Standard_Boolean wasOk = Standard_False;
3225 TopoDS_Wire aSrcWire = TopoDS::Wire(aWireItr.Value());
3227 aWireFix->Load (aSrcWire);
3228 aWireFix->SetFace (TopoDS::Face(aFace));
3229 aWireFix->FixReorder(); //correct order is a prerequisite
3231 if (!aWireFix->FixGaps3d())
3234 aStatus = getStatusGap(aWireFix, Standard_True);
3235 if (aStatus == ShapeExtend_OK)
3236 wasOk = Standard_True;
3239 // keep 3d fail status
3240 if (aStatusNbDMap.IsBound (aStatus))
3241 aStatusNbDMap(aStatus)++;
3243 aStatusNbDMap.Bind(aStatus,1);
3249 if (aWireFix->FixGaps2d())
3253 aStatus = getStatusGap(aWireFix, Standard_False);
3254 if (aStatus == ShapeExtend_OK)
3266 // keep 2d fail status
3267 Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL;
3268 if (aStatusNbDMap.IsBound (aStatus2d))
3269 aStatusNbDMap(aStatus2d)++;
3271 aStatusNbDMap.Bind(aStatus2d,1);
3278 } catch (EXCEPTION) {
3279 di << "Exception is raised = " <<aStatus << "\n";
3283 // report what is done
3287 di <<"Fix_FillGaps_Fixed: nbFixed = "<<nbFixed <<"\n";
3292 di << "Fix_FillGaps_NothingToDo\n";
3295 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aStatusItr(aStatusNbDMap);
3296 for (; aStatusItr.More(); aStatusItr.Next())
3298 switch ((ShapeExtend_Status) aStatusItr.Key())
3301 case ShapeExtend_FAIL1:
3302 di <<"Fix_FillGaps_3dNoCurveFail, nb failed = ";
3304 case ShapeExtend_FAIL2:
3305 di <<"Fix_FillGaps_3dSomeGapsFail, nb failed = ";
3309 switch ((ShapeExtend_Status) (aStatusItr.Key() - ShapeExtend_FAIL))
3311 case ShapeExtend_FAIL1:
3312 di <<"Fix_FillGaps_2dNoPCurveFail, nb failed = ";
3314 case ShapeExtend_FAIL2:
3315 di <<"Fix_FillGaps_2dSomeGapsFail, nb failed = ";
3321 di <<aStatusItr.Value()<< "\n";
3323 di << ("__________________________________") <<"\n";
3328 //=======================================================================
3329 //function : OCC26172
3331 //=======================================================================
3332 static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3336 std::cerr << "Error: wrong number of arguments! See usage:\n";
3337 theDI.PrintHelp (theArgVec[0]);
3341 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
3342 if(anAISContext.IsNull())
3344 std::cerr << "Error: no active view. Please call vinit.\n";
3348 gp_Pnt aStart (100, 100, 100);
3349 gp_Pnt anEnd (300, 400, 600);
3350 BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
3351 TopoDS_Edge anEdge = anEdgeBuilder.Edge();
3352 Handle(AIS_Shape) aTestAISShape = new AIS_Shape (anEdge);
3353 anAISContext->Display (aTestAISShape);
3355 // 2. activate it in selection modes
3356 TColStd_SequenceOfInteger aModes;
3357 aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX));
3358 aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_EDGE));
3360 anAISContext->OpenLocalContext();
3361 anAISContext->Deactivate (aTestAISShape);
3362 anAISContext->Load (aTestAISShape, -1, true);
3363 for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt)
3365 anAISContext->Activate (aTestAISShape, aModes (anIt));
3368 // select entities in vertex selection mode
3369 Handle(SelectMgr_Selection) aSelection = aTestAISShape->Selection (aModes (1));
3370 for (aSelection->Init(); aSelection->More(); aSelection->Next())
3372 Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
3373 if (anEntity.IsNull())
3378 Handle(SelectMgr_EntityOwner) anOwner =
3379 Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
3381 if (anOwner.IsNull())
3386 anAISContext->LocalContext()->AddOrRemoveSelected (anOwner);
3389 // select entities in edge selection mode
3390 aSelection = aTestAISShape->Selection (aModes (2));
3391 for (aSelection->Init(); aSelection->More(); aSelection->Next())
3393 Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
3394 if (anEntity.IsNull())
3399 Handle(SelectMgr_EntityOwner) anOwner =
3400 Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
3402 if (anOwner.IsNull())
3407 anAISContext->LocalContext()->AddOrRemoveSelected (anOwner);
3410 // deactivate vertex mode and check clearing of outdated selection
3411 anAISContext->Deactivate (aTestAISShape, aModes (1));
3412 anAISContext->LocalContext()->ClearOutdatedSelection (aTestAISShape, true);
3417 //=======================================================================
3418 //function : OCC26284
3420 //=======================================================================
3421 static Standard_Integer OCC26284 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3425 std::cerr << "Error: wrong number of arguments! See usage:\n";
3426 theDI.PrintHelp (theArgVec[0]);
3430 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
3431 if (anAISContext.IsNull())
3433 std::cerr << "Error: no active view. Please call vinit.\n";
3437 BRepPrimAPI_MakeSphere aSphereBuilder (gp_Pnt (0.0, 0.0, 0.0), 1.0);
3438 Handle(AIS_Shape) aSphere = new AIS_Shape (aSphereBuilder.Shape());
3439 anAISContext->Display (aSphere);
3440 for (Standard_Integer aChildIdx = 0; aChildIdx < 5; ++aChildIdx)
3442 BRepPrimAPI_MakeSphere aBuilder (gp_Pnt (1.0 + aChildIdx, 1.0 + aChildIdx, 1.0 + aChildIdx), 1.0);
3443 Handle(AIS_Shape) aChild = new AIS_Shape (aBuilder.Shape());
3444 aSphere->AddChild (aChild);
3445 anAISContext->Display (aChild);
3448 anAISContext->RecomputeSelectionOnly (aSphere);
3453 #include <IntTools_Context.hxx>
3454 #include <GeomAPI_ProjectPointOnSurf.hxx>
3456 //=======================================================================
3457 //function : xprojponf
3459 //=======================================================================
3460 Standard_Integer xprojponf (Draw_Interpretor& di,
3465 di<<" use xprojponf p f \n";
3472 Handle(IntTools_Context) aCtx;
3474 DrawTrSurf::GetPoint(a[1], aP);
3475 aS=DBRep::Get(a[2]);
3478 di<<" null shape is not allowed\n";
3482 if (aS.ShapeType()!=TopAbs_FACE) {
3483 di << a[2] << " not a face\n";
3487 aCtx=new IntTools_Context;
3489 aF=TopoDS::Face(aS);
3490 GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF);
3493 if (!aPPS.IsDone()) {
3494 di<<" projection failed\n";
3498 aPS=aPPS.NearestPoint();
3499 di<< " point px " << aPS.X() << " " << aPS.Y() << " " << aPS.Z() << "\n";
3504 //=======================================================================
3505 //function : OCC25547
3507 //=======================================================================
3508 #include <BRepMesh_CircleTool.hxx>
3509 #include <SelectMgr_EntityOwner.hxx>
3511 static Standard_Boolean inspect_point(const gp_XY& thePoint,
3512 const gp_XY& theCenter,
3513 const Standard_Real theRadius)
3515 static Standard_Real aPrecision = Precision::PConfusion();
3516 static Standard_Real aSqPrecision = aPrecision * aPrecision;
3517 const gp_XY aDistVec = thePoint - theCenter;
3518 if (aDistVec.SquareModulus() - (theRadius * theRadius) < aSqPrecision)
3519 return Standard_True;
3521 return Standard_False;
3524 static Standard_Integer OCC24923(
3525 Draw_Interpretor& theDI,
3526 Standard_Integer argc,
3529 srand(static_cast<unsigned int>(time(NULL)));
3531 const Standard_Real aMaxDeviation = (argc > 1) ? Draw::Atof(argv[1]) : 0.01;
3532 const Standard_Integer aPointsNb = 10000000;
3533 const Standard_Real aMinAngle = 5 * M_PI / 180.;
3534 static Standard_Real aSqPrecision = Precision::PConfusion() * Precision::PConfusion();
3536 Standard_Integer aFailedNb = 0;
3537 for (Standard_Integer i = 0; i < aPointsNb; ++i)
3540 for (Standard_Integer j = 0; j < 3; ++j)
3541 p[j].SetCoord(((Standard_Real)rand())/RAND_MAX, ((Standard_Real)rand())/RAND_MAX);
3543 // Check that points do not compose degenerated triangle.
3544 gp_XY aVec1 = p[1] - p[0];
3545 gp_XY aVec2 = p[2] - p[0];
3546 if (aVec1.SquareModulus() > aSqPrecision &&
3547 aVec2.SquareModulus() > aSqPrecision &&
3548 (aVec1 ^ aVec2) > aMinAngle)
3551 Standard_Real aRadius;
3552 if (BRepMesh_CircleTool::MakeCircle(p[0], p[1], p[2], aCenter, aRadius))
3554 if (!inspect_point(p[0], aCenter, aRadius) ||
3555 !inspect_point(p[1], aCenter, aRadius) ||
3556 !inspect_point(p[2], aCenter, aRadius))
3558 /* theDI << "Missed: " <<
3559 "p1=(" << p1.X() << ", " << p1.Y() << "), " <<
3560 "p2=(" << p2.X() << ", " << p2.Y() << "), " <<
3561 "p3=(" << p3.X() << ", " << p3.Y() << "), " <<
3562 "c=(" << aCenter.X() << ", " << aCenter.Y() << "), " <<
3563 "r=" << aRadius << "\n";*/
3572 // Ensure that aPointsNb suitable for tests are generated
3576 const Standard_Real aDeviation =
3577 1. - (Standard_Real)(aPointsNb - aFailedNb) / (Standard_Real)aPointsNb;
3579 theDI << "Number of failed cases: " << aFailedNb << " (Total " << aPointsNb << ")\n";
3580 if (aDeviation > aMaxDeviation)
3582 theDI << "Failed. Number of incorrect results is too huge: " <<
3583 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
3587 theDI << "Deviation of incorrect results is: " <<
3588 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
3589 theDI << "Test completed\n";
3593 #include <TColGeom_Array1OfBSplineCurve.hxx>
3594 #include <TColStd_Array1OfReal.hxx>
3595 #include <TColGeom_HArray1OfBSplineCurve.hxx>
3596 #include <GeomConvert.hxx>
3598 //=======================================================================
3599 //function : OCC26446
3601 //=======================================================================
3602 Standard_Integer OCC26446 (Draw_Interpretor& di,
3607 di << "Usage: OCC26446 r c1 c2\n";
3611 Handle(Geom_BSplineCurve) aCurve1 =
3612 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[2]));
3613 Handle(Geom_BSplineCurve) aCurve2 =
3614 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[3]));
3616 if (aCurve1.IsNull()) {
3617 di << a[2] << " is not a BSpline curve\n";
3621 if (aCurve2.IsNull()) {
3622 di << a[3] << " is not a BSpline curve\n";
3626 TColGeom_Array1OfBSplineCurve aCurves (0, 1);
3627 TColStd_Array1OfReal aTolerances (0, 0);
3628 Standard_Real aTolConf = 1.e-3;
3629 Standard_Real aTolClosure = Precision::Confusion();
3630 Handle(TColGeom_HArray1OfBSplineCurve) aConcatCurves;
3631 Handle(TColStd_HArray1OfInteger) anIndices;
3633 aCurves.SetValue(0, aCurve1);
3634 aCurves.SetValue(1, aCurve2);
3635 aTolerances.SetValue(0, aTolConf);
3637 GeomConvert::ConcatC1(aCurves,
3644 Handle(Geom_BSplineCurve) aResult =
3645 aConcatCurves->Value(aConcatCurves->Lower());
3647 DrawTrSurf::Set(a[1], aResult);
3651 static Standard_Integer OCC26448 (Draw_Interpretor& theDI, Standard_Integer, const char **)
3653 TColStd_SequenceOfReal aSeq1, aSeq2;
3655 aSeq1.Prepend (aSeq2);
3656 theDI << "TCollection: 11 -> " << aSeq1.First() << "\n";
3658 NCollection_Sequence<Standard_Real> nSeq1, nSeq2;
3660 nSeq1.Prepend (nSeq2);
3661 theDI << "NCollection: 11 -> " << nSeq1.First() << "\n";
3667 //=======================================================================
3668 //function : OCC26407
3670 //=======================================================================
3671 #include <BRepBuilderAPI_MakeWire.hxx>
3672 #include <BRepBuilderAPI_MakeEdge.hxx>
3673 #include <BRepMesh_IncrementalMesh.hxx>
3674 #include <TCollection_AsciiString.hxx>
3675 static Standard_Integer OCC26407 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3679 std::cerr << "Error: wrong number of arguments! See usage:\n";
3680 theDI.PrintHelp (theArgVec[0]);
3684 // Construct vertices.
3685 std::vector<TopoDS_Vertex> wire_vertices;
3686 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.90000000000009094947, 40.6758179230516248026106, 88.5)));
3687 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(807.824182076948432040808, 260.599999999999965893949, 88.5)));
3688 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(644.174182076948454778176, 424.249999999999943156581, 88.5000000000000142108547)));
3689 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(629.978025792618950617907, 424.25, 88.5)));
3690 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(793.628025792618700506864, 260.599999999999852207111, 88.5)));
3691 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.900000000000204636308, 54.8719742073813492311274, 88.5)));
3692 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(218.521974207381418864315, 424.250000000000056843419, 88.5)));
3693 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(204.325817923051886282337, 424.249999999999943156581, 88.5)));
3696 BRepBuilderAPI_MakeWire wire_builder;
3697 for (size_t i = 0; i < wire_vertices.size(); i++)
3699 const TopoDS_Vertex &v = wire_vertices[i];
3700 const TopoDS_Vertex &w = wire_vertices[(i+1) % wire_vertices.size()];
3702 wire_builder.Add(BRepBuilderAPI_MakeEdge(v, w));
3705 // Create face and triangulate it.
3707 gp_Pnt v0 = BRep_Tool::Pnt(wire_vertices[0]);
3708 gp_Pnt v1 = BRep_Tool::Pnt(wire_vertices[1]);
3709 gp_Pnt v2 = BRep_Tool::Pnt(wire_vertices[wire_vertices.size() - 1]);
3711 gp_Vec face_normal = gp_Vec(v0, v1).Crossed(gp_Vec(v0, v2));
3713 TopoDS_Face face = BRepBuilderAPI_MakeFace(gp_Pln(v0, face_normal), wire_builder);
3714 BRepMesh_IncrementalMesh m(face, 1e-7);
3716 if (m.GetStatusFlags() != 0)
3718 theDI << "Failed. Status for face constructed from vertices: " << m.GetStatusFlags() << "\n";
3721 DBRep::Set(theArgVec[1], face);
3723 sprintf(buf, "isos %s 0", theArgVec[1]);
3726 sprintf(buf, "triangles %s", theArgVec[1]);
3729 theDI.Eval("smallview; fit");
3731 theDI << "Test completed\n";
3735 //=======================================================================
3736 //function : OCC26485
3738 //=======================================================================
3740 static Standard_Integer OCC26485 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3744 std::cerr << "Error: wrong number of arguments! See usage:\n";
3745 theDI.PrintHelp (theArgVec[0]);
3749 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
3750 if (aShape.IsNull())
3752 theDI << "Failed. Null shape\n";
3756 Standard_Boolean isFailed = Standard_False;
3757 TopExp_Explorer aExplorer(aShape, TopAbs_FACE);
3758 for (; aExplorer.More(); aExplorer.Next())
3760 const TopoDS_Face& aFace = TopoDS::Face( aExplorer.Current() );
3761 TopLoc_Location L = TopLoc_Location();
3762 const Handle(Poly_Triangulation)& aT = BRep_Tool::Triangulation( aFace , L );
3767 Poly::ComputeNormals(aT);
3768 const TColgp_Array1OfPnt& aVertices = aT->Nodes();
3769 const TShort_Array1OfShortReal& aNormals = aT->Normals();
3771 // Number of nodes in the triangulation
3772 int aVertexNb = aT->Nodes().Length();
3773 if (aVertexNb*3 != aNormals.Length())
3775 theDI << "Failed. Different number of normals vs. vertices\n";
3779 // Get each vertex index, checking common vertexes between shapes
3780 for( int i=0; i < aVertexNb; i++ )
3782 gp_Pnt aPoint = aVertices.Value( i+1 );
3783 gp_Vec aNormal = gp_Vec(
3784 aNormals.Value( i*3 + 1 ),
3785 aNormals.Value( i*3 + 2 ),
3786 aNormals.Value( i*3 + 3 ) );
3788 if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
3791 sprintf(buf, "fail_%d", i+1);
3792 theDI << "Failed. Point " << buf << ": "
3793 << aPoint.X() << " "
3794 << aPoint.Y() << " "
3795 << aPoint.Z() << "\n";
3797 DrawTrSurf::Set (buf, aPoint);
3802 theDI << (isFailed ? "Test failed" : "Test completed") << "\n";
3806 //=======================================================================
3807 //function : OCC26553
3809 //=======================================================================
3810 #include <BRepBuilderAPI_MakeWire.hxx>
3812 static Standard_Integer OCC26553 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
3816 theDI << "Error: path to file with shell is missing\n";
3820 BRep_Builder aBuilder;
3821 TopoDS_Shape aShell;
3822 BRepTools::Read(aShell, theArgv[1], aBuilder);
3824 if (aShell.IsNull())
3826 theDI << "Error: shell not loaded\n";
3830 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge (gp_Pnt (0, 0, 0), gp_Pnt (0, 0, 10));
3831 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
3833 BRepOffsetAPI_MakePipe aPipeBuilder(aPipeWire, aShell);
3834 if (!aPipeBuilder.IsDone())
3836 theDI << "Error: failed to create pipe\n";
3840 for (TopExp_Explorer aShapeExplorer(aShell, TopAbs_EDGE); aShapeExplorer.More(); aShapeExplorer.Next ()) {
3841 const TopoDS_Shape& aGeneratedShape = aPipeBuilder.Generated(aPipeEdge, aShapeExplorer.Current());
3842 if (aGeneratedShape.IsNull())
3844 theDI << "Error: null shape\n";
3849 theDI << "History returned successfully\n";
3853 //=======================================================================
3854 //function : OCC26195
3856 //=======================================================================
3857 #include <SelectMgr_SelectingVolumeManager.hxx>
3858 #include <BRepBuilderAPI_MakePolygon.hxx>
3859 #include <Geom_CartesianPoint.hxx>
3860 #include <AIS_Line.hxx>
3861 #include <Aspect_Window.hxx>
3862 static Standard_Integer OCC26195 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3866 std::cerr << "Error: wrong number of arguments! See usage:\n";
3867 theDI.PrintHelp (theArgVec[0]);
3871 if (ViewerTest::GetAISContext().IsNull())
3873 std::cerr << "Error: No opened context!\n";
3877 gp_Pnt2d aPxPnt1, aPxPnt2;
3878 aPxPnt1.SetX (Draw::Atof (theArgVec[1]));
3879 aPxPnt1.SetY (Draw::Atof (theArgVec[2]));
3882 aPxPnt2.SetX (Draw::Atof (theArgVec[3]));
3883 aPxPnt2.SetY (Draw::Atof (theArgVec[4]));
3885 Standard_Boolean toPrint = Standard_False;
3886 if (theArgNb % 2 == 0)
3888 toPrint = Draw::Atoi (theArgVec[theArgNb - 1]);
3891 SelectMgr_SelectingVolumeManager* aMgr = new SelectMgr_SelectingVolumeManager();
3892 aMgr->SetActiveSelectionType (theArgNb > 4 ?
3893 SelectMgr_SelectingVolumeManager::Box : SelectMgr_SelectingVolumeManager::Point);
3894 aMgr->SetCamera (ViewerTest::CurrentView()->Camera());
3895 aMgr->SetPixelTolerance (ViewerTest::GetAISContext()->PixelTolerance());
3896 Standard_Integer aWidth, aHeight;
3897 ViewerTest::CurrentView()->View()->Window()->Size (aWidth, aHeight);
3898 aMgr->SetWindowSize (aWidth, aHeight);
3901 aMgr->BuildSelectingVolume (aPxPnt1, aPxPnt2);
3905 aMgr->BuildSelectingVolume (aPxPnt1);
3907 const gp_Pnt* aVerts = aMgr->GetVertices();
3908 gp_Pnt aNearPnt = aMgr->GetNearPnt();
3909 gp_Pnt aFarPnt = aMgr->GetFarPnt();
3910 BRepBuilderAPI_MakePolygon aWireBldrs[4];
3912 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
3913 aWireBldrs[0].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
3914 aWireBldrs[0].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
3915 aWireBldrs[0].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
3916 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
3918 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
3919 aWireBldrs[1].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
3920 aWireBldrs[1].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
3921 aWireBldrs[1].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
3922 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
3924 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
3925 aWireBldrs[2].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
3926 aWireBldrs[2].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
3927 aWireBldrs[2].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
3928 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
3930 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
3931 aWireBldrs[3].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
3932 aWireBldrs[3].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
3933 aWireBldrs[3].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
3934 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
3936 TopoDS_Compound aComp;
3937 BRep_Builder aCompBuilder;
3938 aCompBuilder.MakeCompound (aComp);
3939 for (Standard_Integer aWireIdx = 0; aWireIdx < 4; ++aWireIdx)
3941 aCompBuilder.Add (aComp, aWireBldrs[aWireIdx].Shape());
3943 DBRep::Set ("c", aComp);
3945 Handle(AIS_InteractiveObject) aCmp = new AIS_Shape (aComp);
3946 aCmp->SetColor (Quantity_NOC_GREEN);
3947 ViewerTest::Display ("c", aCmp, Standard_True, Standard_True);
3949 Handle(Geom_CartesianPoint) aPnt1 = new Geom_CartesianPoint (aNearPnt);
3950 Handle(Geom_CartesianPoint) aPnt2 = new Geom_CartesianPoint (aFarPnt);
3952 Handle(AIS_Line) aLine = new AIS_Line (aPnt1, aPnt2);
3953 ViewerTest::Display ("l", aLine, Standard_True, Standard_True);
3957 theDI << "Near: " << aNearPnt.X() << " " << aNearPnt.Y() << " " << aNearPnt.Z() << "\n";
3958 theDI << "Far: " << aFarPnt.X() << " " << aFarPnt.Y() << " " << aFarPnt.Z() << "\n";
3964 //=======================================================================
3965 //function : OCC26462
3967 //=======================================================================
3968 static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
3970 if (ViewerTest::GetAISContext().IsNull())
3972 std::cerr << "Error: No opened context!\n";
3976 BRepPrimAPI_MakeBox aBuilder1 (gp_Pnt (10.0, 10.0, 0.0), 10.0, 10.0, 10.0);
3977 BRepPrimAPI_MakeBox aBuilder2 (10.0, 10.0, 10.0);
3978 Handle(AIS_InteractiveObject) aBox1 = new AIS_Shape (aBuilder1.Shape());
3979 Handle(AIS_InteractiveObject) aBox2 = new AIS_Shape (aBuilder2.Shape());
3981 const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
3982 aCtx->OpenLocalContext();
3983 aCtx->Display (aBox1, 0, 2);
3984 aCtx->Display (aBox2, 0, 2);
3985 ViewerTest::CurrentView()->FitAll();
3986 aCtx->SetWidth (aBox1, 3);
3987 aCtx->SetWidth (aBox2, 3);
3989 aCtx->MoveTo (305, 322, ViewerTest::CurrentView());
3990 aCtx->ShiftSelect();
3991 aCtx->MoveTo (103, 322, ViewerTest::CurrentView());
3992 aCtx->ShiftSelect();
3993 if (aCtx->NbSelected() != 0)
3995 theDI << "ERROR: no boxes must be selected!\n";
3999 aCtx->SetSelectionSensitivity (aBox1, 2, 5);
4001 aCtx->MoveTo (305, 322, ViewerTest::CurrentView());
4002 aCtx->ShiftSelect();
4003 if (aCtx->NbSelected() != 1)
4005 theDI << "ERROR: b1 was not selected\n";
4008 aCtx->MoveTo (103, 322, ViewerTest::CurrentView());
4009 aCtx->ShiftSelect();
4010 if (aCtx->NbSelected() != 1)
4012 theDI << "ERROR: b2 is selected after b1's tolerance increased\n";
4020 #include <BRepBuilderAPI_GTransform.hxx>
4021 static Standard_Integer OCC26313(Draw_Interpretor& di,Standard_Integer n,const char** a)
4023 if (n <= 1) return 1;
4028 gp_Mat rot( 1.0, 0.0, 0.0,
4032 GT.SetVectorialPart(rot);
4033 BRepBuilderAPI_GTransform gtrf(GT);
4035 TopoDS_Shape aSrcShape = DBRep::Get(a[2]);
4036 if (aSrcShape.IsNull()) {
4037 di << a[2] << " is not a valid shape\n";
4042 gtrf.Perform(aSrcShape);
4047 DBRep::Set(a[1], gtrf.ModifiedShape(aSrcShape));
4049 catch(Standard_Failure)
4051 di << "Error: Exception is thrown\n";
4056 di << "Error: Result is not done\n";
4063 //=======================================================================
4064 //function : OCC26525
4065 //purpose : check number of intersection points
4066 //=======================================================================
4067 #include <BRepAdaptor_Curve.hxx>
4068 #include <BRepAdaptor_Surface.hxx>
4069 #include <BRepAdaptor_HCurve.hxx>
4070 #include <BRepAdaptor_HSurface.hxx>
4071 #include <IntCurveSurface_HInter.hxx>
4072 Standard_Integer OCC26525 (Draw_Interpretor& di,
4076 TopoDS_Shape aS1, aS2;
4082 di << " use OCC26525 r edge face \n";
4086 aS1 = DBRep::Get(a[2]);
4087 aS2 = DBRep::Get(a[3]);
4089 if (aS1.IsNull() || aS2.IsNull())
4091 di << " Null shapes are not allowed \n";
4094 if (aS1.ShapeType()!=TopAbs_EDGE)
4096 di << " Shape" << a[2] << " should be of type EDGE\n";
4099 if (aS2.ShapeType()!=TopAbs_FACE)
4101 di << " Shape" << a[3] << " should be of type FACE\n";
4105 aE=TopoDS::Edge(aS1);
4106 aF=TopoDS::Face(aS2);
4109 Standard_Boolean bIsDone;
4110 Standard_Integer i, aNbPoints;
4111 Standard_Real aU, aV, aT;
4113 BRepAdaptor_Curve aBAC;
4114 BRepAdaptor_Surface aBAS;
4115 IntCurveSurface_TransitionOnCurve aTC;
4116 IntCurveSurface_HInter aHInter;
4118 aBAC.Initialize(aE);
4119 aBAS.Initialize(aF);
4121 Handle(BRepAdaptor_HCurve) aHBAC=new BRepAdaptor_HCurve(aBAC);
4122 Handle(BRepAdaptor_HSurface) aHBAS = new BRepAdaptor_HSurface(aBAS);
4124 aHInter.Perform(aHBAC, aHBAS);
4125 bIsDone=aHInter.IsDone();
4128 di << " intersection is not done\n";
4132 aNbPoints=aHInter.NbPoints();
4133 sprintf (buf, " Number of intersection points found: %d", aNbPoints);
4135 for (i=1; i<=aNbPoints; ++i)
4137 const IntCurveSurface_IntersectionPoint& aIP=aHInter.Point(i);
4138 aIP.Values(aP, aU, aV, aT, aTC);
4140 sprintf (buf, "point %s_%d %lg %lg %lg ", a[1], i, aP.X(), aP.Y(), aP.Z());
4147 //=======================================================================
4148 //function : OCC24537
4149 //purpose : Puts inverted numbers (in the sense of little/big endian inversion)
4150 // from predefined arrays.
4151 //=======================================================================
4152 #include <FSD_BinaryFile.hxx>
4155 inline const unsigned char* SizeRef ();
4158 inline const unsigned char* SizeRef <8> ()
4160 static const unsigned char aSizeRef[] = {
4161 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4162 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
4163 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
4164 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,
4165 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,
4166 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,
4167 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
4168 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
4169 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,
4170 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4175 inline const unsigned char* SizeRef <4> ()
4177 static const unsigned char aSizeRef[] = {
4178 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4179 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4180 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4181 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4182 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4186 static Standard_Integer OCC24537(
4187 Draw_Interpretor& theDI,
4188 Standard_Integer argc,
4197 cout << "cannot create file " << argv[1] << endl;
4201 Standard_Boolean isErr = Standard_False;
4203 const unsigned char anIntRef[] = {
4204 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4205 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4206 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4207 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4208 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4209 Standard_Integer anIntArr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
4212 for(int i = 0; i < 10; ++i)
4214 Standard_Integer anInv = FSD_BinaryFile::InverseInt(anIntArr[i]);
4215 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4220 Standard_Integer anInv[10];
4221 for(int i = 0; i < 10; ++i)
4222 anInv[i] = FSD_BinaryFile::InverseInt(anIntArr[i]);
4223 if (memcmp(anInv, anIntRef, sizeof(anIntRef)) != 0)
4225 theDI << "Error: incorrect conversion of an integer value\n";
4226 isErr = Standard_True;
4230 // 1a. Random InverseInt
4231 const unsigned char aRndIntRef[] = {
4232 0xFF,0xC2,0xF7,0x00,0xFF,0xFF,0xFB,0x2E,
4233 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4234 0x00,0x00,0x04,0xD2,0x00,0x00,0x04,0xD3,
4235 0xFF,0xFF,0xFD,0x1E,0xFF,0xFF,0xFF,0xFB,
4236 0x00,0x00,0x03,0x8D,0x00,0x3D,0x09,0x00};
4237 Standard_Integer aRndIntArr[] = {-4000000, -1234, 0, 1, 1234, 1235, -738, -5, 909, 4000000};
4240 for(int i = 0; i < 10; ++i)
4242 Standard_Integer anInv = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4243 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4248 Standard_Integer anInv[10];
4249 for(int i = 0; i < 10; ++i)
4250 anInv[i] = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4251 if (memcmp(anInv, aRndIntRef, sizeof(aRndIntRef)) != 0)
4253 theDI << "Error: incorrect conversion of a dispersed integer value\n";
4254 isErr = Standard_True;
4259 const unsigned char aRealRef[] = {
4260 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4261 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4262 0x40,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
4263 0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
4264 0x40,0x14,0x00,0x00,0x00,0x00,0x00,0x00,
4265 0x40,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
4266 0x40,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
4267 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4268 0x40,0x22,0x00,0x00,0x00,0x00,0x00,0x00,
4269 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4270 const Standard_Real aRealArr[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0};
4273 for(int i = 0; i < 10; ++i)
4275 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRealArr[i]);
4276 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4281 Standard_Real anInv[10];
4282 for(int i = 0; i < 10; ++i)
4283 anInv[i] = FSD_BinaryFile::InverseReal(aRealArr[i]);
4284 if (memcmp(anInv, aRealRef, sizeof(aRealRef)) != 0)
4286 theDI << "Error: incorrect conversion of a real value\n";
4287 isErr = Standard_True;
4291 // 2a. Random InverseReal
4292 const unsigned char aRndRealRef[] = {
4293 0xFE,0x37,0xE4,0x3C,0x88,0x00,0x75,0x9C,
4294 0xBE,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4295 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4296 0x3E,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4297 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4298 0x40,0x09,0x21,0xDA,0x45,0x5B,0x53,0xE4,
4299 0x54,0xB2,0x49,0xAD,0x25,0x94,0xC3,0x7D,
4300 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4301 0xC0,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD,
4302 0x40,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD};
4303 const Standard_Real aRndRealArr[] = {-1e300, -1.e-9, 0., 1.e-9, 1., 3.1415296, 1.e100, 8.0, -9.9, 9.9};
4306 for(int i = 0; i < 10; ++i)
4308 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4309 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4314 Standard_Real anInv[10];
4315 for(int i = 0; i < 10; ++i)
4316 anInv[i] = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4317 if (memcmp(anInv, aRndRealRef, sizeof(aRndRealRef)) != 0)
4319 theDI << "Error: incorrect conversion of a dispersed real value\n";
4320 isErr = Standard_True;
4324 // 3. InverseShortReal
4325 const unsigned char aShortRealRef[] = {
4326 0x3F,0x80,0x00,0x00,0x40,0x00,0x00,0x00,
4327 0x40,0x40,0x00,0x00,0x40,0x80,0x00,0x00,
4328 0x40,0xA0,0x00,0x00,0x40,0xC0,0x00,0x00,
4329 0x40,0xE0,0x00,0x00,0x41,0x00,0x00,0x00,
4330 0x41,0x10,0x00,0x00,0x00,0x00,0x00,0x00};
4331 const Standard_ShortReal aShortRealArr[] = {
4332 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 0.0f};
4335 for(int i = 0; i < 10; ++i)
4337 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4338 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4343 Standard_ShortReal anInv[10];
4344 for(int i = 0; i < 10; ++i)
4345 anInv[i] = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4346 if (memcmp(anInv, aShortRealRef, sizeof(aShortRealRef)) != 0)
4348 theDI << "Error: incorrect conversion of a short real value\n";
4349 isErr = Standard_True;
4353 // 3a. Random InverseShortReal
4354 const unsigned char aRndShortRealRef[] = {
4355 0xB0,0x89,0x70,0x5F,0x00,0x00,0x00,0x00,
4356 0x30,0x89,0x70,0x5F,0x3F,0x80,0x00,0x00,
4357 0x40,0x49,0x0E,0x56,0xC0,0xD6,0x66,0x66,
4358 0x40,0xD6,0x66,0x66,0x42,0xC5,0xCC,0xCD,
4359 0xC2,0xC7,0xCC,0xCD,0x42,0xC7,0xCC,0xCD};
4360 const Standard_ShortReal aRndShortRealArr[] = {
4361 -1.e-9f, 0.f, 1.e-9f, 1.f, 3.1415f, -6.7f, 6.7f, 98.9f, -99.9f, 99.9f};
4364 for(int i = 0; i < 10; ++i)
4366 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4367 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4372 Standard_ShortReal anInv[10];
4373 for(int i = 0; i < 10; ++i)
4374 anInv[i] = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4375 if (memcmp(anInv, aRndShortRealRef, sizeof(aRndShortRealRef)) != 0)
4377 theDI << "Error: incorrect conversion of a dispersed short real value\n";
4378 isErr = Standard_True;
4383 const Standard_Size aSizeArr[] = {1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul, 8ul, 9ul, 0ul};
4386 for(int i = 0; i < 10; ++i)
4388 Standard_Size anInv = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4389 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4394 Standard_Size anInv[10];
4395 const unsigned char* aSizeRef = SizeRef<sizeof(Standard_Size)>();
4396 for(int i = 0; i < 10; ++i)
4397 anInv[i] = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4398 if (memcmp(anInv, aSizeRef, sizeof(Standard_Size)*10) != 0)
4400 theDI << "Error: incorrect conversion of a size value\n";
4401 isErr = Standard_True;
4405 if (!aF.is_open() && !isErr)
4406 theDI << "Conversion was done OK";
4409 cout << "the file " << argv[1] << " has been created" << endl;
4416 #include <TopExp.hxx>
4417 #include <BRepOffsetAPI_DraftAngle.hxx>
4419 static TopoDS_Shape taper(const TopoDS_Shape &shape, const TopoDS_Face &face_a, const TopoDS_Face &face_b, Standard_Real angle)
4421 // Use maximum face-to-taper z-offset.
4422 const gp_Pln neutral_plane(gp_Ax3(gp_Pnt(0.0, 0.0, 140.0), gp_Dir(0.0, 0.0, 1.0)));
4424 // Draft angle needs to be in radians, and flipped to adhere to our own (arbitrary) draft
4425 // angle definition.
4426 const Standard_Real draft_angle = -(angle / 180.0) * M_PI;
4428 // Add face to draft. The first argument indicates that all material added/removed during
4429 // drafting is located below the neutral plane
4430 BRepOffsetAPI_DraftAngle drafter(shape);
4431 drafter.Add(face_a, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4432 drafter.Add(face_b, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4435 return drafter.Shape();
4438 static void dumpShapeVertices(const TopoDS_Shape &shape, std::vector<Standard_Real>& coords)
4440 TopTools_IndexedMapOfShape shape_vertices;
4441 TopExp::MapShapes(shape, TopAbs_VERTEX, shape_vertices);
4443 for (Standard_Integer i = 1; i <= shape_vertices.Extent(); i++)
4445 gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(shape_vertices(i)));
4446 coords.push_back(p.X());
4447 coords.push_back(p.Y());
4448 coords.push_back(p.Z());
4452 static void GetCoords(const Standard_CString& path_to_file, std::vector<Standard_Real>& coords)
4455 BRep_Builder builder;
4456 BRepTools::Read(shape, path_to_file, builder);
4457 TopTools_IndexedMapOfShape shape_faces;
4458 TopExp::MapShapes(shape, TopAbs_FACE, shape_faces);
4459 TopoDS_Face face_a = TopoDS::Face(shape_faces(1));
4460 TopoDS_Face face_b = TopoDS::Face(shape_faces(5));
4461 dumpShapeVertices(taper(shape, face_a, face_b, 5.0), coords);
4464 static Standard_Integer OCC26396 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4468 theDI << "Error: path to file is missing\n";
4472 const int maxInd = 50;
4474 std::vector<Standard_Real> ref_coords;
4475 ref_coords.reserve(100);
4476 Standard_Boolean Stat = Standard_True;
4478 GetCoords(theArgv[1], ref_coords);
4480 std::vector<Standard_Real> coords;
4481 coords.reserve(100);
4482 for (int i = 1; i < maxInd; i++)
4484 GetCoords(theArgv[1], coords);
4485 if (coords.size() != ref_coords.size())
4487 Stat = Standard_False;
4490 for (size_t j = 0; j < coords.size(); j++)
4491 if (Abs(ref_coords[j] - coords[j]) > RealEpsilon())
4493 Stat = Standard_False;
4499 theDI << "Error: unstable results";
4506 //=======================================================================
4507 //function : OCC26750
4509 //=======================================================================
4510 static Standard_Integer OCC26750( Draw_Interpretor& theDI,
4511 Standard_Integer /*theNArg*/,
4512 const char ** /*theArgVal*/)
4514 const gp_Vec2d aVec1(1.0, 0.0);
4515 const gp_Vec2d aVec2(0.0, -1.0);
4517 if(aVec1.IsNormal(aVec2, Precision::Angular()))
4519 theDI << "gp_Vec2d OK. Vectors are normal.\n";
4523 theDI << "Error in gp_Vec2d. Vectors should be normal.\n";
4526 const gp_Dir2d aD1(1.0, 0.0);
4527 const gp_Dir2d aD2(0.0, -1.0);
4529 if(aD1.IsNormal(aD2, Precision::Angular()))
4531 theDI << "gp_Dir2d OK. Vectors are normal.\n";
4535 theDI << "Error in gp_Dir2d. Vectors should be normal.\n";
4541 //=======================================================================
4542 //function : OCC26746
4543 //purpose : Checks if coefficients of the torus are computed properly.
4544 //=======================================================================
4545 #include <Geom_ToroidalSurface.hxx>
4546 #include <Geom_BSplineCurve.hxx>
4547 static Standard_Integer OCC26746(
4548 Draw_Interpretor& theDI,
4549 Standard_Integer theNArg,
4550 const char ** theArgVal)
4554 theDI << "Use: OCC26746 torus [toler NbCheckedPoints]\n";
4558 const Handle(Geom_ToroidalSurface) aGtor =
4559 Handle(Geom_ToroidalSurface)::DownCast(DrawTrSurf::GetSurface(theArgVal[1]));
4561 const Standard_Real aToler = (theNArg >= 3)? Draw::Atof(theArgVal[2]) : 1.0e-7;
4562 const Standard_Integer aNbPntsMax = (theNArg >= 4)? Draw::Atoi(theArgVal[3]) : 5;
4564 const Standard_Integer aLowIndex = 5;
4565 const Standard_Real aStep = 2.0*M_PI/aNbPntsMax;
4567 TColStd_Array1OfReal anArrCoeffs(aLowIndex, aLowIndex+34);
4568 aGtor->Torus().Coefficients(anArrCoeffs);
4570 Standard_Real aUpar = 0.0, aVpar = 0.0;
4571 for(Standard_Integer aUind = 0; aUind <= aNbPntsMax; aUind++)
4573 for(Standard_Integer aVind = 0; aVind <= aNbPntsMax; aVind++)
4575 const gp_Pnt aPt(aGtor->Value(aUpar, aVpar));
4576 const Standard_Real aX1 = aPt.X();
4577 const Standard_Real aX2 = aX1*aX1;
4578 const Standard_Real aX3 = aX2*aX1;
4579 const Standard_Real aX4 = aX2*aX2;
4580 const Standard_Real aY1 = aPt.Y();
4581 const Standard_Real aY2 = aY1*aY1;
4582 const Standard_Real aY3 = aY2*aY1;
4583 const Standard_Real aY4 = aY2*aY2;
4584 const Standard_Real aZ1 = aPt.Z();
4585 const Standard_Real aZ2 = aZ1*aZ1;
4586 const Standard_Real aZ3 = aZ2*aZ1;
4587 const Standard_Real aZ4 = aZ2*aZ2;
4589 Standard_Integer i = aLowIndex;
4591 Standard_Real aDelta = anArrCoeffs(i++) * aX4; //1
4592 aDelta+= anArrCoeffs(i++) * aY4; //2
4593 aDelta+= anArrCoeffs(i++) * aZ4; //3
4594 aDelta+= anArrCoeffs(i++) * aX3 * aY1; //4
4595 aDelta+= anArrCoeffs(i++) * aX3 * aZ1; //5
4596 aDelta+= anArrCoeffs(i++) * aY3 * aX1; //6
4597 aDelta+= anArrCoeffs(i++) * aY3 * aZ1; //7
4598 aDelta+= anArrCoeffs(i++) * aZ3 * aX1; //8
4599 aDelta+= anArrCoeffs(i++) * aZ3 * aY1; //9
4600 aDelta+= anArrCoeffs(i++) * aX2 * aY2; //10
4601 aDelta+= anArrCoeffs(i++) * aX2 * aZ2; //11
4602 aDelta+= anArrCoeffs(i++) * aY2 * aZ2; //12
4603 aDelta+= anArrCoeffs(i++) * aX2 * aY1 * aZ1; //13
4604 aDelta+= anArrCoeffs(i++) * aX1 * aY2 * aZ1; //14
4605 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ2; //15
4606 aDelta+= anArrCoeffs(i++) * aX3; //16
4607 aDelta+= anArrCoeffs(i++) * aY3; //17
4608 aDelta+= anArrCoeffs(i++) * aZ3; //18
4609 aDelta+= anArrCoeffs(i++) * aX2 * aY1; //19
4610 aDelta+= anArrCoeffs(i++) * aX2 * aZ1; //20
4611 aDelta+= anArrCoeffs(i++) * aY2 * aX1; //21
4612 aDelta+= anArrCoeffs(i++) * aY2 * aZ1; //22
4613 aDelta+= anArrCoeffs(i++) * aZ2 * aX1; //23
4614 aDelta+= anArrCoeffs(i++) * aZ2 * aY1; //24
4615 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ1; //25
4616 aDelta+= anArrCoeffs(i++) * aX2; //26
4617 aDelta+= anArrCoeffs(i++) * aY2; //27
4618 aDelta+= anArrCoeffs(i++) * aZ2; //28
4619 aDelta+= anArrCoeffs(i++) * aX1 * aY1; //29
4620 aDelta+= anArrCoeffs(i++) * aX1 * aZ1; //30
4621 aDelta+= anArrCoeffs(i++) * aY1 * aZ1; //31
4622 aDelta+= anArrCoeffs(i++) * aX1; //32
4623 aDelta+= anArrCoeffs(i++) * aY1; //33
4624 aDelta+= anArrCoeffs(i++) * aZ1; //34
4625 aDelta+= anArrCoeffs(i++); //35
4627 if(Abs(aDelta) > aToler)
4629 theDI << "(" << aUpar << ", " << aVpar << "): Error in torus coefficients computation (Delta = " << aDelta << ").\n";
4633 theDI << "(" << aUpar << ", " << aVpar << "): OK (Delta = " << aDelta << ").\n";
4636 aVpar = (aVind == aNbPntsMax)? 2.0*M_PI : aVpar + aStep;
4640 aUpar = (aUind == aNbPntsMax)? 2.0*M_PI : aUpar + aStep;
4646 DEFINE_STANDARD_HANDLE(QABugs_VertexFilter, SelectMgr_Filter);
4647 class QABugs_VertexFilter: public SelectMgr_Filter
4650 Standard_EXPORT QABugs_VertexFilter() : SelectMgr_Filter() {}
4652 Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)&) const
4654 return Standard_False;
4658 //=======================================================================
4659 //function : BUC26658
4660 //purpose : Checks selection in the context after using a selection filter
4661 //=======================================================================
4662 static Standard_Integer BUC26658 (Draw_Interpretor& theDI,
4663 Standard_Integer /*theNArg*/,
4664 const char ** theArgVal)
4666 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4667 if(aContext.IsNull()) {
4668 theDI << "use 'vinit' command before " << theArgVal[0] << "\n";
4672 TopoDS_Shape aBoxShape = BRepPrimAPI_MakeBox(20,20,20).Shape();
4673 Handle(AIS_Shape) anAISIO = new AIS_Shape(aBoxShape);
4675 // visualization of the box in the local mode with possibility to
4676 // select box vertices
4677 aContext->OpenLocalContext();
4679 int aDispMode = 0;// wireframe
4680 anAISIO->SetDisplayMode(aDispMode);
4681 aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed);
4682 theDI.Eval(" vfit");
4684 aContext->Load(anAISIO, -1, true); /// load allowing decomposition
4685 aContext->Deactivate(anAISIO);
4686 aContext->Activate(anAISIO, AIS_Shape::SelectionMode(TopAbs_VERTEX), false);
4687 aContext->UpdateCurrentViewer();
4689 // select a point on the box
4690 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
4692 myV3dView->Project(20,20,0,Xv,Yv);
4693 Standard_Integer Xp,Yp;
4694 myV3dView->Convert(Xv,Yv,Xp,Yp);
4696 aContext->MoveTo(Xp,Yp, myV3dView);
4698 bool aHasSelected = false;
4699 for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) {
4700 Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
4701 if (!anIO.IsNull()) {
4702 const TopoDS_Shape aShape = aContext->SelectedShape();
4703 if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX)
4704 aHasSelected = true;
4708 cout << "has selected vertex : OK" << endl;
4710 theDI << "has selected vertex : bugged - Faulty\n";
4713 // filter to deny any selection in the viewer
4714 Handle(QABugs_VertexFilter) aFilter = new QABugs_VertexFilter();
4715 aContext->AddFilter(aFilter);
4717 // update previous selection by hand
4718 aContext->LocalContext()->ClearOutdatedSelection(anAISIO, true);
4720 // check that there are no selected vertices
4722 aHasSelected = false;
4723 for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) {
4724 Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
4725 if (!anIO.IsNull()) {
4726 const TopoDS_Shape aShape = aContext->SelectedShape();
4727 if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX)
4728 aHasSelected = true;
4731 if (!aHasSelected) cout << "has no selected vertex after filter : OK" << endl;
4733 theDI << "has no selected vertex after filter : bugged - Faulty\n";
4740 //=======================================================================
4741 //function : OCC26945_open
4742 //purpose : Opens local context and activates given standard selection mode
4743 //=======================================================================
4744 static Standard_Integer OCC26945_open (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4746 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
4749 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
4755 std::cout << "Not enough arguments. See usage:\n";
4756 theDI.PrintHelp (theArgv[0]);
4760 const TopAbs_ShapeEnum aSelType = AIS_Shape::SelectionType (Draw::Atoi (theArgv[1]));
4761 Standard_Integer aLocalCtxIdx = aCtx->OpenLocalContext();
4762 aCtx->ActivateStandardMode (aSelType);
4763 theDI << aLocalCtxIdx;
4768 //=======================================================================
4769 //function : OCC26945_close
4770 //purpose : Closes local context with the id given
4771 //=======================================================================
4772 static Standard_Integer OCC26945_close (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4774 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
4777 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
4783 std::cout << "Not enough arguments. See usage:\n";
4784 theDI.PrintHelp (theArgv[0]);
4788 const Standard_Integer aCtxToClose = Draw::Atoi (theArgv[1]);
4789 aCtx->CloseLocalContext (aCtxToClose);
4794 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
4795 const char *group = "QABugs";
4797 Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass();
4798 theCommands.Add ("OCC24202_1", "Test Handle-based procedure",
4799 __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group);
4800 NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass();
4801 theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure",
4802 __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group);
4804 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
4805 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
4806 theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
4807 theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
4808 theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
4809 theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
4810 theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
4811 theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
4812 theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
4813 theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
4814 theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
4815 theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
4816 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);
4817 theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
4818 theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
4819 theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
4820 theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
4821 theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
4822 theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group);
4823 theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group);
4824 theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group);
4825 theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group);
4826 theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group);
4827 theCommands.Add ("OCC24622", "OCC24622 texture={1D|2D}\n Tests sourcing of 1D/2D pixmaps for AIS_TexturedShape", __FILE__, OCC24622, group);
4828 theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group);
4829 theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group);
4830 theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group);
4831 theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group);
4832 theCommands.Add ("OCC23951", "OCC23951 path to saved step file", __FILE__, OCC23951, group);
4833 theCommands.Add ("OCC24931", "OCC24931 path to saved xml file", __FILE__, OCC24931, group);
4834 theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group);
4835 theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
4836 theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group);
4837 theCommands.Add ("OCC24925",
4838 "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]"
4839 "\nOCAF persistence without setting environment variables",
4840 __FILE__, OCC24925, group);
4841 theCommands.Add ("OCC23010", "OCC23010 STEP_file", __FILE__, OCC23010, group);
4842 theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group);
4843 theCommands.Add ("OCC24826,", "This test performs simple saxpy test.\n Usage: OCC24826 length", __FILE__, OCC24826, group);
4844 theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group);
4845 theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group);
4846 theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
4847 theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
4848 theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group);
4849 theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group);
4850 theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
4851 theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
4852 theCommands.Add ("OCC25545",
4853 "no args; tests data race when concurrently accessing \n"
4854 "\t\tTopLoc_Location::Transformation()",
4855 __FILE__, OCC25545, group);
4856 theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
4857 theCommands.Add ("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group);
4858 theCommands.Add ("OCC26172", "OCC26172", __FILE__, OCC26172, group);
4859 theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);
4860 theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group);
4861 theCommands.Add ("OCC26139", "OCC26139 [-boxsize value] [-boxgrid value] [-compgrid value]", __FILE__, OCC26139, group);
4862 theCommands.Add ("OCC26284", "OCC26284", __FILE__, OCC26284, group);
4863 theCommands.Add ("OCC26446", "OCC26446 r c1 c2", __FILE__, OCC26446, group);
4864 theCommands.Add ("OCC26448", "OCC26448: check method Prepend() of sequence", __FILE__, OCC26448, group);
4865 theCommands.Add ("OCC26407", "OCC26407 result_name", __FILE__, OCC26407, group);
4866 theCommands.Add ("OCC26485", "OCC26485 shape", __FILE__, OCC26485, group);
4867 theCommands.Add ("OCC26553", "OCC26553 file_path", __FILE__, OCC26553, group);
4868 theCommands.Add ("OCC26195",
4869 "OCC26195: x1_pix y1_pix [x2_pix y2_pix] [toPrintPixelCoord 0|1]"
4870 "\n\t\t: Draws rectangular selecting frustum defined by point selection in pixel coordinates"
4871 "\n\t\t: [x1_pix, y1_pix] or rectangular selection in pixel coordinates [x1_pix, y1_pix,"
4872 "\n\t\t: x2_pix, y2_pix]."
4873 "\n\t\t: [toPrintPixelCoord 0|1] - prints 3d projection of pixel coordinate or center of"
4874 "\n\t\t: selecting rectangle onto near and far view frustum planes",
4875 __FILE__, OCC26195, group);
4876 theCommands.Add ("OCC26462",
4877 "OCC26462: Checks the ability to manage sensitivity of a particular selection mode in local context",
4878 __FILE__, OCC26462, group);
4880 theCommands.Add ("OCC26313", "OCC26313 result shape", __FILE__, OCC26313, group);
4881 theCommands.Add ("OCC26396", "OCC26396 shape_file_path", __FILE__, OCC26396, group);
4882 theCommands.Add ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group);
4884 theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group);
4885 theCommands.Add ("OCC26750", "OCC26750", __FILE__, OCC26750, group);
4887 theCommands.Add ("OCC26746", "OCC26746 torus [toler NbCheckedPoints] ", __FILE__, OCC26746, group);
4889 theCommands.Add ("BUC26658", "BUC26658 unexpected selection in the context using a selection filter", __FILE__, BUC26658, group);
4890 theCommands.Add ("OCC26945_open",
4891 "OCC26945 selectionModeToActivate"
4892 "\n\t\t: Opens a new local context with selectionModeToActivate activated."
4893 "\n\t\t: Prints the ID of newely opened local context in case of success.",
4894 __FILE__, OCC26945_open, group);
4895 theCommands.Add ("OCC26945_close",
4896 "OCC26945 localCtxToClose"
4897 "\n\t\t: Closes local context with the ID localCtxToClose",
4898 __FILE__, OCC26945_close, group);