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_Axis2Placement.hxx>
31 #include <gp_Trsf.hxx>
32 #include <AIS_Trihedron.hxx>
33 #include <BRepPrimAPI_MakeBox.hxx>
34 #include <Graphic3d_MaterialAspect.hxx>
35 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
36 #include <TopoDS_Solid.hxx>
37 #include <BRepPrimAPI_MakeSphere.hxx>
38 #include <BRepPrimAPI_MakeCone.hxx>
39 #include <BRepPrimAPI_MakeCylinder.hxx>
40 #include <IGESToBRep_Reader.hxx>
41 #include <TopExp_Explorer.hxx>
43 #include <GCPnts_UniformDeflection.hxx>
44 #include <BRepAdaptor_Curve.hxx>
45 #include <IGESToBRep.hxx>
46 #include <V3d_Viewer.hxx>
47 #include <BRepAdaptor_CompCurve.hxx>
48 #include <GCPnts_AbscissaPoint.hxx>
49 #include <Standard_ErrorHandler.hxx>
50 #include <Standard_Overflow.hxx>
51 #include <Standard_Underflow.hxx>
52 #include <Standard_DivideByZero.hxx>
53 #include <OSD_SIGSEGV.hxx>
54 #include <OSD_Exception_ACCESS_VIOLATION.hxx>
55 #include <OSD_Exception_STACK_OVERFLOW.hxx>
57 #include <STEPCAFControl_Writer.hxx>
58 #include <STEPControl_StepModelType.hxx>
59 #include <Interface_Static.hxx>
60 #include <IFSelect_ReturnStatus.hxx>
61 #include <Standard_Failure.hxx>
62 #include <TColgp_HArray1OfPnt2d.hxx>
63 #include <Geom2dAPI_Interpolate.hxx>
64 #include <Geom2d_BSplineCurve.hxx>
65 #include <Geom2dConvert_BSplineCurveToBezierCurve.hxx>
66 #include <Geom2d_BezierCurve.hxx>
67 #include <BRep_Tool.hxx>
68 #include <GeomProjLib.hxx>
69 #include <Geom2dAPI_InterCurveCurve.hxx>
70 #include <IntRes2d_IntersectionSegment.hxx>
71 #include <TDataStd_RealArray.hxx>
72 #include <TDF_CopyLabel.hxx>
73 #include <NCollection_Vector.hxx>
74 #include <TColStd_Array1OfInteger.hxx>
75 #include <Geom_BSplineCurve.hxx>
76 #include <TColgp_Array1OfPnt.hxx>
77 #include <AIS_ListOfInteractive.hxx>
78 #include <AIS_ListIteratorOfListOfInteractive.hxx>
79 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
80 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
81 #include <BRepBuilderAPI_MakePolygon.hxx>
82 #include <gp_GTrsf.hxx>
83 #include <Poly_Triangulation.hxx>
84 #include <IGESControl_Reader.hxx>
85 #include <IGESData_IGESModel.hxx>
86 #include <IGESData_IGESEntity.hxx>
87 #include <V3d_View.hxx>
88 #include <BRepFeat_SplitShape.hxx>
89 #include <BRepAlgoAPI_Section.hxx>
92 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
94 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
97 static Standard_Integer OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
99 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
100 if(myAISContext.IsNull()) {
101 di << "use 'vinit' command before " << argv[0] ;
105 Handle(Geom_Axis2Placement) aTrihedronAxis = new Geom_Axis2Placement(gp::XOY());
108 trsf1.SetTranslation(gp_Vec(100, 100, 0));
109 aTrihedronAxis->Transform(trsf1);
110 Handle(AIS_Trihedron) myTrihedron = new AIS_Trihedron(aTrihedronAxis);
111 myTrihedron->SetColor(Quantity_NOC_LIGHTSTEELBLUE4);
112 myTrihedron->SetSize(100);
113 myAISContext->Display(myTrihedron, Standard_True);
115 // TopoDS_Shape shape1 = (TopoDS_Shape) BRepPrimAPI_MakeBox(50,50,50);
116 TopoDS_Shape shape1 = BRepPrimAPI_MakeBox(50,50,50).Shape();
117 Handle(AIS_Shape) AS = new AIS_Shape(shape1);
118 AS->SetDisplayMode(1);
119 Graphic3d_MaterialAspect mat(Graphic3d_NOM_PLASTIC);
120 AS->SetMaterial(mat);
121 AS->SetColor(Quantity_NOC_RED);
122 myAISContext->Display(AS);
125 TouchTrsf.SetTranslation(gp_Vec(20, 20, 0));
127 myAISContext->ResetLocation(AS);
128 myAISContext->SetLocation(AS , TouchTrsf) ;
129 myAISContext->Redisplay(AS, Standard_True);
134 // Remove as bad version of QAAddOrRemoveSelected from QADraw
135 //static Standard_Integer OCC129 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
138 // di<<"Usage : " << argv[0] << " shape islocal\n";
142 // Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
144 // // ViewerTest_DoubleMapOfInteractiveAndName& aMap =
145 // // ViewerTest::GetDataMapOfAIS ();
146 // ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
148 // TCollection_AsciiString aName(argv[1]);
149 // Handle(AIS_InteractiveObject) AISObj;
151 // if(aMap.IsBound2(aName)) {
152 // AISObj = aMap.Find2(aName);
153 // if(AISObj.IsNull()){
154 // di<<"No interactive object \n";
158 // Standard_Integer aNum = -1;
160 // if(Draw::Atoi(argv[2])) {
161 // aNum = anAISCtx->OpenLocalContext();
164 // if(anAISCtx->HasOpenedContext()){
165 // anAISCtx->InitSelected();
166 // anAISCtx->AddOrRemoveSelected(AISObj);
169 // anAISCtx->InitCurrent();
170 // anAISCtx->AddOrRemoveCurrentObject(AISObj);
174 // // anAISCtx->CloseLocalContext(aNum);
179 // //select this shape:
181 // di<<"Use 'vdisplay' before";
186 static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
189 di<<"Usage: OCC136\n";
193 //create some primitives:
195 Standard_Real Size=100;
196 gp_Pnt P0(0,0,0), P1(Size,Size,Size);
198 TopoDS_Solid aBox = BRepPrimAPI_MakeBox(P0,P1);
200 TopoDS_Solid aSphere = BRepPrimAPI_MakeSphere (Size*0.5);
202 gp_Ax2 anAx2(P1, gp_Dir(1,1,1));
203 TopoDS_Solid aCone = BRepPrimAPI_MakeCone(anAx2, Size*0.7, Size*0.3, Size);
205 anAx2.SetLocation(gp_Pnt(Size,0,0));
206 anAx2.SetDirection(gp_Dir(-1,-1,1));
207 TopoDS_Solid aCyl = BRepPrimAPI_MakeCylinder(anAx2, Size*0.5, Size);
209 Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
210 if(anAISCtx.IsNull()){
211 di<<"Null interactive context. Use 'vinit' at first.\n";
215 if(anAISCtx->HasOpenedContext()) anAISCtx->CloseAllContexts();
216 anAISCtx->EraseAll();
218 //load primitives to context
219 Handle(AIS_Shape) aSh1 = new AIS_Shape(aBox);
220 anAISCtx->Display(aSh1);
222 Handle(AIS_Shape) aSh2 = new AIS_Shape(aSphere);
223 anAISCtx->Display(aSh2);
225 Handle(AIS_Shape) aSh3 = new AIS_Shape(aCone);
226 anAISCtx->Display(aSh3);
228 Handle(AIS_Shape) aSh4 = new AIS_Shape(aCyl);
229 anAISCtx->Display(aSh4);
232 anAISCtx->InitCurrent();
233 anAISCtx->AddOrRemoveCurrentObject(aSh1);
234 anAISCtx->AddOrRemoveCurrentObject(aSh2);
235 anAISCtx->AddOrRemoveCurrentObject(aSh3);
236 anAISCtx->AddOrRemoveCurrentObject(aSh4);
238 //remove all this objects from context
239 anAISCtx->Clear(aSh1, Standard_False);
240 anAISCtx->Clear(aSh2, Standard_False);
241 anAISCtx->Clear(aSh3, Standard_False);
242 anAISCtx->Clear(aSh4, Standard_False);
246 static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
248 printf("Usage: %s iges_input [name]\n",argv[0]);
251 Standard_Character *Ch = NULL;
254 Ch = new Standard_Character[strlen(argv[2])+3];
256 IGESToBRep_Reader IR;
257 IR.LoadFile (argv[1]);
260 TopoDS_Shape aTopShape = IR.OneShape();
261 TopExp_Explorer ex(aTopShape, TopAbs_EDGE);
262 Standard_Integer i=0;
263 for( ; ex.More(); ex.Next()){
264 const TopoDS_Edge &E = TopoDS::Edge(ex.Current());
265 BRepAdaptor_Curve aCurve(E);
266 GCPnts_UniformDeflection plin(aCurve, 0.1);
267 di << "Num points = " << plin.NbPoints() << "\n";
270 Sprintf(Ch,"%s_%i",argv[2],1);
277 //====================================================
279 // Following code is inserted from
280 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
281 // ( 75455 Apr 16 18:59)
283 //====================================================
286 #include <BRepTools_WireExplorer.hxx>
287 #include <BRep_Tool.hxx>
288 #include <GCPnts_UniformAbscissa.hxx>
289 #include <TopExp.hxx>
292 // usage : OCC105 shape
295 //GCPnts_UniformAbscissa returns bad end point foe first edge. Its value is
297 //Value Pnt = -338.556216693211 -394.465571897208 0
299 //Value Pnt = -307.47165394 -340.18073533 0
301 static int OCC105(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
304 di<<"Usage : OCC105 shape\n";
307 // TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get("aa.brep"));
308 TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1]));
309 Standard_Real l = 0.5; //Draw::Atof(argv[2]);
310 // Find the first vertex of the wire
311 BRepTools_WireExplorer wire_exp(myTopoDSWire);
314 TopoDS_Vertex vw1, vw2;
315 TopExp::Vertices(myTopoDSWire,vw1,vw2);
316 TopoDS_Vertex ve1, ve2;
317 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
318 TopExp::Vertices(edge,ve1,ve2);
319 if (vw1.IsSame(ve1) || vw1.IsSame(ve2))
322 // assert(vw2.IsSame(ve1) || vw2.IsSame(ve2));
326 for ( ; wire_exp.More(); wire_exp.Next())
328 di << "\n\n New Edge \n" << "\n";
329 Standard_Real newufirst, newulast;
330 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
331 Standard_Real ufirst, ulast;
332 Handle(Geom_Curve) acurve;
333 TopoDS_Vertex ve1, ve2;
334 TopExp::Vertices(edge,ve1,ve2);
335 if (ve1.IsSame(vlast))
337 acurve = BRep_Tool::Curve(edge, ufirst, ulast);
344 // assert(ve2.IsSame(vlast));
345 // assert ( wire_exp.Orientation( ) == TopAbs_REVERSED );
346 acurve = BRep_Tool::Curve( edge, ufirst, ulast );
347 newufirst = acurve->ReversedParameter( ufirst );
348 newulast = acurve->ReversedParameter( ulast );
349 acurve = acurve->Reversed( );
353 GeomAdaptor_Curve curve;
354 GCPnts_UniformAbscissa algo;
356 algo.Initialize( curve, l, newufirst, newulast );
358 di << "Not Done!!!" << "\n";
359 for (Standard_Integer Index = 1; Index<=algo.NbPoints();Index++) {
360 Standard_Real t = algo.Parameter(Index);
361 gp_Pnt pt3 = curve.Value(t);
362 di << "Parameter t = " << t << "\n";
363 di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z() << "\n";
370 #include <TColStd_SequenceOfTransient.hxx>
371 #include <GeomFill_Pipe.hxx>
372 static int pipe_OCC9 (Draw_Interpretor& di,
373 Standard_Integer n, const char ** a)
376 di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]" << "\n";
380 TColStd_SequenceOfTransient aCurveSeq;
382 for (i=2 ; i<=4; i++) {
383 Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast( DrawTrSurf::Get(a[i]) );
385 di << a[i] << " is not a curve" << "\n";
388 aCurveSeq.Append(aC);
391 GeomFill_Pipe aPipe(Handle(Geom_Curve)::DownCast( aCurveSeq(1) ),
392 Handle(Geom_Curve)::DownCast( aCurveSeq(2) ),
393 Handle(Geom_Curve)::DownCast( aCurveSeq(3) ),
397 aPipe.Perform(Draw::Atof (a[6]), Standard_True);
399 aPipe.Perform(Standard_True/*, Standard_True*/);
402 Handle(Geom_Surface) aSurf = aPipe.Surface();
404 DrawTrSurf::Set(a[1], aSurf);
408 //======================================================================
410 // usage : OCC125 shell
411 //======================================================================
412 #include <ShapeFix_Shell.hxx>
414 Standard_Integer OCC125(Draw_Interpretor& di ,
419 di<<" Use OCC125 shell";
423 TopoDS_Shape S = DBRep::Get(a[1]);
426 di<<" Null shape is not allowed";
432 if (aT!=TopAbs_SHELL) {
433 di<<" Shape Type must be SHELL";
437 const TopoDS_Shell& aShell = TopoDS::Shell(S);
439 Standard_Boolean isAccountMultiConex, bNonManifold, bResult;
441 isAccountMultiConex=Standard_True;
442 bNonManifold=Standard_False;
444 Handle (ShapeFix_Shell) aFix = new ShapeFix_Shell(aShell);
445 bResult=aFix->FixFaceOrientation(aShell, isAccountMultiConex, bNonManifold);
447 di<<"bResult="<<(Standard_Integer)bResult;
450 aShape=aFix->Shape();
452 TCollection_AsciiString aName(a[1]), aDef("_sh"), aRName;
455 DBRep::Set (aRName.ToCString(), aShape);
456 di<<aRName.ToCString();
461 #include <BRepLib_FindSurface.hxx>
462 #include <BRepBuilderAPI_MakeFace.hxx>
463 Standard_Integer OCC157(Draw_Interpretor& di,
466 //static Standard_Integer findplanarsurface(Draw_Interpretor&, Standard_Integer n, const char ** a)
469 di << "bad number of arguments" <<"\n";
473 // try to read a shape:
474 TopoDS_Shape inputShape=DBRep::Get(a[2]);
475 if (inputShape.IsNull() || inputShape.ShapeType() != TopAbs_WIRE) {
476 di << "Invalid input shape"<< "\n";
479 Standard_Real toler = Draw::Atof(a[3]);
480 TopoDS_Wire aWire = TopoDS::Wire(inputShape);
481 BRepLib_FindSurface FS(aWire, toler, Standard_True);
483 di<<"OCC157: OK; Planar surface is found"<<"\n";
484 Handle(Geom_Surface) aSurf = FS.Surface();
485 BRepBuilderAPI_MakeFace aMakeFace(aSurf,aWire,Standard_True);
486 if(aMakeFace.IsDone()) {
487 TopoDS_Face aFace = aMakeFace.Face();
488 DBRep::Set(a[1],aFace);
491 else di<<"OCC157: ERROR; Planar surface is not found with toler = "<<toler <<"\n";
496 // #include <MyCommandsCMD.h>
497 #include <ShapeFix_Shape.hxx>
498 #include <BRepOffset_MakeOffset.hxx>
499 #include <BRepOffsetAPI_MakeOffset.hxx>
500 #include <BRepOffset_Mode.hxx>
501 #include <GeomAbs_JoinType.hxx>
502 #include <AIS_Shape.hxx>
504 #include <BRepTools.hxx>
506 Standard_Integer OCC165(Draw_Interpretor& di ,
511 //=======================================================================
513 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv);
515 // void MyOffsets_Commands(Draw_Interpretor& theCommands)
517 // theCommands.Add("yoffset" , "yoffset" , __FILE__, YOffset, " Offset on Z Direction");
520 //=======================================================================
522 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
526 di <<"Usage : " << a[0] << " [file]"<<"\n";
531 #define _OFFSET_TELCO_
532 #ifdef _OFFSET_TELCO_
534 Standard_CString file = a[1];
536 BRep_Builder aBuilder;
537 TopoDS_Shape theShape;
538 //BRepTools::Read(theShape, Standard_CString("/dn02/users_SUN/inv/3/OCC165/2d_tr_line.brep"), aBuilder);
539 BRepTools::Read(theShape, file, aBuilder);
540 DBRep::Set("shape", theShape);
542 TopoDS_Wire theWire = TopoDS::Wire(theShape);
544 Standard_Real anOffset = 1.5;
548 Standard_Real xA = 0.0, xB = 200.0, xC = 200.0, xD = 0.0,
549 yA = 0.0, yB = 0.0, yC = 200.0, yD = 200.0,
550 zA = 0.0, zB = 0.0, zC = 0.0, zD = 0.0;
552 BRepBuilderAPI_MakePolygon theSquare;
553 TopoDS_Vertex theA = BRepBuilderAPI_MakeVertex(gp_Pnt(xA, yA, zA));
555 TopoDS_Vertex theB = BRepBuilderAPI_MakeVertex(gp_Pnt(xB, yB, zB));
557 TopoDS_Vertex theC = BRepBuilderAPI_MakeVertex(gp_Pnt(xC, yC, zC));
559 TopoDS_Vertex theD = BRepBuilderAPI_MakeVertex(gp_Pnt(xD, yD, zD));
563 TopoDS_Wire theWire = theSquare.Wire();
565 Standard_Real anOffset = 10;
568 #endif /* _OFFSET_TELCO_ */
571 TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire).Face();
572 DBRep::Set("face", theFace);
575 Standard_Real anAlt = 0.;
576 GeomAbs_JoinType theJoin = GeomAbs_Intersection;
577 //GeomAbs_Intersection; //GeomAbs_Arc;
578 BRepOffsetAPI_MakeOffset aMakeOffset(theFace, theJoin);
579 aMakeOffset.AddWire(theWire);
581 aMakeOffset.Perform(anOffset, anAlt);
583 TopoDS_Shape theOffsetShapePos = aMakeOffset.Shape();
584 DBRep::Set("offset", theOffsetShapePos);
589 #include<BRepAlgoAPI_Cut.hxx>
590 #include<BRepAlgo_Cut.hxx>
592 #include<BRepPrimAPI_MakeHalfSpace.hxx>
593 #include<Handle_Geom_CartesianPoint.hxx>
594 #include<Geom_CartesianPoint.hxx>
595 #include<AIS_Point.hxx>
597 #include <BRepBuilderAPI_MakeEdge.hxx>
598 #include <BRepBuilderAPI_MakeWire.hxx>
599 #include <BRepBuilderAPI_MakeFace.hxx>
601 static Standard_Integer OCC297 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
605 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
606 if(myAISContext.IsNull()) {
607 di << "use 'vinit' command before " << argv[0] << "\n";
612 gp_Pnt pt1_(250.,250.,0.);
613 gp_Pnt pt2_(-250.,250.,0.);
614 gp_Pnt pt3_(-250.,-250.,0.);
615 gp_Pnt pt4_(250.,-250.,0.);
616 BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
617 BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
618 BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
619 BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
621 BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
622 BRepBuilderAPI_MakeFace face_(wire_);
623 TopoDS_Face sh_ = face_.Face();
629 g_pnt = gp_Pnt(0,0,-100);
631 g_pnt = gp_Pnt(0,0,100);
633 myAISContext->EraseAll(Standard_False);
634 Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
635 Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
636 myAISContext->Display(AISPoint);
638 BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
639 TopoDS_Solid sol1_ = half_.Solid();
640 // Handle(AIS_Shape) AISHalf = new AIS_Shape(sol1_);
641 // AISHalf->SetColor(Quantity_NOC_GREEN);
642 // myAISContext->Display(AISHalf);
644 DBRep::Set("Face",sol1_);
646 gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
648 Standard_Real x=0., y=0., z=-80.;
650 BRepPrimAPI_MakeBox box(gp_Pnt(x,y,z),gp_Pnt(x+150,y+200,z+200));
651 // Handle(AIS_Shape) AISBox = new AIS_Shape(box);
652 // AISBox->SetColor(Quantity_NOC_BLUE1);
653 // myAISContext->Display(AISBox);
655 DBRep::Set("Box",box.Shape());
657 // BRepAlgoAPI_Cut cut( sol1_, box.Shape() );
658 // //BRepAlgoAPI_Cut cut( box.Shape(), sol1_ );
659 // TopoDS_Shape sh1_ = cut.Shape();
660 // Handle(AIS_Shape) AISCut = new AIS_Shape(sh1_);
661 // AISCut->SetColor(Quantity_NOC_RED);
662 // myAISContext->Display(AISCut);
664 // DBRep::Set("Cut",sh1_);
669 #include<GProp_GProps.hxx>
670 #include<BRepGProp.hxx>
672 static Standard_Integer OCC305 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
677 di <<"Usage : " << argv[0] << " file"<<"\n";
680 Standard_CString file = argv[1];
682 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
683 if(myAISContext.IsNull()) {
684 di << "use 'vinit' command before " << argv[0] << "\n";
689 BRep_Builder builder;
690 //BRepTools::Read(sh, "/dn02/users_SUN/inv/3/OCC305/testc.brep", builder);
691 BRepTools::Read(sh, file, builder);
694 builder.MakeWire(wire);
696 TopoDS_Vertex vt1, vt2;
697 TopExp_Explorer wex(sh, TopAbs_EDGE);
698 for(;wex.More();wex.Next())
700 ed = TopoDS::Edge(wex.Current());
701 TopExp::Vertices(ed, vt1, vt2);
702 builder.UpdateVertex(vt1, 0.01);
703 builder.UpdateVertex(vt2, 0.01);
704 builder.UpdateEdge(ed, 0.01);
705 builder.Add(wire, ed);
709 BRepGProp::LinearProperties(ed, lprop);
710 printf("\n length = %f", lprop.Mass());
712 DBRep::Set("Wire",wire);
713 // Handle(AIS_Shape) res = new AIS_Shape( wire );
714 // aContext->SetColor( res, Quantity_NOC_RED );
715 // aContext->Display( res );
717 // BRepOffsetAPI_MakeOffset off(wire, GeomAbs_Arc);
718 // off.Perform(0.5, 0);
720 // printf("\n IsDone = %d", off.IsDone());
722 // res = new AIS_Shape( sh );
723 // aContext->SetColor( res, Quantity_NOC_GREEN );
724 // aContext->Display( res );
730 static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
733 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
734 if(myAISContext.IsNull()) {
735 di << "use 'vinit' command before " << argv[0];
739 BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
740 Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape());
741 myAISContext->Display(anAISBox, 1);
742 anAISBox->SetSelectionMode(-1);
743 Standard_Integer myLocContInd = myAISContext->OpenLocalContext();
744 myAISContext->CloseLocalContext(myLocContInd);
745 Standard_Integer aSelMode = ((Handle(AIS_InteractiveObject)) anAISBox)->SelectionMode();
752 #include <TDocStd_Document.hxx>
753 #include <DDocStd.hxx>
754 #include <PCDM_StoreStatus.hxx>
755 #include <TDocStd_Application.hxx>
757 static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
760 di << "Usage: " << a[0] << " Doc" << "\n";
764 Handle(TDocStd_Document) D;
765 if (!DDocStd::GetDocument(a[1],D)) return 1;
767 Handle(TDocStd_Application) A;
768 if (!DDocStd::Find(A)) return 1;
770 TCollection_ExtendedString theStatusMessage;
772 di << "this document has never been saved" << "\n";
775 PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
776 if (theStatus != PCDM_SS_OK ) {
777 switch ( theStatus ) {
778 case PCDM_SS_DriverFailure: {
779 di << "Error saving document: Could not store , no driver found to make it" << "\n";
782 case PCDM_SS_WriteFailure: {
783 di << "Error saving document: Write access failure" << "\n";
786 case PCDM_SS_Failure: {
787 di << "Error saving document: Write failure" << "\n" ;
790 case PCDM_SS_Doc_IsNull: {
791 di << "Error saving document: No document to save" << "\n";
794 case PCDM_SS_No_Obj: {
795 di << "Error saving document: No objects written" << "\n";
798 case PCDM_SS_Info_Section_Error: {
799 di << "Error saving document: Write info section failure" << "\n" ;
810 static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
813 di << "Usage: " << a[0] << " Doc Path" << "\n";
817 Handle(TDocStd_Document) D;
818 if (!DDocStd::GetDocument(a[1],D)) return 1;
820 TCollection_ExtendedString path (a[2]);
821 Handle(TDocStd_Application) A;
822 if (!DDocStd::Find(A)) return 1;
824 TCollection_ExtendedString theStatusMessage;
825 PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
826 if (theStatus != PCDM_SS_OK ) {
827 switch ( theStatus ) {
828 case PCDM_SS_DriverFailure: {
829 di << "Error saving document: Could not store , no driver found to make it" << "\n";
832 case PCDM_SS_WriteFailure: {
833 di << "Error saving document: Write access failure" << "\n";
836 case PCDM_SS_Failure: {
837 di << "Error saving document: Write failure" << "\n" ;
840 case PCDM_SS_Doc_IsNull: {
841 di << "Error saving document: No document to save" << "\n";
844 case PCDM_SS_No_Obj: {
845 di << "Error saving document: No objects written" << "\n";
848 case PCDM_SS_Info_Section_Error: {
849 di << "Error saving document: Write info section failure" << "\n" ;
861 #include <BRepClass3d_SolidClassifier.hxx>
863 Standard_Integer OCC299bug (Draw_Interpretor& theDi,
864 Standard_Integer theArgNb,
865 const char** theArgVec)
869 theDi << "Usage : " << theArgVec[0] << " Solid Point [Tolerance=1.e-7]\n";
873 TopoDS_Shape aS = DBRep::Get (theArgVec[1]);
876 theDi << " Null Shape is not allowed here\n";
879 else if (aS.ShapeType() != TopAbs_SOLID)
881 theDi << " Shape type must be SOLID\n";
885 gp_Pnt aP (8., 9., 10.);
886 if (!DrawTrSurf::GetPoint (theArgVec[2], aP))
888 theDi << " Null Point is not allowed here\n";
891 const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : 1.e-7;
893 BRepClass3d_SolidClassifier aSC (aS);
894 aSC.Perform (aP, aTol);
898 case TopAbs_IN: theDi << "The point is IN shape\n"; return 0;
899 case TopAbs_OUT: theDi << "The point is OUT of shape\n"; return 0;
900 case TopAbs_ON: theDi << "The point is ON shape\n"; return 0;
902 default: theDi << "The point is UNKNOWN shape\n"; return 0;
906 #include <OSD_Process.hxx>
907 #include <OSD_Path.hxx>
909 static Standard_Integer OCC309bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
912 di << "Usage: " << a[0] << "\n";
916 OSD_Path d = p.CurrentDirectory();
917 TCollection_AsciiString s;
919 di << "*" << s.ToCString() << "*" << "\n";
922 di << "*" << s.ToCString() << "*" <<"\n";
926 static Standard_Integer OCC310bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
929 di << "Usage: " << a[0] << "\n";
932 OSD_Path p("/where/you/want/tmp/qwerty/tmp/");
933 di << p.Trek().ToCString() << "\n";
935 di << p.Trek().ToCString() << "\n";
939 #include <BRepAlgoAPI_Fuse.hxx>
940 #include <BRepAlgoAPI_Common.hxx>
941 #include <BRepAlgo_Fuse.hxx>
942 #include <BRepAlgo_Common.hxx>
944 static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
947 // cout << "Usage: " << a[0] << endl;
950 if(nb < 1 || nb > 2) {
951 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
954 Standard_Boolean IsBRepAlgoAPI = Standard_True;
956 Standard_Integer IsB = Draw::Atoi(a[1]);
958 IsBRepAlgoAPI = Standard_False;
962 BRepPrimAPI_MakeBox box1( 100, 100, 100 );
963 BRepPrimAPI_MakeBox box2( gp_Pnt( 50, 50,50 ), 200, 200, 200 );
965 TopoDS_Shape shape1 = box1.Shape();
966 TopoDS_Shape shape2 = box2.Shape();
968 //#if ! defined(BRepAlgoAPI_def01)
969 // TopoDS_Shape fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
970 // TopoDS_Shape comm = BRepAlgoAPI_Common( shape1, shape2 );
972 // TopoDS_Shape fuse = BRepAlgo_Fuse( shape1, shape2 );
973 // TopoDS_Shape comm = BRepAlgo_Common( shape1, shape2 );
975 TopoDS_Shape fuse,comm;
977 di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )" <<"\n";
978 di << "comm = BRepAlgoAPI_Common( shape1, shape2 )" <<"\n";
979 fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
980 comm = BRepAlgoAPI_Common( shape1, shape2 );
982 di << "fuse = BRepAlgo_Fuse( shape1, shape2 )" <<"\n";
983 fuse = BRepAlgo_Fuse( shape1, shape2 );
984 di << "comm = BRepAlgo_Common( shape1, shape2 )" <<"\n";
985 comm = BRepAlgo_Common( shape1, shape2 );
991 #include <ShapeAnalysis_Edge.hxx>
993 static Standard_Integer OCC333bug (Draw_Interpretor& di, Standard_Integer n, const char ** a)
997 di << "Usage: " << a[0] << " edge1 edge2 [toler domaindist]" << "\n";
1000 TopoDS_Shape Sh1 = DBRep::Get(a[1]);
1001 TopoDS_Shape Sh2 = DBRep::Get(a[2]);
1002 if(Sh1.IsNull() || Sh2.IsNull()) {
1004 di<<"Invalid arguments"<<"\n";
1007 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
1008 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
1009 if(e1.IsNull() || e2.IsNull()) {
1011 di<<"Invalid type of arguments"<<"\n";
1014 Standard_Real aTol = Precision::Confusion();
1015 Standard_Real aDistDomain = 0.0;
1016 Standard_Integer k = 3;
1018 aTol = Draw::Atof(a[k++]);
1020 aDistDomain = Draw::Atof(a[k++]);
1022 ShapeAnalysis_Edge sae;
1023 if(sae.CheckOverlapping(e1,e2,aTol,aDistDomain)) {
1024 if(aDistDomain ==0.0) {
1026 di<<"Edges is overlaping comletly"<<"\n";
1029 di<<"Edges is overlaped"<<"\n";
1030 di<<"with tolerance = "<<aTol<<"\n";
1031 di<<"on segment length = "<<aDistDomain<<"\n";
1035 di<<"Edges is not overlaped"<<"\n";
1041 #include <DDocStd_DrawDocument.hxx>
1042 #include <TDataStd_Name.hxx>
1044 #include <XCAFDoc_ShapeTool.hxx>
1045 #include <XCAFDoc_DocumentTool.hxx>
1046 #include <TDF_LabelSequence.hxx>
1047 #include <TPrsStd_AISPresentation.hxx>
1048 #include <TDF_Data.hxx>
1049 #include <TDF_Label.hxx>
1050 #include <XCAFPrs_Driver.hxx>
1052 //------------------------------------------------------------------------------------------
1055 //------------------------------------------------------------------------------------------
1056 static Standard_Integer OCC363 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1061 // 1. Verufy amount of arguments
1062 if(argc < 3) { di <<"Error OCC363 : Use : OCC363 document filename\n"; return 1; }
1064 // 2. Retrieve DDocStd application
1065 Handle(TDocStd_Application) App;
1066 if (!DDocStd::Find(App)) { di << "Error OCC363 : There is no current DDocStd application\n";return 1;}
1069 TCollection_ExtendedString name(argv[2]);
1070 Handle(TDocStd_Document) Doc;
1071 if(App->Open(name, Doc) != PCDM_RS_OK) { di << "Error OCC363 : document was not opened successfully\n"; return 1;}
1072 Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(Doc);
1073 TDataStd_Name::Set(Doc->GetData()->Root(),argv[1]);
1074 Draw::Set(argv[1],DD);
1076 // 4. Create prsentations
1077 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1078 TDF_LabelSequence seq;
1079 shapes->GetFreeShapes ( seq );
1080 Handle(TPrsStd_AISPresentation) prs;
1081 for ( Standard_Integer i=1; i <= seq.Length(); i++ )
1082 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) )
1083 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
1085 catch(Standard_Failure) { di << "FAULTY OCC363 : Exception during reading document.\n";return 0;}
1087 di << "OCC363 OK\n";
1092 ////======================================================================================
1093 //// Function : OCC372
1095 ////======================================================================================
1096 //static Standard_Integer OCC372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1100 // OCC_CATCH_SIGNALS
1101 // // 1. Verufy amount of arguments
1102 // if(argc < 2) {di << "OCC372 FAULTY. Use : OCC372 brep-file";return 0;}
1106 // TopoDS_Shape Ref;
1107 // BRepTools::Read(Ref, argv[1], B);
1109 // // 3. Calculate location of aP3d in relation to the solid
1110 // gp_Pnt aP3d(6311.4862583184, -2841.3092756034, 16.461053497188);
1111 // BRepClass3d_SolidClassifier SC(Ref);
1112 // SC.Perform(aP3d, 1e-7);
1114 // // 4. Check returned state. The point must be inside the solid.
1115 // TopAbs_State aState=SC.State();
1119 // di<<"OCC372 FAULTY. aState = TopAbs_OUT";
1122 // di<<"OCC372 FAULTY. aState = TopAbs_ON";
1125 // di<<"OCC372 OK. aState = TopAbs_IN" ;
1128 // di<<"OCC372 FAULTY. aState = UNKNOWN";
1132 // catch (Standard_Failure) { di<<"OCC372 FAULTY. Exception raised"; }
1137 #include <BRepTopAdaptor_FClass2d.hxx>
1139 //======================================================================================
1140 // Function : OCC377
1142 //======================================================================================
1143 static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1148 // 1. Verify validity of arguments
1149 if ( argc < 1 ) {di << "Error OCC377. Use OCC377 file x y precuv \n";return 0;}
1151 // 2. Initialize parameters
1153 p2d.SetX ( Draw::Atof(argv[2]) );
1154 p2d.SetY ( Draw::Atof(argv[3]) );
1155 Standard_Real precuv = Draw::Atof (argv[4] );
1160 BRepTools::Read ( Shape, argv[1], B );
1162 // 4. Verify whether enrtry point is on wire and reversed ones (indeed results of veridying must be same)
1163 TopExp_Explorer exp;
1164 Standard_Integer i=1;
1165 for (exp.Init(Shape.Oriented(TopAbs_FORWARD),TopAbs_WIRE); exp.More(); exp.Next(), i++)
1167 // 4.1. Verify whether enrtry point is on wire
1168 const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
1169 TopoDS_Face newFace = TopoDS::Face(Shape.EmptyCopied());
1171 TopAbs_Orientation orWire = wir.Orientation();
1172 newFace.Orientation(TopAbs_FORWARD);
1175 BRepTopAdaptor_FClass2d FClass2d1(newFace,precuv);
1176 TopAbs_State stat1 = FClass2d1.PerformInfinitePoint();
1177 //di << "Wire " << i << ": Infinite point is " <<
1178 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1180 TCollection_AsciiString TmpString;
1181 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1182 di << "Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1184 stat1 = FClass2d1.Perform(p2d);
1185 //di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1186 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1189 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1190 di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1192 // 4.2. Verify whether enrtry point is on reversed wire
1193 newFace = TopoDS::Face(Shape.EmptyCopied());
1194 newFace.Orientation(TopAbs_FORWARD);
1195 orWire = TopAbs::Reverse(orWire);
1196 B.Add(newFace,wir.Oriented(orWire));
1197 BRepTopAdaptor_FClass2d FClass2d2(newFace,precuv);
1198 TopAbs_State stat2 = FClass2d2.PerformInfinitePoint();
1199 //di << "Reversed Wire " << i << ": Infinite point is " <<
1200 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1203 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1204 di << "Reversed Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1206 stat2 = FClass2d2.Perform(p2d);
1207 //di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1208 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1211 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1212 di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1214 // 4.3. Compare results (they must be same)
1215 if(stat1 ==stat2) di << "OCC377 OK" << "\n";
1216 else {di << "OCC377 FAULTY" << "\n"; return 0;}
1219 catch(Standard_Failure)
1221 di << "OCC377 Exception";
1227 #include <ShapeUpgrade_ShapeDivideAngle.hxx>
1228 #include <ShapeBuild_ReShape.hxx>
1230 //=======================================================================
1233 //=======================================================================
1234 static Standard_Integer OCC22 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1239 // 1. Verify arguments of the command
1240 if (argc < 5) { di << "OCC22 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation"; return 0;}
1242 Standard_Boolean aConsiderLocation;
1243 if(strcmp(argv[4], "0")==0) aConsiderLocation = Standard_False;
1244 else aConsiderLocation = Standard_True;
1246 // 2. Iniitialize aShapeUpgrade
1247 ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(M_PI/2.);
1249 aShapeUpgrade.SetPrecision (Precision::Confusion());
1251 aShapeUpgrade.SetMaxTolerance(0.1);
1252 // subshapes to be divided
1253 TopoDS_Shape aSubShapesToBeDivided = DBRep::Get(argv[3]);
1254 if(aSubShapesToBeDivided.IsNull()) {di << "OCC22 FAULTY. Compound of subshapes to be divided is not exist. Please, verify input values. \n";return 0;}
1255 aShapeUpgrade.Init(aSubShapesToBeDivided);
1257 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1258 aShapeUpgrade.SetContext(aReshape);
1259 if(aConsiderLocation) aReshape->ModeConsiderLocation() = Standard_True;
1261 // 3. Perform splitting
1262 if (aShapeUpgrade.Perform (Standard_False)) di << "Upgrade_SplitRevolution_Done \n";
1263 else if (aShapeUpgrade.Status (ShapeExtend_OK)) di << "Upgrade_SplitRevolution_OK \n";
1264 else if (aShapeUpgrade.Status (ShapeExtend_FAIL)) { di << "OCC22 FAULTY. Operation failed. Angle was not divided\n";return 0;}
1266 // 4. Perform rebuilding shape
1267 // 4.1. Retrieve Shape
1268 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1269 if(anInitShape.IsNull()) { di << "OCC22 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1270 // 4.2 Rebuid retrieved shape
1271 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1272 // 4.3. Create result Draw shape
1273 DBRep::Set(argv[1], aResultShape);
1275 catch (Standard_Failure) {di << "OCC22 Exception \n" ;return 0;}
1281 #include <ShapeProcess_OperLibrary.hxx>
1282 #include <ShapeProcess_ShapeContext.hxx>
1283 #include <ShapeProcess.hxx>
1285 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
1286 #include <BRepMesh_IncrementalMesh.hxx>
1288 //=======================================================================
1291 //=======================================================================
1292 static Standard_Integer OCC24 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1297 // 1. Verify amount of arguments of the command
1298 if (argc < 6) { di << "OCC24 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapes ResourceFileName SequenceName"; return 0;}
1300 // 2. Retrieve parameters
1302 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1303 if(anInitShape.IsNull()) { di << "OCC24 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1304 // compound of subshapes
1305 TopoDS_Shape aSubShapes = DBRep::Get(argv[3]);
1306 if(aSubShapes.IsNull()) {di << "OCC24 FAULTY. Compound of subshapes is not exist. Please, verify input values. \n";return 0;}
1307 // name of resource file
1308 const char* aResourceFile = argv[4];
1309 // name of sequence from resource file to be executed
1310 const char* aSequenceName = argv[5];
1312 // 3. Initialize ShapeContext and perform sequence of operation specified with resource file
1313 ShapeProcess_OperLibrary::Init();
1314 Handle(ShapeProcess_ShapeContext) aShapeContext = new ShapeProcess_ShapeContext (aSubShapes, aResourceFile);
1315 aShapeContext->SetDetalisation (TopAbs_EDGE);
1316 ShapeProcess::Perform (aShapeContext, aSequenceName);
1318 // 4. Rebuild initil shape in accordance with performed operation
1319 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1320 TopTools_DataMapIteratorOfDataMapOfShapeShape anIter (aShapeContext->Map());
1321 for (; anIter.More(); anIter.Next())
1322 aReshape->Replace(anIter.Key(), anIter.Value());
1323 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1325 // 5 Create resultant Draw shape
1326 DBRep::Set(argv[1], aResultShape);
1329 catch (Standard_Failure) {di << "OCC24 Exception \n" ;return 0;}
1334 //=======================================================================
1336 //purpose : Verify whether exception occurs during building mesh
1337 //=======================================================================
1338 static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1343 // 1. Verify amount of arguments of the command
1344 if (argc < 2) { di << "OCC369 FAULTY. Use : OCC369 Shape \n"; return 0;}
1346 // 2. Retrieve shape
1347 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1348 if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
1351 BRepMesh_IncrementalMesh aMesh(aShape, 0.2, Standard_True, M_PI/6);
1354 catch (Standard_Failure) {di << "OCC369 Exception \n" ;return 0;}
1356 di << "OCC369 OK \n";
1360 #include <math_Vector.hxx>
1361 #include <math_Matrix.hxx>
1362 static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1365 di<<"Usage : " << argv[0] << " LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix\n";
1368 Standard_Integer LowerVector = Draw::Atoi(argv[1]);
1369 Standard_Integer UpperVector = Draw::Atoi(argv[2]);
1370 Standard_Real InitialValueVector = Draw::Atof(argv[3]);
1371 Standard_Integer LowerRowMatrix = Draw::Atoi(argv[4]);
1372 Standard_Integer UpperRowMatrix = Draw::Atoi(argv[5]);
1373 Standard_Integer LowerColMatrix = Draw::Atoi(argv[6]);
1374 Standard_Integer UpperColMatrix = Draw::Atoi(argv[7]);
1375 Standard_Real InitialValueMatrix = Draw::Atof(argv[8]);
1377 math_Vector Vector1(LowerVector, UpperVector);
1378 math_Vector Vector2(LowerVector, UpperVector);
1380 math_Vector Vector(LowerVector, UpperVector, InitialValueVector);
1381 math_Matrix Matrix(LowerRowMatrix, UpperRowMatrix, LowerColMatrix, UpperColMatrix, InitialValueMatrix);
1383 //Vector.Dump(cout);
1386 //Matrix.Dump(cout);
1389 Vector1.Multiply(Vector, Matrix);
1391 //Vector1.Dump(cout);
1392 Standard_SStream aSStream1;
1393 Vector1.Dump(aSStream1);
1397 if (Matrix.RowNumber() > 1) {
1398 Matrix(Matrix.LowerRow() + 1, Matrix.LowerCol()) += 1.;
1400 Vector2.TMultiply(Vector, Matrix);
1402 //Vector2.Dump(cout);
1403 Standard_SStream aSStream2;
1404 Vector2.Dump(aSStream2);
1411 #include <GeomPlate_BuildPlateSurface.hxx>
1412 //=======================================================================
1415 //=======================================================================
1416 static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
1421 GeomPlate_BuildPlateSurface aBuilder;
1424 catch (Standard_RangeError) { di << "OCC525 Exception \n" ;return 0; }
1425 //catch (...) { di << "OCC525 Exception \n" ;return 0; }
1427 di << "OCC525 OK \n";
1431 #include <BRepPrimAPI_MakeWedge.hxx>
1432 #include <gce_MakeRotation.hxx>
1433 #include <gce_MakeTranslation.hxx>
1434 #include <BRepBuilderAPI_Transform.hxx>
1435 #include <BRepPrimAPI_MakeWedge.hxx>
1436 #include <BRepAlgoAPI_Fuse.hxx>
1437 #include <BRepAlgoAPI_Cut.hxx>
1438 #include <BRepAlgo_Fuse.hxx>
1439 #include <BRepAlgo_Cut.hxx>
1440 //=======================================================================
1443 //=======================================================================
1444 static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1447 // di<<"Usage : " << argv[0] << " shape1 shape2 shape3\n";
1450 if(argc < 4 || argc > 5) {
1451 di << "Usage : " << argv[0] << " shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1454 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1456 Standard_Integer IsB = Draw::Atoi(argv[4]);
1458 IsBRepAlgoAPI = Standard_False;
1459 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1461 // di << "Error: There is not BRepAlgo_Cut class" << "\n";
1467 double xperiod = 1.0;
1468 double yperiod = 1.0;
1469 double sub_thick = 0.5;
1472 //TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick );
1473 TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick ).Shape();
1475 // --------------------------------------------------------------------
1478 //TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1479 // 0.1, 0.1 , 0.4, 0.4 );
1480 TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1481 0.1, 0.1 , 0.4, 0.4 ).Shape();
1483 gp_Trsf rotate = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1484 gp_Dir(1.0,0.0,0.0),
1487 gp_Trsf translate = gce_MakeTranslation(gp_Pnt( 0.0, -0.5, 0.0),
1488 gp_Pnt( 0.25, 0.25, 0.5)
1491 rotate.PreMultiply( translate );
1493 TopoDS_Shape wedge1a = BRepBuilderAPI_Transform( wedge1, rotate );
1495 if (wedge1a.IsNull()) {
1496 di<<" Null shape1 is not allowed\n";
1499 DBRep::Set(argv[1], wedge1a);
1501 // --------------------------------------------------------------------
1504 //TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1505 // 0.1, 0.1 , 0.4, 0.4 );
1506 TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1507 0.1, 0.1 , 0.4, 0.4 ).Shape();
1509 gp_Trsf rotate2 = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1510 gp_Dir(1.0,0.0,0.0),
1513 gp_Trsf translate2 = gce_MakeTranslation(gp_Pnt( 0.0, 0.0, 0.0),
1514 gp_Pnt( 0.25, 0.25, 0.5)
1517 rotate2.PreMultiply( translate2 );
1519 TopoDS_Shape wedge2a = BRepBuilderAPI_Transform( wedge2, rotate2 );
1521 if (wedge2a.IsNull()) {
1522 di<<" Null shape2 is not allowed\n";
1525 DBRep::Set(argv[2], wedge2a);
1529 //#if ! defined(BRepAlgoAPI_def01)
1530 // TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1532 // TopoDS_Shape wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1534 TopoDS_Shape wedge_common;
1535 if (IsBRepAlgoAPI) {
1536 di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)" <<"\n";
1537 wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1539 di << "wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a)" <<"\n";
1540 wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1543 // remove wedge area from substrate
1544 //#if ! defined(BRepAlgoAPI_def01)
1545 // TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1547 // TopoDS_Shape sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1549 TopoDS_Shape sub_etch1;
1550 if (IsBRepAlgoAPI) {
1551 di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)" <<"\n";
1552 sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1554 di << "sub_etch1 = BRepAlgo_Cut(substrate, wedge_common)" <<"\n";
1555 sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1558 if (sub_etch1.IsNull()) {
1559 di<<" Null shape3 is not allowed\n";
1562 DBRep::Set(argv[3], sub_etch1);
1567 #include <Standard_GUID.hxx>
1568 //=======================================================================
1571 //=======================================================================
1572 static Standard_Integer OCC669 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1575 di<<"Usage : " << argv[0] << " GUID\n";
1578 Standard_GUID guid(argv[1]);
1579 //guid.ShallowDump(cout);
1580 Standard_SStream aSStream;
1581 guid.ShallowDump(aSStream);
1587 #include <XCAFDoc.hxx>
1588 //=======================================================================
1589 //function : OCC738_ShapeRef
1591 //=======================================================================
1592 static Standard_Integer OCC738_ShapeRef (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1595 di<<"Usage : " << argv[0] << "\n";
1598 const Standard_GUID& guid = XCAFDoc::ShapeRefGUID ();
1599 //guid.ShallowDump(cout);
1600 Standard_SStream aSStream;
1601 guid.ShallowDump(aSStream);
1606 //=======================================================================
1607 //function : OCC738_Assembly
1609 //=======================================================================
1610 static Standard_Integer OCC738_Assembly (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1613 di<<"Usage : " << argv[0] << "\n";
1616 const Standard_GUID& guid = XCAFDoc::AssemblyGUID ();
1617 //guid.ShallowDump(cout);
1618 Standard_SStream aSStream;
1619 guid.ShallowDump(aSStream);
1624 #if defined(DDataStd_def01)
1625 #include <DDataStd_DrawPresentation.hxx>
1626 //=======================================================================
1627 //function : OCC739_DrawPresentation
1629 //=======================================================================
1630 static Standard_Integer OCC739_DrawPresentation (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1633 di<<"Usage : " << argv[0] << "\n";
1636 const Standard_GUID& guid = DDataStd_DrawPresentation::GetID() ;
1637 //guid.ShallowDump(cout);
1638 Standard_SStream aSStream;
1639 guid.ShallowDump(aSStream);
1645 //=======================================================================
1648 //=======================================================================
1649 static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1651 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1652 if(aContext.IsNull()) {
1653 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
1658 di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation" << "\n";
1662 Standard_Boolean updateviewer = Standard_True;
1664 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1666 TCollection_AsciiString aName(argv[1]);
1667 Handle(AIS_InteractiveObject) AISObj;
1669 if(!aMap.IsBound2(aName)) {
1670 di << "Use 'vdisplay' before" << "\n";
1673 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
1674 if(AISObj.IsNull()){
1675 di << argv[1] << " : No interactive object" << "\n";
1678 AISObj->UnsetTransformation();
1679 if (!aContext->HasOpenedContext()) {
1680 aContext->OpenLocalContext();
1682 aContext->Erase(AISObj, updateviewer);
1683 aContext->UpdateCurrentViewer();
1684 aContext->Display(AISObj, updateviewer);
1685 aContext->UpdateCurrentViewer();
1690 //=======================================================================
1693 //=======================================================================
1694 #include <TColStd_Array2OfInteger.hxx>
1695 static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1698 di<<"Usage : " << argv[0] << "\n";
1701 TColStd_Array2OfInteger Array2OfInteger(1,1,1,1);
1702 Array2OfInteger.SetValue(5,5,55);
1706 #include <GeomAPI_ProjectPointOnSurf.hxx>
1707 //=======================================================================
1710 //=======================================================================
1711 static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1715 di<<"Usage : " << argv[0] << " Point Surface Umin Usup Vmin Vsup \n";
1720 DrawTrSurf::GetPoint(argv[1],aPoint3d);
1721 Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
1722 Standard_Real Umin=Draw::Atof(argv[3]);
1723 Standard_Real Usup=Draw::Atof(argv[4]);
1724 Standard_Real Vmin=Draw::Atof(argv[5]);
1725 Standard_Real Vsup=Draw::Atof(argv[6]);
1727 if (aSurface.IsNull()) {
1728 di << argv[2] << " Null surface \n" ;
1732 GeomAPI_ProjectPointOnSurf PonSurf;
1733 PonSurf.Init(aSurface, Umin, Usup, Vmin, Vsup);
1734 PonSurf.Perform(aPoint3d);
1739 //=======================================================================
1742 //=======================================================================
1743 static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1747 di<<"Usage : " << argv[0] << " wire face\n";
1751 TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
1752 TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
1753 if (awire.IsNull() || aface.IsNull()) {
1754 di << "Null object" << "\n";
1758 Standard_Integer count = 0;
1759 TopExp_Explorer TE(awire, TopAbs_VERTEX);
1761 BRepTools_WireExplorer WE;
1762 for ( WE.Init(awire,aface); WE.More(); WE.Next()) {
1763 TopoDS_Edge E = WE.Current();
1767 di << "Count = " << count << "\n";
1772 //=======================================================================
1775 //=======================================================================
1776 static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1780 di <<"Usage : " << argv[0] << " face"<<"\n";
1783 Standard_Real u1, u2, v1, v2;
1784 TopoDS_Face F = TopoDS::Face( DBRep::Get(argv[1]) ); //read the shape
1787 BRepTools::UVBounds(F, u1, u2, v1, v2);
1788 di << "Bounds: " << u1 << " " << u2 << " " << v1 << " " << v2 << "\n";
1792 #include <Expr_NamedUnknown.hxx>
1793 #include <Expr_GeneralExpression.hxx>
1794 #include <Expr_Exponential.hxx>
1795 //=======================================================================
1798 //=======================================================================
1799 static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1803 di <<"Usage : " << argv[0] << " expression"<<"\n";
1807 TCollection_AsciiString myStr(argv[1]);
1809 Handle (Expr_NamedUnknown) myNamed = new Expr_NamedUnknown(myStr);
1810 Handle (Expr_Exponential) oldExpr = new Expr_Exponential(myNamed);
1811 Handle (Expr_GeneralExpression) newExpr = oldExpr->Derivative(myNamed);
1814 TCollection_AsciiString res = newExpr->String();
1815 Standard_CString resStr = res.ToCString();
1816 TCollection_AsciiString res_old = oldExpr->String();
1817 Standard_CString res_oldStr = res_old.ToCString();
1820 di << "X = " << argv[1] << "\n";
1821 di << "Y = " << res_oldStr << "\n";
1822 di << "Y' = " << resStr << "\n";
1828 #include <TPrsStd_AISViewer.hxx>
1829 #include <TDF_Label.hxx>
1830 #include <TPrsStd_AISPresentation.hxx>
1831 //=======================================================================
1832 //function : OCC1029_AISTransparency
1833 //purpose : OCC1029_AISTransparency (DOC,entry,[real])
1834 //=======================================================================
1836 static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
1837 Standard_Integer nb,
1841 Handle(TDocStd_Document) D;
1842 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1844 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1846 Handle(TPrsStd_AISViewer) viewer;
1847 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1849 Handle(TPrsStd_AISPresentation) prs;
1850 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1852 prs->SetTransparency(Draw::Atof(arg[3]));
1853 TPrsStd_AISViewer::Update(L);
1856 di << "Transparency = " << prs->Transparency() << "\n";
1861 di << arg[0] << " : Error" << "\n";
1865 //=======================================================================
1866 //function : OCC1030_AISColor
1867 //purpose : OCC1030_AISColor (DOC,entry,[color])
1868 //=======================================================================
1870 static Standard_Integer OCC1030_AISColor (Draw_Interpretor& di,
1871 Standard_Integer nb,
1875 Handle(TDocStd_Document) D;
1876 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1878 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1880 Handle(TPrsStd_AISViewer) viewer;
1881 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1883 Handle(TPrsStd_AISPresentation) prs;
1884 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1886 prs->SetColor((Quantity_NameOfColor)Draw::Atoi(arg[3]));
1887 TPrsStd_AISViewer::Update(L);
1890 di << "Color = " << prs->Color() << "\n";
1894 di << arg[0] << " : Error" << "\n";
1898 //=======================================================================
1899 //function : OCC1031_AISMaterial
1900 //purpose : OCC1031_AISMaterial (DOC,entry,[material])
1901 //=======================================================================
1903 static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
1904 Standard_Integer nb,
1908 Handle(TDocStd_Document) D;
1909 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1911 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1913 Handle(TPrsStd_AISViewer) viewer;
1914 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1916 Handle(TPrsStd_AISPresentation) prs;
1917 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1919 prs->SetMaterial((Graphic3d_NameOfMaterial)Draw::Atoi(arg[3]));
1920 TPrsStd_AISViewer::Update(L);
1923 di << "Material = " << prs->Material() << "\n";
1928 di << arg[0] << " : Error" << "\n";
1932 //=======================================================================
1933 //function : OCC1032_AISWidth
1934 //purpose : OCC1032_AISWidth (DOC,entry,[width])
1935 //=======================================================================
1937 static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
1938 Standard_Integer nb,
1942 Handle(TDocStd_Document) D;
1943 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1945 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1947 Handle(TPrsStd_AISViewer) viewer;
1948 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1950 Handle(TPrsStd_AISPresentation) prs;
1951 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1953 prs->SetWidth(Draw::Atof(arg[3]));
1954 TPrsStd_AISViewer::Update(L);
1957 di << "Width = " << prs->Width() << "\n";
1962 di << arg[0] << " : Error" << "\n";
1966 //=======================================================================
1967 //function : OCC1033_AISMode
1968 //purpose : OCC1033_AISMode (DOC,entry,[mode])
1969 //=======================================================================
1971 static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
1972 Standard_Integer nb,
1976 Handle(TDocStd_Document) D;
1977 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1979 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1981 Handle(TPrsStd_AISViewer) viewer;
1982 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1984 Handle(TPrsStd_AISPresentation) prs;
1985 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1987 prs->SetMode(Draw::Atoi(arg[3]));
1988 TPrsStd_AISViewer::Update(L);
1991 di << "Mode = " << prs->Mode() << "\n";
1996 di << arg[0] << " : Error" << "\n";
2000 //=======================================================================
2001 //function : OCC1034_AISSelectionMode
2002 //purpose : OCC1034_AISSelectionMode (DOC,entry,[selectionmode])
2003 //=======================================================================
2005 static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
2006 Standard_Integer nb,
2010 Handle(TDocStd_Document) D;
2011 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2013 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2015 Handle(TPrsStd_AISViewer) viewer;
2016 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2018 Handle(TPrsStd_AISPresentation) prs;
2019 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2021 prs->SetSelectionMode(Draw::Atoi(arg[3]));
2022 TPrsStd_AISViewer::Update(L);
2025 di << "SelectionMode = " << prs->SelectionMode() << "\n";
2030 di << arg[0] << " : Error" << "\n";
2034 #include<BRepAlgoAPI_Cut.hxx>
2035 #include<BRepAlgo_Cut.hxx>
2036 //=======================================================================
2037 //function : OCC1487
2039 //=======================================================================
2040 static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2043 // cerr << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape" << endl;
2046 if(argc < 5 || argc > 6) {
2047 di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2050 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2052 Standard_Integer IsB = Draw::Atoi(argv[5]);
2054 IsBRepAlgoAPI = Standard_False;
2055 // di << "Error: There is not BRepAlgo_Cut class" << "\n";
2060 Standard_Integer CaseNumber = Draw::Atoi(argv[1]);
2062 //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
2063 gp_Dir myDir(1,0,0);
2064 gp_Pnt myPnt(0,-50,140);
2065 gp_Ax2 myAx2(myPnt, myDir);
2066 BRepPrimAPI_MakeCylinder o_mc1 (myAx2, 50,1000);
2068 TopoDS_Shape cyl1 = o_mc1.Shape();
2071 TopoDS_Shape o_cut_shape;
2072 if (CaseNumber == 1) {
2073 //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);
2074 gp_Dir myDir_mc2(-sin(M_PI/3), 0.0, 0.5);
2075 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2076 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2077 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2079 cyl2 = o_mc2.Shape();
2080 //#if ! defined(BRepAlgoAPI_def01)
2081 // o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2083 // o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2085 if (IsBRepAlgoAPI) {
2086 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2087 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2089 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2090 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2093 //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);
2094 gp_Dir myDir_mc2(sin(M_PI/3), 0.0, 0.5);
2095 gp_Pnt myPnt_mc2(978.34936, -50.0, 127.5);
2096 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2097 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2099 cyl2 = o_mc2.Shape();
2100 //#if ! defined(BRepAlgoAPI_def01)
2101 // o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2103 // o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2105 if (IsBRepAlgoAPI) {
2106 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2107 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2109 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2110 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2114 DBRep::Set(argv[2],cyl1);
2115 DBRep::Set(argv[3],cyl2);
2116 DBRep::Set(argv[4],o_cut_shape);
2121 #include<TopTools_ListIteratorOfListOfShape.hxx>
2122 #include<BRepFilletAPI_MakeFillet.hxx>
2123 //=======================================================================
2124 //function : OCC1077
2126 //=======================================================================
2127 TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
2129 Standard_Real t3d = 1.e-4;
2130 Standard_Real t2d = 1.e-5;
2131 Standard_Real ta = 1.e-2;
2132 Standard_Real fl = 1.e-3;
2133 Standard_Real tapp_angle = 1.e-2;
2134 GeomAbs_Shape blend_cont = GeomAbs_C1;
2136 TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
2139 // Handle_TopOpeBRepBuild_HBuilder build = aBoolenaOperation.Builder();
2141 TopTools_ListIteratorOfListOfShape its;
2143 TopoDS_Compound result;
2145 B.MakeCompound(result);
2148 for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
2150 const TopoDS_Shape& cutsol = ex.Current();
2152 BRepFilletAPI_MakeFillet fill(cutsol);
2153 fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
2154 fill.SetContinuity(blend_cont, tapp_angle);
2156 // its = build->Section();
2158 its = aBoolenaOperation.SectionEdges();
2162 TopoDS_Edge E = TopoDS::Edge(its.Value());
2163 fill.Add(aRadius, E);
2170 B.Add(result, fill.Shape());
2174 B.Add(result, cutsol);
2180 TopoDS_Shape OCC1077_cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
2182 //return OCC1077_boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
2183 BRepAlgoAPI_Cut aCut(aShapeToCut, aTool);
2184 return OCC1077_boolbl(aCut,aRadius);
2187 //TopoDS_Shape OCC1077_common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
2189 // return OCC1077_boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
2192 TopoDS_Shape OCC1077_Bug()
2194 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10).Shape();
2195 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7).Shape();
2197 TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
2198 TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10),
2199 gp_Dir(0, 0, 1)), 3, 20).Shape();
2200 TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0),
2201 gp_Dir(1, 0, 0)), 3, 20).Shape();
2202 TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
2203 gp_Dir(0, 1, 0)), 3, 20).Shape();
2204 TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
2205 Handle_ShapeFix_Shape fixer = new ShapeFix_Shape(theTmp1);
2207 theTmp1 = fixer->Shape();
2208 TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
2209 fixer->Init(theTmp2);
2211 theTmp2 = fixer->Shape();
2212 TopoDS_Shape theResult = OCC1077_cut_blend(theTmp2,theCylinder3,0.7);
2213 fixer->Init(theResult);
2215 theResult = fixer->Shape();
2219 static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2221 if(argc < 1 || argc > 2) {
2222 di << "Usage : " << argv[0] << " result" << "\n";
2226 TopoDS_Shape S = OCC1077_Bug();
2227 DBRep::Set(argv[1],S);
2232 //////////////////////////////////////////////////////////////
2234 * Compute uniform distribution of points using GCPnts_UniformAbscissa
2236 //////////////////////////////////////////////////////////////
2237 static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2241 di << "Usage : " << argv[0] << " name shape step" << "\n";
2244 const char *name = argv[1];
2245 Adaptor3d_Curve *adapCurve=NULL;
2246 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
2247 if (!curve.IsNull())
2248 adapCurve = new GeomAdaptor_Curve(curve);
2251 TopoDS_Shape wire = DBRep::Get(argv[2]);
2252 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
2254 di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected"<<"\n";
2257 adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
2259 double step = Draw::Atof(argv[3]);
2260 GCPnts_UniformAbscissa aUni(*adapCurve, step);
2264 di << argv[0] <<" : fail"<<"\n";
2269 int i, np = aUni.NbPoints();
2270 for (i=0; i < np; i++)
2272 double par = aUni.Parameter(i+1);
2273 gp_Pnt p = adapCurve->Value(par);
2274 char n[20], *pname=n;
2275 Sprintf(n,"%s_%d",name,i+1);
2276 DrawTrSurf::Set(pname,p);
2285 static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2289 di << "Usage : " << argv[0] << " nb_of_vectors size" << "\n";
2293 Standard_Integer nb = Draw::Atoi(argv[1]);
2294 Standard_Integer sz = Draw::Atoi(argv[2]);
2295 Standard_Real val = 10;
2296 math_Vector **pv = new math_Vector *[nb];
2298 di<<"creating "<<nb<<" vectors "<<sz<<" elements each..."<<"\n";
2300 for (i=0; i < nb; i++) {
2301 pv[i] = new math_Vector (1, sz, val);
2302 if ((i % (nb/10)) == 0) {
2309 di<<"deleting them ..."<<"\n";
2310 for (i=0; i < nb; i++) {
2312 if ((i % (nb/10)) == 0) {
2325 static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2329 di << "Usage : " << argv[0] << " wire" << "\n";
2332 TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
2335 TopoDS_Wire wire = TopoDS::Wire(shape);
2336 // create curve parameterised by curvilinear distance
2337 BRepAdaptor_CompCurve curve(wire,Standard_True);
2338 Standard_Real length = curve.LastParameter();
2339 Standard_Real need_length = length/2;
2341 curve.D0(need_length,pnt);
2342 // create check_curve parameterised in a general way
2343 BRepAdaptor_CompCurve check_curve(wire);
2344 Standard_Real check_par =
2345 GCPnts_AbscissaPoint(check_curve, need_length, 0).Parameter();
2347 check_curve.D0(check_par,check_pnt);
2348 // check that points are coinsiding
2349 Standard_Real error_dist = pnt.Distance(check_pnt);
2350 if (error_dist > Precision::Confusion()) {
2351 //cout.precision(3);
2352 di<<"error_dist = "<<error_dist<<
2353 " ( "<<error_dist/need_length*100<<" %)"<<"\n";
2361 static int StackOverflow (int i = -1)
2364 memset (arr, 0, sizeof(arr));
2370 // this code does not work with optimize mode on Windows
2371 #pragma optimize( "", off )
2373 static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2377 cout << "Usage : " << argv[0] << "\n";
2380 Standard_Boolean Succes;
2382 Succes = Standard_True;
2385 {//==== Test Divide ByZero (Integer) ========================================
2388 cout << "(Integer) Divide By Zero..." << endl;
2389 di << "(Integer) Divide By Zero...";
2392 Standard_Integer res, a =4, b = 0 ;
2394 di << " 4 / 0 = " << res << " Does not Caught... KO"<< "\n";
2395 Succes = Standard_False;
2397 #if defined(SOLARIS) || defined(WNT)
2398 catch(Standard_DivideByZero)
2400 catch(Standard_NumericError)
2405 catch(Standard_Failure) {
2406 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2408 di << Standard_Failure::Caught()->GetMessageString();
2409 di << ")... KO" << "\n";
2410 Succes = Standard_False;
2412 #ifndef NO_CXX_EXCEPTION
2413 // this case tests if (...) supersedes (Standard_*),
2414 // the normal behaviour is not
2416 di<<" unknown exception... (But) Ok"<<"\n";
2421 {//==== Test Divide ByZero (Real) ===========================================
2424 cout << "(Real) Divide By Zero..." << endl;
2425 di << "(Real) Divide By Zero...";
2428 Standard_Real res, a= 4.0, b=0.0;
2430 di << " 4.0 / 0.0 = " << res << " Does not Caught... KO"<< "\n";
2431 Succes = Standard_False;
2433 catch(Standard_DivideByZero) // Solaris, Windows w/o SSE2
2435 di << " Ok" << "\n";
2437 catch(Standard_NumericError) // Linux, Windows with SSE2
2439 di << " Ok" << "\n";
2441 catch(Standard_Failure) {
2442 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2444 di << Standard_Failure::Caught()->GetMessageString();
2445 di << ")... KO" << "\n";
2446 Succes = Standard_False;
2450 {//==== Test Overflow (Integer) =============================================
2453 cout << "(Integer) Overflow..." << endl;
2454 di << "(Integer) Overflow...";
2457 Standard_Integer res, i=IntegerLast();
2459 //++++ cout << " -- "<<res<<"="<<i<<"+1 Does not Caught... KO"<< endl;
2460 //++++ Succes = Standard_False;
2461 di << " "<<res<<"="<<i<<"+1 Does not Caught... (But) Ok"<< "\n";
2463 catch(Standard_Overflow) {
2466 catch(Standard_Failure) {
2467 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2469 di << Standard_Failure::Caught()->GetMessageString();
2470 di << ")... KO" << "\n";
2471 Succes = Standard_False;
2475 {//==== Test Overflow (Real) ================================================
2478 cout << "(Real) Overflow..." << endl;
2479 di << "(Real) Overflow...";
2482 Standard_Real res, r=RealLast();
2485 sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
2487 di << "-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<< "\n";
2488 Succes = Standard_False;
2490 catch(Standard_Overflow) // Solaris, Windows w/o SSE2
2492 di << " Ok" << "\n";
2494 catch(Standard_NumericError) // Linux, Windows with SSE2
2496 di << " Ok" << "\n";
2498 catch(Standard_Failure) {
2499 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2501 di << Standard_Failure::Caught()->GetMessageString();
2502 di << ")... KO" << "\n";
2503 Succes = Standard_False;
2507 {//==== Test Underflow (Real) ===============================================
2510 cout << "(Real) Underflow" << endl; // to have message in log even if process crashed
2511 di << "(Real) Underflow";
2514 Standard_Real res, r=1.0e-308;
2517 //++++ cout<<"-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<<endl;
2518 //++++ Succes = Standard_False;
2519 di<<" -- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... (But) Ok"<<"\n";
2521 catch(Standard_Underflow) // could be on Solaris, Windows w/o SSE2
2523 di << " Ok" << "\n";
2525 catch(Standard_NumericError) // could be on Linux, Windows with SSE2
2527 di << " Ok" << "\n";
2529 catch(Standard_Failure) {
2530 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2532 di << Standard_Failure::Caught()->GetMessageString();
2533 di << ")... KO" << "\n";
2534 Succes = Standard_False;
2538 {//==== Test Invalid Operation (Real) ===============================================
2541 cout << "(Real) Invalid Operation..." << endl;
2542 di << "(Real) Invalid Operation...";
2545 Standard_Real res, r=-1;
2547 di<<" "<<res<<"=sqrt("<<r<<") Does not Caught... KO"<<"\n";
2548 Succes = Standard_False;
2550 catch(Standard_NumericError) {
2553 catch(Standard_Failure) {
2554 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2556 di << Standard_Failure::Caught()->GetMessageString();
2557 di << ")... KO" << "\n";
2558 Succes = Standard_False;
2562 {//==== Test Access Violation ===============================================
2565 cout << "Segmentation Fault..." << endl;
2566 di << "Segmentation Fault...";
2571 di << " Does not Caught... KO"<<"\n";
2572 Succes = Standard_False;
2575 catch(OSD_Exception_ACCESS_VIOLATION)
2581 } catch(Standard_Failure) {
2582 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2584 di << Standard_Failure::Caught()->GetMessageString();
2585 di << ")... KO" << "\n";
2586 Succes = Standard_False;
2591 {//==== Test Stack Overflow ===============================================
2594 cout << "Stack Overflow..." << endl;
2595 di << "Stack Overflow...";
2599 di << " Does not Caught... KO"<<"\n";
2600 Succes = Standard_False;
2602 catch(OSD_Exception_STACK_OVERFLOW) {
2605 catch(Standard_Failure) {
2606 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2608 di << Standard_Failure::Caught()->GetMessageString();
2609 di << ")... KO" << "\n";
2610 Succes = Standard_False;
2616 di << "TestExcept: Successfull completion" << "\n";
2618 di << "TestExcept: failure" << "\n";
2624 #pragma optimize( "", on )
2627 static TopoDS_Compound AddTestStructure(int nCount_)
2633 BRepPrimAPI_MakeBox mkBox(1.0, 2.0, 3.0);
2634 for (int i=0; i<nCount; i++) {
2635 for (int j=0; j<nCount; j++) {
2637 trsf.SetTranslationPart(gp_Vec(5.0*i, 05.0*j, 0.0));
2638 TopLoc_Location topLoc(trsf);
2639 TopoDS_Shape tempShape=mkBox.Shape().Located(topLoc);
2640 B.Add(C, tempShape);
2646 static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2652 di << "Usage : " << argv[0] << " [nCount] path" << "\n";
2657 nCount = Draw::Atoi(argv[1]);
2658 TCollection_AsciiString aFilePath = argv[2];
2659 STEPCAFControl_Writer writer;
2660 Handle_TDocStd_Document document;
2661 document = new TDocStd_Document("Pace Test-StepExporter-");
2662 Handle_XCAFDoc_ShapeTool shapeTool;
2663 shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
2664 shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
2665 STEPControl_StepModelType mode = STEPControl_AsIs;
2666 if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
2667 di << "Failed to set assembly mode for step data\n" << "\n";
2672 if( writer.Transfer(document, mode)) {
2673 writer.Write(aFilePath.ToCString());
2676 catch(OSD_Exception_STACK_OVERFLOW) {
2677 di << "Failed : STACK OVERFLOW\n" << "\n";
2679 catch (Standard_Failure) {
2680 di << "Failed :\n" << "\n";
2681 //cout << Standard_Failure::Caught() << endl;
2682 di << Standard_Failure::Caught()->GetMessageString();
2684 di << argv[0] << " : Finish" << "\n";
2689 static Standard_Integer OCC7372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2693 di << "Usage : " << argv[0] << "\n";
2697 // 1. Create an array of points
2698 Handle(TColgp_HArray1OfPnt2d) ap = new TColgp_HArray1OfPnt2d(1,5);
2699 ap->SetValue(1,gp_Pnt2d(100.0,0.0));
2700 ap->SetValue(2,gp_Pnt2d(100.0,100.0));
2701 ap->SetValue(3,gp_Pnt2d(0.0,100.0));
2702 ap->SetValue(4,gp_Pnt2d(0.0,0.0));
2703 ap->SetValue(5,gp_Pnt2d(50.0,-50.0));
2705 // 2. Create a periodic bspline through these 5 points
2706 Geom2dAPI_Interpolate intp(ap,Standard_True,1e-6);
2708 Handle(Geom2d_BSplineCurve) bspline1 = intp.Curve();
2710 // 3. Increase degree of curve from 3 to 8
2711 bspline1->IncreaseDegree(8); // Increase degree to demonstrate the error
2712 Standard_CString CString1 = "BSplineCurve";
2713 DrawTrSurf::Set(CString1,bspline1);
2715 // 4. Convers BSpline curve to Bezier segments
2716 Geom2dConvert_BSplineCurveToBezierCurve bc(bspline1);
2718 // 5. Test the result of conversion
2719 TCollection_AsciiString aRName;
2720 for(Standard_Integer i = 1; i <= bc.NbArcs(); i++) {
2721 Handle(Geom2d_BezierCurve) arc = bc.Arc(i);
2723 aRName=aRName+TCollection_AsciiString(i);
2724 Standard_CString aRNameStr = aRName.ToCString();
2725 DrawTrSurf::Set(aRNameStr,arc);
2726 di << aRNameStr << " ";
2732 static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2736 di << "Usage : " << argv[0] << " edge1 edge2 plane" << "\n";
2739 TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
2740 if (theEdge1.IsNull()) {
2741 di << "Invalid input shape " << argv[1] << "\n";
2744 TopoDS_Edge theEdge2 = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
2745 if (theEdge2.IsNull()) {
2746 di << "Invalid input shape " << argv[2] << "\n";
2749 TopoDS_Face theFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
2750 if (theFace.IsNull()) {
2751 di << "Invalid input shape " << argv[3] << "\n";
2755 Handle(Geom_Surface) thePlane = BRep_Tool::Surface(theFace);
2757 Standard_Real aConfusion = Precision::Confusion();
2758 Standard_Real aP1first, aP1last, aP2first, aP2last;
2760 Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(theEdge1, aP1first, aP1last);
2761 Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(theEdge2, aP2first, aP2last);
2762 Handle(Geom2d_Curve) aCurve2d1 = GeomProjLib::Curve2d(aCurve1, aP1first, aP1last, thePlane);
2763 Handle(Geom2d_Curve) aCurve2d2 = GeomProjLib::Curve2d(aCurve2, aP2first, aP2last, thePlane);
2765 Geom2dAPI_InterCurveCurve anInter(aCurve2d1, aCurve2d2, aConfusion);
2767 Standard_Integer NbPoints = anInter.NbPoints();
2769 di << "NbPoints = " << NbPoints << "\n" ;
2773 for (i=1; i<=NbPoints; i++) {
2774 gp_Pnt2d aPi = anInter.Point(i);
2775 di << "Point.X(" << i << ") = " << aPi.X() << " " << "Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
2779 Standard_Integer NbSegments = anInter.NbSegments();
2781 di << "\nNbSegments = " << NbSegments << "\n" ;
2783 if (NbSegments > 0) {
2784 IntRes2d_IntersectionSegment aSegment = anInter.Intersector().Segment(1);
2786 gp_Pnt2d aP1 = aCurve2d1->Value(aSegment.FirstPoint().ParamOnFirst());
2787 gp_Pnt2d aP2 = aCurve2d2->Value(aSegment.FirstPoint().ParamOnSecond());
2789 Standard_Real aDist = aP1.Distance(aP2);
2791 di << "aP1.X() = " << aP1.X() << " " << "aP1.Y() = " << aP1.Y() << "\n" ;
2792 di << "aP2.X() = " << aP2.X() << " " << "aP2.Y() = " << aP2.Y() << "\n" ;
2794 di << "Distance = " << aDist << "\n" ;
2796 di << "Confusion = " << aConfusion << "\n" ;
2798 if (aDist > aConfusion) {
2799 di << "\n" << argv[0] << " Faulty" << "\n" ;
2801 di << "\n" << argv[0] << " OK" << "\n" ;
2804 di << "\n" << argv[0] << " OK" << "\n" ;
2809 static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2813 di << "Usage : " << argv[0] << " lower upper" << "\n";
2817 Standard_Integer LOWER = Draw::Atoi(argv[1]);
2818 Standard_Integer UPPER = Draw::Atoi(argv[2]);
2820 //! 0. Create an empty document with several test labels
2821 Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
2822 doc->SetUndoLimit(100);
2823 TDF_Label main_label = doc->Main();
2824 TDF_Label label1 = main_label.FindChild(1, Standard_True);
2825 TDF_Label label2 = main_label.FindChild(2, Standard_True);
2827 //! 1. Set/Get OCAF attribute
2829 TDataStd_RealArray::Set(label1, LOWER, UPPER);
2830 Handle(TDataStd_RealArray) array;
2831 if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) &&
2832 array->Lower() == LOWER && array->Upper() == UPPER)
2833 cout<<"1: OK"<<endl;
2836 cout<<"1: Failed.."<<endl;
2839 doc->CommitCommand();
2841 //! 2. Set/Get value
2844 for (i = LOWER; i <= UPPER; i++)
2845 array->SetValue(i, i);
2846 for (i = LOWER; i <= UPPER; i++)
2848 if (array->Value(i) != i)
2850 cout<<"2: Failed.."<<endl;
2854 cout<<"2: OK"<<endl;
2855 doc->CommitCommand();
2857 //! 3. Re-init the array
2859 array->Init(LOWER + 2, UPPER + 4);
2860 if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4)
2862 cout<<"3: Failed.."<<endl;
2865 for (i = LOWER + 2; i <= UPPER + 4; i++)
2866 array->SetValue(i, i);
2867 for (i = LOWER + 2; i <= UPPER + 4; i++)
2869 if (array->Value(i) != i)
2871 cout<<"3: Failed.."<<endl;
2875 cout<<"3: OK"<<endl;
2876 doc->CommitCommand();
2880 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(LOWER + 5, UPPER + 5);
2881 for (i = LOWER + 5; i <= UPPER + 5; i++)
2882 arr->SetValue(i, i);
2883 array->ChangeArray(arr);
2884 for (i = LOWER + 5; i <= UPPER + 5; i++)
2886 if (array->Value(i) != i)
2888 cout<<"4: Failed.."<<endl;
2892 cout<<"4: OK"<<endl;
2893 doc->CommitCommand();
2895 //! 5. Copy the array
2897 TDF_CopyLabel copier(label1, label2);
2899 if (!copier.IsDone())
2901 cout<<"5: Failed.."<<endl;
2904 Handle(TDataStd_RealArray) array2;
2905 if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2907 cout<<"5: Failed.."<<endl;
2910 for (i = LOWER + 5; i <= UPPER + 5; i++)
2912 if (array->Value(i) != i)
2914 cout<<"5: Failed.."<<endl;
2918 cout<<"5: OK"<<endl;
2919 doc->CommitCommand();
2922 //! 6.a: undoes the 5th action: the copied array should disappear
2924 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2925 label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2927 cout<<"6.a: Failed.."<<endl;
2930 //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4)
2932 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2933 array->Lower() != LOWER + 2 ||
2934 array->Upper() != UPPER + 4)
2936 cout<<"6.b: Failed.."<<endl;
2939 for (i = LOWER + 2; i <= UPPER + 4; i++)
2941 if (array->Value(i) != i)
2943 cout<<"6.b: Failed.."<<endl;
2947 //! 6.c: undoes the 3d action: the array should be changed to (lower,upper)
2949 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2950 array->Lower() != LOWER ||
2951 array->Upper() != UPPER)
2953 cout<<"6.c: Failed.."<<endl;
2956 for (i = LOWER; i <= UPPER; i++)
2958 if (array->Value(i) != i)
2960 cout<<"6.c: Failed.."<<endl;
2964 //! 6.d: undoes and redoes the 2nd action: no change is expected.
2967 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2968 array->Lower() != LOWER ||
2969 array->Upper() != UPPER)
2971 cout<<"6.d: Failed.."<<endl;
2974 for (i = LOWER; i <= UPPER; i++)
2976 if (array->Value(i) != i)
2978 cout<<"6.d: Failed.."<<endl;
2982 cout<<"6: OK"<<endl;
2984 //! 7. Re-set the array
2986 array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1);
2987 if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1)
2989 cout<<"7: Failed.."<<endl;
2992 for (i = LOWER + 1; i <= UPPER + 1; i++)
2993 array->SetValue(i, i);
2994 for (i = LOWER + 1; i <= UPPER + 1; i++)
2996 if (array->Value(i) != i)
2998 cout<<"7: Failed.."<<endl;
3002 cout<<"7: OK"<<endl;
3003 doc->CommitCommand();
3005 //! 8.Test of speed: set LOWER and UPPER equal to great integer number and
3006 //! measure the time spent by this test.
3012 static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3014 Standard_Boolean IsEvenArgc = Standard_True;
3015 if (argc % 2 == 0) {
3016 IsEvenArgc = Standard_True;
3018 IsEvenArgc = Standard_False;
3021 if (argc < 3 || IsEvenArgc)
3023 di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]" << "\n";
3027 Standard_Integer i, aValue, aPosition;
3028 NCollection_Vector<int> vec;
3029 for (i = 0; i < argc - 1; i++) {
3031 aValue = Draw::Atoi(argv[i]);
3032 aPosition = Draw::Atoi(argv[i+1]);
3033 vec.SetValue(aValue, aPosition);
3035 NCollection_Vector<int>::Iterator it(vec);
3037 for (j = 0; it.More(); it.Next(), j++) {
3038 //di << it.Value() << "\n";
3039 di << j << " " << it.Value() << "\n";
3045 static Standard_Integer OCC8797 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3048 di << "Usage : " << argv[0] << "\n";
3052 gp_Pnt point(0.0,0.0,0.0);
3054 TColgp_Array1OfPnt poles(0,6);
3057 point.SetCoord(1.0,1.0,0.0);
3060 point.SetCoord(2.0,1.0,0.0);
3063 point.SetCoord(3.0,0.0,0.0);
3066 point.SetCoord(4.0,1.0,0.0);
3069 point.SetCoord(5.0,1.0,0.0);
3072 point.SetCoord(6.0,0.0,0.0);
3075 TColStd_Array1OfReal knots(0,2);
3080 TColStd_Array1OfInteger multi(0,2);
3085 Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles,knots,multi,3);
3088 Standard_Real l_abcissa,l_gprop;
3089 GeomAdaptor_Curve adaptor_spline(spline);
3090 GCPnts_AbscissaPoint temp;
3091 l_abcissa=temp.Length(adaptor_spline);
3092 cout<<"Length Spline(abcissa_Pnt): "<<l_abcissa<<endl;
3095 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge (spline);
3097 BRepGProp::LinearProperties(edge,prop);
3098 l_gprop=prop.Mass();
3099 cout<<"Length Spline(GProp_GProps): "<<l_gprop<<endl;
3101 cout<<"Difference (abcissa_Pnt<->GProp_GProps): "<<l_gprop-l_abcissa<<endl;
3106 static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3110 di << "Usage : " << argv[0] << "\n";
3114 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
3115 if(AISContext.IsNull())
3117 di << "use 'vinit' command before " << argv[0] << "\n";
3122 AIS_ListOfInteractive ListOfIO_1;
3123 AISContext->ObjectsInside(ListOfIO_1);
3124 di<< "ObjectsInside = " << ListOfIO_1.Extent() <<"\n";
3125 if (!ListOfIO_1.IsEmpty() ) {
3126 AIS_ListIteratorOfListOfInteractive iter;
3127 for (iter.Initialize(ListOfIO_1); iter.More() ; iter.Next() ) {
3128 Handle(AIS_InteractiveObject) aIO=iter.Value();
3129 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3136 static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3138 if ((argc < 9) || (((argc-3) % 3) != 0))
3140 di << "Usage : " << argv[0] << "polygon lastedge x1 y1 z1 x2 y2 z2 ...\n";
3143 Standard_Integer i, j, np = (argc-3) / 3;
3144 BRepBuilderAPI_MakePolygon W;
3146 for (i = 1; i <= np; i ++) {
3147 W.Add(gp_Pnt(Draw::Atof(argv[j]),Draw::Atof(argv[j+1]),Draw::Atof(argv[j+2])));
3151 DBRep::Set(argv[1],W.Wire());
3152 DBRep::Set(argv[2],W.Edge());
3156 static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3159 di << "Usage : " << argv[0] << " ratio origin_x origin_y origin_z\n";
3162 gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
3163 gp_Dir(1., -1., 0.));
3165 aTrf.SetAffinity (aPln, Draw::Atof(argv[4]));
3166 gp_XYZ aOrigin (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3167 gp_XYZ aResult (aOrigin);
3168 aTrf.Transforms(aResult);
3170 Sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
3171 aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
3172 aResult.X(), aResult.Y(), aResult.Z());
3177 Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3180 di << "Usage : " << argv[0] << " shape [deflection]\n";
3184 TopoDS_Shape aShape = DBRep::Get(argv[1]);
3186 if (aShape.IsNull()) {
3187 di<<" Null shape is not allowed";
3191 Standard_Real aDeflection = 0.45110277533;
3193 aDeflection = Draw::Atof(argv[2]);
3195 di<<"deflection="<< aDeflection << "\n";
3197 BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI/9.);
3198 TopLoc_Location aLocation;
3199 Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
3201 if(aTriang.IsNull()) {
3202 di << argv[0] << " : Faulty\n" ;
3204 di << argv[0] << " : OK\n" ;
3205 di<<"NbNodes="<< aTriang->NbNodes()<< "\n";
3206 di<<"NbTriangles="<< aTriang->NbTriangles()<< "\n";
3211 static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3214 di << "Usage : " << argv[0] << " A B C\n";
3219 gp_Lin2d aLin2d (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3220 gp_Pnt2d anOrigin = aLin2d.Location();
3221 di << "X_0 = " << anOrigin.X() << " Y_0 = " << anOrigin.Y() << "\n" ;
3223 catch(Standard_ConstructionError)
3225 di << argv[0] << " Exception: Sqrt(A*A + B*B) <= Resolution from gp\n";
3230 static Standard_Integer OCC15755 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3233 di << "Usage : " << argv[0] << " file shape\n";
3237 IGESControl_Reader aReader;
3238 aReader.ReadFile(argv[1]);
3239 aReader.SetReadVisible(Standard_True);
3240 aReader.TransferRoots();
3242 Handle(IGESData_IGESModel) model = aReader.IGESModel();
3243 if (model.IsNull()) {
3244 di << "model.IsNull()\n";
3247 Standard_Integer nb = model->NbEntities();
3248 for (Standard_Integer i = 1; i <= nb; i ++) {
3249 Handle(IGESData_IGESEntity) ent = model->Entity(i);
3250 Handle(TCollection_HAsciiString) name;
3251 name = ent->NameValue();
3252 Standard_CString aStr = name->ToCString();
3253 di << "NameValue = " << aStr << "\n";
3256 TopoDS_Shape shape = aReader.OneShape();
3257 DBRep::Set(argv[2],shape);
3261 // For OCC16782 testing
3262 #include <AppStd_Application.hxx>
3263 #include <TDF_Tool.hxx>
3264 #include <TColStd_HArray1OfInteger.hxx>
3266 #include <TColStd_ListIteratorOfListOfInteger.hxx>
3267 #include <TColStd_ListIteratorOfListOfReal.hxx>
3268 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
3269 #include <TDataStd_ListIteratorOfListOfByte.hxx>
3270 #include <TDF_ListIteratorOfLabelList.hxx>
3272 #include <TDataStd_Tick.hxx>
3273 #include <TDataStd_IntegerList.hxx>
3274 #include <TDataStd_RealList.hxx>
3275 #include <TDataStd_ExtStringList.hxx>
3276 #include <TDataStd_BooleanList.hxx>
3277 #include <TDataStd_ReferenceList.hxx>
3278 #include <TDataStd_BooleanArray.hxx>
3279 #include <TDataStd_ReferenceArray.hxx>
3280 #include <TDataStd_ByteArray.hxx>
3281 #include <TDataStd_NamedData.hxx>
3282 #include <TDF_Reference.hxx>
3284 Handle(AppStd_Application) app;
3285 int TestSetGet(const Handle(TDocStd_Document)& doc)
3289 TDataStd_Tick::Set(doc->Main());
3291 Handle(TDataStd_Tick) tick;
3292 if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick))
3295 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3296 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3298 doc->Main().ResumeAttribute(tick);
3299 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3302 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3303 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3306 // TDataStd_IntegerList:
3308 Handle(TDataStd_IntegerList) setintlist = TDataStd_IntegerList::Set(doc->Main());
3309 setintlist->Append(2);
3310 setintlist->Prepend(1);
3311 setintlist->InsertAfter(3, 2);
3312 setintlist->InsertBefore(0, 1);
3313 setintlist->Append(200);
3314 setintlist->Remove(0);
3315 setintlist->Remove(200);
3317 Handle(TDataStd_IntegerList) getintlist;
3318 if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist))
3320 if (getintlist->First() != 1)
3322 if (getintlist->Last() != 3)
3324 const TColStd_ListOfInteger& intlist = getintlist->List();
3325 TColStd_ListIteratorOfListOfInteger itr_intlist(intlist);
3326 for (; itr_intlist.More(); itr_intlist.Next())
3328 if (itr_intlist.Value() != 1 &&
3329 itr_intlist.Value() != 2 &&
3330 itr_intlist.Value() != 3)
3335 getintlist->Clear();
3337 // TDataStd_RealList:
3339 Handle(TDataStd_RealList) setdbllist = TDataStd_RealList::Set(doc->Main());
3340 setdbllist->Append(2.5);
3341 setdbllist->Prepend(1.5);
3342 setdbllist->InsertAfter(3.5, 2.5);
3343 setdbllist->InsertBefore(0.5, 1.5);
3344 setdbllist->Append(200.5);
3345 setdbllist->Remove(0.5);
3346 setdbllist->Remove(200.5);
3348 Handle(TDataStd_RealList) getdbllist;
3349 if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist))
3351 if (getdbllist->First() != 1.5)
3353 if (getdbllist->Last() != 3.5)
3355 const TColStd_ListOfReal& dbllist = getdbllist->List();
3356 TColStd_ListIteratorOfListOfReal itr_dbllist(dbllist);
3357 for (; itr_dbllist.More(); itr_dbllist.Next())
3359 if (itr_dbllist.Value() != 1.5 &&
3360 itr_dbllist.Value() != 2.5 &&
3361 itr_dbllist.Value() != 3.5)
3366 getdbllist->Clear();
3368 // TDataStd_ExtStringList:
3370 Handle(TDataStd_ExtStringList) setstrlist = TDataStd_ExtStringList::Set(doc->Main());
3371 setstrlist->Append("Hello");
3372 setstrlist->Prepend("Guten Tag");
3373 setstrlist->InsertAfter("Bonjour", "Guten Tag");
3374 setstrlist->InsertBefore("Bonsoir", "Hello");
3375 setstrlist->Append("Good bye");
3376 setstrlist->Remove("Bonsoir");
3377 setstrlist->Remove("Good bye");
3379 Handle(TDataStd_ExtStringList) getstrlist;
3380 if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist))
3382 if (getstrlist->First() != "Guten Tag")
3384 if (getstrlist->Last() != "Hello")
3386 const TDataStd_ListOfExtendedString& strlist = getstrlist->List();
3387 TDataStd_ListIteratorOfListOfExtendedString itr_strlist(strlist);
3388 for (; itr_strlist.More(); itr_strlist.Next())
3390 if (itr_strlist.Value() != "Guten Tag" &&
3391 itr_strlist.Value() != "Bonjour" &&
3392 itr_strlist.Value() != "Hello")
3397 getstrlist->Clear();
3399 // TDataStd_BooleanList:
3401 Handle(TDataStd_BooleanList) setboollist = TDataStd_BooleanList::Set(doc->Main());
3402 setboollist->Append(Standard_True);
3403 setboollist->Prepend(Standard_False);
3405 Handle(TDataStd_BooleanList) getboollist;
3406 if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist))
3408 if (getboollist->First() != Standard_False)
3410 if (getboollist->Last() != Standard_True)
3412 const TDataStd_ListOfByte& boollist = getboollist->List();
3413 TDataStd_ListIteratorOfListOfByte itr_boollist(boollist);
3414 for (; itr_boollist.More(); itr_boollist.Next())
3416 if (itr_boollist.Value() != Standard_True &&
3417 itr_boollist.Value() != Standard_False)
3422 getboollist->Clear();
3424 // TDataStd_ReferenceList:
3425 TDF_Label L1 = doc->Main().FindChild(100);
3426 TDF_Label L2 = doc->Main().FindChild(101);
3427 TDF_Label L3 = doc->Main().FindChild(102);
3428 TDF_Label L4 = doc->Main().FindChild(103);
3429 TDF_Label L5 = doc->Main().FindChild(104);
3431 Handle(TDataStd_ReferenceList) setreflist = TDataStd_ReferenceList::Set(doc->Main());
3432 setreflist->Append(L1);
3433 setreflist->Prepend(L2);
3434 setreflist->InsertAfter(L3, L2);
3435 setreflist->InsertBefore(L4, L1);
3436 setreflist->Append(L5);
3437 setreflist->Remove(L4);
3438 setreflist->Remove(L5);
3440 Handle(TDataStd_ReferenceList) getreflist;
3441 if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist))
3443 if (getreflist->First() != L2)
3445 if (getreflist->Last() != L1)
3447 const TDF_LabelList& reflist = getreflist->List();
3448 TDF_ListIteratorOfLabelList itr_reflist(reflist);
3449 for (; itr_reflist.More(); itr_reflist.Next())
3451 if (itr_reflist.Value() != L1 &&
3452 itr_reflist.Value() != L2 &&
3453 itr_reflist.Value() != L3)
3458 getreflist->Clear();
3460 // TDataStd_BooleanArray:
3462 Handle(TDataStd_BooleanArray) setboolarr = TDataStd_BooleanArray::Set(doc->Main(), 12, 16);
3463 setboolarr->SetValue(12, Standard_True);
3464 setboolarr->SetValue(13, Standard_False);
3465 setboolarr->SetValue(14, Standard_False);
3466 setboolarr->SetValue(15, Standard_False);
3467 setboolarr->SetValue(16, Standard_True);
3468 setboolarr->SetValue(14, Standard_True);
3470 Handle(TDataStd_BooleanArray) getboolarr;
3471 if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr))
3473 if (getboolarr->Value(12) != Standard_True)
3475 if (getboolarr->Value(13) != Standard_False)
3477 if (getboolarr->Value(14) != Standard_True)
3479 if (getboolarr->Value(15) != Standard_False)
3481 if (getboolarr->Value(16) != Standard_True)
3484 // TDataStd_ReferenceArray:
3486 Handle(TDataStd_ReferenceArray) setrefarr = TDataStd_ReferenceArray::Set(doc->Main(), 0, 4);
3487 setrefarr->SetValue(0, L1);
3488 setrefarr->SetValue(1, L2);
3489 setrefarr->SetValue(2, L3);
3490 setrefarr->SetValue(3, L4);
3491 setrefarr->SetValue(4, L5);
3493 Handle(TDataStd_ReferenceArray) getrefarr;
3494 if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr))
3496 if (getrefarr->Value(0) != L1)
3498 if (getrefarr->Value(1) != L2)
3500 if (getrefarr->Value(2) != L3)
3502 if (getrefarr->Value(3) != L4)
3504 if (getrefarr->Value(4) != L5)
3507 // TDataStd_ByteArray:
3509 Handle(TDataStd_ByteArray) setbytearr = TDataStd_ByteArray::Set(doc->Main(), 12, 16);
3510 setbytearr->SetValue(12, 0);
3511 setbytearr->SetValue(13, 1);
3512 setbytearr->SetValue(14, 2);
3513 setbytearr->SetValue(15, 3);
3514 setbytearr->SetValue(16, 255);
3516 Handle(TDataStd_ByteArray) getbytearr;
3517 if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr))
3519 if (getbytearr->Value(12) != 0)
3521 if (getbytearr->Value(13) != 1)
3523 if (getbytearr->Value(14) != 2)
3525 if (getbytearr->Value(15) != 3)
3527 if (getbytearr->Value(16) != 255)
3530 // TDataStd_NamedData:
3532 Handle(TDataStd_NamedData) setnd = TDataStd_NamedData::Set(doc->Main());
3533 setnd->SetInteger("Integer1", 1);
3534 setnd->SetInteger("Integer2", 2);
3535 setnd->SetInteger("Integer3", 8);
3536 setnd->SetInteger("Integer3", 3);
3538 Handle(TDataStd_NamedData) getnd;
3539 if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd))
3541 if (!getnd->HasIntegers())
3543 if (!getnd->HasInteger("Integer1"))
3545 if (getnd->GetInteger("Integer2") != 2)
3547 if (getnd->GetInteger("Integer3") != 3)
3553 int TestUndoRedo(const Handle(TDocStd_Document)& doc)
3557 Handle(TDataStd_Tick) tick = TDataStd_Tick::Set(doc->Main());
3558 doc->CommitCommand();
3559 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3562 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3565 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3568 // TDataStd_IntegerList:
3570 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc->Main());
3572 intlist->Prepend(1);
3573 intlist->InsertBefore(0, 1);
3574 intlist->InsertAfter(3, 2);
3575 doc->CommitCommand();
3576 if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID()))
3579 if (!intlist->IsEmpty())
3582 if (!intlist->Extent())
3584 if (intlist->First() != 0)
3586 if (intlist->Last() != 3)
3590 // TDataStd_RealList:
3592 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc->Main());
3593 dbllist->Append(2.5);
3594 dbllist->Prepend(1.5);
3595 dbllist->InsertBefore(0.5, 1.5);
3596 dbllist->InsertAfter(3.5, 2.5);
3597 doc->CommitCommand();
3598 if (!doc->Main().IsAttribute(TDataStd_RealList::GetID()))
3601 if (!dbllist->IsEmpty())
3604 if (!dbllist->Extent())
3606 if (dbllist->First() != 0.5)
3608 if (dbllist->Last() != 3.5)
3612 // TDataStd_ExtStringList:
3614 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc->Main());
3615 strlist->Append("Hello");
3616 strlist->Prepend("Guten Tag");
3617 strlist->InsertAfter("Bonjour", "Guten Tag");
3618 strlist->InsertBefore("Bonsoir", "Hello");
3619 doc->CommitCommand();
3620 if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID()))
3623 if (!strlist->IsEmpty())
3626 if (!strlist->Extent())
3628 if (strlist->First() != "Guten Tag")
3630 if (strlist->Last() != "Hello")
3634 // TDataStd_BooleanList:
3636 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc->Main());
3637 boollist->Append(Standard_True);
3638 boollist->Prepend(Standard_False);
3639 doc->CommitCommand();
3640 if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID()))
3643 if (!boollist->IsEmpty())
3646 if (!boollist->Extent())
3648 if (boollist->First() != Standard_False)
3650 if (boollist->Last() != Standard_True)
3654 // TDataStd_ReferenceList:
3655 TDF_Label L1 = doc->Main().FindChild(100);
3656 TDF_Label L2 = doc->Main().FindChild(101);
3657 TDF_Label L3 = doc->Main().FindChild(102);
3658 TDF_Label L4 = doc->Main().FindChild(103);
3660 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc->Main());
3661 reflist->Append(L1);
3662 reflist->Prepend(L2);
3663 reflist->InsertBefore(L3, L1);
3664 reflist->InsertAfter(L4, L2);
3665 doc->CommitCommand();
3666 if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID()))
3669 if (!reflist->IsEmpty())
3672 if (!reflist->Extent())
3674 if (reflist->First() != L2)
3676 if (reflist->Last() != L1)
3680 // TDataStd_BooleanArray:
3682 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc->Main(), 23, 25);
3683 boolarr->SetValue(23, Standard_True);
3684 boolarr->SetValue(25, Standard_True);
3685 doc->CommitCommand();
3687 boolarr = TDataStd_BooleanArray::Set(doc->Main(), 230, 250);
3688 boolarr->SetValue(230, Standard_True);
3689 boolarr->SetValue(250, Standard_True);
3690 doc->CommitCommand();
3692 if (boolarr->Value(23) != Standard_True)
3694 if (boolarr->Value(24) != Standard_False)
3696 if (boolarr->Value(25) != Standard_True)
3699 if (boolarr->Value(230) != Standard_True)
3701 if (boolarr->Value(240) != Standard_False)
3703 if (boolarr->Value(250) != Standard_True)
3706 // TDataStd_ReferenceArray:
3708 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc->Main(), 5, 8);
3709 refarr->SetValue(5, L1);
3710 refarr->SetValue(6, L2);
3711 refarr->SetValue(7, L3);
3712 refarr->SetValue(8, L4);
3713 doc->CommitCommand();
3714 if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID()))
3718 if (refarr->Value(5) != L1)
3720 if (refarr->Value(6) != L2)
3722 if (refarr->Value(7) != L3)
3724 if (refarr->Value(8) != L4)
3727 // TDataStd_ByteArray:
3729 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc->Main(), 23, 25);
3730 bytearr->SetValue(23, 23);
3731 bytearr->SetValue(25, 25);
3732 doc->CommitCommand();
3734 bytearr = TDataStd_ByteArray::Set(doc->Main(), 230, 250);
3735 bytearr->SetValue(230, 230);
3736 bytearr->SetValue(250, 250);
3737 doc->CommitCommand();
3739 if (bytearr->Value(23) != 23)
3741 if (bytearr->Value(25) != 25)
3744 if (bytearr->Value(230) != 230)
3746 if (bytearr->Value(250) != 250)
3749 // TDataStd_NamedData:
3751 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(doc->Main());
3752 nd->SetByte("b14", 12);
3753 nd->SetByte("b17", 18);
3754 nd->SetByte("b14", 14);
3755 nd->SetByte("b17", 17);
3756 doc->CommitCommand();
3758 nd = TDataStd_NamedData::Set(doc->Main());
3759 nd->SetReal("r14", 14);
3760 nd->SetReal("r17", 17);
3761 nd->SetReal("r14", 14.4);
3762 nd->SetReal("r17", 17.7);
3763 doc->CommitCommand();
3765 if (nd->HasStrings())
3769 if (nd->HasReal("r17"))
3771 if (!nd->HasBytes())
3773 if (nd->GetByte("b14") != 14)
3775 if (nd->GetByte("b17") != 17)
3777 if (nd->HasByte("b18"))
3780 if (!nd->HasBytes())
3782 if (!nd->HasReals())
3784 if (nd->GetByte("b14") != 14)
3786 if (nd->GetReal("r14") != 14.4)
3788 if (nd->GetReal("r17") != 17.7)
3794 int TestCopyPaste(const Handle(TDocStd_Document)& doc)
3796 TDF_Label L1 = doc->Main().FindChild(1);
3797 TDF_Label L2 = doc->Main().FindChild(2);
3798 TDF_CopyLabel copier(L1, L2);
3801 TDataStd_Tick::Set(L1);
3803 if (!copier.IsDone())
3805 if (!L2.IsAttribute(TDataStd_Tick::GetID()))
3808 // TDataStd_IntegerList:
3809 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(L1);
3811 intlist->InsertAfter(2, 1);
3813 if (!copier.IsDone())
3817 if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3819 if (intlist->First() != 1)
3821 if (intlist->Last() != 2)
3825 // TDataStd_RealList:
3826 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(L1);
3827 dbllist->Append(1.5);
3828 dbllist->InsertAfter(2.5, 1.5);
3830 if (!copier.IsDone())
3834 if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist))
3836 if (dbllist->First() != 1.5)
3838 if (dbllist->Last() != 2.5)
3842 // TDataStd_ExtStringList:
3843 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(L1);
3844 strlist->Append("Open CASCADE");
3845 strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE");
3847 if (!copier.IsDone())
3851 if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
3853 if (strlist->First() != "Open CASCADE")
3855 if (strlist->Last() != " - is the best set of libraries!")
3859 // TDataStd_BooleanList:
3860 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(L1);
3861 boollist->Append(Standard_True);
3862 boollist->Prepend(Standard_False);
3864 if (!copier.IsDone())
3868 if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist))
3870 if (boollist->First() != Standard_False)
3872 if (boollist->Last() != Standard_True)
3876 // TDataStd_ReferenceList:
3877 TDF_Label L100 = doc->Main().FindChild(100);
3878 TDF_Label L101 = doc->Main().FindChild(101);
3879 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(L1);
3880 reflist->Append(L100);
3881 reflist->InsertAfter(L101, L100);
3883 if (!copier.IsDone())
3887 if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
3889 if (reflist->First() != L100)
3891 if (reflist->Last() != L101)
3895 // TDataStd_BooleanArray:
3896 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(L1, 4, 6);
3897 boolarr->SetValue(4, Standard_True);
3898 boolarr->SetValue(6, Standard_True);
3900 if (!copier.IsDone())
3903 if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
3905 if (boolarr->Value(4) != Standard_True)
3907 if (boolarr->Value(5) != Standard_False)
3909 if (boolarr->Value(6) != Standard_True)
3912 // TDataStd_ReferenceArray:
3913 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(L1, 3, 4);
3914 refarr->SetValue(3, L100);
3915 refarr->SetValue(4, L101);
3917 if (!copier.IsDone())
3920 if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
3922 if (refarr->Value(3) != L100)
3924 if (refarr->Value(4) != L101)
3927 // TDataStd_ByteArray:
3928 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(L1, 4, 6);
3929 bytearr->SetValue(4, 40);
3930 bytearr->SetValue(6, 60);
3932 if (!copier.IsDone())
3935 if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
3937 if (bytearr->Value(4) != 40)
3939 if (bytearr->Value(6) != 60)
3942 // TDataStd_NamedData:
3943 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(L1);
3944 nd->SetInteger("Integer1", 11);
3945 nd->SetReal("Real1", 11.1);
3946 nd->SetString("String1", "11.11111111");
3947 nd->SetByte("Byte1", 111);
3948 Handle(TColStd_HArray1OfInteger) ints_arr = new TColStd_HArray1OfInteger(4, 5);
3949 ints_arr->SetValue(4, 4);
3950 ints_arr->SetValue(5, 5);
3951 nd->SetArrayOfIntegers("Integers1", ints_arr);
3953 if (!copier.IsDone())
3956 if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd))
3958 if (!nd->HasIntegers())
3960 if (!nd->HasReals())
3962 if (!nd->HasStrings())
3964 if (!nd->HasBytes())
3966 if (!nd->HasArraysOfIntegers())
3968 if (nd->HasArraysOfReals())
3970 if (!nd->HasInteger("Integer1"))
3972 if (nd->GetInteger("Integer1") != 11)
3974 if (!nd->HasReal("Real1"))
3976 if (nd->GetReal("Real1") != 11.1)
3978 if (!nd->HasString("String1"))
3980 if (nd->GetString("String1") != "11.11111111")
3982 if (!nd->HasByte("Byte1"))
3984 if (nd->GetByte("Byte1") != 111)
3986 if (!nd->HasArrayOfIntegers("Integers1"))
3988 const Handle(TColStd_HArray1OfInteger)& ints_arr_out = nd->GetArrayOfIntegers("Integers1");
3989 if (ints_arr_out.IsNull())
3991 if (ints_arr_out->Value(5) != 5)
3997 int TestOpenSave(TCollection_ExtendedString aFile1,
3998 TCollection_ExtendedString aFile2,
3999 TCollection_ExtendedString aFile3)
4002 Handle(TDocStd_Document) doc_std, doc_std_open;
4003 app->NewDocument("MDTV-Standard", doc_std);
4005 TDataStd_Tick::Set(doc_std->Main());
4006 // TDataStd_IntegerList:
4007 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc_std->Main());
4010 // TDataStd_RealList:
4011 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc_std->Main());
4012 dbllist->Append(1.5);
4013 dbllist->Append(5.5);
4014 // TDataStd_ExtStringList:
4015 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc_std->Main());
4016 strlist->Append("Auf");
4017 strlist->Append("Wiedersehen");
4018 // TDataStd_BooleanList:
4019 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc_std->Main());
4020 boollist->Append(Standard_False);
4021 boollist->Append(Standard_True);
4022 // TDataStd_ReferenceList:
4023 TCollection_AsciiString entry1, entry2, entry_first, entry_last;
4024 TDF_Label Lstd1 = doc_std->Main().FindChild(100);
4025 TDF_Tool::Entry(Lstd1, entry1);
4026 TDF_Label Lstd2 = doc_std->Main().FindChild(101);
4027 TDF_Tool::Entry(Lstd2, entry2);
4028 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc_std->Main());
4029 reflist->Append(Lstd1);
4030 reflist->Append(Lstd2);
4031 // TDataStd_BooleanArray:
4032 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc_std->Main(), 15, 18);
4033 boolarr->SetValue(15, Standard_False);
4034 boolarr->SetValue(16, Standard_True);
4035 boolarr->SetValue(17, Standard_True);
4036 boolarr->SetValue(18, Standard_True);
4037 // TDataStd_ReferenceArray:
4038 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc_std->Main(), 45, 46);
4039 refarr->SetValue(45, Lstd1);
4040 refarr->SetValue(46, Lstd2);
4041 // TDataStd_ByteArray:
4042 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc_std->Main(), 15, 18);
4043 bytearr->SetValue(15, 150);
4044 bytearr->SetValue(16, 160);
4045 bytearr->SetValue(17, 170);
4046 bytearr->SetValue(18, 180);
4047 // TDataStd_NamedData:
4048 Handle(TDataStd_NamedData) nameddata = TDataStd_NamedData::Set(doc_std->Main());
4050 TDF_Label Lstd3 = doc_std->Main().FindChild(103);
4051 Handle(TDF_Reference) ref = TDF_Reference::Set(doc_std->Main(), Lstd3);
4054 //if (app->SaveAs(doc_std, "W:\\doc.std") != PCDM_SS_OK)
4055 if (app->SaveAs(doc_std, aFile1) != PCDM_SS_OK)
4064 app->Close(doc_std);
4066 //if (app->Open("W:\\doc.std", doc_std_open) != PCDM_RS_OK)
4067 if (app->Open(aFile1, doc_std_open) != PCDM_RS_OK)
4069 if (!doc_std_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4071 if (!doc_std_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4073 if (intlist->First() != 1)
4075 if (intlist->Last() != 5)
4077 if (!doc_std_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4079 if (dbllist->First() != 1.5)
4081 if (dbllist->Last() != 5.5)
4083 if (!doc_std_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4085 if (strlist->First() != "Auf")
4087 if (strlist->Last() != "Wiedersehen")
4089 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4091 if (boollist->First() != Standard_False)
4093 if (boollist->Last() != Standard_True)
4095 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4097 TDF_Tool::Entry(reflist->First(), entry_first);
4098 if (entry1 != entry_first)
4100 TDF_Tool::Entry(reflist->Last(), entry_last);
4101 if (entry2 != entry_last)
4103 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4105 if (boolarr->Value(15) != Standard_False)
4107 if (boolarr->Value(16) != Standard_True)
4109 if (boolarr->Value(17) != Standard_True)
4111 if (boolarr->Value(18) != Standard_True)
4113 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4115 TDF_Tool::Entry(refarr->Value(45), entry_first);
4116 if (entry1 != entry_first)
4118 TDF_Tool::Entry(refarr->Value(46), entry_last);
4119 if (entry2 != entry_last)
4121 if (!doc_std_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4123 if (bytearr->Value(15) != 150)
4125 if (bytearr->Value(16) != 160)
4127 if (bytearr->Value(17) != 170)
4129 if (bytearr->Value(18) != 180)
4131 if (!doc_std_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4133 if (ref->Get().IsNull())
4135 if (ref->Get().Tag() != 103)
4139 Handle(TDocStd_Document) doc_xml, doc_xml_open;
4140 app->NewDocument("XmlOcaf", doc_xml);
4142 TDataStd_Tick::Set(doc_xml->Main());
4143 // TDataStd_IntegerList:
4144 intlist = TDataStd_IntegerList::Set(doc_xml->Main());
4147 // TDataStd_RealList:
4148 dbllist = TDataStd_RealList::Set(doc_xml->Main());
4149 dbllist->Append(1.5);
4150 dbllist->Append(5.5);
4151 // TDataStd_ExtStringList:
4152 strlist = TDataStd_ExtStringList::Set(doc_xml->Main());
4153 strlist->Append("Guten ");
4154 strlist->Append("Tag");
4155 // TDataStd_BooleanList:
4156 boollist = TDataStd_BooleanList::Set(doc_xml->Main());
4157 boollist->Append(Standard_False);
4158 boollist->Append(Standard_True);
4159 // TDataStd_ReferenceList:
4160 TDF_Label Lxml1 = doc_xml->Main().FindChild(100);
4161 TDF_Tool::Entry(Lxml1, entry1);
4162 TDF_Label Lxml2 = doc_xml->Main().FindChild(101);
4163 TDF_Tool::Entry(Lxml2, entry2);
4164 reflist = TDataStd_ReferenceList::Set(doc_xml->Main());
4165 reflist->Append(Lxml1);
4166 reflist->Append(Lxml2);
4167 // TDataStd_BooleanArray:
4168 boolarr = TDataStd_BooleanArray::Set(doc_xml->Main(), 15, 24);
4169 boolarr->SetValue(15, Standard_False);
4170 boolarr->SetValue(16, Standard_True);
4171 boolarr->SetValue(17, Standard_True);
4172 boolarr->SetValue(18, Standard_True);
4173 boolarr->SetValue(19, Standard_True);
4174 boolarr->SetValue(20, Standard_True);
4175 boolarr->SetValue(21, Standard_False);
4176 boolarr->SetValue(22, Standard_True);
4177 boolarr->SetValue(23, Standard_True);
4178 boolarr->SetValue(24, Standard_True);
4179 // TDataStd_ReferenceArray:
4180 refarr = TDataStd_ReferenceArray::Set(doc_xml->Main(), 444, 445);
4181 refarr->SetValue(444, Lxml1);
4182 refarr->SetValue(445, Lxml2);
4183 // TDataStd_ByteArray:
4184 bytearr = TDataStd_ByteArray::Set(doc_xml->Main(), 15, 24);
4185 bytearr->SetValue(15, 0);
4186 bytearr->SetValue(16, 10);
4187 bytearr->SetValue(17, 100);
4188 bytearr->SetValue(18, 200);
4189 bytearr->SetValue(19, 250);
4190 bytearr->SetValue(20, 251);
4191 bytearr->SetValue(21, 252);
4192 bytearr->SetValue(22, 253);
4193 bytearr->SetValue(23, 254);
4194 bytearr->SetValue(24, 255);
4196 Lstd3 = doc_xml->Main().FindChild(103);
4197 ref = TDF_Reference::Set(doc_xml->Main(), Lstd3);
4200 //if (app->SaveAs(doc_xml, "W:\\doc.xml") != PCDM_SS_OK)
4201 if (app->SaveAs(doc_xml, aFile2) != PCDM_SS_OK)
4205 app->Close(doc_xml);
4207 //if (app->Open("W:\\doc.xml", doc_xml_open) != PCDM_RS_OK)
4208 if (app->Open(aFile2, doc_xml_open) != PCDM_RS_OK)
4210 if (!doc_xml_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4212 if (!doc_xml_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4214 if (intlist->First() != 1)
4216 if (intlist->Last() != 5)
4218 if (!doc_xml_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4220 if (dbllist->First() != 1.5)
4222 if (dbllist->Last() != 5.5)
4224 if (!doc_xml_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4226 if (strlist->First() != "Guten ")
4228 if (strlist->Last() != "Tag")
4230 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4232 if (boollist->First() != Standard_False)
4234 if (boollist->Last() != Standard_True)
4236 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4238 TDF_Tool::Entry(reflist->First(), entry_first);
4239 if (entry1 != entry_first)
4241 TDF_Tool::Entry(reflist->Last(), entry_last);
4242 if (entry2 != entry_last)
4244 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4246 if (boolarr->Value(15) != Standard_False)
4248 if (boolarr->Value(16) != Standard_True)
4250 if (boolarr->Value(17) != Standard_True)
4252 if (boolarr->Value(18) != Standard_True)
4254 if (boolarr->Value(19) != Standard_True)
4256 if (boolarr->Value(20) != Standard_True)
4258 if (boolarr->Value(21) != Standard_False)
4260 if (boolarr->Value(22) != Standard_True)
4262 if (boolarr->Value(23) != Standard_True)
4264 if (boolarr->Value(24) != Standard_True)
4266 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4268 TDF_Tool::Entry(refarr->Value(444), entry_first);
4269 if (entry1 != entry_first)
4271 TDF_Tool::Entry(refarr->Value(445), entry_last);
4272 if (entry2 != entry_last)
4274 if (!doc_xml_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4276 if (bytearr->Value(15) != 0)
4278 if (bytearr->Value(16) != 10)
4280 if (bytearr->Value(17) != 100)
4282 if (bytearr->Value(18) != 200)
4284 if (bytearr->Value(19) != 250)
4286 if (bytearr->Value(20) != 251)
4288 if (bytearr->Value(21) != 252)
4290 if (bytearr->Value(22) != 253)
4292 if (bytearr->Value(23) != 254)
4294 if (bytearr->Value(24) != 255)
4296 if (!doc_xml_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4298 if (ref->Get().IsNull())
4300 if (ref->Get().Tag() != 103)
4304 Handle(TDocStd_Document) doc_bin, doc_bin_open;
4305 app->NewDocument("BinOcaf", doc_bin);
4307 TDataStd_Tick::Set(doc_bin->Main());
4308 // TDataStd_IntegerList:
4309 intlist = TDataStd_IntegerList::Set(doc_bin->Main());
4312 // TDataStd_RealList:
4313 dbllist = TDataStd_RealList::Set(doc_bin->Main());
4314 dbllist->Append(1.5);
4315 dbllist->Append(5.5);
4316 // TDataStd_ExtStringList:
4317 strlist = TDataStd_ExtStringList::Set(doc_bin->Main());
4318 strlist->Append("Bonjour");
4319 strlist->Append("Bonsoir");
4320 // TDataStd_BooleanList:
4321 boollist = TDataStd_BooleanList::Set(doc_bin->Main());
4322 boollist->Append(Standard_False);
4323 boollist->Append(Standard_True);
4324 // TDataStd_ReferenceList:
4325 TDF_Label Lbin1 = doc_bin->Main().FindChild(100);
4326 TDF_Tool::Entry(Lbin1, entry1);
4327 TDF_Label Lbin2 = doc_bin->Main().FindChild(101);
4328 TDF_Tool::Entry(Lbin2, entry2);
4329 reflist = TDataStd_ReferenceList::Set(doc_bin->Main());
4330 reflist->Append(Lbin1);
4331 reflist->Append(Lbin2);
4332 // TDataStd_BooleanArray:
4333 boolarr = TDataStd_BooleanArray::Set(doc_bin->Main(), 15, 24);
4334 boolarr->SetValue(15, Standard_False);
4335 boolarr->SetValue(16, Standard_True);
4336 boolarr->SetValue(17, Standard_True);
4337 boolarr->SetValue(18, Standard_True);
4338 boolarr->SetValue(19, Standard_True);
4339 boolarr->SetValue(20, Standard_True);
4340 boolarr->SetValue(21, Standard_False);
4341 boolarr->SetValue(22, Standard_True);
4342 boolarr->SetValue(23, Standard_True);
4343 boolarr->SetValue(24, Standard_True);
4344 // TDataStd_ReferenceArray:
4345 refarr = TDataStd_ReferenceArray::Set(doc_bin->Main(), 0, 1);
4346 refarr->SetValue(0, Lbin1);
4347 refarr->SetValue(1, Lbin2);
4348 // TDataStd_ByteArray:
4349 bytearr = TDataStd_ByteArray::Set(doc_bin->Main(), 15, 16);
4350 bytearr->SetValue(15, 0);
4351 bytearr->SetValue(16, 255);
4352 // TDataStd_NamedData:
4353 nameddata = TDataStd_NamedData::Set(doc_bin->Main());
4354 nameddata->SetByte("A", 12);
4355 nameddata->SetByte("B", 234);
4357 Lstd3 = doc_bin->Main().FindChild(103);
4358 ref = TDF_Reference::Set(doc_bin->Main(), Lstd3);
4361 //if (app->SaveAs(doc_bin, "W:\\doc.cbf") != PCDM_SS_OK)
4362 if (app->SaveAs(doc_bin, aFile3) != PCDM_SS_OK)
4366 app->Close(doc_bin);
4368 //if (app->Open("W:\\doc.cbf", doc_bin_open) != PCDM_RS_OK)
4369 if (app->Open(aFile3, doc_bin_open) != PCDM_RS_OK)
4371 if (!doc_bin_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4373 if (!doc_bin_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4375 if (intlist->First() != 1)
4377 if (intlist->Last() != 5)
4379 if (!doc_bin_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4381 if (dbllist->First() != 1.5)
4383 if (dbllist->Last() != 5.5)
4385 if (!doc_bin_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4387 if (strlist->First() != "Bonjour")
4389 if (strlist->Last() != "Bonsoir")
4391 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4393 if (boollist->First() != Standard_False)
4395 if (boollist->Last() != Standard_True)
4397 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4399 TDF_Tool::Entry(reflist->First(), entry_first);
4400 if (entry1 != entry_first)
4402 TDF_Tool::Entry(reflist->Last(), entry_last);
4403 if (entry2 != entry_last)
4405 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4407 if (boolarr->Value(15) != Standard_False)
4409 if (boolarr->Value(16) != Standard_True)
4411 if (boolarr->Value(17) != Standard_True)
4413 if (boolarr->Value(18) != Standard_True)
4415 if (boolarr->Value(19) != Standard_True)
4417 if (boolarr->Value(20) != Standard_True)
4419 if (boolarr->Value(21) != Standard_False)
4421 if (boolarr->Value(22) != Standard_True)
4423 if (boolarr->Value(23) != Standard_True)
4425 if (boolarr->Value(24) != Standard_True)
4427 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4429 TDF_Tool::Entry(refarr->Value(0), entry_first);
4430 if (entry1 != entry_first)
4432 TDF_Tool::Entry(refarr->Value(1), entry_last);
4433 if (entry2 != entry_last)
4435 if (!doc_bin_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4437 if (bytearr->Value(15) != 0)
4439 if (bytearr->Value(16) != 255)
4441 if (!doc_bin_open->Main().FindAttribute(TDataStd_NamedData::GetID(), nameddata))
4443 if (nameddata->GetByte("A") != 12)
4445 if (nameddata->GetByte("B") != 234)
4447 if (!doc_bin_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4449 if (ref->Get().IsNull())
4451 if (ref->Get().Tag() != 103)
4456 // For OCC16782 testing
4458 static Standard_Integer OCC16782 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4462 di << "Usage : " << argv[0] << " file.std file.xml file.cbf\n";
4465 TCollection_ExtendedString aFile1(argv[1]);
4466 TCollection_ExtendedString aFile2(argv[2]);
4467 TCollection_ExtendedString aFile3(argv[3]);
4470 app = new AppStd_Application();
4474 Handle(TDocStd_Document) doc;
4475 app->NewDocument("MDTV-Standard", doc);
4476 doc->SetUndoLimit(10);
4478 di <<"\nTestSetGet start\n";
4479 good += TestSetGet(doc);
4480 di <<"TestSetGet finish\n";
4481 di <<"Status = " << good << "\n";
4483 di <<"\nTestUndoRedo start\n";
4484 good += TestUndoRedo(doc);
4485 di <<"TestUndoRedo finish\n";
4486 di <<"Status = " << good << "\n";
4488 di <<"\nTestCopyPaste start\n";
4489 good += TestCopyPaste(doc);
4490 di <<"TestCopyPaste finish\n";
4491 di <<"Status = " << good << "\n";
4493 di <<"\nTestOpenSave start\n";
4494 good += TestOpenSave(aFile1, aFile2, aFile3);
4495 di <<"TestOpenSave finish\n";
4496 di <<"Status = " << good << "\n";
4499 di <<"\nThe " << argv[0] << " test is passed well, OK\n";
4501 di <<"\nThe " << argv[0] << " test failed, Faulty\n";
4506 static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4508 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4509 if(aContext.IsNull()) {
4510 di << argv[0] << " ERROR : use 'vinit' command before " << "\n";
4516 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4519 Standard_Integer mode = 0;
4522 mode = Draw::Atoi(argv[1]);
4524 if (mode > 2 || mode < 0)
4526 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4529 Handle(V3d_View) V = ViewerTest::CurrentView();
4530 if ( !V.IsNull() ) {
4532 V->ColorScaleDisplay();
4535 V->ColorScaleErase();
4540 Standard_Boolean IsDisplayed = V->ColorScaleIsDisplayed();
4542 di <<"ColorScaleIsDisplayed = " << "1" << "\n";
4544 di <<"ColorScaleIsDisplayed = " << "0" << "\n";
4550 #include <Interface_Macros.hxx>
4551 #include <IGESControl_Controller.hxx>
4552 #include <XSDRAW.hxx>
4553 #include <Draw_ProgressIndicator.hxx>