1 // Created on: 2002-03-20
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
21 #include <Draw_Interpretor.hxx>
23 #include <DrawTrSurf.hxx>
24 #include <AIS_InteractiveContext.hxx>
25 #include <ViewerTest.hxx>
26 #include <AIS_Shape.hxx>
27 #include <TopoDS_Shape.hxx>
29 #include <Geom_Surface.hxx>
30 #include <Geom_Axis2Placement.hxx>
32 #include <gp_Trsf.hxx>
33 #include <AIS_Trihedron.hxx>
34 #include <BRepPrimAPI_MakeBox.hxx>
35 #include <Graphic3d_MaterialAspect.hxx>
36 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
37 #include <TopoDS_Solid.hxx>
38 #include <BRepPrimAPI_MakeSphere.hxx>
39 #include <BRepPrimAPI_MakeCone.hxx>
40 #include <BRepPrimAPI_MakeCylinder.hxx>
41 #include <IGESToBRep_Reader.hxx>
42 #include <TopExp_Explorer.hxx>
44 #include <GCPnts_UniformDeflection.hxx>
45 #include <BRepAdaptor_Curve.hxx>
46 #include <IGESToBRep.hxx>
47 #include <V3d_Viewer.hxx>
48 #include <BRepAdaptor_CompCurve.hxx>
49 #include <GCPnts_AbscissaPoint.hxx>
50 #include <Standard_ErrorHandler.hxx>
51 #include <Standard_Overflow.hxx>
52 #include <Standard_Underflow.hxx>
53 #include <Standard_DivideByZero.hxx>
54 #include <OSD_SIGSEGV.hxx>
55 #include <OSD_Exception_ACCESS_VIOLATION.hxx>
56 #include <OSD_Exception_STACK_OVERFLOW.hxx>
58 #include <STEPCAFControl_Writer.hxx>
59 #include <STEPControl_StepModelType.hxx>
60 #include <Interface_Static.hxx>
61 #include <IFSelect_ReturnStatus.hxx>
62 #include <Standard_Failure.hxx>
63 #include <TColgp_HArray1OfPnt2d.hxx>
64 #include <Geom2dAPI_Interpolate.hxx>
65 #include <Geom2d_BSplineCurve.hxx>
66 #include <Geom2dConvert_BSplineCurveToBezierCurve.hxx>
67 #include <Geom2d_BezierCurve.hxx>
68 #include <BRep_Tool.hxx>
69 #include <GeomProjLib.hxx>
70 #include <Geom2dAPI_InterCurveCurve.hxx>
71 #include <IntRes2d_IntersectionSegment.hxx>
72 #include <TDataStd_RealArray.hxx>
73 #include <TDF_CopyLabel.hxx>
74 #include <NCollection_Vector.hxx>
75 #include <TColStd_Array1OfInteger.hxx>
76 #include <Geom_BSplineCurve.hxx>
77 #include <TColgp_Array1OfPnt.hxx>
78 #include <AIS_ColorScale.hxx>
79 #include <AIS_ListOfInteractive.hxx>
80 #include <AIS_ListIteratorOfListOfInteractive.hxx>
81 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
82 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
83 #include <BRepBuilderAPI_MakePolygon.hxx>
84 #include <gp_GTrsf.hxx>
85 #include <Poly_Triangulation.hxx>
86 #include <IGESControl_Reader.hxx>
87 #include <IGESData_IGESModel.hxx>
88 #include <IGESData_IGESEntity.hxx>
89 #include <V3d_View.hxx>
90 #include <BRepFeat_SplitShape.hxx>
91 #include <BRepAlgoAPI_Section.hxx>
92 #include <TColStd_PackedMapOfInteger.hxx>
95 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
97 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
100 static Standard_Integer OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
102 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
103 if(myAISContext.IsNull()) {
104 di << "use 'vinit' command before " << argv[0] ;
108 Handle(Geom_Axis2Placement) aTrihedronAxis = new Geom_Axis2Placement(gp::XOY());
111 trsf1.SetTranslation(gp_Vec(100, 100, 0));
112 aTrihedronAxis->Transform(trsf1);
113 Handle(AIS_Trihedron) myTrihedron = new AIS_Trihedron(aTrihedronAxis);
114 myTrihedron->SetColor(Quantity_NOC_LIGHTSTEELBLUE4);
115 myTrihedron->SetSize(100);
116 myAISContext->Display(myTrihedron, Standard_True);
118 // TopoDS_Shape shape1 = (TopoDS_Shape) BRepPrimAPI_MakeBox(50,50,50);
119 TopoDS_Shape shape1 = BRepPrimAPI_MakeBox(50,50,50).Shape();
120 Handle(AIS_Shape) AS = new AIS_Shape(shape1);
121 AS->SetDisplayMode(1);
122 Graphic3d_MaterialAspect mat(Graphic3d_NOM_PLASTIC);
123 AS->SetMaterial(mat);
124 AS->SetColor(Quantity_NOC_RED);
125 myAISContext->Display (AS, Standard_False);
128 TouchTrsf.SetTranslation(gp_Vec(20, 20, 0));
130 myAISContext->ResetLocation(AS);
131 myAISContext->SetLocation(AS , TouchTrsf) ;
132 myAISContext->Redisplay(AS, Standard_True);
137 // Remove as bad version of QAAddOrRemoveSelected from QADraw
138 //static Standard_Integer OCC129 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
141 // di<<"Usage : " << argv[0] << " shape islocal\n";
145 // Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
147 // // ViewerTest_DoubleMapOfInteractiveAndName& aMap =
148 // // ViewerTest::GetDataMapOfAIS ();
149 // ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
151 // TCollection_AsciiString aName(argv[1]);
152 // Handle(AIS_InteractiveObject) AISObj;
154 // if(aMap.IsBound2(aName)) {
155 // AISObj = aMap.Find2(aName);
156 // if(AISObj.IsNull()){
157 // di<<"No interactive object \n";
161 // Standard_Integer aNum = -1;
163 // if(Draw::Atoi(argv[2])) {
164 // aNum = anAISCtx->OpenLocalContext();
167 // if(anAISCtx->HasOpenedContext()){
168 // anAISCtx->InitSelected();
169 // anAISCtx->AddOrRemoveSelected(AISObj);
172 // anAISCtx->InitCurrent();
173 // anAISCtx->AddOrRemoveCurrentObject(AISObj);
177 // // anAISCtx->CloseLocalContext(aNum);
182 // //select this shape:
184 // di<<"Use 'vdisplay' before";
189 static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
192 di<<"Usage: OCC136\n";
196 //create some primitives:
198 Standard_Real Size=100;
199 gp_Pnt P0(0,0,0), P1(Size,Size,Size);
201 TopoDS_Solid aBox = BRepPrimAPI_MakeBox(P0,P1);
203 TopoDS_Solid aSphere = BRepPrimAPI_MakeSphere (Size*0.5);
205 gp_Ax2 anAx2(P1, gp_Dir(1,1,1));
206 TopoDS_Solid aCone = BRepPrimAPI_MakeCone(anAx2, Size*0.7, Size*0.3, Size);
208 anAx2.SetLocation(gp_Pnt(Size,0,0));
209 anAx2.SetDirection(gp_Dir(-1,-1,1));
210 TopoDS_Solid aCyl = BRepPrimAPI_MakeCylinder(anAx2, Size*0.5, Size);
212 Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
213 if(anAISCtx.IsNull()){
214 di<<"Null interactive context. Use 'vinit' at first.\n";
218 anAISCtx->EraseAll (Standard_False);
220 //load primitives to context
221 Handle(AIS_InteractiveObject) aSh1 = new AIS_Shape(aBox);
222 anAISCtx->Display (aSh1, Standard_False);
224 Handle(AIS_InteractiveObject) aSh2 = new AIS_Shape(aSphere);
225 anAISCtx->Display (aSh2, Standard_False);
227 Handle(AIS_InteractiveObject) aSh3 = new AIS_Shape(aCone);
228 anAISCtx->Display (aSh3, Standard_False);
230 Handle(AIS_InteractiveObject) aSh4 = new AIS_Shape(aCyl);
231 anAISCtx->Display (aSh4, Standard_False);
234 anAISCtx->InitSelected();
235 anAISCtx->AddOrRemoveSelected (aSh1, Standard_False);
236 anAISCtx->AddOrRemoveSelected (aSh2, Standard_False);
237 anAISCtx->AddOrRemoveSelected (aSh3, Standard_False);
238 anAISCtx->AddOrRemoveSelected (aSh4, Standard_False);
240 //remove all this objects from context
241 anAISCtx->Remove (aSh1, Standard_False);
242 anAISCtx->Remove (aSh2, Standard_False);
243 anAISCtx->Remove (aSh3, Standard_False);
244 anAISCtx->Remove (aSh4, Standard_False);
246 anAISCtx->UpdateCurrentViewer();
250 static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
252 printf("Usage: %s iges_input [name]\n",argv[0]);
255 Standard_Character *Ch = NULL;
258 Ch = new Standard_Character[strlen(argv[2])+3];
260 IGESToBRep_Reader IR;
261 IR.LoadFile (argv[1]);
264 TopoDS_Shape aTopShape = IR.OneShape();
265 TopExp_Explorer ex(aTopShape, TopAbs_EDGE);
266 Standard_Integer i=0;
267 for( ; ex.More(); ex.Next()){
268 const TopoDS_Edge &E = TopoDS::Edge(ex.Current());
269 BRepAdaptor_Curve aCurve(E);
270 GCPnts_UniformDeflection plin(aCurve, 0.1);
271 di << "Num points = " << plin.NbPoints() << "\n";
274 Sprintf(Ch,"%s_%i",argv[2],1);
281 //====================================================
283 // Following code is inserted from
284 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
285 // ( 75455 Apr 16 18:59)
287 //====================================================
290 #include <BRepTools_WireExplorer.hxx>
291 #include <BRep_Tool.hxx>
292 #include <GCPnts_UniformAbscissa.hxx>
293 #include <TopExp.hxx>
296 // usage : OCC105 shape
299 //GCPnts_UniformAbscissa returns bad end point foe first edge. Its value is
301 //Value Pnt = -338.556216693211 -394.465571897208 0
303 //Value Pnt = -307.47165394 -340.18073533 0
305 static int OCC105(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
308 di<<"Usage : OCC105 shape\n";
311 // TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get("aa.brep"));
312 TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1]));
313 Standard_Real l = 0.5; //Draw::Atof(argv[2]);
314 // Find the first vertex of the wire
315 BRepTools_WireExplorer wire_exp(myTopoDSWire);
318 TopoDS_Vertex vw1, vw2;
319 TopExp::Vertices(myTopoDSWire,vw1,vw2);
320 TopoDS_Vertex ve1, ve2;
321 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
322 TopExp::Vertices(edge,ve1,ve2);
323 if (vw1.IsSame(ve1) || vw1.IsSame(ve2))
326 // assert(vw2.IsSame(ve1) || vw2.IsSame(ve2));
330 for ( ; wire_exp.More(); wire_exp.Next())
332 di << "\n\n New Edge \n" << "\n";
333 Standard_Real newufirst, newulast;
334 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
335 Standard_Real ufirst, ulast;
336 Handle(Geom_Curve) acurve;
337 TopoDS_Vertex ve1, ve2;
338 TopExp::Vertices(edge,ve1,ve2);
339 if (ve1.IsSame(vlast))
341 acurve = BRep_Tool::Curve(edge, ufirst, ulast);
348 // assert(ve2.IsSame(vlast));
349 // assert ( wire_exp.Orientation( ) == TopAbs_REVERSED );
350 acurve = BRep_Tool::Curve( edge, ufirst, ulast );
351 newufirst = acurve->ReversedParameter( ufirst );
352 newulast = acurve->ReversedParameter( ulast );
353 acurve = acurve->Reversed( );
357 GeomAdaptor_Curve curve;
358 GCPnts_UniformAbscissa algo;
360 algo.Initialize( curve, l, newufirst, newulast );
362 di << "Not Done!!!" << "\n";
363 for (Standard_Integer Index = 1; Index<=algo.NbPoints();Index++) {
364 Standard_Real t = algo.Parameter(Index);
365 gp_Pnt pt3 = curve.Value(t);
366 di << "Parameter t = " << t << "\n";
367 di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z() << "\n";
374 #include <TColStd_SequenceOfTransient.hxx>
375 #include <GeomFill_Pipe.hxx>
376 static int pipe_OCC9 (Draw_Interpretor& di,
377 Standard_Integer n, const char ** a)
380 di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]\n";
384 TColStd_SequenceOfTransient aCurveSeq;
386 for (i=2 ; i<=4; i++) {
387 Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast( DrawTrSurf::Get(a[i]) );
389 di << a[i] << " is not a curve\n";
392 aCurveSeq.Append(aC);
395 GeomFill_Pipe aPipe(Handle(Geom_Curve)::DownCast( aCurveSeq(1) ),
396 Handle(Geom_Curve)::DownCast( aCurveSeq(2) ),
397 Handle(Geom_Curve)::DownCast( aCurveSeq(3) ),
401 aPipe.Perform(Draw::Atof (a[6]), Standard_True);
403 aPipe.Perform(Standard_True/*, Standard_True*/);
406 if (!aPipe.IsDone()) {
407 di << "GeomFill_Pipe cannot make a surface\n";
411 Handle(Geom_Surface) aSurf = aPipe.Surface();
413 DrawTrSurf::Set(a[1], aSurf);
417 //======================================================================
419 // usage : OCC125 shell
420 //======================================================================
421 #include <ShapeFix_Shell.hxx>
423 Standard_Integer OCC125(Draw_Interpretor& di ,
428 di<<" Use OCC125 shell";
432 TopoDS_Shape S = DBRep::Get(a[1]);
435 di<<" Null shape is not allowed";
441 if (aT!=TopAbs_SHELL) {
442 di<<" Shape Type must be SHELL";
446 const TopoDS_Shell& aShell = TopoDS::Shell(S);
448 Standard_Boolean isAccountMultiConex, bNonManifold, bResult;
450 isAccountMultiConex=Standard_True;
451 bNonManifold=Standard_False;
453 Handle (ShapeFix_Shell) aFix = new ShapeFix_Shell(aShell);
454 bResult=aFix->FixFaceOrientation(aShell, isAccountMultiConex, bNonManifold);
456 di<<"bResult="<<(Standard_Integer)bResult;
459 aShape=aFix->Shape();
461 TCollection_AsciiString aName(a[1]), aDef("_sh"), aRName;
464 DBRep::Set (aRName.ToCString(), aShape);
465 di<<aRName.ToCString();
470 #include <BRepLib_FindSurface.hxx>
471 #include <BRepBuilderAPI_MakeFace.hxx>
472 Standard_Integer OCC157(Draw_Interpretor& di,
475 //static Standard_Integer findplanarsurface(Draw_Interpretor&, Standard_Integer n, const char ** a)
478 di << "bad number of arguments\n";
482 // try to read a shape:
483 TopoDS_Shape inputShape=DBRep::Get(a[2]);
484 if (inputShape.IsNull() || inputShape.ShapeType() != TopAbs_WIRE) {
485 di << "Invalid input shape\n";
488 Standard_Real toler = Draw::Atof(a[3]);
489 TopoDS_Wire aWire = TopoDS::Wire(inputShape);
490 BRepLib_FindSurface FS(aWire, toler, Standard_True);
492 di<<"OCC157: OK; Planar surface is found\n";
493 Handle(Geom_Surface) aSurf = FS.Surface();
494 BRepBuilderAPI_MakeFace aMakeFace(aSurf,aWire,Standard_True);
495 if(aMakeFace.IsDone()) {
496 TopoDS_Face aFace = aMakeFace.Face();
497 DBRep::Set(a[1],aFace);
500 else di<<"OCC157: ERROR; Planar surface is not found with toler = "<<toler <<"\n";
505 // #include <MyCommandsCMD.h>
506 #include <ShapeFix_Shape.hxx>
507 #include <BRepOffset_MakeOffset.hxx>
508 #include <BRepOffsetAPI_MakeOffset.hxx>
509 #include <BRepOffset_Mode.hxx>
510 #include <GeomAbs_JoinType.hxx>
511 #include <AIS_Shape.hxx>
513 #include <BRepTools.hxx>
515 Standard_Integer OCC165(Draw_Interpretor& di ,
520 //=======================================================================
522 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv);
524 // void MyOffsets_Commands(Draw_Interpretor& theCommands)
526 // theCommands.Add("yoffset" , "yoffset" , __FILE__, YOffset, " Offset on Z Direction");
529 //=======================================================================
531 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
535 di <<"Usage : " << a[0] << " [file]\n";
540 #define _OFFSET_TELCO_
541 #ifdef _OFFSET_TELCO_
543 Standard_CString file = a[1];
545 BRep_Builder aBuilder;
546 TopoDS_Shape theShape;
547 //BRepTools::Read(theShape, Standard_CString("/dn02/users_SUN/inv/3/OCC165/2d_tr_line.brep"), aBuilder);
548 BRepTools::Read(theShape, file, aBuilder);
549 DBRep::Set("shape", theShape);
551 TopoDS_Wire theWire = TopoDS::Wire(theShape);
553 Standard_Real anOffset = 1.5;
557 Standard_Real xA = 0.0, xB = 200.0, xC = 200.0, xD = 0.0,
558 yA = 0.0, yB = 0.0, yC = 200.0, yD = 200.0,
559 zA = 0.0, zB = 0.0, zC = 0.0, zD = 0.0;
561 BRepBuilderAPI_MakePolygon theSquare;
562 TopoDS_Vertex theA = BRepBuilderAPI_MakeVertex(gp_Pnt(xA, yA, zA));
564 TopoDS_Vertex theB = BRepBuilderAPI_MakeVertex(gp_Pnt(xB, yB, zB));
566 TopoDS_Vertex theC = BRepBuilderAPI_MakeVertex(gp_Pnt(xC, yC, zC));
568 TopoDS_Vertex theD = BRepBuilderAPI_MakeVertex(gp_Pnt(xD, yD, zD));
572 TopoDS_Wire theWire = theSquare.Wire();
574 Standard_Real anOffset = 10;
577 #endif /* _OFFSET_TELCO_ */
580 TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire).Face();
581 DBRep::Set("face", theFace);
584 Standard_Real anAlt = 0.;
585 GeomAbs_JoinType theJoin = GeomAbs_Intersection;
586 //GeomAbs_Intersection; //GeomAbs_Arc;
587 BRepOffsetAPI_MakeOffset aMakeOffset(theFace, theJoin);
588 aMakeOffset.AddWire(theWire);
590 aMakeOffset.Perform(anOffset, anAlt);
592 TopoDS_Shape theOffsetShapePos = aMakeOffset.Shape();
593 DBRep::Set("offset", theOffsetShapePos);
598 #include<BRepAlgoAPI_Cut.hxx>
599 #include<BRepAlgo_Cut.hxx>
601 #include<BRepPrimAPI_MakeHalfSpace.hxx>
602 #include<Geom_CartesianPoint.hxx>
603 #include<AIS_Point.hxx>
605 #include <BRepBuilderAPI_MakeEdge.hxx>
606 #include <BRepBuilderAPI_MakeWire.hxx>
607 #include <BRepBuilderAPI_MakeFace.hxx>
609 static Standard_Integer OCC297 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
613 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
614 if(myAISContext.IsNull()) {
615 di << "use 'vinit' command before " << argv[0] << "\n";
620 gp_Pnt pt1_(250.,250.,0.);
621 gp_Pnt pt2_(-250.,250.,0.);
622 gp_Pnt pt3_(-250.,-250.,0.);
623 gp_Pnt pt4_(250.,-250.,0.);
624 BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
625 BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
626 BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
627 BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
629 BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
630 BRepBuilderAPI_MakeFace face_(wire_);
631 TopoDS_Face sh_ = face_.Face();
637 g_pnt = gp_Pnt(0,0,-100);
639 g_pnt = gp_Pnt(0,0,100);
641 myAISContext->EraseAll(Standard_False);
642 Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
643 Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
644 myAISContext->Display (AISPoint, Standard_True);
646 BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
647 TopoDS_Solid sol1_ = half_.Solid();
648 // Handle(AIS_Shape) AISHalf = new AIS_Shape(sol1_);
649 // AISHalf->SetColor(Quantity_NOC_GREEN);
650 // myAISContext->Display(AISHalf);
652 DBRep::Set("Face",sol1_);
654 gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
656 Standard_Real x=0., y=0., z=-80.;
658 BRepPrimAPI_MakeBox box(gp_Pnt(x,y,z),gp_Pnt(x+150,y+200,z+200));
659 // Handle(AIS_Shape) AISBox = new AIS_Shape(box);
660 // AISBox->SetColor(Quantity_NOC_BLUE1);
661 // myAISContext->Display(AISBox);
663 DBRep::Set("Box",box.Shape());
665 // BRepAlgoAPI_Cut cut( sol1_, box.Shape() );
666 // //BRepAlgoAPI_Cut cut( box.Shape(), sol1_ );
667 // TopoDS_Shape sh1_ = cut.Shape();
668 // Handle(AIS_Shape) AISCut = new AIS_Shape(sh1_);
669 // AISCut->SetColor(Quantity_NOC_RED);
670 // myAISContext->Display(AISCut);
672 // DBRep::Set("Cut",sh1_);
677 #include<GProp_GProps.hxx>
678 #include<BRepGProp.hxx>
680 static Standard_Integer OCC305 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
685 di <<"Usage : " << argv[0] << " file\n";
688 Standard_CString file = argv[1];
690 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
691 if(myAISContext.IsNull()) {
692 di << "use 'vinit' command before " << argv[0] << "\n";
697 BRep_Builder builder;
698 //BRepTools::Read(sh, "/dn02/users_SUN/inv/3/OCC305/testc.brep", builder);
699 BRepTools::Read(sh, file, builder);
702 builder.MakeWire(wire);
704 TopoDS_Vertex vt1, vt2;
705 TopExp_Explorer wex(sh, TopAbs_EDGE);
706 for(;wex.More();wex.Next())
708 ed = TopoDS::Edge(wex.Current());
709 TopExp::Vertices(ed, vt1, vt2);
710 builder.UpdateVertex(vt1, 0.01);
711 builder.UpdateVertex(vt2, 0.01);
712 builder.UpdateEdge(ed, 0.01);
713 builder.Add(wire, ed);
717 BRepGProp::LinearProperties(ed, lprop);
718 printf("\n length = %f", lprop.Mass());
720 DBRep::Set("Wire",wire);
721 // Handle(AIS_Shape) res = new AIS_Shape( wire );
722 // aContext->SetColor( res, Quantity_NOC_RED );
723 // aContext->Display( res );
725 // BRepOffsetAPI_MakeOffset off(wire, GeomAbs_Arc);
726 // off.Perform(0.5, 0);
728 // printf("\n IsDone = %d", off.IsDone());
730 // res = new AIS_Shape( sh );
731 // aContext->SetColor( res, Quantity_NOC_GREEN );
732 // aContext->Display( res );
738 static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
741 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
742 if(myAISContext.IsNull()) {
743 di << "use 'vinit' command before " << argv[0];
747 BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
748 Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape());
749 myAISContext->SetAutoActivateSelection (Standard_False);
750 myAISContext->Display(anAISBox, 1);
752 TColStd_ListOfInteger anActivatedModes;
753 myAISContext->ActivatedModes (anAISBox, anActivatedModes);
754 if(anActivatedModes.Extent() != 1 || anActivatedModes.First() != -1 )
760 #include <TDocStd_Document.hxx>
761 #include <DDocStd.hxx>
762 #include <PCDM_StoreStatus.hxx>
763 #include <TDocStd_Application.hxx>
765 static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
768 di << "Usage: " << a[0] << " Doc\n";
772 Handle(TDocStd_Document) D;
773 if (!DDocStd::GetDocument(a[1],D)) return 1;
775 Handle(TDocStd_Application) A = DDocStd::GetApplication();
777 TCollection_ExtendedString theStatusMessage;
779 di << "this document has never been saved\n";
782 PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
783 if (theStatus != PCDM_SS_OK ) {
784 switch ( theStatus ) {
785 case PCDM_SS_DriverFailure: {
786 di << "Error saving document: Could not store , no driver found to make it\n";
789 case PCDM_SS_WriteFailure: {
790 di << "Error saving document: Write access failure\n";
793 case PCDM_SS_Failure: {
794 di << "Error saving document: Write failure\n" ;
797 case PCDM_SS_Doc_IsNull: {
798 di << "Error saving document: No document to save\n";
801 case PCDM_SS_No_Obj: {
802 di << "Error saving document: No objects written\n";
805 case PCDM_SS_Info_Section_Error: {
806 di << "Error saving document: Write info section failure\n" ;
817 static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
820 di << "Usage: " << a[0] << " Doc Path\n";
824 Handle(TDocStd_Document) D;
825 if (!DDocStd::GetDocument(a[1],D)) return 1;
827 TCollection_ExtendedString path (a[2]);
828 Handle(TDocStd_Application) A = DDocStd::GetApplication();
830 TCollection_ExtendedString theStatusMessage;
831 PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
832 if (theStatus != PCDM_SS_OK ) {
833 switch ( theStatus ) {
834 case PCDM_SS_DriverFailure: {
835 di << "Error saving document: Could not store , no driver found to make it\n";
838 case PCDM_SS_WriteFailure: {
839 di << "Error saving document: Write access failure\n";
842 case PCDM_SS_Failure: {
843 di << "Error saving document: Write failure\n" ;
846 case PCDM_SS_Doc_IsNull: {
847 di << "Error saving document: No document to save\n";
850 case PCDM_SS_No_Obj: {
851 di << "Error saving document: No objects written\n";
854 case PCDM_SS_Info_Section_Error: {
855 di << "Error saving document: Write info section failure\n" ;
867 #include <BRepClass3d_SolidClassifier.hxx>
869 Standard_Integer OCC299bug (Draw_Interpretor& theDi,
870 Standard_Integer theArgNb,
871 const char** theArgVec)
875 theDi << "Usage : " << theArgVec[0] << " Solid Point [Tolerance=1.e-7]\n";
879 TopoDS_Shape aS = DBRep::Get (theArgVec[1]);
882 theDi << " Null Shape is not allowed here\n";
885 else if (aS.ShapeType() != TopAbs_SOLID)
887 theDi << " Shape type must be SOLID\n";
891 gp_Pnt aP (8., 9., 10.);
892 if (!DrawTrSurf::GetPoint (theArgVec[2], aP))
894 theDi << " Null Point is not allowed here\n";
897 const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : 1.e-7;
899 BRepClass3d_SolidClassifier aSC (aS);
900 aSC.Perform (aP, aTol);
904 case TopAbs_IN: theDi << "The point is IN shape\n"; return 0;
905 case TopAbs_OUT: theDi << "The point is OUT of shape\n"; return 0;
906 case TopAbs_ON: theDi << "The point is ON shape\n"; return 0;
908 default: theDi << "The point is UNKNOWN shape\n"; return 0;
912 #include <OSD_Process.hxx>
913 #include <OSD_Path.hxx>
915 static Standard_Integer OCC309bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
918 di << "Usage: " << a[0] << "\n";
922 OSD_Path d = p.CurrentDirectory();
923 TCollection_AsciiString s;
925 di << "*" << s.ToCString() << "*\n";
928 di << "*" << s.ToCString() << "*\n";
932 static Standard_Integer OCC310bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
935 di << "Usage: " << a[0] << "\n";
938 OSD_Path p("/where/you/want/tmp/qwerty/tmp/");
939 di << p.Trek().ToCString() << "\n";
941 di << p.Trek().ToCString() << "\n";
945 #include <BRepAlgoAPI_Fuse.hxx>
946 #include <BRepAlgoAPI_Common.hxx>
947 #include <BRepAlgo_Fuse.hxx>
948 #include <BRepAlgo_Common.hxx>
950 static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
953 // cout << "Usage: " << a[0] << endl;
956 if(nb < 1 || nb > 2) {
957 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
960 Standard_Boolean IsBRepAlgoAPI = Standard_True;
962 Standard_Integer IsB = Draw::Atoi(a[1]);
964 IsBRepAlgoAPI = Standard_False;
968 BRepPrimAPI_MakeBox box1( 100, 100, 100 );
969 BRepPrimAPI_MakeBox box2( gp_Pnt( 50, 50,50 ), 200, 200, 200 );
971 TopoDS_Shape shape1 = box1.Shape();
972 TopoDS_Shape shape2 = box2.Shape();
974 //#if ! defined(BRepAlgoAPI_def01)
975 // TopoDS_Shape fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
976 // TopoDS_Shape comm = BRepAlgoAPI_Common( shape1, shape2 );
978 // TopoDS_Shape fuse = BRepAlgo_Fuse( shape1, shape2 );
979 // TopoDS_Shape comm = BRepAlgo_Common( shape1, shape2 );
981 TopoDS_Shape fuse,comm;
983 di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )\n";
984 di << "comm = BRepAlgoAPI_Common( shape1, shape2 )\n";
985 fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
986 comm = BRepAlgoAPI_Common( shape1, shape2 );
988 di << "fuse = BRepAlgo_Fuse( shape1, shape2 )\n";
989 fuse = BRepAlgo_Fuse( shape1, shape2 );
990 di << "comm = BRepAlgo_Common( shape1, shape2 )\n";
991 comm = BRepAlgo_Common( shape1, shape2 );
997 #include <ShapeAnalysis_Edge.hxx>
999 static Standard_Integer OCC333bug (Draw_Interpretor& di, Standard_Integer n, const char ** a)
1003 di << "Usage: " << a[0] << " edge1 edge2 [toler domaindist]\n";
1006 TopoDS_Shape Sh1 = DBRep::Get(a[1]);
1007 TopoDS_Shape Sh2 = DBRep::Get(a[2]);
1008 if(Sh1.IsNull() || Sh2.IsNull()) {
1010 di<<"Invalid arguments\n";
1013 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
1014 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
1015 if(e1.IsNull() || e2.IsNull()) {
1017 di<<"Invalid type of arguments\n";
1020 Standard_Real aTol = Precision::Confusion();
1021 Standard_Real aDistDomain = 0.0;
1022 Standard_Integer k = 3;
1024 aTol = Draw::Atof(a[k++]);
1026 aDistDomain = Draw::Atof(a[k++]);
1028 ShapeAnalysis_Edge sae;
1029 if(sae.CheckOverlapping(e1,e2,aTol,aDistDomain)) {
1030 if(aDistDomain ==0.0) {
1032 di<<"Edges is overlaping comletly\n";
1035 di<<"Edges is overlaped\n";
1036 di<<"with tolerance = "<<aTol<<"\n";
1037 di<<"on segment length = "<<aDistDomain<<"\n";
1041 di<<"Edges is not overlaped\n";
1047 #include <DDocStd_DrawDocument.hxx>
1048 #include <TDataStd_Name.hxx>
1050 #include <XCAFDoc_ShapeTool.hxx>
1051 #include <XCAFDoc_DocumentTool.hxx>
1052 #include <TDF_LabelSequence.hxx>
1053 #include <TPrsStd_AISPresentation.hxx>
1054 #include <TDF_Data.hxx>
1055 #include <TDF_Label.hxx>
1056 #include <XCAFPrs_Driver.hxx>
1058 //------------------------------------------------------------------------------------------
1061 //------------------------------------------------------------------------------------------
1062 static Standard_Integer OCC363 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1067 // 1. Verufy amount of arguments
1068 if(argc < 3) { di <<"Error OCC363 : Use : OCC363 document filename\n"; return 1; }
1070 // 2. Retrieve DDocStd application
1071 Handle(TDocStd_Application) App = DDocStd::GetApplication();
1074 TCollection_ExtendedString name(argv[2]);
1075 Handle(TDocStd_Document) Doc;
1076 if(App->Open(name, Doc) != PCDM_RS_OK) { di << "Error OCC363 : document was not opened successfully\n"; return 1;}
1077 Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(Doc);
1078 TDataStd_Name::Set(Doc->GetData()->Root(),argv[1]);
1079 Draw::Set(argv[1],DD);
1081 // 4. Create prsentations
1082 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1083 TDF_LabelSequence seq;
1084 shapes->GetFreeShapes ( seq );
1085 Handle(TPrsStd_AISPresentation) prs;
1086 for ( Standard_Integer i=1; i <= seq.Length(); i++ )
1087 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) )
1088 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
1090 catch(Standard_Failure) { di << "FAULTY OCC363 : Exception during reading document.\n";return 0;}
1092 di << "OCC363 OK\n";
1097 ////======================================================================================
1098 //// Function : OCC372
1100 ////======================================================================================
1101 //static Standard_Integer OCC372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1105 // OCC_CATCH_SIGNALS
1106 // // 1. Verufy amount of arguments
1107 // if(argc < 2) {di << "OCC372 FAULTY. Use : OCC372 brep-file";return 0;}
1111 // TopoDS_Shape Ref;
1112 // BRepTools::Read(Ref, argv[1], B);
1114 // // 3. Calculate location of aP3d in relation to the solid
1115 // gp_Pnt aP3d(6311.4862583184, -2841.3092756034, 16.461053497188);
1116 // BRepClass3d_SolidClassifier SC(Ref);
1117 // SC.Perform(aP3d, 1e-7);
1119 // // 4. Check returned state. The point must be inside the solid.
1120 // TopAbs_State aState=SC.State();
1124 // di<<"OCC372 FAULTY. aState = TopAbs_OUT";
1127 // di<<"OCC372 FAULTY. aState = TopAbs_ON";
1130 // di<<"OCC372 OK. aState = TopAbs_IN" ;
1133 // di<<"OCC372 FAULTY. aState = UNKNOWN";
1137 // catch (Standard_Failure) { di<<"OCC372 FAULTY. Exception raised"; }
1142 #include <BRepTopAdaptor_FClass2d.hxx>
1144 //======================================================================================
1145 // Function : OCC377
1147 //======================================================================================
1148 static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1153 // 1. Verify validity of arguments
1154 if ( argc < 1 ) {di << "Error OCC377. Use OCC377 file x y precuv \n";return 0;}
1156 // 2. Initialize parameters
1158 p2d.SetX ( Draw::Atof(argv[2]) );
1159 p2d.SetY ( Draw::Atof(argv[3]) );
1160 Standard_Real precuv = Draw::Atof (argv[4] );
1165 BRepTools::Read ( Shape, argv[1], B );
1167 // 4. Verify whether enrtry point is on wire and reversed ones (indeed results of veridying must be same)
1168 TopExp_Explorer exp;
1169 Standard_Integer i=1;
1170 for (exp.Init(Shape.Oriented(TopAbs_FORWARD),TopAbs_WIRE); exp.More(); exp.Next(), i++)
1172 // 4.1. Verify whether enrtry point is on wire
1173 const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
1174 TopoDS_Face newFace = TopoDS::Face(Shape.EmptyCopied());
1176 TopAbs_Orientation orWire = wir.Orientation();
1177 newFace.Orientation(TopAbs_FORWARD);
1180 BRepTopAdaptor_FClass2d FClass2d1(newFace,precuv);
1181 TopAbs_State stat1 = FClass2d1.PerformInfinitePoint();
1182 //di << "Wire " << i << ": Infinite point is " <<
1183 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1185 TCollection_AsciiString TmpString;
1186 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1187 di << "Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1189 stat1 = FClass2d1.Perform(p2d);
1190 //di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1191 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1194 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1195 di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1197 // 4.2. Verify whether enrtry point is on reversed wire
1198 newFace = TopoDS::Face(Shape.EmptyCopied());
1199 newFace.Orientation(TopAbs_FORWARD);
1200 orWire = TopAbs::Reverse(orWire);
1201 B.Add(newFace,wir.Oriented(orWire));
1202 BRepTopAdaptor_FClass2d FClass2d2(newFace,precuv);
1203 TopAbs_State stat2 = FClass2d2.PerformInfinitePoint();
1204 //di << "Reversed Wire " << i << ": Infinite point is " <<
1205 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1208 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1209 di << "Reversed Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1211 stat2 = FClass2d2.Perform(p2d);
1212 //di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1213 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1216 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1217 di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1219 // 4.3. Compare results (they must be same)
1220 if(stat1 ==stat2) di << "OCC377 OK\n";
1221 else {di << "OCC377 FAULTY\n"; return 0;}
1224 catch(Standard_Failure)
1226 di << "OCC377 Exception";
1232 #include <ShapeUpgrade_ShapeDivideAngle.hxx>
1233 #include <ShapeBuild_ReShape.hxx>
1235 //=======================================================================
1238 //=======================================================================
1239 static Standard_Integer OCC22 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1244 // 1. Verify arguments of the command
1245 if (argc < 5) { di << "OCC22 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation"; return 0;}
1247 Standard_Boolean aConsiderLocation;
1248 if(strcmp(argv[4], "0")==0) aConsiderLocation = Standard_False;
1249 else aConsiderLocation = Standard_True;
1251 // 2. Iniitialize aShapeUpgrade
1252 ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(M_PI/2.);
1254 aShapeUpgrade.SetPrecision (Precision::Confusion());
1256 aShapeUpgrade.SetMaxTolerance(0.1);
1257 // subshapes to be divided
1258 TopoDS_Shape aSubShapesToBeDivided = DBRep::Get(argv[3]);
1259 if(aSubShapesToBeDivided.IsNull()) {di << "OCC22 FAULTY. Compound of subshapes to be divided is not exist. Please, verify input values. \n";return 0;}
1260 aShapeUpgrade.Init(aSubShapesToBeDivided);
1262 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1263 aShapeUpgrade.SetContext(aReshape);
1264 if(aConsiderLocation) aReshape->ModeConsiderLocation() = Standard_True;
1266 // 3. Perform splitting
1267 if (aShapeUpgrade.Perform (Standard_False)) di << "Upgrade_SplitRevolution_Done \n";
1268 else if (aShapeUpgrade.Status (ShapeExtend_OK)) di << "Upgrade_SplitRevolution_OK \n";
1269 else if (aShapeUpgrade.Status (ShapeExtend_FAIL)) { di << "OCC22 FAULTY. Operation failed. Angle was not divided\n";return 0;}
1271 // 4. Perform rebuilding shape
1272 // 4.1. Retrieve Shape
1273 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1274 if(anInitShape.IsNull()) { di << "OCC22 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1275 // 4.2 Rebuid retrieved shape
1276 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1277 // 4.3. Create result Draw shape
1278 DBRep::Set(argv[1], aResultShape);
1280 catch (Standard_Failure) {di << "OCC22 Exception \n" ;return 0;}
1286 #include <ShapeProcess_OperLibrary.hxx>
1287 #include <ShapeProcess_ShapeContext.hxx>
1288 #include <ShapeProcess.hxx>
1290 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
1291 #include <BRepMesh_IncrementalMesh.hxx>
1293 //=======================================================================
1296 //=======================================================================
1297 static Standard_Integer OCC24 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1302 // 1. Verify amount of arguments of the command
1303 if (argc < 6) { di << "OCC24 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapes ResourceFileName SequenceName"; return 0;}
1305 // 2. Retrieve parameters
1307 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1308 if(anInitShape.IsNull()) { di << "OCC24 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1309 // compound of subshapes
1310 TopoDS_Shape aSubShapes = DBRep::Get(argv[3]);
1311 if(aSubShapes.IsNull()) {di << "OCC24 FAULTY. Compound of subshapes is not exist. Please, verify input values. \n";return 0;}
1312 // name of resource file
1313 const char* aResourceFile = argv[4];
1314 // name of sequence from resource file to be executed
1315 const char* aSequenceName = argv[5];
1317 // 3. Initialize ShapeContext and perform sequence of operation specified with resource file
1318 ShapeProcess_OperLibrary::Init();
1319 Handle(ShapeProcess_ShapeContext) aShapeContext = new ShapeProcess_ShapeContext (aSubShapes, aResourceFile);
1320 aShapeContext->SetDetalisation (TopAbs_EDGE);
1321 ShapeProcess::Perform (aShapeContext, aSequenceName);
1323 // 4. Rebuild initil shape in accordance with performed operation
1324 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1325 TopTools_DataMapIteratorOfDataMapOfShapeShape anIter (aShapeContext->Map());
1326 for (; anIter.More(); anIter.Next())
1327 aReshape->Replace(anIter.Key(), anIter.Value());
1328 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1330 // 5 Create resultant Draw shape
1331 DBRep::Set(argv[1], aResultShape);
1334 catch (Standard_Failure) {di << "OCC24 Exception \n" ;return 0;}
1339 //=======================================================================
1341 //purpose : Verify whether exception occurs during building mesh
1342 //=======================================================================
1343 static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1348 // 1. Verify amount of arguments of the command
1349 if (argc < 2) { di << "OCC369 FAULTY. Use : OCC369 Shape \n"; return 0;}
1351 // 2. Retrieve shape
1352 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1353 if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
1356 BRepMesh_FastDiscret::Parameters aMeshParams;
1357 aMeshParams.Relative = Standard_True;
1358 aMeshParams.Deflection = 0.2;
1359 aMeshParams.Angle = M_PI / 6;
1360 BRepMesh_IncrementalMesh aMesh(aShape, aMeshParams);
1363 catch (Standard_Failure) {di << "OCC369 Exception \n" ;return 0;}
1365 di << "OCC369 OK \n";
1369 #include <math_Vector.hxx>
1370 #include <math_Matrix.hxx>
1371 static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1374 di<<"Usage : " << argv[0] << " LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix\n";
1377 Standard_Integer LowerVector = Draw::Atoi(argv[1]);
1378 Standard_Integer UpperVector = Draw::Atoi(argv[2]);
1379 Standard_Real InitialValueVector = Draw::Atof(argv[3]);
1380 Standard_Integer LowerRowMatrix = Draw::Atoi(argv[4]);
1381 Standard_Integer UpperRowMatrix = Draw::Atoi(argv[5]);
1382 Standard_Integer LowerColMatrix = Draw::Atoi(argv[6]);
1383 Standard_Integer UpperColMatrix = Draw::Atoi(argv[7]);
1384 Standard_Real InitialValueMatrix = Draw::Atof(argv[8]);
1386 math_Vector Vector1(LowerVector, UpperVector);
1387 math_Vector Vector2(LowerVector, UpperVector);
1389 math_Vector Vector(LowerVector, UpperVector, InitialValueVector);
1390 math_Matrix Matrix(LowerRowMatrix, UpperRowMatrix, LowerColMatrix, UpperColMatrix, InitialValueMatrix);
1392 //Vector.Dump(cout);
1395 //Matrix.Dump(cout);
1398 Vector1.Multiply(Vector, Matrix);
1400 //Vector1.Dump(cout);
1401 Standard_SStream aSStream1;
1402 Vector1.Dump(aSStream1);
1406 if (Matrix.RowNumber() > 1) {
1407 Matrix(Matrix.LowerRow() + 1, Matrix.LowerCol()) += 1.;
1409 Vector2.TMultiply(Vector, Matrix);
1411 //Vector2.Dump(cout);
1412 Standard_SStream aSStream2;
1413 Vector2.Dump(aSStream2);
1420 #include <GeomPlate_BuildPlateSurface.hxx>
1421 //=======================================================================
1424 //=======================================================================
1425 static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
1427 GeomPlate_BuildPlateSurface aBuilder;
1430 if (aBuilder.IsDone())
1432 di << "Error in OCC525. Null result is expected.\n";
1436 di << "OCC525 OK \n";
1442 #include <BRepPrimAPI_MakeWedge.hxx>
1443 #include <gce_MakeRotation.hxx>
1444 #include <gce_MakeTranslation.hxx>
1445 #include <BRepBuilderAPI_Transform.hxx>
1446 #include <BRepPrimAPI_MakeWedge.hxx>
1447 #include <BRepAlgoAPI_Fuse.hxx>
1448 #include <BRepAlgoAPI_Cut.hxx>
1449 #include <BRepAlgo_Fuse.hxx>
1450 #include <BRepAlgo_Cut.hxx>
1451 //=======================================================================
1454 //=======================================================================
1455 static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1458 // di<<"Usage : " << argv[0] << " shape1 shape2 shape3\n";
1461 if(argc < 4 || argc > 5) {
1462 di << "Usage : " << argv[0] << " shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]\n";
1465 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1467 Standard_Integer IsB = Draw::Atoi(argv[4]);
1469 IsBRepAlgoAPI = Standard_False;
1470 // di << "Error: There is not BRepAlgo_Fuse class\n";
1472 // di << "Error: There is not BRepAlgo_Cut class\n";
1478 double xperiod = 1.0;
1479 double yperiod = 1.0;
1480 double sub_thick = 0.5;
1483 //TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick );
1484 TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick ).Shape();
1486 // --------------------------------------------------------------------
1489 //TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1490 // 0.1, 0.1 , 0.4, 0.4 );
1491 TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1492 0.1, 0.1 , 0.4, 0.4 ).Shape();
1494 gp_Trsf rotate = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1495 gp_Dir(1.0,0.0,0.0),
1498 gp_Trsf translate = gce_MakeTranslation(gp_Pnt( 0.0, -0.5, 0.0),
1499 gp_Pnt( 0.25, 0.25, 0.5)
1502 rotate.PreMultiply( translate );
1504 TopoDS_Shape wedge1a = BRepBuilderAPI_Transform( wedge1, rotate );
1506 if (wedge1a.IsNull()) {
1507 di<<" Null shape1 is not allowed\n";
1510 DBRep::Set(argv[1], wedge1a);
1512 // --------------------------------------------------------------------
1515 //TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1516 // 0.1, 0.1 , 0.4, 0.4 );
1517 TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1518 0.1, 0.1 , 0.4, 0.4 ).Shape();
1520 gp_Trsf rotate2 = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1521 gp_Dir(1.0,0.0,0.0),
1524 gp_Trsf translate2 = gce_MakeTranslation(gp_Pnt( 0.0, 0.0, 0.0),
1525 gp_Pnt( 0.25, 0.25, 0.5)
1528 rotate2.PreMultiply( translate2 );
1530 TopoDS_Shape wedge2a = BRepBuilderAPI_Transform( wedge2, rotate2 );
1532 if (wedge2a.IsNull()) {
1533 di<<" Null shape2 is not allowed\n";
1536 DBRep::Set(argv[2], wedge2a);
1540 //#if ! defined(BRepAlgoAPI_def01)
1541 // TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1543 // TopoDS_Shape wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1545 TopoDS_Shape wedge_common;
1546 if (IsBRepAlgoAPI) {
1547 di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)\n";
1548 wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1550 di << "wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a)\n";
1551 wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1554 // remove wedge area from substrate
1555 //#if ! defined(BRepAlgoAPI_def01)
1556 // TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1558 // TopoDS_Shape sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1560 TopoDS_Shape sub_etch1;
1561 if (IsBRepAlgoAPI) {
1562 di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)\n";
1563 sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1565 di << "sub_etch1 = BRepAlgo_Cut(substrate, wedge_common)\n";
1566 sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1569 if (sub_etch1.IsNull()) {
1570 di<<" Null shape3 is not allowed\n";
1573 DBRep::Set(argv[3], sub_etch1);
1578 #include <Standard_GUID.hxx>
1579 //=======================================================================
1582 //=======================================================================
1583 static Standard_Integer OCC669 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1586 di<<"Usage : " << argv[0] << " GUID\n";
1589 Standard_GUID guid(argv[1]);
1590 //guid.ShallowDump(cout);
1591 Standard_SStream aSStream;
1592 guid.ShallowDump(aSStream);
1598 #include <XCAFDoc.hxx>
1599 //=======================================================================
1600 //function : OCC738_ShapeRef
1602 //=======================================================================
1603 static Standard_Integer OCC738_ShapeRef (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1606 di<<"Usage : " << argv[0] << "\n";
1609 const Standard_GUID& guid = XCAFDoc::ShapeRefGUID ();
1610 //guid.ShallowDump(cout);
1611 Standard_SStream aSStream;
1612 guid.ShallowDump(aSStream);
1617 //=======================================================================
1618 //function : OCC738_Assembly
1620 //=======================================================================
1621 static Standard_Integer OCC738_Assembly (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1624 di<<"Usage : " << argv[0] << "\n";
1627 const Standard_GUID& guid = XCAFDoc::AssemblyGUID ();
1628 //guid.ShallowDump(cout);
1629 Standard_SStream aSStream;
1630 guid.ShallowDump(aSStream);
1635 #if defined(DDataStd_def01)
1636 #include <DDataStd_DrawPresentation.hxx>
1637 //=======================================================================
1638 //function : OCC739_DrawPresentation
1640 //=======================================================================
1641 static Standard_Integer OCC739_DrawPresentation (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1644 di<<"Usage : " << argv[0] << "\n";
1647 const Standard_GUID& guid = DDataStd_DrawPresentation::GetID() ;
1648 //guid.ShallowDump(cout);
1649 Standard_SStream aSStream;
1650 guid.ShallowDump(aSStream);
1656 //=======================================================================
1659 //=======================================================================
1660 static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1662 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1663 if(aContext.IsNull()) {
1664 di << argv[0] << "ERROR : use 'vinit' command before \n";
1669 di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation\n";
1673 Standard_Boolean updateviewer = Standard_True;
1675 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1677 TCollection_AsciiString aName(argv[1]);
1678 Handle(AIS_InteractiveObject) AISObj;
1680 if(!aMap.IsBound2(aName)) {
1681 di << "Use 'vdisplay' before\n";
1684 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
1685 if(AISObj.IsNull()){
1686 di << argv[1] << " : No interactive object\n";
1689 AISObj->ResetTransformation();
1691 aContext->Erase(AISObj, updateviewer);
1692 aContext->UpdateCurrentViewer();
1693 aContext->Display(AISObj, updateviewer);
1694 aContext->UpdateCurrentViewer();
1699 //=======================================================================
1702 //=======================================================================
1703 #include <TColStd_Array2OfInteger.hxx>
1704 static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1707 di<<"Usage : " << argv[0] << "\n";
1711 // check that exception initialized without message string can be safely handled and printed
1713 Standard_OutOfRange::Raise();
1715 catch (Standard_Failure) {
1716 std::cout << "Caught successfully: ";
1717 Standard_Failure::Caught()->Print (std::cout);
1723 #include <GeomAPI_ProjectPointOnSurf.hxx>
1724 //=======================================================================
1727 //=======================================================================
1728 static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1732 di<<"Usage : " << argv[0] << " Point Surface Umin Usup Vmin Vsup \n";
1737 DrawTrSurf::GetPoint(argv[1],aPoint3d);
1738 Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
1739 Standard_Real Umin=Draw::Atof(argv[3]);
1740 Standard_Real Usup=Draw::Atof(argv[4]);
1741 Standard_Real Vmin=Draw::Atof(argv[5]);
1742 Standard_Real Vsup=Draw::Atof(argv[6]);
1744 if (aSurface.IsNull()) {
1745 di << argv[2] << " Null surface \n" ;
1749 GeomAPI_ProjectPointOnSurf PonSurf;
1750 PonSurf.Init(aSurface, Umin, Usup, Vmin, Vsup);
1751 PonSurf.Perform(aPoint3d);
1756 //=======================================================================
1759 //=======================================================================
1760 static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1764 di<<"Usage : " << argv[0] << " wire face\n";
1768 TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
1769 TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
1770 if (awire.IsNull() || aface.IsNull()) {
1771 di << "Null object\n";
1775 Standard_Integer count = 0;
1776 TopExp_Explorer TE(awire, TopAbs_VERTEX);
1778 BRepTools_WireExplorer WE;
1779 for ( WE.Init(awire,aface); WE.More(); WE.Next()) {
1780 TopoDS_Edge E = WE.Current();
1784 di << "Count = " << count << "\n";
1789 //=======================================================================
1792 //=======================================================================
1793 static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1797 di <<"Usage : " << argv[0] << " face\n";
1800 Standard_Real u1, u2, v1, v2;
1801 TopoDS_Face F = TopoDS::Face( DBRep::Get(argv[1]) ); //read the shape
1804 BRepTools::UVBounds(F, u1, u2, v1, v2);
1805 di << "Bounds: " << u1 << " " << u2 << " " << v1 << " " << v2 << "\n";
1809 #include <Expr_NamedUnknown.hxx>
1810 #include <Expr_GeneralExpression.hxx>
1811 #include <Expr_Exponential.hxx>
1812 //=======================================================================
1815 //=======================================================================
1816 static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1820 di <<"Usage : " << argv[0] << " expression\n";
1824 TCollection_AsciiString myStr(argv[1]);
1826 Handle (Expr_NamedUnknown) myNamed = new Expr_NamedUnknown(myStr);
1827 Handle (Expr_Exponential) oldExpr = new Expr_Exponential(myNamed);
1828 Handle (Expr_GeneralExpression) newExpr = oldExpr->Derivative(myNamed);
1831 TCollection_AsciiString res = newExpr->String();
1832 Standard_CString resStr = res.ToCString();
1833 TCollection_AsciiString res_old = oldExpr->String();
1834 Standard_CString res_oldStr = res_old.ToCString();
1837 di << "X = " << argv[1] << "\n";
1838 di << "Y = " << res_oldStr << "\n";
1839 di << "Y' = " << resStr << "\n";
1845 #include <TPrsStd_AISViewer.hxx>
1846 #include <TDF_Label.hxx>
1847 #include <TPrsStd_AISPresentation.hxx>
1848 //=======================================================================
1849 //function : OCC1029_AISTransparency
1850 //purpose : OCC1029_AISTransparency (DOC,entry,[real])
1851 //=======================================================================
1853 static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
1854 Standard_Integer nb,
1858 Handle(TDocStd_Document) D;
1859 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1861 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1863 Handle(TPrsStd_AISViewer) viewer;
1864 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1866 Handle(TPrsStd_AISPresentation) prs;
1867 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1869 prs->SetTransparency(Draw::Atof(arg[3]));
1870 TPrsStd_AISViewer::Update(L);
1873 di << "Transparency = " << prs->Transparency() << "\n";
1878 di << arg[0] << " : Error\n";
1882 //=======================================================================
1883 //function : OCC1030_AISColor
1884 //purpose : OCC1030_AISColor (DOC,entry,[color])
1885 //=======================================================================
1887 static Standard_Integer OCC1030_AISColor (Draw_Interpretor& di,
1888 Standard_Integer nb,
1892 Handle(TDocStd_Document) D;
1893 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1895 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1897 Handle(TPrsStd_AISViewer) viewer;
1898 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1900 Handle(TPrsStd_AISPresentation) prs;
1901 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1903 prs->SetColor((Quantity_NameOfColor)Draw::Atoi(arg[3]));
1904 TPrsStd_AISViewer::Update(L);
1907 di << "Color = " << prs->Color() << "\n";
1911 di << arg[0] << " : Error\n";
1915 //=======================================================================
1916 //function : OCC1031_AISMaterial
1917 //purpose : OCC1031_AISMaterial (DOC,entry,[material])
1918 //=======================================================================
1920 static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
1921 Standard_Integer nb,
1925 Handle(TDocStd_Document) D;
1926 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1928 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1930 Handle(TPrsStd_AISViewer) viewer;
1931 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1933 Handle(TPrsStd_AISPresentation) prs;
1934 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1936 prs->SetMaterial((Graphic3d_NameOfMaterial)Draw::Atoi(arg[3]));
1937 TPrsStd_AISViewer::Update(L);
1940 di << "Material = " << prs->Material() << "\n";
1945 di << arg[0] << " : Error\n";
1949 //=======================================================================
1950 //function : OCC1032_AISWidth
1951 //purpose : OCC1032_AISWidth (DOC,entry,[width])
1952 //=======================================================================
1954 static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
1955 Standard_Integer nb,
1959 Handle(TDocStd_Document) D;
1960 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1962 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1964 Handle(TPrsStd_AISViewer) viewer;
1965 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1967 Handle(TPrsStd_AISPresentation) prs;
1968 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1970 prs->SetWidth(Draw::Atof(arg[3]));
1971 TPrsStd_AISViewer::Update(L);
1974 di << "Width = " << prs->Width() << "\n";
1979 di << arg[0] << " : Error\n";
1983 //=======================================================================
1984 //function : OCC1033_AISMode
1985 //purpose : OCC1033_AISMode (DOC,entry,[mode])
1986 //=======================================================================
1988 static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
1989 Standard_Integer nb,
1993 Handle(TDocStd_Document) D;
1994 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1996 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1998 Handle(TPrsStd_AISViewer) viewer;
1999 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2001 Handle(TPrsStd_AISPresentation) prs;
2002 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2004 prs->SetMode(Draw::Atoi(arg[3]));
2005 TPrsStd_AISViewer::Update(L);
2008 di << "Mode = " << prs->Mode() << "\n";
2013 di << arg[0] << " : Error\n";
2017 //=======================================================================
2018 //function : OCC1034_AISSelectionMode
2019 //purpose : OCC1034_AISSelectionMode (DOC,entry,[selectionmode])
2020 //=======================================================================
2022 static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
2023 Standard_Integer nb,
2027 Handle(TDocStd_Document) D;
2028 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2030 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2032 Handle(TPrsStd_AISViewer) viewer;
2033 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2035 Handle(TPrsStd_AISPresentation) prs;
2036 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2038 prs->SetSelectionMode(Draw::Atoi(arg[3]));
2039 TPrsStd_AISViewer::Update(L);
2042 di << "SelectionMode = " << prs->SelectionMode() << "\n";
2047 di << arg[0] << " : Error\n";
2051 #include<BRepAlgoAPI_Cut.hxx>
2052 #include<BRepAlgo_Cut.hxx>
2053 //=======================================================================
2054 //function : OCC1487
2056 //=======================================================================
2057 static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2060 // cerr << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape" << endl;
2063 if(argc < 5 || argc > 6) {
2064 di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]\n";
2067 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2069 Standard_Integer IsB = Draw::Atoi(argv[5]);
2071 IsBRepAlgoAPI = Standard_False;
2072 // di << "Error: There is not BRepAlgo_Cut class\n";
2077 Standard_Integer CaseNumber = Draw::Atoi(argv[1]);
2079 //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
2080 gp_Dir myDir(1,0,0);
2081 gp_Pnt myPnt(0,-50,140);
2082 gp_Ax2 myAx2(myPnt, myDir);
2083 BRepPrimAPI_MakeCylinder o_mc1 (myAx2, 50,1000);
2085 TopoDS_Shape cyl1 = o_mc1.Shape();
2088 TopoDS_Shape o_cut_shape;
2089 if (CaseNumber == 1) {
2090 //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);
2091 gp_Dir myDir_mc2(-sin(M_PI/3), 0.0, 0.5);
2092 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2093 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2094 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2096 cyl2 = o_mc2.Shape();
2097 //#if ! defined(BRepAlgoAPI_def01)
2098 // o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2100 // o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2102 if (IsBRepAlgoAPI) {
2103 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
2104 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2106 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
2107 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2110 //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);
2111 gp_Dir myDir_mc2(sin(M_PI/3), 0.0, 0.5);
2112 gp_Pnt myPnt_mc2(978.34936, -50.0, 127.5);
2113 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2114 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2116 cyl2 = o_mc2.Shape();
2117 //#if ! defined(BRepAlgoAPI_def01)
2118 // o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2120 // o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2122 if (IsBRepAlgoAPI) {
2123 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
2124 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2126 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
2127 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2131 DBRep::Set(argv[2],cyl1);
2132 DBRep::Set(argv[3],cyl2);
2133 DBRep::Set(argv[4],o_cut_shape);
2138 #include<TopTools_ListIteratorOfListOfShape.hxx>
2139 #include<BRepFilletAPI_MakeFillet.hxx>
2140 //=======================================================================
2141 //function : OCC1077
2143 //=======================================================================
2144 TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
2146 Standard_Real t3d = 1.e-4;
2147 Standard_Real t2d = 1.e-5;
2148 Standard_Real ta = 1.e-2;
2149 Standard_Real fl = 1.e-3;
2150 Standard_Real tapp_angle = 1.e-2;
2151 GeomAbs_Shape blend_cont = GeomAbs_C1;
2153 TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
2156 // Handle(TopOpeBRepBuild_HBuilder) build = aBoolenaOperation.Builder();
2158 TopTools_ListIteratorOfListOfShape its;
2160 TopoDS_Compound result;
2162 B.MakeCompound(result);
2165 for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
2167 const TopoDS_Shape& cutsol = ex.Current();
2169 BRepFilletAPI_MakeFillet fill(cutsol);
2170 fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
2171 fill.SetContinuity(blend_cont, tapp_angle);
2173 // its = build->Section();
2175 its = aBoolenaOperation.SectionEdges();
2179 TopoDS_Edge E = TopoDS::Edge(its.Value());
2180 fill.Add(aRadius, E);
2187 B.Add(result, fill.Shape());
2191 B.Add(result, cutsol);
2197 TopoDS_Shape OCC1077_cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
2199 //return OCC1077_boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
2200 BRepAlgoAPI_Cut aCut(aShapeToCut, aTool);
2201 return OCC1077_boolbl(aCut,aRadius);
2204 //TopoDS_Shape OCC1077_common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
2206 // return OCC1077_boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
2209 TopoDS_Shape OCC1077_Bug()
2211 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10).Shape();
2212 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7).Shape();
2214 TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
2215 TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10),
2216 gp_Dir(0, 0, 1)), 3, 20).Shape();
2217 TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0),
2218 gp_Dir(1, 0, 0)), 3, 20).Shape();
2219 TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
2220 gp_Dir(0, 1, 0)), 3, 20).Shape();
2221 TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
2222 Handle(ShapeFix_Shape) fixer = new ShapeFix_Shape(theTmp1);
2224 theTmp1 = fixer->Shape();
2225 TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
2226 fixer->Init(theTmp2);
2228 theTmp2 = fixer->Shape();
2229 TopoDS_Shape theResult = OCC1077_cut_blend(theTmp2,theCylinder3,0.7);
2230 fixer->Init(theResult);
2232 theResult = fixer->Shape();
2236 static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2238 if(argc < 1 || argc > 2) {
2239 di << "Usage : " << argv[0] << " result\n";
2243 TopoDS_Shape S = OCC1077_Bug();
2244 DBRep::Set(argv[1],S);
2249 //////////////////////////////////////////////////////////////
2251 * Compute uniform distribution of points using GCPnts_UniformAbscissa
2253 //////////////////////////////////////////////////////////////
2254 static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2258 di << "Usage : " << argv[0] << " name shape step\n";
2261 const char *name = argv[1];
2262 Adaptor3d_Curve *adapCurve=NULL;
2263 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
2264 if (!curve.IsNull())
2265 adapCurve = new GeomAdaptor_Curve(curve);
2268 TopoDS_Shape wire = DBRep::Get(argv[2]);
2269 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
2271 di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected\n";
2274 adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
2276 double step = Draw::Atof(argv[3]);
2277 GCPnts_UniformAbscissa aUni(*adapCurve, step);
2281 di << argv[0] <<" : fail\n";
2286 int i, np = aUni.NbPoints();
2287 for (i=0; i < np; i++)
2289 double par = aUni.Parameter(i+1);
2290 gp_Pnt p = adapCurve->Value(par);
2291 char n[20], *pname=n;
2292 Sprintf(n,"%s_%d",name,i+1);
2293 DrawTrSurf::Set(pname,p);
2302 static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2306 di << "Usage : " << argv[0] << " nb_of_vectors size\n";
2310 Standard_Integer nb = Draw::Atoi(argv[1]);
2311 Standard_Integer sz = Draw::Atoi(argv[2]);
2312 Standard_Real val = 10;
2313 math_Vector **pv = new math_Vector *[nb];
2315 di<<"creating "<<nb<<" vectors "<<sz<<" elements each...\n";
2317 for (i=0; i < nb; i++) {
2318 pv[i] = new math_Vector (1, sz, val);
2319 if ((i % (nb/10)) == 0) {
2326 di<<"deleting them ...\n";
2327 for (i=0; i < nb; i++) {
2329 if ((i % (nb/10)) == 0) {
2342 static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2346 di << "Usage : " << argv[0] << " wire\n";
2349 TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
2352 TopoDS_Wire wire = TopoDS::Wire(shape);
2353 // create curve parameterised by curvilinear distance
2354 BRepAdaptor_CompCurve curve(wire,Standard_True);
2355 Standard_Real length = curve.LastParameter();
2356 Standard_Real need_length = length/2;
2358 curve.D0(need_length,pnt);
2359 // create check_curve parameterised in a general way
2360 BRepAdaptor_CompCurve check_curve(wire);
2361 Standard_Real check_par =
2362 GCPnts_AbscissaPoint(check_curve, need_length, 0).Parameter();
2364 check_curve.D0(check_par,check_pnt);
2365 // check that points are coinsiding
2366 Standard_Real error_dist = pnt.Distance(check_pnt);
2367 if (error_dist > Precision::Confusion()) {
2368 //cout.precision(3);
2369 di<<"error_dist = "<<error_dist<<
2370 " ( "<<error_dist/need_length*100<<" %)\n";
2377 // stack overflow can be successfully handled only on 32-bit Windows
2378 #if defined(_WIN32) && !defined(_WIN64)
2379 static int StackOverflow (int i = -1)
2382 memset (arr, 0, sizeof(arr));
2389 // this code does not work with optimize mode on Windows
2390 #if defined(_MSC_VER)
2391 #pragma optimize( "", off )
2393 static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2397 cout << "Usage : " << argv[0] << "\n";
2400 Standard_Boolean Succes;
2402 Succes = Standard_True;
2405 {//==== Test Divide ByZero (Integer) ========================================
2408 cout << "(Integer) Divide By Zero..." << endl;
2409 di << "(Integer) Divide By Zero...";
2412 Standard_Integer res, a =4, b = 0 ;
2414 di << "Error: 4 / 0 = " << res << " - no exception is raised!\n";
2415 Succes = Standard_False;
2417 #if defined(SOLARIS) || defined(_WIN32)
2418 catch(Standard_DivideByZero)
2420 catch(Standard_NumericError)
2423 di << "Caught, OK\n";
2425 catch(Standard_Failure) {
2427 di << Standard_Failure::Caught()->GetMessageString();
2429 Succes = Standard_False;
2431 #ifndef NO_CXX_EXCEPTION
2432 // this case tests if (...) supersedes (Standard_*),
2433 // the normal behaviour is not
2435 di<<" unknown exception... (But) Ok\n";
2440 {//==== Test Divide ByZero (Real) ===========================================
2443 cout << "(Real) Divide By Zero..." << endl;
2444 di << "(Real) Divide By Zero...";
2447 Standard_Real res, a= 4.0, b=0.0;
2449 di << "Error: 4.0 / 0.0 = " << res << " - no exception is raised!\n";
2450 Succes = Standard_False;
2452 catch(Standard_DivideByZero) // Solaris, Windows w/o SSE2
2454 di << "Caught, OK\n";
2456 catch(Standard_NumericError) // Linux, Windows with SSE2
2458 di << "Caught, OK\n";
2460 catch(Standard_Failure) {
2461 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2463 di << Standard_Failure::Caught()->GetMessageString();
2465 Succes = Standard_False;
2469 {//==== Test Overflow (Integer) =============================================
2472 cout << "(Integer) Overflow..." << endl;
2473 di << "(Integer) Overflow...";
2476 Standard_Integer res, i=IntegerLast();
2478 //++++ cout << " -- "<<res<<"="<<i<<"+1 Does not Caught... KO"<< endl;
2479 //++++ Succes = Standard_False;
2480 di << "Not caught: " << i << " + 1 = " << res << ", still OK\n";
2482 catch(Standard_Overflow) {
2483 di << "Caught, OK\n";
2485 catch(Standard_Failure) {
2486 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2488 di << Standard_Failure::Caught()->GetMessageString();
2490 Succes = Standard_False;
2494 {//==== Test Overflow (Real) ================================================
2497 cout << "(Real) Overflow..." << endl;
2498 di << "(Real) Overflow...";
2501 Standard_Real res, r=RealLast();
2504 (void)sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
2506 di << "Error: " << r << "*" << r << " = " << res << " - no exception is raised!\n";
2507 Succes = Standard_False;
2509 catch(Standard_Overflow) // Solaris, Windows w/o SSE2
2511 di << "Caught, OK\n";
2513 catch(Standard_NumericError) // Linux, Windows with SSE2
2515 di << "Caught, OK\n";
2517 catch(Standard_Failure) {
2518 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2520 di << Standard_Failure::Caught()->GetMessageString();
2522 Succes = Standard_False;
2526 {//==== Test Underflow (Real) ===============================================
2529 cout << "(Real) Underflow" << endl; // to have message in log even if process crashed
2530 di << "(Real) Underflow";
2533 Standard_Real res, r=1.0e-308;
2536 //++++ cout<<"-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<<endl;
2537 //++++ Succes = Standard_False;
2538 di << "Not caught: " << r << "*" << r << " = " << res << ", still OK\n";
2540 catch(Standard_Underflow) // could be on Solaris, Windows w/o SSE2
2542 di << "Exception caught, KO\n";
2543 Succes = Standard_False;
2545 catch(Standard_NumericError) // could be on Linux, Windows with SSE2
2547 di << "Exception caught, KO\n";
2548 Succes = Standard_False;
2550 catch(Standard_Failure) {
2551 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2553 di << Standard_Failure::Caught()->GetMessageString();
2555 Succes = Standard_False;
2559 {//==== Test Invalid Operation (Real) ===============================================
2562 cout << "(Real) Invalid Operation..." << endl;
2563 di << "(Real) Invalid Operation...";
2566 Standard_Real res, r=-1;
2568 di << "Error: swrt(-1) = " << res << " - no exception is raised!\n";
2569 Succes = Standard_False;
2571 catch(Standard_NumericError) {
2572 di << "Caught, OK\n";
2574 catch(Standard_Failure) {
2575 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2577 di << Standard_Failure::Caught()->GetMessageString();
2579 Succes = Standard_False;
2583 {//==== Test Access Violation ===============================================
2586 cout << "Segmentation Fault..." << endl;
2587 di << "Segmentation Fault...";
2592 di << "Error: writing by NULL address - no exception is raised!\n";
2593 Succes = Standard_False;
2596 catch(OSD_Exception_ACCESS_VIOLATION)
2601 di << "Caught, OK\n";
2602 } catch(Standard_Failure) {
2603 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2605 di << Standard_Failure::Caught()->GetMessageString();
2607 Succes = Standard_False;
2611 #if defined(_WIN32) && !defined(_WIN64)
2612 {//==== Test Stack Overflow ===============================================
2615 cout << "Stack Overflow..." << endl;
2616 di << "Stack Overflow...";
2620 di << "Error - no exception is raised!\n";
2621 Succes = Standard_False;
2623 catch(OSD_Exception_STACK_OVERFLOW) {
2624 di << "Caught, OK\n";
2626 catch(Standard_Failure) {
2627 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2629 di << Standard_Failure::Caught()->GetMessageString();
2631 Succes = Standard_False;
2637 di << "TestExcept: Successfull completion\n";
2639 di << "TestExcept: failure\n";
2644 #if defined(_MSC_VER)
2645 #pragma optimize( "", on )
2648 static TopoDS_Compound AddTestStructure(int nCount_)
2654 BRepPrimAPI_MakeBox mkBox(1.0, 2.0, 3.0);
2655 for (int i=0; i<nCount; i++) {
2656 for (int j=0; j<nCount; j++) {
2658 trsf.SetTranslationPart(gp_Vec(5.0*i, 05.0*j, 0.0));
2659 TopLoc_Location topLoc(trsf);
2660 TopoDS_Shape tempShape=mkBox.Shape().Located(topLoc);
2661 B.Add(C, tempShape);
2667 static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2673 di << "Usage : " << argv[0] << " [nCount] path\n";
2678 nCount = Draw::Atoi(argv[1]);
2679 TCollection_AsciiString aFilePath = argv[2];
2680 STEPCAFControl_Writer writer;
2681 Handle(TDocStd_Document) document;
2682 document = new TDocStd_Document("Pace Test-StepExporter-");
2683 Handle(XCAFDoc_ShapeTool) shapeTool;
2684 shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
2685 shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
2686 STEPControl_StepModelType mode = STEPControl_AsIs;
2687 if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
2688 di << "Failed to set assembly mode for step data\n\n";
2693 if( writer.Transfer(document, mode)) {
2694 writer.Write(aFilePath.ToCString());
2697 catch(OSD_Exception_STACK_OVERFLOW) {
2698 di << "Failed : STACK OVERFLOW\n\n";
2700 catch (Standard_Failure) {
2701 di << "Failed :\n\n";
2702 //cout << Standard_Failure::Caught() << endl;
2703 di << Standard_Failure::Caught()->GetMessageString();
2705 di << argv[0] << " : Finish\n";
2710 static Standard_Integer OCC7372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2714 di << "Usage : " << argv[0] << "\n";
2718 // 1. Create an array of points
2719 Handle(TColgp_HArray1OfPnt2d) ap = new TColgp_HArray1OfPnt2d(1,5);
2720 ap->SetValue(1,gp_Pnt2d(100.0,0.0));
2721 ap->SetValue(2,gp_Pnt2d(100.0,100.0));
2722 ap->SetValue(3,gp_Pnt2d(0.0,100.0));
2723 ap->SetValue(4,gp_Pnt2d(0.0,0.0));
2724 ap->SetValue(5,gp_Pnt2d(50.0,-50.0));
2726 // 2. Create a periodic bspline through these 5 points
2727 Geom2dAPI_Interpolate intp(ap,Standard_True,1e-6);
2729 Handle(Geom2d_BSplineCurve) bspline1 = intp.Curve();
2731 // 3. Increase degree of curve from 3 to 8
2732 bspline1->IncreaseDegree(8); // Increase degree to demonstrate the error
2733 Standard_CString CString1 = "BSplineCurve";
2734 DrawTrSurf::Set(CString1,bspline1);
2736 // 4. Convers BSpline curve to Bezier segments
2737 Geom2dConvert_BSplineCurveToBezierCurve bc(bspline1);
2739 // 5. Test the result of conversion
2740 TCollection_AsciiString aRName;
2741 for(Standard_Integer i = 1; i <= bc.NbArcs(); i++) {
2742 Handle(Geom2d_BezierCurve) arc = bc.Arc(i);
2744 aRName=aRName+TCollection_AsciiString(i);
2745 Standard_CString aRNameStr = aRName.ToCString();
2746 DrawTrSurf::Set(aRNameStr,arc);
2747 di << aRNameStr << " ";
2753 static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2757 di << "Usage : " << argv[0] << " edge1 edge2 plane\n";
2760 TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
2761 if (theEdge1.IsNull()) {
2762 di << "Invalid input shape " << argv[1] << "\n";
2765 TopoDS_Edge theEdge2 = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
2766 if (theEdge2.IsNull()) {
2767 di << "Invalid input shape " << argv[2] << "\n";
2770 TopoDS_Face theFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
2771 if (theFace.IsNull()) {
2772 di << "Invalid input shape " << argv[3] << "\n";
2776 Handle(Geom_Surface) thePlane = BRep_Tool::Surface(theFace);
2778 Standard_Real aConfusion = Precision::Confusion();
2779 Standard_Real aP1first, aP1last, aP2first, aP2last;
2781 Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(theEdge1, aP1first, aP1last);
2782 Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(theEdge2, aP2first, aP2last);
2783 Handle(Geom2d_Curve) aCurve2d1 = GeomProjLib::Curve2d(aCurve1, aP1first, aP1last, thePlane);
2784 Handle(Geom2d_Curve) aCurve2d2 = GeomProjLib::Curve2d(aCurve2, aP2first, aP2last, thePlane);
2786 Geom2dAPI_InterCurveCurve anInter(aCurve2d1, aCurve2d2, aConfusion);
2788 Standard_Integer NbPoints = anInter.NbPoints();
2790 di << "NbPoints = " << NbPoints << "\n" ;
2794 for (i=1; i<=NbPoints; i++) {
2795 gp_Pnt2d aPi = anInter.Point(i);
2796 di << "Point.X(" << i << ") = " << aPi.X() << " Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
2800 Standard_Integer NbSegments = anInter.NbSegments();
2802 di << "\nNbSegments = " << NbSegments << "\n" ;
2804 if (NbSegments > 0) {
2805 IntRes2d_IntersectionSegment aSegment = anInter.Intersector().Segment(1);
2807 gp_Pnt2d aP1 = aCurve2d1->Value(aSegment.FirstPoint().ParamOnFirst());
2808 gp_Pnt2d aP2 = aCurve2d2->Value(aSegment.FirstPoint().ParamOnSecond());
2810 Standard_Real aDist = aP1.Distance(aP2);
2812 di << "aP1.X() = " << aP1.X() << " aP1.Y() = " << aP1.Y() << "\n" ;
2813 di << "aP2.X() = " << aP2.X() << " aP2.Y() = " << aP2.Y() << "\n" ;
2815 di << "Distance = " << aDist << "\n" ;
2817 di << "Confusion = " << aConfusion << "\n" ;
2819 if (aDist > aConfusion) {
2820 di << "\n" << argv[0] << " Faulty\n" ;
2822 di << "\n" << argv[0] << " OK\n" ;
2825 di << "\n" << argv[0] << " OK\n" ;
2830 static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2834 di << "Usage : " << argv[0] << " lower upper\n";
2838 Standard_Integer LOWER = Draw::Atoi(argv[1]);
2839 Standard_Integer UPPER = Draw::Atoi(argv[2]);
2841 //! 0. Create an empty document with several test labels
2842 Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
2843 doc->SetUndoLimit(100);
2844 TDF_Label main_label = doc->Main();
2845 TDF_Label label1 = main_label.FindChild(1, Standard_True);
2846 TDF_Label label2 = main_label.FindChild(2, Standard_True);
2848 //! 1. Set/Get OCAF attribute
2850 TDataStd_RealArray::Set(label1, LOWER, UPPER);
2851 Handle(TDataStd_RealArray) array;
2852 if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) &&
2853 array->Lower() == LOWER && array->Upper() == UPPER)
2854 cout<<"1: OK"<<endl;
2857 cout<<"1: Failed.."<<endl;
2860 doc->CommitCommand();
2862 //! 2. Set/Get value
2865 for (i = LOWER; i <= UPPER; i++)
2866 array->SetValue(i, i);
2867 for (i = LOWER; i <= UPPER; i++)
2869 if (array->Value(i) != i)
2871 cout<<"2: Failed.."<<endl;
2875 cout<<"2: OK"<<endl;
2876 doc->CommitCommand();
2878 //! 3. Re-init the array
2880 array->Init(LOWER + 2, UPPER + 4);
2881 if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4)
2883 cout<<"3: Failed.."<<endl;
2886 for (i = LOWER + 2; i <= UPPER + 4; i++)
2887 array->SetValue(i, i);
2888 for (i = LOWER + 2; i <= UPPER + 4; i++)
2890 if (array->Value(i) != i)
2892 cout<<"3: Failed.."<<endl;
2896 cout<<"3: OK"<<endl;
2897 doc->CommitCommand();
2901 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(LOWER + 5, UPPER + 5);
2902 for (i = LOWER + 5; i <= UPPER + 5; i++)
2903 arr->SetValue(i, i);
2904 array->ChangeArray(arr);
2905 for (i = LOWER + 5; i <= UPPER + 5; i++)
2907 if (array->Value(i) != i)
2909 cout<<"4: Failed.."<<endl;
2913 cout<<"4: OK"<<endl;
2914 doc->CommitCommand();
2916 //! 5. Copy the array
2918 TDF_CopyLabel copier(label1, label2);
2920 if (!copier.IsDone())
2922 cout<<"5: Failed.."<<endl;
2925 Handle(TDataStd_RealArray) array2;
2926 if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2928 cout<<"5: Failed.."<<endl;
2931 for (i = LOWER + 5; i <= UPPER + 5; i++)
2933 if (array->Value(i) != i)
2935 cout<<"5: Failed.."<<endl;
2939 cout<<"5: OK"<<endl;
2940 doc->CommitCommand();
2943 //! 6.a: undoes the 5th action: the copied array should disappear
2945 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2946 label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
2948 cout<<"6.a: Failed.."<<endl;
2951 //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4)
2953 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2954 array->Lower() != LOWER + 2 ||
2955 array->Upper() != UPPER + 4)
2957 cout<<"6.b: Failed.."<<endl;
2960 for (i = LOWER + 2; i <= UPPER + 4; i++)
2962 if (array->Value(i) != i)
2964 cout<<"6.b: Failed.."<<endl;
2968 //! 6.c: undoes the 3d action: the array should be changed to (lower,upper)
2970 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2971 array->Lower() != LOWER ||
2972 array->Upper() != UPPER)
2974 cout<<"6.c: Failed.."<<endl;
2977 for (i = LOWER; i <= UPPER; i++)
2979 if (array->Value(i) != i)
2981 cout<<"6.c: Failed.."<<endl;
2985 //! 6.d: undoes and redoes the 2nd action: no change is expected.
2988 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
2989 array->Lower() != LOWER ||
2990 array->Upper() != UPPER)
2992 cout<<"6.d: Failed.."<<endl;
2995 for (i = LOWER; i <= UPPER; i++)
2997 if (array->Value(i) != i)
2999 cout<<"6.d: Failed.."<<endl;
3003 cout<<"6: OK"<<endl;
3005 //! 7. Re-set the array
3007 array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1);
3008 if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1)
3010 cout<<"7: Failed.."<<endl;
3013 for (i = LOWER + 1; i <= UPPER + 1; i++)
3014 array->SetValue(i, i);
3015 for (i = LOWER + 1; i <= UPPER + 1; i++)
3017 if (array->Value(i) != i)
3019 cout<<"7: Failed.."<<endl;
3023 cout<<"7: OK"<<endl;
3024 doc->CommitCommand();
3026 //! 8.Test of speed: set LOWER and UPPER equal to great integer number and
3027 //! measure the time spent by this test.
3033 static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3035 Standard_Boolean IsEvenArgc = Standard_True;
3036 if (argc % 2 == 0) {
3037 IsEvenArgc = Standard_True;
3039 IsEvenArgc = Standard_False;
3042 if (argc < 3 || IsEvenArgc)
3044 di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]\n";
3048 Standard_Integer i, aValue, aPosition;
3049 NCollection_Vector<int> vec;
3050 for (i = 0; i < argc - 1; i++) {
3052 aValue = Draw::Atoi(argv[i]);
3053 aPosition = Draw::Atoi(argv[i+1]);
3054 vec.SetValue(aValue, aPosition);
3056 NCollection_Vector<int>::Iterator it(vec);
3058 for (j = 0; it.More(); it.Next(), j++) {
3059 //di << it.Value() << "\n";
3060 di << j << " " << it.Value() << "\n";
3066 static Standard_Integer OCC8797 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3069 di << "Usage : " << argv[0] << "\n";
3073 gp_Pnt point(0.0,0.0,0.0);
3075 TColgp_Array1OfPnt poles(0,6);
3078 point.SetCoord(1.0,1.0,0.0);
3081 point.SetCoord(2.0,1.0,0.0);
3084 point.SetCoord(3.0,0.0,0.0);
3087 point.SetCoord(4.0,1.0,0.0);
3090 point.SetCoord(5.0,1.0,0.0);
3093 point.SetCoord(6.0,0.0,0.0);
3096 TColStd_Array1OfReal knots(0,2);
3101 TColStd_Array1OfInteger multi(0,2);
3106 Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles,knots,multi,3);
3109 Standard_Real l_abcissa,l_gprop;
3110 GeomAdaptor_Curve adaptor_spline(spline);
3111 GCPnts_AbscissaPoint temp;
3112 l_abcissa=temp.Length(adaptor_spline);
3113 cout<<"Length Spline(abcissa_Pnt): "<<l_abcissa<<endl;
3116 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge (spline);
3118 BRepGProp::LinearProperties(edge,prop);
3119 l_gprop=prop.Mass();
3120 cout<<"Length Spline(GProp_GProps): "<<l_gprop<<endl;
3122 cout<<"Difference (abcissa_Pnt<->GProp_GProps): "<<l_gprop-l_abcissa<<endl;
3127 static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3131 di << "Usage : " << argv[0] << "\n";
3135 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
3136 if(AISContext.IsNull())
3138 di << "use 'vinit' command before " << argv[0] << "\n";
3143 AIS_ListOfInteractive ListOfIO_1;
3144 AISContext->ObjectsInside(ListOfIO_1);
3145 di<< "ObjectsInside = " << ListOfIO_1.Extent() <<"\n";
3146 if (!ListOfIO_1.IsEmpty() ) {
3147 AIS_ListIteratorOfListOfInteractive iter;
3148 for (iter.Initialize(ListOfIO_1); iter.More() ; iter.Next() ) {
3149 Handle(AIS_InteractiveObject) aIO=iter.Value();
3150 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3157 static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3159 if ((argc < 9) || (((argc-3) % 3) != 0))
3161 di << "Usage : " << argv[0] << "polygon lastedge x1 y1 z1 x2 y2 z2 ...\n";
3164 Standard_Integer i, j, np = (argc-3) / 3;
3165 BRepBuilderAPI_MakePolygon W;
3167 for (i = 1; i <= np; i ++) {
3168 W.Add(gp_Pnt(Draw::Atof(argv[j]),Draw::Atof(argv[j+1]),Draw::Atof(argv[j+2])));
3172 DBRep::Set(argv[1],W.Wire());
3173 DBRep::Set(argv[2],W.Edge());
3177 static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3180 di << "Usage : " << argv[0] << " ratio origin_x origin_y origin_z\n";
3183 gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
3184 gp_Dir(1., -1., 0.));
3186 aTrf.SetAffinity (aPln, Draw::Atof(argv[4]));
3187 gp_XYZ aOrigin (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3188 gp_XYZ aResult (aOrigin);
3189 aTrf.Transforms(aResult);
3191 Sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
3192 aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
3193 aResult.X(), aResult.Y(), aResult.Z());
3198 Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3201 di << "Usage : " << argv[0] << " shape [deflection]\n";
3205 TopoDS_Shape aShape = DBRep::Get(argv[1]);
3207 if (aShape.IsNull()) {
3208 di<<" Null shape is not allowed";
3212 Standard_Real aDeflection = 0.45110277533;
3214 aDeflection = Draw::Atof(argv[2]);
3216 di<<"deflection="<< aDeflection << "\n";
3218 BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI / 9.);
3219 TopLoc_Location aLocation;
3220 Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
3222 if(aTriang.IsNull()) {
3223 di << argv[0] << " : Faulty\n" ;
3225 di << argv[0] << " : OK\n" ;
3226 di<<"NbNodes="<< aTriang->NbNodes()<< "\n";
3227 di<<"NbTriangles="<< aTriang->NbTriangles()<< "\n";
3232 static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3235 di << "Usage : " << argv[0] << " A B C\n";
3240 gp_Lin2d aLin2d (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
3241 gp_Pnt2d anOrigin = aLin2d.Location();
3242 di << "X_0 = " << anOrigin.X() << " Y_0 = " << anOrigin.Y() << "\n" ;
3244 catch(Standard_ConstructionError)
3246 di << argv[0] << " Exception: Sqrt(A*A + B*B) <= Resolution from gp\n";
3251 static Standard_Integer OCC15755 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3254 di << "Usage : " << argv[0] << " file shape\n";
3258 IGESControl_Reader aReader;
3259 aReader.ReadFile(argv[1]);
3260 aReader.SetReadVisible(Standard_True);
3261 aReader.TransferRoots();
3263 Handle(IGESData_IGESModel) model = aReader.IGESModel();
3264 if (model.IsNull()) {
3265 di << "model.IsNull()\n";
3268 Standard_Integer nb = model->NbEntities();
3269 for (Standard_Integer i = 1; i <= nb; i ++) {
3270 Handle(IGESData_IGESEntity) ent = model->Entity(i);
3271 Handle(TCollection_HAsciiString) name;
3272 name = ent->NameValue();
3273 Standard_CString aStr = name->ToCString();
3274 di << "NameValue = " << aStr << "\n";
3277 TopoDS_Shape shape = aReader.OneShape();
3278 DBRep::Set(argv[2],shape);
3282 // For OCC16782 testing
3283 #include <AppStd_Application.hxx>
3284 #include <TDF_Tool.hxx>
3285 #include <TColStd_HArray1OfInteger.hxx>
3287 #include <TColStd_ListIteratorOfListOfInteger.hxx>
3288 #include <TColStd_ListIteratorOfListOfReal.hxx>
3289 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
3290 #include <TDataStd_ListIteratorOfListOfByte.hxx>
3291 #include <TDF_ListIteratorOfLabelList.hxx>
3293 #include <TDataStd_Tick.hxx>
3294 #include <TDataStd_IntegerList.hxx>
3295 #include <TDataStd_RealList.hxx>
3296 #include <TDataStd_ExtStringList.hxx>
3297 #include <TDataStd_BooleanList.hxx>
3298 #include <TDataStd_ReferenceList.hxx>
3299 #include <TDataStd_BooleanArray.hxx>
3300 #include <TDataStd_ReferenceArray.hxx>
3301 #include <TDataStd_ByteArray.hxx>
3302 #include <TDataStd_NamedData.hxx>
3303 #include <TDF_Reference.hxx>
3305 Handle(AppStd_Application) app;
3306 int TestSetGet(const Handle(TDocStd_Document)& doc)
3310 TDataStd_Tick::Set(doc->Main());
3312 Handle(TDataStd_Tick) tick;
3313 if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick))
3316 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3317 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3319 doc->Main().ResumeAttribute(tick);
3320 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3323 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3324 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3327 // TDataStd_IntegerList:
3329 Handle(TDataStd_IntegerList) setintlist = TDataStd_IntegerList::Set(doc->Main());
3330 setintlist->Append(2);
3331 setintlist->Prepend(1);
3332 setintlist->InsertAfter(3, 2);
3333 setintlist->InsertBefore(0, 1);
3334 setintlist->Append(200);
3335 setintlist->Remove(0);
3336 setintlist->Remove(200);
3338 Handle(TDataStd_IntegerList) getintlist;
3339 if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist))
3341 if (getintlist->First() != 1)
3343 if (getintlist->Last() != 3)
3345 const TColStd_ListOfInteger& intlist = getintlist->List();
3346 TColStd_ListIteratorOfListOfInteger itr_intlist(intlist);
3347 for (; itr_intlist.More(); itr_intlist.Next())
3349 if (itr_intlist.Value() != 1 &&
3350 itr_intlist.Value() != 2 &&
3351 itr_intlist.Value() != 3)
3356 getintlist->Clear();
3358 // TDataStd_RealList:
3360 Handle(TDataStd_RealList) setdbllist = TDataStd_RealList::Set(doc->Main());
3361 setdbllist->Append(2.5);
3362 setdbllist->Prepend(1.5);
3363 setdbllist->InsertAfter(3.5, 2.5);
3364 setdbllist->InsertBefore(0.5, 1.5);
3365 setdbllist->Append(200.5);
3366 setdbllist->Remove(0.5);
3367 setdbllist->Remove(200.5);
3369 Handle(TDataStd_RealList) getdbllist;
3370 if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist))
3372 if (getdbllist->First() != 1.5)
3374 if (getdbllist->Last() != 3.5)
3376 const TColStd_ListOfReal& dbllist = getdbllist->List();
3377 TColStd_ListIteratorOfListOfReal itr_dbllist(dbllist);
3378 for (; itr_dbllist.More(); itr_dbllist.Next())
3380 if (itr_dbllist.Value() != 1.5 &&
3381 itr_dbllist.Value() != 2.5 &&
3382 itr_dbllist.Value() != 3.5)
3387 getdbllist->Clear();
3389 // TDataStd_ExtStringList:
3391 Handle(TDataStd_ExtStringList) setstrlist = TDataStd_ExtStringList::Set(doc->Main());
3392 setstrlist->Append("Hello");
3393 setstrlist->Prepend("Guten Tag");
3394 setstrlist->InsertAfter("Bonjour", "Guten Tag");
3395 setstrlist->InsertBefore("Bonsoir", "Hello");
3396 setstrlist->Append("Good bye");
3397 setstrlist->Remove("Bonsoir");
3398 setstrlist->Remove("Good bye");
3400 Handle(TDataStd_ExtStringList) getstrlist;
3401 if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist))
3403 if (getstrlist->First() != "Guten Tag")
3405 if (getstrlist->Last() != "Hello")
3407 const TDataStd_ListOfExtendedString& strlist = getstrlist->List();
3408 TDataStd_ListIteratorOfListOfExtendedString itr_strlist(strlist);
3409 for (; itr_strlist.More(); itr_strlist.Next())
3411 if (itr_strlist.Value() != "Guten Tag" &&
3412 itr_strlist.Value() != "Bonjour" &&
3413 itr_strlist.Value() != "Hello")
3418 getstrlist->Clear();
3420 // TDataStd_BooleanList:
3422 Handle(TDataStd_BooleanList) setboollist = TDataStd_BooleanList::Set(doc->Main());
3423 setboollist->Append(Standard_True);
3424 setboollist->Prepend(Standard_False);
3426 Handle(TDataStd_BooleanList) getboollist;
3427 if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist))
3429 if (getboollist->First() != Standard_False)
3431 if (getboollist->Last() != Standard_True)
3433 const TDataStd_ListOfByte& boollist = getboollist->List();
3434 for (TDataStd_ListIteratorOfListOfByte itr_boollist(boollist); itr_boollist.More(); itr_boollist.Next())
3436 if (itr_boollist.Value() != 1
3437 && itr_boollist.Value() != 0)
3442 getboollist->Clear();
3444 // TDataStd_ReferenceList:
3445 TDF_Label L1 = doc->Main().FindChild(100);
3446 TDF_Label L2 = doc->Main().FindChild(101);
3447 TDF_Label L3 = doc->Main().FindChild(102);
3448 TDF_Label L4 = doc->Main().FindChild(103);
3449 TDF_Label L5 = doc->Main().FindChild(104);
3451 Handle(TDataStd_ReferenceList) setreflist = TDataStd_ReferenceList::Set(doc->Main());
3452 setreflist->Append(L1);
3453 setreflist->Prepend(L2);
3454 setreflist->InsertAfter(L3, L2);
3455 setreflist->InsertBefore(L4, L1);
3456 setreflist->Append(L5);
3457 setreflist->Remove(L4);
3458 setreflist->Remove(L5);
3460 Handle(TDataStd_ReferenceList) getreflist;
3461 if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist))
3463 if (getreflist->First() != L2)
3465 if (getreflist->Last() != L1)
3467 const TDF_LabelList& reflist = getreflist->List();
3468 TDF_ListIteratorOfLabelList itr_reflist(reflist);
3469 for (; itr_reflist.More(); itr_reflist.Next())
3471 if (itr_reflist.Value() != L1 &&
3472 itr_reflist.Value() != L2 &&
3473 itr_reflist.Value() != L3)
3478 getreflist->Clear();
3480 // TDataStd_BooleanArray:
3482 Handle(TDataStd_BooleanArray) setboolarr = TDataStd_BooleanArray::Set(doc->Main(), 12, 16);
3483 setboolarr->SetValue(12, Standard_True);
3484 setboolarr->SetValue(13, Standard_False);
3485 setboolarr->SetValue(14, Standard_False);
3486 setboolarr->SetValue(15, Standard_False);
3487 setboolarr->SetValue(16, Standard_True);
3488 setboolarr->SetValue(14, Standard_True);
3490 Handle(TDataStd_BooleanArray) getboolarr;
3491 if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr))
3493 if (getboolarr->Value(12) != Standard_True)
3495 if (getboolarr->Value(13) != Standard_False)
3497 if (getboolarr->Value(14) != Standard_True)
3499 if (getboolarr->Value(15) != Standard_False)
3501 if (getboolarr->Value(16) != Standard_True)
3504 // TDataStd_ReferenceArray:
3506 Handle(TDataStd_ReferenceArray) setrefarr = TDataStd_ReferenceArray::Set(doc->Main(), 0, 4);
3507 setrefarr->SetValue(0, L1);
3508 setrefarr->SetValue(1, L2);
3509 setrefarr->SetValue(2, L3);
3510 setrefarr->SetValue(3, L4);
3511 setrefarr->SetValue(4, L5);
3513 Handle(TDataStd_ReferenceArray) getrefarr;
3514 if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr))
3516 if (getrefarr->Value(0) != L1)
3518 if (getrefarr->Value(1) != L2)
3520 if (getrefarr->Value(2) != L3)
3522 if (getrefarr->Value(3) != L4)
3524 if (getrefarr->Value(4) != L5)
3527 // TDataStd_ByteArray:
3529 Handle(TDataStd_ByteArray) setbytearr = TDataStd_ByteArray::Set(doc->Main(), 12, 16);
3530 setbytearr->SetValue(12, 0);
3531 setbytearr->SetValue(13, 1);
3532 setbytearr->SetValue(14, 2);
3533 setbytearr->SetValue(15, 3);
3534 setbytearr->SetValue(16, 255);
3536 Handle(TDataStd_ByteArray) getbytearr;
3537 if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr))
3539 if (getbytearr->Value(12) != 0)
3541 if (getbytearr->Value(13) != 1)
3543 if (getbytearr->Value(14) != 2)
3545 if (getbytearr->Value(15) != 3)
3547 if (getbytearr->Value(16) != 255)
3550 // TDataStd_NamedData:
3552 Handle(TDataStd_NamedData) setnd = TDataStd_NamedData::Set(doc->Main());
3553 setnd->SetInteger("Integer1", 1);
3554 setnd->SetInteger("Integer2", 2);
3555 setnd->SetInteger("Integer3", 8);
3556 setnd->SetInteger("Integer3", 3);
3558 Handle(TDataStd_NamedData) getnd;
3559 if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd))
3561 if (!getnd->HasIntegers())
3563 if (!getnd->HasInteger("Integer1"))
3565 if (getnd->GetInteger("Integer2") != 2)
3567 if (getnd->GetInteger("Integer3") != 3)
3573 int TestUndoRedo(const Handle(TDocStd_Document)& doc)
3577 Handle(TDataStd_Tick) tick = TDataStd_Tick::Set(doc->Main());
3578 doc->CommitCommand();
3579 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3582 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3585 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3588 // TDataStd_IntegerList:
3590 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc->Main());
3592 intlist->Prepend(1);
3593 intlist->InsertBefore(0, 1);
3594 intlist->InsertAfter(3, 2);
3595 doc->CommitCommand();
3596 if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID()))
3599 if (!intlist->IsEmpty())
3602 if (!intlist->Extent())
3604 if (intlist->First() != 0)
3606 if (intlist->Last() != 3)
3610 // TDataStd_RealList:
3612 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc->Main());
3613 dbllist->Append(2.5);
3614 dbllist->Prepend(1.5);
3615 dbllist->InsertBefore(0.5, 1.5);
3616 dbllist->InsertAfter(3.5, 2.5);
3617 doc->CommitCommand();
3618 if (!doc->Main().IsAttribute(TDataStd_RealList::GetID()))
3621 if (!dbllist->IsEmpty())
3624 if (!dbllist->Extent())
3626 if (dbllist->First() != 0.5)
3628 if (dbllist->Last() != 3.5)
3632 // TDataStd_ExtStringList:
3634 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc->Main());
3635 strlist->Append("Hello");
3636 strlist->Prepend("Guten Tag");
3637 strlist->InsertAfter("Bonjour", "Guten Tag");
3638 strlist->InsertBefore("Bonsoir", "Hello");
3639 doc->CommitCommand();
3640 if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID()))
3643 if (!strlist->IsEmpty())
3646 if (!strlist->Extent())
3648 if (strlist->First() != "Guten Tag")
3650 if (strlist->Last() != "Hello")
3654 // TDataStd_BooleanList:
3656 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc->Main());
3657 boollist->Append(Standard_True);
3658 boollist->Prepend(Standard_False);
3659 doc->CommitCommand();
3660 if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID()))
3663 if (!boollist->IsEmpty())
3666 if (!boollist->Extent())
3668 if (boollist->First() != Standard_False)
3670 if (boollist->Last() != Standard_True)
3674 // TDataStd_ReferenceList:
3675 TDF_Label L1 = doc->Main().FindChild(100);
3676 TDF_Label L2 = doc->Main().FindChild(101);
3677 TDF_Label L3 = doc->Main().FindChild(102);
3678 TDF_Label L4 = doc->Main().FindChild(103);
3680 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc->Main());
3681 reflist->Append(L1);
3682 reflist->Prepend(L2);
3683 reflist->InsertBefore(L3, L1);
3684 reflist->InsertAfter(L4, L2);
3685 doc->CommitCommand();
3686 if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID()))
3689 if (!reflist->IsEmpty())
3692 if (!reflist->Extent())
3694 if (reflist->First() != L2)
3696 if (reflist->Last() != L1)
3700 // TDataStd_BooleanArray:
3702 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc->Main(), 23, 25);
3703 boolarr->SetValue(23, Standard_True);
3704 boolarr->SetValue(25, Standard_True);
3705 doc->CommitCommand();
3707 boolarr = TDataStd_BooleanArray::Set(doc->Main(), 230, 250);
3708 boolarr->SetValue(230, Standard_True);
3709 boolarr->SetValue(250, Standard_True);
3710 doc->CommitCommand();
3712 if (boolarr->Value(23) != Standard_True)
3714 if (boolarr->Value(24) != Standard_False)
3716 if (boolarr->Value(25) != Standard_True)
3719 if (boolarr->Value(230) != Standard_True)
3721 if (boolarr->Value(240) != Standard_False)
3723 if (boolarr->Value(250) != Standard_True)
3726 // TDataStd_ReferenceArray:
3728 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc->Main(), 5, 8);
3729 refarr->SetValue(5, L1);
3730 refarr->SetValue(6, L2);
3731 refarr->SetValue(7, L3);
3732 refarr->SetValue(8, L4);
3733 doc->CommitCommand();
3734 if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID()))
3738 if (refarr->Value(5) != L1)
3740 if (refarr->Value(6) != L2)
3742 if (refarr->Value(7) != L3)
3744 if (refarr->Value(8) != L4)
3747 // TDataStd_ByteArray:
3749 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc->Main(), 23, 25);
3750 bytearr->SetValue(23, 23);
3751 bytearr->SetValue(25, 25);
3752 doc->CommitCommand();
3754 bytearr = TDataStd_ByteArray::Set(doc->Main(), 230, 250);
3755 bytearr->SetValue(230, 230);
3756 bytearr->SetValue(250, 250);
3757 doc->CommitCommand();
3759 if (bytearr->Value(23) != 23)
3761 if (bytearr->Value(25) != 25)
3764 if (bytearr->Value(230) != 230)
3766 if (bytearr->Value(250) != 250)
3769 // TDataStd_NamedData:
3771 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(doc->Main());
3772 nd->SetByte("b14", 12);
3773 nd->SetByte("b17", 18);
3774 nd->SetByte("b14", 14);
3775 nd->SetByte("b17", 17);
3776 doc->CommitCommand();
3778 nd = TDataStd_NamedData::Set(doc->Main());
3779 nd->SetReal("r14", 14);
3780 nd->SetReal("r17", 17);
3781 nd->SetReal("r14", 14.4);
3782 nd->SetReal("r17", 17.7);
3783 doc->CommitCommand();
3785 if (nd->HasStrings())
3789 if (nd->HasReal("r17"))
3791 if (!nd->HasBytes())
3793 if (nd->GetByte("b14") != 14)
3795 if (nd->GetByte("b17") != 17)
3797 if (nd->HasByte("b18"))
3800 if (!nd->HasBytes())
3802 if (!nd->HasReals())
3804 if (nd->GetByte("b14") != 14)
3806 if (nd->GetReal("r14") != 14.4)
3808 if (nd->GetReal("r17") != 17.7)
3814 int TestCopyPaste(const Handle(TDocStd_Document)& doc)
3816 TDF_Label L1 = doc->Main().FindChild(1);
3817 TDF_Label L2 = doc->Main().FindChild(2);
3818 TDF_CopyLabel copier(L1, L2);
3821 TDataStd_Tick::Set(L1);
3823 if (!copier.IsDone())
3825 if (!L2.IsAttribute(TDataStd_Tick::GetID()))
3828 // TDataStd_IntegerList:
3829 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(L1);
3831 intlist->InsertAfter(2, 1);
3833 if (!copier.IsDone())
3837 if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3839 if (intlist->First() != 1)
3841 if (intlist->Last() != 2)
3845 // TDataStd_RealList:
3846 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(L1);
3847 dbllist->Append(1.5);
3848 dbllist->InsertAfter(2.5, 1.5);
3850 if (!copier.IsDone())
3854 if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist))
3856 if (dbllist->First() != 1.5)
3858 if (dbllist->Last() != 2.5)
3862 // TDataStd_ExtStringList:
3863 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(L1);
3864 strlist->Append("Open CASCADE");
3865 strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE");
3867 if (!copier.IsDone())
3871 if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
3873 if (strlist->First() != "Open CASCADE")
3875 if (strlist->Last() != " - is the best set of libraries!")
3879 // TDataStd_BooleanList:
3880 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(L1);
3881 boollist->Append(Standard_True);
3882 boollist->Prepend(Standard_False);
3884 if (!copier.IsDone())
3888 if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist))
3890 if (boollist->First() != Standard_False)
3892 if (boollist->Last() != Standard_True)
3896 // TDataStd_ReferenceList:
3897 TDF_Label L100 = doc->Main().FindChild(100);
3898 TDF_Label L101 = doc->Main().FindChild(101);
3899 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(L1);
3900 reflist->Append(L100);
3901 reflist->InsertAfter(L101, L100);
3903 if (!copier.IsDone())
3907 if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
3909 if (reflist->First() != L100)
3911 if (reflist->Last() != L101)
3915 // TDataStd_BooleanArray:
3916 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(L1, 4, 6);
3917 boolarr->SetValue(4, Standard_True);
3918 boolarr->SetValue(6, Standard_True);
3920 if (!copier.IsDone())
3923 if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
3925 if (boolarr->Value(4) != Standard_True)
3927 if (boolarr->Value(5) != Standard_False)
3929 if (boolarr->Value(6) != Standard_True)
3932 // TDataStd_ReferenceArray:
3933 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(L1, 3, 4);
3934 refarr->SetValue(3, L100);
3935 refarr->SetValue(4, L101);
3937 if (!copier.IsDone())
3940 if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
3942 if (refarr->Value(3) != L100)
3944 if (refarr->Value(4) != L101)
3947 // TDataStd_ByteArray:
3948 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(L1, 4, 6);
3949 bytearr->SetValue(4, 40);
3950 bytearr->SetValue(6, 60);
3952 if (!copier.IsDone())
3955 if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
3957 if (bytearr->Value(4) != 40)
3959 if (bytearr->Value(6) != 60)
3962 // TDataStd_NamedData:
3963 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(L1);
3964 nd->SetInteger("Integer1", 11);
3965 nd->SetReal("Real1", 11.1);
3966 nd->SetString("String1", "11.11111111");
3967 nd->SetByte("Byte1", 111);
3968 Handle(TColStd_HArray1OfInteger) ints_arr = new TColStd_HArray1OfInteger(4, 5);
3969 ints_arr->SetValue(4, 4);
3970 ints_arr->SetValue(5, 5);
3971 nd->SetArrayOfIntegers("Integers1", ints_arr);
3973 if (!copier.IsDone())
3976 if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd))
3978 if (!nd->HasIntegers())
3980 if (!nd->HasReals())
3982 if (!nd->HasStrings())
3984 if (!nd->HasBytes())
3986 if (!nd->HasArraysOfIntegers())
3988 if (nd->HasArraysOfReals())
3990 if (!nd->HasInteger("Integer1"))
3992 if (nd->GetInteger("Integer1") != 11)
3994 if (!nd->HasReal("Real1"))
3996 if (nd->GetReal("Real1") != 11.1)
3998 if (!nd->HasString("String1"))
4000 if (nd->GetString("String1") != "11.11111111")
4002 if (!nd->HasByte("Byte1"))
4004 if (nd->GetByte("Byte1") != 111)
4006 if (!nd->HasArrayOfIntegers("Integers1"))
4008 const Handle(TColStd_HArray1OfInteger)& ints_arr_out = nd->GetArrayOfIntegers("Integers1");
4009 if (ints_arr_out.IsNull())
4011 if (ints_arr_out->Value(5) != 5)
4017 int TestOpenSave(TCollection_ExtendedString aFile1,
4018 TCollection_ExtendedString aFile2,
4019 TCollection_ExtendedString aFile3)
4022 Handle(TDocStd_Document) doc_std, doc_std_open;
4023 app->NewDocument("BinOcaf", doc_std);
4025 TDataStd_Tick::Set(doc_std->Main());
4026 // TDataStd_IntegerList:
4027 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc_std->Main());
4030 // TDataStd_RealList:
4031 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc_std->Main());
4032 dbllist->Append(1.5);
4033 dbllist->Append(5.5);
4034 // TDataStd_ExtStringList:
4035 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc_std->Main());
4036 strlist->Append("Auf");
4037 strlist->Append("Wiedersehen");
4038 // TDataStd_BooleanList:
4039 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc_std->Main());
4040 boollist->Append(Standard_False);
4041 boollist->Append(Standard_True);
4042 // TDataStd_ReferenceList:
4043 TCollection_AsciiString entry1, entry2, entry_first, entry_last;
4044 TDF_Label Lstd1 = doc_std->Main().FindChild(100);
4045 TDF_Tool::Entry(Lstd1, entry1);
4046 TDF_Label Lstd2 = doc_std->Main().FindChild(101);
4047 TDF_Tool::Entry(Lstd2, entry2);
4048 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc_std->Main());
4049 reflist->Append(Lstd1);
4050 reflist->Append(Lstd2);
4051 // TDataStd_BooleanArray:
4052 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc_std->Main(), 15, 18);
4053 boolarr->SetValue(15, Standard_False);
4054 boolarr->SetValue(16, Standard_True);
4055 boolarr->SetValue(17, Standard_True);
4056 boolarr->SetValue(18, Standard_True);
4057 // TDataStd_ReferenceArray:
4058 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc_std->Main(), 45, 46);
4059 refarr->SetValue(45, Lstd1);
4060 refarr->SetValue(46, Lstd2);
4061 // TDataStd_ByteArray:
4062 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc_std->Main(), 15, 18);
4063 bytearr->SetValue(15, 150);
4064 bytearr->SetValue(16, 160);
4065 bytearr->SetValue(17, 170);
4066 bytearr->SetValue(18, 180);
4067 // TDataStd_NamedData:
4068 Handle(TDataStd_NamedData) nameddata = TDataStd_NamedData::Set(doc_std->Main());
4070 TDF_Label Lstd3 = doc_std->Main().FindChild(103);
4071 Handle(TDF_Reference) ref = TDF_Reference::Set(doc_std->Main(), Lstd3);
4074 //if (app->SaveAs(doc_std, "W:\\doc.std") != PCDM_SS_OK)
4075 if (app->SaveAs(doc_std, aFile1) != PCDM_SS_OK)
4084 app->Close(doc_std);
4086 //if (app->Open("W:\\doc.std", doc_std_open) != PCDM_RS_OK)
4087 if (app->Open(aFile1, doc_std_open) != PCDM_RS_OK)
4089 if (!doc_std_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4091 if (!doc_std_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4093 if (intlist->First() != 1)
4095 if (intlist->Last() != 5)
4097 if (!doc_std_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4099 if (dbllist->First() != 1.5)
4101 if (dbllist->Last() != 5.5)
4103 if (!doc_std_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4105 if (strlist->First() != "Auf")
4107 if (strlist->Last() != "Wiedersehen")
4109 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4111 if (boollist->First() != Standard_False)
4113 if (boollist->Last() != Standard_True)
4115 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4117 TDF_Tool::Entry(reflist->First(), entry_first);
4118 if (entry1 != entry_first)
4120 TDF_Tool::Entry(reflist->Last(), entry_last);
4121 if (entry2 != entry_last)
4123 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4125 if (boolarr->Value(15) != Standard_False)
4127 if (boolarr->Value(16) != Standard_True)
4129 if (boolarr->Value(17) != Standard_True)
4131 if (boolarr->Value(18) != Standard_True)
4133 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4135 TDF_Tool::Entry(refarr->Value(45), entry_first);
4136 if (entry1 != entry_first)
4138 TDF_Tool::Entry(refarr->Value(46), entry_last);
4139 if (entry2 != entry_last)
4141 if (!doc_std_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4143 if (bytearr->Value(15) != 150)
4145 if (bytearr->Value(16) != 160)
4147 if (bytearr->Value(17) != 170)
4149 if (bytearr->Value(18) != 180)
4151 if (!doc_std_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4153 if (ref->Get().IsNull())
4155 if (ref->Get().Tag() != 103)
4159 Handle(TDocStd_Document) doc_xml, doc_xml_open;
4160 app->NewDocument("XmlOcaf", doc_xml);
4162 TDataStd_Tick::Set(doc_xml->Main());
4163 // TDataStd_IntegerList:
4164 intlist = TDataStd_IntegerList::Set(doc_xml->Main());
4167 // TDataStd_RealList:
4168 dbllist = TDataStd_RealList::Set(doc_xml->Main());
4169 dbllist->Append(1.5);
4170 dbllist->Append(5.5);
4171 // TDataStd_ExtStringList:
4172 strlist = TDataStd_ExtStringList::Set(doc_xml->Main());
4173 strlist->Append("Guten ");
4174 strlist->Append("Tag");
4175 // TDataStd_BooleanList:
4176 boollist = TDataStd_BooleanList::Set(doc_xml->Main());
4177 boollist->Append(Standard_False);
4178 boollist->Append(Standard_True);
4179 // TDataStd_ReferenceList:
4180 TDF_Label Lxml1 = doc_xml->Main().FindChild(100);
4181 TDF_Tool::Entry(Lxml1, entry1);
4182 TDF_Label Lxml2 = doc_xml->Main().FindChild(101);
4183 TDF_Tool::Entry(Lxml2, entry2);
4184 reflist = TDataStd_ReferenceList::Set(doc_xml->Main());
4185 reflist->Append(Lxml1);
4186 reflist->Append(Lxml2);
4187 // TDataStd_BooleanArray:
4188 boolarr = TDataStd_BooleanArray::Set(doc_xml->Main(), 15, 24);
4189 boolarr->SetValue(15, Standard_False);
4190 boolarr->SetValue(16, Standard_True);
4191 boolarr->SetValue(17, Standard_True);
4192 boolarr->SetValue(18, Standard_True);
4193 boolarr->SetValue(19, Standard_True);
4194 boolarr->SetValue(20, Standard_True);
4195 boolarr->SetValue(21, Standard_False);
4196 boolarr->SetValue(22, Standard_True);
4197 boolarr->SetValue(23, Standard_True);
4198 boolarr->SetValue(24, Standard_True);
4199 // TDataStd_ReferenceArray:
4200 refarr = TDataStd_ReferenceArray::Set(doc_xml->Main(), 444, 445);
4201 refarr->SetValue(444, Lxml1);
4202 refarr->SetValue(445, Lxml2);
4203 // TDataStd_ByteArray:
4204 bytearr = TDataStd_ByteArray::Set(doc_xml->Main(), 15, 24);
4205 bytearr->SetValue(15, 0);
4206 bytearr->SetValue(16, 10);
4207 bytearr->SetValue(17, 100);
4208 bytearr->SetValue(18, 200);
4209 bytearr->SetValue(19, 250);
4210 bytearr->SetValue(20, 251);
4211 bytearr->SetValue(21, 252);
4212 bytearr->SetValue(22, 253);
4213 bytearr->SetValue(23, 254);
4214 bytearr->SetValue(24, 255);
4216 Lstd3 = doc_xml->Main().FindChild(103);
4217 ref = TDF_Reference::Set(doc_xml->Main(), Lstd3);
4220 //if (app->SaveAs(doc_xml, "W:\\doc.xml") != PCDM_SS_OK)
4221 if (app->SaveAs(doc_xml, aFile2) != PCDM_SS_OK)
4225 app->Close(doc_xml);
4227 //if (app->Open("W:\\doc.xml", doc_xml_open) != PCDM_RS_OK)
4228 if (app->Open(aFile2, doc_xml_open) != PCDM_RS_OK)
4230 if (!doc_xml_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4232 if (!doc_xml_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4234 if (intlist->First() != 1)
4236 if (intlist->Last() != 5)
4238 if (!doc_xml_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4240 if (dbllist->First() != 1.5)
4242 if (dbllist->Last() != 5.5)
4244 if (!doc_xml_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4246 if (strlist->First() != "Guten ")
4248 if (strlist->Last() != "Tag")
4250 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4252 if (boollist->First() != Standard_False)
4254 if (boollist->Last() != Standard_True)
4256 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4258 TDF_Tool::Entry(reflist->First(), entry_first);
4259 if (entry1 != entry_first)
4261 TDF_Tool::Entry(reflist->Last(), entry_last);
4262 if (entry2 != entry_last)
4264 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4266 if (boolarr->Value(15) != Standard_False)
4268 if (boolarr->Value(16) != Standard_True)
4270 if (boolarr->Value(17) != Standard_True)
4272 if (boolarr->Value(18) != Standard_True)
4274 if (boolarr->Value(19) != Standard_True)
4276 if (boolarr->Value(20) != Standard_True)
4278 if (boolarr->Value(21) != Standard_False)
4280 if (boolarr->Value(22) != Standard_True)
4282 if (boolarr->Value(23) != Standard_True)
4284 if (boolarr->Value(24) != Standard_True)
4286 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4288 TDF_Tool::Entry(refarr->Value(444), entry_first);
4289 if (entry1 != entry_first)
4291 TDF_Tool::Entry(refarr->Value(445), entry_last);
4292 if (entry2 != entry_last)
4294 if (!doc_xml_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4296 if (bytearr->Value(15) != 0)
4298 if (bytearr->Value(16) != 10)
4300 if (bytearr->Value(17) != 100)
4302 if (bytearr->Value(18) != 200)
4304 if (bytearr->Value(19) != 250)
4306 if (bytearr->Value(20) != 251)
4308 if (bytearr->Value(21) != 252)
4310 if (bytearr->Value(22) != 253)
4312 if (bytearr->Value(23) != 254)
4314 if (bytearr->Value(24) != 255)
4316 if (!doc_xml_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4318 if (ref->Get().IsNull())
4320 if (ref->Get().Tag() != 103)
4324 Handle(TDocStd_Document) doc_bin, doc_bin_open;
4325 app->NewDocument("BinOcaf", doc_bin);
4327 TDataStd_Tick::Set(doc_bin->Main());
4328 // TDataStd_IntegerList:
4329 intlist = TDataStd_IntegerList::Set(doc_bin->Main());
4332 // TDataStd_RealList:
4333 dbllist = TDataStd_RealList::Set(doc_bin->Main());
4334 dbllist->Append(1.5);
4335 dbllist->Append(5.5);
4336 // TDataStd_ExtStringList:
4337 strlist = TDataStd_ExtStringList::Set(doc_bin->Main());
4338 strlist->Append("Bonjour");
4339 strlist->Append("Bonsoir");
4340 // TDataStd_BooleanList:
4341 boollist = TDataStd_BooleanList::Set(doc_bin->Main());
4342 boollist->Append(Standard_False);
4343 boollist->Append(Standard_True);
4344 // TDataStd_ReferenceList:
4345 TDF_Label Lbin1 = doc_bin->Main().FindChild(100);
4346 TDF_Tool::Entry(Lbin1, entry1);
4347 TDF_Label Lbin2 = doc_bin->Main().FindChild(101);
4348 TDF_Tool::Entry(Lbin2, entry2);
4349 reflist = TDataStd_ReferenceList::Set(doc_bin->Main());
4350 reflist->Append(Lbin1);
4351 reflist->Append(Lbin2);
4352 // TDataStd_BooleanArray:
4353 boolarr = TDataStd_BooleanArray::Set(doc_bin->Main(), 15, 24);
4354 boolarr->SetValue(15, Standard_False);
4355 boolarr->SetValue(16, Standard_True);
4356 boolarr->SetValue(17, Standard_True);
4357 boolarr->SetValue(18, Standard_True);
4358 boolarr->SetValue(19, Standard_True);
4359 boolarr->SetValue(20, Standard_True);
4360 boolarr->SetValue(21, Standard_False);
4361 boolarr->SetValue(22, Standard_True);
4362 boolarr->SetValue(23, Standard_True);
4363 boolarr->SetValue(24, Standard_True);
4364 // TDataStd_ReferenceArray:
4365 refarr = TDataStd_ReferenceArray::Set(doc_bin->Main(), 0, 1);
4366 refarr->SetValue(0, Lbin1);
4367 refarr->SetValue(1, Lbin2);
4368 // TDataStd_ByteArray:
4369 bytearr = TDataStd_ByteArray::Set(doc_bin->Main(), 15, 16);
4370 bytearr->SetValue(15, 0);
4371 bytearr->SetValue(16, 255);
4372 // TDataStd_NamedData:
4373 nameddata = TDataStd_NamedData::Set(doc_bin->Main());
4374 nameddata->SetByte("A", 12);
4375 nameddata->SetByte("B", 234);
4377 Lstd3 = doc_bin->Main().FindChild(103);
4378 ref = TDF_Reference::Set(doc_bin->Main(), Lstd3);
4381 //if (app->SaveAs(doc_bin, "W:\\doc.cbf") != PCDM_SS_OK)
4382 if (app->SaveAs(doc_bin, aFile3) != PCDM_SS_OK)
4386 app->Close(doc_bin);
4388 //if (app->Open("W:\\doc.cbf", doc_bin_open) != PCDM_RS_OK)
4389 if (app->Open(aFile3, doc_bin_open) != PCDM_RS_OK)
4391 if (!doc_bin_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4393 if (!doc_bin_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4395 if (intlist->First() != 1)
4397 if (intlist->Last() != 5)
4399 if (!doc_bin_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4401 if (dbllist->First() != 1.5)
4403 if (dbllist->Last() != 5.5)
4405 if (!doc_bin_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4407 if (strlist->First() != "Bonjour")
4409 if (strlist->Last() != "Bonsoir")
4411 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4413 if (boollist->First() != Standard_False)
4415 if (boollist->Last() != Standard_True)
4417 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4419 TDF_Tool::Entry(reflist->First(), entry_first);
4420 if (entry1 != entry_first)
4422 TDF_Tool::Entry(reflist->Last(), entry_last);
4423 if (entry2 != entry_last)
4425 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4427 if (boolarr->Value(15) != Standard_False)
4429 if (boolarr->Value(16) != Standard_True)
4431 if (boolarr->Value(17) != Standard_True)
4433 if (boolarr->Value(18) != Standard_True)
4435 if (boolarr->Value(19) != Standard_True)
4437 if (boolarr->Value(20) != Standard_True)
4439 if (boolarr->Value(21) != Standard_False)
4441 if (boolarr->Value(22) != Standard_True)
4443 if (boolarr->Value(23) != Standard_True)
4445 if (boolarr->Value(24) != Standard_True)
4447 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4449 TDF_Tool::Entry(refarr->Value(0), entry_first);
4450 if (entry1 != entry_first)
4452 TDF_Tool::Entry(refarr->Value(1), entry_last);
4453 if (entry2 != entry_last)
4455 if (!doc_bin_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4457 if (bytearr->Value(15) != 0)
4459 if (bytearr->Value(16) != 255)
4461 if (!doc_bin_open->Main().FindAttribute(TDataStd_NamedData::GetID(), nameddata))
4463 if (nameddata->GetByte("A") != 12)
4465 if (nameddata->GetByte("B") != 234)
4467 if (!doc_bin_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4469 if (ref->Get().IsNull())
4471 if (ref->Get().Tag() != 103)
4476 // For OCC16782 testing
4478 static Standard_Integer OCC16782 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4482 di << "Usage : " << argv[0] << " file.std file.xml file.cbf\n";
4485 TCollection_ExtendedString aFile1(argv[1]);
4486 TCollection_ExtendedString aFile2(argv[2]);
4487 TCollection_ExtendedString aFile3(argv[3]);
4490 app = new AppStd_Application();
4494 Handle(TDocStd_Document) doc;
4495 app->NewDocument("BinOcaf", doc);
4496 doc->SetUndoLimit(10);
4498 di <<"\nTestSetGet start\n";
4499 good += TestSetGet(doc);
4500 di <<"TestSetGet finish\n";
4501 di <<"Status = " << good << "\n";
4503 di <<"\nTestUndoRedo start\n";
4504 good += TestUndoRedo(doc);
4505 di <<"TestUndoRedo finish\n";
4506 di <<"Status = " << good << "\n";
4508 di <<"\nTestCopyPaste start\n";
4509 good += TestCopyPaste(doc);
4510 di <<"TestCopyPaste finish\n";
4511 di <<"Status = " << good << "\n";
4513 di <<"\nTestOpenSave start\n";
4514 good += TestOpenSave(aFile1, aFile2, aFile3);
4515 di <<"TestOpenSave finish\n";
4516 di <<"Status = " << good << "\n";
4519 di <<"\nThe " << argv[0] << " test is passed well, OK\n";
4521 di <<"\nThe " << argv[0] << " test failed, Faulty\n";
4526 static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4528 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4529 if(aContext.IsNull()) {
4530 di << argv[0] << " ERROR : use 'vinit' command before \n";
4536 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4539 Standard_Integer mode = 0;
4542 mode = Draw::Atoi(argv[1]);
4544 if (mode > 2 || mode < 0)
4546 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4549 Handle(V3d_View) V = ViewerTest::CurrentView();
4550 static Handle(AIS_ColorScale) aCS;
4553 aCS = new AIS_ColorScale();
4555 if (aCS->ZLayer() != Graphic3d_ZLayerId_TopOSD)
4557 aCS->SetZLayer (Graphic3d_ZLayerId_TopOSD);
4559 if (aCS->TransformPersistence().IsNull()
4560 || aCS->TransformPersistence()->Mode() != Graphic3d_TMF_2d)
4562 aContext->SetTransformPersistence (aCS, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
4564 Standard_Integer aWinWidth, aWinHeight;
4565 V->Window()->Size (aWinWidth, aWinHeight);
4566 aCS->SetSize (aWinWidth, aWinHeight);
4567 if ( !V.IsNull() ) {
4569 aContext->Display (aCS, Standard_True);
4572 aContext->Erase (aCS, Standard_False);
4577 Standard_Boolean IsDisplayed = aContext->IsDisplayed (aCS);
4579 di <<"ColorScaleIsDisplayed = 1\n";
4581 di <<"ColorScaleIsDisplayed = 0\n";
4587 #include <Interface_Macros.hxx>
4588 #include <IGESControl_Controller.hxx>
4589 #include <XSDRAW.hxx>
4590 #include <Draw_ProgressIndicator.hxx>
4591 #include <XSControl_WorkSession.hxx>
4592 #include <Transfer_TransientProcess.hxx>
4593 #include <XSDRAW_Commands.hxx>
4594 #include <TColStd_HSequenceOfTransient.hxx>
4595 #include <Message_ProgressSentry.hxx>
4596 #include <XSControl_TransferReader.hxx>
4598 static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4600 DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
4601 if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
4603 // Progress indicator
4604 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
4605 progress->SetScale ( 0, 100, 1 );
4608 IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
4610 ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
4612 TCollection_AsciiString fnom,rnom;
4614 Standard_Boolean modfic = XSDRAW::FileAndVar
4615 (argv[1],argv[2],"IGESBREP",fnom,rnom);
4616 if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
4617 else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
4618 di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
4619 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
4622 OSD_Timer Chr; Chr.Reset();
4628 progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
4632 //In order to decrease number of produced edges during translation it is possible to set following parameter
4633 Interface_Static::SetIVal("read.iges.bspline.continuity",0);
4636 if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
4637 else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
4639 progress->EndScope();
4642 if (readstat != IFSelect_RetDone) {
4643 if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon\n";
4644 else di<<"No model loaded\n";
4647 // Choice of treatment
4648 Standard_Boolean fromtcl = (argc > 3);
4649 Standard_Integer modepri = 1, nent, nbs;
4650 if (fromtcl) modepri = 4;
4653 //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka
4654 //mode OnlyVisible does not work.
4655 // nent = Reader.NbRootsForTransfer();
4657 cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<flush;
4660 // amv 26.09.2003 : this is used to avoid error of enter's simbol
4663 modepri = Draw::Atoi(str);
4666 if (modepri == 0) { //fin
4667 di << "Bye and good luck! \n";
4671 else if (modepri <= 2) { // 1 : Visible Roots, 2 : All Roots
4672 di << "All Geometry Transfer\n";
4673 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
4674 di<<" To modify : command param read.iges.bspline.continuity\n";
4675 Handle(XSControl_WorkSession) thesession = Reader.WS();
4676 thesession->ClearContext();
4677 XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
4678 progress->NewScope ( 80, "Translation" );
4680 thesession->TransferReader()->TransientProcess()->SetProgress ( progress );
4682 if (modepri == 1) Reader.SetReadVisible (Standard_True);
4683 Reader.TransferRoots();
4685 thesession->TransferReader()->TransientProcess()->SetProgress ( 0 );
4686 progress->EndScope();
4688 // result in only one shape for all the roots
4689 // or in one shape for one root.
4690 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
4691 Standard_Integer answer = 1;
4692 if (Reader.NbShapes() > 1) {
4693 cout << " pass(0) one shape for all (1)\n or one shape per root (2)\n + WriteBRep (one for all : 3) (one per root : 4) : " << flush;
4698 answer = Draw::Atoi(str_a);
4700 if ( answer == 0) continue;
4701 if ( answer == 1 || answer == 3) {
4702 TopoDS_Shape shape = Reader.OneShape();
4704 if (shape.IsNull()) { di<<"No Shape produced\n"; continue; }
4706 Sprintf(fname, "%s", rnom.ToCString());
4707 di << "Saving shape in variable Draw : " << fname << "\n";
4708 if (answer == 3) IGESToBRep::WriteShape (shape,1);
4711 DBRep::Set(fname,shape);
4713 catch(Standard_Failure) {
4714 di << "** Exception : ";
4715 di << Standard_Failure::Caught()->GetMessageString();
4717 di << "Saving shape in variable Draw : " << fname << "\n";
4718 IGESToBRep::WriteShape (shape,1);
4722 else if (answer == 2 || answer == 4) {
4723 Standard_Integer numshape = Reader.NbShapes();
4724 for (Standard_Integer inum = 1; inum <= numshape; inum++) {
4725 // save all the shapes
4726 TopoDS_Shape shape = Reader.Shape(inum);
4727 if (shape.IsNull()) { di<<"No Shape produced\n"; continue; }
4729 Sprintf(fname, "%s_%d", rnom.ToCString(),inum);
4730 di << "Saving shape in variable Draw : " << fname << "\n";
4731 if (answer == 4) IGESToBRep::WriteShape (shape,inum);
4734 DBRep::Set(fname,shape);
4736 catch(Standard_Failure) {
4737 di << "** Exception : ";
4738 di << Standard_Failure::Caught()->GetMessageString();
4746 else if (modepri == 3) { // One Entity
4747 cout << "Only One Entity"<<endl;
4748 cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<endl;
4749 cout<<" To modify : command param read.iges.bspline.continuity"<<endl;
4750 cout << " give the number of the Entity : " << flush;
4751 nent = XSDRAW::GetEntityNumber();
4753 if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result\n";
4755 nbs = Reader.NbShapes();
4756 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nent);
4757 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
4758 di<<"Now, "<<nbs<<" Shapes produced\n";
4759 TopoDS_Shape sh = Reader.Shape(nbs);
4760 DBRep::Set (shname,sh);
4764 else if (modepri == 4) { // Selection
4765 Standard_Integer answer = 1;
4766 Handle(TColStd_HSequenceOfTransient) list;
4768 // Selection, nommee ou via tcl. tcl : raccourcis admis
4769 // * donne iges-visible + xst-transferrable-roots
4770 // *r donne xst-model-roots (TOUTES racines)
4772 if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {
4773 di << "All Geometry Transfer\n";
4774 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
4775 di<<" To modify : command param read.iges.bspline.continuity\n";
4776 Handle(XSControl_WorkSession) thesession = Reader.WS();
4777 thesession->ClearContext();
4778 XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
4779 progress->NewScope ( 80, "Translation" );
4781 thesession->TransferReader()->TransientProcess()->SetProgress ( progress );
4783 Reader.SetReadVisible (Standard_True);
4784 Reader.TransferRoots();
4786 thesession->TransferReader()->TransientProcess()->SetProgress ( 0 );
4787 progress->EndScope();
4790 // result in only one shape for all the roots
4791 TopoDS_Shape shape = Reader.OneShape();
4794 Sprintf(fname, "%s", rnom.ToCString());
4795 di << "Saving shape in variable Draw : " << fname << "\n";
4798 DBRep::Set(fname,shape);
4800 catch(Standard_Failure) {
4801 di << "** Exception : ";
4802 di << Standard_Failure::Caught()->GetMessageString();
4804 di << "Saving shape in variable Draw : " << fname << "\n";
4805 IGESToBRep::WriteShape (shape,1);
4811 modepri = 0; // d office, une seule passe
4812 if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
4814 list = XSDRAW::GetList ("xst-model-roots");
4817 TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
4818 di<<"List given by "<<compart.ToCString()<<" : ";
4819 list = XSDRAW::GetList (compart.ToCString());
4821 if (list.IsNull()) {
4822 di<<"No list defined. Give a selection name or * for all visible transferrable roots\n";
4827 cout<<"Name of Selection :"<<flush;
4828 list = XSDRAW::GetList();
4829 if (list.IsNull()) { cout<<"No list defined"<<endl; continue; }
4832 Standard_Integer nbl = list->Length();
4833 di<<"Nb entities selected : "<<nbl<<"\n";
4834 if (nbl == 0) continue;
4837 cout<<"Choice: 0 abandon 1 transfer all 2 with confirmation 3 list n0s ents :"<<flush;
4840 char str_answer[80];
4842 answer = Draw::Atoi(str_answer);
4844 if (answer <= 0 || answer > 3) continue;
4846 for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
4847 Handle(Standard_Transient) ent = list->Value(ill);
4848 di<<" ";// model->Print(ent,di);
4852 if (answer == 1 || answer == 2) {
4853 Standard_Integer nbt = 0;
4854 Handle(XSControl_WorkSession) thesession = Reader.WS();
4856 XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
4857 progress->NewScope ( 80, "Translation" );
4859 thesession->TransferReader()->TransientProcess()->SetProgress ( progress );
4861 Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
4862 for (Standard_Integer ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
4864 nent = Reader.Model()->Number(list->Value(ill));
4865 if (nent == 0) continue;
4866 if (!Reader.TransferOne(nent)) di<<"Transfer entity n0 "<<nent<<" : no result\n";
4868 nbs = Reader.NbShapes();
4869 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
4870 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
4871 di<<"Now, "<<nbs<<" Shapes produced\n";
4872 TopoDS_Shape sh = Reader.Shape(nbs);
4873 DBRep::Set (shname,sh);
4877 thesession->TransferReader()->TransientProcess()->SetProgress ( 0 );
4878 progress->EndScope();
4880 di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
4881 answer = 0; // on ne reboucle pas
4885 else di<<"Unknown mode n0 "<<modepri<<"\n";
4889 //In order to clear memory after IGES reading you could add the following code
4890 const Handle(XSControl_TransferReader) &TR = Reader.WS()->TransferReader();
4891 const Handle(Transfer_TransientProcess) &TP = TR->TransientProcess();
4894 Reader.WS()->Model()->Clear();
4895 Standard_Integer i =1;
4897 Reader.WS()->ClearData(i);
4903 #include <Geom_Plane.hxx>
4904 static Standard_Integer OCC20766 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4908 di << "Usage : " << argv[0] << " plane a b c d\n";
4912 Standard_Real A = Draw::Atof(argv[2]);
4913 Standard_Real B = Draw::Atof(argv[3]);
4914 Standard_Real C = Draw::Atof(argv[4]);
4915 Standard_Real D = Draw::Atof(argv[5]);
4917 Handle(Geom_Geometry) result;
4919 Handle(Geom_Plane) aPlane = new Geom_Plane(A, B, C, D);
4922 DrawTrSurf::Set(argv[1],result);
4926 static Standard_Integer OCC20627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4930 di << "Usage : " << argv[0] << " MaxNbr\n";
4933 Standard_Integer aMaxNbr = Draw::Atoi(argv[1]);
4935 for (Standard_Integer i=0;i<aMaxNbr;i++)
4937 BRepBuilderAPI_MakePolygon w(gp_Pnt(0,0,0),gp_Pnt(0,100,0),gp_Pnt(20,100,0),gp_Pnt(20,0,0));
4939 TopoDS_Wire wireShape( w.Wire());
4940 BRepBuilderAPI_MakeFace faceBuilder(wireShape);
4941 TopoDS_Face f( faceBuilder.Face());
4942 BRepMesh_IncrementalMesh im(f,1);
4943 BRepTools::Clean(f);
4948 #include <Graphic3d_Vector.hxx>
4949 Standard_Integer OCC22762 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4953 di << "Wrong number of arguments\n";
4956 Standard_Real X1_Pnt = Draw::Atof(argv[1]);
4957 Standard_Real Y1_Pnt = Draw::Atof(argv[2]);
4958 Standard_Real Z1_Pnt = Draw::Atof(argv[3]);
4959 Standard_Real X2_Pnt = Draw::Atof(argv[4]);
4960 Standard_Real Y2_Pnt = Draw::Atof(argv[5]);
4961 Standard_Real Z2_Pnt = Draw::Atof(argv[6]);
4963 Graphic3d_Vector AV1(X1_Pnt, Y1_Pnt, Z1_Pnt);
4964 Graphic3d_Vector AV2(X2_Pnt, Y2_Pnt, Z2_Pnt);
4966 di << "Result is: " << (Graphic3d_Vector::IsParallel(AV1, AV2) ? "true" : "false") << "\n" ;
4973 #include <IntCurvesFace_ShapeIntersector.hxx>
4974 #include <gp_Lin.hxx>
4975 Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4979 di << "Usage : " << argv[0] << " shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf\n";
4983 TopoDS_Shape shape = DBRep::Get(argv[1]);
4985 if (shape.IsNull()) {
4986 di<<" Null shape is not allowed";
4990 Standard_Real X_Pnt = Draw::Atof(argv[2]);
4991 Standard_Real Y_Pnt = Draw::Atof(argv[3]);
4992 Standard_Real Z_Pnt = Draw::Atof(argv[4]);
4994 Standard_Real X_Dir = Draw::Atof(argv[5]);
4995 Standard_Real Y_Dir = Draw::Atof(argv[6]);
4996 Standard_Real Z_Dir = Draw::Atof(argv[7]);
4998 Standard_Real PInf = Draw::Atof(argv[8]);
5000 IntCurvesFace_ShapeIntersector intersector;
5001 intersector.Load(shape, Precision::Intersection());
5003 gp_Pnt origin(X_Pnt, Y_Pnt, Z_Pnt);
5004 gp_Dir dir(X_Dir, Y_Dir, Z_Dir);
5005 gp_Lin ray(origin, dir);
5007 Standard_Real PSup = RealLast();
5008 intersector.PerformNearest(ray, PInf, PSup);
5009 if (intersector.NbPnt() != 0)
5011 di << argv[0] << " status = 0 \n";
5012 Standard_Real w = intersector.WParameter(1);
5013 di << "w = " << w << "\n";
5015 di << argv[0] << " status = -1 \n";
5020 Standard_Integer OCC22301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5023 di << "Usage : " << argv[0] << "\n";
5027 // Create mask 1111: extent == 4
5028 TColStd_PackedMapOfInteger aFullMask;
5029 for (Standard_Integer i = 0; i < 4; i++)
5032 // Create mask 1100: extent == 2
5033 TColStd_PackedMapOfInteger aPartMask;
5034 for (Standard_Integer i = 0; i < 2; i++)
5037 di << "aFullMask = 1111\n";
5038 di << "aPartMask = 1100\n";
5040 Standard_Boolean isAffected;
5042 isAffected = aFullMask.Intersect(aPartMask); // true; extent == 2 (OK)
5043 di << "First time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5044 isAffected = aFullMask.Intersect(aPartMask); // true; extent == 0 (?)
5045 di << "Second time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5046 isAffected = aFullMask.Subtract(aPartMask); // false (?)
5047 di << "After two intersections: aFullMask.Subtract(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5051 #include <ShapeFix_FixSmallFace.hxx>
5052 Standard_Integer OCC22586 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5056 di << "Usage : " << argv[0] << " shape resshape\n";
5060 // try to read a shape:
5061 TopoDS_Shape aShape=DBRep::Get(argv[1]);
5062 ShapeFix_FixSmallFace aFixSmallFaces;
5063 aFixSmallFaces.Init (aShape);
5064 aFixSmallFaces.Perform();
5065 TopoDS_Shape aResShape = aFixSmallFaces.Shape();
5066 DBRep::Set(argv[2],aResShape);
5072 #include <NCollection_DataMap.hxx>
5073 Standard_Integer OCC22744 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5077 di << "Usage : " << argv[0] << "\n";
5081 TCollection_ExtendedString anExtString;
5083 Standard_ExtCharacter aNonAsciiChar = 0x0f00;
5084 anExtString.Insert(1, aNonAsciiChar);
5086 di << "Is ASCII: " << ( anExtString.IsAscii() ? "true : Error" : "false : OK" ) << "\n";
5087 NCollection_DataMap<TCollection_ExtendedString, Standard_Integer> aMap;
5088 aMap.Bind(anExtString, 0);
5094 Standard_Integer OCC22558 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5097 di << "Wrong number of arguments" << argv[0] << "\n";
5101 Standard_Real X_vec = Draw::Atof(argv[1]);
5102 Standard_Real Y_vec = Draw::Atof(argv[2]);
5103 Standard_Real Z_vec = Draw::Atof(argv[3]);
5105 Standard_Real X_dir = Draw::Atof(argv[4]);
5106 Standard_Real Y_dir = Draw::Atof(argv[5]);
5107 Standard_Real Z_dir = Draw::Atof(argv[6]);
5109 Standard_Real X_pnt = Draw::Atof(argv[7]);
5110 Standard_Real Y_pnt = Draw::Atof(argv[8]);
5111 Standard_Real Z_pnt = Draw::Atof(argv[9]);
5113 gp_Dir toSym(X_vec, Y_vec, Z_vec);
5114 gp_Dir dir(X_dir, Y_dir, Z_dir);
5115 gp_Pnt loc(X_pnt, Y_pnt, Z_pnt);
5116 gp_Ax2 symObj(loc,dir);
5117 toSym.Mirror(symObj);
5119 di << "The result " << toSym.X() << " " << toSym.Y() << " " << toSym.Z() << "\n";
5124 Standard_Integer OCC22736 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5128 di << "Usage : " << argv[0] << " X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2\n";
5132 Standard_Real X_mirrorFirstPoint = Draw::Atof(argv[1]);
5133 Standard_Real Y_mirrorFirstPoint = Draw::Atof(argv[2]);
5134 Standard_Real X_mirrorSecondPoint = Draw::Atof(argv[3]);
5135 Standard_Real Y_mirrorSecondPoint = Draw::Atof(argv[4]);
5136 Standard_Real X_p1 = Draw::Atof(argv[5]);
5137 Standard_Real Y_p1 = Draw::Atof(argv[6]);
5138 Standard_Real X_p2 = Draw::Atof(argv[7]);
5139 Standard_Real Y_p2 = Draw::Atof(argv[8]);
5141 gp_Trsf2d identityTransformation;
5143 gp_Pnt2d mirrorFirstPoint(X_mirrorFirstPoint,Y_mirrorFirstPoint);
5144 gp_Pnt2d mirrorSecondPoint(X_mirrorSecondPoint,Y_mirrorSecondPoint);
5145 gp_Ax2d mirrorAxis(mirrorFirstPoint,gp_Vec2d(mirrorFirstPoint,mirrorSecondPoint));
5147 gp_Pnt2d p1(X_p1,Y_p1);
5148 gp_Pnt2d p2(X_p2,Y_p2);
5151 M1.SetMirror(mirrorAxis);
5153 M2.SetMirror(mirrorAxis);
5155 Tcomp = M2.Multiplied(M1);
5157 Standard_Real aTol = Precision::Confusion();
5158 Standard_Integer aStatus = 0;
5160 //After applying two times the same mirror the point is located on the same location OK
5161 gp_Pnt2d p1MirrorM1 = p1.Transformed(M1);
5162 if ( Abs(p2.X() - p1MirrorM1.X()) > aTol )
5164 if ( Abs(p2.Y() - p1MirrorM1.Y()) > aTol )
5167 gp_Pnt2d p1MirrorM1M2 = p1MirrorM1.Transformed(M2);
5168 if ( Abs(p1.X() - p1MirrorM1M2.X()) > aTol )
5170 if ( Abs(p1.Y() - p1MirrorM1M2.Y()) > aTol )
5173 //If we apply the composed transformation of the same two mirrors to a point the result is //not located on the initial position.-->>ERROR
5174 gp_Pnt2d p1MirrorComp = p1.Transformed(Tcomp);
5175 if ( Abs(p1.X() - p1MirrorComp.X()) > aTol )
5177 if ( Abs(p1.Y() - p1MirrorComp.Y()) > aTol )
5180 di << "Status = " << aStatus << "\n";
5184 Standard_Integer OCC23429(Draw_Interpretor& /*di*/,
5185 Standard_Integer narg, const char** a)
5187 if (narg < 4) return 1;
5189 TopoDS_Shape aShape = DBRep::Get(a[2]);
5190 if (aShape.IsNull()) return 1;
5192 BRepFeat_SplitShape Spls(aShape);
5193 Spls.SetCheckInterior(Standard_False);
5195 TopoDS_Shape aTool = DBRep::Get(a[3]);
5197 BRepAlgoAPI_Section Builder(aShape, aTool, Standard_False);
5198 Builder.ComputePCurveOn1(Standard_True);
5200 Builder.Approximation(Standard_True);
5202 TopoDS_Shape aSection = Builder.Shape();
5204 TopExp_Explorer ExpSec(aSection, TopAbs_EDGE);
5205 for (; ExpSec.More(); ExpSec.Next())
5207 TopoDS_Edge anEdge = TopoDS::Edge(ExpSec.Current());
5208 Handle(Geom2d_Curve) thePCurve;
5209 Handle(Geom_Surface) theSurface;
5210 TopLoc_Location theLoc;
5211 Standard_Real fpar, lpar;
5212 BRep_Tool::CurveOnSurface(anEdge, thePCurve, theSurface, theLoc, fpar, lpar);
5214 TopExp_Explorer ExpShape(aShape, TopAbs_FACE);
5215 for (; ExpShape.More(); ExpShape.Next())
5217 aFace = TopoDS::Face(ExpShape.Current());
5218 TopLoc_Location aLoc;
5219 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace, aLoc);
5220 if (aSurface == theSurface && aLoc == theLoc)
5223 Spls.Add(anEdge, aFace);
5226 TopoDS_Shape Result = Spls.Shape();
5227 DBRep::Set(a[1], Result);
5232 #include <ExprIntrp_GenExp.hxx>
5233 Standard_Integer CR23403 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5237 di << "Usage : " << argv[0] << " string\n";
5241 Standard_CString aString = argv[1];
5242 Handle(ExprIntrp_GenExp) myExpr = ExprIntrp_GenExp::Create();
5245 myExpr->Process( aString );
5247 catch(Standard_Failure) {
5248 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
5249 di << "Exception : " << aFail->GetMessageString() << "\n";
5255 void QABugs::Commands_11(Draw_Interpretor& theCommands) {
5256 const char *group = "QABugs";
5258 theCommands.Add("OCC128", "OCC128", __FILE__, OCC128, group);
5260 // Remove as bad version of QAAddOrRemoveSelected from QADraw
5261 //theCommands.Add("OCC129", "OCC129 shape islocal", __FILE__, OCC129, group);
5263 theCommands.Add("OCC136", "OCC136", __FILE__, OCC136, group);
5264 theCommands.Add("BUC60610","BUC60610 iges_input [name]",__FILE__,BUC60610,group);
5266 //====================================================
5268 // Following commands are inserted from
5269 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
5270 // ( 75455 Apr 16 18:59)
5272 //====================================================
5274 theCommands.Add("OCC105","OCC105 shape",__FILE__,OCC105,group);
5275 theCommands.Add("OCC9"," result path cur1 cur2 radius [tolerance]:\t test GeomFill_Pipe", __FILE__, pipe_OCC9,group);
5277 theCommands.Add("OCC125","OCC125 shell", __FILE__, OCC125,group);
5279 theCommands.Add("OCC157","findplanarsurface Result wire Tol",__FILE__,OCC157,group);
5280 //theCommands.Add("OCC165","OCC165",__FILE__,OCC165,group);
5281 theCommands.Add("OCC165","OCC165 file",__FILE__,OCC165,group);
5282 theCommands.Add("OCC297","OCC297",__FILE__,OCC297,group);
5283 //theCommands.Add("OCC305","OCC305",__FILE__,OCC305,group);
5284 theCommands.Add("OCC305","OCC305 file",__FILE__,OCC305,group);
5287 theCommands.Add("OCC166", "OCC166", __FILE__, OCC166, group);
5288 theCommands.Add("OCC381_Save", "OCC381_Save Doc", __FILE__, OCC381_Save, group);
5289 theCommands.Add("OCC381_SaveAs", "OCC381_SaveAs Doc Path", __FILE__, OCC381_SaveAs, group);
5291 theCommands.Add("OCC299","OCC299 Solid Point [Tolerance=1.e-7]", __FILE__, OCC299bug, group);
5292 theCommands.Add("OCC309","OCC309", __FILE__, OCC309bug, group);
5293 theCommands.Add("OCC310","OCC310", __FILE__, OCC310bug, group);
5295 //theCommands.Add("OCC277","OCC277", __FILE__, OCC277bug, group);
5296 theCommands.Add("OCC277","OCC277 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC277bug, group);
5298 theCommands.Add("OCC333","OCC333 edge1 edge2 [toler domaindist]; Check overlapping edges", __FILE__, OCC333bug, group);
5300 theCommands.Add("OCC363", "OCC363 document filename ", __FILE__, OCC363, group);
5302 //theCommands.Add("OCC372", "OCC372", __FILE__, OCC372, group);
5303 theCommands.Add("OCC377", "OCC377", __FILE__, OCC377, group);
5304 theCommands.Add("OCC22", "OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation", __FILE__, OCC22, group);
5305 theCommands.Add("OCC24", "OCC24 Result Shape CompoundOfSubshapes ResourceFileName", __FILE__, OCC24, group);
5306 theCommands.Add("OCC369", "OCC369 Shape", __FILE__, OCC369, group);
5307 theCommands.Add("OCC524", "OCC524 LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix", __FILE__, OCC524, group);
5308 theCommands.Add("OCC525", "OCC525", __FILE__, OCC525, group);
5309 //theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
5310 theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC578, group);
5311 theCommands.Add("OCC669", "OCC669 GUID", __FILE__, OCC669, group);
5312 theCommands.Add("OCC738_ShapeRef", "OCC738_ShapeRef", __FILE__, OCC738_ShapeRef, group);
5313 theCommands.Add("OCC738_Assembly", "OCC738_Assembly", __FILE__, OCC738_Assembly, group);
5314 theCommands.Add("OCC708", "OCC708 shape ; Deactivate the current transformation", __FILE__, OCC708, group);
5315 theCommands.Add("OCC670", "OCC670", __FILE__, OCC670, group);
5316 theCommands.Add("OCC867", "OCC867 Point Surface Umin Usup Vmin Vsup", __FILE__, OCC867, group);
5317 theCommands.Add("OCC909", "OCC909 wire face", __FILE__, OCC909, group);
5318 theCommands.Add("OCC921", "OCC921 face", __FILE__, OCC921, group);
5319 theCommands.Add("OCC902", "OCC902 expression", __FILE__, OCC902, group);
5321 theCommands.Add ("OCC1029_AISTransparency","OCC1029_AISTransparency (DOC, entry, [real])",__FILE__, OCC1029_AISTransparency, group);
5322 theCommands.Add ("OCC1030_AISColor", "OCC1030_AISColor (DOC, entry, [color])", __FILE__, OCC1030_AISColor, group);
5323 theCommands.Add ("OCC1031_AISMaterial", "OCC1031_AISMaterial (DOC, entry, [material])", __FILE__, OCC1031_AISMaterial, group);
5324 theCommands.Add ("OCC1032_AISWidth", "OCC1032_AISWidth (DOC, entry, [width])", __FILE__, OCC1032_AISWidth, group);
5325 theCommands.Add ("OCC1033_AISMode", "OCC1033_AISMode (DOC, entry, [mode])", __FILE__, OCC1033_AISMode, group);
5326 theCommands.Add ("OCC1034_AISSelectionMode", "OCC1034_AISSelectionMode (DOC, entry, [selectionmode])", __FILE__, OCC1034_AISSelectionMode, group);
5328 //theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape", __FILE__, OCC1487, group);
5329 theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC1487, group);
5331 theCommands.Add("OCC1077", "OCC1077 result", __FILE__, OCC1077, group);
5332 theCommands.Add("OCC5739", "OCC5739 name shape step", __FILE__, OCC5739_UniAbs, group);
5333 theCommands.Add("OCC6046", "OCC6046 nb_of_vectors size", __FILE__, OCC6046, group);
5334 theCommands.Add("OCC5698", "OCC5698 wire", __FILE__, OCC5698, group);
5335 theCommands.Add("OCC6143", "OCC6143", __FILE__, OCC6143, group);
5336 theCommands.Add("OCC7141", "OCC7141 [nCount] aPath", __FILE__, OCC7141, group);
5337 theCommands.Add("OCC7372", "OCC7372", __FILE__, OCC7372, group);
5338 theCommands.Add("OCC8169", "OCC8169 edge1 edge2 plane", __FILE__, OCC8169, group);
5339 theCommands.Add("OCC10138", "OCC10138 lower upper", __FILE__, OCC10138, group);
5340 theCommands.Add("OCC7639", "OCC7639 index1 value1 ... [indexN valueN]", __FILE__, OCC7639, group);
5341 theCommands.Add("OCC8797", "OCC8797", __FILE__, OCC8797, group);
5342 theCommands.Add("OCC7068", "OCC7068", __FILE__, OCC7068, group);
5343 theCommands.Add("OCC11457", "OCC11457 polygon lastedge x1 y1 z1 x2 y2 z2 ...", __FILE__, OCC11457, group);
5344 theCommands.Add("OCC13963", "OCC13963 ratio origin_x origin_y origin_z", __FILE__, OCC13963, group);
5345 theCommands.Add("OCC14376", "OCC14376 shape [deflection]", __FILE__, OCC14376, group);
5346 theCommands.Add("OCC15489", "OCC15489 A B C", __FILE__, OCC15489, group);
5347 theCommands.Add("OCC15755", "OCC15755 file shape", __FILE__, OCC15755, group);
5348 theCommands.Add("OCC16782", "OCC16782 file.std file.xml file.cbf", __FILE__, OCC16782, group);
5349 theCommands.Add("OCC12584", "OCC12584 [mode = 0/1/2]", __FILE__, OCC12584, group);
5350 theCommands.Add("OCC18612", "OCC18612 [file else already loaded model] [name DRAW]", __FILE__, OCC18612igesbrep, group);
5351 theCommands.Add("OCC20766", "OCC20766 plane a b c d", __FILE__, OCC20766, group);
5352 theCommands.Add("OCC20627", "OCC20627", __FILE__, OCC20627, group);
5353 theCommands.Add("OCC17424", "OCC17424 shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf", __FILE__, OCC17424, group);
5354 theCommands.Add("OCC22301", "OCC22301", __FILE__, OCC22301, group);
5355 theCommands.Add("OCC22586", "OCC22586 shape resshape", __FILE__, OCC22586, group);
5356 theCommands.Add("OCC22736", "OCC22736 X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2", __FILE__, OCC22736, group);
5357 theCommands.Add("OCC22744", "OCC22744", __FILE__, OCC22744, group);
5358 theCommands.Add("OCC22762", "OCC22762 x1 y1 z1 x2 y2 z3", __FILE__, OCC22762, group);
5359 theCommands.Add("OCC22558", "OCC22558 x_vec y_vec z_vec x_dir y_dir z_dit x_pnt y_pnt z_pnt", __FILE__, OCC22558, group);
5360 theCommands.Add("CR23403", "CR23403 string", __FILE__, CR23403, group);
5361 theCommands.Add("OCC23429", "OCC23429 res shape tool [appr]", __FILE__, OCC23429, group);