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 <OSD_ThreadPool.hxx>
43 #include <Precision.hxx>
44 #include <Prs3d_ShadingAspect.hxx>
45 #include <Prs3d_Text.hxx>
46 #include <SelectMgr_Filter.hxx>
47 #include <Standard_Version.hxx>
48 #include <StdSelect_BRepOwner.hxx>
49 #include <TCollection_HAsciiString.hxx>
50 #include <TopExp_Explorer.hxx>
51 #include <TopoDS_Shape.hxx>
52 #include <V3d_View.hxx>
53 #include <ViewerTest.hxx>
54 #include <XmlDrivers_DocumentRetrievalDriver.hxx>
55 #include <XmlDrivers_DocumentStorageDriver.hxx>
56 #include <TDataStd_Real.hxx>
57 #include <Standard_Atomic.hxx>
60 #include <tbb/parallel_for.h>
61 #include <tbb/parallel_for_each.h>
62 #include <tbb/blocked_range.h>
70 #define QCOMPARE(val1, val2) \
71 di << "Checking " #val1 " == " #val2 << \
72 ((val1) == (val2) ? ": OK\n" : ": Error\n")
74 static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
77 di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d\n";
82 if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
83 di << "ERROR OCC230: " << argv[2] << " is not Pnt2d\n";
86 if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
87 di << "ERROR OCC230: " << argv[3] << " is not Pnt2d\n";
91 GCE2d_MakeSegment MakeSegment(P1,P2);
92 Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
93 DrawTrSurf::Set(argv[1], TrimmedCurve);
97 static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
102 t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267);
103 t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880);
105 gp_Trsf tComp = t2 * t1;
108 gp_Pnt p2 = p1.Transformed(tComp);
109 gp_Pnt p3 = p1.Transformed(t1);
112 // points must be equal
113 if ( ! p2.IsEqual(p3, Precision::Confusion()) )
114 di << "ERROR OCC23361: equivalent transformations does not produce equal points\n";
116 di << "OCC23361: OK\n";
121 static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
123 OSD_PerfMeter aPM("TestMeter",0);
126 // run some operation in cycle for about 2 seconds to have good values of times to compare
128 printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n");
129 for (; aTM.ElapsedTime() < 2.; count++)
134 // do some operation that will take considerable time compared with time of starting / stopping timers
135 BRepPrimAPI_MakeBox aBox (10., 10., 10.);
136 BRepPrimAPI_MakeSphere aSphere (10.);
137 BRepAlgoAPI_Cut aCutter (aBox.Shape(), aSphere.Shape());
144 Standard_Real aPerfMeter_CPUtime = 0., aTimer_CPUTime = 0., aS;
145 Standard_Integer aM, aH;
146 aTM.Show(aS, aM, aH, aTimer_CPUTime);
148 perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
149 perf_init_meter("TestMeter");
151 Standard_Real aTimeDiff = (fabs(aTimer_CPUTime - aPerfMeter_CPUtime) / aTimer_CPUTime);
153 printf("\nMeasurement results (%d cycles):\n", count);
154 printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer CPU time: %lf\n",
155 aPerfMeter_CPUtime, aTimer_CPUTime);
156 printf("Time delta is: %.3lf %%\n", aTimeDiff * 100);
159 di << "OCC23237: Error: too much difference between CPU and elapsed times";
160 else if (aNbEnters != count)
161 di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles";
163 di << "OCC23237: OK";
168 class IncrementerDecrementer
171 IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
173 void operator() (const size_t) const
176 Standard_Atomic_Increment(myVal);
178 Standard_Atomic_Decrement(myVal);
181 Standard_Integer* myVal;
182 Standard_Boolean myPositive;
185 static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
189 //check returned value
190 QCOMPARE (Standard_Atomic_Decrement (&aSum), -1);
191 QCOMPARE (Standard_Atomic_Increment (&aSum), 0);
192 QCOMPARE (Standard_Atomic_Increment (&aSum), 1);
193 QCOMPARE (Standard_Atomic_Increment (&aSum), 2);
194 // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0);
195 // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1);
199 const int N = 1 << 24; //big enough to ensure concurrency
202 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, true));
206 OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, false));
212 #include <TDocStd_Application.hxx>
213 #include <TDocStd_Document.hxx>
214 #include <XCAFDoc_ShapeTool.hxx>
215 #include <XCAFDoc_DocumentTool.hxx>
216 #include <TDF_Label.hxx>
217 #include <TDataStd_Name.hxx>
218 #include <DDocStd.hxx>
220 static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
222 Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
223 Handle(TDocStd_Document) aDoc;
224 anApp->NewDocument ("XmlXCAF", aDoc);
225 QCOMPARE (!aDoc.IsNull(), Standard_True);
227 Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
229 //check default value
230 Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
231 QCOMPARE (aValue, Standard_True);
234 XCAFDoc_ShapeTool::SetAutoNaming (Standard_True);
235 TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape();
236 TDF_Label aLabel = aShTool->AddShape (aShape);
237 Handle(TDataStd_Name) anAttr;
238 QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
241 XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
242 aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape();
243 aLabel = aShTool->AddShape (aShape);
244 QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
247 XCAFDoc_ShapeTool::SetAutoNaming (aValue);
252 #include <ExprIntrp_GenExp.hxx>
253 Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
257 di << "Usage : " << argv[0] << " string nb\n";
261 TCollection_AsciiString aToken = argv[1];
262 Standard_Integer aNb = atoi(argv[2]);
264 Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create();
265 for (Standard_Integer i=0; i < aNb; i++)
267 aGen->Process(aToken);
268 Handle(Expr_GeneralExpression) aExpr = aGen->Expression();
274 Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
278 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"
279 << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}"
280 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}";
284 #include <TopoDS_Face.hxx>
285 #include <TopoDS_Face.hxx>
286 #include <TopoDS.hxx>
287 #include <BRepBuilderAPI_Transform.hxx>
288 #include <BRepExtrema_DistShapeShape.hxx>
289 #include <BRepTools.hxx>
291 static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di)
293 BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN);
294 if(!distShapeShape.IsDone()) {
295 di <<"Distance ShapeShape is Not Done\n";
296 return Standard_False;
299 if(distShapeShape.Value() > 0.01) {
300 di << "Wrong Dist = " <<distShapeShape.Value() << "\n";
301 return Standard_False;
303 di << "Dist0 = " <<distShapeShape.Value() <<"\n";
305 //////////////////////////////////////////////////////////////////////////
307 const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970);
308 const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970);
310 gp_Vec2d mirrorVector1(axis1P1,axis1P2);
313 mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1));
315 BRepBuilderAPI_Transform transformer1(mirror1);
316 transformer1.Perform(originalWire);
317 if(!transformer1.IsDone()) {
318 di << "Not Done1 \n";
319 return Standard_False;
321 TopoDS_Shape step1ModifiedShape = transformer1.ModifiedShape(originalWire);
323 BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN);
324 if(!distShapeShape1.IsDone())
325 return Standard_False;
326 if(distShapeShape1.Value() > 0.01) {
327 di << "Dist = " <<distShapeShape1.Value() <<"\n";
328 return Standard_False;
330 di << "Dist1 = " <<distShapeShape1.Value() <<"\n";
332 //////////////////////////////////////////////////////////////////////////
334 transformer1.Perform(step1ModifiedShape);
335 if(!transformer1.IsDone()) {
336 di << "Not Done1 \n";
337 return Standard_False;
339 TopoDS_Shape step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
341 //This is identity matrix for values but for type is gp_Rotation ?!
342 gp_Trsf2d mirror11 = mirror1;
343 mirror11.PreMultiply(mirror1);
345 BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN);
346 if(!distShapeShape2.IsDone())
347 return Standard_False;
349 //This last test case give error (the value is 1008.8822038689706)
350 if(distShapeShape2.Value() > 0.01) {
351 di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n";
352 Standard_Integer N = distShapeShape2.NbSolution();
353 di << "Nb = " <<N <<"\n";
354 for (Standard_Integer i=1;i <= N;i++)
355 di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n";
356 return Standard_False;
358 di << "Distance2 = " <<distShapeShape2.Value() <<"\n";
360 return Standard_True;
362 static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a)
366 di <<"OCC23774: invalid number of input parameters\n";
370 const char *ns1 = (a[1]), *ns2 = (a[2]);
371 TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2));
372 if (S1.IsNull() || S2.IsNull()) {
373 di <<"OCC23774: Null input shapes\n";
376 const TopoDS_Face& aFace = TopoDS::Face(S1);
377 if(!OCC23774Test(aFace, S2, di))
378 di << "Something is wrong\n";
383 #include <GeomConvert_ApproxSurface.hxx>
384 #include <Geom_BSplineSurface.hxx>
386 #include <OSD_Thread.hxx>
388 struct GeomConvertTest_Data
390 Standard_Integer nbupoles;
391 Handle(Geom_Surface) surf;
394 static Standard_Address GeomConvertTest (Standard_Address data)
396 GeomConvertTest_Data* info = (GeomConvertTest_Data*)data;
398 GeomConvert_ApproxSurface aGAS (info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
399 if (!aGAS.IsDone()) {
400 cout << "Error: ApproxSurface is not done!" << endl;
403 const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
404 if (aBSurf.IsNull()) {
405 cout << "Error: BSplineSurface is not created!" << endl;
408 cout << "Number of UPoles:" << aBSurf->NbUPoles();
409 if (aBSurf->NbUPoles() == info->nbupoles)
411 cout << ": OK" << endl;
412 return data; // any non-null pointer
416 cout << ": Error, must be " << info->nbupoles << endl;
421 static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
424 cout << "Error: invalid number of arguments" << endl;
428 struct GeomConvertTest_Data aStorage;
429 aStorage.nbupoles = Draw::Atoi(argv[1]);
430 aStorage.surf = DrawTrSurf::GetSurface(argv[2]);
431 if (aStorage.surf.IsNull())
433 cout << "Error: " << argv[2] << " is not a DRAW surface!" << endl;
437 // start conversion in several threads
438 const int NBTHREADS = 100;
439 OSD_Thread aThread[NBTHREADS];
440 for (int i=0; i < NBTHREADS; i++)
442 aThread[i].SetFunction (GeomConvertTest);
443 if (!aThread[i].Run(&aStorage))
444 di << "Error: Cannot start thread << " << i << "\n";
448 for (int i=0; i < NBTHREADS; i++)
450 Standard_Address aResult = 0;
451 if (!aThread[i].Wait(aResult))
452 di << "Error: Failed waiting for thread << " << i << "\n";
454 di << "Error: wrong number of poles in thread " << i << "!\n";
460 #include <GeomInt_IntSS.hxx>
462 struct GeomIntSSTest_Data
464 Standard_Integer nbsol;
465 Handle(Geom_Surface) surf1, surf2;
468 static Standard_Address GeomIntSSTest (Standard_Address data)
470 GeomIntSSTest_Data* info = (GeomIntSSTest_Data*)data;
471 GeomInt_IntSS anInter;
472 anInter.Perform (info->surf1, info->surf2, Precision::Confusion(), Standard_True);
473 if (!anInter.IsDone()) {
474 cout << "An intersection is not done!" << endl;
478 cout << "Number of Lines:" << anInter.NbLines();
479 if (anInter.NbLines() == info->nbsol)
481 cout << ": OK" << endl;
482 return data; // any non-null pointer
486 cout << ": Error, must be " << info->nbsol << endl;
491 static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
494 cout << "Error: invalid number of arguments" << endl;
498 struct GeomIntSSTest_Data aStorage;
499 aStorage.nbsol = Draw::Atoi(argv[1]);
500 aStorage.surf1 = DrawTrSurf::GetSurface(argv[2]);
501 aStorage.surf2 = DrawTrSurf::GetSurface(argv[3]);
502 if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull())
504 cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" << endl;
508 // start conversion in several threads
509 const int NBTHREADS = 100;
510 OSD_Thread aThread[NBTHREADS];
511 for (int i=0; i < NBTHREADS; i++)
513 aThread[i].SetFunction (GeomIntSSTest);
514 if (!aThread[i].Run(&aStorage))
515 di << "Error: Cannot start thread << " << i << "\n";
519 for (int i=0; i < NBTHREADS; i++)
521 Standard_Address aResult = 0;
522 if (!aThread[i].Wait(aResult))
523 di << "Error: Failed waiting for thread << " << i << "\n";
525 di << "Error: wrong number of intersections in thread " << i << "!\n";
531 #include <Geom_SurfaceOfRevolution.hxx>
532 static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
535 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
539 Standard_Integer ucontinuity = 1;
540 Standard_Integer vcontinuity = 1;
541 Standard_Boolean iscnu = false;
542 Standard_Boolean iscnv = false;
544 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
546 QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
547 QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
552 #include <gp_Ax1.hxx>
553 #include <gp_Ax22d.hxx>
554 #include <Geom_Plane.hxx>
555 #include <Geom2d_Circle.hxx>
556 #include <Geom2d_TrimmedCurve.hxx>
557 #include <BRepBuilderAPI_MakeEdge.hxx>
558 #include <BRepPrimAPI_MakeRevol.hxx>
559 #include <Geom2d_OffsetCurve.hxx>
561 static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
563 // Check the command arguments
566 di << "Error: " << argv[0] << " - invalid number of arguments\n";
567 di << "Usage: type help " << argv[0] << "\n";
568 return 1; // TCL_ERROR
571 gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
572 gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
573 Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
575 di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>\n";
576 di << "-----------------------------------------------------------------------\n";
578 Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
579 Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
580 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
582 DBRep::Set("e1", E1);
584 BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
585 TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
587 DBRep::Set("f1", F1);
589 di << "Result: f1\n";
591 di << "<<<< Preparing sample surface of revolution based on offset curve >>>>\n";
592 di << "-----------------------------------------------------------------------\n";
594 Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
595 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
597 DBRep::Set("e2", E2);
599 BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
600 TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
602 DBRep::Set("f2", F2);
604 di << "Result: f2\n";
609 #include <Geom_Curve.hxx>
610 #include <Geom_Surface.hxx>
611 #include <Precision.hxx>
612 #include <ShapeConstruct_ProjectCurveOnSurface.hxx>
613 //=======================================================================
614 //function : OCC24008
616 //=======================================================================
617 static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
620 di << "Usage: " << argv[0] << " invalid number of arguments\n";
623 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]);
624 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]);
625 if (aCurve.IsNull()) {
626 di << "Curve was not read\n";
629 if (aSurf.IsNull()) {
630 di << "Surface was not read\n";
633 ShapeConstruct_ProjectCurveOnSurface aProj;
634 aProj.Init (aSurf, Precision::Confusion());
636 Handle(Geom2d_Curve) aPCurve;
637 aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve);
638 if (aPCurve.IsNull()) {
639 di << "PCurve was not created\n";
643 di << "Exception was caught\n";
648 #include <GeomAdaptor_Surface.hxx>
650 //=======================================================================
651 //function : OCC23945
653 //=======================================================================
655 static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
659 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
660 if (aS.IsNull()) return 1;
662 GeomAdaptor_Surface GS(aS);
664 Standard_Real U = Draw::Atof(a[2]);
665 Standard_Real V = Draw::Atof(a[3]);
667 Standard_Boolean DrawPoint = ( n%3 == 2);
675 GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
676 Draw::Set(a[13],D2U.X());
677 Draw::Set(a[14],D2U.Y());
678 Draw::Set(a[15],D2U.Z());
679 Draw::Set(a[16],D2V.X());
680 Draw::Set(a[17],D2V.Y());
681 Draw::Set(a[18],D2V.Z());
682 Draw::Set(a[19],D2UV.X());
683 Draw::Set(a[20],D2UV.Y());
684 Draw::Set(a[21],D2UV.Z());
689 Draw::Set(a[7],DU.X());
690 Draw::Set(a[8],DU.Y());
691 Draw::Set(a[9],DU.Z());
692 Draw::Set(a[10],DV.X());
693 Draw::Set(a[11],DV.Y());
694 Draw::Set(a[12],DV.Z());
700 Draw::Set(a[4],P.X());
701 Draw::Set(a[5],P.Y());
702 Draw::Set(a[6],P.Z());
705 DrawTrSurf::Set(a[n],P);
711 //=======================================================================
712 //function : OCC11758
714 //=======================================================================
715 static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
717 if (n != 1) return 1;
719 const char* theStr = "0123456789";
720 Standard_Integer i, j;
721 for ( i = 0; i < 5; ++i ) {
722 // TCollection_AsciiString(const Standard_CString astring)
723 TCollection_AsciiString a(theStr+i);
724 // IsEqual (const Standard_CString other)const
725 //assert( a == theStr+i );
726 QCOMPARE ( a , theStr+i );
728 //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen )
729 TCollection_AsciiString b(theStr+i, 3);
730 //assert( b.Length() == 3 );
731 //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 );
732 //assert( strlen( b.ToCString() ) == 3 );
733 QCOMPARE ( b.Length() , 3 );
734 QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 );
735 QCOMPARE ( b.Length() , 3 );
737 //TCollection_AsciiString(const Standard_Integer aValue)
738 TCollection_AsciiString c(i);
739 //assert( c.IsIntegerValue() );
740 //assert( c.IntegerValue() == i );
741 QCOMPARE ( c.IsIntegerValue() , Standard_True );
742 QCOMPARE ( c.IntegerValue() , i );
744 //TCollection_AsciiString(const Standard_Real aValue)
745 TCollection_AsciiString d( 0.1*i );
746 //assert( d.IsRealValue() );
747 //assert( TCollection_AsciiString(3.3) == "3.3");
748 QCOMPARE ( d.IsRealValue() , Standard_True );
749 QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" );
751 //TCollection_AsciiString(const TCollection_AsciiString& astring)
752 TCollection_AsciiString e(d);
754 //assert( e.Length() == d.Length() );
755 //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
757 QCOMPARE ( e.Length() , d.Length() );
758 QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
760 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
761 // const Standard_Character other )
762 TCollection_AsciiString f(e,'\a');
763 //assert( f.Length() == e.Length() + 1 );
764 //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 );
765 //assert( f.Value( f.Length() ) == '\a');
766 QCOMPARE ( f.Length() , e.Length() + 1 );
767 QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 );
768 QCOMPARE ( f.Value( f.Length() ) , '\a' );
770 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
771 // const Standard_CString other )
772 TCollection_AsciiString g(f, theStr);
773 //assert( g.Length() == f.Length() + strlen( theStr ));
774 //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 );
775 //assert( g.Search( theStr ) == f.Length() + 1 );
776 QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) );
777 QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 );
778 QCOMPARE ( g.Search( theStr ) , f.Length() + 1 );
780 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
781 // const TCollection_AsciiString& other )
782 TCollection_AsciiString h(d,a);
783 //assert( h.Length() == d.Length() + a.Length() );
784 //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 );
785 //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 );
786 QCOMPARE ( h.Length() , d.Length() + a.Length() );
787 QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 );
788 QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 );
790 // AssignCat(const Standard_CString other)
791 c.AssignCat( a.ToCString() );
792 //assert( c.Length() == 1 + a.Length() );
793 //assert( c.Search( a ) == 2 );
794 QCOMPARE ( c.Length() , 1 + a.Length() );
795 QCOMPARE ( c.Search( a ) , 2 );
797 // AssignCat(const TCollection_AsciiString& other)
798 Standard_Integer dl = d.Length();
800 //assert( d.Length() == dl + a.Length() );
801 //assert( d.Search( a ) == dl + 1 );
802 QCOMPARE ( d.Length() , dl + a.Length() );
803 QCOMPARE ( d.Search( a ) , dl + 1 );
806 TCollection_AsciiString capitalize("aBC");
807 capitalize.Capitalize();
808 //assert( capitalize == "Abc" );
809 QCOMPARE ( capitalize , "Abc" );
811 // Copy(const Standard_CString fromwhere)
813 //assert( d == theStr+i );
814 QCOMPARE ( d , theStr+i );
816 // Copy(const TCollection_AsciiString& fromwhere)
818 // IsEqual (const TCollection_AsciiString& other)const
822 // Insert(const Standard_Integer where, const Standard_CString what)
824 d.Insert( 2, theStr );
825 //assert( d.Length() == dl + strlen( theStr ));
826 //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 );
827 QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) );
828 QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 );
830 //Insert(const Standard_Integer where,const Standard_Character what)
832 d.Insert( i+1, 'i' );
833 //assert( d.Length() == strlen( theStr ) + 1 );
834 //assert( d.Value( i+1 ) == 'i');
835 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
836 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
837 QCOMPARE ( d.Value( i+1 ) , 'i' );
838 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
840 //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
842 d.Insert( i+1, TCollection_AsciiString( "i" ));
843 //assert( d.Length() == strlen( theStr ) + 1 );
844 //assert( d.Value( i+1 ) == 'i');
845 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
846 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
847 QCOMPARE ( d.Value( i+1 ) , 'i' );
848 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
850 // IsDifferent (const Standard_CString other)const
851 //assert( d.IsDifferent( theStr ));
852 //assert( d.IsDifferent( "theStr" ));
853 //assert( d.IsDifferent( "" ));
854 //assert( !d.IsDifferent( d.ToCString() ));
855 QCOMPARE ( d.IsDifferent( theStr ) , Standard_True );
856 QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True );
857 QCOMPARE ( d.IsDifferent( "" ) , Standard_True );
858 QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True );
860 // IsDifferent (const TCollection_AsciiString& other)const
861 //assert( d.IsDifferent( TCollection_AsciiString() ));
862 //assert( d.IsDifferent( a ));
863 //assert( d.IsDifferent( h ));
864 //assert( !d.IsDifferent( d ));
865 QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True );
866 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
867 QCOMPARE ( d.IsDifferent( h ) , Standard_True );
868 QCOMPARE ( !d.IsDifferent( d ) , Standard_True );
870 // IsLess (const Standard_CString other)const
871 //assert( TCollection_AsciiString ("0"). IsLess("1"));
872 //assert( TCollection_AsciiString ("0"). IsLess("00"));
873 //assert( TCollection_AsciiString (""). IsLess("0"));
874 //assert( !TCollection_AsciiString("1"). IsLess("0"));
875 //assert( !TCollection_AsciiString("00").IsLess("0"));
876 //assert( !TCollection_AsciiString("0"). IsLess(""));
877 //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1));
878 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True );
879 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True );
880 QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True );
881 QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True );
882 QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True );
883 QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True );
884 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True );
886 // IsLess (const TCollection_AsciiString& other)const
887 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )));
888 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")));
889 //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )));
890 //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )));
891 //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )));
892 //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )));
893 //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)));
894 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True );
895 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True );
896 QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True );
897 QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True );
898 QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True );
899 QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True );
900 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True );
902 // IsGreater (const Standard_CString other)const
903 //assert( !TCollection_AsciiString("0"). IsGreater("1"));
904 //assert( !TCollection_AsciiString("0"). IsGreater("00"));
905 //assert( !TCollection_AsciiString(""). IsGreater("0"));
906 //assert( TCollection_AsciiString ("1"). IsGreater("0"));
907 //assert( TCollection_AsciiString ("00").IsGreater("0"));
908 //assert( TCollection_AsciiString ("0"). IsGreater(""));
909 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i));
910 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True );
911 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True );
912 QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True );
913 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True );
914 QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True );
915 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True );
916 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True );
918 // IsGreater (const TCollection_AsciiString& other)const
919 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )));
920 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")));
921 //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )));
922 //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )));
923 //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )));
924 //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )));
925 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)));
926 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True );
927 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True );
928 QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
929 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
930 QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True );
931 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True );
932 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True );
934 // void Read(Standard_IStream& astream)
935 std::istringstream is( theStr );
937 //assert( e == theStr );
938 QCOMPARE ( e , theStr );
940 // Standard_Integer SearchFromEnd (const Standard_CString what)const
941 //assert( e.SearchFromEnd( theStr + i ) == i + 1 );
942 QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 );
944 // SetValue(const Standard_Integer where, const Standard_CString what)
945 e.SetValue( i+1, "what");
946 //assert( e.Search( "what" ) == i+1 );
947 //assert( e.Length() == strlen( theStr ));
948 QCOMPARE ( e.Search( "what" ) , i+1 );
949 QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) );
951 // TCollection_AsciiString Split (const Standard_Integer where)
954 //assert( d.Length() + e.Length() == strlen( theStr ));
955 QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
957 // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
958 // const Standard_Integer ToIndex) const
960 d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 );
961 //assert( d.Length() == 3 );
962 //assert( d.Value(1) == theStr[ i ]);
963 QCOMPARE ( d.Length() , 3 );
964 QCOMPARE ( d.Value(1) , theStr[ i ] );
966 // TCollection_AsciiString Token (const Standard_CString separators,
967 // const Standard_Integer whichone) const
969 for ( j = 0; j < i; ++j ) {
970 e += TCollection_AsciiString( theStr[j] ) + " ";
971 //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 ));
972 QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) );
975 for ( i = 0; i < 5; ++i )
977 // TCollection_ExtendedString (const Standard_CString astring,
978 // const Standard_Boolean isMultiByte)
979 const TCollection_ExtendedString a( theStr+i );
980 //assert( TCollection_AsciiString( a ) == theStr+i );
981 QCOMPARE ( TCollection_AsciiString( a ) , theStr+i );
983 //TCollection_ExtendedString (const Standard_ExtString astring)
984 const TCollection_ExtendedString b( a.ToExtString() );
988 // TCollection_ExtendedString (const Standard_Integer length,
989 // const Standard_ExtCharacter filler )
990 const TCollection_ExtendedString c( i, 1 );
991 //assert( c.Length() == i );
992 QCOMPARE ( c.Length() , i );
993 if ( c.Length() > 0 ) {
994 //assert( c.Value( i ) == 1 );
995 QCOMPARE ( c.Value( i ) , 1 );
998 // TCollection_ExtendedString (const Standard_Integer aValue)
999 TCollection_ExtendedString d( i );
1000 const TCollection_AsciiString da( d );
1001 //assert( da.IsIntegerValue() );
1002 //assert( da.IntegerValue() == i );
1003 QCOMPARE ( da.IsIntegerValue() , Standard_True );
1004 QCOMPARE ( da.IntegerValue(), i );
1006 // TCollection_ExtendedString (const Standard_Real aValue)
1007 const TCollection_ExtendedString e( 0.1 * i );
1008 const TCollection_AsciiString ea( e );
1009 //assert( ea.IsRealValue() );
1010 //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 );
1011 QCOMPARE ( ea.IsRealValue() , Standard_True );
1012 QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True );
1014 // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1015 const TCollection_ExtendedString f(e);
1016 //assert( f.Length() == e.Length());
1018 QCOMPARE ( f.Length() , e.Length() );
1021 // TCollection_ExtendedString (const TCollection_AsciiString& astring)
1022 const TCollection_ExtendedString g( ea );
1023 //assert( g.Length() == ea.Length() );
1024 //assert( TCollection_AsciiString( g ) == ea );
1025 QCOMPARE ( g.Length() , ea.Length() );
1026 QCOMPARE ( TCollection_AsciiString( g ) , ea );
1028 // AssignCat (const TCollection_ExtendedString& other)
1029 const TCollection_ExtendedString sep(",");
1032 //assert( d.Length() == 2 + g.Length() );
1033 //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i ));
1034 //assert( d.Token( sep.ToExtString(), 2 ) == g );
1035 QCOMPARE ( d.Length() , 2 + g.Length() );
1036 QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) );
1037 QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g );
1039 // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const
1040 const TCollection_ExtendedString cat = a.Cat( sep );
1041 //assert( cat.Length() == a.Length() + sep.Length() );
1042 //assert( cat.Search( a ) == 1 );
1043 //assert( cat.Search( sep ) == a.Length() + 1 );
1044 QCOMPARE ( cat.Length() , a.Length() + sep.Length() );
1045 QCOMPARE ( cat.Search( a ) , 1 );
1046 QCOMPARE ( cat.Search( sep ) , a.Length() + 1 );
1048 // Copy (const TCollection_ExtendedString& fromwhere)
1050 //assert( d.Length() == cat.Length() );
1051 //assert( d == cat );
1052 QCOMPARE ( d.Length() , cat.Length() );
1053 QCOMPARE ( d , cat );
1055 // IsEqual (const Standard_ExtString other) const
1056 //assert( d.IsEqual( d.ToExtString() ));
1057 QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1059 // IsDifferent (const Standard_ExtString other ) const
1060 //assert( d.IsDifferent( a.ToExtString() ));
1061 QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1063 // IsDifferent (const TCollection_ExtendedString& other) const
1064 //assert( d.IsDifferent( a ));
1065 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
1067 // IsLess (const Standard_ExtString other) const
1068 const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1);
1069 //assert( l0. IsLess( l1.ToExtString() ));
1070 //assert( l0. IsLess( l00.ToExtString() ));
1071 //assert( l. IsLess( l0.ToExtString() ));
1072 //assert( ! l1. IsLess( l0.ToExtString() ));
1073 //assert( ! l00.IsLess( l0.ToExtString() ));
1074 //assert( ! l0. IsLess( l.ToExtString() ));
1075 //assert( ls.IsLess( ls1.ToExtString() ));
1076 QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True );
1077 QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True );
1078 QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True );
1079 QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True );
1080 QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True );
1081 QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True );
1082 QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True );
1084 // IsLess (const TCollection_ExtendedString& other) const
1085 //assert( l0. IsLess( l1 ));
1086 //assert( l0. IsLess( l00 ));
1087 //assert( l. IsLess( l0 ));
1088 //assert( ! l1. IsLess( l0 ));
1089 //assert( ! l00.IsLess( l0 ));
1090 //assert( ! l0. IsLess( l ));
1091 //assert( ls.IsLess( ls1 ));
1092 QCOMPARE ( l0. IsLess( l1 ) , Standard_True );
1093 QCOMPARE ( l0. IsLess( l00 ) , Standard_True );
1094 QCOMPARE ( l. IsLess( l0 ) , Standard_True );
1095 QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True );
1096 QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True );
1097 QCOMPARE ( ! l0. IsLess( l ) , Standard_True );
1098 QCOMPARE ( ls.IsLess( ls1 ) , Standard_True );
1100 // IsGreater (const Standard_ExtString other) const
1101 //assert( ! l0.IsGreater( l1.ToExtString() ));
1102 //assert( ! l0.IsGreater( l00.ToExtString() ));
1103 //assert( ! l. IsGreater( l0.ToExtString() ));
1104 //assert( l1. IsGreater( l0.ToExtString() ));
1105 //assert( l00.IsGreater( l0.ToExtString() ));
1106 //assert( l0. IsGreater( l.ToExtString() ));
1107 //assert( ls1.IsGreater( ls.ToExtString() ));
1108 QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True );
1109 QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True );
1110 QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True );
1111 QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True );
1112 QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True );
1113 QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True );
1114 QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True );
1116 // IsGreater (const TCollection_ExtendedString& other) const
1117 //assert( ! l0.IsGreater( l1));
1118 //assert( ! l0.IsGreater( l00));
1119 //assert( ! l. IsGreater( l0));
1120 //assert( l1. IsGreater( l0));
1121 //assert( l00.IsGreater( l0));
1122 //assert( l0. IsGreater( l));
1123 //assert( ls1.IsGreater( ls));
1124 QCOMPARE ( ! l0.IsGreater( l1) , Standard_True );
1125 QCOMPARE ( ! l0.IsGreater( l00) , Standard_True );
1126 QCOMPARE ( ! l. IsGreater( l0) , Standard_True );
1127 QCOMPARE ( l1. IsGreater( l0) , Standard_True );
1128 QCOMPARE ( l00.IsGreater( l0) , Standard_True );
1129 QCOMPARE ( l0. IsGreater( l) , Standard_True );
1130 QCOMPARE ( ls1.IsGreater( ls) , Standard_True );
1132 // ==========================
1133 //TCollection_HAsciiString::
1134 // ==========================
1136 // IsDifferent(const Handle(TCollection_HAsciiString)& S)
1137 Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i );
1138 Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 );
1139 //assert( ha1->IsDifferent( ha2 ));
1140 //assert( !ha1->IsDifferent( ha1 ));
1141 QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True );
1142 QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True );
1144 // IsSameString (const Handle(TCollection_HAsciiString)& S)
1145 //assert( !ha1->IsSameString( ha2 ));
1146 //assert( ha1->IsSameString( ha1 ));
1147 QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True );
1148 QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True );
1150 // IsSameState (const Handle(TCollection_HAsciiString)& other) const
1151 //assert( !ha1->IsSameState( ha2 ));
1152 //assert( ha1->IsSameState( ha1 ));
1153 QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True );
1154 QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True );
1156 // IsSameString (const Handle(TCollection_HAsciiString)& S ,
1157 // const Standard_Boolean CaseSensitive) const
1158 //assert( !ha1->IsSameString( ha2, true ));
1159 //assert( ha1->IsSameString( ha1, true ));
1160 //assert( !ha1->IsSameString( ha2, false ));
1161 //assert( ha1->IsSameString( ha1, false ));
1162 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1163 QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True );
1164 QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True );
1165 QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True );
1167 ha1->SetValue( 1, "AbC0000000");
1168 ha2->SetValue( 1, "aBc0000000");
1169 //assert( !ha1->IsSameString( ha2, true ));
1170 //assert( ha1->IsSameString( ha2, false ));
1171 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1172 QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True );
1177 #include <Geom_CylindricalSurface.hxx>
1178 #include <IntTools_FaceFace.hxx>
1179 #include <IntTools_Curve.hxx>
1180 #include <IntTools_PntOn2Faces.hxx>
1182 static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1186 theDI << "Wrong a number of arguments!\n";
1190 Handle(Geom_Plane) plane(new Geom_Plane(
1191 gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
1192 gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
1193 gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000))));
1194 Handle(Geom_CylindricalSurface) cylinder(
1195 new Geom_CylindricalSurface(
1196 gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
1197 gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
1198 gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
1199 19.712534607908712));
1201 DrawTrSurf::Set("pln", plane);
1203 DrawTrSurf::Set("cyl", cylinder);
1206 BRep_Builder builder;
1207 TopoDS_Face face1, face2;
1208 builder.MakeFace(face1, plane, Precision::Confusion());
1209 builder.MakeFace(face2, cylinder, Precision::Confusion());
1210 IntTools_FaceFace anInters;
1211 anInters.SetParameters(false, true, true, Precision::Confusion());
1212 anInters.Perform(face1, face2);
1214 if (!anInters.IsDone())
1216 theDI<<"No intersections found!\n";
1221 //Handle(Geom_Curve) aResult;
1224 const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1225 const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1228 Standard_Integer aNbCurves, aNbPoints;
1230 aNbCurves=aCvsX.Length();
1231 aNbPoints=aPntsX.Length();
1235 for (Standard_Integer i=1; i<=aNbCurves; ++i)
1237 Sprintf(buf, "%s_%d",theArgv[1],i);
1238 theDI << buf << " ";
1240 const IntTools_Curve& aIC = aCvsX(i);
1241 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1242 DrawTrSurf::Set(buf,aC3D);
1245 else if (aNbCurves == 1)
1247 const IntTools_Curve& aIC = aCvsX(1);
1248 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1249 Sprintf(buf, "%s",theArgv[1]);
1250 theDI << buf << " ";
1251 DrawTrSurf::Set(buf,aC3D);
1254 for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1256 const IntTools_PntOn2Faces& aPi=aPntsX(i);
1257 const gp_Pnt& aP=aPi.P1().Pnt();
1259 Sprintf(buf,"%s_p_%d",theArgv[1],i);
1260 theDI << buf << " ";
1261 DrawTrSurf::Set(buf, aP);
1267 #include <BRepAlgo_NormalProjection.hxx>
1268 static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1271 di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)";
1275 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1276 if(myAISContext.IsNull()) {
1277 di << "use 'vinit' command before " << argv[0] << "\n";
1281 TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1]));
1282 TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2]));
1284 BRepAlgo_NormalProjection anormpro(m_Face1);
1285 anormpro.Add(m_Edge);
1286 anormpro.SetDefaultParams();
1288 //anormpro.Compute3d();
1289 //anormpro.SetLimit();
1293 if (anormpro.IsDone())
1295 TopoDS_Shape rshape = anormpro.Projection();
1296 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape);
1297 myAISContext->SetColor (myShape, Quantity_Color(Quantity_NOC_YELLOW), Standard_False);
1298 myAISContext->Display (myShape, Standard_True);
1304 #include <BRepFeat_SplitShape.hxx>
1305 #include <ShapeAnalysis_ShapeContents.hxx>
1306 #include <BRepAlgo.hxx>
1307 static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1310 di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)";
1314 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1315 if(myAISContext.IsNull()) {
1316 di << "use 'vinit' command before " << argv[0] << "\n";
1320 TopoDS_Shape result;
1321 TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1]));
1322 TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2]));
1324 BRepFeat_SplitShape asplit(face);
1325 asplit.Add(wire, face);
1327 result = asplit.Shape();
1328 ShapeAnalysis_ShapeContents ana;
1329 ana.Perform(result);
1332 if (!(BRepAlgo::IsValid(result))) {
1333 di << "Result was checked and it is INVALID\n";
1335 di << "Result was checked and it is VALID\n";
1338 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result);
1339 myAISContext->Display(myShape, Standard_True);
1344 #include <Geom_Circle.hxx>
1345 #include <GeomAdaptor_Curve.hxx>
1346 #include <Extrema_ExtPC.hxx>
1347 #include <gp_Cylinder.hxx>
1348 #include <ElSLib.hxx>
1349 static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1352 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1356 gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 );
1357 gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() );
1358 Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 );
1359 GeomAdaptor_Curve aC3D( aCircle );
1361 Extrema_ExtPC aExtPC( aP3D, aC3D );
1362 //Standard_Real aParam = (aExtPC.Point(1)).Parameter();
1363 gp_Pnt aProj = (aExtPC.Point(1)).Value();
1364 di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n";
1366 // Result of deviation
1367 gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() );
1368 gp_Cylinder aCylinder( aCylAxis, 1890. );
1370 Standard_Real aU = 0., aV = 0.;
1371 ElSLib::Parameters( aCylinder, aProj, aU, aV );
1372 di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n";
1377 #include <Extrema_FuncPSNorm.hxx>
1378 #include <math_FunctionSetRoot.hxx>
1379 #include <math_Vector.hxx>
1380 #include <BRepBuilderAPI_MakeVertex.hxx>
1381 static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1383 Standard_Integer anArgIter = 1;
1386 theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]\n";
1391 Standard_CString aFaceName = theArgv[anArgIter++];
1392 Standard_CString aVertName = theArgv[anArgIter++];
1393 const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
1394 const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
1395 const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
1396 const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
1397 const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
1398 if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
1400 std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1403 if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1405 std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1408 const TopoDS_Face aFace = TopoDS::Face (aShapeF);
1409 const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1410 GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1412 gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1414 Extrema_FuncPSNorm anExtFunc;
1415 math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
1417 math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2);
1418 aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion();
1419 aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite();
1420 aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite();
1421 aFromUV(1) = aUFrom; aFromUV(2) = aVFrom;
1423 anExtFunc.Initialize (aSurf);
1424 anExtFunc.SetPoint (aPnt);
1425 aRoot.SetTolerance (aTolUV);
1426 aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1427 if (!aRoot.IsDone())
1429 std::cerr << "No results!\n";
1433 theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1435 aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1436 DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1440 //! Check boolean operations on NCollection_Map
1441 static Standard_Integer OCC24271 (Draw_Interpretor& di,
1442 Standard_Integer /*theArgNb*/,
1443 const char** /*theArgVec*/)
1446 const Standard_Integer aLeftLower = 1;
1447 const Standard_Integer aLeftUpper = 10;
1448 const Standard_Integer aRightLower = 5;
1449 const Standard_Integer aRightUpper = 15;
1452 NCollection_Map<Standard_Integer> aMapLeft;
1453 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1455 aMapLeft.Add (aKeyIter);
1458 NCollection_Map<Standard_Integer> aMapRight;
1459 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1461 aMapRight.Add (aKeyIter);
1464 QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1465 QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False);
1467 // validate Union operation
1468 NCollection_Map<Standard_Integer> aMapUnion;
1469 aMapUnion.Union (aMapLeft, aMapRight);
1470 QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1);
1471 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter)
1473 QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
1476 // validate Intersection operation
1477 NCollection_Map<Standard_Integer> aMapSect;
1478 aMapSect.Intersection (aMapLeft, aMapRight);
1479 QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1);
1480 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1482 QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1484 QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1485 QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
1487 // validate Substruction operation
1488 NCollection_Map<Standard_Integer> aMapSubsLR;
1489 aMapSubsLR.Subtraction (aMapLeft, aMapRight);
1490 QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower);
1491 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1493 QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
1496 NCollection_Map<Standard_Integer> aMapSubsRL;
1497 aMapSubsRL.Subtraction (aMapRight, aMapLeft);
1498 QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper);
1499 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1501 QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
1504 // validate Difference operation
1505 NCollection_Map<Standard_Integer> aMapDiff;
1506 aMapDiff.Difference (aMapLeft, aMapRight);
1507 QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper);
1508 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1510 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1512 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1514 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1517 // validate Exchange operation
1518 NCollection_Map<Standard_Integer> aMapSwap;
1519 aMapSwap.Exchange (aMapSect);
1520 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1522 QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1524 QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1528 NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1529 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1530 aMapCopy.Remove (34);
1532 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1537 #define QVERIFY(val1) \
1538 di << "Checking " #val1 " == Standard_True" << \
1539 ((val1) == Standard_True ? ": OK\n" : ": Error\n")
1541 #include <GeomInt_IntSS.hxx>
1542 #include <Geom_ConicalSurface.hxx>
1543 #include <Standard_ErrorHandler.hxx>
1546 static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc,
1547 const gp_Dir& theDir,
1548 const gp_Dir& theXDir,
1549 const Standard_Real theRad,
1550 const Standard_Real theSin,
1551 const Standard_Real theCos)
1553 const Standard_Real anA = atan (theSin / theCos);
1554 gp_Ax3 anAxis (theLoc, theDir, theXDir);
1555 Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad);
1560 static Standard_Integer OCC23972(Draw_Interpretor& /*theDI*/,
1561 Standard_Integer theNArg, const char** theArgs)
1563 if (theNArg != 3) return 1;
1565 //process specific cones, cannot read them from files because
1566 //due to rounding the original error in math_FunctionRoots gets hidden
1567 const Handle(Geom_Surface) aS1 = CreateCone(
1568 gp_Pnt(123.694345356663, 789.9, 68.15),
1569 gp_Dir(-1, 3.48029791472957e-016, -8.41302743359754e-017),
1570 gp_Dir(-3.48029791472957e-016, -1, -3.17572289932207e-016),
1574 const Handle(Geom_Surface) aS2 = CreateCone(
1575 gp_Pnt(123.694345356663, 784.9, 68.15),
1576 gp_Dir(-1, -2.5209507537117e-016, -1.49772808948866e-016),
1577 gp_Dir(1.49772808948866e-016, 3.17572289932207e-016, -1),
1582 DrawTrSurf::Set(theArgs[1], aS1);
1583 DrawTrSurf::Set(theArgs[2], aS2);
1588 #include <ShapeFix_EdgeProjAux.hxx>
1589 static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1592 di<<"Usage: " << argv[0] << " invalid number of arguments\n";
1596 TopoDS_Shape aSh = DBRep::Get(argv[1]);
1598 di << argv[0] << " Error: Null input edge\n";
1601 const TopoDS_Edge& anEdge = TopoDS::Edge (aSh);
1603 Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]);
1605 di << argv[0] << " Error: Null input curve\n";
1609 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]);
1611 di << argv[0] << " Error: Null input surface\n";
1615 Standard_Real prec = Draw::Atof(argv[4]);
1620 aB.MakeFace (aFace, aS, Precision::Confusion());
1621 aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion());
1622 aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter());
1625 ShapeFix_EdgeProjAux aProj (aFace, anEdge);
1626 aProj.Compute (prec);
1628 Standard_Boolean isfirstdone = aProj.IsFirstDone();
1629 Standard_Boolean islastdone = aProj.IsLastDone();
1631 Standard_Real first = 0.;
1632 Standard_Real last = 0.;
1633 Standard_Integer isfirstdoneInteger = 0;
1634 Standard_Integer islastdoneInteger = 0;
1638 first = aProj.FirstParam();
1639 isfirstdoneInteger = 1;
1643 last= aProj.LastParam();
1644 islastdoneInteger = 1;
1647 di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n";
1652 template<typename T, typename HT>
1653 static void DoIsNull(Draw_Interpretor& di)
1656 // QVERIFY (aHandle.IsNull());
1657 QCOMPARE (aHandle.IsNull(), Standard_True);
1658 const T* p = aHandle.get();
1659 #if OCC_VERSION_HEX > 0x060700
1662 QCOMPARE (!p, Standard_True);
1663 QCOMPARE (p == 0, Standard_True);
1667 //QVERIFY (!aHandle.IsNull());
1668 QCOMPARE (!aHandle.IsNull(), Standard_True);
1672 QCOMPARE (p != NULL, Standard_True);
1673 QCOMPARE (p != 0, Standard_True);
1676 //=======================================================================
1677 //function : OCC24533
1679 //=======================================================================
1680 static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**)
1682 if (n != 1) return 1;
1684 DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di);
1689 // Dummy class to test interface for compilation issues
1690 class QABugs_HandleClass : public Standard_Transient
1693 Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1695 std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n";
1698 DEFINE_STANDARD_RTTI_INLINE(QABugs_HandleClass,Standard_Transient) // Type definition
1700 DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient)
1703 // Dummy class to test interface for compilation issues
1704 struct QABugs_NHandleClass
1706 Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec)
1708 std::cerr << "QABugs_NHandleClass[" << this << "] " << theArgVec[0] << "\n";
1713 #include <XCAFDoc_ColorTool.hxx>
1714 #include <STEPControl_StepModelType.hxx>
1715 #include <STEPCAFControl_Writer.hxx>
1716 static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1719 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1722 Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");;
1723 TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape();
1724 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape();
1725 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1);
1726 TDataStd_Name::Set(lab1, "Box1");
1728 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1729 XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen);
1730 XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0);
1732 STEPControl_StepModelType mode = STEPControl_AsIs;
1733 STEPCAFControl_Writer writer;
1734 if ( ! writer.Transfer (aDoc, mode ) )
1736 di << "The document cannot be translated or gives no result" << "\n";
1740 writer.Write(argv[1]);
1745 //=======================================================================
1746 //function : OCC23950
1748 //=======================================================================
1749 static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1752 di << "Usage : " << argv[0] << " step_file\n";
1756 Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy");
1757 TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
1759 TopLoc_Location location0 (t0);
1761 TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1762 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6);
1763 TDataStd_Name::Set(lab1, "Point1");
1765 TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
1766 TDataStd_Name::Set(labelA0, "ASSEMBLY");
1768 TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
1769 XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->UpdateAssemblies();
1771 Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
1772 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
1773 XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
1775 STEPControl_StepModelType mode = STEPControl_AsIs;
1776 STEPCAFControl_Writer writer;
1777 if (! writer.Transfer (aDoc, mode))
1779 di << "The document cannot be translated or gives no result\n";
1783 writer.Write (argv[1]);
1787 //=======================================================================
1788 //function : OCC24667
1790 //=======================================================================
1791 static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1795 di << "OCC24667 result Wire_spine Profile [Mode [Approx]]\n";
1796 di << "Mode = 0 - CorrectedFrenet,\n";
1797 di << " = 1 - Frenet,\n";
1798 di << " = 2 - DiscreteTrihedron\n";
1799 di << "Approx - force C1-approximation if result is C0\n";
1803 if (n > 1 && n < 4) return 1;
1805 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
1806 if ( Spine.IsNull()) return 1;
1808 TopoDS_Shape Profile = DBRep::Get(a[3]);
1809 if ( Profile.IsNull()) return 1;
1811 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
1814 Standard_Integer iMode = atoi(a[4]);
1816 Mode = GeomFill_IsFrenet;
1817 else if (iMode == 2)
1818 Mode = GeomFill_IsDiscreteTrihedron;
1821 Standard_Boolean ForceApproxC1 = Standard_False;
1823 ForceApproxC1 = Standard_True;
1825 BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine),
1830 TopoDS_Shape S = aPipe.Shape();
1831 TopoDS_Shape aSF = aPipe.FirstShape();
1832 TopoDS_Shape aSL = aPipe.LastShape();
1836 TCollection_AsciiString aStrF(a[1], "_f");
1837 TCollection_AsciiString aStrL(a[1], "_l");
1839 DBRep::Set(aStrF.ToCString(), aSF);
1840 DBRep::Set(aStrL.ToCString(), aSL);
1845 #include <BRepPrimAPI_MakeCylinder.hxx>
1846 #include <BRepBuilderAPI_Copy.hxx>
1847 #include <BRepTools_NurbsConvertModification.hxx>
1848 static TopoDS_Shape CreateTestShape (int& theShapeNb)
1850 TopoDS_Compound aComp;
1851 BRep_Builder aBuilder;
1852 aBuilder.MakeCompound (aComp);
1853 //NURBS modifier is used to increase footprint of each shape
1854 Handle(BRepTools_NurbsConvertModification) aNurbsModif = new BRepTools_NurbsConvertModification;
1855 TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid();
1856 BRepTools_Modifier aModifier (aRefShape, aNurbsModif);
1857 if (aModifier.IsDone()) {
1858 aRefShape = aModifier.ModifiedShape (aRefShape);
1861 for (; theShapeNb > 0; --theShapeNb) {
1862 TopoDS_Shape aShape;
1863 if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists
1864 aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape();
1866 aShape = CreateTestShape (theShapeNb);
1868 aBuilder.Add (aComp, aShape);
1873 #include <TDataStd_Integer.hxx>
1874 #include <TNaming_Builder.hxx>
1875 static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1878 di << "Usage: " << argv[0] << " invalid number of arguments\n";
1881 TCollection_ExtendedString aFileName (argv[1]);
1882 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
1884 Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
1886 Handle(TDocStd_Document) aDoc;
1887 anApp->NewDocument ("XmlOcaf", aDoc);
1888 TDF_Label aLab = aDoc->Main();
1889 TDataStd_Integer::Set (aLab, 0);
1890 int n = 10000; //must be big enough
1891 TopoDS_Shape aShape = CreateTestShape (n);
1892 TNaming_Builder aBuilder (aLab);
1893 aBuilder.Generated (aShape);
1895 aSStatus = anApp->SaveAs (aDoc, aFileName);
1896 anApp->Close (aDoc);
1898 QCOMPARE (aSStatus, PCDM_SS_OK);
1902 #include <TDF_AttributeIterator.hxx>
1903 //=======================================================================
1904 //function : OCC24755
1906 //=======================================================================
1907 static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1911 std::cout << "Usage : " << a[0] << "\n";
1915 Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
1916 Handle(TDocStd_Document) aDoc;
1917 anApp->NewDocument ("BinOcaf", aDoc);
1918 TDF_Label aLab = aDoc->Main();
1919 // Prepend an int value.
1920 TDataStd_Integer::Set (aLab, 0);
1922 TDataStd_Name::Set (aLab, "test");
1923 // Append a double value.
1924 aLab.AddAttribute(new TDataStd_Real(), true/*append*/);
1926 TDF_AttributeIterator i (aLab);
1927 Handle(TDF_Attribute) anAttr = i.Value();
1928 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True);
1931 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True);
1934 QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Real)), Standard_True);
1941 MyStubObject() : ptr(0L) {}
1942 MyStubObject(void* thePtr) : ptr(thePtr) {}
1947 //=======================================================================
1948 //function : OCC24834
1950 //=======================================================================
1951 static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a)
1955 std::cout << "Usage : " << a[0] << "\n";
1959 int i = sizeof (char*);
1961 std::cout << "64-bit architecture is not supported.\n";
1965 NCollection_List<MyStubObject> aList;
1966 const Standard_Integer aSmallBlockSize = 40;
1967 const Standard_Integer aLargeBlockSize = 1500000;
1969 // quick populate memory with large blocks
1974 aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize)));
1977 catch (Standard_Failure)
1979 di << "caught out of memory for large blocks: OK\n";
1983 di << "skept out of memory for large blocks: Error\n";
1986 // allocate small blocks
1991 aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize)));
1994 catch (Standard_Failure)
1996 di << "caught out of memory for small blocks: OK\n";
2000 di << "skept out of memory for small blocks: Error\n";
2003 // release all allocated blocks
2004 for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next())
2006 Standard::Free(it.Value().ptr);
2012 #include <Geom2dAPI_InterCurveCurve.hxx>
2013 #include <IntRes2d_IntersectionPoint.hxx>
2014 //=======================================================================
2015 //function : OCC24889
2017 //=======================================================================
2018 static Standard_Integer OCC24889 (Draw_Interpretor& theDI,
2019 Standard_Integer /*theNArg*/,
2020 const char** /*theArgs*/)
2023 Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle(
2024 gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2026 Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle(
2027 gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 );
2029 Handle( Geom2d_TrimmedCurve ) aTrim[2] = {
2030 new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ),
2031 new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 )
2034 DrawTrSurf::Set("c_1", aTrim[0]);
2035 DrawTrSurf::Set("c_2", aTrim[1]);
2038 const Standard_Real aTol = Precision::Confusion();
2039 Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol );
2041 const IntRes2d_IntersectionPoint& aIntPnt =
2042 aIntTool.Intersector().Point( 1 );
2044 gp_Pnt2d aIntRes = aIntTool.Point( 1 );
2045 Standard_Real aPar[2] = {
2046 aIntPnt.ParamOnFirst(),
2047 aIntPnt.ParamOnSecond()
2050 //theDI.precision( 5 );
2051 theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n";
2052 for (int i = 0; i < 2; ++i)
2054 theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() <<
2055 "; LastParam = " << aTrim[i]->LastParameter() <<
2056 "; IntParameter = " << aPar[i] << "\n";
2062 #include <math_GlobOptMin.hxx>
2063 #include <math_MultipleVarFunctionWithHessian.hxx>
2064 //=======================================================================
2065 //function : OCC25004
2066 //purpose : Check extremaCC on Branin function.
2067 //=======================================================================
2069 // f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s
2070 // Standard borders are:
2073 class BraninFunction : public math_MultipleVarFunctionWithHessian
2079 b = 5.1 / (4.0 * M_PI * M_PI);
2083 t = 1.0 / (8.0 * M_PI);
2085 virtual Standard_Integer NbVariables() const
2089 virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F)
2091 Standard_Real u = X(1);
2092 Standard_Real v = X(2);
2094 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2095 Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion.
2096 F = a * aSqPt * aSqPt + aLnPt + s;
2097 return Standard_True;
2099 virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G)
2101 Standard_Real u = X(1);
2102 Standard_Real v = X(2);
2104 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2105 G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u);
2106 G(2) = 2 * a * aSqPt;
2108 return Standard_True;
2110 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
2115 return Standard_True;
2117 virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H)
2122 Standard_Real u = X(1);
2123 Standard_Real v = X(2);
2125 Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
2126 Standard_Real aTmpPt = c - 2 * b *u; // Tmp part.
2127 H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u);
2128 H(1,2) = 2 * a * aTmpPt;
2132 return Standard_True;
2136 // Standard parameters.
2137 Standard_Real a, b, c, r, s, t;
2140 static Standard_Integer OCC25004 (Draw_Interpretor& theDI,
2141 Standard_Integer /*theNArg*/,
2142 const char** /*theArgs*/)
2144 BraninFunction aFunc;
2146 math_Vector aLower(1,2), aUpper(1,2);
2152 Standard_Integer aGridOrder = 16;
2153 math_Vector aFuncValues(1, aGridOrder * aGridOrder);
2155 Standard_Real aLipConst = 0;
2156 math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2);
2158 // Get Lipshitz constant estimation on regular grid.
2159 Standard_Integer i, j, idx = 1;
2160 for(i = 1; i <= aGridOrder; i++)
2162 for(j = 1; j <= aGridOrder; j++)
2164 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2165 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2167 aFunc.Value(aCurrPnt1, aFuncValues(idx));
2172 Standard_Integer k, l;
2173 Standard_Integer idx1, idx2;
2174 for(i = 1; i <= aGridOrder; i++)
2175 for(j = 1; j <= aGridOrder; j++)
2176 for(k = 1; k <= aGridOrder; k++)
2177 for(l = 1; l <= aGridOrder; l++)
2179 if (i == k && j == l)
2182 aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
2183 aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
2184 idx1 = (i - 1) * aGridOrder + j;
2186 aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0);
2187 aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0);
2188 idx2 = (k - 1) * aGridOrder + l;
2190 aCurrPnt1.Add(-aCurrPnt2);
2191 Standard_Real dist = aCurrPnt1.Norm();
2193 Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist;
2198 math_GlobOptMin aFinder(&aFunc, aLower, aUpper, aLipConst);
2200 //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475)
2202 Standard_Real anExtValue = aFinder.GetF();
2203 theDI << "F = " << anExtValue << "\n";
2205 Standard_Integer aNbExt = aFinder.NbExtrema();
2206 theDI << "NbExtrema = " << aNbExt << "\n";
2211 #include <OSD_Environment.hxx>
2212 #include <Plugin.hxx>
2213 #include <Plugin_Macro.hxx>
2214 #include <Resource_Manager.hxx>
2216 #define THE_QATEST_DOC_FORMAT "My Proprietary Format"
2218 #define QA_CHECK(theDesc, theExpr, theValue) \
2220 const bool isTrue = !!(theExpr); \
2221 std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \
2224 class Test_TDocStd_Application : public TDocStd_Application
2228 Test_TDocStd_Application ()
2230 // explicitly initialize resource manager
2231 myResources = new Resource_Manager ("");
2232 myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT);
2233 myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document");
2234 myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml");
2237 virtual Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString&) Standard_OVERRIDE
2239 return new XmlDrivers_DocumentRetrievalDriver ();
2241 virtual Handle(PCDM_StorageDriver) WriterFromFormat (const TCollection_ExtendedString&) Standard_OVERRIDE
2243 return new XmlDrivers_DocumentStorageDriver ("Test");
2245 virtual Standard_CString ResourcesName() Standard_OVERRIDE { return ""; }
2248 //=======================================================================
2249 //function : OCC24925
2251 //=======================================================================
2252 static Standard_Integer OCC24925 (Draw_Interpretor& theDI,
2253 Standard_Integer theArgNb,
2254 const char** theArgVec)
2259 std::cout << "Error: wrong syntax! See usage:\n";
2260 theDI.PrintHelp (theArgVec[0]);
2264 Standard_Integer anArgIter = 1;
2265 TCollection_ExtendedString aFileName = theArgVec[anArgIter++];
2266 TCollection_AsciiString aPlugin = "TKXml";
2267 TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx
2268 TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx
2269 if (anArgIter < theArgNb)
2271 aPlugin = theArgVec[anArgIter++];
2272 aSaver = theArgVec[anArgIter++];
2273 aLoader = theArgVec[anArgIter++];
2276 PCDM_StoreStatus aSStatus = PCDM_SS_Failure;
2277 PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError;
2279 Handle(TDocStd_Application) anApp = new Test_TDocStd_Application ();
2281 Handle(TDocStd_Document) aDoc;
2282 anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc);
2283 TDF_Label aLab = aDoc->Main();
2284 TDataStd_Integer::Set (aLab, 0);
2285 TDataStd_Name::Set (aLab, "QABugs_19.cxx");
2287 aSStatus = anApp->SaveAs (aDoc, aFileName);
2288 anApp->Close (aDoc);
2290 QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true);
2293 Handle(TDocStd_Document) aDoc;
2294 aRStatus = anApp->Open (aFileName, aDoc);
2295 anApp->Close (aDoc);
2297 QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true);
2301 //=======================================================================
2302 //function : OCC25043
2304 //=======================================================================
2305 #include <BRepAlgoAPI_Check.hxx>
2306 static Standard_Integer OCC25043 (Draw_Interpretor& theDI,
2307 Standard_Integer theArgNb,
2308 const char** theArgVec)
2310 if (theArgNb != 2) {
2311 theDI << "Usage: " << theArgVec[0] << " shape\n";
2315 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
2316 if (aShape.IsNull())
2318 theDI << theArgVec[1] << " shape is NULL\n";
2322 BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True);
2324 if (!anAlgoApiCheck.IsValid())
2326 BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result());
2327 for (; anCheckIter.More(); anCheckIter.Next())
2329 const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value();
2330 const TopTools_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1();
2331 TopTools_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes);
2332 for (; aFaultyIter.More(); aFaultyIter.Next())
2334 const TopoDS_Shape& aFaultyShape = aFaultyIter.Value();
2336 Standard_Boolean anIsFaultyShapeFound = Standard_False;
2337 TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType());
2338 for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next())
2340 if (anExp.Current().IsEqual(aFaultyShape))
2341 anIsFaultyShapeFound = Standard_True;
2344 if (!anIsFaultyShapeFound)
2346 theDI << "Error. Faulty Shape is NOT found in source shape.\n";
2351 theDI << "Info. Faulty shape is found in source shape\n";
2358 theDI << "Problems are not detected. Test is not performed.";
2364 //=======================================================================
2365 //function : OCC24606
2367 //=======================================================================
2368 static Standard_Integer OCC24606 (Draw_Interpretor& theDI,
2369 Standard_Integer theArgNb,
2370 const char** theArgVec)
2374 std::cerr << "Error: incorrect number of arguments.\n";
2375 theDI << "Usage : " << theArgVec[0] << "\n";
2379 Handle(V3d_View) aView = ViewerTest::CurrentView();
2382 std::cerr << "Errro: no active view, please call 'vinit'.\n";
2386 aView->DepthFitAll();
2392 //=======================================================================
2393 //function : OCC25202
2395 //=======================================================================
2396 #include <ShapeBuild_ReShape.hxx>
2397 static Standard_Integer OCC25202 ( Draw_Interpretor& theDI,
2398 Standard_Integer theArgN,
2399 const char** theArgVal)
2402 //reshape res shape numF1 face1 numF2 face2
2405 theDI << "Use: reshape res shape numF1 face1 numF2 face2\n";
2409 TopoDS_Shape aShape = DBRep::Get(theArgVal[2]);
2410 const Standard_Integer aNumOfRE1 = Draw::Atoi(theArgVal[3]),
2411 aNumOfRE2 = Draw::Atoi(theArgVal[5]);
2412 TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])),
2413 aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6]));
2417 theDI << theArgVal[2] << " is null shape\n";
2421 if(aShapeForRepl1.IsNull())
2423 theDI << theArgVal[4] << " is not a replaced type\n";
2427 if(aShapeForRepl2.IsNull())
2429 theDI << theArgVal[6] << " is not a replaced type\n";
2434 TopoDS_Shape aReplacedShape;
2435 ShapeBuild_ReShape aReshape;
2437 //////////////////// explode (begin)
2438 TopTools_MapOfShape M;
2440 Standard_Integer aNbShapes = 0;
2441 for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next())
2443 const TopoDS_Shape& Sx = ex.Current();
2444 Standard_Boolean added = M.Add(Sx);
2448 if(aNbShapes == aNumOfRE1)
2450 aReplacedShape = Sx;
2452 aReshape.Replace(aReplacedShape, aShapeForRepl1);
2455 if(aNbShapes == aNumOfRE2)
2457 aReplacedShape = Sx;
2459 aReshape.Replace(aReplacedShape, aShapeForRepl2);
2463 //////////////////// explode (end)
2465 if(aReplacedShape.IsNull())
2467 theDI << "There is not any shape for replacing.\n";
2470 DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2));
2475 #include <ShapeFix_Wireframe.hxx>
2476 //=======================================================================
2477 //function : OCC7570
2479 //=======================================================================
2480 static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a)
2483 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
2486 TopoDS_Shape in_shape (DBRep::Get (a[1]));
2487 ShapeFix_Wireframe fix_tool (in_shape);
2488 fix_tool.ModeDropSmallEdges () = Standard_True;
2489 fix_tool.SetPrecision (1.e+6);
2490 fix_tool.SetLimitAngle (0.01);
2491 fix_tool.FixSmallEdges ();
2492 TopoDS_Shape new_shape = fix_tool.Shape ();
2496 #include <AIS_TypeFilter.hxx>
2497 //=======================================================================
2498 //function : OCC25340
2500 //=======================================================================
2501 static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/,
2502 Standard_Integer /*theArgNb*/,
2503 const char** /*theArgVec*/)
2505 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
2508 std::cerr << "Error: No opened viewer!\n";
2511 Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
2512 aCtx->AddFilter (aFilter);
2516 //=======================================================================
2517 //function : OCC24826
2519 //=======================================================================
2520 class ParallelTest_Saxpy
2524 ParallelTest_Saxpy (const NCollection_Array1<Standard_Real>& theX,
2525 NCollection_Array1<Standard_Real>& theY,
2526 Standard_Real theScalar)
2527 : myX (theX), myY (theY), myScalar (theScalar) {}
2529 int Begin() const { return 0; }
2530 int End() const { return myX.Size(); }
2532 //! Dummy calculation
2533 void operator() (Standard_Integer theIndex) const
2535 myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex);
2538 //! Dummy calculation
2539 void operator() (Standard_Integer theThreadIndex, Standard_Integer theIndex) const
2541 (void )theThreadIndex;
2542 myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex);
2546 ParallelTest_Saxpy( const ParallelTest_Saxpy& );
2547 ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& );
2550 const NCollection_Array1<Standard_Real>& myX;
2551 NCollection_Array1<Standard_Real>& myY;
2552 const Standard_Real myScalar;
2555 class ParallelTest_SaxpyBatch : private ParallelTest_Saxpy
2558 static const Standard_Integer THE_BATCH_SIZE = 10000000;
2560 ParallelTest_SaxpyBatch (const NCollection_Array1<Standard_Real>& theX,
2561 NCollection_Array1<Standard_Real>& theY,
2562 Standard_Real theScalar)
2563 : ParallelTest_Saxpy (theX, theY, theScalar),
2564 myNbBatches ((int )Ceiling ((double )theX.Size() / THE_BATCH_SIZE)) {}
2566 int Begin() const { return 0; }
2567 int End() const { return myNbBatches; }
2569 void operator() (int theBatchIndex) const
2571 const int aLower = theBatchIndex * THE_BATCH_SIZE;
2572 const int anUpper = Min (aLower + THE_BATCH_SIZE - 1, myX.Upper());
2573 for (int i = aLower; i <= anUpper; ++i)
2575 myY(i) = myScalar * myX(i) + myY(i);
2579 void operator() (int theThreadIndex, int theBatchIndex) const
2581 (void )theThreadIndex;
2582 (*this)(theBatchIndex);
2588 //---------------------------------------------------------------------
2589 static Standard_Integer OCC24826(Draw_Interpretor& theDI,
2590 Standard_Integer theArgc,
2591 const char** theArgv)
2602 Standard_Integer aLength = Draw::Atoi(theArgv[1]);
2604 NCollection_Array1<Standard_Real> aX (0, aLength - 1);
2605 NCollection_Array1<Standard_Real> anY(0, aLength - 1);
2606 for ( Standard_Integer i = 0; i < aLength; ++i )
2608 aX(i) = anY(i) = (Standard_Real) i;
2611 //! Serial processing
2612 NCollection_Array1<Standard_Real> anY1 = anY;
2613 Standard_Real aTimeSeq = 0.0;
2617 const ParallelTest_Saxpy aFunctor (aX, anY1, 1e-6);
2618 for (Standard_Integer i = 0; i < aLength; ++i)
2624 std::cout << " Processing time (sequential mode): 1x [reference]\n";
2625 aTimeSeq = aTimer.ElapsedTime();
2626 aTimer.Show (std::cout);
2629 // Parallel processing
2630 for (Standard_Integer aMode = 0; aMode <= 4; ++aMode)
2632 NCollection_Array1<Standard_Real> anY2 = anY;
2635 const char* aModeDesc = NULL;
2636 const ParallelTest_Saxpy aFunctor1 (aX, anY2, 1e-6);
2637 const ParallelTest_SaxpyBatch aFunctor2 (aX, anY2, 1e-6);
2642 aModeDesc = "OSD_Parallel::For()";
2643 OSD_Parallel::For (aFunctor1.Begin(), aFunctor1.End(), aFunctor1);
2648 aModeDesc = "OSD_ThreadPool::Launcher";
2649 OSD_ThreadPool::Launcher aLauncher (*OSD_ThreadPool::DefaultPool());
2650 aLauncher.Perform (aFunctor1.Begin(), aFunctor1.End(), aFunctor1);
2655 aModeDesc = "OSD_Parallel::Batched()";
2656 OSD_Parallel::For (aFunctor2.Begin(), aFunctor2.End(), aFunctor2);
2661 aModeDesc = "OSD_ThreadPool::Launcher, Batched";
2662 OSD_ThreadPool::Launcher aLauncher (*OSD_ThreadPool::DefaultPool());
2663 aLauncher.Perform (aFunctor2.Begin(), aFunctor2.End(), aFunctor2);
2669 aModeDesc = "tbb::parallel_for";
2670 tbb::parallel_for (aFunctor1.Begin(), aFunctor1.End(), aFunctor1);
2678 std::cout << " " << aModeDesc << ": "
2679 << aTimeSeq / aTimer.ElapsedTime() << "x " << (aTimer.ElapsedTime() < aTimeSeq ? "[boost]" : "[slow-down]") << "\n";
2680 aTimer.Show (std::cout);
2682 for (Standard_Integer i = 0; i < aLength; ++i)
2684 if (anY2(i) != anY1(i))
2686 std::cerr << "Error: Parallel algorithm produced invalid result!\n";
2694 //! Initializes the given square matrix with values that are generated by the given generator function.
2695 template<class GeneratorT> void initRandMatrix (NCollection_Array2<double>& theMat, GeneratorT& theGen)
2697 for (int i = theMat.LowerRow(); i <= theMat.UpperRow(); ++i)
2699 for (int j = theMat.LowerCol(); j <= theMat.UpperCol(); ++j)
2701 theMat(i, j) = static_cast<double>(theGen());
2706 //! Compute the product of two square matrices in parallel.
2707 class ParallelTest_MatMult
2710 ParallelTest_MatMult (const NCollection_Array2<double>& theMat1,
2711 const NCollection_Array2<double>& theMat2,
2712 NCollection_Array2<double>& theResult, int theSize)
2713 : myMat1 (theMat1), myMat2 (theMat2), myResult (theResult), mySize (theSize) {}
2715 int Begin() const { return 0; }
2716 int End() const { return mySize; }
2718 void operator() (int theIndex) const
2720 for (int j = 0; j < mySize; ++j)
2723 for (int k = 0; k < mySize; ++k)
2725 aTmp += myMat1(theIndex, k) * myMat2(k, j);
2727 myResult(theIndex, j) = aTmp;
2731 void operator() (int theThreadIndex, int theIndex) const
2733 (void )theThreadIndex;
2738 ParallelTest_MatMult (const ParallelTest_MatMult& );
2739 ParallelTest_MatMult& operator= (ParallelTest_MatMult& );
2742 const NCollection_Array2<double>& myMat1;
2743 const NCollection_Array2<double>& myMat2;
2744 NCollection_Array2<double>& myResult;
2748 //---------------------------------------------------------------------
2749 static Standard_Integer OCC29935(Draw_Interpretor& ,
2750 Standard_Integer theArgc,
2751 const char** theArgv)
2755 std::cout << "Syntax error: wrong number of arguments\n";
2760 Standard_Integer aSize = Draw::Atoi (theArgv[1]);
2762 opencascade::std::mt19937 aGen (42);
2763 NCollection_Array2<double> aMat1 (0, aSize - 1, 0, aSize - 1);
2764 NCollection_Array2<double> aMat2 (0, aSize - 1, 0, aSize - 1);
2765 NCollection_Array2<double> aMatResRef(0, aSize - 1, 0, aSize - 1);
2766 NCollection_Array2<double> aMatRes (0, aSize - 1, 0, aSize - 1);
2767 initRandMatrix (aMat1, aGen);
2768 initRandMatrix (aMat2, aGen);
2770 //! Serial processing
2771 Standard_Real aTimeSeq = 0.0;
2775 ParallelTest_MatMult aFunctor (aMat1, aMat2, aMatResRef, aSize);
2776 for (int i = aFunctor.Begin(); i < aFunctor.End(); ++i)
2782 std::cout << " Processing time (sequential mode): 1x [reference]\n";
2783 aTimeSeq = aTimer.ElapsedTime();
2784 aTimer.Show (std::cout);
2787 // Parallel processing
2788 for (Standard_Integer aMode = 0; aMode <= 2; ++aMode)
2794 const char* aModeDesc = NULL;
2795 ParallelTest_MatMult aFunctor1 (aMat1, aMat2, aMatRes, aSize);
2800 aModeDesc = "OSD_Parallel::For()";
2801 OSD_Parallel::For (aFunctor1.Begin(), aFunctor1.End(), aFunctor1);
2806 aModeDesc = "OSD_ThreadPool::Launcher";
2807 OSD_ThreadPool::Launcher aLauncher (*OSD_ThreadPool::DefaultPool());
2808 aLauncher.Perform (aFunctor1.Begin(), aFunctor1.End(), aFunctor1);
2814 aModeDesc = "tbb::parallel_for";
2815 tbb::parallel_for (aFunctor1.Begin(), aFunctor1.End(), aFunctor1);
2823 std::cout << " " << aModeDesc << ": "
2824 << aTimeSeq / aTimer.ElapsedTime() << "x " << (aTimer.ElapsedTime() < aTimeSeq ? "[boost]" : "[slow-down]") << "\n";
2825 aTimer.Show (std::cout);
2827 for (int i = 0; i < aSize; ++i)
2829 for (int j = 0; j < aSize; ++j)
2831 if (aMatRes(i, j) != aMatResRef(i, j))
2833 std::cerr << "Error: Parallel algorithm produced invalid result!\n";
2843 /*****************************************************************************/
2845 #include <GeomAPI_IntSS.hxx>
2846 //=======================================================================
2847 //function : OCC25100
2849 //=======================================================================
2850 static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2854 di << "the method requires a shape name\n";
2858 TopoDS_Shape S = DBRep::Get(argv[1]);
2861 di << "Shape is empty\n";
2865 TopExp_Explorer aFaceExp(S, TopAbs_FACE);
2866 const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current()));
2868 GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion());
2870 if (!anIntersector.IsDone())
2872 di << "Error. Intersection is not done\n";
2876 di << "Test complete\n";
2881 //=======================================================================
2882 //function : OCC25348
2884 //=======================================================================
2885 static Standard_Integer OCC25348 (Draw_Interpretor& theDI,
2886 Standard_Integer /*theArgNb*/,
2887 const char** /*theArgVec*/)
2889 Handle(NCollection_IncAllocator) anAlloc1;
2890 NCollection_List<int> aList1(anAlloc1);
2891 for (int i=0; i < 10; i++)
2893 Handle(NCollection_IncAllocator) anAlloc2;
2894 NCollection_List<int> aList2(anAlloc2);
2896 aList1.Assign(aList2);
2898 theDI << "Test complete\n";
2902 #include <IntCurvesFace_ShapeIntersector.hxx>
2903 #include <BRepBndLib.hxx>
2904 //=======================================================================
2905 //function : OCC25413
2907 //=======================================================================
2908 static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
2911 di << "Usage: " << a[0] << " invalid number of arguments\n";
2914 TopoDS_Shape aShape = DBRep::Get (a[1]);
2916 IntCurvesFace_ShapeIntersector Inter;
2917 Inter.Load(aShape, Precision::Confusion());
2920 BRepBndLib::Add(aShape, aBndBox);
2922 gp_Dir aDir(0., 1., 0.);
2924 Standard_Real xMin = aBndBox.CornerMin().X();
2925 Standard_Real zMin = aBndBox.CornerMin().Z();
2926 Standard_Real xMax = aBndBox.CornerMax().X();
2927 Standard_Real zMax = aBndBox.CornerMax().Z();
2928 Standard_Real xStep = (xMax - xMin) / N;
2929 Standard_Real zStep = (zMax - zMin) / N;
2931 for (Standard_Real x = xMin; x <= xMax; x += xStep)
2932 for (Standard_Real z = zMin; z <= zMax; z += zStep)
2934 gp_Pnt aPoint(x, 0.0, z);
2935 gp_Lin aLine(aPoint, aDir);
2936 Inter.PerformNearest(aLine, -100., 100.);
2942 #include <BOPAlgo_PaveFiller.hxx>
2944 #include <BRepAlgoAPI_BooleanOperation.hxx>
2945 #include <BRepAlgoAPI_Common.hxx>
2946 #include <BRepAlgoAPI_Fuse.hxx>
2947 #include <BRepAlgoAPI_Cut.hxx>
2948 #include <BRepAlgoAPI_Section.hxx>
2950 #include <TopExp.hxx>
2951 #include <TopTools_MapOfShape.hxx>
2952 //=======================================================================
2953 //function : OCC25446
2955 //=======================================================================
2956 static Standard_Integer OCC25446 (Draw_Interpretor& theDI,
2957 Standard_Integer argc,
2961 theDI << "Usage: OCC25446 res b1 b2 op\n";
2965 TopoDS_Shape aS1 = DBRep::Get(argv[2]);
2967 theDI << argv[2] << " shape is NULL\n";
2971 TopoDS_Shape aS2 = DBRep::Get(argv[3]);
2973 theDI << argv[3] << " shape is NULL\n";
2977 Standard_Integer iOp;
2978 BOPAlgo_Operation aOp;
2980 iOp = Draw::Atoi(argv[4]);
2981 if (iOp < 0 || iOp > 4) {
2982 theDI << "Invalid operation type\n";
2985 aOp = (BOPAlgo_Operation)iOp;
2987 Standard_Integer iErr;
2988 TopTools_ListOfShape aLS;
2989 BOPAlgo_PaveFiller aPF;
2993 aPF.SetArguments(aLS);
2996 iErr = aPF.HasErrors();
2998 theDI << "Intersection failed with error status: " << iErr << "\n";
3002 BRepAlgoAPI_BooleanOperation* pBuilder = NULL;
3005 case BOPAlgo_COMMON:
3006 pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF);
3009 pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
3012 pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF);
3015 pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
3017 case BOPAlgo_SECTION:
3018 pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF);
3024 iErr = pBuilder->HasErrors();
3025 if (!pBuilder->IsDone()) {
3026 theDI << "BOP failed with error status: " << iErr << "\n";
3030 const TopoDS_Shape& aRes = pBuilder->Shape();
3031 DBRep::Set(argv[1], aRes);
3033 TopTools_MapOfShape aMapArgs, aMapShape;
3034 TopTools_MapIteratorOfMapOfShape aIt;
3035 Standard_Boolean bIsDeletedHist, bIsDeletedMap;
3036 TopAbs_ShapeEnum aType;
3038 TopExp::MapShapes(aS1, aMapArgs);
3039 TopExp::MapShapes(aS2, aMapArgs);
3040 TopExp::MapShapes(aRes, aMapShape);
3042 aIt.Initialize(aMapArgs);
3043 for (; aIt.More(); aIt.Next()) {
3044 const TopoDS_Shape& aS = aIt.Value();
3045 aType = aS.ShapeType();
3046 if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
3047 aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
3051 bIsDeletedHist = pBuilder->IsDeleted(aS);
3052 bIsDeletedMap = !aMapShape.Contains(aS) &&
3053 (pBuilder->Modified(aS).Extent() == 0);
3055 if (bIsDeletedHist != bIsDeletedMap) {
3056 theDI << "Error. Wrong value of IsDeleted flag.\n";
3061 theDI << "Test complete\n";
3065 //====================================================
3066 // Auxiliary functor class for the command OCC25545;
3067 // it gets access to a vertex with the given index and
3068 // checks that X coordinate of the point is equal to index;
3069 // if it is not so then a data race is reported.
3070 //====================================================
3071 struct OCC25545_Functor
3073 OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
3074 : myShapeVec(&theShapeVec),
3078 void operator()(size_t i) const
3080 if (!myIsRaceDetected) {
3081 const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i));
3082 gp_Pnt aP = BRep_Tool::Pnt (aV);
3083 if (aP.X () != static_cast<double> (i)) {
3084 Standard_Atomic_Increment(&myIsRaceDetected);
3089 const std::vector<TopoDS_Shape>* myShapeVec;
3090 mutable volatile int myIsRaceDetected;
3093 //=======================================================================
3094 //function : OCC25545
3095 //purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation()
3096 //=======================================================================
3098 static Standard_Integer OCC25545 (Draw_Interpretor& di,
3102 // Place vertices in a vector, giving the i-th vertex the
3103 // transformation that translates it on the vector (i,0,0) from the origin.
3104 Standard_Integer n = 1000;
3105 std::vector<TopoDS_Shape> aShapeVec (n);
3106 std::vector<TopLoc_Location> aLocVec (n);
3107 TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ());
3108 aShapeVec[0] = aShape;
3109 for (Standard_Integer i = 1; i < n; ++i) {
3111 aT.SetTranslation (gp_Vec (1, 0, 0));
3112 aLocVec[i] = aLocVec[i - 1] * aT;
3113 aShapeVec[i] = aShape.Moved (aLocVec[i]);
3116 // Evaluator function will access vertices geometry
3118 OCC25545_Functor aFunc(aShapeVec);
3120 // concurrently process
3121 OSD_Parallel::For (0, n, aFunc);
3123 QVERIFY (!aFunc.myIsRaceDetected);
3127 //=======================================================================
3128 //function : OCC25547
3130 //=======================================================================
3131 #include <BRepMesh_GeomTool.hxx>
3132 #include <BRepAdaptor_Curve.hxx>
3133 #include <Geom_TrimmedCurve.hxx>
3134 #include <BRepBuilderAPI_MakeFace.hxx>
3135 #include <BRepAdaptor_HSurface.hxx>
3136 #include <BRepAdaptor_Surface.hxx>
3137 static Standard_Integer OCC25547(
3138 Draw_Interpretor& theDI,
3139 Standard_Integer /*argc*/,
3140 const char ** /*argv*/)
3142 // The general aim of this test is to prevent linkage errors due to missed
3143 // Standard_EXPORT attribute for static methods.
3145 // However, start checking the main functionality at first.
3146 const Standard_Real aFirstP = 0., aLastP = M_PI;
3147 Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
3148 Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
3149 TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf);
3150 BRepAdaptor_Curve aAdaptor(aEdge);
3151 BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5);
3153 if (aGeomTool.NbPoints() == 0)
3155 theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
3159 // Test static methods.
3160 TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
3161 BRepAdaptor_Surface aSurf(aFace);
3162 Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf);
3166 if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
3168 theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
3172 gp_XY aRefPnts[4] = {
3173 gp_XY(-10., -10.), gp_XY(10., 10.),
3174 gp_XY(-10., 10.), gp_XY(10., -10.)
3178 Standard_Real aParams[2];
3179 BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin(
3180 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3181 aIntPnt.ChangeCoord(), aParams);
3183 Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
3184 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3186 theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
3190 aIntFlag = BRepMesh_GeomTool::IntSegSeg(
3191 aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
3192 Standard_False, Standard_False, aIntPnt);
3194 aDiff = aIntPnt.Distance(gp::Origin2d());
3195 if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
3197 theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
3202 theDI << "Test complete\n";
3206 static Standard_Integer OCC26139 (Draw_Interpretor& theDI,
3207 Standard_Integer argc,
3211 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
3214 theDI << "Use 'vinit' command before " << argv[0] << "\n";
3218 Standard_Integer aBoxGridSize = 100;
3219 Standard_Integer aCompGridSize = 3;
3220 Standard_Real aBoxSize = 5.0;
3224 for (Standard_Integer anArgIdx = 1; anArgIdx < argc; ++anArgIdx)
3226 TCollection_AsciiString anArg (argv[anArgIdx]);
3228 if (anArg == "-boxgrid")
3230 aBoxGridSize = Draw::Atoi (argv[++anArgIdx]);
3232 else if (anArg == "-compgrid")
3234 aCompGridSize = Draw::Atoi (argv[++anArgIdx]);
3236 else if (anArg == "-boxsize")
3238 aBoxSize = Draw::Atof (argv[++anArgIdx]);
3243 NCollection_List<Handle(AIS_Shape)> aCompounds;
3244 for (Standard_Integer aCompGridX = 0; aCompGridX < aCompGridSize; ++aCompGridX)
3246 for (Standard_Integer aCompGridY = 0; aCompGridY < aCompGridSize; ++aCompGridY)
3248 BRep_Builder aBuilder;
3249 TopoDS_Compound aComp;
3250 aBuilder.MakeCompound (aComp);
3251 for (Standard_Integer aBoxGridX = 0; aBoxGridX < aBoxGridSize; ++aBoxGridX)
3253 for (Standard_Integer aBoxGridY = 0; aBoxGridY < aBoxGridSize; ++aBoxGridY)
3255 BRepPrimAPI_MakeBox aBox (gp_Pnt (aBoxGridX * aBoxSize, aBoxGridY * aBoxSize, 0.0),
3256 aBoxSize, aBoxSize, aBoxSize);
3257 aBuilder.Add (aComp, aBox.Shape());
3261 aTrsf.SetTranslation (gp_Vec (aBoxGridSize * aBoxSize * aCompGridX,
3262 aBoxGridSize * aBoxSize * aCompGridY,
3264 TopLoc_Location aLoc (aTrsf);
3265 aComp.Located (aLoc);
3266 aCompounds.Append (new AIS_Shape (aComp));
3271 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3274 aCtx->Display (aCompIter.Value(), Standard_False);
3276 theDI << "Display time: " << aTimer.ElapsedTime() << "\n";
3282 for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next())
3284 aCtx->Remove (aCompIter.Value(), Standard_False);
3287 theDI << "Remove time: " << aTimer.ElapsedTime() << "\n";
3292 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
3293 #include <TColStd_DataMapOfIntegerInteger.hxx>
3295 #include <ShapeFix_Wire.hxx>
3296 #include <ShapeExtend_Status.hxx>
3298 #define EXCEPTION ...
3300 #define EXCEPTION Standard_Failure
3303 static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)& theFix,
3304 const Standard_Boolean theIs3d)
3306 for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++)
3308 Standard_Boolean isFound;
3310 isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i );
3312 isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i );
3313 if (isFound) return ShapeExtend_Status(i);
3315 return ShapeExtend_OK;
3318 //===================
3319 //function : OCC24881
3321 //===================
3322 static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
3325 di<<"Usage: "<<a[0]<<" invalid number of arguments\n";
3328 // cout <<"FileName1: " << argv[1] <<endl;
3330 TopoDS_Shape aShape = DBRep::Get (a[1]);
3333 Handle(ShapeFix_Wire) aWireFix = new ShapeFix_Wire;
3335 // map FixStatus - NbSuchStatuses
3336 TColStd_DataMapOfIntegerInteger aStatusNbDMap;
3337 Standard_Integer nbFixed=0, nbOk=0;
3340 ShapeExtend_Status aStatus=ShapeExtend_OK;
3342 TopExp_Explorer aFaceExplorer(aShape, TopAbs_FACE);
3343 for (; aFaceExplorer.More(); aFaceExplorer.Next())
3345 TopoDS_Shape aFace = aFaceExplorer.Current();
3347 TopoDS_Iterator aWireItr(aFace);
3348 for (; aWireItr.More(); aWireItr.Next() )
3350 Standard_Boolean wasOk = Standard_False;
3351 TopoDS_Wire aSrcWire = TopoDS::Wire(aWireItr.Value());
3353 aWireFix->Load (aSrcWire);
3354 aWireFix->SetFace (TopoDS::Face(aFace));
3355 aWireFix->FixReorder(); //correct order is a prerequisite
3357 if (!aWireFix->FixGaps3d())
3360 aStatus = getStatusGap(aWireFix, Standard_True);
3361 if (aStatus == ShapeExtend_OK)
3362 wasOk = Standard_True;
3365 // keep 3d fail status
3366 if (aStatusNbDMap.IsBound (aStatus))
3367 aStatusNbDMap(aStatus)++;
3369 aStatusNbDMap.Bind(aStatus,1);
3375 if (aWireFix->FixGaps2d())
3379 aStatus = getStatusGap(aWireFix, Standard_False);
3380 if (aStatus == ShapeExtend_OK)
3392 // keep 2d fail status
3393 Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL;
3394 if (aStatusNbDMap.IsBound (aStatus2d))
3395 aStatusNbDMap(aStatus2d)++;
3397 aStatusNbDMap.Bind(aStatus2d,1);
3404 } catch (EXCEPTION) {
3405 di << "Exception is raised = " <<aStatus << "\n";
3409 // report what is done
3413 di <<"Fix_FillGaps_Fixed: nbFixed = "<<nbFixed <<"\n";
3418 di << "Fix_FillGaps_NothingToDo\n";
3421 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aStatusItr(aStatusNbDMap);
3422 for (; aStatusItr.More(); aStatusItr.Next())
3424 switch ((ShapeExtend_Status) aStatusItr.Key())
3427 case ShapeExtend_FAIL1:
3428 di <<"Fix_FillGaps_3dNoCurveFail, nb failed = ";
3430 case ShapeExtend_FAIL2:
3431 di <<"Fix_FillGaps_3dSomeGapsFail, nb failed = ";
3435 switch ((ShapeExtend_Status) (aStatusItr.Key() - ShapeExtend_FAIL))
3437 case ShapeExtend_FAIL1:
3438 di <<"Fix_FillGaps_2dNoPCurveFail, nb failed = ";
3440 case ShapeExtend_FAIL2:
3441 di <<"Fix_FillGaps_2dSomeGapsFail, nb failed = ";
3447 di <<aStatusItr.Value()<< "\n";
3449 di << ("__________________________________") <<"\n";
3454 //=======================================================================
3455 //function : OCC26284
3457 //=======================================================================
3458 static Standard_Integer OCC26284 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3462 std::cerr << "Error: wrong number of arguments! See usage:\n";
3463 theDI.PrintHelp (theArgVec[0]);
3467 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
3468 if (anAISContext.IsNull())
3470 std::cerr << "Error: no active view. Please call vinit.\n";
3474 BRepPrimAPI_MakeSphere aSphereBuilder (gp_Pnt (0.0, 0.0, 0.0), 1.0);
3475 Handle(AIS_Shape) aSphere = new AIS_Shape (aSphereBuilder.Shape());
3476 anAISContext->Display (aSphere, Standard_False);
3477 for (Standard_Integer aChildIdx = 0; aChildIdx < 5; ++aChildIdx)
3479 BRepPrimAPI_MakeSphere aBuilder (gp_Pnt (1.0 + aChildIdx, 1.0 + aChildIdx, 1.0 + aChildIdx), 1.0);
3480 Handle(AIS_Shape) aChild = new AIS_Shape (aBuilder.Shape());
3481 aSphere->AddChild (aChild);
3482 anAISContext->Display (aChild, Standard_False);
3485 anAISContext->RecomputeSelectionOnly (aSphere);
3486 anAISContext->UpdateCurrentViewer();
3491 #include <IntTools_Context.hxx>
3492 #include <GeomAPI_ProjectPointOnSurf.hxx>
3494 //=======================================================================
3495 //function : xprojponf
3497 //=======================================================================
3498 Standard_Integer xprojponf (Draw_Interpretor& di,
3503 di<<" use xprojponf p f \n";
3510 Handle(IntTools_Context) aCtx;
3512 DrawTrSurf::GetPoint(a[1], aP);
3513 aS=DBRep::Get(a[2]);
3516 di<<" null shape is not allowed\n";
3520 if (aS.ShapeType()!=TopAbs_FACE) {
3521 di << a[2] << " not a face\n";
3525 aCtx=new IntTools_Context;
3527 aF=TopoDS::Face(aS);
3528 GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF);
3531 if (!aPPS.IsDone()) {
3532 di<<" projection failed\n";
3536 aPS=aPPS.NearestPoint();
3537 di<< " point px " << aPS.X() << " " << aPS.Y() << " " << aPS.Z() << "\n";
3542 //=======================================================================
3543 //function : OCC25547
3545 //=======================================================================
3546 #include <BRepMesh_CircleTool.hxx>
3547 #include <SelectMgr_EntityOwner.hxx>
3549 static Standard_Boolean inspect_point(const gp_XY& thePoint,
3550 const gp_XY& theCenter,
3551 const Standard_Real theRadius)
3553 static Standard_Real aPrecision = Precision::PConfusion();
3554 static Standard_Real aSqPrecision = aPrecision * aPrecision;
3555 const gp_XY aDistVec = thePoint - theCenter;
3556 if (aDistVec.SquareModulus() - (theRadius * theRadius) < aSqPrecision)
3557 return Standard_True;
3559 return Standard_False;
3562 static Standard_Integer OCC24923(
3563 Draw_Interpretor& theDI,
3564 Standard_Integer argc,
3567 srand(static_cast<unsigned int>(time(NULL)));
3569 const Standard_Real aMaxDeviation = (argc > 1) ? Draw::Atof(argv[1]) : 0.01;
3570 const Standard_Integer aPointsNb = 10000000;
3571 const Standard_Real aMinAngle = 5 * M_PI / 180.;
3572 static Standard_Real aSqPrecision = Precision::PConfusion() * Precision::PConfusion();
3574 Standard_Integer aFailedNb = 0;
3575 for (Standard_Integer i = 0; i < aPointsNb; ++i)
3578 for (Standard_Integer j = 0; j < 3; ++j)
3579 p[j].SetCoord(((Standard_Real)rand())/RAND_MAX, ((Standard_Real)rand())/RAND_MAX);
3581 // Check that points do not compose degenerated triangle.
3582 gp_XY aVec1 = p[1] - p[0];
3583 gp_XY aVec2 = p[2] - p[0];
3584 if (aVec1.SquareModulus() > aSqPrecision &&
3585 aVec2.SquareModulus() > aSqPrecision &&
3586 (aVec1 ^ aVec2) > aMinAngle)
3589 Standard_Real aRadius;
3590 if (BRepMesh_CircleTool::MakeCircle(p[0], p[1], p[2], aCenter, aRadius))
3592 if (!inspect_point(p[0], aCenter, aRadius) ||
3593 !inspect_point(p[1], aCenter, aRadius) ||
3594 !inspect_point(p[2], aCenter, aRadius))
3596 /* theDI << "Missed: " <<
3597 "p1=(" << p1.X() << ", " << p1.Y() << "), " <<
3598 "p2=(" << p2.X() << ", " << p2.Y() << "), " <<
3599 "p3=(" << p3.X() << ", " << p3.Y() << "), " <<
3600 "c=(" << aCenter.X() << ", " << aCenter.Y() << "), " <<
3601 "r=" << aRadius << "\n";*/
3610 // Ensure that aPointsNb suitable for tests are generated
3614 const Standard_Real aDeviation =
3615 1. - (Standard_Real)(aPointsNb - aFailedNb) / (Standard_Real)aPointsNb;
3617 theDI << "Number of incorrect cases: " << aFailedNb << " (Total " << aPointsNb << ")\n";
3618 if (aDeviation > aMaxDeviation)
3620 theDI << "Failed. Number of incorrect results is too huge: " <<
3621 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
3625 theDI << "Deviation of incorrect results is: " <<
3626 aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n";
3627 theDI << "Test completed\n";
3631 //=======================================================================
3632 //function : OCC25574
3633 //purpose : check implementation of Euler angles in gp_Quaternion
3634 //=======================================================================
3636 static Standard_Integer OCC25574 (Draw_Interpretor& theDI, Standard_Integer /*argc*/, const char** /*argv*/)
3638 Standard_Boolean isTestOk = Standard_True;
3640 // Check consistency of Get and Set operations for Euler angles
3641 gp_Quaternion aQuat;
3642 aQuat.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637);
3643 Standard_Real alpha,beta,gamma;
3644 gp_Mat aRinv = aQuat.GetMatrix().Inverted();
3647 const char* names[] = { "Extrinsic_XYZ", "Extrinsic_XZY", "Extrinsic_YZX", "Extrinsic_YXZ", "Extrinsic_ZXY", "Extrinsic_ZYX",
3648 "Intrinsic_XYZ", "Intrinsic_XZY", "Intrinsic_YZX", "Intrinsic_YXZ", "Intrinsic_ZXY", "Intrinsic_ZYX",
3649 "Extrinsic_XYX", "Extrinsic_XZX", "Extrinsic_YZY", "Extrinsic_YXY", "Extrinsic_ZYZ", "Extrinsic_ZXZ",
3650 "Intrinsic_XYX", "Intrinsic_XZX", "Intrinsic_YZY", "Intrinsic_YXY", "Intrinsic_ZXZ", "Intrinsic_ZYZ" };
3651 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3653 aQuat.GetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma);
3655 gp_Quaternion aQuat2;
3656 aQuat2.SetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma);
3658 gp_Mat aR = aQuat2.GetMatrix();
3659 gp_Mat aDiff = aR * aRinv - aI;
3660 if (aDiff.Determinant() > 1e-5)
3662 theDI << "Error: Euler angles conversion incorrect for sequence " << names[i - gp_Extrinsic_XYZ] << "\n";
3663 isTestOk = Standard_False;
3667 // Check conversion between intrinsic and extrinsic rotations
3668 // Any extrinsic rotation is equivalent to an intrinsic rotation
3669 // by the same angles but with inverted order of elemental rotations, and vice versa
3671 // Extrinsic_XZY = Incrinsic_XZY
3672 // R = X(A)Z(B)Y(G) --> R = Y(G)Z(B)X(A)
3673 alpha = 0.1517461713131;
3674 beta = 1.5162198410141;
3675 gamma = 1.9313156236541;
3676 Standard_Real alpha2, beta2, gamma2;
3677 gp_EulerSequence pairs[][2] = { {gp_Extrinsic_XYZ, gp_Intrinsic_ZYX},
3678 {gp_Extrinsic_XZY, gp_Intrinsic_YZX},
3679 {gp_Extrinsic_YZX, gp_Intrinsic_XZY},
3680 {gp_Extrinsic_YXZ, gp_Intrinsic_ZXY},
3681 {gp_Extrinsic_ZXY, gp_Intrinsic_YXZ},
3682 {gp_Extrinsic_ZYX, gp_Intrinsic_XYZ} };
3683 for (int i = 0; i < 6; i++)
3685 aQuat.SetEulerAngles(pairs[i][0], alpha, beta, gamma);
3686 aQuat.GetEulerAngles(pairs[i][1], gamma2, beta2, alpha2);
3688 if (Abs(alpha - alpha2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - gamma2) > 1e-5)
3690 theDI << "Error: intrinsic and extrinsic conversion incorrect for sequence " << names[i] << "\n";
3691 isTestOk = Standard_False;
3695 // Check correspondence of enumeration and actual rotation it defines,
3696 // by rotation by one axis and checking that it does not change a point on that axis
3697 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3699 // Iterate over rotations R(A)R(B)R(G) for each Euler angle Alpha, Beta, Gamma
3700 // There are three ordered axes corresponding to three rotations.
3701 // Each rotation applyed with current angle around current axis.
3702 for (int j=0; j < 3; j++)
3704 // note that current axis index is obtained by parsing of enumeration name!
3705 int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X';
3706 Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1);
3708 // Set 90 degrees to current Euler angle
3709 double anAngles[3] = {0., 0., 0.};
3710 anAngles[j] = 0.5 * M_PI;
3713 q2.SetEulerAngles (gp_EulerSequence(i), anAngles[0], anAngles[1], anAngles[2]);
3715 // Set point on axis corresponding to current rotation
3716 // We will apply rotation around this axis
3717 gp_XYZ v (0., 0., 0.);
3718 v.SetCoord (anAxis + 1, 1.);
3720 // Apply rotation to point
3722 aT.SetRotation (q2);
3726 // Check that point is still on origin position
3727 if ((v - v2).SquareModulus() > Precision::SquareConfusion())
3729 // avoid reporting small coordinates
3730 for (int k=1; k <= 3; k++)
3731 if (Abs (v2.Coord(k)) < Precision::Confusion())
3732 v2.SetCoord (k, 0.);
3734 isTestOk = Standard_False;
3735 theDI << "Error: Euler sequence " << names[i - gp_Extrinsic_XYZ] << " is incorrect:\n";
3736 theDI << "rotating by angle 90 deg around " << (anAxis == 0 ? "X" : anAxis == 1 ? "Y" : "Z") <<
3737 " converts vector (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") to ("
3738 << v2.X() << ", " << v2.Y() << ", " << v2.Z() << ")\n";
3743 // Check correspondence of enumeration and actual rotation it defines,
3744 // by comparing cumulative rotation matrix with sequence of rotations by axes
3745 const Standard_Real anAngle[3] = { 0.1, 0.2, 0.3 };
3746 for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++)
3748 // Sequence of rotations
3750 for (int j=0; j < 3; j++)
3752 // note that current axis index is obtained by parsing of enumeration name!
3753 int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X';
3754 Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1);
3756 // Set point on axis corresponding to current rotation
3757 // We will apply rotation around this axis
3758 gp_XYZ v (0., 0., 0.);
3759 v.SetCoord (anAxis + 1, 1.);
3760 aR[j].SetRotation (v, anAngle[j]);
3763 // construct cumulative transformation (differently for extrinsic and intrinsic rotations);
3764 // note that we parse first symbol of the enum name to identify its type
3766 if (names[i - gp_Extrinsic_XYZ][0] == 'E') // extrinsic
3768 aRot = aR[2] * aR[1] * aR[0];
3772 aRot = aR[0] * aR[1] * aR[2];
3775 // set the same angles in quaternion
3776 aQuat.SetEulerAngles (gp_EulerSequence(i), anAngle[0], anAngle[1], anAngle[2]);
3778 gp_Mat aRQ = aQuat.GetMatrix();
3779 gp_Mat aDiff = aRQ * aRot.Inverted() - aI;
3780 if (aDiff.Determinant() > 1e-5)
3782 theDI << "Error: Euler angles conversion does not correspond to sequential rotations for " << names[i - gp_Extrinsic_XYZ] << "\n";
3783 isTestOk = Standard_False;
3787 // similar checkfor YawPitchRoll sequence as defined in description of #25574
3789 // Start with world coordinate system
3792 // Perform three rotations using the yaw-pitch-roll convention.
3793 // This means: rotate around the original z axis with angle alpha,
3794 // then rotate around the new y axis with angle beta,
3795 // then rotate around the new x axis with angle gamma.
3796 alpha = 0.0 / 180.0 * M_PI;
3797 beta = -35.0 / 180.0 * M_PI;
3798 gamma = 90.0 / 180.0 * M_PI;
3800 const gp_Quaternion rotationZ(world.Direction(), alpha);
3801 const gp_Vec rotY = rotationZ.Multiply(world.YDirection());
3802 const gp_Vec rotX = rotationZ.Multiply(world.XDirection());
3804 const gp_Quaternion rotationY(rotY, beta);
3805 const gp_Vec rotZ = rotationY.Multiply(world.Direction());
3806 const gp_Vec rotRotX = rotationY.Multiply(rotX);
3808 const gp_Quaternion rotationX(rotRotX, gamma);
3809 const gp_Vec rotRotZ = rotationX.Multiply(rotZ);
3811 gp_Ax2 result(gp_Pnt(0.0, 0.0, 0.0), rotRotZ, rotRotX);
3813 // Now compute the Euler angles
3814 gp_Trsf transformation;
3815 transformation.SetDisplacement(gp_Ax2(), result);
3817 Standard_Real computedAlpha;
3818 Standard_Real computedBeta;
3819 Standard_Real computedGamma;
3821 transformation.GetRotation().GetEulerAngles(gp_YawPitchRoll, computedAlpha, computedBeta, computedGamma);
3823 // We expect now to get the same angles as we have used for our rotations
3824 if (Abs(alpha - computedAlpha) > 1e-5 || Abs(beta - computedBeta) > 1e-5 || Abs(gamma - computedGamma) > 1e-5)
3826 theDI << "Error: unexpected values of Euler angles for YawPitchRoll sequence:\n";
3827 theDI << "alpha: " << alpha / M_PI * 180.0 << " and computed alpha: "
3828 << computedAlpha / M_PI * 180.0 << "\n";
3829 theDI << "beta: " << beta / M_PI * 180.0 << " and computed beta: "
3830 << computedBeta / M_PI * 180.0 << "\n";
3831 theDI << "gamma: " << gamma / M_PI * 180.0 << " and computed gamma: "
3832 << computedGamma / M_PI * 180.0 << "\n";
3833 isTestOk = Standard_False;
3840 q.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637);
3842 q.GetEulerAngles(gp_Intrinsic_ZYX, alpha,beta, gamma);
3843 q.GetEulerAngles(gp_Extrinsic_XYZ, alpha2,beta2,gamma2);
3845 // gp_Intrinsic_ZYX and gp_Extrinsic_XYZ should produce the same values of angles but in opposite order
3846 if (Abs(alpha - gamma2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - alpha2) > 1e-5)
3848 theDI << "Error: Euler angles computed for gp_Intrinsic_ZYX and gp_Extrinsic_XYZ do not match:\n";
3849 theDI << "alpha: " << alpha / M_PI * 180.0 << " and " << alpha2 / M_PI * 180.0 << "\n";
3850 theDI << "beta: " << beta / M_PI * 180.0 << " and " << beta2 / M_PI * 180.0 << "\n";
3851 theDI << "gamma: " << gamma / M_PI * 180.0 << " and " << gamma2 / M_PI * 180.0 << "\n";
3852 isTestOk = Standard_False;
3856 theDI << (isTestOk ? "Test completed" : "Test failed") << "\n";
3860 #include <TColGeom_Array1OfBSplineCurve.hxx>
3861 #include <TColStd_Array1OfReal.hxx>
3862 #include <TColGeom_HArray1OfBSplineCurve.hxx>
3863 #include <GeomConvert.hxx>
3865 //=======================================================================
3866 //function : OCC26446
3868 //=======================================================================
3869 Standard_Integer OCC26446 (Draw_Interpretor& di,
3874 di << "Usage: OCC26446 r c1 c2\n";
3878 Handle(Geom_BSplineCurve) aCurve1 =
3879 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[2]));
3880 Handle(Geom_BSplineCurve) aCurve2 =
3881 Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[3]));
3883 if (aCurve1.IsNull()) {
3884 di << a[2] << " is not a BSpline curve\n";
3888 if (aCurve2.IsNull()) {
3889 di << a[3] << " is not a BSpline curve\n";
3893 TColGeom_Array1OfBSplineCurve aCurves (0, 1);
3894 TColStd_Array1OfReal aTolerances (0, 0);
3895 Standard_Real aTolConf = 1.e-3;
3896 Standard_Real aTolClosure = Precision::Confusion();
3897 Handle(TColGeom_HArray1OfBSplineCurve) aConcatCurves;
3898 Handle(TColStd_HArray1OfInteger) anIndices;
3900 aCurves.SetValue(0, aCurve1);
3901 aCurves.SetValue(1, aCurve2);
3902 aTolerances.SetValue(0, aTolConf);
3904 GeomConvert::ConcatC1(aCurves,
3911 Handle(Geom_BSplineCurve) aResult =
3912 aConcatCurves->Value(aConcatCurves->Lower());
3914 DrawTrSurf::Set(a[1], aResult);
3918 static Standard_Integer OCC26448 (Draw_Interpretor& theDI, Standard_Integer, const char **)
3920 TColStd_SequenceOfReal aSeq1, aSeq2;
3922 aSeq1.Prepend (aSeq2);
3923 theDI << "TCollection: 11 -> " << aSeq1.First() << "\n";
3925 NCollection_Sequence<Standard_Real> nSeq1, nSeq2;
3927 nSeq1.Prepend (nSeq2);
3928 theDI << "NCollection: 11 -> " << nSeq1.First() << "\n";
3934 //=======================================================================
3935 //function : OCC26407
3937 //=======================================================================
3938 #include <BRepBuilderAPI_MakeWire.hxx>
3939 #include <BRepBuilderAPI_MakeEdge.hxx>
3940 #include <BRepMesh_IncrementalMesh.hxx>
3941 #include <TCollection_AsciiString.hxx>
3942 static Standard_Integer OCC26407 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3946 std::cerr << "Error: wrong number of arguments! See usage:\n";
3947 theDI.PrintHelp (theArgVec[0]);
3951 // Construct vertices.
3952 std::vector<TopoDS_Vertex> wire_vertices;
3953 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.90000000000009094947, 40.6758179230516248026106, 88.5)));
3954 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(807.824182076948432040808, 260.599999999999965893949, 88.5)));
3955 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(644.174182076948454778176, 424.249999999999943156581, 88.5000000000000142108547)));
3956 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(629.978025792618950617907, 424.25, 88.5)));
3957 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(793.628025792618700506864, 260.599999999999852207111, 88.5)));
3958 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.900000000000204636308, 54.8719742073813492311274, 88.5)));
3959 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(218.521974207381418864315, 424.250000000000056843419, 88.5)));
3960 wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(204.325817923051886282337, 424.249999999999943156581, 88.5)));
3963 BRepBuilderAPI_MakeWire wire_builder;
3964 for (size_t i = 0; i < wire_vertices.size(); i++)
3966 const TopoDS_Vertex &v = wire_vertices[i];
3967 const TopoDS_Vertex &w = wire_vertices[(i+1) % wire_vertices.size()];
3969 wire_builder.Add(BRepBuilderAPI_MakeEdge(v, w));
3972 // Create face and triangulate it.
3974 gp_Pnt v0 = BRep_Tool::Pnt(wire_vertices[0]);
3975 gp_Pnt v1 = BRep_Tool::Pnt(wire_vertices[1]);
3976 gp_Pnt v2 = BRep_Tool::Pnt(wire_vertices[wire_vertices.size() - 1]);
3978 gp_Vec face_normal = gp_Vec(v0, v1).Crossed(gp_Vec(v0, v2));
3980 TopoDS_Face face = BRepBuilderAPI_MakeFace(gp_Pln(v0, face_normal), wire_builder);
3981 BRepMesh_IncrementalMesh m(face, 1e-7);
3983 if (m.GetStatusFlags() != 0)
3985 theDI << "Failed. Status for face constructed from vertices: " << m.GetStatusFlags() << "\n";
3988 DBRep::Set(theArgVec[1], face);
3990 sprintf(buf, "isos %s 0", theArgVec[1]);
3993 sprintf(buf, "triangles %s", theArgVec[1]);
3996 theDI.Eval("smallview; fit");
3998 theDI << "Test completed\n";
4002 //=======================================================================
4003 //function : OCC26485
4005 //=======================================================================
4007 static Standard_Integer OCC26485 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
4011 std::cerr << "Error: wrong number of arguments! See usage:\n";
4012 theDI.PrintHelp (theArgVec[0]);
4016 TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
4017 if (aShape.IsNull())
4019 theDI << "Failed. Null shape\n";
4023 Standard_Boolean isFailed = Standard_False;
4024 TopExp_Explorer aExplorer(aShape, TopAbs_FACE);
4025 for (; aExplorer.More(); aExplorer.Next())
4027 const TopoDS_Face& aFace = TopoDS::Face( aExplorer.Current() );
4028 TopLoc_Location L = TopLoc_Location();
4029 const Handle(Poly_Triangulation)& aT = BRep_Tool::Triangulation( aFace , L );
4034 Poly::ComputeNormals(aT);
4035 const TColgp_Array1OfPnt& aVertices = aT->Nodes();
4036 const TShort_Array1OfShortReal& aNormals = aT->Normals();
4038 // Number of nodes in the triangulation
4039 int aVertexNb = aT->Nodes().Length();
4040 if (aVertexNb*3 != aNormals.Length())
4042 theDI << "Failed. Different number of normals vs. vertices\n";
4046 // Get each vertex index, checking common vertexes between shapes
4047 for( int i=0; i < aVertexNb; i++ )
4049 gp_Pnt aPoint = aVertices.Value( i+1 );
4050 gp_Vec aNormal = gp_Vec(
4051 aNormals.Value( i*3 + 1 ),
4052 aNormals.Value( i*3 + 2 ),
4053 aNormals.Value( i*3 + 3 ) );
4055 if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
4058 sprintf(buf, "fail_%d", i+1);
4059 theDI << "Failed. Point " << buf << ": "
4060 << aPoint.X() << " "
4061 << aPoint.Y() << " "
4062 << aPoint.Z() << "\n";
4064 DrawTrSurf::Set (buf, aPoint);
4069 theDI << (isFailed ? "Test failed" : "Test completed") << "\n";
4073 //=======================================================================
4074 //function : OCC26553
4076 //=======================================================================
4077 #include <BRepBuilderAPI_MakeWire.hxx>
4079 static Standard_Integer OCC26553 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4083 theDI << "Error: path to file with shell is missing\n";
4087 BRep_Builder aBuilder;
4088 TopoDS_Shape aShell;
4089 BRepTools::Read(aShell, theArgv[1], aBuilder);
4091 if (aShell.IsNull())
4093 theDI << "Error: shell not loaded\n";
4097 TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge (gp_Pnt (0, 0, 0), gp_Pnt (0, 0, 10));
4098 TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire();
4100 BRepOffsetAPI_MakePipe aPipeBuilder(aPipeWire, aShell);
4101 if (!aPipeBuilder.IsDone())
4103 theDI << "Error: failed to create pipe\n";
4107 for (TopExp_Explorer aShapeExplorer(aShell, TopAbs_EDGE); aShapeExplorer.More(); aShapeExplorer.Next ()) {
4108 const TopoDS_Shape& aGeneratedShape = aPipeBuilder.Generated(aPipeEdge, aShapeExplorer.Current());
4109 if (aGeneratedShape.IsNull())
4111 theDI << "Error: null shape\n";
4116 theDI << "History returned successfully\n";
4120 //=======================================================================
4121 //function : OCC26195
4123 //=======================================================================
4124 #include <SelectMgr_SelectingVolumeManager.hxx>
4125 #include <BRepBuilderAPI_MakePolygon.hxx>
4126 #include <Geom_CartesianPoint.hxx>
4127 #include <AIS_Line.hxx>
4128 #include <Aspect_Window.hxx>
4129 static Standard_Integer OCC26195 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
4133 std::cerr << "Error: wrong number of arguments! See usage:\n";
4134 theDI.PrintHelp (theArgVec[0]);
4138 if (ViewerTest::GetAISContext().IsNull())
4140 std::cerr << "Error: No opened context!\n";
4144 gp_Pnt2d aPxPnt1, aPxPnt2;
4145 aPxPnt1.SetX (Draw::Atof (theArgVec[1]));
4146 aPxPnt1.SetY (Draw::Atof (theArgVec[2]));
4149 aPxPnt2.SetX (Draw::Atof (theArgVec[3]));
4150 aPxPnt2.SetY (Draw::Atof (theArgVec[4]));
4152 Standard_Boolean toPrint = Standard_False;
4153 if (theArgNb % 2 == 0)
4155 toPrint = Draw::Atoi (theArgVec[theArgNb - 1]) != 0;
4158 SelectMgr_SelectingVolumeManager* aMgr = new SelectMgr_SelectingVolumeManager();
4159 aMgr->SetActiveSelectionType (theArgNb > 4 ?
4160 SelectMgr_SelectingVolumeManager::Box : SelectMgr_SelectingVolumeManager::Point);
4161 aMgr->SetCamera (ViewerTest::CurrentView()->Camera());
4162 aMgr->SetPixelTolerance (ViewerTest::GetAISContext()->PixelTolerance());
4163 Standard_Integer aWidth, aHeight;
4164 ViewerTest::CurrentView()->View()->Window()->Size (aWidth, aHeight);
4165 aMgr->SetWindowSize (aWidth, aHeight);
4168 aMgr->BuildSelectingVolume (aPxPnt1, aPxPnt2);
4172 aMgr->BuildSelectingVolume (aPxPnt1);
4174 const gp_Pnt* aVerts = aMgr->GetVertices();
4175 gp_Pnt aNearPnt = aMgr->GetNearPickedPnt();
4176 gp_Pnt aFarPnt = aMgr->GetFarPickedPnt();
4177 BRepBuilderAPI_MakePolygon aWireBldrs[4];
4179 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4180 aWireBldrs[0].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
4181 aWireBldrs[0].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
4182 aWireBldrs[0].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
4183 aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4185 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
4186 aWireBldrs[1].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
4187 aWireBldrs[1].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
4188 aWireBldrs[1].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z()));
4189 aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z()));
4191 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
4192 aWireBldrs[2].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z()));
4193 aWireBldrs[2].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z()));
4194 aWireBldrs[2].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
4195 aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
4197 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4198 aWireBldrs[3].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z()));
4199 aWireBldrs[3].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z()));
4200 aWireBldrs[3].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z()));
4201 aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z()));
4203 TopoDS_Compound aComp;
4204 BRep_Builder aCompBuilder;
4205 aCompBuilder.MakeCompound (aComp);
4206 for (Standard_Integer aWireIdx = 0; aWireIdx < 4; ++aWireIdx)
4208 aCompBuilder.Add (aComp, aWireBldrs[aWireIdx].Shape());
4210 DBRep::Set ("c", aComp);
4212 Handle(AIS_InteractiveObject) aCmp = new AIS_Shape (aComp);
4213 aCmp->SetColor (Quantity_NOC_GREEN);
4214 ViewerTest::Display ("c", aCmp, Standard_True, Standard_True);
4216 Handle(Geom_CartesianPoint) aPnt1 = new Geom_CartesianPoint (aNearPnt);
4217 Handle(Geom_CartesianPoint) aPnt2 = new Geom_CartesianPoint (aFarPnt);
4219 Handle(AIS_Line) aLine = new AIS_Line (aPnt1, aPnt2);
4220 ViewerTest::Display ("l", aLine, Standard_True, Standard_True);
4224 theDI << "Near: " << aNearPnt.X() << " " << aNearPnt.Y() << " " << aNearPnt.Z() << "\n";
4225 theDI << "Far: " << aFarPnt.X() << " " << aFarPnt.Y() << " " << aFarPnt.Z() << "\n";
4231 //=======================================================================
4232 //function : OCC26462
4234 //=======================================================================
4235 static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
4237 if (ViewerTest::GetAISContext().IsNull())
4239 std::cerr << "Error: No opened context!\n";
4243 BRepPrimAPI_MakeBox aBuilder1 (gp_Pnt (10.0, 10.0, 0.0), 10.0, 10.0, 10.0);
4244 BRepPrimAPI_MakeBox aBuilder2 (10.0, 10.0, 10.0);
4245 Handle(AIS_InteractiveObject) aBox1 = new AIS_Shape (aBuilder1.Shape());
4246 Handle(AIS_InteractiveObject) aBox2 = new AIS_Shape (aBuilder2.Shape());
4248 const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
4249 aCtx->Display (aBox1, 0, 2, Standard_False);
4250 aCtx->Display (aBox2, 0, 2, Standard_False);
4251 ViewerTest::CurrentView()->FitAll();
4252 aCtx->SetWidth (aBox1, 3, Standard_False);
4253 aCtx->SetWidth (aBox2, 3, Standard_False);
4255 aCtx->MoveTo (305, 322, ViewerTest::CurrentView(), Standard_False);
4256 aCtx->ShiftSelect (Standard_False);
4257 aCtx->MoveTo (103, 322, ViewerTest::CurrentView(), Standard_False);
4258 aCtx->ShiftSelect (Standard_False);
4259 if (aCtx->NbSelected() != 0)
4261 theDI << "ERROR: no boxes must be selected!\n";
4265 aCtx->SetSelectionSensitivity (aBox1, 2, 5);
4267 aCtx->MoveTo (305, 322, ViewerTest::CurrentView(), Standard_False);
4268 aCtx->ShiftSelect (Standard_False);
4269 if (aCtx->NbSelected() != 1)
4271 theDI << "ERROR: b1 was not selected\n";
4274 aCtx->MoveTo (103, 322, ViewerTest::CurrentView(), Standard_False);
4275 aCtx->ShiftSelect (Standard_True);
4276 if (aCtx->NbSelected() != 1)
4278 theDI << "ERROR: b2 is selected after b1's tolerance increased\n";
4286 #include <BRepBuilderAPI_GTransform.hxx>
4287 static Standard_Integer OCC26313(Draw_Interpretor& di,Standard_Integer n,const char** a)
4289 if (n <= 1) return 1;
4294 gp_Mat rot( 1.0, 0.0, 0.0,
4298 GT.SetVectorialPart(rot);
4299 BRepBuilderAPI_GTransform gtrf(GT);
4301 TopoDS_Shape aSrcShape = DBRep::Get(a[2]);
4302 if (aSrcShape.IsNull()) {
4303 di << a[2] << " is not a valid shape\n";
4308 gtrf.Perform(aSrcShape);
4313 DBRep::Set(a[1], gtrf.ModifiedShape(aSrcShape));
4315 catch(Standard_Failure)
4317 di << "Error: Exception is thrown\n";
4322 di << "Error: Result is not done\n";
4329 //=======================================================================
4330 //function : OCC26525
4331 //purpose : check number of intersection points
4332 //=======================================================================
4333 #include <BRepAdaptor_Curve.hxx>
4334 #include <BRepAdaptor_Surface.hxx>
4335 #include <BRepAdaptor_HCurve.hxx>
4336 #include <BRepAdaptor_HSurface.hxx>
4337 #include <IntCurveSurface_HInter.hxx>
4338 Standard_Integer OCC26525 (Draw_Interpretor& di,
4342 TopoDS_Shape aS1, aS2;
4348 di << " use OCC26525 r edge face \n";
4352 aS1 = DBRep::Get(a[2]);
4353 aS2 = DBRep::Get(a[3]);
4355 if (aS1.IsNull() || aS2.IsNull())
4357 di << " Null shapes are not allowed \n";
4360 if (aS1.ShapeType()!=TopAbs_EDGE)
4362 di << " Shape" << a[2] << " should be of type EDGE\n";
4365 if (aS2.ShapeType()!=TopAbs_FACE)
4367 di << " Shape" << a[3] << " should be of type FACE\n";
4371 aE=TopoDS::Edge(aS1);
4372 aF=TopoDS::Face(aS2);
4375 Standard_Boolean bIsDone;
4376 Standard_Integer i, aNbPoints;
4377 Standard_Real aU, aV, aT;
4379 BRepAdaptor_Curve aBAC;
4380 BRepAdaptor_Surface aBAS;
4381 IntCurveSurface_TransitionOnCurve aTC;
4382 IntCurveSurface_HInter aHInter;
4384 aBAC.Initialize(aE);
4385 aBAS.Initialize(aF);
4387 Handle(BRepAdaptor_HCurve) aHBAC=new BRepAdaptor_HCurve(aBAC);
4388 Handle(BRepAdaptor_HSurface) aHBAS = new BRepAdaptor_HSurface(aBAS);
4390 aHInter.Perform(aHBAC, aHBAS);
4391 bIsDone=aHInter.IsDone();
4394 di << " intersection is not done\n";
4398 aNbPoints=aHInter.NbPoints();
4399 sprintf (buf, " Number of intersection points found: %d", aNbPoints);
4401 for (i=1; i<=aNbPoints; ++i)
4403 const IntCurveSurface_IntersectionPoint& aIP=aHInter.Point(i);
4404 aIP.Values(aP, aU, aV, aT, aTC);
4406 sprintf (buf, "point %s_%d %lg %lg %lg ", a[1], i, aP.X(), aP.Y(), aP.Z());
4413 //=======================================================================
4414 //function : OCC24537
4415 //purpose : Puts inverted numbers (in the sense of little/big endian inversion)
4416 // from predefined arrays.
4417 //=======================================================================
4418 #include <FSD_BinaryFile.hxx>
4421 inline const unsigned char* SizeRef ();
4424 inline const unsigned char* SizeRef <8> ()
4426 static const unsigned char aSizeRef[] = {
4427 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4428 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
4429 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
4430 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,
4431 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,
4432 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,
4433 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
4434 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
4435 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,
4436 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4441 inline const unsigned char* SizeRef <4> ()
4443 static const unsigned char aSizeRef[] = {
4444 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4445 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4446 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4447 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4448 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4452 static Standard_Integer OCC24537(
4453 Draw_Interpretor& theDI,
4454 Standard_Integer argc,
4463 cout << "cannot create file " << argv[1] << endl;
4467 Standard_Boolean isErr = Standard_False;
4469 const unsigned char anIntRef[] = {
4470 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
4471 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
4472 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
4473 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
4474 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00};
4475 Standard_Integer anIntArr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
4478 for(int i = 0; i < 10; ++i)
4480 Standard_Integer anInv = FSD_BinaryFile::InverseInt(anIntArr[i]);
4481 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4486 Standard_Integer anInv[10];
4487 for(int i = 0; i < 10; ++i)
4488 anInv[i] = FSD_BinaryFile::InverseInt(anIntArr[i]);
4489 if (memcmp(anInv, anIntRef, sizeof(anIntRef)) != 0)
4491 theDI << "Error: incorrect conversion of an integer value\n";
4492 isErr = Standard_True;
4496 // 1a. Random InverseInt
4497 const unsigned char aRndIntRef[] = {
4498 0xFF,0xC2,0xF7,0x00,0xFF,0xFF,0xFB,0x2E,
4499 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
4500 0x00,0x00,0x04,0xD2,0x00,0x00,0x04,0xD3,
4501 0xFF,0xFF,0xFD,0x1E,0xFF,0xFF,0xFF,0xFB,
4502 0x00,0x00,0x03,0x8D,0x00,0x3D,0x09,0x00};
4503 Standard_Integer aRndIntArr[] = {-4000000, -1234, 0, 1, 1234, 1235, -738, -5, 909, 4000000};
4506 for(int i = 0; i < 10; ++i)
4508 Standard_Integer anInv = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4509 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4514 Standard_Integer anInv[10];
4515 for(int i = 0; i < 10; ++i)
4516 anInv[i] = FSD_BinaryFile::InverseInt(aRndIntArr[i]);
4517 if (memcmp(anInv, aRndIntRef, sizeof(aRndIntRef)) != 0)
4519 theDI << "Error: incorrect conversion of a dispersed integer value\n";
4520 isErr = Standard_True;
4525 const unsigned char aRealRef[] = {
4526 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4527 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4528 0x40,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
4529 0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
4530 0x40,0x14,0x00,0x00,0x00,0x00,0x00,0x00,
4531 0x40,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
4532 0x40,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
4533 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4534 0x40,0x22,0x00,0x00,0x00,0x00,0x00,0x00,
4535 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4536 const Standard_Real aRealArr[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0};
4539 for(int i = 0; i < 10; ++i)
4541 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRealArr[i]);
4542 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4547 Standard_Real anInv[10];
4548 for(int i = 0; i < 10; ++i)
4549 anInv[i] = FSD_BinaryFile::InverseReal(aRealArr[i]);
4550 if (memcmp(anInv, aRealRef, sizeof(aRealRef)) != 0)
4552 theDI << "Error: incorrect conversion of a real value\n";
4553 isErr = Standard_True;
4557 // 2a. Random InverseReal
4558 const unsigned char aRndRealRef[] = {
4559 0xFE,0x37,0xE4,0x3C,0x88,0x00,0x75,0x9C,
4560 0xBE,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4561 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4562 0x3E,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95,
4563 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
4564 0x40,0x09,0x21,0xDA,0x45,0x5B,0x53,0xE4,
4565 0x54,0xB2,0x49,0xAD,0x25,0x94,0xC3,0x7D,
4566 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
4567 0xC0,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD,
4568 0x40,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD};
4569 const Standard_Real aRndRealArr[] = {-1e300, -1.e-9, 0., 1.e-9, 1., 3.1415296, 1.e100, 8.0, -9.9, 9.9};
4572 for(int i = 0; i < 10; ++i)
4574 Standard_Real anInv = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4575 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4580 Standard_Real anInv[10];
4581 for(int i = 0; i < 10; ++i)
4582 anInv[i] = FSD_BinaryFile::InverseReal(aRndRealArr[i]);
4583 if (memcmp(anInv, aRndRealRef, sizeof(aRndRealRef)) != 0)
4585 theDI << "Error: incorrect conversion of a dispersed real value\n";
4586 isErr = Standard_True;
4590 // 3. InverseShortReal
4591 const unsigned char aShortRealRef[] = {
4592 0x3F,0x80,0x00,0x00,0x40,0x00,0x00,0x00,
4593 0x40,0x40,0x00,0x00,0x40,0x80,0x00,0x00,
4594 0x40,0xA0,0x00,0x00,0x40,0xC0,0x00,0x00,
4595 0x40,0xE0,0x00,0x00,0x41,0x00,0x00,0x00,
4596 0x41,0x10,0x00,0x00,0x00,0x00,0x00,0x00};
4597 const Standard_ShortReal aShortRealArr[] = {
4598 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 0.0f};
4601 for(int i = 0; i < 10; ++i)
4603 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4604 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4609 Standard_ShortReal anInv[10];
4610 for(int i = 0; i < 10; ++i)
4611 anInv[i] = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]);
4612 if (memcmp(anInv, aShortRealRef, sizeof(aShortRealRef)) != 0)
4614 theDI << "Error: incorrect conversion of a short real value\n";
4615 isErr = Standard_True;
4619 // 3a. Random InverseShortReal
4620 const unsigned char aRndShortRealRef[] = {
4621 0xB0,0x89,0x70,0x5F,0x00,0x00,0x00,0x00,
4622 0x30,0x89,0x70,0x5F,0x3F,0x80,0x00,0x00,
4623 0x40,0x49,0x0E,0x56,0xC0,0xD6,0x66,0x66,
4624 0x40,0xD6,0x66,0x66,0x42,0xC5,0xCC,0xCD,
4625 0xC2,0xC7,0xCC,0xCD,0x42,0xC7,0xCC,0xCD};
4626 const Standard_ShortReal aRndShortRealArr[] = {
4627 -1.e-9f, 0.f, 1.e-9f, 1.f, 3.1415f, -6.7f, 6.7f, 98.9f, -99.9f, 99.9f};
4630 for(int i = 0; i < 10; ++i)
4632 Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4633 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4638 Standard_ShortReal anInv[10];
4639 for(int i = 0; i < 10; ++i)
4640 anInv[i] = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]);
4641 if (memcmp(anInv, aRndShortRealRef, sizeof(aRndShortRealRef)) != 0)
4643 theDI << "Error: incorrect conversion of a dispersed short real value\n";
4644 isErr = Standard_True;
4649 const Standard_Size aSizeArr[] = {1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul, 8ul, 9ul, 0ul};
4652 for(int i = 0; i < 10; ++i)
4654 Standard_Size anInv = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4655 aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv));
4660 Standard_Size anInv[10];
4661 const unsigned char* aSizeRef = SizeRef<sizeof(Standard_Size)>();
4662 for(int i = 0; i < 10; ++i)
4663 anInv[i] = FSD_BinaryFile::InverseSize(aSizeArr[i]);
4664 if (memcmp(anInv, aSizeRef, sizeof(Standard_Size)*10) != 0)
4666 theDI << "Error: incorrect conversion of a size value\n";
4667 isErr = Standard_True;
4671 if (!aF.is_open() && !isErr)
4672 theDI << "Conversion was done OK";
4675 cout << "the file " << argv[1] << " has been created" << endl;
4682 #include <TopExp.hxx>
4683 #include <BRepOffsetAPI_DraftAngle.hxx>
4685 static TopoDS_Shape taper(const TopoDS_Shape &shape, const TopoDS_Face &face_a, const TopoDS_Face &face_b, Standard_Real angle)
4687 // Use maximum face-to-taper z-offset.
4688 const gp_Pln neutral_plane(gp_Ax3(gp_Pnt(0.0, 0.0, 140.0), gp_Dir(0.0, 0.0, 1.0)));
4690 // Draft angle needs to be in radians, and flipped to adhere to our own (arbitrary) draft
4691 // angle definition.
4692 const Standard_Real draft_angle = -(angle / 180.0) * M_PI;
4694 // Add face to draft. The first argument indicates that all material added/removed during
4695 // drafting is located below the neutral plane
4696 BRepOffsetAPI_DraftAngle drafter(shape);
4697 drafter.Add(face_a, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4698 drafter.Add(face_b, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane);
4701 return drafter.Shape();
4704 static void dumpShapeVertices(const TopoDS_Shape &shape, std::vector<Standard_Real>& coords)
4706 TopTools_IndexedMapOfShape shape_vertices;
4707 TopExp::MapShapes(shape, TopAbs_VERTEX, shape_vertices);
4709 for (Standard_Integer i = 1; i <= shape_vertices.Extent(); i++)
4711 gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(shape_vertices(i)));
4712 coords.push_back(p.X());
4713 coords.push_back(p.Y());
4714 coords.push_back(p.Z());
4718 static void GetCoords(const Standard_CString& path_to_file, std::vector<Standard_Real>& coords)
4721 BRep_Builder builder;
4722 BRepTools::Read(shape, path_to_file, builder);
4723 TopTools_IndexedMapOfShape shape_faces;
4724 TopExp::MapShapes(shape, TopAbs_FACE, shape_faces);
4725 TopoDS_Face face_a = TopoDS::Face(shape_faces(1));
4726 TopoDS_Face face_b = TopoDS::Face(shape_faces(5));
4727 dumpShapeVertices(taper(shape, face_a, face_b, 5.0), coords);
4730 static Standard_Integer OCC26396 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4734 theDI << "Error: path to file is missing\n";
4738 const int maxInd = 50;
4740 std::vector<Standard_Real> ref_coords;
4741 ref_coords.reserve(100);
4742 Standard_Boolean Stat = Standard_True;
4744 GetCoords(theArgv[1], ref_coords);
4746 std::vector<Standard_Real> coords;
4747 coords.reserve(100);
4748 for (int i = 1; i < maxInd; i++)
4750 GetCoords(theArgv[1], coords);
4751 if (coords.size() != ref_coords.size())
4753 Stat = Standard_False;
4756 for (size_t j = 0; j < coords.size(); j++)
4757 if (Abs(ref_coords[j] - coords[j]) > RealEpsilon())
4759 Stat = Standard_False;
4765 theDI << "Error: unstable results";
4772 //=======================================================================
4773 //function : OCC26750
4775 //=======================================================================
4776 static Standard_Integer OCC26750( Draw_Interpretor& theDI,
4777 Standard_Integer /*theNArg*/,
4778 const char ** /*theArgVal*/)
4780 const gp_Vec2d aVec1(1.0, 0.0);
4781 const gp_Vec2d aVec2(0.0, -1.0);
4783 if(aVec1.IsNormal(aVec2, Precision::Angular()))
4785 theDI << "gp_Vec2d OK. Vectors are normal.\n";
4789 theDI << "Error in gp_Vec2d. Vectors should be normal.\n";
4792 const gp_Dir2d aD1(1.0, 0.0);
4793 const gp_Dir2d aD2(0.0, -1.0);
4795 if(aD1.IsNormal(aD2, Precision::Angular()))
4797 theDI << "gp_Dir2d OK. Vectors are normal.\n";
4801 theDI << "Error in gp_Dir2d. Vectors should be normal.\n";
4807 //=======================================================================
4808 //function : OCC26746
4809 //purpose : Checks if coefficients of the torus are computed properly.
4810 //=======================================================================
4811 #include <Geom_ToroidalSurface.hxx>
4812 #include <Geom_BSplineCurve.hxx>
4813 static Standard_Integer OCC26746(
4814 Draw_Interpretor& theDI,
4815 Standard_Integer theNArg,
4816 const char ** theArgVal)
4820 theDI << "Use: OCC26746 torus [toler NbCheckedPoints]\n";
4824 const Handle(Geom_ToroidalSurface) aGtor =
4825 Handle(Geom_ToroidalSurface)::DownCast(DrawTrSurf::GetSurface(theArgVal[1]));
4827 const Standard_Real aToler = (theNArg >= 3)? Draw::Atof(theArgVal[2]) : 1.0e-7;
4828 const Standard_Integer aNbPntsMax = (theNArg >= 4)? Draw::Atoi(theArgVal[3]) : 5;
4830 const Standard_Integer aLowIndex = 5;
4831 const Standard_Real aStep = 2.0*M_PI/aNbPntsMax;
4833 TColStd_Array1OfReal anArrCoeffs(aLowIndex, aLowIndex+34);
4834 aGtor->Torus().Coefficients(anArrCoeffs);
4836 Standard_Real aUpar = 0.0, aVpar = 0.0;
4837 for(Standard_Integer aUind = 0; aUind <= aNbPntsMax; aUind++)
4839 for(Standard_Integer aVind = 0; aVind <= aNbPntsMax; aVind++)
4841 const gp_Pnt aPt(aGtor->Value(aUpar, aVpar));
4842 const Standard_Real aX1 = aPt.X();
4843 const Standard_Real aX2 = aX1*aX1;
4844 const Standard_Real aX3 = aX2*aX1;
4845 const Standard_Real aX4 = aX2*aX2;
4846 const Standard_Real aY1 = aPt.Y();
4847 const Standard_Real aY2 = aY1*aY1;
4848 const Standard_Real aY3 = aY2*aY1;
4849 const Standard_Real aY4 = aY2*aY2;
4850 const Standard_Real aZ1 = aPt.Z();
4851 const Standard_Real aZ2 = aZ1*aZ1;
4852 const Standard_Real aZ3 = aZ2*aZ1;
4853 const Standard_Real aZ4 = aZ2*aZ2;
4855 Standard_Integer i = aLowIndex;
4857 Standard_Real aDelta = anArrCoeffs(i++) * aX4; //1
4858 aDelta+= anArrCoeffs(i++) * aY4; //2
4859 aDelta+= anArrCoeffs(i++) * aZ4; //3
4860 aDelta+= anArrCoeffs(i++) * aX3 * aY1; //4
4861 aDelta+= anArrCoeffs(i++) * aX3 * aZ1; //5
4862 aDelta+= anArrCoeffs(i++) * aY3 * aX1; //6
4863 aDelta+= anArrCoeffs(i++) * aY3 * aZ1; //7
4864 aDelta+= anArrCoeffs(i++) * aZ3 * aX1; //8
4865 aDelta+= anArrCoeffs(i++) * aZ3 * aY1; //9
4866 aDelta+= anArrCoeffs(i++) * aX2 * aY2; //10
4867 aDelta+= anArrCoeffs(i++) * aX2 * aZ2; //11
4868 aDelta+= anArrCoeffs(i++) * aY2 * aZ2; //12
4869 aDelta+= anArrCoeffs(i++) * aX2 * aY1 * aZ1; //13
4870 aDelta+= anArrCoeffs(i++) * aX1 * aY2 * aZ1; //14
4871 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ2; //15
4872 aDelta+= anArrCoeffs(i++) * aX3; //16
4873 aDelta+= anArrCoeffs(i++) * aY3; //17
4874 aDelta+= anArrCoeffs(i++) * aZ3; //18
4875 aDelta+= anArrCoeffs(i++) * aX2 * aY1; //19
4876 aDelta+= anArrCoeffs(i++) * aX2 * aZ1; //20
4877 aDelta+= anArrCoeffs(i++) * aY2 * aX1; //21
4878 aDelta+= anArrCoeffs(i++) * aY2 * aZ1; //22
4879 aDelta+= anArrCoeffs(i++) * aZ2 * aX1; //23
4880 aDelta+= anArrCoeffs(i++) * aZ2 * aY1; //24
4881 aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ1; //25
4882 aDelta+= anArrCoeffs(i++) * aX2; //26
4883 aDelta+= anArrCoeffs(i++) * aY2; //27
4884 aDelta+= anArrCoeffs(i++) * aZ2; //28
4885 aDelta+= anArrCoeffs(i++) * aX1 * aY1; //29
4886 aDelta+= anArrCoeffs(i++) * aX1 * aZ1; //30
4887 aDelta+= anArrCoeffs(i++) * aY1 * aZ1; //31
4888 aDelta+= anArrCoeffs(i++) * aX1; //32
4889 aDelta+= anArrCoeffs(i++) * aY1; //33
4890 aDelta+= anArrCoeffs(i++) * aZ1; //34
4891 aDelta+= anArrCoeffs(i++); //35
4893 if(Abs(aDelta) > aToler)
4895 theDI << "(" << aUpar << ", " << aVpar << "): Error in torus coefficients computation (Delta = " << aDelta << ").\n";
4899 theDI << "(" << aUpar << ", " << aVpar << "): OK (Delta = " << aDelta << ").\n";
4902 aVpar = (aVind == aNbPntsMax)? 2.0*M_PI : aVpar + aStep;
4906 aUpar = (aUind == aNbPntsMax)? 2.0*M_PI : aUpar + aStep;
4912 //=======================================================================
4913 //function : OCC27048
4914 //purpose : Calculate value of B-spline surface N times
4915 //=======================================================================
4916 static Standard_Integer OCC27048(Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
4920 std::cout << "Incorrect number of arguments. See usage:" << std::endl;
4921 theDI.PrintHelp(theArgv[0]);
4925 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theArgv[1]);
4926 GeomAdaptor_Surface anAdaptor(aSurf);
4928 Standard_Real aU = Draw::Atof(theArgv[2]);
4929 Standard_Real aV = Draw::Atof(theArgv[3]);
4930 Standard_Integer aN = Draw::Atoi(theArgv[4]);
4932 for (; aN > 0; --aN)
4933 anAdaptor.Value(aU, aV);
4938 //========================================================================
4939 //function : OCC27065
4940 //purpose : Tests overloaded method "Generated" of BRepOffsetAPI_MakePipe
4941 //========================================================================
4942 static Standard_Integer OCC27065(Draw_Interpretor& di,
4943 Standard_Integer n, const char** a)
4945 if (n < 3) return 1;
4948 TopoDS_Shape SpineShape = DBRep::Get(a[1],TopAbs_WIRE);
4949 if ( SpineShape.IsNull()) return 1;
4950 TopoDS_Wire Spine = TopoDS::Wire(SpineShape);
4952 TopoDS_Shape Profile = DBRep::Get(a[2]);
4953 if ( Profile.IsNull()) return 1;
4955 BRepOffsetAPI_MakePipe aPipeBuilder(Spine, Profile);
4956 if (!aPipeBuilder.IsDone())
4958 di << "Error: failed to create pipe\n";
4962 TopExp_Explorer Explo(Profile, TopAbs_SHELL);
4963 TopoDS_Shape aShape;
4964 TopTools_ListIteratorOfListOfShape itl;
4967 aShape = Explo.Current();
4968 TopoDS_Compound res1;
4969 BB.MakeCompound(res1);
4970 itl.Initialize(aPipeBuilder.Generated(aShape));
4971 for (; itl.More(); itl.Next())
4972 BB.Add(res1, itl.Value());
4973 DBRep::Set("res_shell", res1);
4976 Explo.Init(Profile, TopAbs_FACE);
4979 aShape = Explo.Current();
4980 TopoDS_Compound res2;
4981 BB.MakeCompound(res2);
4982 itl.Initialize(aPipeBuilder.Generated(aShape));
4983 for (; itl.More(); itl.Next())
4984 BB.Add(res2, itl.Value());
4985 DBRep::Set("res_face", res2);
4988 Explo.Init(Profile, TopAbs_WIRE);
4991 aShape = Explo.Current();
4992 TopoDS_Compound res3;
4993 BB.MakeCompound(res3);
4994 itl.Initialize(aPipeBuilder.Generated(aShape));
4995 for (; itl.More(); itl.Next())
4996 BB.Add(res3, itl.Value());
4997 DBRep::Set("res_wire", res3);
5000 Explo.Init(Profile, TopAbs_EDGE);
5003 aShape = Explo.Current();
5004 TopoDS_Compound res4;
5005 BB.MakeCompound(res4);
5006 itl.Initialize(aPipeBuilder.Generated(aShape));
5007 for (; itl.More(); itl.Next())
5008 BB.Add(res4, itl.Value());
5009 DBRep::Set("res_edge", res4);
5012 Explo.Init(Profile, TopAbs_VERTEX);
5015 aShape = Explo.Current();
5016 TopoDS_Compound res5;
5017 BB.MakeCompound(res5);
5018 itl.Initialize(aPipeBuilder.Generated(aShape));
5019 for (; itl.More(); itl.Next())
5020 BB.Add(res5, itl.Value());
5021 DBRep::Set("res_vertex", res5);
5027 //========================================================================
5028 //function : OCC27318
5029 //purpose : Creates a box that is not listed in map of AIS objects of ViewerTest
5030 //========================================================================
5031 static Standard_Integer OCC27318 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5033 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5036 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5040 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20, 20, 20).Shape();
5041 Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
5042 aCtx->Display (aBoxObj, Standard_True);
5047 //========================================================================
5048 //function : OCC27523
5049 //purpose : Checks recomputation of deactivated selection mode after object's redisplaying
5050 //========================================================================
5051 static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
5055 std::cerr << "Error: wrong number of arguments! See usage:\n";
5056 theDI.PrintHelp (theArgVec[0]);
5060 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
5061 if(anAISContext.IsNull())
5063 std::cerr << "Error: no active view. Please call vinit.\n";
5067 gp_Pnt aStart (100, 100, 100);
5068 gp_Pnt anEnd (300, 400, 600);
5069 BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
5070 TopoDS_Edge anEdge = anEdgeBuilder.Edge();
5071 Handle(AIS_InteractiveObject) aTestAISShape = new AIS_Shape (anEdge);
5072 anAISContext->Display (aTestAISShape, Standard_False);
5074 // activate it in selection modes
5075 TColStd_SequenceOfInteger aModes;
5076 aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX));
5078 anAISContext->Deactivate (aTestAISShape);
5079 anAISContext->Load (aTestAISShape, -1);
5080 anAISContext->Activate (aTestAISShape, 0);
5081 anAISContext->Deactivate (aTestAISShape, 0);
5083 // activate in vertices mode
5084 for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt)
5086 anAISContext->Activate (aTestAISShape, aModes (anIt));
5089 TopoDS_Shape aVertexShape = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
5090 TopAbs_ShapeEnum aVertexShapeType = aVertexShape.ShapeType();
5091 Handle(AIS_Shape)::DownCast (aTestAISShape)->Set (aVertexShape);
5092 aTestAISShape->Redisplay();
5094 anAISContext->AddOrRemoveSelected (aTestAISShape, Standard_True);
5096 bool aValidShapeType = false;
5097 for (anAISContext->InitSelected(); anAISContext->MoreSelected(); anAISContext->NextSelected())
5099 Handle(SelectMgr_EntityOwner) anOwner = anAISContext->SelectedOwner();
5100 Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
5101 if (!aBRO.IsNull() && aBRO->HasShape())
5103 TopoDS_Shape aShape = aBRO->Shape();
5105 aValidShapeType = aShape.ShapeType() == aVertexShapeType;
5109 if (!aValidShapeType)
5111 std::cerr << "Error: shape type is invalid.\n";
5118 //========================================================================
5119 //function : OCC27700
5120 //purpose : glPolygonMode() used for frame drawing affects label text shading
5121 //========================================================================
5123 class OCC27700_Text : public AIS_InteractiveObject
5127 DEFINE_STANDARD_RTTI_INLINE (OCC27700_Text, AIS_InteractiveObject)
5129 virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
5130 const Handle(Prs3d_Presentation)& thePresentation,
5131 const Standard_Integer /*theMode*/) Standard_OVERRIDE
5133 Handle(Graphic3d_ArrayOfTriangles) aFrame = new Graphic3d_ArrayOfTriangles (6, 6);
5134 aFrame->AddVertex (gp_Pnt (-1, 0, 0));
5135 aFrame->AddVertex (gp_Pnt (-1, 1, 0));
5136 aFrame->AddVertex (gp_Pnt ( 3, 1, 0));
5137 aFrame->AddVertex (gp_Pnt ( 3, 0, 0));
5139 aFrame->AddEdge (1);
5140 aFrame->AddEdge (2);
5141 aFrame->AddEdge (3);
5143 aFrame->AddEdge (2);
5144 aFrame->AddEdge (3);
5145 aFrame->AddEdge (4);
5147 Handle(Graphic3d_AspectFillArea3d) aFillAspect =
5148 new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect().get());
5149 aFillAspect->SetInteriorStyle (Aspect_IS_POINT);
5151 // create separate group for frame elements
5152 Handle(Graphic3d_Group) aFrameGroup = Prs3d_Root::NewGroup (thePresentation);
5153 aFrameGroup->AddPrimitiveArray (aFrame);
5154 aFrameGroup->SetGroupPrimitivesAspect (aFillAspect);
5156 // create separate group for text elements
5157 Handle(Graphic3d_Group) aTextGroup = Prs3d_Root::NewGroup (thePresentation);
5158 TCollection_ExtendedString aString ("YOU SHOULD SEE THIS TEXT", Standard_True);
5159 Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePresentation), myDrawer->TextAspect(), aString, gp_Ax2 (gp::Origin(), gp::DZ()));
5162 virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
5163 const Standard_Integer /*theMode*/) Standard_OVERRIDE {}
5166 static Standard_Integer OCC27700 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
5168 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
5169 if (aContext.IsNull())
5171 std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
5174 Handle(OCC27700_Text) aPresentation = new OCC27700_Text();
5175 aContext->Display (aPresentation, Standard_True);
5179 //========================================================================
5180 //function : OCC27757
5181 //purpose : Creates a box that has a sphere as child object and displays it
5182 //========================================================================
5183 static Standard_Integer OCC27757 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5185 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5188 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5192 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20.0, 20.0, 20.0).Shape();
5193 TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere (10.0).Shape();
5195 aTrsf.SetTranslationPart (gp_Vec (20.0, 20.0, 0.0));
5196 aSphere.Located (TopLoc_Location (aTrsf));
5199 Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
5200 Handle(AIS_Shape) aSphereObj = new AIS_Shape (aSphere);
5201 aBoxObj->AddChild (aSphereObj);
5202 aCtx->Display (aBoxObj, 1, 0, Standard_False);
5203 aCtx->UpdateCurrentViewer();
5208 //========================================================================
5209 //function : OCC27818
5210 //purpose : Creates three boxes and highlights one of them with own style
5211 //========================================================================
5212 static Standard_Integer OCC27818 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5214 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5217 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5221 Handle(AIS_Shape) aBoxObjs[3];
5222 for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx)
5224 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20.0, 20.0, 20.0).Shape();
5225 aBoxObjs[aBoxIdx] = new AIS_Shape (aBox);
5227 aTrsf.SetTranslationPart (gp_Vec (30.0 * aBoxIdx, 30.0 * aBoxIdx, 0.0));
5228 aBoxObjs[aBoxIdx]->SetLocalTransformation (aTrsf);
5229 aBoxObjs[aBoxIdx]->SetHilightMode (AIS_Shaded);
5233 Handle(Prs3d_Drawer) aHiStyle = new Prs3d_Drawer();
5234 aBoxObjs[1]->SetDynamicHilightAttributes (aHiStyle);
5235 aHiStyle->SetDisplayMode (AIS_Shaded);
5236 aHiStyle->SetColor (Quantity_NOC_RED);
5237 aHiStyle->SetTransparency (0.8f);
5240 Handle(Prs3d_Drawer) aSelStyle = new Prs3d_Drawer();
5241 aBoxObjs[2]->SetHilightAttributes (aSelStyle);
5242 aSelStyle->SetDisplayMode (AIS_Shaded);
5243 aSelStyle->SetColor (Quantity_NOC_RED);
5244 aSelStyle->SetTransparency (0.0f);
5245 aSelStyle->SetZLayer (Graphic3d_ZLayerId_Topmost);
5248 for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx)
5250 aCtx->Display (aBoxObjs[aBoxIdx], AIS_Shaded, 0, Standard_False);
5253 aCtx->UpdateCurrentViewer();
5258 //========================================================================
5259 //function : OCC27893
5260 //purpose : Creates a box and selects it via AIS_InteractiveContext API
5261 //========================================================================
5262 static Standard_Integer OCC27893 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5264 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5267 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5271 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
5272 Handle(AIS_InteractiveObject) aBoxObj = new AIS_Shape (aBox);
5273 aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False);
5274 aCtx->SetSelected (aBoxObj, Standard_True);
5279 //========================================================================
5280 //function : OCC28310
5281 //purpose : Tests validness of iterator in AIS_InteractiveContext after
5282 // an removing object from it
5283 //========================================================================
5284 static Standard_Integer OCC28310 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
5286 const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
5289 std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
5293 TopoDS_Shape aBox = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
5294 Handle(AIS_InteractiveObject) aBoxObj = new AIS_Shape (aBox);
5295 aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False);
5296 ViewerTest::CurrentView()->FitAll();
5297 aCtx->MoveTo (200, 200, ViewerTest::CurrentView(), Standard_True);
5298 aCtx->Select(Standard_True);
5300 aCtx->Remove (aBoxObj, Standard_True);
5301 // nullify the object explicitly to simulate situation in project,
5302 // when ::Remove is called from another method and the object is destroyed
5303 // before ::DetectedInteractive is called
5306 for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
5308 Handle(AIS_InteractiveObject) anObj = aCtx->DetectedInteractive();
5314 // repetitive display and removal of multiple small objects in the viewer for
5315 // test of memory leak in visualization (OCCT 6.9.0 - 7.0.0)
5316 static Standard_Integer OCC29412 (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, const char** theArgVec)
5318 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
5321 std::cout << "Error: no active view.\n";
5325 const int aNbIters = (theArgNb <= 1 ? 10000 : Draw::Atoi (theArgVec[1]));
5326 int aProgressPrev = -1;
5327 for (int m_loopIndex = 0; m_loopIndex < aNbIters; m_loopIndex++)
5332 gp_Ax2 center (pos, dir);
5333 gp_Circ circle (center, 1);
5334 Handle(AIS_Shape) feature;
5336 BRepBuilderAPI_MakeEdge builder( circle );
5338 if( builder.Error() == BRepBuilderAPI_EdgeDone )
5340 TopoDS_Edge E1 = builder.Edge();
5341 TopoDS_Shape W2 = BRepBuilderAPI_MakeWire(E1).Wire();
5342 feature = new AIS_Shape(W2);
5343 aCtx->Display (feature, true);
5346 aCtx->CurrentViewer()->Update();
5347 ViewerTest::CurrentView()->FitAll();
5348 aCtx->Remove (feature, true);
5350 const int aProgress = (m_loopIndex * 100) / aNbIters;
5351 if (aProgress != aProgressPrev)
5353 std::cerr << aProgress << "%\r";
5354 aProgressPrev = aProgress;
5360 //========================================================================
5361 //function : Commands_19
5363 //========================================================================
5365 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
5366 const char *group = "QABugs";
5368 Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass();
5369 theCommands.Add ("OCC24202_1", "Test Handle-based procedure",
5370 __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group);
5371 NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass();
5372 theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure",
5373 __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group);
5375 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
5376 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
5377 theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
5378 theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
5379 theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
5380 theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
5381 theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
5382 theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
5383 theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
5384 theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
5385 theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
5386 theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
5387 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);
5388 theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
5389 theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
5390 theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
5391 theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
5392 theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
5393 theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group);
5394 theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group);
5395 theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group);
5396 theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group);
5397 theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group);
5398 theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group);
5399 theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group);
5400 theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group);
5401 theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group);
5402 theCommands.Add ("OCC23951", "OCC23951 path to saved step file", __FILE__, OCC23951, group);
5403 theCommands.Add ("OCC24931", "OCC24931 path to saved xml file", __FILE__, OCC24931, group);
5404 theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group);
5405 theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
5406 theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group);
5407 theCommands.Add ("OCC24925",
5408 "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]"
5409 "\nOCAF persistence without setting environment variables",
5410 __FILE__, OCC24925, group);
5411 theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group);
5412 theCommands.Add ("OCC24826,", "This test performs simple saxpy test using multiple threads.\n Usage: OCC24826 length", __FILE__, OCC24826, group);
5413 theCommands.Add ("OCC29935,", "This test performs product of two square matrices using multiple threads.\n Usage: OCC29935 size", __FILE__, OCC29935, group);
5414 theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group);
5415 theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group);
5416 theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
5417 theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
5418 theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group);
5419 theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group);
5420 theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
5421 theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
5422 theCommands.Add ("OCC25545",
5423 "no args; tests data race when concurrently accessing \n"
5424 "\t\tTopLoc_Location::Transformation()",
5425 __FILE__, OCC25545, group);
5426 theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
5427 theCommands.Add ("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group);
5428 theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);
5429 theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group);
5430 theCommands.Add ("OCC26139", "OCC26139 [-boxsize value] [-boxgrid value] [-compgrid value]", __FILE__, OCC26139, group);
5431 theCommands.Add ("OCC26284", "OCC26284", __FILE__, OCC26284, group);
5432 theCommands.Add ("OCC26446", "OCC26446 r c1 c2", __FILE__, OCC26446, group);
5433 theCommands.Add ("OCC26448", "OCC26448: check method Prepend() of sequence", __FILE__, OCC26448, group);
5434 theCommands.Add ("OCC26407", "OCC26407 result_name", __FILE__, OCC26407, group);
5435 theCommands.Add ("OCC26485", "OCC26485 shape", __FILE__, OCC26485, group);
5436 theCommands.Add ("OCC26553", "OCC26553 file_path", __FILE__, OCC26553, group);
5437 theCommands.Add ("OCC26195",
5438 "OCC26195: x1_pix y1_pix [x2_pix y2_pix] [toPrintPixelCoord 0|1]"
5439 "\n\t\t: Draws rectangular selecting frustum defined by point selection in pixel coordinates"
5440 "\n\t\t: [x1_pix, y1_pix] or rectangular selection in pixel coordinates [x1_pix, y1_pix,"
5441 "\n\t\t: x2_pix, y2_pix]."
5442 "\n\t\t: [toPrintPixelCoord 0|1] - prints 3d projection of pixel coordinate or center of"
5443 "\n\t\t: selecting rectangle onto near and far view frustum planes",
5444 __FILE__, OCC26195, group);
5445 theCommands.Add ("OCC26462",
5446 "OCC26462: Checks the ability to manage sensitivity of a particular selection mode in local context",
5447 __FILE__, OCC26462, group);
5449 theCommands.Add ("OCC26313", "OCC26313 result shape", __FILE__, OCC26313, group);
5450 theCommands.Add ("OCC26396", "OCC26396 shape_file_path", __FILE__, OCC26396, group);
5451 theCommands.Add ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group);
5453 theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group);
5454 theCommands.Add ("OCC26750", "OCC26750", __FILE__, OCC26750, group);
5455 theCommands.Add ("OCC25574", "OCC25574", __FILE__, OCC25574, group);
5456 theCommands.Add ("OCC26746", "OCC26746 torus [toler NbCheckedPoints] ", __FILE__, OCC26746, group);
5458 theCommands.Add ("OCC27048",
5459 "OCC27048 surf U V N\nCalculate value of surface N times in the point (U, V)",
5460 __FILE__, OCC27048, group);
5462 theCommands.Add ("OCC27065",
5463 "OCC27065 spine profile",
5464 __FILE__, OCC27065, group);
5466 theCommands.Add ("OCC27318",
5467 "OCC27318: Creates a box that is not listed in map of AIS objects of ViewerTest",
5468 __FILE__, OCC27318, group);
5469 theCommands.Add ("OCC27523",
5470 "OCC27523: Checks recomputation of deactivated selection mode after object's redisplaying",
5471 __FILE__, OCC27523, group);
5472 theCommands.Add ("OCC27700",
5473 "OCC27700: Checks drawing text after setting interior style",
5474 __FILE__, OCC27700, group);
5475 theCommands.Add ("OCC27757",
5476 "OCC27757: Creates a box that has a sphere as child object and displays it",
5477 __FILE__, OCC27757, group);
5478 theCommands.Add ("OCC27818",
5479 "OCC27818: Creates three boxes and highlights one of them with own style",
5480 __FILE__, OCC27818, group);
5481 theCommands.Add ("OCC27893",
5482 "OCC27893: Creates a box and selects it via AIS_InteractiveContext API",
5483 __FILE__, OCC27893, group);
5484 theCommands.Add("OCC28310",
5485 "OCC28310: Tests validness of iterator in AIS_InteractiveContext after an removing object from it",
5486 __FILE__, OCC28310, group);
5487 theCommands.Add("OCC29412", "OCC29412 [nb cycles]: test display / remove of many small objects", __FILE__, OCC29412, group);