1 // Created on: 2002-03-20
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.
21 #include <Draw_Interpretor.hxx>
23 #include <DrawTrSurf.hxx>
24 #include <AIS_InteractiveContext.hxx>
25 #include <ViewerTest.hxx>
26 #include <AIS_Shape.hxx>
27 #include <TopoDS_Shape.hxx>
29 #include <Geom_Surface.hxx>
30 #include <Geom_Axis2Placement.hxx>
32 #include <gp_Trsf.hxx>
33 #include <AIS_Trihedron.hxx>
34 #include <BRepPrimAPI_MakeBox.hxx>
35 #include <Graphic3d_MaterialAspect.hxx>
36 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
37 #include <TopoDS_Solid.hxx>
38 #include <BRepPrimAPI_MakeSphere.hxx>
39 #include <BRepPrimAPI_MakeCone.hxx>
40 #include <BRepPrimAPI_MakeCylinder.hxx>
41 #include <IGESToBRep_Reader.hxx>
42 #include <TopExp_Explorer.hxx>
44 #include <GCPnts_UniformDeflection.hxx>
45 #include <BRepAdaptor_Curve.hxx>
46 #include <IGESToBRep.hxx>
47 #include <V3d_Viewer.hxx>
48 #include <BRepAdaptor_CompCurve.hxx>
49 #include <GCPnts_AbscissaPoint.hxx>
50 #include <Standard_ErrorHandler.hxx>
51 #include <Standard_Overflow.hxx>
52 #include <Standard_Underflow.hxx>
53 #include <Standard_DivideByZero.hxx>
54 #include <OSD_SIGSEGV.hxx>
55 #include <OSD_Exception_ACCESS_VIOLATION.hxx>
56 #include <OSD_Exception_STACK_OVERFLOW.hxx>
58 #include <OSD_ThreadPool.hxx>
59 #include <STEPCAFControl_Writer.hxx>
60 #include <STEPControl_StepModelType.hxx>
61 #include <Interface_Static.hxx>
62 #include <IFSelect_ReturnStatus.hxx>
63 #include <Standard_Failure.hxx>
64 #include <TColgp_HArray1OfPnt2d.hxx>
65 #include <Geom2dAPI_Interpolate.hxx>
66 #include <Geom2d_BSplineCurve.hxx>
67 #include <Geom2dConvert_BSplineCurveToBezierCurve.hxx>
68 #include <Geom2d_BezierCurve.hxx>
69 #include <BRep_Tool.hxx>
70 #include <GeomProjLib.hxx>
71 #include <Geom2dAPI_InterCurveCurve.hxx>
72 #include <IntRes2d_IntersectionSegment.hxx>
73 #include <TDataStd_RealArray.hxx>
74 #include <TDF_CopyLabel.hxx>
75 #include <NCollection_Vector.hxx>
76 #include <TColStd_Array1OfInteger.hxx>
77 #include <Geom_BSplineCurve.hxx>
78 #include <TColgp_Array1OfPnt.hxx>
79 #include <AIS_ColorScale.hxx>
80 #include <AIS_ListOfInteractive.hxx>
81 #include <AIS_ListIteratorOfListOfInteractive.hxx>
82 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
83 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
84 #include <BRepBuilderAPI_MakePolygon.hxx>
85 #include <gp_GTrsf.hxx>
86 #include <Poly_Triangulation.hxx>
87 #include <IGESControl_Reader.hxx>
88 #include <IGESData_IGESModel.hxx>
89 #include <IGESData_IGESEntity.hxx>
90 #include <V3d_View.hxx>
91 #include <BRepFeat_SplitShape.hxx>
92 #include <BRepAlgoAPI_Section.hxx>
93 #include <TColStd_PackedMapOfInteger.hxx>
94 #include <Message.hxx>
95 #include <Draw_Printer.hxx>
98 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
100 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
103 static Standard_Integer OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
105 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
106 if(myAISContext.IsNull()) {
107 di << "use 'vinit' command before " << argv[0] ;
111 Handle(Geom_Axis2Placement) aTrihedronAxis = new Geom_Axis2Placement(gp::XOY());
114 trsf1.SetTranslation(gp_Vec(100, 100, 0));
115 aTrihedronAxis->Transform(trsf1);
116 Handle(AIS_Trihedron) myTrihedron = new AIS_Trihedron(aTrihedronAxis);
117 myTrihedron->SetColor(Quantity_NOC_LIGHTSTEELBLUE4);
118 myTrihedron->SetSize(100);
119 myAISContext->Display(myTrihedron, Standard_True);
121 // TopoDS_Shape shape1 = (TopoDS_Shape) BRepPrimAPI_MakeBox(50,50,50);
122 TopoDS_Shape shape1 = BRepPrimAPI_MakeBox(50,50,50).Shape();
123 Handle(AIS_Shape) AS = new AIS_Shape(shape1);
124 AS->SetDisplayMode(1);
125 Graphic3d_MaterialAspect mat(Graphic3d_NOM_PLASTIC);
126 AS->SetMaterial(mat);
127 AS->SetColor(Quantity_NOC_RED);
128 myAISContext->Display (AS, Standard_False);
131 TouchTrsf.SetTranslation(gp_Vec(20, 20, 0));
133 myAISContext->ResetLocation(AS);
134 myAISContext->SetLocation(AS , TouchTrsf) ;
135 myAISContext->Redisplay(AS, Standard_True);
140 // Remove as bad version of QAAddOrRemoveSelected from QADraw
141 //static Standard_Integer OCC129 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
144 // di<<"Usage : " << argv[0] << " shape islocal\n";
148 // Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
150 // // ViewerTest_DoubleMapOfInteractiveAndName& aMap =
151 // // ViewerTest::GetDataMapOfAIS ();
152 // ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
154 // TCollection_AsciiString aName(argv[1]);
155 // Handle(AIS_InteractiveObject) AISObj;
157 // if(aMap.IsBound2(aName)) {
158 // AISObj = aMap.Find2(aName);
159 // if(AISObj.IsNull()){
160 // di<<"No interactive object \n";
164 // Standard_Integer aNum = -1;
166 // if(Draw::Atoi(argv[2])) {
167 // aNum = anAISCtx->OpenLocalContext();
170 // if(anAISCtx->HasOpenedContext()){
171 // anAISCtx->InitSelected();
172 // anAISCtx->AddOrRemoveSelected(AISObj);
175 // anAISCtx->InitCurrent();
176 // anAISCtx->AddOrRemoveCurrentObject(AISObj);
180 // // anAISCtx->CloseLocalContext(aNum);
185 // //select this shape:
187 // di<<"Use 'vdisplay' before";
192 static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
195 di<<"Usage: OCC136\n";
199 //create some primitives:
201 Standard_Real Size=100;
202 gp_Pnt P0(0,0,0), P1(Size,Size,Size);
204 TopoDS_Solid aBox = BRepPrimAPI_MakeBox(P0,P1);
206 TopoDS_Solid aSphere = BRepPrimAPI_MakeSphere (Size*0.5);
208 gp_Ax2 anAx2(P1, gp_Dir(1,1,1));
209 TopoDS_Solid aCone = BRepPrimAPI_MakeCone(anAx2, Size*0.7, Size*0.3, Size);
211 anAx2.SetLocation(gp_Pnt(Size,0,0));
212 anAx2.SetDirection(gp_Dir(-1,-1,1));
213 TopoDS_Solid aCyl = BRepPrimAPI_MakeCylinder(anAx2, Size*0.5, Size);
215 Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
216 if(anAISCtx.IsNull()){
217 di<<"Null interactive context. Use 'vinit' at first.\n";
221 anAISCtx->EraseAll (Standard_False);
223 //load primitives to context
224 Handle(AIS_InteractiveObject) aSh1 = new AIS_Shape(aBox);
225 anAISCtx->Display (aSh1, Standard_False);
227 Handle(AIS_InteractiveObject) aSh2 = new AIS_Shape(aSphere);
228 anAISCtx->Display (aSh2, Standard_False);
230 Handle(AIS_InteractiveObject) aSh3 = new AIS_Shape(aCone);
231 anAISCtx->Display (aSh3, Standard_False);
233 Handle(AIS_InteractiveObject) aSh4 = new AIS_Shape(aCyl);
234 anAISCtx->Display (aSh4, Standard_False);
237 anAISCtx->InitSelected();
238 anAISCtx->AddOrRemoveSelected (aSh1, Standard_False);
239 anAISCtx->AddOrRemoveSelected (aSh2, Standard_False);
240 anAISCtx->AddOrRemoveSelected (aSh3, Standard_False);
241 anAISCtx->AddOrRemoveSelected (aSh4, Standard_False);
243 //remove all this objects from context
244 anAISCtx->Remove (aSh1, Standard_False);
245 anAISCtx->Remove (aSh2, Standard_False);
246 anAISCtx->Remove (aSh3, Standard_False);
247 anAISCtx->Remove (aSh4, Standard_False);
249 anAISCtx->UpdateCurrentViewer();
253 static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
255 printf("Usage: %s iges_input [name]\n",argv[0]);
258 Standard_Character *Ch = NULL;
261 Ch = new Standard_Character[strlen(argv[2])+3];
263 IGESToBRep_Reader IR;
264 IR.LoadFile (argv[1]);
267 TopoDS_Shape aTopShape = IR.OneShape();
268 TopExp_Explorer ex(aTopShape, TopAbs_EDGE);
269 Standard_Integer i=0;
270 for( ; ex.More(); ex.Next()){
271 const TopoDS_Edge &E = TopoDS::Edge(ex.Current());
272 BRepAdaptor_Curve aCurve(E);
273 GCPnts_UniformDeflection plin(aCurve, 0.1);
274 di << "Num points = " << plin.NbPoints() << "\n";
277 Sprintf(Ch,"%s_%i",argv[2],1);
284 //====================================================
286 // Following code is inserted from
287 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
288 // ( 75455 Apr 16 18:59)
290 //====================================================
293 #include <BRepTools_WireExplorer.hxx>
294 #include <BRep_Tool.hxx>
295 #include <GCPnts_UniformAbscissa.hxx>
296 #include <TopExp.hxx>
299 // usage : OCC105 shape
302 //GCPnts_UniformAbscissa returns bad end point foe first edge. Its value is
304 //Value Pnt = -338.556216693211 -394.465571897208 0
306 //Value Pnt = -307.47165394 -340.18073533 0
308 static int OCC105(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
311 di<<"Usage : OCC105 shape\n";
314 // TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get("aa.brep"));
315 TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1]));
316 Standard_Real l = 0.5; //Draw::Atof(argv[2]);
317 // Find the first vertex of the wire
318 BRepTools_WireExplorer wire_exp(myTopoDSWire);
321 TopoDS_Vertex vw1, vw2;
322 TopExp::Vertices(myTopoDSWire,vw1,vw2);
323 TopoDS_Vertex ve1, ve2;
324 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
325 TopExp::Vertices(edge,ve1,ve2);
326 if (vw1.IsSame(ve1) || vw1.IsSame(ve2))
329 // assert(vw2.IsSame(ve1) || vw2.IsSame(ve2));
333 for ( ; wire_exp.More(); wire_exp.Next())
335 di << "\n\n New Edge \n" << "\n";
336 Standard_Real newufirst, newulast;
337 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
338 Standard_Real ufirst, ulast;
339 Handle(Geom_Curve) acurve;
340 TopoDS_Vertex ve1, ve2;
341 TopExp::Vertices(edge,ve1,ve2);
342 if (ve1.IsSame(vlast))
344 acurve = BRep_Tool::Curve(edge, ufirst, ulast);
351 // assert(ve2.IsSame(vlast));
352 // assert ( wire_exp.Orientation( ) == TopAbs_REVERSED );
353 acurve = BRep_Tool::Curve( edge, ufirst, ulast );
354 newufirst = acurve->ReversedParameter( ufirst );
355 newulast = acurve->ReversedParameter( ulast );
356 acurve = acurve->Reversed( );
360 GeomAdaptor_Curve curve;
361 GCPnts_UniformAbscissa algo;
363 algo.Initialize( curve, l, newufirst, newulast );
365 di << "Not Done!!!" << "\n";
366 for (Standard_Integer Index = 1; Index<=algo.NbPoints();Index++) {
367 Standard_Real t = algo.Parameter(Index);
368 gp_Pnt pt3 = curve.Value(t);
369 di << "Parameter t = " << t << "\n";
370 di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z() << "\n";
377 #include <TColStd_SequenceOfTransient.hxx>
378 #include <GeomFill_Pipe.hxx>
379 static int pipe_OCC9 (Draw_Interpretor& di,
380 Standard_Integer n, const char ** a)
383 di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]\n";
387 TColStd_SequenceOfTransient aCurveSeq;
389 for (i=2 ; i<=4; i++) {
390 Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast( DrawTrSurf::Get(a[i]) );
392 di << a[i] << " is not a curve\n";
395 aCurveSeq.Append(aC);
398 GeomFill_Pipe aPipe(Handle(Geom_Curve)::DownCast( aCurveSeq(1) ),
399 Handle(Geom_Curve)::DownCast( aCurveSeq(2) ),
400 Handle(Geom_Curve)::DownCast( aCurveSeq(3) ),
404 aPipe.Perform(Draw::Atof (a[6]), Standard_True);
406 aPipe.Perform(Standard_True/*, Standard_True*/);
409 if (!aPipe.IsDone()) {
410 di << "GeomFill_Pipe cannot make a surface\n";
414 Handle(Geom_Surface) aSurf = aPipe.Surface();
416 DrawTrSurf::Set(a[1], aSurf);
420 //======================================================================
422 // usage : OCC125 shell
423 //======================================================================
424 #include <ShapeFix_Shell.hxx>
426 Standard_Integer OCC125(Draw_Interpretor& di ,
431 di<<" Use OCC125 shell";
435 TopoDS_Shape S = DBRep::Get(a[1]);
438 di<<" Null shape is not allowed";
444 if (aT!=TopAbs_SHELL) {
445 di<<" Shape Type must be SHELL";
449 const TopoDS_Shell& aShell = TopoDS::Shell(S);
451 Standard_Boolean isAccountMultiConex, bNonManifold, bResult;
453 isAccountMultiConex=Standard_True;
454 bNonManifold=Standard_False;
456 Handle (ShapeFix_Shell) aFix = new ShapeFix_Shell(aShell);
457 bResult=aFix->FixFaceOrientation(aShell, isAccountMultiConex, bNonManifold);
459 di<<"bResult="<<(Standard_Integer)bResult;
462 aShape=aFix->Shape();
464 TCollection_AsciiString aName(a[1]), aDef("_sh"), aRName;
467 DBRep::Set (aRName.ToCString(), aShape);
468 di<<aRName.ToCString();
473 #include <BRepLib_FindSurface.hxx>
474 #include <BRepBuilderAPI_MakeFace.hxx>
475 Standard_Integer OCC157(Draw_Interpretor& di,
478 //static Standard_Integer findplanarsurface(Draw_Interpretor&, Standard_Integer n, const char ** a)
481 di << "bad number of arguments\n";
485 // try to read a shape:
486 TopoDS_Shape inputShape=DBRep::Get(a[2]);
487 if (inputShape.IsNull() || inputShape.ShapeType() != TopAbs_WIRE) {
488 di << "Invalid input shape\n";
491 Standard_Real toler = Draw::Atof(a[3]);
492 TopoDS_Wire aWire = TopoDS::Wire(inputShape);
493 BRepLib_FindSurface FS(aWire, toler, Standard_True);
495 di<<"OCC157: OK; Planar surface is found\n";
496 Handle(Geom_Surface) aSurf = FS.Surface();
497 BRepBuilderAPI_MakeFace aMakeFace(aSurf,aWire,Standard_True);
498 if(aMakeFace.IsDone()) {
499 TopoDS_Face aFace = aMakeFace.Face();
500 DBRep::Set(a[1],aFace);
503 else di<<"OCC157: ERROR; Planar surface is not found with toler = "<<toler <<"\n";
508 // #include <MyCommandsCMD.h>
509 #include <ShapeFix_Shape.hxx>
510 #include <BRepOffset_MakeOffset.hxx>
511 #include <BRepOffsetAPI_MakeOffset.hxx>
512 #include <BRepOffset_Mode.hxx>
513 #include <GeomAbs_JoinType.hxx>
514 #include <AIS_Shape.hxx>
516 #include <BRepTools.hxx>
518 Standard_Integer OCC165(Draw_Interpretor& di ,
523 //=======================================================================
525 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv);
527 // void MyOffsets_Commands(Draw_Interpretor& theCommands)
529 // theCommands.Add("yoffset" , "yoffset" , __FILE__, YOffset, " Offset on Z Direction");
532 //=======================================================================
534 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
538 di <<"Usage : " << a[0] << " [file]\n";
543 #define _OFFSET_TELCO_
544 #ifdef _OFFSET_TELCO_
546 Standard_CString file = a[1];
548 BRep_Builder aBuilder;
549 TopoDS_Shape theShape;
550 //BRepTools::Read(theShape, Standard_CString("/dn02/users_SUN/inv/3/OCC165/2d_tr_line.brep"), aBuilder);
551 BRepTools::Read(theShape, file, aBuilder);
552 DBRep::Set("shape", theShape);
554 TopoDS_Wire theWire = TopoDS::Wire(theShape);
556 Standard_Real anOffset = 1.5;
560 Standard_Real xA = 0.0, xB = 200.0, xC = 200.0, xD = 0.0,
561 yA = 0.0, yB = 0.0, yC = 200.0, yD = 200.0,
562 zA = 0.0, zB = 0.0, zC = 0.0, zD = 0.0;
564 BRepBuilderAPI_MakePolygon theSquare;
565 TopoDS_Vertex theA = BRepBuilderAPI_MakeVertex(gp_Pnt(xA, yA, zA));
567 TopoDS_Vertex theB = BRepBuilderAPI_MakeVertex(gp_Pnt(xB, yB, zB));
569 TopoDS_Vertex theC = BRepBuilderAPI_MakeVertex(gp_Pnt(xC, yC, zC));
571 TopoDS_Vertex theD = BRepBuilderAPI_MakeVertex(gp_Pnt(xD, yD, zD));
575 TopoDS_Wire theWire = theSquare.Wire();
577 Standard_Real anOffset = 10;
580 #endif /* _OFFSET_TELCO_ */
583 TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire).Face();
584 DBRep::Set("face", theFace);
587 Standard_Real anAlt = 0.;
588 GeomAbs_JoinType theJoin = GeomAbs_Intersection;
589 //GeomAbs_Intersection; //GeomAbs_Arc;
590 BRepOffsetAPI_MakeOffset aMakeOffset(theFace, theJoin);
591 aMakeOffset.AddWire(theWire);
593 aMakeOffset.Perform(anOffset, anAlt);
595 TopoDS_Shape theOffsetShapePos = aMakeOffset.Shape();
596 DBRep::Set("offset", theOffsetShapePos);
601 #include<BRepAlgoAPI_Cut.hxx>
603 #include<BRepPrimAPI_MakeHalfSpace.hxx>
604 #include<Geom_CartesianPoint.hxx>
605 #include<AIS_Point.hxx>
607 #include <BRepBuilderAPI_MakeEdge.hxx>
608 #include <BRepBuilderAPI_MakeWire.hxx>
609 #include <BRepBuilderAPI_MakeFace.hxx>
611 static Standard_Integer OCC297 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
614 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
615 if (myAISContext.IsNull()) {
616 di << "use 'vinit' command before " << argv[0] << "\n";
620 gp_Pnt pt1_(250., 250., 0.);
621 gp_Pnt pt2_(-250., 250., 0.);
622 gp_Pnt pt3_(-250., -250., 0.);
623 gp_Pnt pt4_(250., -250., 0.);
624 BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
625 BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
626 BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
627 BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
629 BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
630 BRepBuilderAPI_MakeFace face_(wire_);
631 TopoDS_Face sh_ = face_.Face();
637 g_pnt = gp_Pnt(0, 0, -100);
639 g_pnt = gp_Pnt(0, 0, 100);
641 myAISContext->EraseAll(Standard_False);
642 Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
643 Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
644 myAISContext->Display(AISPoint, Standard_True);
646 BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
647 TopoDS_Solid sol1_ = half_.Solid();
649 DBRep::Set("Face", sol1_);
651 gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
653 Standard_Real x = 0., y = 0., z = -80.;
655 BRepPrimAPI_MakeBox box(gp_Pnt(x, y, z), gp_Pnt(x + 150, y + 200, z + 200));
657 DBRep::Set("Box", box.Shape());
663 #include<GProp_GProps.hxx>
664 #include<BRepGProp.hxx>
666 static Standard_Integer OCC305 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
671 di <<"Usage : " << argv[0] << " file\n";
674 Standard_CString file = argv[1];
676 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
677 if(myAISContext.IsNull()) {
678 di << "use 'vinit' command before " << argv[0] << "\n";
683 BRep_Builder builder;
684 //BRepTools::Read(sh, "/dn02/users_SUN/inv/3/OCC305/testc.brep", builder);
685 BRepTools::Read(sh, file, builder);
688 builder.MakeWire(wire);
690 TopoDS_Vertex vt1, vt2;
691 TopExp_Explorer wex(sh, TopAbs_EDGE);
692 for(;wex.More();wex.Next())
694 ed = TopoDS::Edge(wex.Current());
695 TopExp::Vertices(ed, vt1, vt2);
696 builder.UpdateVertex(vt1, 0.01);
697 builder.UpdateVertex(vt2, 0.01);
698 builder.UpdateEdge(ed, 0.01);
699 builder.Add(wire, ed);
703 BRepGProp::LinearProperties(ed, lprop);
704 printf("\n length = %f", lprop.Mass());
706 DBRep::Set("Wire",wire);
707 // Handle(AIS_Shape) res = new AIS_Shape( wire );
708 // aContext->SetColor( res, Quantity_NOC_RED );
709 // aContext->Display( res );
711 // BRepOffsetAPI_MakeOffset off(wire, GeomAbs_Arc);
712 // off.Perform(0.5, 0);
714 // printf("\n IsDone = %d", off.IsDone());
716 // res = new AIS_Shape( sh );
717 // aContext->SetColor( res, Quantity_NOC_GREEN );
718 // aContext->Display( res );
724 static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
727 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
728 if(myAISContext.IsNull()) {
729 di << "use 'vinit' command before " << argv[0];
733 BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
734 Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape());
735 myAISContext->SetAutoActivateSelection (Standard_False);
736 myAISContext->Display(anAISBox, 1);
738 TColStd_ListOfInteger anActivatedModes;
739 myAISContext->ActivatedModes (anAISBox, anActivatedModes);
740 if(anActivatedModes.Extent() != 1 || anActivatedModes.First() != -1 )
746 #include <TDocStd_Document.hxx>
747 #include <DDocStd.hxx>
748 #include <PCDM_StoreStatus.hxx>
749 #include <TDocStd_Application.hxx>
751 static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
754 di << "Usage: " << a[0] << " Doc\n";
758 Handle(TDocStd_Document) D;
759 if (!DDocStd::GetDocument(a[1],D)) return 1;
761 Handle(TDocStd_Application) A = DDocStd::GetApplication();
763 TCollection_ExtendedString theStatusMessage;
765 di << "this document has never been saved\n";
768 PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
769 if (theStatus != PCDM_SS_OK ) {
770 switch ( theStatus ) {
771 case PCDM_SS_DriverFailure: {
772 di << "Error saving document: Could not store , no driver found to make it\n";
775 case PCDM_SS_WriteFailure: {
776 di << "Error saving document: Write access failure\n";
779 case PCDM_SS_Failure: {
780 di << "Error saving document: Write failure\n" ;
783 case PCDM_SS_Doc_IsNull: {
784 di << "Error saving document: No document to save\n";
787 case PCDM_SS_No_Obj: {
788 di << "Error saving document: No objects written\n";
791 case PCDM_SS_Info_Section_Error: {
792 di << "Error saving document: Write info section failure\n" ;
803 static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
806 di << "Usage: " << a[0] << " Doc Path\n";
810 Handle(TDocStd_Document) D;
811 if (!DDocStd::GetDocument(a[1],D)) return 1;
813 TCollection_ExtendedString path (a[2]);
814 Handle(TDocStd_Application) A = DDocStd::GetApplication();
816 TCollection_ExtendedString theStatusMessage;
817 PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
818 if (theStatus != PCDM_SS_OK ) {
819 switch ( theStatus ) {
820 case PCDM_SS_DriverFailure: {
821 di << "Error saving document: Could not store , no driver found to make it\n";
824 case PCDM_SS_WriteFailure: {
825 di << "Error saving document: Write access failure\n";
828 case PCDM_SS_Failure: {
829 di << "Error saving document: Write failure\n" ;
832 case PCDM_SS_Doc_IsNull: {
833 di << "Error saving document: No document to save\n";
836 case PCDM_SS_No_Obj: {
837 di << "Error saving document: No objects written\n";
840 case PCDM_SS_Info_Section_Error: {
841 di << "Error saving document: Write info section failure\n" ;
853 #include <BRepClass3d_SolidClassifier.hxx>
855 Standard_Integer OCC299bug (Draw_Interpretor& theDi,
856 Standard_Integer theArgNb,
857 const char** theArgVec)
861 theDi << "Usage : " << theArgVec[0] << " Solid Point [Tolerance=1.e-7]\n";
865 TopoDS_Shape aS = DBRep::Get (theArgVec[1]);
868 theDi << " Null Shape is not allowed here\n";
871 else if (aS.ShapeType() != TopAbs_SOLID)
873 theDi << " Shape type must be SOLID\n";
877 gp_Pnt aP (8., 9., 10.);
878 if (!DrawTrSurf::GetPoint (theArgVec[2], aP))
880 theDi << " Null Point is not allowed here\n";
883 const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : 1.e-7;
885 BRepClass3d_SolidClassifier aSC (aS);
886 aSC.Perform (aP, aTol);
890 case TopAbs_IN: theDi << "The point is IN shape\n"; return 0;
891 case TopAbs_OUT: theDi << "The point is OUT of shape\n"; return 0;
892 case TopAbs_ON: theDi << "The point is ON shape\n"; return 0;
894 default: theDi << "The point is UNKNOWN shape\n"; return 0;
898 #include <OSD_Process.hxx>
899 #include <OSD_Path.hxx>
901 static Standard_Integer OCC309bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
904 di << "Usage: " << a[0] << "\n";
908 OSD_Path d = p.CurrentDirectory();
909 TCollection_AsciiString s;
911 di << "*" << s.ToCString() << "*\n";
914 di << "*" << s.ToCString() << "*\n";
918 static Standard_Integer OCC310bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
921 di << "Usage: " << a[0] << "\n";
924 OSD_Path p("/where/you/want/tmp/qwerty/tmp/");
925 di << p.Trek().ToCString() << "\n";
927 di << p.Trek().ToCString() << "\n";
931 #include <BRepAlgoAPI_Fuse.hxx>
932 #include <BRepAlgoAPI_Common.hxx>
934 static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
937 di << "Usage : " << a[0] << "\n";
941 BRepPrimAPI_MakeBox box1( 100, 100, 100 );
942 BRepPrimAPI_MakeBox box2( gp_Pnt( 50, 50,50 ), 200, 200, 200 );
944 TopoDS_Shape shape1 = box1.Shape();
945 TopoDS_Shape shape2 = box2.Shape();
947 TopoDS_Shape fuse,comm;
948 di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )\n";
949 di << "comm = BRepAlgoAPI_Common( shape1, shape2 )\n";
950 fuse = BRepAlgoAPI_Fuse(shape1, shape2).Shape();
951 comm = BRepAlgoAPI_Common(shape1, shape2).Shape();
956 #include <DDocStd_DrawDocument.hxx>
957 #include <TDataStd_Name.hxx>
959 #include <XCAFDoc_ShapeTool.hxx>
960 #include <XCAFDoc_DocumentTool.hxx>
961 #include <TDF_LabelSequence.hxx>
962 #include <TPrsStd_AISPresentation.hxx>
963 #include <TDF_Data.hxx>
964 #include <TDF_Label.hxx>
965 #include <XCAFPrs_Driver.hxx>
967 //------------------------------------------------------------------------------------------
970 //------------------------------------------------------------------------------------------
971 static Standard_Integer OCC363 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
976 // 1. Verufy amount of arguments
977 if(argc < 3) { di <<"Error OCC363 : Use : OCC363 document filename\n"; return 1; }
979 // 2. Retrieve DDocStd application
980 Handle(TDocStd_Application) App = DDocStd::GetApplication();
983 TCollection_ExtendedString name(argv[2]);
984 Handle(TDocStd_Document) Doc;
985 if(App->Open(name, Doc) != PCDM_RS_OK) { di << "Error OCC363 : document was not opened successfully\n"; return 1;}
986 Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(Doc);
987 TDataStd_Name::Set(Doc->GetData()->Root(),argv[1]);
988 Draw::Set(argv[1],DD);
990 // 4. Create prsentations
991 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
992 TDF_LabelSequence seq;
993 shapes->GetFreeShapes ( seq );
994 Handle(TPrsStd_AISPresentation) prs;
995 for ( Standard_Integer i=1; i <= seq.Length(); i++ )
996 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) )
997 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
999 catch(Standard_Failure const&) { di << "FAULTY OCC363 : Exception during reading document.\n";return 0;}
1001 di << "OCC363 OK\n";
1006 ////======================================================================================
1007 //// Function : OCC372
1009 ////======================================================================================
1010 //static Standard_Integer OCC372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1014 // OCC_CATCH_SIGNALS
1015 // // 1. Verufy amount of arguments
1016 // if(argc < 2) {di << "OCC372 FAULTY. Use : OCC372 brep-file";return 0;}
1020 // TopoDS_Shape Ref;
1021 // BRepTools::Read(Ref, argv[1], B);
1023 // // 3. Calculate location of aP3d in relation to the solid
1024 // gp_Pnt aP3d(6311.4862583184, -2841.3092756034, 16.461053497188);
1025 // BRepClass3d_SolidClassifier SC(Ref);
1026 // SC.Perform(aP3d, 1e-7);
1028 // // 4. Check returned state. The point must be inside the solid.
1029 // TopAbs_State aState=SC.State();
1033 // di<<"OCC372 FAULTY. aState = TopAbs_OUT";
1036 // di<<"OCC372 FAULTY. aState = TopAbs_ON";
1039 // di<<"OCC372 OK. aState = TopAbs_IN" ;
1042 // di<<"OCC372 FAULTY. aState = UNKNOWN";
1046 // catch (Standard_Failure) { di<<"OCC372 FAULTY. Exception raised"; }
1051 #include <BRepTopAdaptor_FClass2d.hxx>
1053 //======================================================================================
1054 // Function : OCC377
1056 //======================================================================================
1057 static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1062 // 1. Verify validity of arguments
1063 if ( argc < 1 ) {di << "Error OCC377. Use OCC377 file x y precuv \n";return 0;}
1065 // 2. Initialize parameters
1067 p2d.SetX ( Draw::Atof(argv[2]) );
1068 p2d.SetY ( Draw::Atof(argv[3]) );
1069 Standard_Real precuv = Draw::Atof (argv[4] );
1074 BRepTools::Read ( Shape, argv[1], B );
1076 // 4. Verify whether enrtry point is on wire and reversed ones (indeed results of veridying must be same)
1077 TopExp_Explorer exp;
1078 Standard_Integer i=1;
1079 for (exp.Init(Shape.Oriented(TopAbs_FORWARD),TopAbs_WIRE); exp.More(); exp.Next(), i++)
1081 // 4.1. Verify whether enrtry point is on wire
1082 const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
1083 TopoDS_Face newFace = TopoDS::Face(Shape.EmptyCopied());
1085 TopAbs_Orientation orWire = wir.Orientation();
1086 newFace.Orientation(TopAbs_FORWARD);
1089 BRepTopAdaptor_FClass2d FClass2d1(newFace,precuv);
1090 TopAbs_State stat1 = FClass2d1.PerformInfinitePoint();
1091 //di << "Wire " << i << ": Infinite point is " <<
1092 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1094 TCollection_AsciiString TmpString;
1095 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1096 di << "Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1098 stat1 = FClass2d1.Perform(p2d);
1099 //di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1100 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1103 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1104 di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1106 // 4.2. Verify whether enrtry point is on reversed wire
1107 newFace = TopoDS::Face(Shape.EmptyCopied());
1108 newFace.Orientation(TopAbs_FORWARD);
1109 orWire = TopAbs::Reverse(orWire);
1110 B.Add(newFace,wir.Oriented(orWire));
1111 BRepTopAdaptor_FClass2d FClass2d2(newFace,precuv);
1112 TopAbs_State stat2 = FClass2d2.PerformInfinitePoint();
1113 //di << "Reversed Wire " << i << ": Infinite point is " <<
1114 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1117 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1118 di << "Reversed Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1120 stat2 = FClass2d2.Perform(p2d);
1121 //di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1122 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1125 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1126 di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1128 // 4.3. Compare results (they must be same)
1129 if(stat1 ==stat2) di << "OCC377 OK\n";
1130 else {di << "OCC377 FAULTY\n"; return 0;}
1133 catch(Standard_Failure const&)
1135 di << "OCC377 Exception";
1141 #include <ShapeUpgrade_ShapeDivideAngle.hxx>
1142 #include <ShapeBuild_ReShape.hxx>
1144 //=======================================================================
1147 //=======================================================================
1148 static Standard_Integer OCC22 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1153 // 1. Verify arguments of the command
1154 if (argc < 5) { di << "OCC22 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation"; return 0;}
1156 Standard_Boolean aConsiderLocation;
1157 if(strcmp(argv[4], "0")==0) aConsiderLocation = Standard_False;
1158 else aConsiderLocation = Standard_True;
1160 // 2. Iniitialize aShapeUpgrade
1161 ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(M_PI/2.);
1163 aShapeUpgrade.SetPrecision (Precision::Confusion());
1165 aShapeUpgrade.SetMaxTolerance(0.1);
1166 // subshapes to be divided
1167 TopoDS_Shape aSubShapesToBeDivided = DBRep::Get(argv[3]);
1168 if(aSubShapesToBeDivided.IsNull()) {di << "OCC22 FAULTY. Compound of subshapes to be divided is not exist. Please, verify input values. \n";return 0;}
1169 aShapeUpgrade.Init(aSubShapesToBeDivided);
1171 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1172 aShapeUpgrade.SetContext(aReshape);
1173 if(aConsiderLocation) aReshape->ModeConsiderLocation() = Standard_True;
1175 // 3. Perform splitting
1176 if (aShapeUpgrade.Perform (Standard_False)) di << "Upgrade_SplitRevolution_Done \n";
1177 else if (aShapeUpgrade.Status (ShapeExtend_OK)) di << "Upgrade_SplitRevolution_OK \n";
1178 else if (aShapeUpgrade.Status (ShapeExtend_FAIL)) { di << "OCC22 FAULTY. Operation failed. Angle was not divided\n";return 0;}
1180 // 4. Perform rebuilding shape
1181 // 4.1. Retrieve Shape
1182 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1183 if(anInitShape.IsNull()) { di << "OCC22 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1184 // 4.2 Rebuid retrieved shape
1185 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1186 // 4.3. Create result Draw shape
1187 DBRep::Set(argv[1], aResultShape);
1189 catch (Standard_Failure const&) {di << "OCC22 Exception \n" ;return 0;}
1195 #include <ShapeProcess_OperLibrary.hxx>
1196 #include <ShapeProcess_ShapeContext.hxx>
1197 #include <ShapeProcess.hxx>
1199 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
1200 #include <BRepMesh_IncrementalMesh.hxx>
1201 #include <IMeshTools_Parameters.hxx>
1203 //=======================================================================
1206 //=======================================================================
1207 static Standard_Integer OCC24 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1212 // 1. Verify amount of arguments of the command
1213 if (argc < 6) { di << "OCC24 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapes ResourceFileName SequenceName"; return 0;}
1215 // 2. Retrieve parameters
1217 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1218 if(anInitShape.IsNull()) { di << "OCC24 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1219 // compound of subshapes
1220 TopoDS_Shape aSubShapes = DBRep::Get(argv[3]);
1221 if(aSubShapes.IsNull()) {di << "OCC24 FAULTY. Compound of subshapes is not exist. Please, verify input values. \n";return 0;}
1222 // name of resource file
1223 const char* aResourceFile = argv[4];
1224 // name of sequence from resource file to be executed
1225 const char* aSequenceName = argv[5];
1227 // 3. Initialize ShapeContext and perform sequence of operation specified with resource file
1228 ShapeProcess_OperLibrary::Init();
1229 Handle(ShapeProcess_ShapeContext) aShapeContext = new ShapeProcess_ShapeContext (aSubShapes, aResourceFile);
1230 aShapeContext->SetDetalisation (TopAbs_EDGE);
1231 ShapeProcess::Perform (aShapeContext, aSequenceName);
1233 // 4. Rebuild initil shape in accordance with performed operation
1234 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1235 TopTools_DataMapIteratorOfDataMapOfShapeShape anIter (aShapeContext->Map());
1236 for (; anIter.More(); anIter.Next())
1237 aReshape->Replace(anIter.Key(), anIter.Value());
1238 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1240 // 5 Create resultant Draw shape
1241 DBRep::Set(argv[1], aResultShape);
1244 catch (Standard_Failure const&) {di << "OCC24 Exception \n" ;return 0;}
1249 //=======================================================================
1251 //purpose : Verify whether exception occurs during building mesh
1252 //=======================================================================
1253 static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1258 // 1. Verify amount of arguments of the command
1259 if (argc < 2) { di << "OCC369 FAULTY. Use : OCC369 Shape \n"; return 0;}
1261 // 2. Retrieve shape
1262 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1263 if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
1266 IMeshTools_Parameters aMeshParams;
1267 aMeshParams.Relative = Standard_True;
1268 aMeshParams.Deflection = 0.2;
1269 aMeshParams.Angle = M_PI / 6.0;
1270 BRepMesh_IncrementalMesh aMesh(aShape, aMeshParams);
1273 catch (Standard_Failure const&) {di << "OCC369 Exception \n" ;return 0;}
1275 di << "OCC369 OK \n";
1279 #include <math_Vector.hxx>
1280 #include <math_Matrix.hxx>
1281 static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1284 di<<"Usage : " << argv[0] << " LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix\n";
1287 Standard_Integer LowerVector = Draw::Atoi(argv[1]);
1288 Standard_Integer UpperVector = Draw::Atoi(argv[2]);
1289 Standard_Real InitialValueVector = Draw::Atof(argv[3]);
1290 Standard_Integer LowerRowMatrix = Draw::Atoi(argv[4]);
1291 Standard_Integer UpperRowMatrix = Draw::Atoi(argv[5]);
1292 Standard_Integer LowerColMatrix = Draw::Atoi(argv[6]);
1293 Standard_Integer UpperColMatrix = Draw::Atoi(argv[7]);
1294 Standard_Real InitialValueMatrix = Draw::Atof(argv[8]);
1296 math_Vector Vector1(LowerVector, UpperVector);
1297 math_Vector Vector2(LowerVector, UpperVector);
1299 math_Vector Vector(LowerVector, UpperVector, InitialValueVector);
1300 math_Matrix Matrix(LowerRowMatrix, UpperRowMatrix, LowerColMatrix, UpperColMatrix, InitialValueMatrix);
1302 //Vector.Dump(std::cout);
1303 //std::cout<<std::endl;
1305 //Matrix.Dump(std::cout);
1306 //std::cout<<std::endl;
1308 Vector1.Multiply(Vector, Matrix);
1310 //Vector1.Dump(std::cout);
1311 Standard_SStream aSStream1;
1312 Vector1.Dump(aSStream1);
1316 if (Matrix.RowNumber() > 1) {
1317 Matrix(Matrix.LowerRow() + 1, Matrix.LowerCol()) += 1.;
1319 Vector2.TMultiply(Vector, Matrix);
1321 //Vector2.Dump(std::cout);
1322 Standard_SStream aSStream2;
1323 Vector2.Dump(aSStream2);
1330 #include <GeomPlate_BuildPlateSurface.hxx>
1331 //=======================================================================
1334 //=======================================================================
1335 static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
1337 GeomPlate_BuildPlateSurface aBuilder;
1340 if (aBuilder.IsDone())
1342 di << "Error in OCC525. Null result is expected.\n";
1346 di << "OCC525 OK \n";
1352 #include <BRepPrimAPI_MakeWedge.hxx>
1353 #include <gce_MakeRotation.hxx>
1354 #include <gce_MakeTranslation.hxx>
1355 #include <BRepBuilderAPI_Transform.hxx>
1356 #include <BRepPrimAPI_MakeWedge.hxx>
1357 //=======================================================================
1360 //=======================================================================
1361 static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1364 di << "Usage : " << argv[0] << " shape1 shape2 shape3\n";
1369 double xperiod = 1.0;
1370 double yperiod = 1.0;
1371 double sub_thick = 0.5;
1374 //TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick );
1375 TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick ).Shape();
1377 // --------------------------------------------------------------------
1380 //TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1381 // 0.1, 0.1 , 0.4, 0.4 );
1382 TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1383 0.1, 0.1 , 0.4, 0.4 ).Shape();
1385 gp_Trsf rotate = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1386 gp_Dir(1.0,0.0,0.0),
1389 gp_Trsf translate = gce_MakeTranslation(gp_Pnt( 0.0, -0.5, 0.0),
1390 gp_Pnt( 0.25, 0.25, 0.5)
1393 rotate.PreMultiply( translate );
1395 TopoDS_Shape wedge1a = BRepBuilderAPI_Transform( wedge1, rotate );
1397 if (wedge1a.IsNull()) {
1398 di<<" Null shape1 is not allowed\n";
1401 DBRep::Set(argv[1], wedge1a);
1403 // --------------------------------------------------------------------
1406 //TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1407 // 0.1, 0.1 , 0.4, 0.4 );
1408 TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1409 0.1, 0.1 , 0.4, 0.4 ).Shape();
1411 gp_Trsf rotate2 = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1412 gp_Dir(1.0,0.0,0.0),
1415 gp_Trsf translate2 = gce_MakeTranslation(gp_Pnt( 0.0, 0.0, 0.0),
1416 gp_Pnt( 0.25, 0.25, 0.5)
1419 rotate2.PreMultiply( translate2 );
1421 TopoDS_Shape wedge2a = BRepBuilderAPI_Transform( wedge2, rotate2 );
1423 if (wedge2a.IsNull()) {
1424 di<<" Null shape2 is not allowed\n";
1427 DBRep::Set(argv[2], wedge2a);
1431 di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)\n";
1432 TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a).Shape();
1434 di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)\n";
1435 TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common).Shape();
1437 if (sub_etch1.IsNull()) {
1438 di<<" Null shape3 is not allowed\n";
1441 DBRep::Set(argv[3], sub_etch1);
1446 #include <Standard_GUID.hxx>
1447 //=======================================================================
1450 //=======================================================================
1451 static Standard_Integer OCC669 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1454 di<<"Usage : " << argv[0] << " GUID\n";
1457 Standard_GUID guid(argv[1]);
1458 //guid.ShallowDump(std::cout);
1459 Standard_SStream aSStream;
1460 guid.ShallowDump(aSStream);
1466 #include <XCAFDoc.hxx>
1467 //=======================================================================
1468 //function : OCC738_ShapeRef
1470 //=======================================================================
1471 static Standard_Integer OCC738_ShapeRef (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1474 di<<"Usage : " << argv[0] << "\n";
1477 const Standard_GUID& guid = XCAFDoc::ShapeRefGUID ();
1478 //guid.ShallowDump(std::cout);
1479 Standard_SStream aSStream;
1480 guid.ShallowDump(aSStream);
1485 //=======================================================================
1486 //function : OCC738_Assembly
1488 //=======================================================================
1489 static Standard_Integer OCC738_Assembly (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1492 di<<"Usage : " << argv[0] << "\n";
1495 const Standard_GUID& guid = XCAFDoc::AssemblyGUID ();
1496 //guid.ShallowDump(std::cout);
1497 Standard_SStream aSStream;
1498 guid.ShallowDump(aSStream);
1503 #if defined(DDataStd_def01)
1504 #include <DDataStd_DrawPresentation.hxx>
1505 //=======================================================================
1506 //function : OCC739_DrawPresentation
1508 //=======================================================================
1509 static Standard_Integer OCC739_DrawPresentation (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1512 di<<"Usage : " << argv[0] << "\n";
1515 const Standard_GUID& guid = DDataStd_DrawPresentation::GetID() ;
1516 //guid.ShallowDump(std::cout);
1517 Standard_SStream aSStream;
1518 guid.ShallowDump(aSStream);
1524 //=======================================================================
1527 //=======================================================================
1528 static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1530 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1531 if(aContext.IsNull()) {
1532 di << argv[0] << "ERROR : use 'vinit' command before \n";
1537 di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation\n";
1541 Standard_Boolean updateviewer = Standard_True;
1543 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1545 TCollection_AsciiString aName(argv[1]);
1546 Handle(AIS_InteractiveObject) AISObj;
1548 if (!aMap.Find2 (aName, AISObj)
1551 di << "Use 'vdisplay' before\n";
1555 AISObj->ResetTransformation();
1557 aContext->Erase(AISObj, updateviewer);
1558 aContext->UpdateCurrentViewer();
1559 aContext->Display(AISObj, updateviewer);
1560 aContext->UpdateCurrentViewer();
1564 //=======================================================================
1567 //=======================================================================
1568 #include <TColStd_Array2OfInteger.hxx>
1569 static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1572 di<<"Usage : " << argv[0] << "\n";
1576 // check that exception initialized without message string can be safely handled and printed
1578 throw Standard_OutOfRange();
1580 catch (Standard_Failure const& anException) {
1581 std::cout << "Caught successfully: ";
1582 std::cout << anException << std::endl;
1587 #include <GeomAPI_ProjectPointOnSurf.hxx>
1588 //=======================================================================
1591 //=======================================================================
1592 static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1596 di<<"Usage : " << argv[0] << " Point Surface Umin Usup Vmin Vsup \n";
1601 DrawTrSurf::GetPoint(argv[1],aPoint3d);
1602 Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
1603 Standard_Real Umin=Draw::Atof(argv[3]);
1604 Standard_Real Usup=Draw::Atof(argv[4]);
1605 Standard_Real Vmin=Draw::Atof(argv[5]);
1606 Standard_Real Vsup=Draw::Atof(argv[6]);
1608 if (aSurface.IsNull()) {
1609 di << argv[2] << " Null surface \n" ;
1613 GeomAPI_ProjectPointOnSurf PonSurf;
1614 PonSurf.Init(aSurface, Umin, Usup, Vmin, Vsup);
1615 PonSurf.Perform(aPoint3d);
1620 //=======================================================================
1623 //=======================================================================
1624 static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1628 di<<"Usage : " << argv[0] << " wire face\n";
1632 TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
1633 TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
1634 if (awire.IsNull() || aface.IsNull()) {
1635 di << "Null object\n";
1639 Standard_Integer count = 0;
1640 TopExp_Explorer TE(awire, TopAbs_VERTEX);
1642 BRepTools_WireExplorer WE;
1643 for ( WE.Init(awire,aface); WE.More(); WE.Next()) {
1644 TopoDS_Edge E = WE.Current();
1648 di << "Count = " << count << "\n";
1653 //=======================================================================
1656 //=======================================================================
1657 static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1661 di <<"Usage : " << argv[0] << " face\n";
1664 Standard_Real u1, u2, v1, v2;
1665 TopoDS_Face F = TopoDS::Face( DBRep::Get(argv[1]) ); //read the shape
1668 BRepTools::UVBounds(F, u1, u2, v1, v2);
1669 di << "Bounds: " << u1 << " " << u2 << " " << v1 << " " << v2 << "\n";
1673 #include <Expr_NamedUnknown.hxx>
1674 #include <Expr_GeneralExpression.hxx>
1675 #include <Expr_Exponential.hxx>
1676 //=======================================================================
1679 //=======================================================================
1680 static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1684 di <<"Usage : " << argv[0] << " expression\n";
1688 TCollection_AsciiString myStr(argv[1]);
1690 Handle (Expr_NamedUnknown) myNamed = new Expr_NamedUnknown(myStr);
1691 Handle (Expr_Exponential) oldExpr = new Expr_Exponential(myNamed);
1692 Handle (Expr_GeneralExpression) newExpr = oldExpr->Derivative(myNamed);
1695 TCollection_AsciiString res = newExpr->String();
1696 Standard_CString resStr = res.ToCString();
1697 TCollection_AsciiString res_old = oldExpr->String();
1698 Standard_CString res_oldStr = res_old.ToCString();
1701 di << "X = " << argv[1] << "\n";
1702 di << "Y = " << res_oldStr << "\n";
1703 di << "Y' = " << resStr << "\n";
1709 #include <TPrsStd_AISViewer.hxx>
1710 #include <TDF_Label.hxx>
1711 #include <TPrsStd_AISPresentation.hxx>
1712 //=======================================================================
1713 //function : OCC1029_AISTransparency
1714 //purpose : OCC1029_AISTransparency (DOC,entry,[real])
1715 //=======================================================================
1717 static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
1718 Standard_Integer nb,
1722 Handle(TDocStd_Document) D;
1723 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1725 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1727 Handle(TPrsStd_AISViewer) viewer;
1728 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1730 Handle(TPrsStd_AISPresentation) prs;
1731 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1733 prs->SetTransparency(Draw::Atof(arg[3]));
1734 TPrsStd_AISViewer::Update(L);
1737 di << "Transparency = " << prs->Transparency() << "\n";
1742 di << arg[0] << " : Error\n";
1746 //=======================================================================
1747 //function : OCC1031_AISMaterial
1748 //purpose : OCC1031_AISMaterial (DOC,entry,[material])
1749 //=======================================================================
1751 static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
1752 Standard_Integer nb,
1756 Handle(TDocStd_Document) D;
1757 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1759 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1761 Handle(TPrsStd_AISViewer) viewer;
1762 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1764 Handle(TPrsStd_AISPresentation) prs;
1765 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1767 prs->SetMaterial((Graphic3d_NameOfMaterial)Draw::Atoi(arg[3]));
1768 TPrsStd_AISViewer::Update(L);
1771 di << "Material = " << prs->Material() << "\n";
1776 di << arg[0] << " : Error\n";
1780 //=======================================================================
1781 //function : OCC1032_AISWidth
1782 //purpose : OCC1032_AISWidth (DOC,entry,[width])
1783 //=======================================================================
1785 static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
1786 Standard_Integer nb,
1790 Handle(TDocStd_Document) D;
1791 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1793 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1795 Handle(TPrsStd_AISViewer) viewer;
1796 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1798 Handle(TPrsStd_AISPresentation) prs;
1799 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1801 prs->SetWidth(Draw::Atof(arg[3]));
1802 TPrsStd_AISViewer::Update(L);
1805 di << "Width = " << prs->Width() << "\n";
1810 di << arg[0] << " : Error\n";
1814 //=======================================================================
1815 //function : OCC1033_AISMode
1816 //purpose : OCC1033_AISMode (DOC,entry,[mode])
1817 //=======================================================================
1819 static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
1820 Standard_Integer nb,
1824 Handle(TDocStd_Document) D;
1825 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1827 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1829 Handle(TPrsStd_AISViewer) viewer;
1830 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1832 Handle(TPrsStd_AISPresentation) prs;
1833 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1835 prs->SetMode(Draw::Atoi(arg[3]));
1836 TPrsStd_AISViewer::Update(L);
1839 di << "Mode = " << prs->Mode() << "\n";
1844 di << arg[0] << " : Error\n";
1848 //=======================================================================
1849 //function : OCC1034_AISSelectionMode
1850 //purpose : OCC1034_AISSelectionMode (DOC,entry,[selectionmode])
1851 //=======================================================================
1853 static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
1854 Standard_Integer nb,
1858 Handle(TDocStd_Document) D;
1859 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1861 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1863 Handle(TPrsStd_AISViewer) viewer;
1864 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1866 Handle(TPrsStd_AISPresentation) prs;
1867 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1869 prs->SetSelectionMode(Draw::Atoi(arg[3]));
1870 TPrsStd_AISViewer::Update(L);
1873 di << "SelectionMode = " << prs->SelectionMode() << "\n";
1878 di << arg[0] << " : Error\n";
1882 //=======================================================================
1883 //function : OCC1487
1885 //=======================================================================
1886 static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1889 di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape\n";
1893 Standard_Integer CaseNumber = Draw::Atoi(argv[1]);
1895 //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
1896 gp_Dir myDir(1,0,0);
1897 gp_Pnt myPnt(0,-50,140);
1898 gp_Ax2 myAx2(myPnt, myDir);
1899 BRepPrimAPI_MakeCylinder o_mc1 (myAx2, 50,1000);
1901 TopoDS_Shape cyl1 = o_mc1.Shape();
1904 TopoDS_Shape o_cut_shape;
1905 if (CaseNumber == 1) {
1906 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(21.65064, -50.0, 127.5),gp_Dir(-sin(M_PI/3), 0.0, 0.5)), 5, 150);
1907 gp_Dir myDir_mc2(-sin(M_PI/3), 0.0, 0.5);
1908 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
1909 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
1910 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
1912 cyl2 = o_mc2.Shape();
1913 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
1914 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ()).Shape();
1916 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(978.34936, -50.0, 127.5),gp_Dir(sin(M_PI/3), 0.0, 0.5)), 5, 150);
1917 gp_Dir myDir_mc2(sin(M_PI/3), 0.0, 0.5);
1918 gp_Pnt myPnt_mc2(978.34936, -50.0, 127.5);
1919 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
1920 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
1922 cyl2 = o_mc2.Shape();
1923 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
1924 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ()).Shape();
1927 DBRep::Set(argv[2],cyl1);
1928 DBRep::Set(argv[3],cyl2);
1929 DBRep::Set(argv[4],o_cut_shape);
1934 #include<TopTools_ListIteratorOfListOfShape.hxx>
1935 #include<BRepFilletAPI_MakeFillet.hxx>
1936 //=======================================================================
1937 //function : OCC1077
1939 //=======================================================================
1940 TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
1942 Standard_Real t3d = 1.e-4;
1943 Standard_Real t2d = 1.e-5;
1944 Standard_Real ta = 1.e-2;
1945 Standard_Real fl = 1.e-3;
1946 Standard_Real tapp_angle = 1.e-2;
1947 GeomAbs_Shape blend_cont = GeomAbs_C1;
1949 TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
1951 TopTools_ListIteratorOfListOfShape its;
1953 TopoDS_Compound result;
1955 B.MakeCompound(result);
1958 for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
1960 const TopoDS_Shape& cutsol = ex.Current();
1962 BRepFilletAPI_MakeFillet fill(cutsol);
1963 fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
1964 fill.SetContinuity(blend_cont, tapp_angle);
1965 its = aBoolenaOperation.SectionEdges();
1968 TopoDS_Edge E = TopoDS::Edge(its.Value());
1969 fill.Add(aRadius, E);
1976 B.Add(result, fill.Shape());
1980 B.Add(result, cutsol);
1986 TopoDS_Shape OCC1077_cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
1988 //return OCC1077_boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
1989 BRepAlgoAPI_Cut aCut(aShapeToCut, aTool);
1990 return OCC1077_boolbl(aCut,aRadius);
1993 //TopoDS_Shape OCC1077_common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
1995 // return OCC1077_boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
1998 TopoDS_Shape OCC1077_Bug()
2000 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10).Shape();
2001 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7).Shape();
2003 TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
2004 TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10),
2005 gp_Dir(0, 0, 1)), 3, 20).Shape();
2006 TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0),
2007 gp_Dir(1, 0, 0)), 3, 20).Shape();
2008 TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
2009 gp_Dir(0, 1, 0)), 3, 20).Shape();
2010 TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
2011 Handle(ShapeFix_Shape) fixer = new ShapeFix_Shape(theTmp1);
2013 theTmp1 = fixer->Shape();
2014 TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
2015 fixer->Init(theTmp2);
2017 theTmp2 = fixer->Shape();
2018 TopoDS_Shape theResult = OCC1077_cut_blend(theTmp2,theCylinder3,0.7);
2019 fixer->Init(theResult);
2021 theResult = fixer->Shape();
2025 static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2027 if(argc < 1 || argc > 2) {
2028 di << "Usage : " << argv[0] << " result\n";
2032 TopoDS_Shape S = OCC1077_Bug();
2033 DBRep::Set(argv[1],S);
2038 //////////////////////////////////////////////////////////////
2040 * Compute uniform distribution of points using GCPnts_UniformAbscissa
2042 //////////////////////////////////////////////////////////////
2043 static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2047 di << "Usage : " << argv[0] << " name shape step\n";
2050 const char *name = argv[1];
2051 Adaptor3d_Curve *adapCurve=NULL;
2052 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
2053 if (!curve.IsNull())
2054 adapCurve = new GeomAdaptor_Curve(curve);
2057 TopoDS_Shape wire = DBRep::Get(argv[2]);
2058 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
2060 di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected\n";
2063 adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
2065 double step = Draw::Atof(argv[3]);
2066 GCPnts_UniformAbscissa aUni(*adapCurve, step);
2070 di << argv[0] <<" : fail\n";
2075 int i, np = aUni.NbPoints();
2076 for (i=0; i < np; i++)
2078 double par = aUni.Parameter(i+1);
2079 gp_Pnt p = adapCurve->Value(par);
2080 char n[20], *pname=n;
2081 Sprintf(n,"%s_%d",name,i+1);
2082 DrawTrSurf::Set(pname,p);
2091 static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2095 di << "Usage : " << argv[0] << " nb_of_vectors size\n";
2099 Standard_Integer nb = Draw::Atoi(argv[1]);
2100 Standard_Integer sz = Draw::Atoi(argv[2]);
2101 Standard_Real val = 10;
2102 math_Vector **pv = new math_Vector *[nb];
2104 di<<"creating "<<nb<<" vectors "<<sz<<" elements each...\n";
2106 for (i=0; i < nb; i++) {
2107 pv[i] = new math_Vector (1, sz, val);
2108 if ((i % (nb/10)) == 0) {
2110 //std::cout.flush();
2115 di<<"deleting them ...\n";
2116 for (i=0; i < nb; i++) {
2118 if ((i % (nb/10)) == 0) {
2120 //std::cout.flush();
2131 static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2135 di << "Usage : " << argv[0] << " wire\n";
2138 TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
2141 TopoDS_Wire wire = TopoDS::Wire(shape);
2142 // create curve parameterised by curvilinear distance
2143 BRepAdaptor_CompCurve curve(wire,Standard_True);
2144 Standard_Real length = curve.LastParameter();
2145 Standard_Real need_length = length/2;
2147 curve.D0(need_length,pnt);
2148 // create check_curve parameterised in a general way
2149 BRepAdaptor_CompCurve check_curve(wire);
2150 Standard_Real check_par =
2151 GCPnts_AbscissaPoint(check_curve, need_length, 0).Parameter();
2153 check_curve.D0(check_par,check_pnt);
2154 // check that points are coinsiding
2155 Standard_Real error_dist = pnt.Distance(check_pnt);
2156 if (error_dist > Precision::Confusion()) {
2157 //std::cout.precision(3);
2158 di<<"error_dist = "<<error_dist<<
2159 " ( "<<error_dist/need_length*100<<" %)\n";
2166 // stack overflow can be successfully handled only on 32-bit Windows
2167 #if defined(_WIN32) && !defined(_WIN64)
2168 static int StackOverflow (int i = -1)
2171 memset (arr, 0, sizeof(arr));
2178 // this code does not work with optimize mode on Windows
2179 #if defined(_MSC_VER) && !defined(__clang__)
2180 #pragma optimize( "", off )
2182 static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2186 std::cout << "Usage : " << argv[0] << "\n";
2189 Standard_Boolean Succes;
2191 Succes = Standard_True;
2194 {//==== Test Divide ByZero (Integer) ========================================
2197 std::cout << "(Integer) Divide By Zero..." << std::endl;
2198 di << "(Integer) Divide By Zero...";
2199 //std::cout.flush();
2201 Standard_Integer res, a =4, b = 0 ;
2203 di << "Error: 4 / 0 = " << res << " - no exception is raised!\n";
2204 Succes = Standard_False;
2206 #if defined(SOLARIS) || defined(_WIN32)
2207 catch(Standard_DivideByZero const&)
2209 catch(Standard_NumericError const&)
2212 di << "Caught, OK\n";
2214 catch(Standard_Failure const& anException) {
2216 di << anException.GetMessageString();
2218 Succes = Standard_False;
2220 // this case tests if (...) supersedes (Standard_*),
2221 // the normal behaviour is not
2223 di<<" unknown exception... (But) Ok\n";
2227 {//==== Test Divide ByZero (Real) ===========================================
2230 std::cout << "(Real) Divide By Zero..." << std::endl;
2231 di << "(Real) Divide By Zero...";
2232 //std::cout.flush();
2234 Standard_Real res, a= 4.0, b=0.0;
2236 di << "Error: 4.0 / 0.0 = " << res << " - no exception is raised!\n";
2237 Succes = Standard_False;
2239 catch(Standard_DivideByZero const&) // Solaris, Windows w/o SSE2
2241 di << "Caught, OK\n";
2243 catch(Standard_NumericError const&) // Linux, Windows with SSE2
2245 di << "Caught, OK\n";
2247 catch(Standard_Failure const& anException) {
2248 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2250 di << anException.GetMessageString();
2252 Succes = Standard_False;
2256 {//==== Test Overflow (Integer) =============================================
2259 std::cout << "(Integer) Overflow..." << std::endl;
2260 di << "(Integer) Overflow...";
2261 //std::cout.flush();
2263 Standard_Integer res, i=IntegerLast();
2265 //++++ std::cout << " -- "<<res<<"="<<i<<"+1 Does not Caught... KO"<< std::endl;
2266 //++++ Succes = Standard_False;
2267 di << "Not caught: " << i << " + 1 = " << res << ", still OK\n";
2269 catch(Standard_Overflow const&) {
2270 di << "Caught, OK\n";
2272 catch(Standard_Failure const& anException) {
2273 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2275 di << anException.GetMessageString();
2277 Succes = Standard_False;
2281 {//==== Test Overflow (Real) ================================================
2284 std::cout << "(Real) Overflow..." << std::endl;
2285 di << "(Real) Overflow...";
2286 //std::cout.flush();
2288 Standard_Real res, r=RealLast();
2291 (void)sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
2293 di << "Error: " << r << "*" << r << " = " << res << " - no exception is raised!\n";
2294 Succes = Standard_False;
2296 catch(Standard_Overflow const&) // Solaris, Windows w/o SSE2
2298 di << "Caught, OK\n";
2300 catch(Standard_NumericError const&) // Linux, Windows with SSE2
2302 di << "Caught, OK\n";
2304 catch(Standard_Failure const& anException) {
2305 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2307 di << anException.GetMessageString();
2309 Succes = Standard_False;
2313 {//==== Test Underflow (Real) ===============================================
2316 std::cout << "(Real) Underflow" << std::endl; // to have message in log even if process crashed
2317 di << "(Real) Underflow";
2318 //std::cout.flush();
2320 Standard_Real res, r = RealSmall();
2323 //++++ std::cout<<"-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<<std::endl;
2324 //++++ Succes = Standard_False;
2325 di << "Not caught: " << r << "*" << r << " = " << res << ", still OK\n";
2327 catch(Standard_Underflow const&) // could be on Solaris, Windows w/o SSE2
2329 di << "Exception caught, KO\n";
2330 Succes = Standard_False;
2332 catch(Standard_NumericError const&) // could be on Linux, Windows with SSE2
2334 di << "Exception caught, KO\n";
2335 Succes = Standard_False;
2337 catch(Standard_Failure const& anException) {
2338 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2340 di << anException.GetMessageString();
2342 Succes = Standard_False;
2346 {//==== Test Invalid Operation (Real) ===============================================
2349 std::cout << "(Real) Invalid Operation..." << std::endl;
2350 di << "(Real) Invalid Operation...";
2351 //std::cout.flush();
2353 Standard_Real res, r=-1;
2355 di << "Error: swrt(-1) = " << res << " - no exception is raised!\n";
2356 Succes = Standard_False;
2358 catch(Standard_NumericError const&) {
2359 di << "Caught, OK\n";
2361 catch(Standard_Failure const& anException) {
2362 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2364 di << anException.GetMessageString();
2366 Succes = Standard_False;
2370 {//==== Test Access Violation ===============================================
2373 std::cout << "Segmentation Fault..." << std::endl;
2374 di << "Segmentation Fault...";
2375 //std::cout.flush();
2379 di << "Error: writing by NULL address - no exception is raised!\n";
2380 Succes = Standard_False;
2383 catch(OSD_Exception_ACCESS_VIOLATION const&)
2385 catch(OSD_SIGSEGV const&)
2388 di << "Caught, OK\n";
2389 } catch(Standard_Failure const& anException) {
2390 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2392 di << anException.GetMessageString();
2394 Succes = Standard_False;
2398 #if defined(_WIN32) && !defined(_WIN64)
2399 {//==== Test Stack Overflow ===============================================
2402 std::cout << "Stack Overflow..." << std::endl;
2403 di << "Stack Overflow...";
2404 //std::cout.flush();
2407 di << "Error - no exception is raised!\n";
2408 Succes = Standard_False;
2410 catch(OSD_Exception_STACK_OVERFLOW const&) {
2411 di << "Caught, OK\n";
2413 catch(Standard_Failure const& anException) {
2414 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2416 di << anException.GetMessageString();
2418 Succes = Standard_False;
2424 di << "TestExcept: Successfull completion\n";
2426 di << "TestExcept: failure\n";
2432 //! Auxiliary functor.
2433 struct TestParallelFunctor
2435 TestParallelFunctor() : myNbNotRaised (0), myNbSigSegv (0), myNbUnknown (0) {}
2437 Standard_Integer NbNotRaised() const { return myNbNotRaised; }
2438 Standard_Integer NbSigSegv() const { return myNbSigSegv; }
2439 Standard_Integer NbUnknown() const { return myNbUnknown; }
2441 void operator() (int theThreadId, int theTaskId) const
2446 // Test Access Violation
2452 Standard_Atomic_Increment (&myNbNotRaised);
2455 catch (OSD_Exception_ACCESS_VIOLATION const&)
2457 catch (OSD_SIGSEGV const&)
2460 Standard_Atomic_Increment (&myNbSigSegv);
2462 catch (Standard_Failure const& )
2464 Standard_Atomic_Increment (&myNbUnknown);
2469 mutable volatile Standard_Integer myNbNotRaised;
2470 mutable volatile Standard_Integer myNbSigSegv;
2471 mutable volatile Standard_Integer myNbUnknown;
2474 static Standard_Integer OCC30775 (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** )
2478 std::cout << "Syntax error: wrong number of arguments\n";
2482 Handle(OSD_ThreadPool) aPool = new OSD_ThreadPool (4);
2483 OSD_ThreadPool::Launcher aLauncher (*aPool, 4);
2484 TestParallelFunctor aFunctor;
2485 aLauncher.Perform (0, 100, aFunctor);
2486 theDI << "NbRaised: " << (aFunctor.NbSigSegv() + aFunctor.NbUnknown()) << "\n"
2487 << "NbNotRaised: " << aFunctor.NbNotRaised() << "\n"
2488 << "NbSigSeg: " << aFunctor.NbSigSegv() << "\n"
2489 << "NbUnknown: " << aFunctor.NbUnknown() << "\n";
2493 #if defined(_MSC_VER) && !defined(__clang__)
2494 #pragma optimize( "", on )
2497 static TopoDS_Compound AddTestStructure(int nCount_)
2503 BRepPrimAPI_MakeBox mkBox(1.0, 2.0, 3.0);
2504 for (int i=0; i<nCount; i++) {
2505 for (int j=0; j<nCount; j++) {
2507 trsf.SetTranslationPart(gp_Vec(5.0*i, 05.0*j, 0.0));
2508 TopLoc_Location topLoc(trsf);
2509 TopoDS_Shape tempShape=mkBox.Shape().Located(topLoc);
2510 B.Add(C, tempShape);
2516 static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2518 if (argc != 2 && argc != 3)
2520 std::cout << "Usage : " << argv[0] << " [nCount] path\n";
2524 int nCount = (argc > 2 ? Draw::Atoi(argv[1]) : 10);
2525 TCollection_AsciiString aFilePath (argv[argc > 2 ? 2 : 1]);
2526 STEPCAFControl_Writer writer;
2527 Handle(TDocStd_Document) document;
2528 document = new TDocStd_Document("Pace Test-StepExporter-");
2529 Handle(XCAFDoc_ShapeTool) shapeTool;
2530 shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
2531 shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
2532 STEPControl_StepModelType mode = STEPControl_AsIs;
2533 if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
2534 di << "Failed to set assembly mode for step data\n\n";
2539 if( writer.Transfer(document, mode)) {
2540 writer.Write(aFilePath.ToCString());
2543 catch(OSD_Exception_STACK_OVERFLOW const&) {
2544 di << "Failed : STACK OVERFLOW\n\n";
2546 catch (Standard_Failure const& anException) {
2547 di << "Failed :\n\n";
2548 //std::cout << Standard_Failure::Caught() << std::endl;
2549 di << anException.GetMessageString();
2551 di << argv[0] << " : Finish\n";
2556 static Standard_Integer OCC7372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2560 di << "Usage : " << argv[0] << "\n";
2564 // 1. Create an array of points
2565 Handle(TColgp_HArray1OfPnt2d) ap = new TColgp_HArray1OfPnt2d(1,5);
2566 ap->SetValue(1,gp_Pnt2d(100.0,0.0));
2567 ap->SetValue(2,gp_Pnt2d(100.0,100.0));
2568 ap->SetValue(3,gp_Pnt2d(0.0,100.0));
2569 ap->SetValue(4,gp_Pnt2d(0.0,0.0));
2570 ap->SetValue(5,gp_Pnt2d(50.0,-50.0));
2572 // 2. Create a periodic bspline through these 5 points
2573 Geom2dAPI_Interpolate intp(ap,Standard_True,1e-6);
2575 Handle(Geom2d_BSplineCurve) bspline1 = intp.Curve();
2577 // 3. Increase degree of curve from 3 to 8
2578 bspline1->IncreaseDegree(8); // Increase degree to demonstrate the error
2579 Standard_CString CString1 = "BSplineCurve";
2580 DrawTrSurf::Set(CString1,bspline1);
2582 // 4. Convers BSpline curve to Bezier segments
2583 Geom2dConvert_BSplineCurveToBezierCurve bc(bspline1);
2585 // 5. Test the result of conversion
2586 TCollection_AsciiString aRName;
2587 for(Standard_Integer i = 1; i <= bc.NbArcs(); i++) {
2588 Handle(Geom2d_BezierCurve) arc = bc.Arc(i);
2590 aRName=aRName+TCollection_AsciiString(i);
2591 Standard_CString aRNameStr = aRName.ToCString();
2592 DrawTrSurf::Set(aRNameStr,arc);
2593 di << aRNameStr << " ";
2599 static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2603 di << "Usage : " << argv[0] << " edge1 edge2 plane\n";
2606 TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
2607 if (theEdge1.IsNull()) {
2608 di << "Invalid input shape " << argv[1] << "\n";
2611 TopoDS_Edge theEdge2 = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
2612 if (theEdge2.IsNull()) {
2613 di << "Invalid input shape " << argv[2] << "\n";
2616 TopoDS_Face theFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
2617 if (theFace.IsNull()) {
2618 di << "Invalid input shape " << argv[3] << "\n";
2622 Handle(Geom_Surface) thePlane = BRep_Tool::Surface(theFace);
2624 Standard_Real aConfusion = Precision::Confusion();
2625 Standard_Real aP1first, aP1last, aP2first, aP2last;
2627 Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(theEdge1, aP1first, aP1last);
2628 Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(theEdge2, aP2first, aP2last);
2629 Handle(Geom2d_Curve) aCurve2d1 = GeomProjLib::Curve2d(aCurve1, aP1first, aP1last, thePlane);
2630 Handle(Geom2d_Curve) aCurve2d2 = GeomProjLib::Curve2d(aCurve2, aP2first, aP2last, thePlane);
2632 Geom2dAPI_InterCurveCurve anInter(aCurve2d1, aCurve2d2, aConfusion);
2634 Standard_Integer NbPoints = anInter.NbPoints();
2636 di << "NbPoints = " << NbPoints << "\n" ;
2640 for (i=1; i<=NbPoints; i++) {
2641 gp_Pnt2d aPi = anInter.Point(i);
2642 di << "Point.X(" << i << ") = " << aPi.X() << " Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
2646 Standard_Integer NbSegments = anInter.NbSegments();
2648 di << "\nNbSegments = " << NbSegments << "\n" ;
2650 if (NbSegments > 0) {
2651 IntRes2d_IntersectionSegment aSegment = anInter.Intersector().Segment(1);
2653 gp_Pnt2d aP1 = aCurve2d1->Value(aSegment.FirstPoint().ParamOnFirst());
2654 gp_Pnt2d aP2 = aCurve2d2->Value(aSegment.FirstPoint().ParamOnSecond());
2656 Standard_Real aDist = aP1.Distance(aP2);
2658 di << "aP1.X() = " << aP1.X() << " aP1.Y() = " << aP1.Y() << "\n" ;
2659 di << "aP2.X() = " << aP2.X() << " aP2.Y() = " << aP2.Y() << "\n" ;
2661 di << "Distance = " << aDist << "\n" ;
2663 di << "Confusion = " << aConfusion << "\n" ;
2665 if (aDist > aConfusion) {
2666 di << "\n" << argv[0] << " Faulty\n" ;
2668 di << "\n" << argv[0] << " OK\n" ;
2671 di << "\n" << argv[0] << " OK\n" ;
2676 static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2680 di << "Usage : " << argv[0] << " lower upper\n";
2684 Standard_Integer LOWER = Draw::Atoi(argv[1]);
2685 Standard_Integer UPPER = Draw::Atoi(argv[2]);
2687 //! 0. Create an empty document with several test labels
2688 Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
2689 doc->SetUndoLimit(100);
2690 TDF_Label main_label = doc->Main();
2691 TDF_Label label1 = main_label.FindChild(1, Standard_True);
2692 TDF_Label label2 = main_label.FindChild(2, Standard_True);
2694 //! 1. Set/Get OCAF attribute
2696 TDataStd_RealArray::Set(label1, LOWER, UPPER);
2697 Handle(TDataStd_RealArray) array;
2698 if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) &&
2699 array->Lower() == LOWER && array->Upper() == UPPER)
2700 std::cout<<"1: OK"<<std::endl;
2703 std::cout<<"1: Failed.."<<std::endl;
2706 doc->CommitCommand();
2708 //! 2. Set/Get value
2711 for (i = LOWER; i <= UPPER; i++)
2712 array->SetValue(i, i);
2713 for (i = LOWER; i <= UPPER; i++)
2715 if (array->Value(i) != i)
2717 std::cout<<"2: Failed.."<<std::endl;
2721 std::cout<<"2: OK"<<std::endl;
2722 doc->CommitCommand();
2724 //! 3. Re-init the array
2726 array->Init(LOWER + 2, UPPER + 4);
2727 if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4)
2729 std::cout<<"3: Failed.."<<std::endl;
2732 for (i = LOWER + 2; i <= UPPER + 4; i++)
2733 array->SetValue(i, i);
2734 for (i = LOWER + 2; i <= UPPER + 4; i++)
2736 if (array->Value(i) != i)
2738 std::cout<<"3: Failed.."<<std::endl;
2742 std::cout<<"3: OK"<<std::endl;
2743 doc->CommitCommand();
2747 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(LOWER + 5, UPPER + 5);
2748 for (i = LOWER + 5; i <= UPPER + 5; i++)
2749 arr->SetValue(i, i);
2750 array->ChangeArray(arr);
2751 for (i = LOWER + 5; i <= UPPER + 5; i++)
2753 if (array->Value(i) != i)
2755 std::cout<<"4: Failed.."<<std::endl;
2759 std::cout<<"4: OK"<<std::endl;
2760 doc->CommitCommand();
2762 //! 5. Copy the array
2764 TDF_CopyLabel copier(label1, label2);
2766 if (!copier.IsDone())
2768 std::cout<<"5: Failed.."<<std::endl;
2771 Handle(TDataStd_RealArray) array2;
2772 if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2774 std::cout<<"5: Failed.."<<std::endl;
2777 for (i = LOWER + 5; i <= UPPER + 5; i++)
2779 if (array->Value(i) != i)
2781 std::cout<<"5: Failed.."<<std::endl;
2785 std::cout<<"5: OK"<<std::endl;
2786 doc->CommitCommand();
2789 //! 6.a: undoes the 5th action: the copied array should disappear
2791 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2792 label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2794 std::cout<<"6.a: Failed.."<<std::endl;
2797 //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4)
2799 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2800 array->Lower() != LOWER + 2 ||
2801 array->Upper() != UPPER + 4)
2803 std::cout<<"6.b: Failed.."<<std::endl;
2806 for (i = LOWER + 2; i <= UPPER + 4; i++)
2808 if (array->Value(i) != i)
2810 std::cout<<"6.b: Failed.."<<std::endl;
2814 //! 6.c: undoes the 3d action: the array should be changed to (lower,upper)
2816 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2817 array->Lower() != LOWER ||
2818 array->Upper() != UPPER)
2820 std::cout<<"6.c: Failed.."<<std::endl;
2823 for (i = LOWER; i <= UPPER; i++)
2825 if (array->Value(i) != i)
2827 std::cout<<"6.c: Failed.."<<std::endl;
2831 //! 6.d: undoes and redoes the 2nd action: no change is expected.
2834 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2835 array->Lower() != LOWER ||
2836 array->Upper() != UPPER)
2838 std::cout<<"6.d: Failed.."<<std::endl;
2841 for (i = LOWER; i <= UPPER; i++)
2843 if (array->Value(i) != i)
2845 std::cout<<"6.d: Failed.."<<std::endl;
2849 std::cout<<"6: OK"<<std::endl;
2851 //! 7. Re-set the array
2853 array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1);
2854 if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1)
2856 std::cout<<"7: Failed.."<<std::endl;
2859 for (i = LOWER + 1; i <= UPPER + 1; i++)
2860 array->SetValue(i, i);
2861 for (i = LOWER + 1; i <= UPPER + 1; i++)
2863 if (array->Value(i) != i)
2865 std::cout<<"7: Failed.."<<std::endl;
2869 std::cout<<"7: OK"<<std::endl;
2870 doc->CommitCommand();
2872 //! 8.Test of speed: set LOWER and UPPER equal to great integer number and
2873 //! measure the time spent by this test.
2879 static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2881 Standard_Boolean IsEvenArgc = Standard_True;
2882 if (argc % 2 == 0) {
2883 IsEvenArgc = Standard_True;
2885 IsEvenArgc = Standard_False;
2888 if (argc < 3 || IsEvenArgc)
2890 di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]\n";
2894 Standard_Integer i, aValue, aPosition;
2895 NCollection_Vector<int> vec;
2896 for (i = 0; i < argc - 1; i++) {
2898 aValue = Draw::Atoi(argv[i]);
2899 aPosition = Draw::Atoi(argv[i+1]);
2900 vec.SetValue(aValue, aPosition);
2902 NCollection_Vector<int>::Iterator it(vec);
2904 for (j = 0; it.More(); it.Next(), j++) {
2905 //di << it.Value() << "\n";
2906 di << j << " " << it.Value() << "\n";
2912 static Standard_Integer OCC8797 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2915 di << "Usage : " << argv[0] << "\n";
2919 gp_Pnt point(0.0,0.0,0.0);
2921 TColgp_Array1OfPnt poles(0,6);
2924 point.SetCoord(1.0,1.0,0.0);
2927 point.SetCoord(2.0,1.0,0.0);
2930 point.SetCoord(3.0,0.0,0.0);
2933 point.SetCoord(4.0,1.0,0.0);
2936 point.SetCoord(5.0,1.0,0.0);
2939 point.SetCoord(6.0,0.0,0.0);
2942 TColStd_Array1OfReal knots(0,2);
2947 TColStd_Array1OfInteger multi(0,2);
2952 Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles,knots,multi,3);
2955 Standard_Real l_abcissa,l_gprop;
2956 GeomAdaptor_Curve adaptor_spline(spline);
2957 GCPnts_AbscissaPoint temp;
2958 l_abcissa=temp.Length(adaptor_spline);
2959 std::cout<<"Length Spline(abcissa_Pnt): "<<l_abcissa<<std::endl;
2962 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge (spline);
2964 BRepGProp::LinearProperties(edge,prop);
2965 l_gprop=prop.Mass();
2966 std::cout<<"Length Spline(GProp_GProps): "<<l_gprop<<std::endl;
2968 std::cout<<"Difference (abcissa_Pnt<->GProp_GProps): "<<l_gprop-l_abcissa<<std::endl;
2973 static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2977 di << "Usage : " << argv[0] << "\n";
2981 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2982 if(AISContext.IsNull())
2984 di << "use 'vinit' command before " << argv[0] << "\n";
2989 AIS_ListOfInteractive ListOfIO_1;
2990 AISContext->ObjectsInside(ListOfIO_1);
2991 di<< "ObjectsInside = " << ListOfIO_1.Extent() <<"\n";
2992 if (!ListOfIO_1.IsEmpty() ) {
2993 AIS_ListIteratorOfListOfInteractive iter;
2994 for (iter.Initialize(ListOfIO_1); iter.More() ; iter.Next() ) {
2995 Handle(AIS_InteractiveObject) aIO=iter.Value();
2996 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3003 static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3005 if ((argc < 9) || (((argc-3) % 3) != 0))
3007 di << "Usage : " << argv[0] << "polygon lastedge x1 y1 z1 x2 y2 z2 ...\n";
3010 Standard_Integer i, j, np = (argc-3) / 3;
3011 BRepBuilderAPI_MakePolygon W;
3013 for (i = 1; i <= np; i ++) {
3014 W.Add(gp_Pnt(Draw::Atof(argv[j]),Draw::Atof(argv[j+1]),Draw::Atof(argv[j+2])));
3018 DBRep::Set(argv[1],W.Wire());
3019 DBRep::Set(argv[2],W.Edge());
3023 static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3026 di << "Usage : " << argv[0] << " ratio origin_x origin_y origin_z\n";
3029 gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
3030 gp_Dir(1., -1., 0.));
3032 aTrf.SetAffinity (aPln, Draw::Atof(argv[4]));
3033 gp_XYZ aOrigin (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3034 gp_XYZ aResult (aOrigin);
3035 aTrf.Transforms(aResult);
3037 Sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
3038 aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
3039 aResult.X(), aResult.Y(), aResult.Z());
3044 Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3047 di << "Usage : " << argv[0] << " shape [deflection]\n";
3051 TopoDS_Shape aShape = DBRep::Get(argv[1]);
3053 if (aShape.IsNull()) {
3054 di<<" Null shape is not allowed";
3058 Standard_Real aDeflection = 0.45110277533;
3060 aDeflection = Draw::Atof(argv[2]);
3062 di<<"deflection="<< aDeflection << "\n";
3064 BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI / 9.);
3065 TopLoc_Location aLocation;
3066 Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
3068 if(aTriang.IsNull()) {
3069 di << argv[0] << " : Faulty\n" ;
3071 di << argv[0] << " : OK\n" ;
3072 di<<"NbNodes="<< aTriang->NbNodes()<< "\n";
3073 di<<"NbTriangles="<< aTriang->NbTriangles()<< "\n";
3078 static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3081 di << "Usage : " << argv[0] << " A B C\n";
3086 gp_Lin2d aLin2d (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3087 gp_Pnt2d anOrigin = aLin2d.Location();
3088 di << "X_0 = " << anOrigin.X() << " Y_0 = " << anOrigin.Y() << "\n" ;
3090 catch(Standard_ConstructionError const&)
3092 di << argv[0] << " Exception: Sqrt(A*A + B*B) <= Resolution from gp\n";
3097 static Standard_Integer OCC15755 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3100 di << "Usage : " << argv[0] << " file shape\n";
3104 IGESControl_Reader aReader;
3105 aReader.ReadFile(argv[1]);
3106 aReader.SetReadVisible(Standard_True);
3107 aReader.TransferRoots();
3109 Handle(IGESData_IGESModel) model = aReader.IGESModel();
3110 if (model.IsNull()) {
3111 di << "model.IsNull()\n";
3114 Standard_Integer nb = model->NbEntities();
3115 for (Standard_Integer i = 1; i <= nb; i ++) {
3116 Handle(IGESData_IGESEntity) ent = model->Entity(i);
3117 Handle(TCollection_HAsciiString) name;
3118 name = ent->NameValue();
3119 Standard_CString aStr = name->ToCString();
3120 di << "NameValue = " << aStr << "\n";
3123 TopoDS_Shape shape = aReader.OneShape();
3124 DBRep::Set(argv[2],shape);
3128 // For OCC16782 testing
3129 #include <AppStd_Application.hxx>
3130 #include <TDF_Tool.hxx>
3131 #include <TColStd_HArray1OfInteger.hxx>
3133 #include <TColStd_ListIteratorOfListOfInteger.hxx>
3134 #include <TColStd_ListIteratorOfListOfReal.hxx>
3135 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
3136 #include <TDataStd_ListIteratorOfListOfByte.hxx>
3137 #include <TDF_ListIteratorOfLabelList.hxx>
3139 #include <TDataStd_Tick.hxx>
3140 #include <TDataStd_IntegerList.hxx>
3141 #include <TDataStd_RealList.hxx>
3142 #include <TDataStd_ExtStringList.hxx>
3143 #include <TDataStd_BooleanList.hxx>
3144 #include <TDataStd_ReferenceList.hxx>
3145 #include <TDataStd_BooleanArray.hxx>
3146 #include <TDataStd_ReferenceArray.hxx>
3147 #include <TDataStd_ByteArray.hxx>
3148 #include <TDataStd_NamedData.hxx>
3149 #include <TDF_Reference.hxx>
3151 Handle(AppStd_Application) app;
3152 int TestSetGet(const Handle(TDocStd_Document)& doc)
3156 TDataStd_Tick::Set(doc->Main());
3158 Handle(TDataStd_Tick) tick;
3159 if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick))
3162 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3163 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3165 doc->Main().ResumeAttribute(tick);
3166 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3169 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3170 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3173 // TDataStd_IntegerList:
3175 Handle(TDataStd_IntegerList) setintlist = TDataStd_IntegerList::Set(doc->Main());
3176 setintlist->Append(2);
3177 setintlist->Prepend(1);
3178 setintlist->InsertAfter(3, 2);
3179 setintlist->InsertBefore(0, 1);
3180 setintlist->Append(200);
3181 setintlist->Remove(0);
3182 setintlist->Remove(200);
3184 Handle(TDataStd_IntegerList) getintlist;
3185 if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist))
3187 if (getintlist->First() != 1)
3189 if (getintlist->Last() != 3)
3191 const TColStd_ListOfInteger& intlist = getintlist->List();
3192 TColStd_ListIteratorOfListOfInteger itr_intlist(intlist);
3193 for (; itr_intlist.More(); itr_intlist.Next())
3195 if (itr_intlist.Value() != 1 &&
3196 itr_intlist.Value() != 2 &&
3197 itr_intlist.Value() != 3)
3202 getintlist->Clear();
3204 // TDataStd_RealList:
3206 Handle(TDataStd_RealList) setdbllist = TDataStd_RealList::Set(doc->Main());
3207 setdbllist->Append(2.5);
3208 setdbllist->Prepend(1.5);
3209 setdbllist->InsertAfter(3.5, 2.5);
3210 setdbllist->InsertBefore(0.5, 1.5);
3211 setdbllist->Append(200.5);
3212 setdbllist->Remove(0.5);
3213 setdbllist->Remove(200.5);
3215 Handle(TDataStd_RealList) getdbllist;
3216 if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist))
3218 if (getdbllist->First() != 1.5)
3220 if (getdbllist->Last() != 3.5)
3222 const TColStd_ListOfReal& dbllist = getdbllist->List();
3223 TColStd_ListIteratorOfListOfReal itr_dbllist(dbllist);
3224 for (; itr_dbllist.More(); itr_dbllist.Next())
3226 if (itr_dbllist.Value() != 1.5 &&
3227 itr_dbllist.Value() != 2.5 &&
3228 itr_dbllist.Value() != 3.5)
3233 getdbllist->Clear();
3235 // TDataStd_ExtStringList:
3237 Handle(TDataStd_ExtStringList) setstrlist = TDataStd_ExtStringList::Set(doc->Main());
3238 setstrlist->Append("Hello");
3239 setstrlist->Prepend("Guten Tag");
3240 setstrlist->InsertAfter("Bonjour", "Guten Tag");
3241 setstrlist->InsertBefore("Bonsoir", "Hello");
3242 setstrlist->Append("Good bye");
3243 setstrlist->Remove("Bonsoir");
3244 setstrlist->Remove("Good bye");
3246 Handle(TDataStd_ExtStringList) getstrlist;
3247 if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist))
3249 if (getstrlist->First() != "Guten Tag")
3251 if (getstrlist->Last() != "Hello")
3253 const TDataStd_ListOfExtendedString& strlist = getstrlist->List();
3254 TDataStd_ListIteratorOfListOfExtendedString itr_strlist(strlist);
3255 for (; itr_strlist.More(); itr_strlist.Next())
3257 if (itr_strlist.Value() != "Guten Tag" &&
3258 itr_strlist.Value() != "Bonjour" &&
3259 itr_strlist.Value() != "Hello")
3264 getstrlist->Clear();
3266 // TDataStd_BooleanList:
3268 Handle(TDataStd_BooleanList) setboollist = TDataStd_BooleanList::Set(doc->Main());
3269 setboollist->Append(Standard_True);
3270 setboollist->Prepend(Standard_False);
3272 Handle(TDataStd_BooleanList) getboollist;
3273 if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist))
3275 if (getboollist->First() != Standard_False)
3277 if (getboollist->Last() != Standard_True)
3279 const TDataStd_ListOfByte& boollist = getboollist->List();
3280 for (TDataStd_ListIteratorOfListOfByte itr_boollist(boollist); itr_boollist.More(); itr_boollist.Next())
3282 if (itr_boollist.Value() != 1
3283 && itr_boollist.Value() != 0)
3288 getboollist->Clear();
3290 // TDataStd_ReferenceList:
3291 TDF_Label L1 = doc->Main().FindChild(100);
3292 TDF_Label L2 = doc->Main().FindChild(101);
3293 TDF_Label L3 = doc->Main().FindChild(102);
3294 TDF_Label L4 = doc->Main().FindChild(103);
3295 TDF_Label L5 = doc->Main().FindChild(104);
3297 Handle(TDataStd_ReferenceList) setreflist = TDataStd_ReferenceList::Set(doc->Main());
3298 setreflist->Append(L1);
3299 setreflist->Prepend(L2);
3300 setreflist->InsertAfter(L3, L2);
3301 setreflist->InsertBefore(L4, L1);
3302 setreflist->Append(L5);
3303 setreflist->Remove(L4);
3304 setreflist->Remove(L5);
3306 Handle(TDataStd_ReferenceList) getreflist;
3307 if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist))
3309 if (getreflist->First() != L2)
3311 if (getreflist->Last() != L1)
3313 const TDF_LabelList& reflist = getreflist->List();
3314 TDF_ListIteratorOfLabelList itr_reflist(reflist);
3315 for (; itr_reflist.More(); itr_reflist.Next())
3317 if (itr_reflist.Value() != L1 &&
3318 itr_reflist.Value() != L2 &&
3319 itr_reflist.Value() != L3)
3324 getreflist->Clear();
3326 // TDataStd_BooleanArray:
3328 Handle(TDataStd_BooleanArray) setboolarr = TDataStd_BooleanArray::Set(doc->Main(), 12, 16);
3329 setboolarr->SetValue(12, Standard_True);
3330 setboolarr->SetValue(13, Standard_False);
3331 setboolarr->SetValue(14, Standard_False);
3332 setboolarr->SetValue(15, Standard_False);
3333 setboolarr->SetValue(16, Standard_True);
3334 setboolarr->SetValue(14, Standard_True);
3336 Handle(TDataStd_BooleanArray) getboolarr;
3337 if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr))
3339 if (getboolarr->Value(12) != Standard_True)
3341 if (getboolarr->Value(13) != Standard_False)
3343 if (getboolarr->Value(14) != Standard_True)
3345 if (getboolarr->Value(15) != Standard_False)
3347 if (getboolarr->Value(16) != Standard_True)
3350 // TDataStd_ReferenceArray:
3352 Handle(TDataStd_ReferenceArray) setrefarr = TDataStd_ReferenceArray::Set(doc->Main(), 0, 4);
3353 setrefarr->SetValue(0, L1);
3354 setrefarr->SetValue(1, L2);
3355 setrefarr->SetValue(2, L3);
3356 setrefarr->SetValue(3, L4);
3357 setrefarr->SetValue(4, L5);
3359 Handle(TDataStd_ReferenceArray) getrefarr;
3360 if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr))
3362 if (getrefarr->Value(0) != L1)
3364 if (getrefarr->Value(1) != L2)
3366 if (getrefarr->Value(2) != L3)
3368 if (getrefarr->Value(3) != L4)
3370 if (getrefarr->Value(4) != L5)
3373 // TDataStd_ByteArray:
3375 Handle(TDataStd_ByteArray) setbytearr = TDataStd_ByteArray::Set(doc->Main(), 12, 16);
3376 setbytearr->SetValue(12, 0);
3377 setbytearr->SetValue(13, 1);
3378 setbytearr->SetValue(14, 2);
3379 setbytearr->SetValue(15, 3);
3380 setbytearr->SetValue(16, 255);
3382 Handle(TDataStd_ByteArray) getbytearr;
3383 if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr))
3385 if (getbytearr->Value(12) != 0)
3387 if (getbytearr->Value(13) != 1)
3389 if (getbytearr->Value(14) != 2)
3391 if (getbytearr->Value(15) != 3)
3393 if (getbytearr->Value(16) != 255)
3396 // TDataStd_NamedData:
3398 Handle(TDataStd_NamedData) setnd = TDataStd_NamedData::Set(doc->Main());
3399 setnd->SetInteger("Integer1", 1);
3400 setnd->SetInteger("Integer2", 2);
3401 setnd->SetInteger("Integer3", 8);
3402 setnd->SetInteger("Integer3", 3);
3404 Handle(TDataStd_NamedData) getnd;
3405 if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd))
3407 if (!getnd->HasIntegers())
3409 if (!getnd->HasInteger("Integer1"))
3411 if (getnd->GetInteger("Integer2") != 2)
3413 if (getnd->GetInteger("Integer3") != 3)
3419 int TestUndoRedo(const Handle(TDocStd_Document)& doc)
3423 Handle(TDataStd_Tick) tick = TDataStd_Tick::Set(doc->Main());
3424 doc->CommitCommand();
3425 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3428 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3431 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3434 // TDataStd_IntegerList:
3436 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc->Main());
3438 intlist->Prepend(1);
3439 intlist->InsertBefore(0, 1);
3440 intlist->InsertAfter(3, 2);
3441 doc->CommitCommand();
3442 if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID()))
3445 if (!intlist->IsEmpty())
3448 if (!intlist->Extent())
3450 if (intlist->First() != 0)
3452 if (intlist->Last() != 3)
3456 // TDataStd_RealList:
3458 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc->Main());
3459 dbllist->Append(2.5);
3460 dbllist->Prepend(1.5);
3461 dbllist->InsertBefore(0.5, 1.5);
3462 dbllist->InsertAfter(3.5, 2.5);
3463 doc->CommitCommand();
3464 if (!doc->Main().IsAttribute(TDataStd_RealList::GetID()))
3467 if (!dbllist->IsEmpty())
3470 if (!dbllist->Extent())
3472 if (dbllist->First() != 0.5)
3474 if (dbllist->Last() != 3.5)
3478 // TDataStd_ExtStringList:
3480 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc->Main());
3481 strlist->Append("Hello");
3482 strlist->Prepend("Guten Tag");
3483 strlist->InsertAfter("Bonjour", "Guten Tag");
3484 strlist->InsertBefore("Bonsoir", "Hello");
3485 doc->CommitCommand();
3486 if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID()))
3489 if (!strlist->IsEmpty())
3492 if (!strlist->Extent())
3494 if (strlist->First() != "Guten Tag")
3496 if (strlist->Last() != "Hello")
3500 // TDataStd_BooleanList:
3502 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc->Main());
3503 boollist->Append(Standard_True);
3504 boollist->Prepend(Standard_False);
3505 doc->CommitCommand();
3506 if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID()))
3509 if (!boollist->IsEmpty())
3512 if (!boollist->Extent())
3514 if (boollist->First() != Standard_False)
3516 if (boollist->Last() != Standard_True)
3520 // TDataStd_ReferenceList:
3521 TDF_Label L1 = doc->Main().FindChild(100);
3522 TDF_Label L2 = doc->Main().FindChild(101);
3523 TDF_Label L3 = doc->Main().FindChild(102);
3524 TDF_Label L4 = doc->Main().FindChild(103);
3526 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc->Main());
3527 reflist->Append(L1);
3528 reflist->Prepend(L2);
3529 reflist->InsertBefore(L3, L1);
3530 reflist->InsertAfter(L4, L2);
3531 doc->CommitCommand();
3532 if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID()))
3535 if (!reflist->IsEmpty())
3538 if (!reflist->Extent())
3540 if (reflist->First() != L2)
3542 if (reflist->Last() != L1)
3546 // TDataStd_BooleanArray:
3548 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc->Main(), 23, 25);
3549 boolarr->SetValue(23, Standard_True);
3550 boolarr->SetValue(25, Standard_True);
3551 doc->CommitCommand();
3553 boolarr = TDataStd_BooleanArray::Set(doc->Main(), 230, 250);
3554 boolarr->SetValue(230, Standard_True);
3555 boolarr->SetValue(250, Standard_True);
3556 doc->CommitCommand();
3558 if (boolarr->Value(23) != Standard_True)
3560 if (boolarr->Value(24) != Standard_False)
3562 if (boolarr->Value(25) != Standard_True)
3565 if (boolarr->Value(230) != Standard_True)
3567 if (boolarr->Value(240) != Standard_False)
3569 if (boolarr->Value(250) != Standard_True)
3572 // TDataStd_ReferenceArray:
3574 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc->Main(), 5, 8);
3575 refarr->SetValue(5, L1);
3576 refarr->SetValue(6, L2);
3577 refarr->SetValue(7, L3);
3578 refarr->SetValue(8, L4);
3579 doc->CommitCommand();
3580 if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID()))
3584 if (refarr->Value(5) != L1)
3586 if (refarr->Value(6) != L2)
3588 if (refarr->Value(7) != L3)
3590 if (refarr->Value(8) != L4)
3593 // TDataStd_ByteArray:
3595 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc->Main(), 23, 25);
3596 bytearr->SetValue(23, 23);
3597 bytearr->SetValue(25, 25);
3598 doc->CommitCommand();
3600 bytearr = TDataStd_ByteArray::Set(doc->Main(), 230, 250);
3601 bytearr->SetValue(230, 230);
3602 bytearr->SetValue(250, 250);
3603 doc->CommitCommand();
3605 if (bytearr->Value(23) != 23)
3607 if (bytearr->Value(25) != 25)
3610 if (bytearr->Value(230) != 230)
3612 if (bytearr->Value(250) != 250)
3615 // TDataStd_NamedData:
3617 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(doc->Main());
3618 nd->SetByte("b14", 12);
3619 nd->SetByte("b17", 18);
3620 nd->SetByte("b14", 14);
3621 nd->SetByte("b17", 17);
3622 doc->CommitCommand();
3624 nd = TDataStd_NamedData::Set(doc->Main());
3625 nd->SetReal("r14", 14);
3626 nd->SetReal("r17", 17);
3627 nd->SetReal("r14", 14.4);
3628 nd->SetReal("r17", 17.7);
3629 doc->CommitCommand();
3631 if (nd->HasStrings())
3635 if (nd->HasReal("r17"))
3637 if (!nd->HasBytes())
3639 if (nd->GetByte("b14") != 14)
3641 if (nd->GetByte("b17") != 17)
3643 if (nd->HasByte("b18"))
3646 if (!nd->HasBytes())
3648 if (!nd->HasReals())
3650 if (nd->GetByte("b14") != 14)
3652 if (nd->GetReal("r14") != 14.4)
3654 if (nd->GetReal("r17") != 17.7)
3660 int TestCopyPaste(const Handle(TDocStd_Document)& doc)
3662 TDF_Label L1 = doc->Main().FindChild(1);
3663 TDF_Label L2 = doc->Main().FindChild(2);
3664 TDF_CopyLabel copier(L1, L2);
3667 TDataStd_Tick::Set(L1);
3669 if (!copier.IsDone())
3671 if (!L2.IsAttribute(TDataStd_Tick::GetID()))
3674 // TDataStd_IntegerList:
3675 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(L1);
3677 intlist->InsertAfter(2, 1);
3679 if (!copier.IsDone())
3683 if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3685 if (intlist->First() != 1)
3687 if (intlist->Last() != 2)
3691 // TDataStd_RealList:
3692 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(L1);
3693 dbllist->Append(1.5);
3694 dbllist->InsertAfter(2.5, 1.5);
3696 if (!copier.IsDone())
3700 if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist))
3702 if (dbllist->First() != 1.5)
3704 if (dbllist->Last() != 2.5)
3708 // TDataStd_ExtStringList:
3709 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(L1);
3710 strlist->Append("Open CASCADE");
3711 strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE");
3713 if (!copier.IsDone())
3717 if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
3719 if (strlist->First() != "Open CASCADE")
3721 if (strlist->Last() != " - is the best set of libraries!")
3725 // TDataStd_BooleanList:
3726 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(L1);
3727 boollist->Append(Standard_True);
3728 boollist->Prepend(Standard_False);
3730 if (!copier.IsDone())
3734 if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist))
3736 if (boollist->First() != Standard_False)
3738 if (boollist->Last() != Standard_True)
3742 // TDataStd_ReferenceList:
3743 TDF_Label L100 = doc->Main().FindChild(100);
3744 TDF_Label L101 = doc->Main().FindChild(101);
3745 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(L1);
3746 reflist->Append(L100);
3747 reflist->InsertAfter(L101, L100);
3749 if (!copier.IsDone())
3753 if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
3755 if (reflist->First() != L100)
3757 if (reflist->Last() != L101)
3761 // TDataStd_BooleanArray:
3762 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(L1, 4, 6);
3763 boolarr->SetValue(4, Standard_True);
3764 boolarr->SetValue(6, Standard_True);
3766 if (!copier.IsDone())
3769 if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
3771 if (boolarr->Value(4) != Standard_True)
3773 if (boolarr->Value(5) != Standard_False)
3775 if (boolarr->Value(6) != Standard_True)
3778 // TDataStd_ReferenceArray:
3779 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(L1, 3, 4);
3780 refarr->SetValue(3, L100);
3781 refarr->SetValue(4, L101);
3783 if (!copier.IsDone())
3786 if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
3788 if (refarr->Value(3) != L100)
3790 if (refarr->Value(4) != L101)
3793 // TDataStd_ByteArray:
3794 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(L1, 4, 6);
3795 bytearr->SetValue(4, 40);
3796 bytearr->SetValue(6, 60);
3798 if (!copier.IsDone())
3801 if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
3803 if (bytearr->Value(4) != 40)
3805 if (bytearr->Value(6) != 60)
3808 // TDataStd_NamedData:
3809 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(L1);
3810 nd->SetInteger("Integer1", 11);
3811 nd->SetReal("Real1", 11.1);
3812 nd->SetString("String1", "11.11111111");
3813 nd->SetByte("Byte1", 111);
3814 Handle(TColStd_HArray1OfInteger) ints_arr = new TColStd_HArray1OfInteger(4, 5);
3815 ints_arr->SetValue(4, 4);
3816 ints_arr->SetValue(5, 5);
3817 nd->SetArrayOfIntegers("Integers1", ints_arr);
3819 if (!copier.IsDone())
3822 if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd))