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>
96 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
98 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
101 static Standard_Integer OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
103 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
104 if(myAISContext.IsNull()) {
105 di << "use 'vinit' command before " << argv[0] ;
109 Handle(Geom_Axis2Placement) aTrihedronAxis = new Geom_Axis2Placement(gp::XOY());
112 trsf1.SetTranslation(gp_Vec(100, 100, 0));
113 aTrihedronAxis->Transform(trsf1);
114 Handle(AIS_Trihedron) myTrihedron = new AIS_Trihedron(aTrihedronAxis);
115 myTrihedron->SetColor(Quantity_NOC_LIGHTSTEELBLUE4);
116 myTrihedron->SetSize(100);
117 myAISContext->Display(myTrihedron, Standard_True);
119 // TopoDS_Shape shape1 = (TopoDS_Shape) BRepPrimAPI_MakeBox(50,50,50);
120 TopoDS_Shape shape1 = BRepPrimAPI_MakeBox(50,50,50).Shape();
121 Handle(AIS_Shape) AS = new AIS_Shape(shape1);
122 AS->SetDisplayMode(1);
123 Graphic3d_MaterialAspect mat(Graphic3d_NOM_PLASTIC);
124 AS->SetMaterial(mat);
125 AS->SetColor(Quantity_NOC_RED);
126 myAISContext->Display (AS, Standard_False);
129 TouchTrsf.SetTranslation(gp_Vec(20, 20, 0));
131 myAISContext->ResetLocation(AS);
132 myAISContext->SetLocation(AS , TouchTrsf) ;
133 myAISContext->Redisplay(AS, Standard_True);
138 // Remove as bad version of QAAddOrRemoveSelected from QADraw
139 //static Standard_Integer OCC129 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
142 // di<<"Usage : " << argv[0] << " shape islocal\n";
146 // Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
148 // // ViewerTest_DoubleMapOfInteractiveAndName& aMap =
149 // // ViewerTest::GetDataMapOfAIS ();
150 // ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
152 // TCollection_AsciiString aName(argv[1]);
153 // Handle(AIS_InteractiveObject) AISObj;
155 // if(aMap.IsBound2(aName)) {
156 // AISObj = aMap.Find2(aName);
157 // if(AISObj.IsNull()){
158 // di<<"No interactive object \n";
162 // Standard_Integer aNum = -1;
164 // if(Draw::Atoi(argv[2])) {
165 // aNum = anAISCtx->OpenLocalContext();
168 // if(anAISCtx->HasOpenedContext()){
169 // anAISCtx->InitSelected();
170 // anAISCtx->AddOrRemoveSelected(AISObj);
173 // anAISCtx->InitCurrent();
174 // anAISCtx->AddOrRemoveCurrentObject(AISObj);
178 // // anAISCtx->CloseLocalContext(aNum);
183 // //select this shape:
185 // di<<"Use 'vdisplay' before";
190 static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
193 di<<"Usage: OCC136\n";
197 //create some primitives:
199 Standard_Real Size=100;
200 gp_Pnt P0(0,0,0), P1(Size,Size,Size);
202 TopoDS_Solid aBox = BRepPrimAPI_MakeBox(P0,P1);
204 TopoDS_Solid aSphere = BRepPrimAPI_MakeSphere (Size*0.5);
206 gp_Ax2 anAx2(P1, gp_Dir(1,1,1));
207 TopoDS_Solid aCone = BRepPrimAPI_MakeCone(anAx2, Size*0.7, Size*0.3, Size);
209 anAx2.SetLocation(gp_Pnt(Size,0,0));
210 anAx2.SetDirection(gp_Dir(-1,-1,1));
211 TopoDS_Solid aCyl = BRepPrimAPI_MakeCylinder(anAx2, Size*0.5, Size);
213 Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
214 if(anAISCtx.IsNull()){
215 di<<"Null interactive context. Use 'vinit' at first.\n";
219 anAISCtx->EraseAll (Standard_False);
221 //load primitives to context
222 Handle(AIS_InteractiveObject) aSh1 = new AIS_Shape(aBox);
223 anAISCtx->Display (aSh1, Standard_False);
225 Handle(AIS_InteractiveObject) aSh2 = new AIS_Shape(aSphere);
226 anAISCtx->Display (aSh2, Standard_False);
228 Handle(AIS_InteractiveObject) aSh3 = new AIS_Shape(aCone);
229 anAISCtx->Display (aSh3, Standard_False);
231 Handle(AIS_InteractiveObject) aSh4 = new AIS_Shape(aCyl);
232 anAISCtx->Display (aSh4, Standard_False);
235 anAISCtx->InitSelected();
236 anAISCtx->AddOrRemoveSelected (aSh1, Standard_False);
237 anAISCtx->AddOrRemoveSelected (aSh2, Standard_False);
238 anAISCtx->AddOrRemoveSelected (aSh3, Standard_False);
239 anAISCtx->AddOrRemoveSelected (aSh4, Standard_False);
241 //remove all this objects from context
242 anAISCtx->Remove (aSh1, Standard_False);
243 anAISCtx->Remove (aSh2, Standard_False);
244 anAISCtx->Remove (aSh3, Standard_False);
245 anAISCtx->Remove (aSh4, Standard_False);
247 anAISCtx->UpdateCurrentViewer();
251 static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
253 printf("Usage: %s iges_input [name]\n",argv[0]);
256 Standard_Character *Ch = NULL;
259 Ch = new Standard_Character[strlen(argv[2])+3];
261 IGESToBRep_Reader IR;
262 IR.LoadFile (argv[1]);
265 TopoDS_Shape aTopShape = IR.OneShape();
266 TopExp_Explorer ex(aTopShape, TopAbs_EDGE);
267 Standard_Integer i=0;
268 for( ; ex.More(); ex.Next()){
269 const TopoDS_Edge &E = TopoDS::Edge(ex.Current());
270 BRepAdaptor_Curve aCurve(E);
271 GCPnts_UniformDeflection plin(aCurve, 0.1);
272 di << "Num points = " << plin.NbPoints() << "\n";
275 Sprintf(Ch,"%s_%i",argv[2],1);
282 //====================================================
284 // Following code is inserted from
285 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
286 // ( 75455 Apr 16 18:59)
288 //====================================================
291 #include <BRepTools_WireExplorer.hxx>
292 #include <BRep_Tool.hxx>
293 #include <GCPnts_UniformAbscissa.hxx>
294 #include <TopExp.hxx>
297 // usage : OCC105 shape
300 //GCPnts_UniformAbscissa returns bad end point foe first edge. Its value is
302 //Value Pnt = -338.556216693211 -394.465571897208 0
304 //Value Pnt = -307.47165394 -340.18073533 0
306 static int OCC105(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
309 di<<"Usage : OCC105 shape\n";
312 // TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get("aa.brep"));
313 TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1]));
314 Standard_Real l = 0.5; //Draw::Atof(argv[2]);
315 // Find the first vertex of the wire
316 BRepTools_WireExplorer wire_exp(myTopoDSWire);
319 TopoDS_Vertex vw1, vw2;
320 TopExp::Vertices(myTopoDSWire,vw1,vw2);
321 TopoDS_Vertex ve1, ve2;
322 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
323 TopExp::Vertices(edge,ve1,ve2);
324 if (vw1.IsSame(ve1) || vw1.IsSame(ve2))
327 // assert(vw2.IsSame(ve1) || vw2.IsSame(ve2));
331 for ( ; wire_exp.More(); wire_exp.Next())
333 di << "\n\n New Edge \n" << "\n";
334 Standard_Real newufirst, newulast;
335 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
336 Standard_Real ufirst, ulast;
337 Handle(Geom_Curve) acurve;
338 TopoDS_Vertex ve1, ve2;
339 TopExp::Vertices(edge,ve1,ve2);
340 if (ve1.IsSame(vlast))
342 acurve = BRep_Tool::Curve(edge, ufirst, ulast);
349 // assert(ve2.IsSame(vlast));
350 // assert ( wire_exp.Orientation( ) == TopAbs_REVERSED );
351 acurve = BRep_Tool::Curve( edge, ufirst, ulast );
352 newufirst = acurve->ReversedParameter( ufirst );
353 newulast = acurve->ReversedParameter( ulast );
354 acurve = acurve->Reversed( );
358 GeomAdaptor_Curve curve;
359 GCPnts_UniformAbscissa algo;
361 algo.Initialize( curve, l, newufirst, newulast );
363 di << "Not Done!!!" << "\n";
364 for (Standard_Integer Index = 1; Index<=algo.NbPoints();Index++) {
365 Standard_Real t = algo.Parameter(Index);
366 gp_Pnt pt3 = curve.Value(t);
367 di << "Parameter t = " << t << "\n";
368 di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z() << "\n";
375 #include <TColStd_SequenceOfTransient.hxx>
376 #include <GeomFill_Pipe.hxx>
377 static int pipe_OCC9 (Draw_Interpretor& di,
378 Standard_Integer n, const char ** a)
381 di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]\n";
385 TColStd_SequenceOfTransient aCurveSeq;
387 for (i=2 ; i<=4; i++) {
388 Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast( DrawTrSurf::Get(a[i]) );
390 di << a[i] << " is not a curve\n";
393 aCurveSeq.Append(aC);
396 GeomFill_Pipe aPipe(Handle(Geom_Curve)::DownCast( aCurveSeq(1) ),
397 Handle(Geom_Curve)::DownCast( aCurveSeq(2) ),
398 Handle(Geom_Curve)::DownCast( aCurveSeq(3) ),
402 aPipe.Perform(Draw::Atof (a[6]), Standard_True);
404 aPipe.Perform(Standard_True/*, Standard_True*/);
407 if (!aPipe.IsDone()) {
408 di << "GeomFill_Pipe cannot make a surface\n";
412 Handle(Geom_Surface) aSurf = aPipe.Surface();
414 DrawTrSurf::Set(a[1], aSurf);
418 //======================================================================
420 // usage : OCC125 shell
421 //======================================================================
422 #include <ShapeFix_Shell.hxx>
424 Standard_Integer OCC125(Draw_Interpretor& di ,
429 di<<" Use OCC125 shell";
433 TopoDS_Shape S = DBRep::Get(a[1]);
436 di<<" Null shape is not allowed";
442 if (aT!=TopAbs_SHELL) {
443 di<<" Shape Type must be SHELL";
447 const TopoDS_Shell& aShell = TopoDS::Shell(S);
449 Standard_Boolean isAccountMultiConex, bNonManifold, bResult;
451 isAccountMultiConex=Standard_True;
452 bNonManifold=Standard_False;
454 Handle (ShapeFix_Shell) aFix = new ShapeFix_Shell(aShell);
455 bResult=aFix->FixFaceOrientation(aShell, isAccountMultiConex, bNonManifold);
457 di<<"bResult="<<(Standard_Integer)bResult;
460 aShape=aFix->Shape();
462 TCollection_AsciiString aName(a[1]), aDef("_sh"), aRName;
465 DBRep::Set (aRName.ToCString(), aShape);
466 di<<aRName.ToCString();
471 #include <BRepLib_FindSurface.hxx>
472 #include <BRepBuilderAPI_MakeFace.hxx>
473 Standard_Integer OCC157(Draw_Interpretor& di,
476 //static Standard_Integer findplanarsurface(Draw_Interpretor&, Standard_Integer n, const char ** a)
479 di << "bad number of arguments\n";
483 // try to read a shape:
484 TopoDS_Shape inputShape=DBRep::Get(a[2]);
485 if (inputShape.IsNull() || inputShape.ShapeType() != TopAbs_WIRE) {
486 di << "Invalid input shape\n";
489 Standard_Real toler = Draw::Atof(a[3]);
490 TopoDS_Wire aWire = TopoDS::Wire(inputShape);
491 BRepLib_FindSurface FS(aWire, toler, Standard_True);
493 di<<"OCC157: OK; Planar surface is found\n";
494 Handle(Geom_Surface) aSurf = FS.Surface();
495 BRepBuilderAPI_MakeFace aMakeFace(aSurf,aWire,Standard_True);
496 if(aMakeFace.IsDone()) {
497 TopoDS_Face aFace = aMakeFace.Face();
498 DBRep::Set(a[1],aFace);
501 else di<<"OCC157: ERROR; Planar surface is not found with toler = "<<toler <<"\n";
506 // #include <MyCommandsCMD.h>
507 #include <ShapeFix_Shape.hxx>
508 #include <BRepOffset_MakeOffset.hxx>
509 #include <BRepOffsetAPI_MakeOffset.hxx>
510 #include <BRepOffset_Mode.hxx>
511 #include <GeomAbs_JoinType.hxx>
512 #include <AIS_Shape.hxx>
514 #include <BRepTools.hxx>
516 Standard_Integer OCC165(Draw_Interpretor& di ,
521 //=======================================================================
523 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv);
525 // void MyOffsets_Commands(Draw_Interpretor& theCommands)
527 // theCommands.Add("yoffset" , "yoffset" , __FILE__, YOffset, " Offset on Z Direction");
530 //=======================================================================
532 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
536 di <<"Usage : " << a[0] << " [file]\n";
541 #define _OFFSET_TELCO_
542 #ifdef _OFFSET_TELCO_
544 Standard_CString file = a[1];
546 BRep_Builder aBuilder;
547 TopoDS_Shape theShape;
548 //BRepTools::Read(theShape, Standard_CString("/dn02/users_SUN/inv/3/OCC165/2d_tr_line.brep"), aBuilder);
549 BRepTools::Read(theShape, file, aBuilder);
550 DBRep::Set("shape", theShape);
552 TopoDS_Wire theWire = TopoDS::Wire(theShape);
554 Standard_Real anOffset = 1.5;
558 Standard_Real xA = 0.0, xB = 200.0, xC = 200.0, xD = 0.0,
559 yA = 0.0, yB = 0.0, yC = 200.0, yD = 200.0,
560 zA = 0.0, zB = 0.0, zC = 0.0, zD = 0.0;
562 BRepBuilderAPI_MakePolygon theSquare;
563 TopoDS_Vertex theA = BRepBuilderAPI_MakeVertex(gp_Pnt(xA, yA, zA));
565 TopoDS_Vertex theB = BRepBuilderAPI_MakeVertex(gp_Pnt(xB, yB, zB));
567 TopoDS_Vertex theC = BRepBuilderAPI_MakeVertex(gp_Pnt(xC, yC, zC));
569 TopoDS_Vertex theD = BRepBuilderAPI_MakeVertex(gp_Pnt(xD, yD, zD));
573 TopoDS_Wire theWire = theSquare.Wire();
575 Standard_Real anOffset = 10;
578 #endif /* _OFFSET_TELCO_ */
581 TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire).Face();
582 DBRep::Set("face", theFace);
585 Standard_Real anAlt = 0.;
586 GeomAbs_JoinType theJoin = GeomAbs_Intersection;
587 //GeomAbs_Intersection; //GeomAbs_Arc;
588 BRepOffsetAPI_MakeOffset aMakeOffset(theFace, theJoin);
589 aMakeOffset.AddWire(theWire);
591 aMakeOffset.Perform(anOffset, anAlt);
593 TopoDS_Shape theOffsetShapePos = aMakeOffset.Shape();
594 DBRep::Set("offset", theOffsetShapePos);
599 #include<BRepAlgoAPI_Cut.hxx>
601 #include<BRepPrimAPI_MakeHalfSpace.hxx>
602 #include<Geom_CartesianPoint.hxx>
603 #include<AIS_Point.hxx>
605 #include <BRepBuilderAPI_MakeEdge.hxx>
606 #include <BRepBuilderAPI_MakeWire.hxx>
607 #include <BRepBuilderAPI_MakeFace.hxx>
609 static Standard_Integer OCC297 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
612 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
613 if (myAISContext.IsNull()) {
614 di << "use 'vinit' command before " << argv[0] << "\n";
618 gp_Pnt pt1_(250., 250., 0.);
619 gp_Pnt pt2_(-250., 250., 0.);
620 gp_Pnt pt3_(-250., -250., 0.);
621 gp_Pnt pt4_(250., -250., 0.);
622 BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
623 BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
624 BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
625 BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
627 BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
628 BRepBuilderAPI_MakeFace face_(wire_);
629 TopoDS_Face sh_ = face_.Face();
635 g_pnt = gp_Pnt(0, 0, -100);
637 g_pnt = gp_Pnt(0, 0, 100);
639 myAISContext->EraseAll(Standard_False);
640 Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
641 Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
642 myAISContext->Display(AISPoint, Standard_True);
644 BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
645 TopoDS_Solid sol1_ = half_.Solid();
647 DBRep::Set("Face", sol1_);
649 gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
651 Standard_Real x = 0., y = 0., z = -80.;
653 BRepPrimAPI_MakeBox box(gp_Pnt(x, y, z), gp_Pnt(x + 150, y + 200, z + 200));
655 DBRep::Set("Box", box.Shape());
661 #include<GProp_GProps.hxx>
662 #include<BRepGProp.hxx>
664 static Standard_Integer OCC305 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
669 di <<"Usage : " << argv[0] << " file\n";
672 Standard_CString file = argv[1];
674 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
675 if(myAISContext.IsNull()) {
676 di << "use 'vinit' command before " << argv[0] << "\n";
681 BRep_Builder builder;
682 //BRepTools::Read(sh, "/dn02/users_SUN/inv/3/OCC305/testc.brep", builder);
683 BRepTools::Read(sh, file, builder);
686 builder.MakeWire(wire);
688 TopoDS_Vertex vt1, vt2;
689 TopExp_Explorer wex(sh, TopAbs_EDGE);
690 for(;wex.More();wex.Next())
692 ed = TopoDS::Edge(wex.Current());
693 TopExp::Vertices(ed, vt1, vt2);
694 builder.UpdateVertex(vt1, 0.01);
695 builder.UpdateVertex(vt2, 0.01);
696 builder.UpdateEdge(ed, 0.01);
697 builder.Add(wire, ed);
701 BRepGProp::LinearProperties(ed, lprop);
702 printf("\n length = %f", lprop.Mass());
704 DBRep::Set("Wire",wire);
705 // Handle(AIS_Shape) res = new AIS_Shape( wire );
706 // aContext->SetColor( res, Quantity_NOC_RED );
707 // aContext->Display( res );
709 // BRepOffsetAPI_MakeOffset off(wire, GeomAbs_Arc);
710 // off.Perform(0.5, 0);
712 // printf("\n IsDone = %d", off.IsDone());
714 // res = new AIS_Shape( sh );
715 // aContext->SetColor( res, Quantity_NOC_GREEN );
716 // aContext->Display( res );
722 static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
725 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
726 if(myAISContext.IsNull()) {
727 di << "use 'vinit' command before " << argv[0];
731 BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
732 Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape());
733 myAISContext->SetAutoActivateSelection (Standard_False);
734 myAISContext->Display(anAISBox, 1);
736 TColStd_ListOfInteger anActivatedModes;
737 myAISContext->ActivatedModes (anAISBox, anActivatedModes);
738 if(anActivatedModes.Extent() != 1 || anActivatedModes.First() != -1 )
744 #include <TDocStd_Document.hxx>
745 #include <DDocStd.hxx>
746 #include <PCDM_StoreStatus.hxx>
747 #include <TDocStd_Application.hxx>
749 static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
752 di << "Usage: " << a[0] << " Doc\n";
756 Handle(TDocStd_Document) D;
757 if (!DDocStd::GetDocument(a[1],D)) return 1;
759 Handle(TDocStd_Application) A = DDocStd::GetApplication();
761 TCollection_ExtendedString theStatusMessage;
763 di << "this document has never been saved\n";
766 PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
767 if (theStatus != PCDM_SS_OK ) {
768 switch ( theStatus ) {
769 case PCDM_SS_DriverFailure: {
770 di << "Error saving document: Could not store , no driver found to make it\n";
773 case PCDM_SS_WriteFailure: {
774 di << "Error saving document: Write access failure\n";
777 case PCDM_SS_Failure: {
778 di << "Error saving document: Write failure\n" ;
781 case PCDM_SS_Doc_IsNull: {
782 di << "Error saving document: No document to save\n";
785 case PCDM_SS_No_Obj: {
786 di << "Error saving document: No objects written\n";
789 case PCDM_SS_Info_Section_Error: {
790 di << "Error saving document: Write info section failure\n" ;
801 static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
804 di << "Usage: " << a[0] << " Doc Path\n";
808 Handle(TDocStd_Document) D;
809 if (!DDocStd::GetDocument(a[1],D)) return 1;
811 TCollection_ExtendedString path (a[2]);
812 Handle(TDocStd_Application) A = DDocStd::GetApplication();
814 TCollection_ExtendedString theStatusMessage;
815 PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
816 if (theStatus != PCDM_SS_OK ) {
817 switch ( theStatus ) {
818 case PCDM_SS_DriverFailure: {
819 di << "Error saving document: Could not store , no driver found to make it\n";
822 case PCDM_SS_WriteFailure: {
823 di << "Error saving document: Write access failure\n";
826 case PCDM_SS_Failure: {
827 di << "Error saving document: Write failure\n" ;
830 case PCDM_SS_Doc_IsNull: {
831 di << "Error saving document: No document to save\n";
834 case PCDM_SS_No_Obj: {
835 di << "Error saving document: No objects written\n";
838 case PCDM_SS_Info_Section_Error: {
839 di << "Error saving document: Write info section failure\n" ;
851 #include <BRepClass3d_SolidClassifier.hxx>
853 Standard_Integer OCC299bug (Draw_Interpretor& theDi,
854 Standard_Integer theArgNb,
855 const char** theArgVec)
859 theDi << "Usage : " << theArgVec[0] << " Solid Point [Tolerance=1.e-7]\n";
863 TopoDS_Shape aS = DBRep::Get (theArgVec[1]);
866 theDi << " Null Shape is not allowed here\n";
869 else if (aS.ShapeType() != TopAbs_SOLID)
871 theDi << " Shape type must be SOLID\n";
875 gp_Pnt aP (8., 9., 10.);
876 if (!DrawTrSurf::GetPoint (theArgVec[2], aP))
878 theDi << " Null Point is not allowed here\n";
881 const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : 1.e-7;
883 BRepClass3d_SolidClassifier aSC (aS);
884 aSC.Perform (aP, aTol);
888 case TopAbs_IN: theDi << "The point is IN shape\n"; return 0;
889 case TopAbs_OUT: theDi << "The point is OUT of shape\n"; return 0;
890 case TopAbs_ON: theDi << "The point is ON shape\n"; return 0;
892 default: theDi << "The point is UNKNOWN shape\n"; return 0;
896 #include <OSD_Process.hxx>
897 #include <OSD_Path.hxx>
899 static Standard_Integer OCC309bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
902 di << "Usage: " << a[0] << "\n";
906 OSD_Path d = p.CurrentDirectory();
907 TCollection_AsciiString s;
909 di << "*" << s.ToCString() << "*\n";
912 di << "*" << s.ToCString() << "*\n";
916 static Standard_Integer OCC310bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
919 di << "Usage: " << a[0] << "\n";
922 OSD_Path p("/where/you/want/tmp/qwerty/tmp/");
923 di << p.Trek().ToCString() << "\n";
925 di << p.Trek().ToCString() << "\n";
929 #include <BRepAlgoAPI_Fuse.hxx>
930 #include <BRepAlgoAPI_Common.hxx>
932 static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
935 di << "Usage : " << a[0] << "\n";
939 BRepPrimAPI_MakeBox box1( 100, 100, 100 );
940 BRepPrimAPI_MakeBox box2( gp_Pnt( 50, 50,50 ), 200, 200, 200 );
942 TopoDS_Shape shape1 = box1.Shape();
943 TopoDS_Shape shape2 = box2.Shape();
945 TopoDS_Shape fuse,comm;
946 di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )\n";
947 di << "comm = BRepAlgoAPI_Common( shape1, shape2 )\n";
948 fuse = BRepAlgoAPI_Fuse(shape1, shape2).Shape();
949 comm = BRepAlgoAPI_Common(shape1, shape2).Shape();
954 #include <DDocStd_DrawDocument.hxx>
955 #include <TDataStd_Name.hxx>
957 #include <XCAFDoc_ShapeTool.hxx>
958 #include <XCAFDoc_DocumentTool.hxx>
959 #include <TDF_LabelSequence.hxx>
960 #include <TPrsStd_AISPresentation.hxx>
961 #include <TDF_Data.hxx>
962 #include <TDF_Label.hxx>
963 #include <XCAFPrs_Driver.hxx>
965 //------------------------------------------------------------------------------------------
968 //------------------------------------------------------------------------------------------
969 static Standard_Integer OCC363 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
974 // 1. Verufy amount of arguments
975 if(argc < 3) { di <<"Error OCC363 : Use : OCC363 document filename\n"; return 1; }
977 // 2. Retrieve DDocStd application
978 Handle(TDocStd_Application) App = DDocStd::GetApplication();
981 TCollection_ExtendedString name(argv[2]);
982 Handle(TDocStd_Document) Doc;
983 if(App->Open(name, Doc) != PCDM_RS_OK) { di << "Error OCC363 : document was not opened successfully\n"; return 1;}
984 Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(Doc);
985 TDataStd_Name::Set(Doc->GetData()->Root(),argv[1]);
986 Draw::Set(argv[1],DD);
988 // 4. Create prsentations
989 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
990 TDF_LabelSequence seq;
991 shapes->GetFreeShapes ( seq );
992 Handle(TPrsStd_AISPresentation) prs;
993 for ( Standard_Integer i=1; i <= seq.Length(); i++ )
994 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) )
995 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
997 catch(Standard_Failure const&) { di << "FAULTY OCC363 : Exception during reading document.\n";return 0;}
1004 ////======================================================================================
1005 //// Function : OCC372
1007 ////======================================================================================
1008 //static Standard_Integer OCC372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1012 // OCC_CATCH_SIGNALS
1013 // // 1. Verufy amount of arguments
1014 // if(argc < 2) {di << "OCC372 FAULTY. Use : OCC372 brep-file";return 0;}
1018 // TopoDS_Shape Ref;
1019 // BRepTools::Read(Ref, argv[1], B);
1021 // // 3. Calculate location of aP3d in relation to the solid
1022 // gp_Pnt aP3d(6311.4862583184, -2841.3092756034, 16.461053497188);
1023 // BRepClass3d_SolidClassifier SC(Ref);
1024 // SC.Perform(aP3d, 1e-7);
1026 // // 4. Check returned state. The point must be inside the solid.
1027 // TopAbs_State aState=SC.State();
1031 // di<<"OCC372 FAULTY. aState = TopAbs_OUT";
1034 // di<<"OCC372 FAULTY. aState = TopAbs_ON";
1037 // di<<"OCC372 OK. aState = TopAbs_IN" ;
1040 // di<<"OCC372 FAULTY. aState = UNKNOWN";
1044 // catch (Standard_Failure) { di<<"OCC372 FAULTY. Exception raised"; }
1049 #include <BRepTopAdaptor_FClass2d.hxx>
1051 //======================================================================================
1052 // Function : OCC377
1054 //======================================================================================
1055 static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1060 // 1. Verify validity of arguments
1061 if ( argc < 1 ) {di << "Error OCC377. Use OCC377 file x y precuv \n";return 0;}
1063 // 2. Initialize parameters
1065 p2d.SetX ( Draw::Atof(argv[2]) );
1066 p2d.SetY ( Draw::Atof(argv[3]) );
1067 Standard_Real precuv = Draw::Atof (argv[4] );
1072 BRepTools::Read ( Shape, argv[1], B );
1074 // 4. Verify whether enrtry point is on wire and reversed ones (indeed results of veridying must be same)
1075 TopExp_Explorer exp;
1076 Standard_Integer i=1;
1077 for (exp.Init(Shape.Oriented(TopAbs_FORWARD),TopAbs_WIRE); exp.More(); exp.Next(), i++)
1079 // 4.1. Verify whether enrtry point is on wire
1080 const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
1081 TopoDS_Face newFace = TopoDS::Face(Shape.EmptyCopied());
1083 TopAbs_Orientation orWire = wir.Orientation();
1084 newFace.Orientation(TopAbs_FORWARD);
1087 BRepTopAdaptor_FClass2d FClass2d1(newFace,precuv);
1088 TopAbs_State stat1 = FClass2d1.PerformInfinitePoint();
1089 //di << "Wire " << i << ": Infinite point is " <<
1090 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1092 TCollection_AsciiString TmpString;
1093 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1094 di << "Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1096 stat1 = FClass2d1.Perform(p2d);
1097 //di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1098 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1101 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1102 di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1104 // 4.2. Verify whether enrtry point is on reversed wire
1105 newFace = TopoDS::Face(Shape.EmptyCopied());
1106 newFace.Orientation(TopAbs_FORWARD);
1107 orWire = TopAbs::Reverse(orWire);
1108 B.Add(newFace,wir.Oriented(orWire));
1109 BRepTopAdaptor_FClass2d FClass2d2(newFace,precuv);
1110 TopAbs_State stat2 = FClass2d2.PerformInfinitePoint();
1111 //di << "Reversed Wire " << i << ": Infinite point is " <<
1112 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1115 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1116 di << "Reversed Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1118 stat2 = FClass2d2.Perform(p2d);
1119 //di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1120 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1123 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1124 di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1126 // 4.3. Compare results (they must be same)
1127 if(stat1 ==stat2) di << "OCC377 OK\n";
1128 else {di << "OCC377 FAULTY\n"; return 0;}
1131 catch(Standard_Failure const&)
1133 di << "OCC377 Exception";
1139 #include <ShapeUpgrade_ShapeDivideAngle.hxx>
1140 #include <ShapeBuild_ReShape.hxx>
1142 //=======================================================================
1145 //=======================================================================
1146 static Standard_Integer OCC22 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1151 // 1. Verify arguments of the command
1152 if (argc < 5) { di << "OCC22 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation"; return 0;}
1154 Standard_Boolean aConsiderLocation;
1155 if(strcmp(argv[4], "0")==0) aConsiderLocation = Standard_False;
1156 else aConsiderLocation = Standard_True;
1158 // 2. Iniitialize aShapeUpgrade
1159 ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(M_PI/2.);
1161 aShapeUpgrade.SetPrecision (Precision::Confusion());
1163 aShapeUpgrade.SetMaxTolerance(0.1);
1164 // subshapes to be divided
1165 TopoDS_Shape aSubShapesToBeDivided = DBRep::Get(argv[3]);
1166 if(aSubShapesToBeDivided.IsNull()) {di << "OCC22 FAULTY. Compound of subshapes to be divided is not exist. Please, verify input values. \n";return 0;}
1167 aShapeUpgrade.Init(aSubShapesToBeDivided);
1169 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1170 aShapeUpgrade.SetContext(aReshape);
1171 if(aConsiderLocation) aReshape->ModeConsiderLocation() = Standard_True;
1173 // 3. Perform splitting
1174 if (aShapeUpgrade.Perform (Standard_False)) di << "Upgrade_SplitRevolution_Done \n";
1175 else if (aShapeUpgrade.Status (ShapeExtend_OK)) di << "Upgrade_SplitRevolution_OK \n";
1176 else if (aShapeUpgrade.Status (ShapeExtend_FAIL)) { di << "OCC22 FAULTY. Operation failed. Angle was not divided\n";return 0;}
1178 // 4. Perform rebuilding shape
1179 // 4.1. Retrieve Shape
1180 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1181 if(anInitShape.IsNull()) { di << "OCC22 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1182 // 4.2 Rebuid retrieved shape
1183 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1184 // 4.3. Create result Draw shape
1185 DBRep::Set(argv[1], aResultShape);
1187 catch (Standard_Failure const&) {di << "OCC22 Exception \n" ;return 0;}
1193 #include <ShapeProcess_OperLibrary.hxx>
1194 #include <ShapeProcess_ShapeContext.hxx>
1195 #include <ShapeProcess.hxx>
1197 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
1198 #include <BRepMesh_IncrementalMesh.hxx>
1199 #include <IMeshTools_Parameters.hxx>
1201 //=======================================================================
1204 //=======================================================================
1205 static Standard_Integer OCC24 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1210 // 1. Verify amount of arguments of the command
1211 if (argc < 6) { di << "OCC24 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapes ResourceFileName SequenceName"; return 0;}
1213 // 2. Retrieve parameters
1215 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1216 if(anInitShape.IsNull()) { di << "OCC24 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1217 // compound of subshapes
1218 TopoDS_Shape aSubShapes = DBRep::Get(argv[3]);
1219 if(aSubShapes.IsNull()) {di << "OCC24 FAULTY. Compound of subshapes is not exist. Please, verify input values. \n";return 0;}
1220 // name of resource file
1221 const char* aResourceFile = argv[4];
1222 // name of sequence from resource file to be executed
1223 const char* aSequenceName = argv[5];
1225 // 3. Initialize ShapeContext and perform sequence of operation specified with resource file
1226 ShapeProcess_OperLibrary::Init();
1227 Handle(ShapeProcess_ShapeContext) aShapeContext = new ShapeProcess_ShapeContext (aSubShapes, aResourceFile);
1228 aShapeContext->SetDetalisation (TopAbs_EDGE);
1229 ShapeProcess::Perform (aShapeContext, aSequenceName);
1231 // 4. Rebuild initil shape in accordance with performed operation
1232 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1233 TopTools_DataMapIteratorOfDataMapOfShapeShape anIter (aShapeContext->Map());
1234 for (; anIter.More(); anIter.Next())
1235 aReshape->Replace(anIter.Key(), anIter.Value());
1236 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1238 // 5 Create resultant Draw shape
1239 DBRep::Set(argv[1], aResultShape);
1242 catch (Standard_Failure const&) {di << "OCC24 Exception \n" ;return 0;}
1247 //=======================================================================
1249 //purpose : Verify whether exception occurs during building mesh
1250 //=======================================================================
1251 static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1256 // 1. Verify amount of arguments of the command
1257 if (argc < 2) { di << "OCC369 FAULTY. Use : OCC369 Shape \n"; return 0;}
1259 // 2. Retrieve shape
1260 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1261 if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
1264 IMeshTools_Parameters aMeshParams;
1265 aMeshParams.Relative = Standard_True;
1266 aMeshParams.Deflection = 0.2;
1267 aMeshParams.Angle = M_PI / 6.0;
1268 BRepMesh_IncrementalMesh aMesh(aShape, aMeshParams);
1271 catch (Standard_Failure const&) {di << "OCC369 Exception \n" ;return 0;}
1273 di << "OCC369 OK \n";
1277 #include <math_Vector.hxx>
1278 #include <math_Matrix.hxx>
1279 static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1282 di<<"Usage : " << argv[0] << " LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix\n";
1285 Standard_Integer LowerVector = Draw::Atoi(argv[1]);
1286 Standard_Integer UpperVector = Draw::Atoi(argv[2]);
1287 Standard_Real InitialValueVector = Draw::Atof(argv[3]);
1288 Standard_Integer LowerRowMatrix = Draw::Atoi(argv[4]);
1289 Standard_Integer UpperRowMatrix = Draw::Atoi(argv[5]);
1290 Standard_Integer LowerColMatrix = Draw::Atoi(argv[6]);
1291 Standard_Integer UpperColMatrix = Draw::Atoi(argv[7]);
1292 Standard_Real InitialValueMatrix = Draw::Atof(argv[8]);
1294 math_Vector Vector1(LowerVector, UpperVector);
1295 math_Vector Vector2(LowerVector, UpperVector);
1297 math_Vector Vector(LowerVector, UpperVector, InitialValueVector);
1298 math_Matrix Matrix(LowerRowMatrix, UpperRowMatrix, LowerColMatrix, UpperColMatrix, InitialValueMatrix);
1300 //Vector.Dump(std::cout);
1301 //std::cout<<std::endl;
1303 //Matrix.Dump(std::cout);
1304 //std::cout<<std::endl;
1306 Vector1.Multiply(Vector, Matrix);
1308 //Vector1.Dump(std::cout);
1309 Standard_SStream aSStream1;
1310 Vector1.Dump(aSStream1);
1314 if (Matrix.RowNumber() > 1) {
1315 Matrix(Matrix.LowerRow() + 1, Matrix.LowerCol()) += 1.;
1317 Vector2.TMultiply(Vector, Matrix);
1319 //Vector2.Dump(std::cout);
1320 Standard_SStream aSStream2;
1321 Vector2.Dump(aSStream2);
1328 #include <GeomPlate_BuildPlateSurface.hxx>
1329 //=======================================================================
1332 //=======================================================================
1333 static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
1335 GeomPlate_BuildPlateSurface aBuilder;
1338 if (aBuilder.IsDone())
1340 di << "Error in OCC525. Null result is expected.\n";
1344 di << "OCC525 OK \n";
1350 #include <BRepPrimAPI_MakeWedge.hxx>
1351 #include <gce_MakeRotation.hxx>
1352 #include <gce_MakeTranslation.hxx>
1353 #include <BRepBuilderAPI_Transform.hxx>
1354 #include <BRepPrimAPI_MakeWedge.hxx>
1355 //=======================================================================
1358 //=======================================================================
1359 static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1362 di << "Usage : " << argv[0] << " shape1 shape2 shape3\n";
1367 double xperiod = 1.0;
1368 double yperiod = 1.0;
1369 double sub_thick = 0.5;
1372 //TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick );
1373 TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick ).Shape();
1375 // --------------------------------------------------------------------
1378 //TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1379 // 0.1, 0.1 , 0.4, 0.4 );
1380 TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1381 0.1, 0.1 , 0.4, 0.4 ).Shape();
1383 gp_Trsf rotate = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1384 gp_Dir(1.0,0.0,0.0),
1387 gp_Trsf translate = gce_MakeTranslation(gp_Pnt( 0.0, -0.5, 0.0),
1388 gp_Pnt( 0.25, 0.25, 0.5)
1391 rotate.PreMultiply( translate );
1393 TopoDS_Shape wedge1a = BRepBuilderAPI_Transform( wedge1, rotate );
1395 if (wedge1a.IsNull()) {
1396 di<<" Null shape1 is not allowed\n";
1399 DBRep::Set(argv[1], wedge1a);
1401 // --------------------------------------------------------------------
1404 //TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1405 // 0.1, 0.1 , 0.4, 0.4 );
1406 TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1407 0.1, 0.1 , 0.4, 0.4 ).Shape();
1409 gp_Trsf rotate2 = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1410 gp_Dir(1.0,0.0,0.0),
1413 gp_Trsf translate2 = gce_MakeTranslation(gp_Pnt( 0.0, 0.0, 0.0),
1414 gp_Pnt( 0.25, 0.25, 0.5)
1417 rotate2.PreMultiply( translate2 );
1419 TopoDS_Shape wedge2a = BRepBuilderAPI_Transform( wedge2, rotate2 );
1421 if (wedge2a.IsNull()) {
1422 di<<" Null shape2 is not allowed\n";
1425 DBRep::Set(argv[2], wedge2a);
1429 di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)\n";
1430 TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a).Shape();
1432 di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)\n";
1433 TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common).Shape();
1435 if (sub_etch1.IsNull()) {
1436 di<<" Null shape3 is not allowed\n";
1439 DBRep::Set(argv[3], sub_etch1);
1444 #include <Standard_GUID.hxx>
1445 //=======================================================================
1448 //=======================================================================
1449 static Standard_Integer OCC669 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1452 di<<"Usage : " << argv[0] << " GUID\n";
1455 Standard_GUID guid(argv[1]);
1456 //guid.ShallowDump(std::cout);
1457 Standard_SStream aSStream;
1458 guid.ShallowDump(aSStream);
1464 #include <XCAFDoc.hxx>
1465 //=======================================================================
1466 //function : OCC738_ShapeRef
1468 //=======================================================================
1469 static Standard_Integer OCC738_ShapeRef (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1472 di<<"Usage : " << argv[0] << "\n";
1475 const Standard_GUID& guid = XCAFDoc::ShapeRefGUID ();
1476 //guid.ShallowDump(std::cout);
1477 Standard_SStream aSStream;
1478 guid.ShallowDump(aSStream);
1483 //=======================================================================
1484 //function : OCC738_Assembly
1486 //=======================================================================
1487 static Standard_Integer OCC738_Assembly (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1490 di<<"Usage : " << argv[0] << "\n";
1493 const Standard_GUID& guid = XCAFDoc::AssemblyGUID ();
1494 //guid.ShallowDump(std::cout);
1495 Standard_SStream aSStream;
1496 guid.ShallowDump(aSStream);
1501 #if defined(DDataStd_def01)
1502 #include <DDataStd_DrawPresentation.hxx>
1503 //=======================================================================
1504 //function : OCC739_DrawPresentation
1506 //=======================================================================
1507 static Standard_Integer OCC739_DrawPresentation (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1510 di<<"Usage : " << argv[0] << "\n";
1513 const Standard_GUID& guid = DDataStd_DrawPresentation::GetID() ;
1514 //guid.ShallowDump(std::cout);
1515 Standard_SStream aSStream;
1516 guid.ShallowDump(aSStream);
1522 //=======================================================================
1525 //=======================================================================
1526 static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1528 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1529 if(aContext.IsNull()) {
1530 di << argv[0] << "ERROR : use 'vinit' command before \n";
1535 di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation\n";
1539 Standard_Boolean updateviewer = Standard_True;
1541 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1543 TCollection_AsciiString aName(argv[1]);
1544 Handle(AIS_InteractiveObject) AISObj;
1546 if (!aMap.Find2 (aName, AISObj)
1549 di << "Use 'vdisplay' before\n";
1553 AISObj->ResetTransformation();
1555 aContext->Erase(AISObj, updateviewer);
1556 aContext->UpdateCurrentViewer();
1557 aContext->Display(AISObj, updateviewer);
1558 aContext->UpdateCurrentViewer();
1562 //=======================================================================
1565 //=======================================================================
1566 #include <TColStd_Array2OfInteger.hxx>
1567 static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1570 di<<"Usage : " << argv[0] << "\n";
1574 // check that exception initialized without message string can be safely handled and printed
1576 throw Standard_OutOfRange();
1578 catch (Standard_Failure const& anException) {
1579 std::cout << "Caught successfully: ";
1580 std::cout << anException << std::endl;
1585 #include <GeomAPI_ProjectPointOnSurf.hxx>
1586 //=======================================================================
1589 //=======================================================================
1590 static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1594 di<<"Usage : " << argv[0] << " Point Surface Umin Usup Vmin Vsup \n";
1599 DrawTrSurf::GetPoint(argv[1],aPoint3d);
1600 Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
1601 Standard_Real Umin=Draw::Atof(argv[3]);
1602 Standard_Real Usup=Draw::Atof(argv[4]);
1603 Standard_Real Vmin=Draw::Atof(argv[5]);
1604 Standard_Real Vsup=Draw::Atof(argv[6]);
1606 if (aSurface.IsNull()) {
1607 di << argv[2] << " Null surface \n" ;
1611 GeomAPI_ProjectPointOnSurf PonSurf;
1612 PonSurf.Init(aSurface, Umin, Usup, Vmin, Vsup);
1613 PonSurf.Perform(aPoint3d);
1618 //=======================================================================
1621 //=======================================================================
1622 static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1626 di<<"Usage : " << argv[0] << " wire face\n";
1630 TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
1631 TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
1632 if (awire.IsNull() || aface.IsNull()) {
1633 di << "Null object\n";
1637 Standard_Integer count = 0;
1638 TopExp_Explorer TE(awire, TopAbs_VERTEX);
1640 BRepTools_WireExplorer WE;
1641 for ( WE.Init(awire,aface); WE.More(); WE.Next()) {
1642 TopoDS_Edge E = WE.Current();
1646 di << "Count = " << count << "\n";
1651 //=======================================================================
1654 //=======================================================================
1655 static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1659 di <<"Usage : " << argv[0] << " face\n";
1662 Standard_Real u1, u2, v1, v2;
1663 TopoDS_Face F = TopoDS::Face( DBRep::Get(argv[1]) ); //read the shape
1666 BRepTools::UVBounds(F, u1, u2, v1, v2);
1667 di << "Bounds: " << u1 << " " << u2 << " " << v1 << " " << v2 << "\n";
1671 #include <Expr_NamedUnknown.hxx>
1672 #include <Expr_GeneralExpression.hxx>
1673 #include <Expr_Exponential.hxx>
1674 //=======================================================================
1677 //=======================================================================
1678 static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1682 di <<"Usage : " << argv[0] << " expression\n";
1686 TCollection_AsciiString myStr(argv[1]);
1688 Handle (Expr_NamedUnknown) myNamed = new Expr_NamedUnknown(myStr);
1689 Handle (Expr_Exponential) oldExpr = new Expr_Exponential(myNamed);
1690 Handle (Expr_GeneralExpression) newExpr = oldExpr->Derivative(myNamed);
1693 TCollection_AsciiString res = newExpr->String();
1694 Standard_CString resStr = res.ToCString();
1695 TCollection_AsciiString res_old = oldExpr->String();
1696 Standard_CString res_oldStr = res_old.ToCString();
1699 di << "X = " << argv[1] << "\n";
1700 di << "Y = " << res_oldStr << "\n";
1701 di << "Y' = " << resStr << "\n";
1707 #include <TPrsStd_AISViewer.hxx>
1708 #include <TDF_Label.hxx>
1709 #include <TPrsStd_AISPresentation.hxx>
1710 //=======================================================================
1711 //function : OCC1029_AISTransparency
1712 //purpose : OCC1029_AISTransparency (DOC,entry,[real])
1713 //=======================================================================
1715 static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
1716 Standard_Integer nb,
1720 Handle(TDocStd_Document) D;
1721 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1723 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1725 Handle(TPrsStd_AISViewer) viewer;
1726 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1728 Handle(TPrsStd_AISPresentation) prs;
1729 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1731 prs->SetTransparency(Draw::Atof(arg[3]));
1732 TPrsStd_AISViewer::Update(L);
1735 di << "Transparency = " << prs->Transparency() << "\n";
1740 di << arg[0] << " : Error\n";
1744 //=======================================================================
1745 //function : OCC1031_AISMaterial
1746 //purpose : OCC1031_AISMaterial (DOC,entry,[material])
1747 //=======================================================================
1749 static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
1750 Standard_Integer nb,
1754 Handle(TDocStd_Document) D;
1755 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1757 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1759 Handle(TPrsStd_AISViewer) viewer;
1760 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1762 Handle(TPrsStd_AISPresentation) prs;
1763 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1765 prs->SetMaterial((Graphic3d_NameOfMaterial)Draw::Atoi(arg[3]));
1766 TPrsStd_AISViewer::Update(L);
1769 di << "Material = " << prs->Material() << "\n";
1774 di << arg[0] << " : Error\n";
1778 //=======================================================================
1779 //function : OCC1032_AISWidth
1780 //purpose : OCC1032_AISWidth (DOC,entry,[width])
1781 //=======================================================================
1783 static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
1784 Standard_Integer nb,
1788 Handle(TDocStd_Document) D;
1789 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1791 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1793 Handle(TPrsStd_AISViewer) viewer;
1794 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1796 Handle(TPrsStd_AISPresentation) prs;
1797 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1799 prs->SetWidth(Draw::Atof(arg[3]));
1800 TPrsStd_AISViewer::Update(L);
1803 di << "Width = " << prs->Width() << "\n";
1808 di << arg[0] << " : Error\n";
1812 //=======================================================================
1813 //function : OCC1033_AISMode
1814 //purpose : OCC1033_AISMode (DOC,entry,[mode])
1815 //=======================================================================
1817 static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
1818 Standard_Integer nb,
1822 Handle(TDocStd_Document) D;
1823 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1825 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1827 Handle(TPrsStd_AISViewer) viewer;
1828 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1830 Handle(TPrsStd_AISPresentation) prs;
1831 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1833 prs->SetMode(Draw::Atoi(arg[3]));
1834 TPrsStd_AISViewer::Update(L);
1837 di << "Mode = " << prs->Mode() << "\n";
1842 di << arg[0] << " : Error\n";
1846 //=======================================================================
1847 //function : OCC1034_AISSelectionMode
1848 //purpose : OCC1034_AISSelectionMode (DOC,entry,[selectionmode])
1849 //=======================================================================
1851 static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
1852 Standard_Integer nb,
1856 Handle(TDocStd_Document) D;
1857 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1859 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1861 Handle(TPrsStd_AISViewer) viewer;
1862 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1864 Handle(TPrsStd_AISPresentation) prs;
1865 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1867 prs->SetSelectionMode(Draw::Atoi(arg[3]));
1868 TPrsStd_AISViewer::Update(L);
1871 di << "SelectionMode = " << prs->SelectionMode() << "\n";
1876 di << arg[0] << " : Error\n";
1880 //=======================================================================
1881 //function : OCC1487
1883 //=======================================================================
1884 static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1887 di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape\n";
1891 Standard_Integer CaseNumber = Draw::Atoi(argv[1]);
1893 //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
1894 gp_Dir myDir(1,0,0);
1895 gp_Pnt myPnt(0,-50,140);
1896 gp_Ax2 myAx2(myPnt, myDir);
1897 BRepPrimAPI_MakeCylinder o_mc1 (myAx2, 50,1000);
1899 TopoDS_Shape cyl1 = o_mc1.Shape();
1902 TopoDS_Shape o_cut_shape;
1903 if (CaseNumber == 1) {
1904 //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);
1905 gp_Dir myDir_mc2(-sin(M_PI/3), 0.0, 0.5);
1906 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
1907 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
1908 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
1910 cyl2 = o_mc2.Shape();
1911 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
1912 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ()).Shape();
1914 //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);
1915 gp_Dir myDir_mc2(sin(M_PI/3), 0.0, 0.5);
1916 gp_Pnt myPnt_mc2(978.34936, -50.0, 127.5);
1917 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
1918 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
1920 cyl2 = o_mc2.Shape();
1921 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
1922 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ()).Shape();
1925 DBRep::Set(argv[2],cyl1);
1926 DBRep::Set(argv[3],cyl2);
1927 DBRep::Set(argv[4],o_cut_shape);
1932 #include<TopTools_ListIteratorOfListOfShape.hxx>
1933 #include<BRepFilletAPI_MakeFillet.hxx>
1934 //=======================================================================
1935 //function : OCC1077
1937 //=======================================================================
1938 TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
1940 Standard_Real t3d = 1.e-4;
1941 Standard_Real t2d = 1.e-5;
1942 Standard_Real ta = 1.e-2;
1943 Standard_Real fl = 1.e-3;
1944 Standard_Real tapp_angle = 1.e-2;
1945 GeomAbs_Shape blend_cont = GeomAbs_C1;
1947 TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
1949 TopTools_ListIteratorOfListOfShape its;
1951 TopoDS_Compound result;
1953 B.MakeCompound(result);
1956 for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
1958 const TopoDS_Shape& cutsol = ex.Current();
1960 BRepFilletAPI_MakeFillet fill(cutsol);
1961 fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
1962 fill.SetContinuity(blend_cont, tapp_angle);
1963 its = aBoolenaOperation.SectionEdges();
1966 TopoDS_Edge E = TopoDS::Edge(its.Value());
1967 fill.Add(aRadius, E);
1974 B.Add(result, fill.Shape());
1978 B.Add(result, cutsol);
1984 TopoDS_Shape OCC1077_cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
1986 //return OCC1077_boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
1987 BRepAlgoAPI_Cut aCut(aShapeToCut, aTool);
1988 return OCC1077_boolbl(aCut,aRadius);
1991 //TopoDS_Shape OCC1077_common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
1993 // return OCC1077_boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
1996 TopoDS_Shape OCC1077_Bug()
1998 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10).Shape();
1999 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7).Shape();
2001 TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
2002 TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10),
2003 gp_Dir(0, 0, 1)), 3, 20).Shape();
2004 TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0),
2005 gp_Dir(1, 0, 0)), 3, 20).Shape();
2006 TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
2007 gp_Dir(0, 1, 0)), 3, 20).Shape();
2008 TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
2009 Handle(ShapeFix_Shape) fixer = new ShapeFix_Shape(theTmp1);
2011 theTmp1 = fixer->Shape();
2012 TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
2013 fixer->Init(theTmp2);
2015 theTmp2 = fixer->Shape();
2016 TopoDS_Shape theResult = OCC1077_cut_blend(theTmp2,theCylinder3,0.7);
2017 fixer->Init(theResult);
2019 theResult = fixer->Shape();
2023 static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2025 if(argc < 1 || argc > 2) {
2026 di << "Usage : " << argv[0] << " result\n";
2030 TopoDS_Shape S = OCC1077_Bug();
2031 DBRep::Set(argv[1],S);
2036 //////////////////////////////////////////////////////////////
2038 * Compute uniform distribution of points using GCPnts_UniformAbscissa
2040 //////////////////////////////////////////////////////////////
2041 static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2045 di << "Usage : " << argv[0] << " name shape step\n";
2048 const char *name = argv[1];
2049 Adaptor3d_Curve *adapCurve=NULL;
2050 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
2051 if (!curve.IsNull())
2052 adapCurve = new GeomAdaptor_Curve(curve);
2055 TopoDS_Shape wire = DBRep::Get(argv[2]);
2056 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
2058 di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected\n";
2061 adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
2063 double step = Draw::Atof(argv[3]);
2064 GCPnts_UniformAbscissa aUni(*adapCurve, step);
2068 di << argv[0] <<" : fail\n";
2073 int i, np = aUni.NbPoints();
2074 for (i=0; i < np; i++)
2076 double par = aUni.Parameter(i+1);
2077 gp_Pnt p = adapCurve->Value(par);
2078 char n[20], *pname=n;
2079 Sprintf(n,"%s_%d",name,i+1);
2080 DrawTrSurf::Set(pname,p);
2089 static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2093 di << "Usage : " << argv[0] << " nb_of_vectors size\n";
2097 Standard_Integer nb = Draw::Atoi(argv[1]);
2098 Standard_Integer sz = Draw::Atoi(argv[2]);
2099 Standard_Real val = 10;
2100 math_Vector **pv = new math_Vector *[nb];
2102 di<<"creating "<<nb<<" vectors "<<sz<<" elements each...\n";
2104 for (i=0; i < nb; i++) {
2105 pv[i] = new math_Vector (1, sz, val);
2106 if ((i % (nb/10)) == 0) {
2108 //std::cout.flush();
2113 di<<"deleting them ...\n";
2114 for (i=0; i < nb; i++) {
2116 if ((i % (nb/10)) == 0) {
2118 //std::cout.flush();
2129 static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2133 di << "Usage : " << argv[0] << " wire\n";
2136 TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
2139 TopoDS_Wire wire = TopoDS::Wire(shape);
2140 // create curve parameterised by curvilinear distance
2141 BRepAdaptor_CompCurve curve(wire,Standard_True);
2142 Standard_Real length = curve.LastParameter();
2143 Standard_Real need_length = length/2;
2145 curve.D0(need_length,pnt);
2146 // create check_curve parameterised in a general way
2147 BRepAdaptor_CompCurve check_curve(wire);
2148 Standard_Real check_par =
2149 GCPnts_AbscissaPoint(check_curve, need_length, 0).Parameter();
2151 check_curve.D0(check_par,check_pnt);
2152 // check that points are coinsiding
2153 Standard_Real error_dist = pnt.Distance(check_pnt);
2154 if (error_dist > Precision::Confusion()) {
2155 //std::cout.precision(3);
2156 di<<"error_dist = "<<error_dist<<
2157 " ( "<<error_dist/need_length*100<<" %)\n";
2164 // stack overflow can be successfully handled only on 32-bit Windows
2165 #if defined(_WIN32) && !defined(_WIN64)
2166 static int StackOverflow (int i = -1)
2169 memset (arr, 0, sizeof(arr));
2176 // this code does not work with optimize mode on Windows
2177 #if defined(_MSC_VER)
2178 #pragma optimize( "", off )
2180 static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2184 std::cout << "Usage : " << argv[0] << "\n";
2187 Standard_Boolean Succes;
2189 Succes = Standard_True;
2192 {//==== Test Divide ByZero (Integer) ========================================
2195 std::cout << "(Integer) Divide By Zero..." << std::endl;
2196 di << "(Integer) Divide By Zero...";
2197 //std::cout.flush();
2199 Standard_Integer res, a =4, b = 0 ;
2201 di << "Error: 4 / 0 = " << res << " - no exception is raised!\n";
2202 Succes = Standard_False;
2204 #if defined(SOLARIS) || defined(_WIN32)
2205 catch(Standard_DivideByZero const&)
2207 catch(Standard_NumericError const&)
2210 di << "Caught, OK\n";
2212 catch(Standard_Failure const& anException) {
2214 di << anException.GetMessageString();
2216 Succes = Standard_False;
2218 // this case tests if (...) supersedes (Standard_*),
2219 // the normal behaviour is not
2221 di<<" unknown exception... (But) Ok\n";
2225 {//==== Test Divide ByZero (Real) ===========================================
2228 std::cout << "(Real) Divide By Zero..." << std::endl;
2229 di << "(Real) Divide By Zero...";
2230 //std::cout.flush();
2232 Standard_Real res, a= 4.0, b=0.0;
2234 di << "Error: 4.0 / 0.0 = " << res << " - no exception is raised!\n";
2235 Succes = Standard_False;
2237 catch(Standard_DivideByZero const&) // Solaris, Windows w/o SSE2
2239 di << "Caught, OK\n";
2241 catch(Standard_NumericError const&) // Linux, Windows with SSE2
2243 di << "Caught, OK\n";
2245 catch(Standard_Failure const& anException) {
2246 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2248 di << anException.GetMessageString();
2250 Succes = Standard_False;
2254 {//==== Test Overflow (Integer) =============================================
2257 std::cout << "(Integer) Overflow..." << std::endl;
2258 di << "(Integer) Overflow...";
2259 //std::cout.flush();
2261 Standard_Integer res, i=IntegerLast();
2263 //++++ std::cout << " -- "<<res<<"="<<i<<"+1 Does not Caught... KO"<< std::endl;
2264 //++++ Succes = Standard_False;
2265 di << "Not caught: " << i << " + 1 = " << res << ", still OK\n";
2267 catch(Standard_Overflow const&) {
2268 di << "Caught, OK\n";
2270 catch(Standard_Failure const& anException) {
2271 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2273 di << anException.GetMessageString();
2275 Succes = Standard_False;
2279 {//==== Test Overflow (Real) ================================================
2282 std::cout << "(Real) Overflow..." << std::endl;
2283 di << "(Real) Overflow...";
2284 //std::cout.flush();
2286 Standard_Real res, r=RealLast();
2289 (void)sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
2291 di << "Error: " << r << "*" << r << " = " << res << " - no exception is raised!\n";
2292 Succes = Standard_False;
2294 catch(Standard_Overflow const&) // Solaris, Windows w/o SSE2
2296 di << "Caught, OK\n";
2298 catch(Standard_NumericError const&) // Linux, Windows with SSE2
2300 di << "Caught, OK\n";
2302 catch(Standard_Failure const& anException) {
2303 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2305 di << anException.GetMessageString();
2307 Succes = Standard_False;
2311 {//==== Test Underflow (Real) ===============================================
2314 std::cout << "(Real) Underflow" << std::endl; // to have message in log even if process crashed
2315 di << "(Real) Underflow";
2316 //std::cout.flush();
2318 Standard_Real res, r = RealSmall();
2321 //++++ std::cout<<"-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<<std::endl;
2322 //++++ Succes = Standard_False;
2323 di << "Not caught: " << r << "*" << r << " = " << res << ", still OK\n";
2325 catch(Standard_Underflow const&) // could be on Solaris, Windows w/o SSE2
2327 di << "Exception caught, KO\n";
2328 Succes = Standard_False;
2330 catch(Standard_NumericError const&) // could be on Linux, Windows with SSE2
2332 di << "Exception caught, KO\n";
2333 Succes = Standard_False;
2335 catch(Standard_Failure const& anException) {
2336 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2338 di << anException.GetMessageString();
2340 Succes = Standard_False;
2344 {//==== Test Invalid Operation (Real) ===============================================
2347 std::cout << "(Real) Invalid Operation..." << std::endl;
2348 di << "(Real) Invalid Operation...";
2349 //std::cout.flush();
2351 Standard_Real res, r=-1;
2353 di << "Error: swrt(-1) = " << res << " - no exception is raised!\n";
2354 Succes = Standard_False;
2356 catch(Standard_NumericError const&) {
2357 di << "Caught, OK\n";
2359 catch(Standard_Failure const& anException) {
2360 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2362 di << anException.GetMessageString();
2364 Succes = Standard_False;
2368 {//==== Test Access Violation ===============================================
2371 std::cout << "Segmentation Fault..." << std::endl;
2372 di << "Segmentation Fault...";
2373 //std::cout.flush();
2377 di << "Error: writing by NULL address - no exception is raised!\n";
2378 Succes = Standard_False;
2381 catch(OSD_Exception_ACCESS_VIOLATION const&)
2383 catch(OSD_SIGSEGV const&)
2386 di << "Caught, OK\n";
2387 } catch(Standard_Failure const& anException) {
2388 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2390 di << anException.GetMessageString();
2392 Succes = Standard_False;
2396 #if defined(_WIN32) && !defined(_WIN64)
2397 {//==== Test Stack Overflow ===============================================
2400 std::cout << "Stack Overflow..." << std::endl;
2401 di << "Stack Overflow...";
2402 //std::cout.flush();
2405 di << "Error - no exception is raised!\n";
2406 Succes = Standard_False;
2408 catch(OSD_Exception_STACK_OVERFLOW const&) {
2409 di << "Caught, OK\n";
2411 catch(Standard_Failure const& anException) {
2412 //std::cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << std::endl;
2414 di << anException.GetMessageString();
2416 Succes = Standard_False;
2422 di << "TestExcept: Successfull completion\n";
2424 di << "TestExcept: failure\n";
2430 //! Auxiliary functor.
2431 struct TestParallelFunctor
2433 TestParallelFunctor() : myNbNotRaised (0), myNbSigSegv (0), myNbUnknown (0) {}
2435 Standard_Integer NbNotRaised() const { return myNbNotRaised; }
2436 Standard_Integer NbSigSegv() const { return myNbSigSegv; }
2437 Standard_Integer NbUnknown() const { return myNbUnknown; }
2439 void operator() (int theThreadId, int theTaskId) const
2444 // Test Access Violation
2450 Standard_Atomic_Increment (&myNbNotRaised);
2453 catch (OSD_Exception_ACCESS_VIOLATION const&)
2455 catch (OSD_SIGSEGV const&)
2458 Standard_Atomic_Increment (&myNbSigSegv);
2460 catch (Standard_Failure const& )
2462 Standard_Atomic_Increment (&myNbUnknown);
2467 mutable volatile Standard_Integer myNbNotRaised;
2468 mutable volatile Standard_Integer myNbSigSegv;
2469 mutable volatile Standard_Integer myNbUnknown;
2472 static Standard_Integer OCC30775 (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** )
2476 std::cout << "Syntax error: wrong number of arguments\n";
2480 Handle(OSD_ThreadPool) aPool = new OSD_ThreadPool (4);
2481 OSD_ThreadPool::Launcher aLauncher (*aPool, 4);
2482 TestParallelFunctor aFunctor;
2483 aLauncher.Perform (0, 100, aFunctor);
2484 theDI << "NbRaised: " << (aFunctor.NbSigSegv() + aFunctor.NbUnknown()) << "\n"
2485 << "NbNotRaised: " << aFunctor.NbNotRaised() << "\n"
2486 << "NbSigSeg: " << aFunctor.NbSigSegv() << "\n"
2487 << "NbUnknown: " << aFunctor.NbUnknown() << "\n";
2491 #if defined(_MSC_VER)
2492 #pragma optimize( "", on )
2495 static TopoDS_Compound AddTestStructure(int nCount_)
2501 BRepPrimAPI_MakeBox mkBox(1.0, 2.0, 3.0);
2502 for (int i=0; i<nCount; i++) {
2503 for (int j=0; j<nCount; j++) {
2505 trsf.SetTranslationPart(gp_Vec(5.0*i, 05.0*j, 0.0));
2506 TopLoc_Location topLoc(trsf);
2507 TopoDS_Shape tempShape=mkBox.Shape().Located(topLoc);
2508 B.Add(C, tempShape);
2514 static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2516 if (argc != 2 && argc != 3)
2518 std::cout << "Usage : " << argv[0] << " [nCount] path\n";
2522 int nCount = (argc > 2 ? Draw::Atoi(argv[1]) : 10);
2523 TCollection_AsciiString aFilePath (argv[argc > 2 ? 2 : 1]);
2524 STEPCAFControl_Writer writer;
2525 Handle(TDocStd_Document) document;
2526 document = new TDocStd_Document("Pace Test-StepExporter-");
2527 Handle(XCAFDoc_ShapeTool) shapeTool;
2528 shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
2529 shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
2530 STEPControl_StepModelType mode = STEPControl_AsIs;
2531 if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
2532 di << "Failed to set assembly mode for step data\n\n";
2537 if( writer.Transfer(document, mode)) {
2538 writer.Write(aFilePath.ToCString());
2541 catch(OSD_Exception_STACK_OVERFLOW const&) {
2542 di << "Failed : STACK OVERFLOW\n\n";
2544 catch (Standard_Failure const& anException) {
2545 di << "Failed :\n\n";
2546 //std::cout << Standard_Failure::Caught() << std::endl;
2547 di << anException.GetMessageString();
2549 di << argv[0] << " : Finish\n";
2554 static Standard_Integer OCC7372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2558 di << "Usage : " << argv[0] << "\n";
2562 // 1. Create an array of points
2563 Handle(TColgp_HArray1OfPnt2d) ap = new TColgp_HArray1OfPnt2d(1,5);
2564 ap->SetValue(1,gp_Pnt2d(100.0,0.0));
2565 ap->SetValue(2,gp_Pnt2d(100.0,100.0));
2566 ap->SetValue(3,gp_Pnt2d(0.0,100.0));
2567 ap->SetValue(4,gp_Pnt2d(0.0,0.0));
2568 ap->SetValue(5,gp_Pnt2d(50.0,-50.0));
2570 // 2. Create a periodic bspline through these 5 points
2571 Geom2dAPI_Interpolate intp(ap,Standard_True,1e-6);
2573 Handle(Geom2d_BSplineCurve) bspline1 = intp.Curve();
2575 // 3. Increase degree of curve from 3 to 8
2576 bspline1->IncreaseDegree(8); // Increase degree to demonstrate the error
2577 Standard_CString CString1 = "BSplineCurve";
2578 DrawTrSurf::Set(CString1,bspline1);
2580 // 4. Convers BSpline curve to Bezier segments
2581 Geom2dConvert_BSplineCurveToBezierCurve bc(bspline1);
2583 // 5. Test the result of conversion
2584 TCollection_AsciiString aRName;
2585 for(Standard_Integer i = 1; i <= bc.NbArcs(); i++) {
2586 Handle(Geom2d_BezierCurve) arc = bc.Arc(i);
2588 aRName=aRName+TCollection_AsciiString(i);
2589 Standard_CString aRNameStr = aRName.ToCString();
2590 DrawTrSurf::Set(aRNameStr,arc);
2591 di << aRNameStr << " ";
2597 static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2601 di << "Usage : " << argv[0] << " edge1 edge2 plane\n";
2604 TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
2605 if (theEdge1.IsNull()) {
2606 di << "Invalid input shape " << argv[1] << "\n";
2609 TopoDS_Edge theEdge2 = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
2610 if (theEdge2.IsNull()) {
2611 di << "Invalid input shape " << argv[2] << "\n";
2614 TopoDS_Face theFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
2615 if (theFace.IsNull()) {
2616 di << "Invalid input shape " << argv[3] << "\n";
2620 Handle(Geom_Surface) thePlane = BRep_Tool::Surface(theFace);
2622 Standard_Real aConfusion = Precision::Confusion();
2623 Standard_Real aP1first, aP1last, aP2first, aP2last;
2625 Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(theEdge1, aP1first, aP1last);
2626 Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(theEdge2, aP2first, aP2last);
2627 Handle(Geom2d_Curve) aCurve2d1 = GeomProjLib::Curve2d(aCurve1, aP1first, aP1last, thePlane);
2628 Handle(Geom2d_Curve) aCurve2d2 = GeomProjLib::Curve2d(aCurve2, aP2first, aP2last, thePlane);
2630 Geom2dAPI_InterCurveCurve anInter(aCurve2d1, aCurve2d2, aConfusion);
2632 Standard_Integer NbPoints = anInter.NbPoints();
2634 di << "NbPoints = " << NbPoints << "\n" ;
2638 for (i=1; i<=NbPoints; i++) {
2639 gp_Pnt2d aPi = anInter.Point(i);
2640 di << "Point.X(" << i << ") = " << aPi.X() << " Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
2644 Standard_Integer NbSegments = anInter.NbSegments();
2646 di << "\nNbSegments = " << NbSegments << "\n" ;
2648 if (NbSegments > 0) {
2649 IntRes2d_IntersectionSegment aSegment = anInter.Intersector().Segment(1);
2651 gp_Pnt2d aP1 = aCurve2d1->Value(aSegment.FirstPoint().ParamOnFirst());
2652 gp_Pnt2d aP2 = aCurve2d2->Value(aSegment.FirstPoint().ParamOnSecond());
2654 Standard_Real aDist = aP1.Distance(aP2);
2656 di << "aP1.X() = " << aP1.X() << " aP1.Y() = " << aP1.Y() << "\n" ;
2657 di << "aP2.X() = " << aP2.X() << " aP2.Y() = " << aP2.Y() << "\n" ;
2659 di << "Distance = " << aDist << "\n" ;
2661 di << "Confusion = " << aConfusion << "\n" ;
2663 if (aDist > aConfusion) {
2664 di << "\n" << argv[0] << " Faulty\n" ;
2666 di << "\n" << argv[0] << " OK\n" ;
2669 di << "\n" << argv[0] << " OK\n" ;
2674 static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2678 di << "Usage : " << argv[0] << " lower upper\n";
2682 Standard_Integer LOWER = Draw::Atoi(argv[1]);
2683 Standard_Integer UPPER = Draw::Atoi(argv[2]);
2685 //! 0. Create an empty document with several test labels
2686 Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
2687 doc->SetUndoLimit(100);
2688 TDF_Label main_label = doc->Main();
2689 TDF_Label label1 = main_label.FindChild(1, Standard_True);
2690 TDF_Label label2 = main_label.FindChild(2, Standard_True);
2692 //! 1. Set/Get OCAF attribute
2694 TDataStd_RealArray::Set(label1, LOWER, UPPER);
2695 Handle(TDataStd_RealArray) array;
2696 if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) &&
2697 array->Lower() == LOWER && array->Upper() == UPPER)
2698 std::cout<<"1: OK"<<std::endl;
2701 std::cout<<"1: Failed.."<<std::endl;
2704 doc->CommitCommand();
2706 //! 2. Set/Get value
2709 for (i = LOWER; i <= UPPER; i++)
2710 array->SetValue(i, i);
2711 for (i = LOWER; i <= UPPER; i++)
2713 if (array->Value(i) != i)
2715 std::cout<<"2: Failed.."<<std::endl;
2719 std::cout<<"2: OK"<<std::endl;
2720 doc->CommitCommand();
2722 //! 3. Re-init the array
2724 array->Init(LOWER + 2, UPPER + 4);
2725 if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4)
2727 std::cout<<"3: Failed.."<<std::endl;
2730 for (i = LOWER + 2; i <= UPPER + 4; i++)
2731 array->SetValue(i, i);
2732 for (i = LOWER + 2; i <= UPPER + 4; i++)
2734 if (array->Value(i) != i)
2736 std::cout<<"3: Failed.."<<std::endl;
2740 std::cout<<"3: OK"<<std::endl;
2741 doc->CommitCommand();
2745 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(LOWER + 5, UPPER + 5);
2746 for (i = LOWER + 5; i <= UPPER + 5; i++)
2747 arr->SetValue(i, i);
2748 array->ChangeArray(arr);
2749 for (i = LOWER + 5; i <= UPPER + 5; i++)
2751 if (array->Value(i) != i)
2753 std::cout<<"4: Failed.."<<std::endl;
2757 std::cout<<"4: OK"<<std::endl;
2758 doc->CommitCommand();
2760 //! 5. Copy the array
2762 TDF_CopyLabel copier(label1, label2);
2764 if (!copier.IsDone())
2766 std::cout<<"5: Failed.."<<std::endl;
2769 Handle(TDataStd_RealArray) array2;
2770 if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2772 std::cout<<"5: Failed.."<<std::endl;
2775 for (i = LOWER + 5; i <= UPPER + 5; i++)
2777 if (array->Value(i) != i)
2779 std::cout<<"5: Failed.."<<std::endl;
2783 std::cout<<"5: OK"<<std::endl;
2784 doc->CommitCommand();
2787 //! 6.a: undoes the 5th action: the copied array should disappear
2789 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2790 label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2792 std::cout<<"6.a: Failed.."<<std::endl;
2795 //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4)
2797 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2798 array->Lower() != LOWER + 2 ||
2799 array->Upper() != UPPER + 4)
2801 std::cout<<"6.b: Failed.."<<std::endl;
2804 for (i = LOWER + 2; i <= UPPER + 4; i++)
2806 if (array->Value(i) != i)
2808 std::cout<<"6.b: Failed.."<<std::endl;
2812 //! 6.c: undoes the 3d action: the array should be changed to (lower,upper)
2814 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2815 array->Lower() != LOWER ||
2816 array->Upper() != UPPER)
2818 std::cout<<"6.c: Failed.."<<std::endl;
2821 for (i = LOWER; i <= UPPER; i++)
2823 if (array->Value(i) != i)
2825 std::cout<<"6.c: Failed.."<<std::endl;
2829 //! 6.d: undoes and redoes the 2nd action: no change is expected.
2832 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2833 array->Lower() != LOWER ||
2834 array->Upper() != UPPER)
2836 std::cout<<"6.d: Failed.."<<std::endl;
2839 for (i = LOWER; i <= UPPER; i++)
2841 if (array->Value(i) != i)
2843 std::cout<<"6.d: Failed.."<<std::endl;
2847 std::cout<<"6: OK"<<std::endl;
2849 //! 7. Re-set the array
2851 array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1);
2852 if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1)
2854 std::cout<<"7: Failed.."<<std::endl;
2857 for (i = LOWER + 1; i <= UPPER + 1; i++)
2858 array->SetValue(i, i);
2859 for (i = LOWER + 1; i <= UPPER + 1; i++)
2861 if (array->Value(i) != i)
2863 std::cout<<"7: Failed.."<<std::endl;
2867 std::cout<<"7: OK"<<std::endl;
2868 doc->CommitCommand();
2870 //! 8.Test of speed: set LOWER and UPPER equal to great integer number and
2871 //! measure the time spent by this test.
2877 static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2879 Standard_Boolean IsEvenArgc = Standard_True;
2880 if (argc % 2 == 0) {
2881 IsEvenArgc = Standard_True;
2883 IsEvenArgc = Standard_False;
2886 if (argc < 3 || IsEvenArgc)
2888 di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]\n";
2892 Standard_Integer i, aValue, aPosition;
2893 NCollection_Vector<int> vec;
2894 for (i = 0; i < argc - 1; i++) {
2896 aValue = Draw::Atoi(argv[i]);
2897 aPosition = Draw::Atoi(argv[i+1]);
2898 vec.SetValue(aValue, aPosition);
2900 NCollection_Vector<int>::Iterator it(vec);
2902 for (j = 0; it.More(); it.Next(), j++) {
2903 //di << it.Value() << "\n";
2904 di << j << " " << it.Value() << "\n";
2910 static Standard_Integer OCC8797 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2913 di << "Usage : " << argv[0] << "\n";
2917 gp_Pnt point(0.0,0.0,0.0);
2919 TColgp_Array1OfPnt poles(0,6);
2922 point.SetCoord(1.0,1.0,0.0);
2925 point.SetCoord(2.0,1.0,0.0);
2928 point.SetCoord(3.0,0.0,0.0);
2931 point.SetCoord(4.0,1.0,0.0);
2934 point.SetCoord(5.0,1.0,0.0);
2937 point.SetCoord(6.0,0.0,0.0);
2940 TColStd_Array1OfReal knots(0,2);
2945 TColStd_Array1OfInteger multi(0,2);
2950 Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles,knots,multi,3);
2953 Standard_Real l_abcissa,l_gprop;
2954 GeomAdaptor_Curve adaptor_spline(spline);
2955 GCPnts_AbscissaPoint temp;
2956 l_abcissa=temp.Length(adaptor_spline);
2957 std::cout<<"Length Spline(abcissa_Pnt): "<<l_abcissa<<std::endl;
2960 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge (spline);
2962 BRepGProp::LinearProperties(edge,prop);
2963 l_gprop=prop.Mass();
2964 std::cout<<"Length Spline(GProp_GProps): "<<l_gprop<<std::endl;
2966 std::cout<<"Difference (abcissa_Pnt<->GProp_GProps): "<<l_gprop-l_abcissa<<std::endl;
2971 static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2975 di << "Usage : " << argv[0] << "\n";
2979 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
2980 if(AISContext.IsNull())
2982 di << "use 'vinit' command before " << argv[0] << "\n";
2987 AIS_ListOfInteractive ListOfIO_1;
2988 AISContext->ObjectsInside(ListOfIO_1);
2989 di<< "ObjectsInside = " << ListOfIO_1.Extent() <<"\n";
2990 if (!ListOfIO_1.IsEmpty() ) {
2991 AIS_ListIteratorOfListOfInteractive iter;
2992 for (iter.Initialize(ListOfIO_1); iter.More() ; iter.Next() ) {
2993 Handle(AIS_InteractiveObject) aIO=iter.Value();
2994 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3001 static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3003 if ((argc < 9) || (((argc-3) % 3) != 0))
3005 di << "Usage : " << argv[0] << "polygon lastedge x1 y1 z1 x2 y2 z2 ...\n";
3008 Standard_Integer i, j, np = (argc-3) / 3;
3009 BRepBuilderAPI_MakePolygon W;
3011 for (i = 1; i <= np; i ++) {
3012 W.Add(gp_Pnt(Draw::Atof(argv[j]),Draw::Atof(argv[j+1]),Draw::Atof(argv[j+2])));
3016 DBRep::Set(argv[1],W.Wire());
3017 DBRep::Set(argv[2],W.Edge());
3021 static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3024 di << "Usage : " << argv[0] << " ratio origin_x origin_y origin_z\n";
3027 gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
3028 gp_Dir(1., -1., 0.));
3030 aTrf.SetAffinity (aPln, Draw::Atof(argv[4]));
3031 gp_XYZ aOrigin (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3032 gp_XYZ aResult (aOrigin);
3033 aTrf.Transforms(aResult);
3035 Sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
3036 aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
3037 aResult.X(), aResult.Y(), aResult.Z());
3042 Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3045 di << "Usage : " << argv[0] << " shape [deflection]\n";
3049 TopoDS_Shape aShape = DBRep::Get(argv[1]);
3051 if (aShape.IsNull()) {
3052 di<<" Null shape is not allowed";
3056 Standard_Real aDeflection = 0.45110277533;
3058 aDeflection = Draw::Atof(argv[2]);
3060 di<<"deflection="<< aDeflection << "\n";
3062 BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI / 9.);
3063 TopLoc_Location aLocation;
3064 Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
3066 if(aTriang.IsNull()) {
3067 di << argv[0] << " : Faulty\n" ;
3069 di << argv[0] << " : OK\n" ;
3070 di<<"NbNodes="<< aTriang->NbNodes()<< "\n";
3071 di<<"NbTriangles="<< aTriang->NbTriangles()<< "\n";
3076 static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3079 di << "Usage : " << argv[0] << " A B C\n";
3084 gp_Lin2d aLin2d (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3085 gp_Pnt2d anOrigin = aLin2d.Location();
3086 di << "X_0 = " << anOrigin.X() << " Y_0 = " << anOrigin.Y() << "\n" ;
3088 catch(Standard_ConstructionError const&)
3090 di << argv[0] << " Exception: Sqrt(A*A + B*B) <= Resolution from gp\n";
3095 static Standard_Integer OCC15755 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3098 di << "Usage : " << argv[0] << " file shape\n";
3102 IGESControl_Reader aReader;
3103 aReader.ReadFile(argv[1]);
3104 aReader.SetReadVisible(Standard_True);
3105 aReader.TransferRoots();
3107 Handle(IGESData_IGESModel) model = aReader.IGESModel();
3108 if (model.IsNull()) {
3109 di << "model.IsNull()\n";
3112 Standard_Integer nb = model->NbEntities();
3113 for (Standard_Integer i = 1; i <= nb; i ++) {
3114 Handle(IGESData_IGESEntity) ent = model->Entity(i);
3115 Handle(TCollection_HAsciiString) name;
3116 name = ent->NameValue();
3117 Standard_CString aStr = name->ToCString();
3118 di << "NameValue = " << aStr << "\n";
3121 TopoDS_Shape shape = aReader.OneShape();
3122 DBRep::Set(argv[2],shape);
3126 // For OCC16782 testing
3127 #include <AppStd_Application.hxx>
3128 #include <TDF_Tool.hxx>
3129 #include <TColStd_HArray1OfInteger.hxx>
3131 #include <TColStd_ListIteratorOfListOfInteger.hxx>
3132 #include <TColStd_ListIteratorOfListOfReal.hxx>
3133 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
3134 #include <TDataStd_ListIteratorOfListOfByte.hxx>
3135 #include <TDF_ListIteratorOfLabelList.hxx>
3137 #include <TDataStd_Tick.hxx>
3138 #include <TDataStd_IntegerList.hxx>
3139 #include <TDataStd_RealList.hxx>
3140 #include <TDataStd_ExtStringList.hxx>
3141 #include <TDataStd_BooleanList.hxx>
3142 #include <TDataStd_ReferenceList.hxx>
3143 #include <TDataStd_BooleanArray.hxx>
3144 #include <TDataStd_ReferenceArray.hxx>
3145 #include <TDataStd_ByteArray.hxx>
3146 #include <TDataStd_NamedData.hxx>
3147 #include <TDF_Reference.hxx>
3149 Handle(AppStd_Application) app;
3150 int TestSetGet(const Handle(TDocStd_Document)& doc)
3154 TDataStd_Tick::Set(doc->Main());
3156 Handle(TDataStd_Tick) tick;
3157 if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick))
3160 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3161 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3163 doc->Main().ResumeAttribute(tick);
3164 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3167 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3168 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3171 // TDataStd_IntegerList:
3173 Handle(TDataStd_IntegerList) setintlist = TDataStd_IntegerList::Set(doc->Main());
3174 setintlist->Append(2);
3175 setintlist->Prepend(1);
3176 setintlist->InsertAfter(3, 2);
3177 setintlist->InsertBefore(0, 1);
3178 setintlist->Append(200);
3179 setintlist->Remove(0);
3180 setintlist->Remove(200);
3182 Handle(TDataStd_IntegerList) getintlist;
3183 if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist))
3185 if (getintlist->First() != 1)
3187 if (getintlist->Last() != 3)
3189 const TColStd_ListOfInteger& intlist = getintlist->List();
3190 TColStd_ListIteratorOfListOfInteger itr_intlist(intlist);
3191 for (; itr_intlist.More(); itr_intlist.Next())
3193 if (itr_intlist.Value() != 1 &&
3194 itr_intlist.Value() != 2 &&
3195 itr_intlist.Value() != 3)
3200 getintlist->Clear();
3202 // TDataStd_RealList:
3204 Handle(TDataStd_RealList) setdbllist = TDataStd_RealList::Set(doc->Main());
3205 setdbllist->Append(2.5);
3206 setdbllist->Prepend(1.5);
3207 setdbllist->InsertAfter(3.5, 2.5);
3208 setdbllist->InsertBefore(0.5, 1.5);
3209 setdbllist->Append(200.5);
3210 setdbllist->Remove(0.5);
3211 setdbllist->Remove(200.5);
3213 Handle(TDataStd_RealList) getdbllist;
3214 if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist))
3216 if (getdbllist->First() != 1.5)
3218 if (getdbllist->Last() != 3.5)
3220 const TColStd_ListOfReal& dbllist = getdbllist->List();
3221 TColStd_ListIteratorOfListOfReal itr_dbllist(dbllist);
3222 for (; itr_dbllist.More(); itr_dbllist.Next())
3224 if (itr_dbllist.Value() != 1.5 &&
3225 itr_dbllist.Value() != 2.5 &&
3226 itr_dbllist.Value() != 3.5)
3231 getdbllist->Clear();
3233 // TDataStd_ExtStringList:
3235 Handle(TDataStd_ExtStringList) setstrlist = TDataStd_ExtStringList::Set(doc->Main());
3236 setstrlist->Append("Hello");
3237 setstrlist->Prepend("Guten Tag");
3238 setstrlist->InsertAfter("Bonjour", "Guten Tag");
3239 setstrlist->InsertBefore("Bonsoir", "Hello");
3240 setstrlist->Append("Good bye");
3241 setstrlist->Remove("Bonsoir");
3242 setstrlist->Remove("Good bye");
3244 Handle(TDataStd_ExtStringList) getstrlist;
3245 if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist))
3247 if (getstrlist->First() != "Guten Tag")
3249 if (getstrlist->Last() != "Hello")
3251 const TDataStd_ListOfExtendedString& strlist = getstrlist->List();
3252 TDataStd_ListIteratorOfListOfExtendedString itr_strlist(strlist);
3253 for (; itr_strlist.More(); itr_strlist.Next())
3255 if (itr_strlist.Value() != "Guten Tag" &&
3256 itr_strlist.Value() != "Bonjour" &&
3257 itr_strlist.Value() != "Hello")
3262 getstrlist->Clear();
3264 // TDataStd_BooleanList:
3266 Handle(TDataStd_BooleanList) setboollist = TDataStd_BooleanList::Set(doc->Main());
3267 setboollist->Append(Standard_True);
3268 setboollist->Prepend(Standard_False);
3270 Handle(TDataStd_BooleanList) getboollist;
3271 if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist))
3273 if (getboollist->First() != Standard_False)
3275 if (getboollist->Last() != Standard_True)
3277 const TDataStd_ListOfByte& boollist = getboollist->List();
3278 for (TDataStd_ListIteratorOfListOfByte itr_boollist(boollist); itr_boollist.More(); itr_boollist.Next())
3280 if (itr_boollist.Value() != 1
3281 && itr_boollist.Value() != 0)
3286 getboollist->Clear();
3288 // TDataStd_ReferenceList:
3289 TDF_Label L1 = doc->Main().FindChild(100);
3290 TDF_Label L2 = doc->Main().FindChild(101);
3291 TDF_Label L3 = doc->Main().FindChild(102);
3292 TDF_Label L4 = doc->Main().FindChild(103);
3293 TDF_Label L5 = doc->Main().FindChild(104);
3295 Handle(TDataStd_ReferenceList) setreflist = TDataStd_ReferenceList::Set(doc->Main());
3296 setreflist->Append(L1);
3297 setreflist->Prepend(L2);
3298 setreflist->InsertAfter(L3, L2);
3299 setreflist->InsertBefore(L4, L1);
3300 setreflist->Append(L5);
3301 setreflist->Remove(L4);
3302 setreflist->Remove(L5);
3304 Handle(TDataStd_ReferenceList) getreflist;
3305 if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist))
3307 if (getreflist->First() != L2)
3309 if (getreflist->Last() != L1)
3311 const TDF_LabelList& reflist = getreflist->List();
3312 TDF_ListIteratorOfLabelList itr_reflist(reflist);
3313 for (; itr_reflist.More(); itr_reflist.Next())
3315 if (itr_reflist.Value() != L1 &&
3316 itr_reflist.Value() != L2 &&
3317 itr_reflist.Value() != L3)
3322 getreflist->Clear();
3324 // TDataStd_BooleanArray:
3326 Handle(TDataStd_BooleanArray) setboolarr = TDataStd_BooleanArray::Set(doc->Main(), 12, 16);
3327 setboolarr->SetValue(12, Standard_True);
3328 setboolarr->SetValue(13, Standard_False);
3329 setboolarr->SetValue(14, Standard_False);
3330 setboolarr->SetValue(15, Standard_False);
3331 setboolarr->SetValue(16, Standard_True);
3332 setboolarr->SetValue(14, Standard_True);
3334 Handle(TDataStd_BooleanArray) getboolarr;
3335 if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr))
3337 if (getboolarr->Value(12) != Standard_True)
3339 if (getboolarr->Value(13) != Standard_False)
3341 if (getboolarr->Value(14) != Standard_True)
3343 if (getboolarr->Value(15) != Standard_False)
3345 if (getboolarr->Value(16) != Standard_True)
3348 // TDataStd_ReferenceArray:
3350 Handle(TDataStd_ReferenceArray) setrefarr = TDataStd_ReferenceArray::Set(doc->Main(), 0, 4);
3351 setrefarr->SetValue(0, L1);
3352 setrefarr->SetValue(1, L2);
3353 setrefarr->SetValue(2, L3);
3354 setrefarr->SetValue(3, L4);
3355 setrefarr->SetValue(4, L5);
3357 Handle(TDataStd_ReferenceArray) getrefarr;
3358 if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr))
3360 if (getrefarr->Value(0) != L1)
3362 if (getrefarr->Value(1) != L2)
3364 if (getrefarr->Value(2) != L3)
3366 if (getrefarr->Value(3) != L4)
3368 if (getrefarr->Value(4) != L5)
3371 // TDataStd_ByteArray:
3373 Handle(TDataStd_ByteArray) setbytearr = TDataStd_ByteArray::Set(doc->Main(), 12, 16);
3374 setbytearr->SetValue(12, 0);
3375 setbytearr->SetValue(13, 1);
3376 setbytearr->SetValue(14, 2);
3377 setbytearr->SetValue(15, 3);
3378 setbytearr->SetValue(16, 255);
3380 Handle(TDataStd_ByteArray) getbytearr;
3381 if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr))
3383 if (getbytearr->Value(12) != 0)
3385 if (getbytearr->Value(13) != 1)
3387 if (getbytearr->Value(14) != 2)
3389 if (getbytearr->Value(15) != 3)
3391 if (getbytearr->Value(16) != 255)
3394 // TDataStd_NamedData:
3396 Handle(TDataStd_NamedData) setnd = TDataStd_NamedData::Set(doc->Main());
3397 setnd->SetInteger("Integer1", 1);
3398 setnd->SetInteger("Integer2", 2);
3399 setnd->SetInteger("Integer3", 8);
3400 setnd->SetInteger("Integer3", 3);
3402 Handle(TDataStd_NamedData) getnd;
3403 if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd))
3405 if (!getnd->HasIntegers())
3407 if (!getnd->HasInteger("Integer1"))
3409 if (getnd->GetInteger("Integer2") != 2)
3411 if (getnd->GetInteger("Integer3") != 3)
3417 int TestUndoRedo(const Handle(TDocStd_Document)& doc)
3421 Handle(TDataStd_Tick) tick = TDataStd_Tick::Set(doc->Main());
3422 doc->CommitCommand();
3423 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3426 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3429 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3432 // TDataStd_IntegerList:
3434 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc->Main());
3436 intlist->Prepend(1);
3437 intlist->InsertBefore(0, 1);
3438 intlist->InsertAfter(3, 2);
3439 doc->CommitCommand();
3440 if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID()))
3443 if (!intlist->IsEmpty())
3446 if (!intlist->Extent())
3448 if (intlist->First() != 0)
3450 if (intlist->Last() != 3)
3454 // TDataStd_RealList:
3456 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc->Main());
3457 dbllist->Append(2.5);
3458 dbllist->Prepend(1.5);
3459 dbllist->InsertBefore(0.5, 1.5);
3460 dbllist->InsertAfter(3.5, 2.5);
3461 doc->CommitCommand();
3462 if (!doc->Main().IsAttribute(TDataStd_RealList::GetID()))
3465 if (!dbllist->IsEmpty())
3468 if (!dbllist->Extent())
3470 if (dbllist->First() != 0.5)
3472 if (dbllist->Last() != 3.5)
3476 // TDataStd_ExtStringList:
3478 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc->Main());
3479 strlist->Append("Hello");
3480 strlist->Prepend("Guten Tag");
3481 strlist->InsertAfter("Bonjour", "Guten Tag");
3482 strlist->InsertBefore("Bonsoir", "Hello");
3483 doc->CommitCommand();
3484 if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID()))
3487 if (!strlist->IsEmpty())
3490 if (!strlist->Extent())
3492 if (strlist->First() != "Guten Tag")
3494 if (strlist->Last() != "Hello")
3498 // TDataStd_BooleanList:
3500 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc->Main());
3501 boollist->Append(Standard_True);
3502 boollist->Prepend(Standard_False);
3503 doc->CommitCommand();
3504 if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID()))
3507 if (!boollist->IsEmpty())
3510 if (!boollist->Extent())
3512 if (boollist->First() != Standard_False)
3514 if (boollist->Last() != Standard_True)
3518 // TDataStd_ReferenceList:
3519 TDF_Label L1 = doc->Main().FindChild(100);
3520 TDF_Label L2 = doc->Main().FindChild(101);
3521 TDF_Label L3 = doc->Main().FindChild(102);
3522 TDF_Label L4 = doc->Main().FindChild(103);
3524 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc->Main());
3525 reflist->Append(L1);
3526 reflist->Prepend(L2);
3527 reflist->InsertBefore(L3, L1);
3528 reflist->InsertAfter(L4, L2);
3529 doc->CommitCommand();
3530 if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID()))
3533 if (!reflist->IsEmpty())
3536 if (!reflist->Extent())
3538 if (reflist->First() != L2)
3540 if (reflist->Last() != L1)
3544 // TDataStd_BooleanArray:
3546 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc->Main(), 23, 25);
3547 boolarr->SetValue(23, Standard_True);
3548 boolarr->SetValue(25, Standard_True);
3549 doc->CommitCommand();
3551 boolarr = TDataStd_BooleanArray::Set(doc->Main(), 230, 250);
3552 boolarr->SetValue(230, Standard_True);
3553 boolarr->SetValue(250, Standard_True);
3554 doc->CommitCommand();
3556 if (boolarr->Value(23) != Standard_True)
3558 if (boolarr->Value(24) != Standard_False)
3560 if (boolarr->Value(25) != Standard_True)
3563 if (boolarr->Value(230) != Standard_True)
3565 if (boolarr->Value(240) != Standard_False)
3567 if (boolarr->Value(250) != Standard_True)
3570 // TDataStd_ReferenceArray:
3572 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc->Main(), 5, 8);
3573 refarr->SetValue(5, L1);
3574 refarr->SetValue(6, L2);
3575 refarr->SetValue(7, L3);
3576 refarr->SetValue(8, L4);
3577 doc->CommitCommand();
3578 if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID()))
3582 if (refarr->Value(5) != L1)
3584 if (refarr->Value(6) != L2)
3586 if (refarr->Value(7) != L3)
3588 if (refarr->Value(8) != L4)
3591 // TDataStd_ByteArray:
3593 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc->Main(), 23, 25);
3594 bytearr->SetValue(23, 23);
3595 bytearr->SetValue(25, 25);
3596 doc->CommitCommand();
3598 bytearr = TDataStd_ByteArray::Set(doc->Main(), 230, 250);
3599 bytearr->SetValue(230, 230);
3600 bytearr->SetValue(250, 250);
3601 doc->CommitCommand();
3603 if (bytearr->Value(23) != 23)
3605 if (bytearr->Value(25) != 25)
3608 if (bytearr->Value(230) != 230)
3610 if (bytearr->Value(250) != 250)
3613 // TDataStd_NamedData:
3615 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(doc->Main());
3616 nd->SetByte("b14", 12);
3617 nd->SetByte("b17", 18);
3618 nd->SetByte("b14", 14);
3619 nd->SetByte("b17", 17);
3620 doc->CommitCommand();
3622 nd = TDataStd_NamedData::Set(doc->Main());
3623 nd->SetReal("r14", 14);
3624 nd->SetReal("r17", 17);
3625 nd->SetReal("r14", 14.4);
3626 nd->SetReal("r17", 17.7);
3627 doc->CommitCommand();
3629 if (nd->HasStrings())
3633 if (nd->HasReal("r17"))
3635 if (!nd->HasBytes())
3637 if (nd->GetByte("b14") != 14)
3639 if (nd->GetByte("b17") != 17)
3641 if (nd->HasByte("b18"))
3644 if (!nd->HasBytes())
3646 if (!nd->HasReals())
3648 if (nd->GetByte("b14") != 14)
3650 if (nd->GetReal("r14") != 14.4)
3652 if (nd->GetReal("r17") != 17.7)
3658 int TestCopyPaste(const Handle(TDocStd_Document)& doc)
3660 TDF_Label L1 = doc->Main().FindChild(1);
3661 TDF_Label L2 = doc->Main().FindChild(2);
3662 TDF_CopyLabel copier(L1, L2);
3665 TDataStd_Tick::Set(L1);
3667 if (!copier.IsDone())
3669 if (!L2.IsAttribute(TDataStd_Tick::GetID()))
3672 // TDataStd_IntegerList:
3673 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(L1);
3675 intlist->InsertAfter(2, 1);
3677 if (!copier.IsDone())
3681 if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3683 if (intlist->First() != 1)
3685 if (intlist->Last() != 2)
3689 // TDataStd_RealList:
3690 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(L1);
3691 dbllist->Append(1.5);
3692 dbllist->InsertAfter(2.5, 1.5);
3694 if (!copier.IsDone())
3698 if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist))
3700 if (dbllist->First() != 1.5)
3702 if (dbllist->Last() != 2.5)
3706 // TDataStd_ExtStringList:
3707 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(L1);
3708 strlist->Append("Open CASCADE");
3709 strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE");
3711 if (!copier.IsDone())
3715 if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
3717 if (strlist->First() != "Open CASCADE")
3719 if (strlist->Last() != " - is the best set of libraries!")
3723 // TDataStd_BooleanList:
3724 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(L1);
3725 boollist->Append(Standard_True);
3726 boollist->Prepend(Standard_False);
3728 if (!copier.IsDone())
3732 if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist))
3734 if (boollist->First() != Standard_False)
3736 if (boollist->Last() != Standard_True)
3740 // TDataStd_ReferenceList:
3741 TDF_Label L100 = doc->Main().FindChild(100);
3742 TDF_Label L101 = doc->Main().FindChild(101);
3743 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(L1);
3744 reflist->Append(L100);
3745 reflist->InsertAfter(L101, L100);
3747 if (!copier.IsDone())
3751 if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
3753 if (reflist->First() != L100)
3755 if (reflist->Last() != L101)
3759 // TDataStd_BooleanArray:
3760 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(L1, 4, 6);
3761 boolarr->SetValue(4, Standard_True);
3762 boolarr->SetValue(6, Standard_True);
3764 if (!copier.IsDone())
3767 if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
3769 if (boolarr->Value(4) != Standard_True)
3771 if (boolarr->Value(5) != Standard_False)
3773 if (boolarr->Value(6) != Standard_True)
3776 // TDataStd_ReferenceArray:
3777 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(L1, 3, 4);
3778 refarr->SetValue(3, L100);
3779 refarr->SetValue(4, L101);
3781 if (!copier.IsDone())
3784 if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
3786 if (refarr->Value(3) != L100)
3788 if (refarr->Value(4) != L101)
3791 // TDataStd_ByteArray:
3792 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(L1, 4, 6);
3793 bytearr->SetValue(4, 40);
3794 bytearr->SetValue(6, 60);
3796 if (!copier.IsDone())
3799 if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
3801 if (bytearr->Value(4) != 40)
3803 if (bytearr->Value(6) != 60)
3806 // TDataStd_NamedData:
3807 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(L1);
3808 nd->SetInteger("Integer1", 11);
3809 nd->SetReal("Real1", 11.1);
3810 nd->SetString("String1", "11.11111111");
3811 nd->SetByte("Byte1", 111);
3812 Handle(TColStd_HArray1OfInteger) ints_arr = new TColStd_HArray1OfInteger(4, 5);
3813 ints_arr->SetValue(4, 4);
3814 ints_arr->SetValue(5, 5);
3815 nd->SetArrayOfIntegers("Integers1", ints_arr);
3817 if (!copier.IsDone())
3820 if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd))
3822 if (!nd->HasIntegers())
3824 if (!nd->HasReals())
3826 if (!nd->HasStrings())