1 // Created on: 2002-05-21
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
18 #include <AIS_InteractiveContext.hxx>
19 #include <AIS_Shape.hxx>
20 #include <BRepAlgoAPI_Cut.hxx>
21 #include <BRepOffsetAPI_MakePipe.hxx>
22 #include <BRepPrimAPI_MakeBox.hxx>
23 #include <BRepPrimAPI_MakeSphere.hxx>
25 #include <Draw_Interpretor.hxx>
26 #include <DrawTrSurf.hxx>
27 #include <GCE2d_MakeSegment.hxx>
28 #include <Geom2d_TrimmedCurve.hxx>
29 #include <GeomFill_Trihedron.hxx>
30 #include <Graphic3d_ArrayOfTriangles.hxx>
32 #include <gp_Pnt2d.hxx>
33 #include <gp_Quaternion.hxx>
34 #include <Image_Color.hxx>
35 #include <Image_PixMap.hxx>
36 #include <NCollection_Handle.hxx>
37 #include <NCollection_IncAllocator.hxx>
38 #include <NCollection_Map.hxx>
39 #include <OSD_Parallel.hxx>
40 #include <OSD_PerfMeter.hxx>
41 #include <OSD_Timer.hxx>
42 #include <Precision.hxx>
43 #include <Prs3d_ShadingAspect.hxx>
44 #include <Prs3d_Text.hxx>
45 #include <SelectMgr_Filter.hxx>
46 #include <Standard_Version.hxx>
47 #include <StdSelect_BRepOwner.hxx>
48 #include <TCollection_HAsciiString.hxx>
49 #include <TopExp_Explorer.hxx>
50 #include <TopoDS_Shape.hxx>
51 #include <V3d_View.hxx>
52 #include <ViewerTest.hxx>
53 #include <XmlDrivers_DocumentRetrievalDriver.hxx>
54 #include <XmlDrivers_DocumentStorageDriver.hxx>
55 #include <TDataStd_Real.hxx>
56 #include <Standard_Atomic.hxx>
62 #define QCOMPARE(val1, val2) \
63 di << "Checking " #val1 " == " #val2 << \
64 ((val1) == (val2) ? ": OK\n" : ": Error\n")
66 static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
69 di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d\n";
74 if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
75 di << "ERROR OCC230: " << argv[2] << " is not Pnt2d\n";
78 if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
79 di << "ERROR OCC230: " << argv[3] << " is not Pnt2d\n";
83 GCE2d_MakeSegment MakeSegment(P1,P2);
84 Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
85 DrawTrSurf::Set(argv[1], TrimmedCurve);
89 static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
94 t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267);
95 t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880);
97 gp_Trsf tComp = t2 * t1;
100 gp_Pnt p2 = p1.Transformed(tComp);
101 gp_Pnt p3 = p1.Transformed(t1);
104 // points must be equal
105 if ( ! p2.IsEqual(p3, Precision::Confusion()) )
106 di << "ERROR OCC23361: equivalent transformations does not produce equal points\n";
108 di << "OCC23361: OK\n";
113 static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
115 OSD_PerfMeter aPM("TestMeter",0);
118 // run some operation in cycle for about 2 seconds to have good values of times to compare
120 printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n");
121 for (; aTM.ElapsedTime() < 2.; count++)
126 // do some operation that will take considerable time compared with time of starting / stopping timers
127 BRepPrimAPI_MakeBox aBox (10., 10., 10.);
128 BRepPrimAPI_MakeSphere aSphere (10.);
129 BRepAlgoAPI_Cut aCutter (aBox.Shape(), aSphere.Shape());
136 Standard_Real aPerfMeter_CPUtime = 0., aTimer_CPUTime = 0., aS;
137 Standard_Integer aM, aH;
138 aTM.Show(aS, aM, aH, aTimer_CPUTime);
140 perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
141 perf_init_meter("TestMeter");
143 Standard_Real aTimeDiff = (fabs(aTimer_CPUTime - aPerfMeter_CPUtime) / aTimer_CPUTime);
145 printf("\nMeasurement results (%d cycles):\n", count);
146 printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer CPU time: %lf\n",
147 aPerfMeter_CPUtime, aTimer_CPUTime);
148 printf("Time delta is: %.3lf %%\n", aTimeDiff * 100);
151 di << "OCC23237: Error: too much difference between CPU and elapsed times";
152 else if (aNbEnters != count)
153 di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles";
155 di << "OCC23237: OK";
160 class IncrementerDecrementer
163 IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
165 void operator() (const size_t) const
168 Standard_Atomic_Increment(myVal);
170 Standard_Atomic_Decrement(myVal);
173 Standard_Integer* myVal;
174 Standard_Boolean myPositive;
177 static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
181 //check returned value
182 QCOMPARE (Standard_Atomic_Decrement (&aSum), -1);
183 QCOMPARE (Standard_Atomic_Increment (&aSum), 0);
184 QCOMPARE (Standard_Atomic_Increment (&aSum), 1);
185 QCOMPARE (Standard_Atomic_Increment (&aSum), 2);
186 // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0);
187 // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1);
191 const int N = 1 << 24; //big enough to ensure concurrency
194 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, true));
198 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, false));
204 #include <TDocStd_Application.hxx>
205 #include <TDocStd_Document.hxx>
206 #include <XCAFDoc_ShapeTool.hxx>
207 #include <XCAFDoc_DocumentTool.hxx>
208 #include <TDF_Label.hxx>
209 #include <TDataStd_Name.hxx>
210 #include <DDocStd.hxx>
212 static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
214 Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
215 Handle(TDocStd_Document) aDoc;
216 anApp->NewDocument ("XmlXCAF", aDoc);
217 QCOMPARE (!aDoc.IsNull(), Standard_True);
219 Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
221 //check default value
222 Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
223 QCOMPARE (aValue, Standard_True);
226 XCAFDoc_ShapeTool::SetAutoNaming (Standard_True);
227 TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape();
228 TDF_Label aLabel = aShTool->AddShape (aShape);
229 Handle(TDataStd_Name) anAttr;
230 QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
233 XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
234 aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape();
235 aLabel = aShTool->AddShape (aShape);
236 QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
239 XCAFDoc_ShapeTool::SetAutoNaming (aValue);
244 #include <ExprIntrp_GenExp.hxx>
245 Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
249 di << "Usage : " << argv[0] << " string nb\n";
253 TCollection_AsciiString aToken = argv[1];
254 Standard_Integer aNb = atoi(argv[2]);
256 Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create();
257 for (Standard_Integer i=0; i < aNb; i++)
259 aGen->Process(aToken);
260 Handle(Expr_GeneralExpression) aExpr = aGen->Expression();
266 Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
270 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"
271 << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}"
272 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}";
276 #include <TopoDS_Face.hxx>
277 #include <TopoDS_Face.hxx>
278 #include <TopoDS.hxx>
279 #include <BRepBuilderAPI_Transform.hxx>
280 #include <BRepExtrema_DistShapeShape.hxx>
281 #include <BRepTools.hxx>
283 static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di)
285 BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN);
286 if(!distShapeShape.IsDone()) {
287 di <<"Distance ShapeShape is Not Done\n";
288 return Standard_False;
291 if(distShapeShape.Value() > 0.01) {
292 di << "Wrong Dist = " <<distShapeShape.Value() << "\n";
293 return Standard_False;
295 di << "Dist0 = " <<distShapeShape.Value() <<"\n";
297 //////////////////////////////////////////////////////////////////////////
299 const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970);
300 const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970);
302 gp_Vec2d mirrorVector1(axis1P1,axis1P2);
305 mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1));
307 BRepBuilderAPI_Transform transformer1(mirror1);
308 transformer1.Perform(originalWire);
309 if(!transformer1.IsDone()) {
310 di << "Not Done1 \n";
311 return Standard_False;
313 TopoDS_Shape step1ModifiedShape = transformer1.ModifiedShape(originalWire);
315 BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN);
316 if(!distShapeShape1.IsDone())
317 return Standard_False;
318 if(distShapeShape1.Value() > 0.01) {
319 di << "Dist = " <<distShapeShape1.Value() <<"\n";
320 return Standard_False;
322 di << "Dist1 = " <<distShapeShape1.Value() <<"\n";
324 //////////////////////////////////////////////////////////////////////////
326 transformer1.Perform(step1ModifiedShape);
327 if(!transformer1.IsDone()) {
328 di << "Not Done1 \n";
329 return Standard_False;
331 TopoDS_Shape step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
333 //This is identity matrix for values but for type is gp_Rotation ?!
334 gp_Trsf2d mirror11 = mirror1;
335 mirror11.PreMultiply(mirror1);
337 BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN);
338 if(!distShapeShape2.IsDone())
339 return Standard_False;
341 //This last test case give error (the value is 1008.8822038689706)
342 if(distShapeShape2.Value() > 0.01) {
343 di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n";
344 Standard_Integer N = distShapeShape2.NbSolution();
345 di << "Nb = " <<N <<"\n";
346 for (Standard_Integer i=1;i <= N;i++)
347 di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n";
348 return Standard_False;
350 di << "Distance2 = " <<distShapeShape2.Value() <<"\n";
352 return Standard_True;
354 static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a)
358 di <<"OCC23774: invalid number of input parameters\n";
362 const char *ns1 = (a[1]), *ns2 = (a[2]);
363 TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2));
364 if (S1.IsNull() || S2.IsNull()) {
365 di <<"OCC23774: Null input shapes\n";
368 const TopoDS_Face& aFace = TopoDS::Face(S1);
369 if(!OCC23774Test(aFace, S2, di))
370 di << "Something is wrong\n";
375 #include <GeomConvert_ApproxSurface.hxx>
376 #include <Geom_BSplineSurface.hxx>
378 #include <OSD_Thread.hxx>
380 struct GeomConvertTest_Data
382 Standard_Integer nbupoles;
383 Handle(Geom_Surface) surf;
386 static Standard_Address GeomConvertTest (Standard_Address data)
388 GeomConvertTest_Data* info = (GeomConvertTest_Data*)data;
390 GeomConvert_ApproxSurface aGAS (info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
391 if (!aGAS.IsDone()) {
392 cout << "Error: ApproxSurface is not done!" << endl;
395 const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
396 if (aBSurf.IsNull()) {
397 cout << "Error: BSplineSurface is not created!" << endl;
400 cout << "Number of UPoles:" << aBSurf->NbUPoles();
401 if (aBSurf->NbUPoles() == info->nbupoles)
403 cout << ": OK" << endl;
404 return data; // any non-null pointer
408 cout << ": Error, must be " << info->nbupoles << endl;
413 static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
416 cout << "Error: invalid number of arguments" << endl;
420 struct GeomConvertTest_Data aStorage;
421 aStorage.nbupoles = Draw::Atoi(argv[1]);
422 aStorage.surf = DrawTrSurf::GetSurface(argv[2]);
423 if (aStorage.surf.IsNull())
425 cout << "Error: " << argv[2] << " is not a DRAW surface!" << endl;
429 // start conversion in several threads
430 const int NBTHREADS = 100;
431 OSD_Thread aThread[NBTHREADS];
432 for (int i=0; i < NBTHREADS; i++)
434 aThread[i].SetFunction (GeomConvertTest);
435 if (!aThread[i].Run(&aStorage))
436 di << "Error: Cannot start thread << " << i << "\n";
440 for (int i=0; i < NBTHREADS; i++)
442 Standard_Address aResult = 0;
443 if (!aThread[i].Wait(aResult))
444 di << "Error: Failed waiting for thread << " << i << "\n";
446 di << "Error: wrong number of poles in thread " << i << "!\n";
452 #include <GeomInt_IntSS.hxx>
454 struct GeomIntSSTest_Data
456 Standard_Integer nbsol;
457 Handle(Geom_Surface) surf1, surf2;
460 static Standard_Address GeomIntSSTest (Standard_Address data)
462 GeomIntSSTest_Data* info = (GeomIntSSTest_Data*)data;
463 GeomInt_IntSS anInter;
464 anInter.Perform (info->surf1, info->surf2, Precision::Confusion(), Standard_True);
465 if (!anInter.IsDone()) {
466 cout << "An intersection is not done!" << endl;
470 cout << "Number of Lines:" << anInter.NbLines();
471 if (anInter.NbLines() == info->nbsol)
473 cout << ": OK" << endl;
474 return data; // any non-null pointer
478 cout << ": Error, must be " << info->nbsol << endl;
483 static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
486 cout << "Error: invalid number of arguments" << endl;
490 struct GeomIntSSTest_Data aStorage;
491 aStorage.nbsol = Draw::Atoi(argv[1]);
492 aStorage.surf1 = DrawTrSurf::GetSurface(argv[2]);
493 aStorage.surf2 = DrawTrSurf::GetSurface(argv[3]);
494 if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull())
496 cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" << endl;
500 // start conversion in several threads
501 const int NBTHREADS = 100;
502 OSD_Thread aThread[NBTHREADS];
503 for (int i=0; i < NBTHREADS; i++)
505 aThread[i].SetFunction (GeomIntSSTest);
506 if (!aThread[i].Run(&aStorage))
507 di << "Error: Cannot start thread << " << i << "\n";
511 for (int i=0; i < NBTHREADS; i++)
513 Standard_Address aResult = 0;
514 if (!aThread[i].Wait(aResult))
515 di << "Error: Failed waiting for thread << " << i << "\n";
517 di << "Error: wrong number of intersections in thread " << i << "!\n";
523 #include <Geom_SurfaceOfRevolution.hxx>
524 static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
527 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
531 Standard_Integer ucontinuity = 1;
532 Standard_Integer vcontinuity = 1;
533 Standard_Boolean iscnu = false;
534 Standard_Boolean iscnv = false;
536 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
538 QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
539 QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
544 #include <gp_Ax1.hxx>
545 #include <gp_Ax22d.hxx>
546 #include <Geom_Plane.hxx>
547 #include <Geom2d_Circle.hxx>
548 #include <Geom2d_TrimmedCurve.hxx>
549 #include <BRepBuilderAPI_MakeEdge.hxx>
550 #include <BRepPrimAPI_MakeRevol.hxx>
551 #include <Geom2d_OffsetCurve.hxx>
553 static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
555 // Check the command arguments
558 di << "Error: " << argv[0] << " - invalid number of arguments\n";
559 di << "Usage: type help " << argv[0] << "\n";
560 return 1; // TCL_ERROR
563 gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
564 gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
565 Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
567 di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>\n";
568 di << "-----------------------------------------------------------------------\n";
570 Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
571 Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
572 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
574 DBRep::Set("e1", E1);
576 BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
577 TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
579 DBRep::Set("f1", F1);
581 di << "Result: f1\n";
583 di << "<<<< Preparing sample surface of revolution based on offset curve >>>>\n";
584 di << "-----------------------------------------------------------------------\n";
586 Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
587 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
589 DBRep::Set("e2", E2);
591 BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
592 TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
594 DBRep::Set("f2", F2);
596 di << "Result: f2\n";
601 #include <Geom_Curve.hxx>
602 #include <Geom_Surface.hxx>
603 #include <Precision.hxx>
604 #include <ShapeConstruct_ProjectCurveOnSurface.hxx>
605 //=======================================================================
606 //function : OCC24008
608 //=======================================================================
609 static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
612 di << "Usage: " << argv[0] << " invalid number of arguments\n";
615 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]);
616 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]);
617 if (aCurve.IsNull()) {
618 di << "Curve was not read\n";
621 if (aSurf.IsNull()) {
622 di << "Surface was not read\n";
625 ShapeConstruct_ProjectCurveOnSurface aProj;
626 aProj.Init (aSurf, Precision::Confusion());
628 Handle(Geom2d_Curve) aPCurve;
629 aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve);
630 if (aPCurve.IsNull()) {
631 di << "PCurve was not created\n";
635 di << "Exception was caught\n";
640 #include <GeomAdaptor_Surface.hxx>
642 //=======================================================================
643 //function : OCC23945
645 //=======================================================================
647 static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
651 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
652 if (aS.IsNull()) return 1;
654 GeomAdaptor_Surface GS(aS);
656 Standard_Real U = Draw::Atof(a[2]);
657 Standard_Real V = Draw::Atof(a[3]);
659 Standard_Boolean DrawPoint = ( n%3 == 2);
667 GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
668 Draw::Set(a[13],D2U.X());
669 Draw::Set(a[14],D2U.Y());
670 Draw::Set(a[15],D2U.Z());
671 Draw::Set(a[16],D2V.X());
672 Draw::Set(a[17],D2V.Y());
673 Draw::Set(a[18],D2V.Z());
674 Draw::Set(a[19],D2UV.X());
675 Draw::Set(a[20],D2UV.Y());
676 Draw::Set(a[21],D2UV.Z());
681 Draw::Set(a[7],DU.X());
682 Draw::Set(a[8],DU.Y());
683 Draw::Set(a[9],DU.Z());
684 Draw::Set(a[10],DV.X());
685 Draw::Set(a[11],DV.Y());
686 Draw::Set(a[12],DV.Z());
692 Draw::Set(a[4],P.X());
693 Draw::Set(a[5],P.Y());
694 Draw::Set(a[6],P.Z());
697 DrawTrSurf::Set(a[n],P);
703 //=======================================================================
704 //function : OCC11758
706 //=======================================================================
707 static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
709 if (n != 1) return 1;
711 const char* theStr = "0123456789";
712 Standard_Integer i, j;
713 for ( i = 0; i < 5; ++i ) {
714 // TCollection_AsciiString(const Standard_CString astring)
715 TCollection_AsciiString a(theStr+i);
716 // IsEqual (const Standard_CString other)const
717 //assert( a == theStr+i );
718 QCOMPARE ( a , theStr+i );
720 //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen )
721 TCollection_AsciiString b(theStr+i, 3);
722 //assert( b.Length() == 3 );
723 //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 );
724 //assert( strlen( b.ToCString() ) == 3 );
725 QCOMPARE ( b.Length() , 3 );
726 QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 );
727 QCOMPARE ( b.Length() , 3 );
729 //TCollection_AsciiString(const Standard_Integer aValue)
730 TCollection_AsciiString c(i);
731 //assert( c.IsIntegerValue() );
732 //assert( c.IntegerValue() == i );
733 QCOMPARE ( c.IsIntegerValue() , Standard_True );
734 QCOMPARE ( c.IntegerValue() , i );
736 //TCollection_AsciiString(const Standard_Real aValue)
737 TCollection_AsciiString d( 0.1*i );
738 //assert( d.IsRealValue() );
739 //assert( TCollection_AsciiString(3.3) == "3.3");
740 QCOMPARE ( d.IsRealValue() , Standard_True );
741 QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" );
743 //TCollection_AsciiString(const TCollection_AsciiString& astring)
744 TCollection_AsciiString e(d);
746 //assert( e.Length() == d.Length() );
747 //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
749 QCOMPARE ( e.Length() , d.Length() );
750 QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
752 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
753 // const Standard_Character other )
754 TCollection_AsciiString f(e,'\a');
755 //assert( f.Length() == e.Length() + 1 );
756 //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 );
757 //assert( f.Value( f.Length() ) == '\a');
758 QCOMPARE ( f.Length() , e.Length() + 1 );
759 QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 );
760 QCOMPARE ( f.Value( f.Length() ) , '\a' );
762 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
763 // const Standard_CString other )
764 TCollection_AsciiString g(f, theStr);
765 //assert( g.Length() == f.Length() + strlen( theStr ));
766 //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 );
767 //assert( g.Search( theStr ) == f.Length() + 1 );
768 QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) );
769 QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 );
770 QCOMPARE ( g.Search( theStr ) , f.Length() + 1 );
772 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
773 // const TCollection_AsciiString& other )
774 TCollection_AsciiString h(d,a);
775 //assert( h.Length() == d.Length() + a.Length() );
776 //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 );
777 //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 );
778 QCOMPARE ( h.Length() , d.Length() + a.Length() );
779 QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 );
780 QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 );
782 // AssignCat(const Standard_CString other)
783 c.AssignCat( a.ToCString() );
784 //assert( c.Length() == 1 + a.Length() );
785 //assert( c.Search( a ) == 2 );
786 QCOMPARE ( c.Length() , 1 + a.Length() );
787 QCOMPARE ( c.Search( a ) , 2 );
789 // AssignCat(const TCollection_AsciiString& other)
790 Standard_Integer dl = d.Length();
792 //assert( d.Length() == dl + a.Length() );
793 //assert( d.Search( a ) == dl + 1 );
794 QCOMPARE ( d.Length() , dl + a.Length() );
795 QCOMPARE ( d.Search( a ) , dl + 1 );
798 TCollection_AsciiString capitalize("aBC");
799 capitalize.Capitalize();
800 //assert( capitalize == "Abc" );
801 QCOMPARE ( capitalize , "Abc" );
803 // Copy(const Standard_CString fromwhere)
805 //assert( d == theStr+i );
806 QCOMPARE ( d , theStr+i );
808 // Copy(const TCollection_AsciiString& fromwhere)
810 // IsEqual (const TCollection_AsciiString& other)const
814 // Insert(const Standard_Integer where, const Standard_CString what)
816 d.Insert( 2, theStr );
817 //assert( d.Length() == dl + strlen( theStr ));
818 //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 );
819 QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) );
820 QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 );
822 //Insert(const Standard_Integer where,const Standard_Character what)
824 d.Insert( i+1, 'i' );
825 //assert( d.Length() == strlen( theStr ) + 1 );
826 //assert( d.Value( i+1 ) == 'i');
827 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
828 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
829 QCOMPARE ( d.Value( i+1 ) , 'i' );
830 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
832 //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
834 d.Insert( i+1, TCollection_AsciiString( "i" ));
835 //assert( d.Length() == strlen( theStr ) + 1 );
836 //assert( d.Value( i+1 ) == 'i');
837 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
838 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
839 QCOMPARE ( d.Value( i+1 ) , 'i' );
840 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
842 // IsDifferent (const Standard_CString other)const
843 //assert( d.IsDifferent( theStr ));
844 //assert( d.IsDifferent( "theStr" ));
845 //assert( d.IsDifferent( "" ));
846 //assert( !d.IsDifferent( d.ToCString() ));
847 QCOMPARE ( d.IsDifferent( theStr ) , Standard_True );
848 QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True );
849 QCOMPARE ( d.IsDifferent( "" ) , Standard_True );
850 QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True );
852 // IsDifferent (const TCollection_AsciiString& other)const
853 //assert( d.IsDifferent( TCollection_AsciiString() ));
854 //assert( d.IsDifferent( a ));
855 //assert( d.IsDifferent( h ));
856 //assert( !d.IsDifferent( d ));
857 QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True );
858 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
859 QCOMPARE ( d.IsDifferent( h ) , Standard_True );
860 QCOMPARE ( !d.IsDifferent( d ) , Standard_True );
862 // IsLess (const Standard_CString other)const
863 //assert( TCollection_AsciiString ("0"). IsLess("1"));
864 //assert( TCollection_AsciiString ("0"). IsLess("00"));
865 //assert( TCollection_AsciiString (""). IsLess("0"));
866 //assert( !TCollection_AsciiString("1"). IsLess("0"));
867 //assert( !TCollection_AsciiString("00").IsLess("0"));
868 //assert( !TCollection_AsciiString("0"). IsLess(""));
869 //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1));
870 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True );
871 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True );
872 QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True );
873 QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True );
874 QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True );
875 QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True );
876 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True );
878 // IsLess (const TCollection_AsciiString& other)const
879 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )));
880 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")));
881 //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )));
882 //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )));
883 //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )));
884 //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )));
885 //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)));
886 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True );
887 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True );
888 QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True );
889 QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True );
890 QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True );
891 QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True );
892 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True );
894 // IsGreater (const Standard_CString other)const
895 //assert( !TCollection_AsciiString("0"). IsGreater("1"));
896 //assert( !TCollection_AsciiString("0"). IsGreater("00"));
897 //assert( !TCollection_AsciiString(""). IsGreater("0"));
898 //assert( TCollection_AsciiString ("1"). IsGreater("0"));
899 //assert( TCollection_AsciiString ("00").IsGreater("0"));
900 //assert( TCollection_AsciiString ("0"). IsGreater(""));
901 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i));
902 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True );
903 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True );
904 QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True );
905 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True );
906 QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True );
907 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True );
908 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True );
910 // IsGreater (const TCollection_AsciiString& other)const
911 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )));
912 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")));
913 //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )));
914 //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )));
915 //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )));
916 //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )));
917 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)));
918 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True );
919 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True );
920 QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
921 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
922 QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True );
923 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True );
924 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True );
926 // void Read(Standard_IStream& astream)
927 std::istringstream is( theStr );
929 //assert( e == theStr );
930 QCOMPARE ( e , theStr );
932 // Standard_Integer SearchFromEnd (const Standard_CString what)const
933 //assert( e.SearchFromEnd( theStr + i ) == i + 1 );
934 QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 );
936 // SetValue(const Standard_Integer where, const Standard_CString what)
937 e.SetValue( i+1, "what");
938 //assert( e.Search( "what" ) == i+1 );
939 //assert( e.Length() == strlen( theStr ));
940 QCOMPARE ( e.Search( "what" ) , i+1 );
941 QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) );
943 // TCollection_AsciiString Split (const Standard_Integer where)
946 //assert( d.Length() + e.Length() == strlen( theStr ));
947 QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
949 // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
950 // const Standard_Integer ToIndex) const
952 d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 );
953 //assert( d.Length() == 3 );
954 //assert( d.Value(1) == theStr[ i ]);
955 QCOMPARE ( d.Length() , 3 );
956 QCOMPARE ( d.Value(1) , theStr[ i ] );
958 // TCollection_AsciiString Token (const Standard_CString separators,
959 // const Standard_Integer whichone) const
961 for ( j = 0; j < i; ++j ) {
962 e += TCollection_AsciiString( theStr[j] ) + " ";
963 //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 ));
964 QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) );
967 for ( i = 0; i < 5; ++i )
969 // TCollection_ExtendedString (const Standard_CString astring,
970 // const Standard_Boolean isMultiByte)
971 const TCollection_ExtendedString a( theStr+i );
972 //assert( TCollection_AsciiString( a ) == theStr+i );
973 QCOMPARE ( TCollection_AsciiString( a ) , theStr+i );
975 //TCollection_ExtendedString (const Standard_ExtString astring)
976 const TCollection_ExtendedString b( a.ToExtString() );
980 // TCollection_ExtendedString (const Standard_Integer length,
981 // const Standard_ExtCharacter filler )
982 const TCollection_ExtendedString c( i, 1 );
983 //assert( c.Length() == i );
984 QCOMPARE ( c.Length() , i );
985 if ( c.Length() > 0 ) {
986 //assert( c.Value( i ) == 1 );
987 QCOMPARE ( c.Value( i ) , 1 );
990 // TCollection_ExtendedString (const Standard_Integer aValue)
991 TCollection_ExtendedString d( i );
992 const TCollection_AsciiString da( d );
993 //assert( da.IsIntegerValue() );
994 //assert( da.IntegerValue() == i );
995 QCOMPARE ( da.IsIntegerValue() , Standard_True );
996 QCOMPARE ( da.IntegerValue(), i );
998 // TCollection_ExtendedString (const Standard_Real aValue)
999 const TCollection_ExtendedString e( 0.1 * i );
1000 const TCollection_AsciiString ea( e );
1001 //assert( ea.IsRealValue() );
1002 //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 );
1003 QCOMPARE ( ea.IsRealValue() , Standard_True );
1004 QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True );
1006 // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1007 const TCollection_ExtendedString f(e);
1008 //assert( f.Length() == e.Length());
1010 QCOMPARE ( f.Length() , e.Length() );
1013 // TCollection_ExtendedString (const TCollection_AsciiString& astring)
1014 const TCollection_ExtendedString g( ea );
1015 //assert( g.Length() == ea.Length() );
1016 //assert( TCollection_AsciiString( g ) == ea );
1017 QCOMPARE ( g.Length() , ea.Length() );
1018 QCOMPARE ( TCollection_AsciiString( g ) , ea );
1020 // AssignCat (const TCollection_ExtendedString& other)
1021 const TCollection_ExtendedString sep(",");
1024 //assert( d.Length() == 2 + g.Length() );
1025 //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i ));
1026 //assert( d.Token( sep.ToExtString(), 2 ) == g );
1027 QCOMPARE ( d.Length() , 2 + g.Length() );
1028 QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) );
1029 QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g );
1031 // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const
1032 const TCollection_ExtendedString cat = a.Cat( sep );
1033 //assert( cat.Length() == a.Length() + sep.Length() );
1034 //assert( cat.Search( a ) == 1 );
1035 //assert( cat.Search( sep ) == a.Length() + 1 );
1036 QCOMPARE ( cat.Length() , a.Length() + sep.Length() );
1037 QCOMPARE ( cat.Search( a ) , 1 );
1038 QCOMPARE ( cat.Search( sep ) , a.Length() + 1 );
1040 // Copy (const TCollection_ExtendedString& fromwhere)
1042 //assert( d.Length() == cat.Length() );
1043 //assert( d == cat );
1044 QCOMPARE ( d.Length() , cat.Length() );
1045 QCOMPARE ( d , cat );
1047 // IsEqual (const Standard_ExtString other) const
1048 //assert( d.IsEqual( d.ToExtString() ));
1049 QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1051 // IsDifferent (const Standard_ExtString other ) const
1052 //assert( d.IsDifferent( a.ToExtString() ));
1053 QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1055 // IsDifferent (const TCollection_ExtendedString& other) const
1056 //assert( d.IsDifferent( a ));
1057 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
1059 // IsLess (const Standard_ExtString other) const
1060 const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1);
1061 //assert( l0. IsLess( l1.ToExtString() ));
1062 //assert( l0. IsLess( l00.ToExtString() ));
1063 //assert( l. IsLess( l0.ToExtString() ));
1064 //assert( ! l1. IsLess( l0.ToExtString() ));
1065 //assert( ! l00.IsLess( l0.ToExtString() ));
1066 //assert( ! l0. IsLess( l.ToExtString() ));
1067 //assert( ls.IsLess( ls1.ToExtString() ));
1068 QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True );
1069 QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True );
1070 QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True );
1071 QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True );
1072 QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True );
1073 QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True );
1074 QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True );
1076 // IsLess (const TCollection_ExtendedString& other) const
1077 //assert( l0. IsLess( l1 ));
1078 //assert( l0. IsLess( l00 ));
1079 //assert( l. IsLess( l0 ));
1080 //assert( ! l1. IsLess( l0 ));
1081 //assert( ! l00.IsLess( l0 ));
1082 //assert( ! l0. IsLess( l ));
1083 //assert( ls.IsLess( ls1 ));
1084 QCOMPARE ( l0. IsLess( l1 ) , Standard_True );
1085 QCOMPARE ( l0. IsLess( l00 ) , Standard_True );
1086 QCOMPARE ( l. IsLess( l0 ) , Standard_True );
1087 QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True );
1088 QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True );
1089 QCOMPARE ( ! l0. IsLess( l ) , Standard_True );
1090 QCOMPARE ( ls.IsLess( ls1 ) , Standard_True );
1092 // IsGreater (const Standard_ExtString other) const
1093 //assert( ! l0.IsGreater( l1.ToExtString() ));
1094 //assert( ! l0.IsGreater( l00.ToExtString() ));
1095 //assert( ! l. IsGreater( l0.ToExtString() ));
1096 //assert( l1. IsGreater( l0.ToExtString() ));
1097 //assert( l00.IsGreater( l0.ToExtString() ));
1098 //assert( l0. IsGreater( l.ToExtString() ));
1099 //assert( ls1.IsGreater( ls.ToExtString() ));
1100 QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True );
1101 QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True );
1102 QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True );
1103 QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True );
1104 QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True );
1105 QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True );
1106 QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True );
1108 // IsGreater (const TCollection_ExtendedString& other) const
1109 //assert( ! l0.IsGreater( l1));
1110 //assert( ! l0.IsGreater( l00));
1111 //assert( ! l. IsGreater( l0));
1112 //assert( l1. IsGreater( l0));
1113 //assert( l00.IsGreater( l0));
1114 //assert( l0. IsGreater( l));
1115 //assert( ls1.IsGreater( ls));
1116 QCOMPARE ( ! l0.IsGreater( l1) , Standard_True );
1117 QCOMPARE ( ! l0.IsGreater( l00) , Standard_True );
1118 QCOMPARE ( ! l. IsGreater( l0) , Standard_True );
1119 QCOMPARE ( l1. IsGreater( l0) , Standard_True );
1120 QCOMPARE ( l00.IsGreater( l0) , Standard_True );
1121 QCOMPARE ( l0. IsGreater( l) , Standard_True );
1122 QCOMPARE ( ls1.IsGreater( ls) , Standard_True );
1124 // ==========================
1125 //TCollection_HAsciiString::
1126 // ==========================
1128 // IsDifferent(const Handle(TCollection_HAsciiString)& S)
1129 Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i );
1130 Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 );
1131 //assert( ha1->IsDifferent( ha2 ));
1132 //assert( !ha1->IsDifferent( ha1 ));
1133 QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True );
1134 QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True );
1136 // IsSameString (const Handle(TCollection_HAsciiString)& S)
1137 //assert( !ha1->IsSameString( ha2 ));
1138 //assert( ha1->IsSameString( ha1 ));
1139 QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True );
1140 QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True );
1142 // IsSameState (const Handle(TCollection_HAsciiString)& other) const
1143 //assert( !ha1->IsSameState( ha2 ));
1144 //assert( ha1->IsSameState( ha1 ));
1145 QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True );
1146 QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True );
1148 // IsSameString (const Handle(TCollection_HAsciiString)& S ,
1149 // const Standard_Boolean CaseSensitive) const
1150 //assert( !ha1->IsSameString( ha2, true ));
1151 //assert( ha1->IsSameString( ha1, true ));
1152 //assert( !ha1->IsSameString( ha2, false ));
1153 //assert( ha1->IsSameString( ha1, false ));
1154 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1155 QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True );
1156 QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True );
1157 QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True );
1159 ha1->SetValue( 1, "AbC0000000");
1160 ha2->SetValue( 1, "aBc0000000");
1161 //assert( !ha1->IsSameString( ha2, true ));
1162 //assert( ha1->IsSameString( ha2, false ));
1163 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1164 QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True );
1169 #include <Geom_CylindricalSurface.hxx>
1170 #include <IntTools_FaceFace.hxx>
1171 #include <IntTools_Curve.hxx>
1172 #include <IntTools_PntOn2Faces.hxx>
1174 static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1178 theDI << "Wrong a number of arguments!\n";
1182 Handle(Geom_Plane) plane(new Geom_Plane(
1183 gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
1184 gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
1185 gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000))));
1186 Handle(Geom_CylindricalSurface) cylinder(
1187 new Geom_CylindricalSurface(
1188 gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
1189 gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
1190 gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
1191 19.712534607908712));
1193 DrawTrSurf::Set("pln", plane);
1195 DrawTrSurf::Set("cyl", cylinder);
1198 BRep_Builder builder;
1199 TopoDS_Face face1, face2;
1200 builder.MakeFace(face1, plane, Precision::Confusion());
1201 builder.MakeFace(face2, cylinder, Precision::Confusion());
1202 IntTools_FaceFace anInters;
1203 anInters.SetParameters(false, true, true, Precision::Confusion());
1204 anInters.Perform(face1, face2);
1206 if (!anInters.IsDone())
1208 theDI<<"No intersections found!\n";
1213 //Handle(Geom_Curve) aResult;
1216 const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1217 const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1220 Standard_Integer aNbCurves, aNbPoints;
1222 aNbCurves=aCvsX.Length();
1223 aNbPoints=aPntsX.Length();
1227 for (Standard_Integer i=1; i<=aNbCurves; ++i)
1229 Sprintf(buf, "%s_%d",theArgv[1],i);
1230 theDI << buf << " ";
1232 const IntTools_Curve& aIC = aCvsX(i);
1233 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1234 DrawTrSurf::Set(buf,aC3D);
1237 else if (aNbCurves == 1)
1239 const IntTools_Curve& aIC = aCvsX(1);
1240 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1241 Sprintf(buf, "%s",theArgv[1]);
1242 theDI << buf << " ";
1243 DrawTrSurf::Set(buf,aC3D);
1246 for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1248 const IntTools_PntOn2Faces& aPi=aPntsX(i);
1249 const gp_Pnt& aP=aPi.P1().Pnt();
1251 Sprintf(buf,"%s_p_%d",theArgv[1],i);
1252 theDI << buf << " ";
1253 DrawTrSurf::Set(buf, aP);
1259 #include <BRepAlgo_NormalProjection.hxx>
1260 static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1263 di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)";
1267 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1268 if(myAISContext.IsNull()) {
1269 di << "use 'vinit' command before " << argv[0] << "\n";
1273 TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1]));
1274 TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2]));
1276 BRepAlgo_NormalProjection anormpro(m_Face1);
1277 anormpro.Add(m_Edge);
1278 anormpro.SetDefaultParams();
1280 //anormpro.Compute3d();
1281 //anormpro.SetLimit();
1285 if (anormpro.IsDone())
1287 TopoDS_Shape rshape = anormpro.Projection();
1288 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape);
1289 myAISContext->SetColor (myShape, Quantity_Color(Quantity_NOC_YELLOW), Standard_False);
1290 myAISContext->Display (myShape, Standard_True);
1296 #include <BRepFeat_SplitShape.hxx>
1297 #include <ShapeAnalysis_ShapeContents.hxx>
1298 #include <BRepAlgo.hxx>
1299 static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1302 di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)";
1306 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1307 if(myAISContext.IsNull()) {
1308 di << "use 'vinit' command before " << argv[0] << "\n";
1312 TopoDS_Shape result;
1313 TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1]));
1314 TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2]));
1316 BRepFeat_SplitShape asplit(face);
1317 asplit.Add(wire, face);
1319 result = asplit.Shape();
1320 ShapeAnalysis_ShapeContents ana;
1321 ana.Perform(result);
1324 if (!(BRepAlgo::IsValid(result))) {
1325 di << "Result was checked and it is INVALID\n";
1327 di << "Result was checked and it is VALID\n";
1330 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result);
1331 myAISContext->Display(myShape, Standard_True);
1336 #include <Geom_Circle.hxx>
1337 #include <GeomAdaptor_Curve.hxx>
1338 #include <Extrema_ExtPC.hxx>
1339 #include <gp_Cylinder.hxx>
1340 #include <ElSLib.hxx>
1341 static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1344 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1348 gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 );
1349 gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() );
1350 Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 );
1351 GeomAdaptor_Curve aC3D( aCircle );
1353 Extrema_ExtPC aExtPC( aP3D, aC3D );
1354 //Standard_Real aParam = (aExtPC.Point(1)).Parameter();
1355 gp_Pnt aProj = (aExtPC.Point(1)).Value();
1356 di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n";
1358 // Result of deviation
1359 gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() );
1360 gp_Cylinder aCylinder( aCylAxis, 1890. );
1362 Standard_Real aU = 0., aV = 0.;
1363 ElSLib::Parameters( aCylinder, aProj, aU, aV );
1364 di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n";
1369 #include <Extrema_FuncPSNorm.hxx>
1370 #include <math_FunctionSetRoot.hxx>
1371 #include <math_Vector.hxx>
1372 #include <BRepBuilderAPI_MakeVertex.hxx>
1373 static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1375 Standard_Integer anArgIter = 1;
1378 theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]\n";
1383 Standard_CString aFaceName = theArgv[anArgIter++];
1384 Standard_CString aVertName = theArgv[anArgIter++];
1385 const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
1386 const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
1387 const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
1388 const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
1389 const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
1390 if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
1392 std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1395 if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1397 std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1400 const TopoDS_Face aFace = TopoDS::Face (aShapeF);
1401 const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1402 GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1404 gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1406 Extrema_FuncPSNorm anExtFunc;
1407 math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
1409 math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2);
1410 aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion();
1411 aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite();
1412 aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite();
1413 aFromUV(1) = aUFrom; aFromUV(2) = aVFrom;
1415 anExtFunc.Initialize (aSurf);
1416 anExtFunc.SetPoint (aPnt);
1417 aRoot.SetTolerance (aTolUV);
1418 aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1419 if (!aRoot.IsDone())
1421 std::cerr << "No results!\n";
1425 theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1427 aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1428 DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1432 //! Check boolean operations on NCollection_Map
1433 static Standard_Integer OCC24271 (Draw_Interpretor& di,
1434 Standard_Integer /*theArgNb*/,
1435 const char** /*theArgVec*/)
1438 const Standard_Integer aLeftLower = 1;
1439 const Standard_Integer aLeftUpper = 10;
1440 const Standard_Integer aRightLower = 5;
1441 const Standard_Integer aRightUpper = 15;
1444 NCollection_Map<Standard_Integer> aMapLeft;
1445 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1447 aMapLeft.Add (aKeyIter);
1450 NCollection_Map<Standard_Integer> aMapRight;
1451 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1453 aMapRight.Add (aKeyIter);
1456 QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1457 QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False);
1459 // validate Union operation
1460 NCollection_Map<Standard_Integer> aMapUnion;
1461 aMapUnion.Union (aMapLeft, aMapRight);
1462 QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1);
1463 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter)
1465 QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
1468 // validate Intersection operation
1469 NCollection_Map<Standard_Integer> aMapSect;
1470 aMapSect.Intersection (aMapLeft, aMapRight);
1471 QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1);
1472 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1474 QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1476 QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1477 QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
1479 // validate Substruction operation
1480 NCollection_Map<Standard_Integer> aMapSubsLR;
1481 aMapSubsLR.Subtraction (aMapLeft, aMapRight);
1482 QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower);
1483 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1485 QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
1488 NCollection_Map<Standard_Integer> aMapSubsRL;
1489 aMapSubsRL.Subtraction (aMapRight, aMapLeft);
1490 QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper);
1491 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1493 QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
1496 // validate Difference operation
1497 NCollection_Map<Standard_Integer> aMapDiff;
1498 aMapDiff.Difference (aMapLeft, aMapRight);
1499 QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper);
1500 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1502 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1504 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1506 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1509 // validate Exchange operation
1510 NCollection_Map<Standard_Integer> aMapSwap;
1511 aMapSwap.Exchange (aMapSect);
1512 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1514 QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1516 QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1520 NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1521 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1522 aMapCopy.Remove (34);
1524 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1529 #define QVERIFY(val1) \
1530 di << "Checking " #val1 " == Standard_True" << \
1531 ((val1) == Standard_True ? ": OK\n" : ": Error\n")
1533 #include <GeomInt_IntSS.hxx>
1534 #include <Geom_ConicalSurface.hxx>
1535 #include <Standard_ErrorHandler.hxx>
1538 static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc,
1539 const gp_Dir& theDir,
1540 const gp_Dir& theXDir,
1541 const Standard_Real theRad,
1542 const Standard_Real theSin,
1543 const Standard_Real theCos)
1545 const Standard_Real anA = atan (theSin / theCos);
1546 gp_Ax3 anAxis (theLoc, theDir, theXDir);
1547 Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad);
1552 static Standard_Integer OCC23972(Draw_Interpretor& /*theDI*/,
1553 Standard_Integer theNArg, const char** theArgs)
1555 if (theNArg != 3) return 1;
1557 //process specific cones, cannot read them from files because
1558 //due to rounding the original error in math_FunctionRoots gets hidden
1559 const Handle(Geom_Surface) aS1 = CreateCone(
1560 gp_Pnt(123.694345356663, 789.9, 68.15),
1561 gp_Dir(-1, 3.48029791472957e-016, -8.41302743359754e-017),
1562 gp_Dir(-3.48029791472957e-016, -1, -3.17572289932207e-016),
1566 const Handle(Geom_Surface) aS2 = CreateCone(
1567 gp_Pnt(123.694345356663, 784.9, 68.15),
1568 gp_Dir(-1, -2.5209507537117e-016, -1.49772808948866e-016),
1569 gp_Dir(1.49772808948866e-016, 3.17572289932207e-016, -1),
1574 DrawTrSurf::Set(theArgs[1], aS1);
1575 DrawTrSurf::Set(theArgs[2], aS2);
1580 #include <ShapeFix_EdgeProjAux.hxx>
1581 static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1584 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
1588 TopoDS_Shape aSh = DBRep::Get(argv[1]);
1590 di << argv[0] << " Error: Null input edge\n";
1593 const TopoDS_Edge& anEdge = TopoDS::Edge (aSh);
1595 Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]);
1597 di << argv[0] << " Error: Null input curve\n";
1601 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]);
1603 di << argv[0] << " Error: Null input surface\n";
1607 Standard_Real prec = Draw::Atof(argv[4]);
1612 aB.MakeFace (aFace, aS, Precision::Confusion());
1613 aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion());
1614 aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter());
1617 ShapeFix_EdgeProjAux aProj (aFace, anEdge);
1618 aProj.Compute (prec);
1620 Standard_Boolean isfirstdone = aProj.IsFirstDone();
1621 Standard_Boolean islastdone = aProj.IsLastDone();
1623 Standard_Real first = 0.;
1624 Standard_Real last = 0.;
1625 Standard_Integer isfirstdoneInteger = 0;
1626 Standard_Integer islastdoneInteger = 0;
1630 first = aProj.FirstParam();
1631 isfirstdoneInteger = 1;
1635 last= aProj.LastParam();
1636 islastdoneInteger = 1;
1639 di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n";
1644 template<typename T, typename HT>
1645 static void DoIsNull(Draw_Interpretor& di)
1648 // QVERIFY (aHandle.IsNull());
1649 QCOMPARE (aHandle.IsNull(), Standard_True);
1650 const T* p = aHandle.get();
1651 #if OCC_VERSION_HEX > 0x060700
1654 QCOMPARE (!p, Standard_True);
1655 QCOMPARE (p == 0, Standard_True);
1659 //QVERIFY (!aHandle.IsNull());
1660 QCOMPARE (!aHandle.IsNull(), Standard_True);
1664 QCOMPARE (p != NULL, Standard_True);
1665 QCOMPARE (p != 0, Standard_True);
1668 //=======================================================================
1669 //function : OCC24533
1671 //=======================================================================
1672 static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**)
1674 if (n != 1) return 1;
1676 DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di);
1681 // Dummy class to test interface for compilation issues
1682 class QABugs_HandleClass : public Standard_Transient
1685 Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1687 std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n";
1690 DEFINE_STANDARD_RTTI_INLINE(QABugs_HandleClass,Standard_Transient) // Type definition
1692 DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1695 // Dummy class to test interface for compilation issues
1696 struct QABugs_NHandleClass
1698 Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1700 std::cerr << "QABugs_NHandleClass[" << this << "] " << theArgVec[0] << "\n";
1705 #include <XCAFDoc_ColorTool.hxx>
1706 #include <STEPControl_StepModelType.hxx>
1707 #include <STEPCAFControl_Writer.hxx>
1708 static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1711 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1714 Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");;
1715 TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape();
1716 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape();
1717 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1);
1718 TDataStd_Name::Set(lab1, "Box1");
1720 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1721 XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen);
1722 XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0);
1724 STEPControl_StepModelType mode = STEPControl_AsIs;
1725 STEPCAFControl_Writer writer;
1726 if ( ! writer.Transfer (aDoc, mode ) )
1728 di << "The document cannot be translated or gives no result" << "\n";
1732 writer.Write(argv[1]);
1737 //=======================================================================
1738 //function : OCC23950
1740 //=======================================================================
1741 static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1744 di << "Usage : " << argv[0] << " step_file\n";
1748 Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy");
1749 TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
1751 TopLoc_Location location0 (t0);
1753 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1754 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6);
1755 TDataStd_Name::Set(lab1, "Point1");
1757 TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1758 TDataStd_Name::Set(labelA0, "ASSEMBLY");
1760 TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
1761 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->UpdateAssemblies();
1763 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1764 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
1765 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
1767 STEPControl_StepModelType mode = STEPControl_AsIs;
1768 STEPCAFControl_Writer writer;
1769 if (! writer.Transfer (aDoc, mode))
1771 di << "The document cannot be translated or gives no result\n";
1775 writer.Write (argv[1]);
1779 //=======================================================================
1780 //function : OCC24667
1782 //=======================================================================
1783 static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1787 di << "OCC24667 result Wire_spine Profile [Mode [Approx]]\n";
1788 di << "Mode = 0 - CorrectedFrenet,\n";
1789 di << " = 1 - Frenet,\n";
1790 di << " = 2 - DiscreteTrihedron\n";
1791 di << "Approx - force C1-approximation if result is C0\n";
1795 if (n > 1 && n < 4) return 1;
1797 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
1798 if ( Spine.IsNull()) return 1;
1800 TopoDS_Shape Profile = DBRep::Get(a[3]);
1801 if ( Profile.IsNull()) return 1;
1803 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
1806 Standard_Integer iMode = atoi(a[4]);
1808 Mode = GeomFill_IsFrenet;
1809 else if (iMode == 2)
1810 Mode = GeomFill_IsDiscreteTrihedron;
1813 Standard_Boolean ForceApproxC1 = Standard_False;
1815 ForceApproxC1 = Standard_True;
1817 BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine),
1822 TopoDS_Shape S = aPipe.Shape();
1823 TopoDS_Shape aSF = aPipe.FirstShape();
1824 TopoDS_Shape aSL = aPipe.LastShape();
1828 TCollection_AsciiString aStrF(a[1], "_f");
1829 TCollection_AsciiString aStrL(a[1], "_l");
1831 DBRep::Set(aStrF.ToCString(), aSF);
1832 DBRep::Set(aStrL.ToCString(), aSL);
1837 #include <BRepPrimAPI_MakeCylinder.hxx>
1838 #include <BRepBuilderAPI_Copy.hxx>
1839 #include <BRepTools_NurbsConvertModification.hxx>
1840 static TopoDS_Shape CreateTestShape (int& theShapeNb)
1842 TopoDS_Compound aComp;
1843 BRep_Builder aBuilder;
1844 aBuilder.MakeCompound (aComp);
1845 //NURBS modifier is used to increase footprint of each shape
1846 Handle(BRepTools_NurbsConvertModification) aNurbsModif = new BRepTools_NurbsConvertModification;
1847 TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid();
1848 BRepTools_Modifier aModifier (aRefShape, aNurbsModif);
1849 if (aModifier.IsDone()) {
1850 aRefShape = aModifier.ModifiedShape (aRefShape);
1853 for (; theShapeNb > 0; --theShapeNb) {
1854 TopoDS_Shape aShape;
1855 if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists
1856 aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape();
1858 aShape = CreateTestShape (theShapeNb);
1860 aBuilder.Add (aComp, aShape);
1865 #include <TDataStd_Integer.hxx>
1866 #include <TNaming_Builder.hxx>
1867 static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1870 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1873 TCollection_ExtendedString aFileName (argv[1]);
1874 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
1876 Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
1878 Handle(TDocStd_Document) aDoc;
1879 anApp->NewDocument ("XmlOcaf", aDoc);
1880 TDF_Label aLab = aDoc->Main();
1881 TDataStd_Integer::Set (aLab, 0);
1882 int n = 10000; //must be big enough
1883 TopoDS_Shape aShape = CreateTestShape (n);
1884 TNaming_Builder aBuilder (aLab);
1885 aBuilder.Generated (aShape);
1887 aSStatus = anApp->SaveAs (aDoc, aFileName);
1888 anApp->Close (aDoc);
1890 QCOMPARE (aSStatus, PCDM_SS_OK);
1894 #include <TDF_AttributeIterator.hxx>
1895 //=======================================================================
1896 //function : OCC24755
1898 //=======================================================================
1899 static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1903 std::cout << "Usage : " << a[0] << "\n";
1907 Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
1908 Handle(TDocStd_Document) aDoc;
1909 anApp->NewDocument ("BinOcaf", aDoc);
1910 TDF_Label aLab = aDoc->Main();
1911 // Prepend an int value.
1912 TDataStd_Integer::Set (aLab, 0);
1914 TDataStd_Name::Set (aLab, "test");
1915 // Append a double value.
1916 aLab.AddAttribute(new TDataStd_Real(), true/*append*/);
1918 TDF_AttributeIterator i (aLab);
1919 Handle(TDF_Attribute) anAttr = i.Value();
1920 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True);
1923 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True);
1926 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Real)), Standard_True);
1933 MyStubObject() : ptr(0L) {}
1934 MyStubObject(void* thePtr) : ptr(thePtr) {}
1939 //=======================================================================
1940 //function : OCC24834
1942 //=======================================================================
1943 static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1947 std::cout << "Usage : " << a[0] << "\n";
1951 int i = sizeof (char*);
1953 std::cout << "64-bit architecture is not supported.\n";
1957 NCollection_List<MyStubObject> aList;
1958 const Standard_Integer aSmallBlockSize = 40;
1959 const Standard_Integer aLargeBlockSize = 1500000;
1961 // quick populate memory with large blocks
1966 aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize)));
1969 catch (Standard_Failure)
1971 di << "caught out of memory for large blocks: OK\n";
1975 di << "skept out of memory for large blocks: Error\n";
1978 // allocate small blocks
1983 aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize)));
1986 catch (Standard_Failure)
1988 di << "caught out of memory for small blocks: OK\n";
1992 di << "skept out of memory for small blocks: Error\n";
1995 // release all allocated blocks
1996 for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next())
1998 Standard::Free(it.Value().ptr);
2004 #include <Geom2dAPI_InterCurveCurve.hxx>
2005 #include <IntRes2d_IntersectionPoint.hxx>
2006 //=======================================================================
2007 //function : OCC24889
2009 //=======================================================================
2010 static Standard_Integer OCC24889 (Draw_Interpretor& theDI,
2011 Standard_Integer /*theNArg*/,
2012 const char** /*theArgs*/)
2015 Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle(
2016 gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2018 Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle(
2019 gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2021 Handle( Geom2d_TrimmedCurve ) aTrim[2] = {
2022 new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ),
2023 new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 )
2026 DrawTrSurf::Set("c_1", aTrim[0]);
2027 DrawTrSurf::Set("c_2", aTrim[1]);
2030 const Standard_Real aTol = Precision::Confusion();
2031 Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol );
2033 const IntRes2d_IntersectionPoint& aIntPnt =
2034 aIntTool.Intersector().Point( 1 );
2036 gp_Pnt2d aIntRes = aIntTool.Point( 1 );
2037 Standard_Real aPar[2] = {
2038 aIntPnt.ParamOnFirst(),
2039 aIntPnt.ParamOnSecond()
2042 //theDI.precision( 5 );
2043 theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n";
2044 for (int i = 0; i < 2; ++i)
2046 theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() <<
2047 "; LastParam = " << aTrim[i]->LastParameter() <<
2048 "; IntParameter = " << aPar[i] << "\n";
2054 #include <math_GlobOptMin.hxx>
2055 #include <math_MultipleVarFunctionWithHessian.hxx>
2056 //=======================================================================
2057 //function : OCC25004
2058 //purpose : Check extremaCC on Branin function.
2059 //=======================================================================
2061 // f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s
2062 // Standard borders are:
2065 class BraninFunction : public math_MultipleVarFunctionWithHessian
2071 b = 5.1 / (4.0 * M_PI * M_PI);
2075 t = 1.0 / (8.0 * M_PI);
2077 virtual Standard_Integer NbVariables() const
2081 virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F)
2083 Standard_Real u = X(1);
2084 Standard_Real v = X(2);
2086 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2087 Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion.
2088 F = a * aSqPt * aSqPt + aLnPt + s;
2089 return Standard_True;
2091 virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G)
2093 Standard_Real u = X(1);
2094 Standard_Real v = X(2);
2096 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2097 G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u);
2098 G(2) = 2 * a * aSqPt;
2100 return Standard_True;
2102 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
2107 return Standard_True;
2109 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H)
2114 Standard_Real u = X(1);
2115 Standard_Real v = X(2);
2117 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2118 Standard_Real aTmpPt = c - 2 * b *u; // Tmp part.
2119 H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u);
2120 H(1,2) = 2 * a * aTmpPt;
2124 return Standard_True;
2128 // Standard parameters.
2129 Standard_Real a, b, c, r, s, t;
2132 static Standard_Integer OCC25004 (Draw_Interpretor& theDI,
2133 Standard_Integer /*theNArg*/,
2134 const char** /*theArgs*/)
2136 BraninFunction aFunc;
2138 math_Vector aLower(1,2), aUpper(1,2);
2144 Standard_Integer aGridOrder = 16;
2145 math_Vector aFuncValues(1, aGridOrder * aGridOrder);
2147 Standard_Real aLipConst = 0;
2148 math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2);
2150 // Get Lipshitz constant estimation on regular grid.
2151 Standard_Integer i, j, idx = 1;
2152 for(i = 1; i <= aGridOrder; i++)
2154 for(j = 1; j <= aGridOrder; j++)
2156 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2157 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2159 aFunc.Value(aCurrPnt1, aFuncValues(idx));
2164 Standard_Integer k, l;
2165 Standard_Integer idx1, idx2;
2166 for(i = 1; i <= aGridOrder; i++)
2167 for(j = 1; j <= aGridOrder; j++)
2168 for(k = 1; k <= aGridOrder; k++)
2169 for(l = 1; l <= aGridOrder; l++)
2171 if (i == k && j == l)
2174 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2175 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2176 idx1 = (i - 1) * aGridOrder + j;
2178 aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0);
2179 aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0);
2180 idx2 = (k - 1) * aGridOrder + l;
2182 aCurrPnt1.Add(-aCurrPnt2);
2183 Standard_Real dist = aCurrPnt1.Norm();
2185 Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist;
2190 math_GlobOptMin aFinder(&aFunc, aLower, aUpper, aLipConst);
2192 //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475)
2194 Standard_Real anExtValue = aFinder.GetF();
2195 theDI << "F = " << anExtValue << "\n";
2197 Standard_Integer aNbExt = aFinder.NbExtrema();
2198 theDI << "NbExtrema = " << aNbExt << "\n";
2203 #include <OSD_Environment.hxx>
2204 #include <Plugin.hxx>
2205 #include <Plugin_Macro.hxx>
2206 #include <Resource_Manager.hxx>
2208 #define THE_QATEST_DOC_FORMAT "My Proprietary Format"
2210 #define QA_CHECK(theDesc, theExpr, theValue) \
2212 const bool isTrue = !!(theExpr); \
2213 std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \
2216 class Test_TDocStd_Application : public TDocStd_Application
2220 Test_TDocStd_Application ()
2222 // explicitly initialize resource manager
2223 myResources = new Resource_Manager ("");
2224 myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT);
2225 myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document");
2226 myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml");
2229 virtual Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString&) Standard_OVERRIDE
2231 return new XmlDrivers_DocumentRetrievalDriver ();
2233 virtual Handle(PCDM_StorageDriver) WriterFromFormat (const TCollection_ExtendedString&) Standard_OVERRIDE
2235 return new XmlDrivers_DocumentStorageDriver ("Test");
2237 virtual Standard_CString ResourcesName() Standard_OVERRIDE { return ""; }
2240 //=======================================================================
2241 //function : OCC24925
2243 //=======================================================================
2244 static Standard_Integer OCC24925 (Draw_Interpretor& theDI,
2245 Standard_Integer theArgNb,
2246 const char** theArgVec)
2251 std::cout << "Error: wrong syntax! See usage:\n";
2252 theDI.PrintHelp (theArgVec[0]);
2256 Standard_Integer anArgIter = 1;
2257 TCollection_ExtendedString aFileName = theArgVec[anArgIter++];
2258 TCollection_AsciiString aPlugin = "TKXml";
2259 TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx
2260 TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx
2261 if (anArgIter < theArgNb)
2263 aPlugin = theArgVec[anArgIter++];
2264 aSaver = theArgVec[anArgIter++];
2265 aLoader = theArgVec[anArgIter++];
2268 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2269 PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError;
2271 Handle(TDocStd_Application) anApp = new Test_TDocStd_Application ();
2273 Handle(TDocStd_Document) aDoc;
2274 anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc);
2275 TDF_Label aLab = aDoc->Main();
2276 TDataStd_Integer::Set (aLab, 0);
2277 TDataStd_Name::Set (aLab, "QABugs_19.cxx");
2279 aSStatus = anApp->SaveAs (aDoc, aFileName);
2280 anApp->Close (aDoc);
2282 QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true);
2285 Handle(TDocStd_Document) aDoc;
2286 aRStatus = anApp->Open (aFileName, aDoc);
2287 anApp->Close (aDoc);
2289 QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true);
2293 //=======================================================================
2294 //function : OCC25043
2296 //=======================================================================
2297 #include <BRepAlgoAPI_Check.hxx>
2298 static Standard_Integer OCC25043 (Draw_Interpretor& theDI,
2299 Standard_Integer theArgNb,
2300 const char** theArgVec)
2302 if (theArgNb != 2) {
2303 theDI << "Usage: " << theArgVec[0] << " shape\n";
2307 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
2308 if (aShape.IsNull())
2310 theDI << theArgVec[1] << " shape is NULL\n";
2314 BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True);
2316 if (!anAlgoApiCheck.IsValid())
2318 BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result());
2319 for (; anCheckIter.More(); anCheckIter.Next())
2321 const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value();
2322 const TopTools_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1();
2323 TopTools_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes);
2324 for (; aFaultyIter.More(); aFaultyIter.Next())
2326 const TopoDS_Shape& aFaultyShape = aFaultyIter.Value();
2328 Standard_Boolean anIsFaultyShapeFound = Standard_False;
2329 TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType());
2330 for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next())
2332 if (anExp.Current().IsEqual(aFaultyShape))
2333 anIsFaultyShapeFound = Standard_True;
2336 if (!anIsFaultyShapeFound)
2338 theDI << "Error. Faulty Shape is NOT found in source shape.\n";
2343 theDI << "Info. Faulty shape is found in source shape\n";
2350 theDI << "Problems are not detected. Test is not performed.";
2356 //=======================================================================
2357 //function : OCC24606
2359 //=======================================================================
2360 static Standard_Integer OCC24606 (Draw_Interpretor& theDI,
2361 Standard_Integer theArgNb,
2362 const char** theArgVec)
2366 std::cerr << "Error: incorrect number of arguments.\n";
2367 theDI << "Usage : " << theArgVec[0] << "\n";
2371 Handle(V3d_View) aView = ViewerTest::CurrentView();
2374 std::cerr << "Errro: no active view, please call 'vinit'.\n";
2378 aView->DepthFitAll();
2384 //=======================================================================
2385 //function : OCC25202
2387 //=======================================================================
2388 #include <ShapeBuild_ReShape.hxx>
2389 static Standard_Integer OCC25202 ( Draw_Interpretor& theDI,
2390 Standard_Integer theArgN,
2391 const char** theArgVal)
2394 //reshape res shape numF1 face1 numF2 face2
2397 theDI << "Use: reshape res shape numF1 face1 numF2 face2\n";
2401 TopoDS_Shape aShape = DBRep::Get(theArgVal[2]);
2402 const Standard_Integer aNumOfRE1 = Draw::Atoi(theArgVal[3]),
2403 aNumOfRE2 = Draw::Atoi(theArgVal[5]);
2404 TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])),
2405 aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6]));
2409 theDI << theArgVal[2] << " is null shape\n";
2413 if(aShapeForRepl1.IsNull())
2415 theDI << theArgVal[4] << " is not a replaced type\n";
2419 if(aShapeForRepl2.IsNull())
2421 theDI << theArgVal[6] << " is not a replaced type\n";
2426 TopoDS_Shape aReplacedShape;
2427 ShapeBuild_ReShape aReshape;
2429 //////////////////// explode (begin)
2430 TopTools_MapOfShape M;
2432 Standard_Integer aNbShapes = 0;
2433 for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next())
2435 const TopoDS_Shape& Sx = ex.Current();
2436 Standard_Boolean added = M.Add(Sx);
2440 if(aNbShapes == aNumOfRE1)
2442 aReplacedShape = Sx;
2444 aReshape.Replace(aReplacedShape, aShapeForRepl1);
2447 if(aNbShapes == aNumOfRE2)
2449 aReplacedShape = Sx;
2451 aReshape.Replace(aReplacedShape, aShapeForRepl2);
2455 //////////////////// explode (end)
2457 if(aReplacedShape.IsNull())
2459 theDI << "There is not any shape for replacing.\n";
2462 DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2));
2467 #include <ShapeFix_Wireframe.hxx>
2468 //=======================================================================
2469 //function : OCC7570
2471 //=======================================================================
2472 static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2475 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
2478 TopoDS_Shape in_shape (DBRep::Get (a[1]));
2479 ShapeFix_Wireframe fix_tool (in_shape);
2480 fix_tool.ModeDropSmallEdges () = Standard_True;
2481 fix_tool.SetPrecision (1.e+6);
2482 fix_tool.SetLimitAngle (0.01);
2483 fix_tool.FixSmallEdges ();
2484 TopoDS_Shape new_shape = fix_tool.Shape ();
2488 #include <AIS_TypeFilter.hxx>
2489 //=======================================================================
2490 //function : OCC25340
2492 //=======================================================================
2493 static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/,
2494 Standard_Integer /*theArgNb*/,
2495 const char** /*theArgVec*/)
2497 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2500 std::cerr << "Error: No opened viewer!\n";
2503 Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
2504 aCtx->AddFilter (aFilter);
2508 //=======================================================================
2509 //function : OCC24826
2511 //=======================================================================
2512 class ParallelTest_Saxpy
2515 typedef NCollection_Array1<Standard_Real> Vector;
2518 ParallelTest_Saxpy(const Vector& theX, Vector& theY, Standard_Real theScalar)
2525 //! Dummy calculation
2526 void operator() (const Standard_Integer theIndex) const
2528 myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex);
2532 ParallelTest_Saxpy( const ParallelTest_Saxpy& );
2533 ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& );
2538 const Standard_Real myScalar;
2541 //---------------------------------------------------------------------
2542 static Standard_Integer OCC24826(Draw_Interpretor& theDI,
2543 Standard_Integer trheArgc,
2544 const char** theArgv)
2546 if ( trheArgc != 2 )
2555 Standard_Integer aLength = Draw::Atoi(theArgv[1]);
2557 NCollection_Array1<Standard_Real> aX (0, aLength - 1);
2558 NCollection_Array1<Standard_Real> anY(0, aLength - 1);
2560 for ( Standard_Integer i = 0; i < aLength; ++i )
2562 aX(i) = anY(i) = (Standard_Real) i;
2569 //! Serial proccesing
2570 for ( Standard_Integer i = 0; i < aLength; ++i )
2572 anY(i) = 1e-6 * aX(i) + anY(i);
2576 cout << "Processing time (sequential mode):\n";
2579 const ParallelTest_Saxpy aFunctor(aX, anY, 1e-6);
2584 // Parallel processing
2585 OSD_Parallel::For(0, aLength, aFunctor);
2588 cout << "Processing time (parallel mode):\n";
2594 /*****************************************************************************/
2596 #include <GeomAPI_IntSS.hxx>
2597 //=======================================================================
2598 //function : OCC25100
2600 //=======================================================================
2601 static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2605 di << "the method requires a shape name\n";
2609 TopoDS_Shape S = DBRep::Get(argv[1]);
2612 di << "Shape is empty\n";
2616 TopExp_Explorer aFaceExp(S, TopAbs_FACE);
2617 const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current()));
2619 GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion());
2621 if (!anIntersector.IsDone())
2623 di << "Error. Intersection is not done\n";
2627 di << "Test complete\n";
2632 //=======================================================================
2633 //function : OCC25348
2635 //=======================================================================
2636 static Standard_Integer OCC25348 (Draw_Interpretor& theDI,
2637 Standard_Integer /*theArgNb*/,
2638 const char** /*theArgVec*/)
2640 Handle(NCollection_IncAllocator) anAlloc1;
2641 NCollection_List<int> aList1(anAlloc1);
2642 for (int i=0; i < 10; i++)
2644 Handle(NCollection_IncAllocator) anAlloc2;
2645 NCollection_List<int> aList2(anAlloc2);
2647 aList1.Assign(aList2);
2649 theDI << "Test complete\n";
2653 #include <IntCurvesFace_ShapeIntersector.hxx>
2654 #include <BRepBndLib.hxx>
2655 //=======================================================================
2656 //function : OCC25413
2658 //=======================================================================
2659 static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
2662 di << "Usage: " << a[0] << " invalid number of arguments\n";
2665 TopoDS_Shape aShape = DBRep::Get (a[1]);
2667 IntCurvesFace_ShapeIntersector Inter;
2668 Inter.Load(aShape, Precision::Confusion());
2671 BRepBndLib::Add(aShape, aBndBox);
2673 gp_Dir aDir(0., 1., 0.);
2675 Standard_Real xMin = aBndBox.CornerMin().X();
2676 Standard_Real zMin = aBndBox.CornerMin().Z();
2677 Standard_Real xMax = aBndBox.CornerMax().X();
2678 Standard_Real zMax = aBndBox.CornerMax().Z();
2679 Standard_Real xStep = (xMax - xMin) / N;
2680 Standard_Real zStep = (zMax - zMin) / N;
2682 for (Standard_Real x = xMin; x <= xMax; x += xStep)
2683 for (Standard_Real z = zMin; z <= zMax; z += zStep)
2685 gp_Pnt aPoint(x, 0.0, z);
2686 gp_Lin aLine(aPoint, aDir);
2687 Inter.PerformNearest(aLine, -100., 100.);
2693 #include <BOPAlgo_PaveFiller.hxx>
2695 #include <BRepAlgoAPI_BooleanOperation.hxx>
2696 #include <BRepAlgoAPI_Common.hxx>
2697 #include <BRepAlgoAPI_Fuse.hxx>
2698 #include <BRepAlgoAPI_Cut.hxx>
2699 #include <BRepAlgoAPI_Section.hxx>
2701 #include <TopExp.hxx>
2702 #include <TopTools_MapOfShape.hxx>
2703 //=======================================================================
2704 //function : OCC25446
2706 //=======================================================================
2707 static Standard_Integer OCC25446 (Draw_Interpretor& theDI,
2708 Standard_Integer argc,
2712 theDI << "Usage: OCC25446 res b1 b2 op\n";
2716 TopoDS_Shape aS1 = DBRep::Get(argv[2]);
2718 theDI << argv[2] << " shape is NULL\n";
2722 TopoDS_Shape aS2 = DBRep::Get(argv[3]);
2724 theDI << argv[3] << " shape is NULL\n";
2728 Standard_Integer iOp;
2729 BOPAlgo_Operation aOp;
2731 iOp = Draw::Atoi(argv[4]);
2732 if (iOp < 0 || iOp > 4) {
2733 theDI << "Invalid operation type\n";
2736 aOp = (BOPAlgo_Operation)iOp;
2738 Standard_Integer iErr;
2739 TopTools_ListOfShape aLS;
2740 BOPAlgo_PaveFiller aPF;
2744 aPF.SetArguments(aLS);
2747 iErr = aPF.HasErrors();
2749 theDI << "Intersection failed with error status: " << iErr << "\n";
2753 BRepAlgoAPI_BooleanOperation* pBuilder = NULL;
2756 case BOPAlgo_COMMON:
2757 pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF);
2760 pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
2763 pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF);
2766 pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
2768 case BOPAlgo_SECTION:
2769 pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF);
2775 iErr = pBuilder->HasErrors();
2776 if (!pBuilder->IsDone()) {
2777 theDI << "BOP failed with error status: " << iErr << "\n";
2781 const TopoDS_Shape& aRes = pBuilder->Shape();
2782 DBRep::Set(argv[1], aRes);
2784 TopTools_MapOfShape aMapArgs, aMapShape;
2785 TopTools_MapIteratorOfMapOfShape aIt;
2786 Standard_Boolean bIsDeletedHist, bIsDeletedMap;
2787 TopAbs_ShapeEnum aType;
2789 TopExp::MapShapes(aS1, aMapArgs);
2790 TopExp::MapShapes(aS2, aMapArgs);
2791 TopExp::MapShapes(aRes, aMapShape);
2793 aIt.Initialize(aMapArgs);
2794 for (; aIt.More(); aIt.Next()) {
2795 const TopoDS_Shape& aS = aIt.Value();
2796 aType = aS.ShapeType();
2797 if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
2798 aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
2802 bIsDeletedHist = pBuilder->IsDeleted(aS);
2803 bIsDeletedMap = !aMapShape.Contains(aS) &&
2804 (pBuilder->Modified(aS).Extent() == 0);
2806 if (bIsDeletedHist != bIsDeletedMap) {
2807 theDI << "Error. Wrong value of IsDeleted flag.\n";
2812 theDI << "Test complete\n";
2816 //====================================================
2817 // Auxiliary functor class for the command OCC25545;
2818 // it gets access to a vertex with the given index and
2819 // checks that X coordinate of the point is equal to index;
2820 // if it is not so then a data race is reported.
2821 //====================================================
2822 struct OCC25545_Functor
2824 OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
2825 : myShapeVec(&theShapeVec),
2829 void operator()(size_t i) const
2831 if (!myIsRaceDetected) {
2832 const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i));
2833 gp_Pnt aP = BRep_Tool::Pnt (aV);
2834 if (aP.X () != static_cast<double> (i)) {
2835 Standard_Atomic_Increment(&myIsRaceDetected);
2840 const std::vector<TopoDS_Shape>* myShapeVec;
2841 mutable volatile int myIsRaceDetected;
2844 //=======================================================================
2845 //function : OCC25545
2846 //purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation()
2847 //=======================================================================
2849 static Standard_Integer OCC25545 (Draw_Interpretor& di,
2853 // Place vertices in a vector, giving the i-th vertex the
2854 // transformation that translates it on the vector (i,0,0) from the origin.
2855 Standard_Integer n = 1000;
2856 std::vector<TopoDS_Shape> aShapeVec (n);
2857 std::vector<TopLoc_Location> aLocVec (n);
2858 TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ());
2859 aShapeVec[0] = aShape;
2860 for (Standard_Integer i = 1; i < n; ++i) {
2862 aT.SetTranslation (gp_Vec (1, 0, 0));
2863 aLocVec[i] = aLocVec[i - 1] * aT;
2864 aShapeVec[i] = aShape.Moved (aLocVec[i]);
2867 // Evaluator function will access vertices geometry
2869 OCC25545_Functor aFunc(aShapeVec);
2871 // concurrently process
2872 OSD_Parallel::For (0, n, aFunc);
2874 QVERIFY (!aFunc.myIsRaceDetected);
2878 //=======================================================================
2879 //function : OCC25547
2881 //=======================================================================
2882 #include <BRepMesh_GeomTool.hxx>
2883 #include <BRepAdaptor_Curve.hxx>
2884 #include <Geom_TrimmedCurve.hxx>
2885 #include <BRepBuilderAPI_MakeFace.hxx>
2886 #include <BRepAdaptor_HSurface.hxx>
2887 #include <BRepAdaptor_Surface.hxx>
2888 static Standard_Integer OCC25547(
2889 Draw_Interpretor& theDI,
2890 Standard_Integer /*argc*/,
2891 const char ** /*argv*/)
2893 // The general aim of this test is to prevent linkage errors due to missed
2894 // Standard_EXPORT attribute for static methods.
2896 // However, start checking the main functionality at first.
2897 const Standard_Real aFirstP = 0., aLastP = M_PI;
2898 Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
2899 Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
2900 TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf);
2901 BRepAdaptor_Curve aAdaptor(aEdge);
2902 BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5);
2904 if (aGeomTool.NbPoints() == 0)
2906 theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
2910 // Test static methods.
2911 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
2912 BRepAdaptor_Surface aSurf(aFace);
2913 Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf);
2917 if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
2919 theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
2923 gp_XY aRefPnts[4] = {
2924 gp_XY(-10., -10.), gp_XY(10., 10.),
2925 gp_XY(-10., 10.), gp_XY(10., -10.)
2929 Standard_Real aParams[2];
2930 BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin(
2931 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
2932 aIntPnt.ChangeCoord(), aParams);
2934 Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
2935 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
2937 theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
2941 aIntFlag = BRepMesh_GeomTool::IntSegSeg(
2942 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
2943 Standard_False, Standard_False, aIntPnt);
2945 aDiff = aIntPnt.Distance(gp::Origin2d());
2946 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
2948 theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
2953 theDI << "Test complete\n";
2957 static Standard_Integer OCC26139 (Draw_Interpretor& theDI,
2958 Standard_Integer argc,
2962 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2965 theDI << "Use 'vinit' command before " << argv[0] << "\n";
2969 Standard_Integer aBoxGridSize = 100;
2970 Standard_Integer aCompGridSize = 3;
2971 Standard_Real aBoxSize = 5.0;
2975 for (Standard_Integer anArgIdx = 1; anArgIdx < argc; ++anArgIdx)
2977 TCollection_AsciiString anArg (argv[anArgIdx]);
2979 if (anArg == "-boxgrid")
2981 aBoxGridSize = Draw::Atoi (argv[++anArgIdx]);
2983 else if (anArg == "-compgrid")
2985 aCompGridSize = Draw::Atoi (argv[++anArgIdx]);
2987 else if (anArg == "-boxsize")
2989 aBoxSize = Draw::Atof (argv[++anArgIdx]);
2994 NCollection_List<Handle(AIS_Shape)> aCompounds;
2995 for (Standard_Integer aCompGridX = 0; aCompGridX < aCompGridSize; ++aCompGridX)
2997 for (Standard_Integer aCompGridY = 0; aCompGridY < aCompGridSize; ++aCompGridY)
2999 BRep_Builder aBuilder;
3000 TopoDS_Compound aComp;
3001 aBuilder.MakeCompound (aComp);
3002 for (Standard_Integer aBoxGridX = 0; aBoxGridX < aBoxGridSize; ++aBoxGridX)
3004 for (Standard_Integer aBoxGridY = 0; aBoxGridY < aBoxGridSize; ++aBoxGridY)
3006 BRepPrimAPI_MakeBox aBox (gp_Pnt (aBoxGridX * aBoxSize, aBoxGridY * aBoxSize, 0.0),
3007 aBoxSize, aBoxSize, aBoxSize);
3008 aBuilder.Add (aComp, aBox.Shape());
3012 aTrsf.SetTranslation (gp_Vec (aBoxGridSize * aBoxSize * aCompGridX,
3013 aBoxGridSize * aBoxSize * aCompGridY,
3015 TopLoc_Location aLoc (aTrsf);
3016 aComp.Located (aLoc);
3017 aCompounds.Append (new AIS_Shape (aComp));
3022 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3025 aCtx->Display (aCompIter.Value(), Standard_False);
3027 theDI << "Display time: " << aTimer.ElapsedTime() << "\n";
3033 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3035 aCtx->Remove (aCompIter.Value(), Standard_False);
3038 theDI << "Remove time: " << aTimer.ElapsedTime() << "\n";
3043 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
3044 #include <TColStd_DataMapOfIntegerInteger.hxx>
3046 #include <ShapeFix_Wire.hxx>
3047 #include <ShapeExtend_Status.hxx>
3049 #define EXCEPTION ...
3051 #define EXCEPTION Standard_Failure
3054 static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)& theFix,
3055 const Standard_Boolean theIs3d)
3057 for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++)
3059 Standard_Boolean isFound;
3061 isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i );
3063 isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i );
3064 if (isFound) return ShapeExtend_Status(i);
3066 return ShapeExtend_OK;
3069 //===================
3070 //function : OCC24881
3072 //===================
3073 static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
3076 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
3079 // cout <<"FileName1: " << argv[1] <<endl;
3081 TopoDS_Shape aShape = DBRep::Get (a[1]);
3084 Handle(ShapeFix_Wire) aWireFix = new ShapeFix_Wire;
3086 // map FixStatus - NbSuchStatuses
3087 TColStd_DataMapOfIntegerInteger aStatusNbDMap;
3088 Standard_Integer nbFixed=0, nbOk=0;
3091 ShapeExtend_Status aStatus=ShapeExtend_OK;
3093 TopExp_Explorer aFaceExplorer(aShape, TopAbs_FACE);
3094 for (; aFaceExplorer.More(); aFaceExplorer.Next())
3096 TopoDS_Shape aFace = aFaceExplorer.Current();
3098 TopoDS_Iterator aWireItr(aFace);
3099 for (; aWireItr.More(); aWireItr.Next() )
3101 Standard_Boolean wasOk = Standard_False;
3102 TopoDS_Wire aSrcWire = TopoDS::Wire(aWireItr.Value());
3104 aWireFix->Load (aSrcWire);
3105 aWireFix->SetFace (TopoDS::Face(aFace));
3106 aWireFix->FixReorder(); //correct order is a prerequisite
3108 if (!aWireFix->FixGaps3d())
3111 aStatus = getStatusGap(aWireFix, Standard_True);
3112 if (aStatus == ShapeExtend_OK)
3113 wasOk = Standard_True;
3116 // keep 3d fail status
3117 if (aStatusNbDMap.IsBound (aStatus))
3118 aStatusNbDMap(aStatus)++;
3120 aStatusNbDMap.Bind(aStatus,1);
3126 if (aWireFix->FixGaps2d())
3130 aStatus = getStatusGap(aWireFix, Standard_False);
3131 if (aStatus == ShapeExtend_OK)
3143 // keep 2d fail status
3144 Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL;
3145 if (aStatusNbDMap.IsBound (aStatus2d))
3146 aStatusNbDMap(aStatus2d)++;
3148 aStatusNbDMap.Bind(aStatus2d,1);
3155 } catch (EXCEPTION) {
3156 di << "Exception is raised = " <<aStatus << "\n";
3160 // report what is done
3164 di <<"Fix_FillGaps_Fixed: nbFixed = "<<nbFixed <<"\n";
3169 di << "Fix_FillGaps_NothingToDo\n";
3172 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aStatusItr(aStatusNbDMap);
3173 for (; aStatusItr.More(); aStatusItr.Next())
3175 switch ((ShapeExtend_Status) aStatusItr.Key())
3178 case ShapeExtend_FAIL1:
3179 di <<"Fix_FillGaps_3dNoCurveFail, nb failed = ";
3181 case ShapeExtend_FAIL2:
3182 di <<"Fix_FillGaps_3dSomeGapsFail, nb failed = ";
3186 switch ((ShapeExtend_Status) (aStatusItr.Key() - ShapeExtend_FAIL))
3188 case ShapeExtend_FAIL1:
3189 di <<"Fix_FillGaps_2dNoPCurveFail, nb failed = ";
3191 case ShapeExtend_FAIL2:
3192 di <<"Fix_FillGaps_2dSomeGapsFail, nb failed = ";
3198 di <<aStatusItr.Value()<< "\n";
3200 di << ("__________________________________") <<"\n";
3205 //=======================================================================
3206 //function : OCC26284
3208 //=======================================================================
3209 static Standard_Integer OCC26284 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3213 std::cerr << "Error: wrong number of arguments! See usage:\n";
3214 theDI.PrintHelp (theArgVec[0]);
3218 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
3219 if (anAISContext.IsNull())
3221 std::cerr << "Error: no active view. Please call vinit.\n";
3225 BRepPrimAPI_MakeSphere aSphereBuilder (gp_Pnt (0.0, 0.0, 0.0), 1.0);
3226 Handle(AIS_Shape) aSphere = new AIS_Shape (aSphereBuilder.Shape());
3227 anAISContext->Display (aSphere, Standard_False);
3228 for (Standard_Integer aChildIdx = 0; aChildIdx < 5; ++aChildIdx)
3230 BRepPrimAPI_MakeSphere aBuilder (gp_Pnt (1.0 + aChildIdx, 1.0 + aChildIdx, 1.0 + aChildIdx), 1.0);
3231 Handle(AIS_Shape) aChild = new AIS_Shape (aBuilder.Shape());
3232 aSphere->AddChild (aChild);
3233 anAISContext->Display (aChild, Standard_False);
3236 anAISContext->RecomputeSelectionOnly (aSphere);
3237 anAISContext->UpdateCurrentViewer();
3242 #include <IntTools_Context.hxx>
3243 #include <GeomAPI_ProjectPointOnSurf.hxx>
3245 //=======================================================================
3246 //function : xprojponf
3248 //=======================================================================
3249 Standard_Integer xprojponf (Draw_Interpretor& di,
3254 di<<" use xprojponf p f \n";
3261 Handle(IntTools_Context) aCtx;
3263 DrawTrSurf::GetPoint(a[1], aP);
3264 aS=DBRep::Get(a[2]);
3267 di<<" null shape is not allowed\n";
3271 if (aS.ShapeType()!=TopAbs_FACE) {
3272 di << a[2] << " not a face\n";
3276 aCtx=new IntTools_Context;
3278 aF=TopoDS::Face(aS);
3279 GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF);
3282 if (!aPPS.IsDone()) {
3283 di<<" projection failed\n";
3287 aPS=aPPS.NearestPoint();
3288 di<< " point px " << aPS.X() << " " << aPS.Y() << " " << aPS.Z() << "\n";
3293 //=======================================================================
3294 //function : OCC25547
3296 //=======================================================================
3297 #include <BRepMesh_CircleTool.hxx>
3298 #include <SelectMgr_EntityOwner.hxx>
3300 static Standard_Boolean inspect_point(const gp_XY& thePoint,
3301 const gp_XY& theCenter,
3302 const Standard_Real theRadius)
3304 static Standard_Real aPrecision = Precision::PConfusion();
3305 static Standard_Real aSqPrecision = aPrecision * aPrecision;
3306 const gp_XY aDistVec = thePoint - theCenter;
3307 if (aDistVec.SquareModulus() - (theRadius * theRadius) < aSqPrecision)
3308 return Standard_True;
3310 return Standard_False;
3313 static Standard_Integer OCC24923(
3314 Draw_Interpretor& theDI,
3315 Standard_Integer argc,
3318 srand(static_cast<unsigned int>(time(NULL)));
3320 const Standard_Real aMaxDeviation = (argc > 1) ? Draw::Atof(argv[1]) : 0.01;
3321 const Standard_Integer aPointsNb = 10000000;
3322 const Standard_Real aMinAngle = 5 * M_PI / 180.;
3323 static Standard_Real aSqPrecision = Precision::PConfusion() * Precision::PConfusion();
3325 Standard_Integer aFailedNb = 0;
3326 for (Standard_Integer i = 0; i < aPointsNb; ++i)
3329 for (Standard_Integer j = 0; j < 3; ++j)
3330 p[j].SetCoord(((Standard_Real)rand())/RAND_MAX, ((Standard_Real)rand())/RAND_MAX);
3332 // Check that points do not compose degenerated triangle.
3333 gp_XY aVec1 = p[1] - p[0];
3334 gp_XY aVec2 = p[2] - p[0];
3335 if (aVec1.SquareModulus() > aSqPrecision &&
3336 aVec2.SquareModulus() > aSqPrecision &&
3337 (aVec1 ^ aVec2) > aMinAngle)
3340 Standard_Real aRadius;
3341 if (BRepMesh_CircleTool::MakeCircle(p[0], p[1], p[2], aCenter, aRadius))
3343 if (!inspect_point(p[0], aCenter, aRadius) ||
3344 !inspect_point(p[1], aCenter, aRadius) ||
3345 !inspect_point(p[2], aCenter, aRadius))
3347 /* theDI << "Missed: " <<
3348 "p1=(" << p1.X() << ", " << p1.Y() << "), " <<
3349 "p2=(" << p2.X() << ", " << p2.Y() << "), " <<
3350 "p3=(" << p3.X() << ", " << p3.Y() << "), " <<
3351 "c=(" << aCenter.X() << ", " << aCenter.Y() << "), " <<
3352 "r=" << aRadius << "\n";*/
3361 // Ensure that aPointsNb suitable for tests are generated
3365 const Standard_Real aDeviation =
3366 1. - (Standard_Real)(aPointsNb - aFailedNb) / (Standard_Real)aPointsNb;
3368 theDI << "Number of incorrect cases: " << aFailedNb << " (Total " << aPointsNb << ")\n";
3369 if (aDeviation > aMaxDeviation)
3371 theDI << "Failed. Number of incorrect results is too huge: " <<
3372 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
3376 theDI << "Deviation of incorrect results is: " <<
3377 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
3378 theDI << "Test completed\n";
3382 //=======================================================================
3383 //function : OCC25574
3384 //purpose : check implementation of Euler angles in gp_Quaternion
3385 //=======================================================================
3387 static Standard_Integer OCC25574 (Draw_Interpretor& theDI, Standard_Integer /*argc*/, const char** /*argv*/)
3389 Standard_Boolean isTestOk = Standard_True;
3391 // Check consistency of Get and Set operations for Euler angles
3392 gp_Quaternion aQuat;
3393 aQuat.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637);
3394 Standard_Real alpha,beta,gamma;
3395 gp_Mat aRinv = aQuat.GetMatrix().Inverted();
3398 const char* names[] = { "Extrinsic_XYZ", "Extrinsic_XZY", "Extrinsic_YZX", "Extrinsic_YXZ", "Extrinsic_ZXY", "Extrinsic_ZYX",
3399 "Intrinsic_XYZ", "Intrinsic_XZY", "Intrinsic_YZX", "Intrinsic_YXZ", "Intrinsic_ZXY", "Intrinsic_ZYX",
3400 "Extrinsic_XYX", "Extrinsic_XZX", "Extrinsic_YZY", "Extrinsic_YXY", "Extrinsic_ZYZ", "Extrinsic_ZXZ",
3401 "Intrinsic_XYX", "Intrinsic_XZX", "Intrinsic_YZY", "Intrinsic_YXY", "Intrinsic_ZXZ", "Intrinsic_ZYZ" };
3402 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3404 aQuat.GetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma);
3406 gp_Quaternion aQuat2;
3407 aQuat2.SetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma);
3409 gp_Mat aR = aQuat2.GetMatrix();
3410 gp_Mat aDiff = aR * aRinv - aI;
3411 if (aDiff.Determinant() > 1e-5)
3413 theDI << "Error: Euler angles conversion incorrect for sequence " << names[i - gp_Extrinsic_XYZ] << "\n";
3414 isTestOk = Standard_False;
3418 // Check conversion between intrinsic and extrinsic rotations
3419 // Any extrinsic rotation is equivalent to an intrinsic rotation
3420 // by the same angles but with inverted order of elemental rotations, and vice versa
3422 // Extrinsic_XZY = Incrinsic_XZY
3423 // R = X(A)Z(B)Y(G) --> R = Y(G)Z(B)X(A)
3424 alpha = 0.1517461713131;
3425 beta = 1.5162198410141;
3426 gamma = 1.9313156236541;
3427 Standard_Real alpha2, beta2, gamma2;
3428 gp_EulerSequence pairs[][2] = { {gp_Extrinsic_XYZ, gp_Intrinsic_ZYX},
3429 {gp_Extrinsic_XZY, gp_Intrinsic_YZX},
3430 {gp_Extrinsic_YZX, gp_Intrinsic_XZY},
3431 {gp_Extrinsic_YXZ, gp_Intrinsic_ZXY},
3432 {gp_Extrinsic_ZXY, gp_Intrinsic_YXZ},
3433 {gp_Extrinsic_ZYX, gp_Intrinsic_XYZ} };
3434 for (int i = 0; i < 6; i++)
3436 aQuat.SetEulerAngles(pairs[i][0], alpha, beta, gamma);
3437 aQuat.GetEulerAngles(pairs[i][1], gamma2, beta2, alpha2);
3439 if (Abs(alpha - alpha2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - gamma2) > 1e-5)
3441 theDI << "Error: intrinsic and extrinsic conversion incorrect for sequence " << names[i] << "\n";
3442 isTestOk = Standard_False;
3446 // Check correspondence of enumeration and actual rotation it defines,
3447 // by rotation by one axis and checking that it does not change a point on that axis
3448 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3450 // Iterate over rotations R(A)R(B)R(G) for each Euler angle Alpha, Beta, Gamma
3451 // There are three ordered axes corresponding to three rotations.
3452 // Each rotation applyed with current angle around current axis.
3453 for (int j=0; j < 3; j++)
3455 // note that current axis index is obtained by parsing of enumeration name!
3456 int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X';
3457 Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1);
3459 // Set 90 degrees to current Euler angle
3460 double anAngles[3] = {0., 0., 0.};
3461 anAngles[j] = 0.5 * M_PI;
3464 q2.SetEulerAngles (gp_EulerSequence(i), anAngles[0], anAngles[1], anAngles[2]);
3466 // Set point on axis corresponding to current rotation
3467 // We will apply rotation around this axis
3468 gp_XYZ v (0., 0., 0.);
3469 v.SetCoord (anAxis + 1, 1.);
3471 // Apply rotation to point
3473 aT.SetRotation (q2);
3477 // Check that point is still on origin position
3478 if ((v - v2).SquareModulus() > Precision::SquareConfusion())
3480 // avoid reporting small coordinates
3481 for (int k=1; k <= 3; k++)
3482 if (Abs (v2.Coord(k)) < Precision::Confusion())
3483 v2.SetCoord (k, 0.);
3485 isTestOk = Standard_False;
3486 theDI << "Error: Euler sequence " << names[i - gp_Extrinsic_XYZ] << " is incorrect:\n";
3487 theDI << "rotating by angle 90 deg around " << (anAxis == 0 ? "X" : anAxis == 1 ? "Y" : "Z") <<
3488 " converts vector (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") to ("
3489 << v2.X() << ", " << v2.Y() << ", " << v2.Z() << ")\n";
3494 // Check correspondence of enumeration and actual rotation it defines,
3495 // by comparing cumulative rotation matrix with sequence of rotations by axes
3496 const Standard_Real anAngle[3] = { 0.1, 0.2, 0.3 };
3497 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3499 // Sequence of rotations
3501 for (int j=0; j < 3; j++)
3503 // note that current axis index is obtained by parsing of enumeration name!
3504 int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X';
3505 Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1);
3507 // Set point on axis corresponding to current rotation
3508 // We will apply rotation around this axis
3509 gp_XYZ v (0., 0., 0.);
3510 v.SetCoord (anAxis + 1, 1.);
3511 aR[j].SetRotation (v, anAngle[j]);
3514 // construct cumulative transformation (differently for extrinsic and intrinsic rotations);
3515 // note that we parse first symbol of the enum name to identify its type
3517 if (names[i - gp_Extrinsic_XYZ][0] == 'E') // extrinsic
3519 aRot = aR[2] * aR[1] * aR[0];
3523 aRot = aR[0] * aR[1] * aR[2];
3526 // set the same angles in quaternion
3527 aQuat.SetEulerAngles (gp_EulerSequence(i), anAngle[0], anAngle[1], anAngle[2]);
3529 gp_Mat aRQ = aQuat.GetMatrix();
3530 gp_Mat aDiff = aRQ * aRot.Inverted() - aI;
3531 if (aDiff.Determinant() > 1e-5)
3533 theDI << "Error: Euler angles conversion does not correspond to sequential rotations for " << names[i - gp_Extrinsic_XYZ] << "\n";
3534 isTestOk = Standard_False;
3538 // similar checkfor YawPitchRoll sequence as defined in description of #25574
3540 // Start with world coordinate system
3543 // Perform three rotations using the yaw-pitch-roll convention.
3544 // This means: rotate around the original z axis with angle alpha,
3545 // then rotate around the new y axis with angle beta,
3546 // then rotate around the new x axis with angle gamma.
3547 alpha = 0.0 / 180.0 * M_PI;
3548 beta = -35.0 / 180.0 * M_PI;
3549 gamma = 90.0 / 180.0 * M_PI;
3551 const gp_Quaternion rotationZ(world.Direction(), alpha);
3552 const gp_Vec rotY = rotationZ.Multiply(world.YDirection());
3553 const gp_Vec rotX = rotationZ.Multiply(world.XDirection());
3555 const gp_Quaternion rotationY(rotY, beta);
3556 const gp_Vec rotZ = rotationY.Multiply(world.Direction());
3557 const gp_Vec rotRotX = rotationY.Multiply(rotX);
3559 const gp_Quaternion rotationX(rotRotX, gamma);
3560 const gp_Vec rotRotZ = rotationX.Multiply(rotZ);
3562 gp_Ax2 result(gp_Pnt(0.0, 0.0, 0.0), rotRotZ, rotRotX);
3564 // Now compute the Euler angles
3565 gp_Trsf transformation;
3566 transformation.SetDisplacement(gp_Ax2(), result);
3568 Standard_Real computedAlpha;
3569 Standard_Real computedBeta;
3570 Standard_Real computedGamma;
3572 transformation.GetRotation().GetEulerAngles(gp_YawPitchRoll, computedAlpha, computedBeta, computedGamma);
3574 // We expect now to get the same angles as we have used for our rotations
3575 if (Abs(alpha - computedAlpha) > 1e-5 || Abs(beta - computedBeta) > 1e-5 || Abs(gamma - computedGamma) > 1e-5)
3577 theDI << "Error: unexpected values of Euler angles for YawPitchRoll sequence:\n";
3578 theDI << "alpha: " << alpha / M_PI * 180.0 << " and computed alpha: "
3579 << computedAlpha / M_PI * 180.0 << "\n";
3580 theDI << "beta: " << beta / M_PI * 180.0 << " and computed beta: "
3581 << computedBeta / M_PI * 180.0 << "\n";
3582 theDI << "gamma: " << gamma / M_PI * 180.0 << " and computed gamma: "
3583 << computedGamma / M_PI * 180.0 << "\n";
3584 isTestOk = Standard_False;
3591 q.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637);
3593 q.GetEulerAngles(gp_Intrinsic_ZYX, alpha,beta, gamma);
3594 q.GetEulerAngles(gp_Extrinsic_XYZ, alpha2,beta2,gamma2);
3596 // gp_Intrinsic_ZYX and gp_Extrinsic_XYZ should produce the same values of angles but in opposite order
3597 if (Abs(alpha - gamma2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - alpha2) > 1e-5)
3599 theDI << "Error: Euler angles computed for gp_Intrinsic_ZYX and gp_Extrinsic_XYZ do not match:\n";
3600 theDI << "alpha: " << alpha / M_PI * 180.0 << " and " << alpha2 / M_PI * 180.0 << "\n";
3601 theDI << "beta: " << beta / M_PI * 180.0 << " and " << beta2 / M_PI * 180.0 << "\n";
3602 theDI << "gamma: " << gamma / M_PI * 180.0 << " and " << gamma2 / M_PI * 180.0 << "\n";
3603 isTestOk = Standard_False;
3607 theDI << (isTestOk ? "Test completed" : "Test failed") << "\n";
3611 #include <TColGeom_Array1OfBSplineCurve.hxx>
3612 #include <TColStd_Array1OfReal.hxx>
3613 #include <TColGeom_HArray1OfBSplineCurve.hxx>
3614 #include <GeomConvert.hxx>
3616 //=======================================================================
3617 //function : OCC26446
3619 //=======================================================================
3620 Standard_Integer OCC26446 (Draw_Interpretor& di,
3625 di << "Usage: OCC26446 r c1 c2\n";
3629 Handle(Geom_BSplineCurve) aCurve1 =
3630 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[2]));
3631 Handle(Geom_BSplineCurve) aCurve2 =
3632 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[3]));
3634 if (aCurve1.IsNull()) {
3635 di << a[2] << " is not a BSpline curve\n";
3639 if (aCurve2.IsNull()) {
3640 di << a[3] << " is not a BSpline curve\n";
3644 TColGeom_Array1OfBSplineCurve aCurves (0, 1);
3645 TColStd_Array1OfReal aTolerances (0, 0);
3646 Standard_Real aTolConf = 1.e-3;
3647 Standard_Real aTolClosure = Precision::Confusion();
3648 Handle(TColGeom_HArray1OfBSplineCurve) aConcatCurves;
3649 Handle(TColStd_HArray1OfInteger) anIndices;
3651 aCurves.SetValue(0, aCurve1);
3652 aCurves.SetValue(1, aCurve2);
3653 aTolerances.SetValue(0, aTolConf);
3655 GeomConvert::ConcatC1(aCurves,
3662 Handle(Geom_BSplineCurve) aResult =
3663 aConcatCurves->Value(aConcatCurves->Lower());
3665 DrawTrSurf::Set(a[1], aResult);
3669 static Standard_Integer OCC26448 (Draw_Interpretor& theDI, Standard_Integer, const char **)
3671 TColStd_SequenceOfReal aSeq1, aSeq2;
3673 aSeq1.Prepend (aSeq2);
3674 theDI << "TCollection: 11 -> " << aSeq1.First() << "\n";
3676 NCollection_Sequence<Standard_Real> nSeq1, nSeq2;
3678 nSeq1.Prepend (nSeq2);
3679 theDI << "NCollection: 11 -> " << nSeq1.First() << "\n";
3685 //=======================================================================
3686 //function : OCC26407
3688 //=======================================================================
3689 #include <BRepBuilderAPI_MakeWire.hxx>
3690 #include <BRepBuilderAPI_MakeEdge.hxx>
3691 #include <BRepMesh_IncrementalMesh.hxx>
3692 #include <TCollection_AsciiString.hxx>
3693 static Standard_Integer OCC26407 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3697 std::cerr << "Error: wrong number of arguments! See usage:\n";
3698 theDI.PrintHelp (theArgVec[0]);
3702 // Construct vertices.
3703 std::vector<TopoDS_Vertex> wire_vertices;
3704 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.90000000000009094947, 40.6758179230516248026106, 88.5)));
3705 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(807.824182076948432040808, 260.599999999999965893949, 88.5)));
3706 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(644.174182076948454778176, 424.249999999999943156581, 88.5000000000000142108547)));
3707 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(629.978025792618950617907, 424.25, 88.5)));
3708 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(793.628025792618700506864, 260.599999999999852207111, 88.5)));
3709 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.900000000000204636308, 54.8719742073813492311274, 88.5)));
3710 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(218.521974207381418864315, 424.250000000000056843419, 88.5)));
3711 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(204.325817923051886282337, 424.249999999999943156581, 88.5)));
3714 BRepBuilderAPI_MakeWire wire_builder;
3715 for (size_t i = 0; i < wire_vertices.size(); i++)
3717 const TopoDS_Vertex &v = wire_vertices[i];
3718 const TopoDS_Vertex &w = wire_vertices[(i+1) % wire_vertices.size()];
3720 wire_builder.Add(BRepBuilderAPI_MakeEdge(v, w));
3723 // Create face and triangulate it.
3725 gp_Pnt v0 = BRep_Tool::Pnt(wire_vertices[0]);
3726 gp_Pnt v1 = BRep_Tool::Pnt(wire_vertices[1]);
3727 gp_Pnt v2 = BRep_Tool::Pnt(wire_vertices[wire_vertices.size() - 1]);
3729 gp_Vec face_normal = gp_Vec(v0, v1).Crossed(gp_Vec(v0, v2));
3731 TopoDS_Face face = BRepBuilderAPI_MakeFace(gp_Pln(v0, face_normal), wire_builder);
3732 BRepMesh_IncrementalMesh m(face, 1e-7);
3734 if (m.GetStatusFlags() != 0)
3736 theDI << "Failed. Status for face constructed from vertices: " << m.GetStatusFlags() << "\n";
3739 DBRep::Set(theArgVec[1], face);
3741 sprintf(buf, "isos %s 0", theArgVec[1]);
3744 sprintf(buf, "triangles %s", theArgVec[1]);
3747 theDI.Eval("smallview; fit");
3749 theDI << "Test completed\n";
3753 //=======================================================================
3754 //function : OCC26485
3756 //=======================================================================
3758 static Standard_Integer OCC26485 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3762 std::cerr << "Error: wrong number of arguments! See usage:\n";
3763 theDI.PrintHelp (theArgVec[0]);
3767 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
3768 if (aShape.IsNull())
3770 theDI << "Failed. Null shape\n";
3774 Standard_Boolean isFailed = Standard_False;
3775 TopExp_Explorer aExplorer(aShape, TopAbs_FACE);
3776 for (; aExplorer.More(); aExplorer.Next())
3778 const TopoDS_Face& aFace = TopoDS::Face( aExplorer.Current() );
3779 TopLoc_Location L = TopLoc_Location();
3780 const Handle(Poly_Triangulation)& aT = BRep_Tool::Triangulation( aFace , L );
3785 Poly::ComputeNormals(aT);
3786 const TColgp_Array1OfPnt& aVertices = aT->Nodes();
3787 const TShort_Array1OfShortReal& aNormals = aT->Normals();
3789 // Number of nodes in the triangulation
3790 int aVertexNb = aT->Nodes().Length();
3791 if (aVertexNb*3 != aNormals.Length())
3793 theDI << "Failed. Different number of normals vs. vertices\n";
3797 // Get each vertex index, checking common vertexes between shapes
3798 for( int i=0; i < aVertexNb; i++ )
3800 gp_Pnt aPoint = aVertices.Value( i+1 );
3801 gp_Vec aNormal = gp_Vec(
3802 aNormals.Value( i*3 + 1 ),
3803 aNormals.Value( i*3 + 2 ),
3804 aNormals.Value( i*3 + 3 ) );
3806 if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
3809 sprintf(buf, "fail_%d", i+1);
3810 theDI << "Failed. Point " << buf << ": "
3811 << aPoint.X() << " "
3812 << aPoint.Y() << " "
3813 << aPoint.Z() << "\n";
3815 DrawTrSurf::Set (buf, aPoint);
3820 theDI << (isFailed ? "Test failed" : "Test completed") << "\n";
3824 //=======================================================================
3825 //function : OCC26553
3827 //=======================================================================
3828 #include <BRepBuilderAPI_MakeWire.hxx>
3830 static Standard_Integer OCC26553 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
3834 theDI << "Error: path to file with shell is missing\n";
3838 BRep_Builder aBuilder;
3839 TopoDS_Shape aShell;
3840 BRepTools::Read(aShell, theArgv[1], aBuilder);
3842 if (aShell.IsNull())
3844 theDI << "Error: shell not loaded\n";
3848 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge (gp_Pnt (0, 0, 0), gp_Pnt (0, 0, 10));
3849 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
3851 BRepOffsetAPI_MakePipe aPipeBuilder(aPipeWire, aShell);
3852 if (!aPipeBuilder.IsDone())
3854 theDI << "Error: failed to create pipe\n";
3858 for (TopExp_Explorer aShapeExplorer(aShell, TopAbs_EDGE); aShapeExplorer.More(); aShapeExplorer.Next ()) {
3859 const TopoDS_Shape& aGeneratedShape = aPipeBuilder.Generated(aPipeEdge, aShapeExplorer.Current());
3860 if (aGeneratedShape.IsNull())
3862 theDI << "Error: null shape\n";
3867 theDI << "History returned successfully\n";
3871 //=======================================================================
3872 //function : OCC26195
3874 //=======================================================================
3875 #include <SelectMgr_SelectingVolumeManager.hxx>
3876 #include <BRepBuilderAPI_MakePolygon.hxx>
3877 #include <Geom_CartesianPoint.hxx>
3878 #include <AIS_Line.hxx>
3879 #include <Aspect_Window.hxx>
3880 static Standard_Integer OCC26195 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3884 std::cerr << "Error: wrong number of arguments! See usage:\n";
3885 theDI.PrintHelp (theArgVec[0]);
3889 if (ViewerTest::GetAISContext().IsNull())
3891 std::cerr << "Error: No opened context!\n";
3895 gp_Pnt2d aPxPnt1, aPxPnt2;
3896 aPxPnt1.SetX (Draw::Atof (theArgVec[1]));
3897 aPxPnt1.SetY (Draw::Atof (theArgVec[2]));
3900 aPxPnt2.SetX (Draw::Atof (theArgVec[3]));
3901 aPxPnt2.SetY (Draw::Atof (theArgVec[4]));
3903 Standard_Boolean toPrint = Standard_False;
3904 if (theArgNb % 2 == 0)
3906 toPrint = Draw::Atoi (theArgVec[theArgNb - 1]) != 0;
3909 SelectMgr_SelectingVolumeManager* aMgr = new SelectMgr_SelectingVolumeManager();
3910 aMgr->SetActiveSelectionType (theArgNb > 4 ?
3911 SelectMgr_SelectingVolumeManager::Box : SelectMgr_SelectingVolumeManager::Point);
3912 aMgr->SetCamera (ViewerTest::CurrentView()->Camera());
3913 aMgr->SetPixelTolerance (ViewerTest::GetAISContext()->PixelTolerance());
3914 Standard_Integer aWidth, aHeight;
3915 ViewerTest::CurrentView()->View()->Window()->Size (aWidth, aHeight);
3916 aMgr->SetWindowSize (aWidth, aHeight);
3919 aMgr->BuildSelectingVolume (aPxPnt1, aPxPnt2);
3923 aMgr->BuildSelectingVolume (aPxPnt1);
3925 const gp_Pnt* aVerts = aMgr->GetVertices();
3926 gp_Pnt aNearPnt = aMgr->GetNearPickedPnt();
3927 gp_Pnt aFarPnt = aMgr->GetFarPickedPnt();
3928 BRepBuilderAPI_MakePolygon aWireBldrs[4];
3930 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
3931 aWireBldrs[0].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
3932 aWireBldrs[0].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
3933 aWireBldrs[0].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
3934 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
3936 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
3937 aWireBldrs[1].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
3938 aWireBldrs[1].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
3939 aWireBldrs[1].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
3940 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
3942 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
3943 aWireBldrs[2].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
3944 aWireBldrs[2].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
3945 aWireBldrs[2].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
3946 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
3948 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
3949 aWireBldrs[3].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
3950 aWireBldrs[3].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
3951 aWireBldrs[3].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
3952 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
3954 TopoDS_Compound aComp;
3955 BRep_Builder aCompBuilder;
3956 aCompBuilder.MakeCompound (aComp);
3957 for (Standard_Integer aWireIdx = 0; aWireIdx < 4; ++aWireIdx)
3959 aCompBuilder.Add (aComp, aWireBldrs[aWireIdx].Shape());
3961 DBRep::Set ("c", aComp);
3963 Handle(AIS_InteractiveObject) aCmp = new AIS_Shape (aComp);
3964 aCmp->SetColor (Quantity_NOC_GREEN);
3965 ViewerTest::Display ("c", aCmp, Standard_True, Standard_True);
3967 Handle(Geom_CartesianPoint) aPnt1 = new Geom_CartesianPoint (aNearPnt);
3968 Handle(Geom_CartesianPoint) aPnt2 = new Geom_CartesianPoint (aFarPnt);
3970 Handle(AIS_Line) aLine = new AIS_Line (aPnt1, aPnt2);
3971 ViewerTest::Display ("l", aLine, Standard_True, Standard_True);
3975 theDI << "Near: " << aNearPnt.X() << " " << aNearPnt.Y() << " " << aNearPnt.Z() << "\n";
3976 theDI << "Far: " << aFarPnt.X() << " " << aFarPnt.Y() << " " << aFarPnt.Z() << "\n";
3982 //=======================================================================
3983 //function : OCC26462
3985 //=======================================================================
3986 static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
3988 if (ViewerTest::GetAISContext().IsNull())
3990 std::cerr << "Error: No opened context!\n";
3994 BRepPrimAPI_MakeBox aBuilder1 (gp_Pnt (10.0, 10.0, 0.0), 10.0, 10.0, 10.0);
3995 BRepPrimAPI_MakeBox aBuilder2 (10.0, 10.0, 10.0);
3996 Handle(AIS_InteractiveObject) aBox1 = new AIS_Shape (aBuilder1.Shape());
3997 Handle(AIS_InteractiveObject) aBox2 = new AIS_Shape (aBuilder2.Shape());
3999 const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
4000 aCtx->Display (aBox1, 0, 2, Standard_False);
4001 aCtx->Display (aBox2, 0, 2, Standard_False);
4002 ViewerTest::CurrentView()->FitAll();
4003 aCtx->SetWidth (aBox1, 3, Standard_False);
4004 aCtx->SetWidth (aBox2, 3, Standard_False);
4006 aCtx->MoveTo (305, 322, ViewerTest::CurrentView(), Standard_False);
4007 aCtx->ShiftSelect (Standard_False);
4008 aCtx->MoveTo (103, 322, ViewerTest::CurrentView(), Standard_False);
4009 aCtx->ShiftSelect (Standard_False);
4010 if (aCtx->NbSelected() != 0)
4012 theDI << "ERROR: no boxes must be selected!\n";
4016 aCtx->SetSelectionSensitivity (aBox1, 2, 5);
4018 aCtx->MoveTo (305, 322, ViewerTest::CurrentView(), Standard_False);
4019 aCtx->ShiftSelect (Standard_False);
4020 if (aCtx->NbSelected() != 1)
4022 theDI << "ERROR: b1 was not selected\n";
4025 aCtx->MoveTo (103, 322, ViewerTest::CurrentView(), Standard_False);
4026 aCtx->ShiftSelect (Standard_True);
4027 if (aCtx->NbSelected() != 1)
4029 theDI << "ERROR: b2 is selected after b1's tolerance increased\n";
4037 #include <BRepBuilderAPI_GTransform.hxx>
4038 static Standard_Integer OCC26313(Draw_Interpretor& di,Standard_Integer n,const char** a)
4040 if (n <= 1) return 1;
4045 gp_Mat rot( 1.0, 0.0, 0.0,
4049 GT.SetVectorialPart(rot);
4050 BRepBuilderAPI_GTransform gtrf(GT);
4052 TopoDS_Shape aSrcShape = DBRep::Get(a[2]);
4053 if (aSrcShape.IsNull()) {
4054 di << a[2] << " is not a valid shape\n";
4059 gtrf.Perform(aSrcShape);
4064 DBRep::Set(a[1], gtrf.ModifiedShape(aSrcShape));
4066 catch(Standard_Failure)
4068 di << "Error: Exception is thrown\n";
4073 di << "Error: Result is not done\n";
4080 //=======================================================================
4081 //function : OCC26525
4082 //purpose : check number of intersection points
4083 //=======================================================================
4084 #include <BRepAdaptor_Curve.hxx>
4085 #include <BRepAdaptor_Surface.hxx>
4086 #include <BRepAdaptor_HCurve.hxx>
4087 #include <BRepAdaptor_HSurface.hxx>
4088 #include <IntCurveSurface_HInter.hxx>
4089 Standard_Integer OCC26525 (Draw_Interpretor& di,
4093 TopoDS_Shape aS1, aS2;
4099 di << " use OCC26525 r edge face \n";
4103 aS1 = DBRep::Get(a[2]);
4104 aS2 = DBRep::Get(a[3]);
4106 if (aS1.IsNull() || aS2.IsNull())
4108 di << " Null shapes are not allowed \n";
4111 if (aS1.ShapeType()!=TopAbs_EDGE)
4113 di << " Shape" << a[2] << " should be of type EDGE\n";
4116 if (aS2.ShapeType()!=TopAbs_FACE)
4118 di << " Shape" << a[3] << " should be of type FACE\n";
4122 aE=TopoDS::Edge(aS1);
4123 aF=TopoDS::Face(aS2);
4126 Standard_Boolean bIsDone;
4127 Standard_Integer i, aNbPoints;
4128 Standard_Real aU, aV, aT;
4130 BRepAdaptor_Curve aBAC;
4131 BRepAdaptor_Surface aBAS;
4132 IntCurveSurface_TransitionOnCurve aTC;
4133 IntCurveSurface_HInter aHInter;
4135 aBAC.Initialize(aE);
4136 aBAS.Initialize(aF);
4138 Handle(BRepAdaptor_HCurve) aHBAC=new BRepAdaptor_HCurve(aBAC);
4139 Handle(BRepAdaptor_HSurface) aHBAS = new BRepAdaptor_HSurface(aBAS);
4141 aHInter.Perform(aHBAC, aHBAS);
4142 bIsDone=aHInter.IsDone();
4145 di << " intersection is not done\n";
4149 aNbPoints=aHInter.NbPoints();
4150 sprintf (buf, " Number of intersection points found: %d", aNbPoints);
4152 for (i=1; i<=aNbPoints; ++i)
4154 const IntCurveSurface_IntersectionPoint& aIP=aHInter.Point(i);
4155 aIP.Values(aP, aU, aV, aT, aTC);
4157 sprintf (buf, "point %s_%d %lg %lg %lg ", a[1], i, aP.X(), aP.Y(), aP.Z());
4164 //=======================================================================
4165 //function : OCC24537
4166 //purpose : Puts inverted numbers (in the sense of little/big endian inversion)
4167 // from predefined arrays.
4168 //=======================================================================
4169 #include <FSD_BinaryFile.hxx>
4172 inline const unsigned char* SizeRef ();
4175 inline const unsigned char* SizeRef <8> ()
4177 static const unsigned char aSizeRef[] = {
4178 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4179 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
4180 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
4181 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,
4182 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,
4183 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,
4184 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
4185 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
4186 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,
4187 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4192 inline const unsigned char* SizeRef <4> ()
4194 static const unsigned char aSizeRef[] = {
4195 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4196 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4197 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4198 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4199 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4203 static Standard_Integer OCC24537(
4204 Draw_Interpretor& theDI,
4205 Standard_Integer argc,
4214 cout << "cannot create file " << argv[1] << endl;
4218 Standard_Boolean isErr = Standard_False;
4220 const unsigned char anIntRef[] = {
4221 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4222 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4223 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4224 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4225 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4226 Standard_Integer anIntArr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
4229 for(int i = 0; i < 10; ++i)
4231 Standard_Integer anInv = FSD_BinaryFile::InverseInt(anIntArr[i]);
4232 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4237 Standard_Integer anInv[10];
4238 for(int i = 0; i < 10; ++i)
4239 anInv[i] = FSD_BinaryFile::InverseInt(anIntArr[i]);
4240 if (memcmp(anInv, anIntRef, sizeof(anIntRef)) != 0)
4242 theDI << "Error: incorrect conversion of an integer value\n";
4243 isErr = Standard_True;
4247 // 1a. Random InverseInt
4248 const unsigned char aRndIntRef[] = {
4249 0xFF,0xC2,0xF7,0x00,0xFF,0xFF,0xFB,0x2E,
4250 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4251 0x00,0x00,0x04,0xD2,0x00,0x00,0x04,0xD3,
4252 0xFF,0xFF,0xFD,0x1E,0xFF,0xFF,0xFF,0xFB,
4253 0x00,0x00,0x03,0x8D,0x00,0x3D,0x09,0x00};
4254 Standard_Integer aRndIntArr[] = {-4000000, -1234, 0, 1, 1234, 1235, -738, -5, 909, 4000000};
4257 for(int i = 0; i < 10; ++i)
4259 Standard_Integer anInv = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4260 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4265 Standard_Integer anInv[10];
4266 for(int i = 0; i < 10; ++i)
4267 anInv[i] = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4268 if (memcmp(anInv, aRndIntRef, sizeof(aRndIntRef)) != 0)
4270 theDI << "Error: incorrect conversion of a dispersed integer value\n";
4271 isErr = Standard_True;
4276 const unsigned char aRealRef[] = {
4277 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4278 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4279 0x40,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
4280 0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
4281 0x40,0x14,0x00,0x00,0x00,0x00,0x00,0x00,
4282 0x40,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
4283 0x40,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
4284 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4285 0x40,0x22,0x00,0x00,0x00,0x00,0x00,0x00,
4286 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4287 const Standard_Real aRealArr[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0};
4290 for(int i = 0; i < 10; ++i)
4292 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRealArr[i]);
4293 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4298 Standard_Real anInv[10];
4299 for(int i = 0; i < 10; ++i)
4300 anInv[i] = FSD_BinaryFile::InverseReal(aRealArr[i]);
4301 if (memcmp(anInv, aRealRef, sizeof(aRealRef)) != 0)
4303 theDI << "Error: incorrect conversion of a real value\n";
4304 isErr = Standard_True;
4308 // 2a. Random InverseReal
4309 const unsigned char aRndRealRef[] = {
4310 0xFE,0x37,0xE4,0x3C,0x88,0x00,0x75,0x9C,
4311 0xBE,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4312 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4313 0x3E,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4314 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4315 0x40,0x09,0x21,0xDA,0x45,0x5B,0x53,0xE4,
4316 0x54,0xB2,0x49,0xAD,0x25,0x94,0xC3,0x7D,
4317 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4318 0xC0,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD,
4319 0x40,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD};
4320 const Standard_Real aRndRealArr[] = {-1e300, -1.e-9, 0., 1.e-9, 1., 3.1415296, 1.e100, 8.0, -9.9, 9.9};
4323 for(int i = 0; i < 10; ++i)
4325 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4326 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4331 Standard_Real anInv[10];
4332 for(int i = 0; i < 10; ++i)
4333 anInv[i] = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4334 if (memcmp(anInv, aRndRealRef, sizeof(aRndRealRef)) != 0)
4336 theDI << "Error: incorrect conversion of a dispersed real value\n";
4337 isErr = Standard_True;
4341 // 3. InverseShortReal
4342 const unsigned char aShortRealRef[] = {
4343 0x3F,0x80,0x00,0x00,0x40,0x00,0x00,0x00,
4344 0x40,0x40,0x00,0x00,0x40,0x80,0x00,0x00,
4345 0x40,0xA0,0x00,0x00,0x40,0xC0,0x00,0x00,
4346 0x40,0xE0,0x00,0x00,0x41,0x00,0x00,0x00,
4347 0x41,0x10,0x00,0x00,0x00,0x00,0x00,0x00};
4348 const Standard_ShortReal aShortRealArr[] = {
4349 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 0.0f};
4352 for(int i = 0; i < 10; ++i)
4354 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4355 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4360 Standard_ShortReal anInv[10];
4361 for(int i = 0; i < 10; ++i)
4362 anInv[i] = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4363 if (memcmp(anInv, aShortRealRef, sizeof(aShortRealRef)) != 0)
4365 theDI << "Error: incorrect conversion of a short real value\n";
4366 isErr = Standard_True;
4370 // 3a. Random InverseShortReal
4371 const unsigned char aRndShortRealRef[] = {
4372 0xB0,0x89,0x70,0x5F,0x00,0x00,0x00,0x00,
4373 0x30,0x89,0x70,0x5F,0x3F,0x80,0x00,0x00,
4374 0x40,0x49,0x0E,0x56,0xC0,0xD6,0x66,0x66,
4375 0x40,0xD6,0x66,0x66,0x42,0xC5,0xCC,0xCD,
4376 0xC2,0xC7,0xCC,0xCD,0x42,0xC7,0xCC,0xCD};
4377 const Standard_ShortReal aRndShortRealArr[] = {
4378 -1.e-9f, 0.f, 1.e-9f, 1.f, 3.1415f, -6.7f, 6.7f, 98.9f, -99.9f, 99.9f};
4381 for(int i = 0; i < 10; ++i)
4383 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4384 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4389 Standard_ShortReal anInv[10];
4390 for(int i = 0; i < 10; ++i)
4391 anInv[i] = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4392 if (memcmp(anInv, aRndShortRealRef, sizeof(aRndShortRealRef)) != 0)
4394 theDI << "Error: incorrect conversion of a dispersed short real value\n";
4395 isErr = Standard_True;
4400 const Standard_Size aSizeArr[] = {1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul, 8ul, 9ul, 0ul};
4403 for(int i = 0; i < 10; ++i)
4405 Standard_Size anInv = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4406 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4411 Standard_Size anInv[10];
4412 const unsigned char* aSizeRef = SizeRef<sizeof(Standard_Size)>();
4413 for(int i = 0; i < 10; ++i)
4414 anInv[i] = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4415 if (memcmp(anInv, aSizeRef, sizeof(Standard_Size)*10) != 0)
4417 theDI << "Error: incorrect conversion of a size value\n";
4418 isErr = Standard_True;
4422 if (!aF.is_open() && !isErr)
4423 theDI << "Conversion was done OK";
4426 cout << "the file " << argv[1] << " has been created" << endl;
4433 #include <TopExp.hxx>
4434 #include <BRepOffsetAPI_DraftAngle.hxx>
4436 static TopoDS_Shape taper(const TopoDS_Shape &shape, const TopoDS_Face &face_a, const TopoDS_Face &face_b, Standard_Real angle)
4438 // Use maximum face-to-taper z-offset.
4439 const gp_Pln neutral_plane(gp_Ax3(gp_Pnt(0.0, 0.0, 140.0), gp_Dir(0.0, 0.0, 1.0)));
4441 // Draft angle needs to be in radians, and flipped to adhere to our own (arbitrary) draft
4442 // angle definition.
4443 const Standard_Real draft_angle = -(angle / 180.0) * M_PI;
4445 // Add face to draft. The first argument indicates that all material added/removed during
4446 // drafting is located below the neutral plane
4447 BRepOffsetAPI_DraftAngle drafter(shape);
4448 drafter.Add(face_a, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4449 drafter.Add(face_b, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4452 return drafter.Shape();
4455 static void dumpShapeVertices(const TopoDS_Shape &shape, std::vector<Standard_Real>& coords)
4457 TopTools_IndexedMapOfShape shape_vertices;
4458 TopExp::MapShapes(shape, TopAbs_VERTEX, shape_vertices);
4460 for (Standard_Integer i = 1; i <= shape_vertices.Extent(); i++)
4462 gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(shape_vertices(i)));
4463 coords.push_back(p.X());
4464 coords.push_back(p.Y());
4465 coords.push_back(p.Z());
4469 static void GetCoords(const Standard_CString& path_to_file, std::vector<Standard_Real>& coords)
4472 BRep_Builder builder;
4473 BRepTools::Read(shape, path_to_file, builder);
4474 TopTools_IndexedMapOfShape shape_faces;
4475 TopExp::MapShapes(shape, TopAbs_FACE, shape_faces);
4476 TopoDS_Face face_a = TopoDS::Face(shape_faces(1));
4477 TopoDS_Face face_b = TopoDS::Face(shape_faces(5));
4478 dumpShapeVertices(taper(shape, face_a, face_b, 5.0), coords);
4481 static Standard_Integer OCC26396 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4485 theDI << "Error: path to file is missing\n";
4489 const int maxInd = 50;
4491 std::vector<Standard_Real> ref_coords;
4492 ref_coords.reserve(100);
4493 Standard_Boolean Stat = Standard_True;
4495 GetCoords(theArgv[1], ref_coords);
4497 std::vector<Standard_Real> coords;
4498 coords.reserve(100);
4499 for (int i = 1; i < maxInd; i++)
4501 GetCoords(theArgv[1], coords);
4502 if (coords.size() != ref_coords.size())
4504 Stat = Standard_False;
4507 for (size_t j = 0; j < coords.size(); j++)
4508 if (Abs(ref_coords[j] - coords[j]) > RealEpsilon())
4510 Stat = Standard_False;
4516 theDI << "Error: unstable results";
4523 //=======================================================================
4524 //function : OCC26750
4526 //=======================================================================
4527 static Standard_Integer OCC26750( Draw_Interpretor& theDI,
4528 Standard_Integer /*theNArg*/,
4529 const char ** /*theArgVal*/)
4531 const gp_Vec2d aVec1(1.0, 0.0);
4532 const gp_Vec2d aVec2(0.0, -1.0);
4534 if(aVec1.IsNormal(aVec2, Precision::Angular()))
4536 theDI << "gp_Vec2d OK. Vectors are normal.\n";
4540 theDI << "Error in gp_Vec2d. Vectors should be normal.\n";
4543 const gp_Dir2d aD1(1.0, 0.0);
4544 const gp_Dir2d aD2(0.0, -1.0);
4546 if(aD1.IsNormal(aD2, Precision::Angular()))
4548 theDI << "gp_Dir2d OK. Vectors are normal.\n";
4552 theDI << "Error in gp_Dir2d. Vectors should be normal.\n";
4558 //=======================================================================
4559 //function : OCC26746
4560 //purpose : Checks if coefficients of the torus are computed properly.
4561 //=======================================================================
4562 #include <Geom_ToroidalSurface.hxx>
4563 #include <Geom_BSplineCurve.hxx>
4564 static Standard_Integer OCC26746(
4565 Draw_Interpretor& theDI,
4566 Standard_Integer theNArg,
4567 const char ** theArgVal)
4571 theDI << "Use: OCC26746 torus [toler NbCheckedPoints]\n";
4575 const Handle(Geom_ToroidalSurface) aGtor =
4576 Handle(Geom_ToroidalSurface)::DownCast(DrawTrSurf::GetSurface(theArgVal[1]));
4578 const Standard_Real aToler = (theNArg >= 3)? Draw::Atof(theArgVal[2]) : 1.0e-7;
4579 const Standard_Integer aNbPntsMax = (theNArg >= 4)? Draw::Atoi(theArgVal[3]) : 5;
4581 const Standard_Integer aLowIndex = 5;
4582 const Standard_Real aStep = 2.0*M_PI/aNbPntsMax;
4584 TColStd_Array1OfReal anArrCoeffs(aLowIndex, aLowIndex+34);
4585 aGtor->Torus().Coefficients(anArrCoeffs);
4587 Standard_Real aUpar = 0.0, aVpar = 0.0;
4588 for(Standard_Integer aUind = 0; aUind <= aNbPntsMax; aUind++)
4590 for(Standard_Integer aVind = 0; aVind <= aNbPntsMax; aVind++)
4592 const gp_Pnt aPt(aGtor->Value(aUpar, aVpar));
4593 const Standard_Real aX1 = aPt.X();
4594 const Standard_Real aX2 = aX1*aX1;
4595 const Standard_Real aX3 = aX2*aX1;
4596 const Standard_Real aX4 = aX2*aX2;
4597 const Standard_Real aY1 = aPt.Y();
4598 const Standard_Real aY2 = aY1*aY1;
4599 const Standard_Real aY3 = aY2*aY1;
4600 const Standard_Real aY4 = aY2*aY2;
4601 const Standard_Real aZ1 = aPt.Z();
4602 const Standard_Real aZ2 = aZ1*aZ1;
4603 const Standard_Real aZ3 = aZ2*aZ1;
4604 const Standard_Real aZ4 = aZ2*aZ2;
4606 Standard_Integer i = aLowIndex;
4608 Standard_Real aDelta = anArrCoeffs(i++) * aX4; //1
4609 aDelta+= anArrCoeffs(i++) * aY4; //2
4610 aDelta+= anArrCoeffs(i++) * aZ4; //3
4611 aDelta+= anArrCoeffs(i++) * aX3 * aY1; //4
4612 aDelta+= anArrCoeffs(i++) * aX3 * aZ1; //5
4613 aDelta+= anArrCoeffs(i++) * aY3 * aX1; //6
4614 aDelta+= anArrCoeffs(i++) * aY3 * aZ1; //7
4615 aDelta+= anArrCoeffs(i++) * aZ3 * aX1; //8
4616 aDelta+= anArrCoeffs(i++) * aZ3 * aY1; //9
4617 aDelta+= anArrCoeffs(i++) * aX2 * aY2; //10
4618 aDelta+= anArrCoeffs(i++) * aX2 * aZ2; //11
4619 aDelta+= anArrCoeffs(i++) * aY2 * aZ2; //12
4620 aDelta+= anArrCoeffs(i++) * aX2 * aY1 * aZ1; //13
4621 aDelta+= anArrCoeffs(i++) * aX1 * aY2 * aZ1; //14
4622 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ2; //15
4623 aDelta+= anArrCoeffs(i++) * aX3; //16
4624 aDelta+= anArrCoeffs(i++) * aY3; //17
4625 aDelta+= anArrCoeffs(i++) * aZ3; //18
4626 aDelta+= anArrCoeffs(i++) * aX2 * aY1; //19
4627 aDelta+= anArrCoeffs(i++) * aX2 * aZ1; //20
4628 aDelta+= anArrCoeffs(i++) * aY2 * aX1; //21
4629 aDelta+= anArrCoeffs(i++) * aY2 * aZ1; //22
4630 aDelta+= anArrCoeffs(i++) * aZ2 * aX1; //23
4631 aDelta+= anArrCoeffs(i++) * aZ2 * aY1; //24
4632 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ1; //25
4633 aDelta+= anArrCoeffs(i++) * aX2; //26
4634 aDelta+= anArrCoeffs(i++) * aY2; //27
4635 aDelta+= anArrCoeffs(i++) * aZ2; //28
4636 aDelta+= anArrCoeffs(i++) * aX1 * aY1; //29
4637 aDelta+= anArrCoeffs(i++) * aX1 * aZ1; //30
4638 aDelta+= anArrCoeffs(i++) * aY1 * aZ1; //31
4639 aDelta+= anArrCoeffs(i++) * aX1; //32
4640 aDelta+= anArrCoeffs(i++) * aY1; //33
4641 aDelta+= anArrCoeffs(i++) * aZ1; //34
4642 aDelta+= anArrCoeffs(i++); //35
4644 if(Abs(aDelta) > aToler)
4646 theDI << "(" << aUpar << ", " << aVpar << "): Error in torus coefficients computation (Delta = " << aDelta << ").\n";
4650 theDI << "(" << aUpar << ", " << aVpar << "): OK (Delta = " << aDelta << ").\n";
4653 aVpar = (aVind == aNbPntsMax)? 2.0*M_PI : aVpar + aStep;
4657 aUpar = (aUind == aNbPntsMax)? 2.0*M_PI : aUpar + aStep;
4663 //=======================================================================
4664 //function : OCC27048
4665 //purpose : Calculate value of B-spline surface N times
4666 //=======================================================================
4667 static Standard_Integer OCC27048(Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4671 std::cout << "Incorrect number of arguments. See usage:" << std::endl;
4672 theDI.PrintHelp(theArgv[0]);
4676 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theArgv[1]);
4677 GeomAdaptor_Surface anAdaptor(aSurf);
4679 Standard_Real aU = Draw::Atof(theArgv[2]);
4680 Standard_Real aV = Draw::Atof(theArgv[3]);
4681 Standard_Integer aN = Draw::Atoi(theArgv[4]);
4683 for (; aN > 0; --aN)
4684 anAdaptor.Value(aU, aV);
4689 //========================================================================
4690 //function : OCC27065
4691 //purpose : Tests overloaded method "Generated" of BRepOffsetAPI_MakePipe
4692 //========================================================================
4693 static Standard_Integer OCC27065(Draw_Interpretor& di,
4694 Standard_Integer n, const char** a)
4696 if (n < 3) return 1;
4699 TopoDS_Shape SpineShape = DBRep::Get(a[1],TopAbs_WIRE);
4700 if ( SpineShape.IsNull()) return 1;
4701 TopoDS_Wire Spine = TopoDS::Wire(SpineShape);
4703 TopoDS_Shape Profile = DBRep::Get(a[2]);
4704 if ( Profile.IsNull()) return 1;
4706 BRepOffsetAPI_MakePipe aPipeBuilder(Spine, Profile);
4707 if (!aPipeBuilder.IsDone())
4709 di << "Error: failed to create pipe\n";
4713 TopExp_Explorer Explo(Profile, TopAbs_SHELL);
4714 TopoDS_Shape aShape;
4715 TopTools_ListIteratorOfListOfShape itl;
4718 aShape = Explo.Current();
4719 TopoDS_Compound res1;
4720 BB.MakeCompound(res1);
4721 itl.Initialize(aPipeBuilder.Generated(aShape));
4722 for (; itl.More(); itl.Next())
4723 BB.Add(res1, itl.Value());
4724 DBRep::Set("res_shell", res1);
4727 Explo.Init(Profile, TopAbs_FACE);
4730 aShape = Explo.Current();
4731 TopoDS_Compound res2;
4732 BB.MakeCompound(res2);
4733 itl.Initialize(aPipeBuilder.Generated(aShape));
4734 for (; itl.More(); itl.Next())
4735 BB.Add(res2, itl.Value());
4736 DBRep::Set("res_face", res2);
4739 Explo.Init(Profile, TopAbs_WIRE);
4742 aShape = Explo.Current();
4743 TopoDS_Compound res3;
4744 BB.MakeCompound(res3);
4745 itl.Initialize(aPipeBuilder.Generated(aShape));
4746 for (; itl.More(); itl.Next())
4747 BB.Add(res3, itl.Value());
4748 DBRep::Set("res_wire", res3);
4751 Explo.Init(Profile, TopAbs_EDGE);
4754 aShape = Explo.Current();
4755 TopoDS_Compound res4;
4756 BB.MakeCompound(res4);
4757 itl.Initialize(aPipeBuilder.Generated(aShape));
4758 for (; itl.More(); itl.Next())
4759 BB.Add(res4, itl.Value());
4760 DBRep::Set("res_edge", res4);
4763 Explo.Init(Profile, TopAbs_VERTEX);
4766 aShape = Explo.Current();
4767 TopoDS_Compound res5;
4768 BB.MakeCompound(res5);
4769 itl.Initialize(aPipeBuilder.Generated(aShape));
4770 for (; itl.More(); itl.Next())
4771 BB.Add(res5, itl.Value());
4772 DBRep::Set("res_vertex", res5);
4778 //========================================================================
4779 //function : OCC27318
4780 //purpose : Creates a box that is not listed in map of AIS objects of ViewerTest
4781 //========================================================================
4782 static Standard_Integer OCC27318 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
4784 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
4787 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
4791 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20, 20, 20).Shape();
4792 Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
4793 aCtx->Display (aBoxObj, Standard_True);
4798 //========================================================================
4799 //function : OCC27523
4800 //purpose : Checks recomputation of deactivated selection mode after object's redisplaying
4801 //========================================================================
4802 static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
4806 std::cerr << "Error: wrong number of arguments! See usage:\n";
4807 theDI.PrintHelp (theArgVec[0]);
4811 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
4812 if(anAISContext.IsNull())
4814 std::cerr << "Error: no active view. Please call vinit.\n";
4818 gp_Pnt aStart (100, 100, 100);
4819 gp_Pnt anEnd (300, 400, 600);
4820 BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
4821 TopoDS_Edge anEdge = anEdgeBuilder.Edge();
4822 Handle(AIS_InteractiveObject) aTestAISShape = new AIS_Shape (anEdge);
4823 anAISContext->Display (aTestAISShape, Standard_False);
4825 // activate it in selection modes
4826 TColStd_SequenceOfInteger aModes;
4827 aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX));
4829 anAISContext->Deactivate (aTestAISShape);
4830 anAISContext->Load (aTestAISShape, -1);
4831 anAISContext->Activate (aTestAISShape, 0);
4832 anAISContext->Deactivate (aTestAISShape, 0);
4834 // activate in vertices mode
4835 for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt)
4837 anAISContext->Activate (aTestAISShape, aModes (anIt));
4840 TopoDS_Shape aVertexShape = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
4841 TopAbs_ShapeEnum aVertexShapeType = aVertexShape.ShapeType();
4842 Handle(AIS_Shape)::DownCast (aTestAISShape)->Set (aVertexShape);
4843 aTestAISShape->Redisplay();
4845 anAISContext->AddOrRemoveSelected (aTestAISShape, Standard_True);
4847 bool aValidShapeType = false;
4848 for (anAISContext->InitSelected(); anAISContext->MoreSelected(); anAISContext->NextSelected())
4850 Handle(SelectMgr_EntityOwner) anOwner = anAISContext->SelectedOwner();
4851 Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
4852 if (!aBRO.IsNull() && aBRO->HasShape())
4854 TopoDS_Shape aShape = aBRO->Shape();
4856 aValidShapeType = aShape.ShapeType() == aVertexShapeType;
4860 if (!aValidShapeType)
4862 std::cerr << "Error: shape type is invalid.\n";
4869 //========================================================================
4870 //function : OCC27700
4871 //purpose : glPolygonMode() used for frame drawing affects label text shading
4872 //========================================================================
4874 class OCC27700_Text : public AIS_InteractiveObject
4878 DEFINE_STANDARD_RTTI_INLINE (OCC27700_Text, AIS_InteractiveObject)
4880 virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
4881 const Handle(Prs3d_Presentation)& thePresentation,
4882 const Standard_Integer /*theMode*/) Standard_OVERRIDE
4884 Handle(Graphic3d_ArrayOfTriangles) aFrame = new Graphic3d_ArrayOfTriangles (6, 6);
4885 aFrame->AddVertex (gp_Pnt (-1, 0, 0));
4886 aFrame->AddVertex (gp_Pnt (-1, 1, 0));
4887 aFrame->AddVertex (gp_Pnt ( 3, 1, 0));
4888 aFrame->AddVertex (gp_Pnt ( 3, 0, 0));
4890 aFrame->AddEdge (1);
4891 aFrame->AddEdge (2);
4892 aFrame->AddEdge (3);
4894 aFrame->AddEdge (2);
4895 aFrame->AddEdge (3);
4896 aFrame->AddEdge (4);
4898 Handle(Graphic3d_AspectFillArea3d) aFillAspect =
4899 new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect().get());
4900 aFillAspect->SetInteriorStyle (Aspect_IS_POINT);
4902 // create separate group for frame elements
4903 Handle(Graphic3d_Group) aFrameGroup = Prs3d_Root::NewGroup (thePresentation);
4904 aFrameGroup->AddPrimitiveArray (aFrame);
4905 aFrameGroup->SetGroupPrimitivesAspect (aFillAspect);
4907 // create separate group for text elements
4908 Handle(Graphic3d_Group) aTextGroup = Prs3d_Root::NewGroup (thePresentation);
4909 TCollection_ExtendedString aString ("YOU SHOULD SEE THIS TEXT", Standard_True);
4910 Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePresentation), myDrawer->TextAspect(), aString, gp_Ax2 (gp::Origin(), gp::DZ()));
4913 virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
4914 const Standard_Integer /*theMode*/) Standard_OVERRIDE {}
4917 static Standard_Integer OCC27700 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
4919 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4920 if (aContext.IsNull())
4922 std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
4925 Handle(OCC27700_Text) aPresentation = new OCC27700_Text();
4926 aContext->Display (aPresentation, Standard_True);
4930 //========================================================================
4931 //function : OCC27757
4932 //purpose : Creates a box that has a sphere as child object and displays it
4933 //========================================================================
4934 static Standard_Integer OCC27757 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
4936 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
4939 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
4943 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20.0, 20.0, 20.0).Shape();
4944 TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere (10.0).Shape();
4946 aTrsf.SetTranslationPart (gp_Vec (20.0, 20.0, 0.0));
4947 aSphere.Located (TopLoc_Location (aTrsf));
4950 Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
4951 Handle(AIS_Shape) aSphereObj = new AIS_Shape (aSphere);
4952 aBoxObj->AddChild (aSphereObj);
4953 aCtx->Display (aBoxObj, 1, 0, Standard_False);
4954 aCtx->UpdateCurrentViewer();
4959 //========================================================================
4960 //function : OCC27818
4961 //purpose : Creates three boxes and highlights one of them with own style
4962 //========================================================================
4963 static Standard_Integer OCC27818 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
4965 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
4968 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
4972 Handle(AIS_Shape) aBoxObjs[3];
4973 for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx)
4975 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20.0, 20.0, 20.0).Shape();
4976 aBoxObjs[aBoxIdx] = new AIS_Shape (aBox);
4978 aTrsf.SetTranslationPart (gp_Vec (30.0 * aBoxIdx, 30.0 * aBoxIdx, 0.0));
4979 aBoxObjs[aBoxIdx]->SetLocalTransformation (aTrsf);
4980 aBoxObjs[aBoxIdx]->SetHilightMode (AIS_Shaded);
4984 Handle(Prs3d_Drawer) aHiStyle = new Prs3d_Drawer();
4985 aBoxObjs[1]->SetDynamicHilightAttributes (aHiStyle);
4986 aHiStyle->SetDisplayMode (AIS_Shaded);
4987 aHiStyle->SetColor (Quantity_NOC_RED);
4988 aHiStyle->SetTransparency (0.8f);
4991 Handle(Prs3d_Drawer) aSelStyle = new Prs3d_Drawer();
4992 aBoxObjs[2]->SetHilightAttributes (aSelStyle);
4993 aSelStyle->SetDisplayMode (AIS_Shaded);
4994 aSelStyle->SetColor (Quantity_NOC_RED);
4995 aSelStyle->SetTransparency (0.0f);
4996 aSelStyle->SetZLayer (Graphic3d_ZLayerId_Topmost);
4999 for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx)
5001 aCtx->Display (aBoxObjs[aBoxIdx], AIS_Shaded, 0, Standard_False);
5004 aCtx->UpdateCurrentViewer();
5009 //========================================================================
5010 //function : OCC27893
5011 //purpose : Creates a box and selects it via AIS_InteractiveContext API
5012 //========================================================================
5013 static Standard_Integer OCC27893 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5015 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5018 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5022 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
5023 Handle(AIS_InteractiveObject) aBoxObj = new AIS_Shape (aBox);
5024 aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False);
5025 aCtx->SetSelected (aBoxObj, Standard_True);
5030 //========================================================================
5031 //function : OCC28310
5032 //purpose : Tests validness of iterator in AIS_InteractiveContext after
5033 // an removing object from it
5034 //========================================================================
5035 static Standard_Integer OCC28310 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5037 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5040 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5044 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
5045 Handle(AIS_InteractiveObject) aBoxObj = new AIS_Shape (aBox);
5046 aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False);
5047 ViewerTest::CurrentView()->FitAll();
5048 aCtx->MoveTo (200, 200, ViewerTest::CurrentView(), Standard_True);
5049 aCtx->Select(Standard_True);
5051 aCtx->Remove (aBoxObj, Standard_True);
5052 // nullify the object explicitly to simulate situation in project,
5053 // when ::Remove is called from another method and the object is destroyed
5054 // before ::DetectedInteractive is called
5057 for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
5059 Handle(AIS_InteractiveObject) anObj = aCtx->DetectedInteractive();
5065 // repetitive display and removal of multiple small objects in the viewer for
5066 // test of memory leak in visualization (OCCT 6.9.0 - 7.0.0)
5067 static Standard_Integer OCC29412 (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, const char** theArgVec)
5069 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
5072 std::cout << "Error: no active view.\n";
5076 const int aNbIters = (theArgNb <= 1 ? 10000 : Draw::Atoi (theArgVec[1]));
5077 int aProgressPrev = -1;
5078 for (int m_loopIndex = 0; m_loopIndex < aNbIters; m_loopIndex++)
5083 gp_Ax2 center (pos, dir);
5084 gp_Circ circle (center, 1);
5085 Handle(AIS_Shape) feature;
5087 BRepBuilderAPI_MakeEdge builder( circle );
5089 if( builder.Error() == BRepBuilderAPI_EdgeDone )
5091 TopoDS_Edge E1 = builder.Edge();
5092 TopoDS_Shape W2 = BRepBuilderAPI_MakeWire(E1).Wire();
5093 feature = new AIS_Shape(W2);
5094 aCtx->Display (feature, true);
5097 aCtx->CurrentViewer()->Update();
5098 ViewerTest::CurrentView()->FitAll();
5099 aCtx->Remove (feature, true);
5101 const int aProgress = (m_loopIndex * 100) / aNbIters;
5102 if (aProgress != aProgressPrev)
5104 std::cerr << aProgress << "%\r";
5105 aProgressPrev = aProgress;
5111 //========================================================================
5112 //function : Commands_19
5114 //========================================================================
5116 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
5117 const char *group = "QABugs";
5119 Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass();
5120 theCommands.Add ("OCC24202_1", "Test Handle-based procedure",
5121 __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group);
5122 NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass();
5123 theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure",
5124 __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group);
5126 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
5127 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
5128 theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
5129 theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
5130 theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
5131 theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
5132 theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
5133 theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
5134 theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
5135 theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
5136 theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
5137 theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
5138 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);
5139 theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
5140 theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
5141 theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
5142 theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
5143 theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
5144 theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group);
5145 theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group);
5146 theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group);
5147 theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group);
5148 theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group);
5149 theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group);
5150 theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group);
5151 theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group);
5152 theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group);
5153 theCommands.Add ("OCC23951", "OCC23951 path to saved step file", __FILE__, OCC23951, group);
5154 theCommands.Add ("OCC24931", "OCC24931 path to saved xml file", __FILE__, OCC24931, group);
5155 theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group);
5156 theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
5157 theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group);
5158 theCommands.Add ("OCC24925",
5159 "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]"
5160 "\nOCAF persistence without setting environment variables",
5161 __FILE__, OCC24925, group);
5162 theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group);
5163 theCommands.Add ("OCC24826,", "This test performs simple saxpy test.\n Usage: OCC24826 length", __FILE__, OCC24826, group);
5164 theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group);
5165 theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group);
5166 theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
5167 theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
5168 theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group);
5169 theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group);
5170 theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
5171 theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
5172 theCommands.Add ("OCC25545",
5173 "no args; tests data race when concurrently accessing \n"
5174 "\t\tTopLoc_Location::Transformation()",
5175 __FILE__, OCC25545, group);
5176 theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
5177 theCommands.Add ("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group);
5178 theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);
5179 theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group);
5180 theCommands.Add ("OCC26139", "OCC26139 [-boxsize value] [-boxgrid value] [-compgrid value]", __FILE__, OCC26139, group);
5181 theCommands.Add ("OCC26284", "OCC26284", __FILE__, OCC26284, group);
5182 theCommands.Add ("OCC26446", "OCC26446 r c1 c2", __FILE__, OCC26446, group);
5183 theCommands.Add ("OCC26448", "OCC26448: check method Prepend() of sequence", __FILE__, OCC26448, group);
5184 theCommands.Add ("OCC26407", "OCC26407 result_name", __FILE__, OCC26407, group);
5185 theCommands.Add ("OCC26485", "OCC26485 shape", __FILE__, OCC26485, group);
5186 theCommands.Add ("OCC26553", "OCC26553 file_path", __FILE__, OCC26553, group);
5187 theCommands.Add ("OCC26195",
5188 "OCC26195: x1_pix y1_pix [x2_pix y2_pix] [toPrintPixelCoord 0|1]"
5189 "\n\t\t: Draws rectangular selecting frustum defined by point selection in pixel coordinates"
5190 "\n\t\t: [x1_pix, y1_pix] or rectangular selection in pixel coordinates [x1_pix, y1_pix,"
5191 "\n\t\t: x2_pix, y2_pix]."
5192 "\n\t\t: [toPrintPixelCoord 0|1] - prints 3d projection of pixel coordinate or center of"
5193 "\n\t\t: selecting rectangle onto near and far view frustum planes",
5194 __FILE__, OCC26195, group);
5195 theCommands.Add ("OCC26462",
5196 "OCC26462: Checks the ability to manage sensitivity of a particular selection mode in local context",
5197 __FILE__, OCC26462, group);
5199 theCommands.Add ("OCC26313", "OCC26313 result shape", __FILE__, OCC26313, group);
5200 theCommands.Add ("OCC26396", "OCC26396 shape_file_path", __FILE__, OCC26396, group);
5201 theCommands.Add ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group);
5203 theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group);
5204 theCommands.Add ("OCC26750", "OCC26750", __FILE__, OCC26750, group);
5205 theCommands.Add ("OCC25574", "OCC25574", __FILE__, OCC25574, group);
5206 theCommands.Add ("OCC26746", "OCC26746 torus [toler NbCheckedPoints] ", __FILE__, OCC26746, group);
5208 theCommands.Add ("OCC27048",
5209 "OCC27048 surf U V N\nCalculate value of surface N times in the point (U, V)",
5210 __FILE__, OCC27048, group);
5212 theCommands.Add ("OCC27065",
5213 "OCC27065 spine profile",
5214 __FILE__, OCC27065, group);
5216 theCommands.Add ("OCC27318",
5217 "OCC27318: Creates a box that is not listed in map of AIS objects of ViewerTest",
5218 __FILE__, OCC27318, group);
5219 theCommands.Add ("OCC27523",
5220 "OCC27523: Checks recomputation of deactivated selection mode after object's redisplaying",
5221 __FILE__, OCC27523, group);
5222 theCommands.Add ("OCC27700",
5223 "OCC27700: Checks drawing text after setting interior style",
5224 __FILE__, OCC27700, group);
5225 theCommands.Add ("OCC27757",
5226 "OCC27757: Creates a box that has a sphere as child object and displays it",
5227 __FILE__, OCC27757, group);
5228 theCommands.Add ("OCC27818",
5229 "OCC27818: Creates three boxes and highlights one of them with own style",
5230 __FILE__, OCC27818, group);
5231 theCommands.Add ("OCC27893",
5232 "OCC27893: Creates a box and selects it via AIS_InteractiveContext API",
5233 __FILE__, OCC27893, group);
5234 theCommands.Add("OCC28310",
5235 "OCC28310: Tests validness of iterator in AIS_InteractiveContext after an removing object from it",
5236 __FILE__, OCC28310, group);
5237 theCommands.Add("OCC29412", "OCC29412 [nb cycles]: test display / remove of many small objects", __FILE__, OCC29412, group);