2 // Created: Wed Mar 20 09:42:59 2002
4 // <qa@umnox.nnov.matra-dtv.fr>
11 #include <Draw_Interpretor.hxx>
13 #include <DrawTrSurf.hxx>
14 #include <AIS_InteractiveContext.hxx>
15 #include <ViewerTest.hxx>
16 #include <AIS_Shape.hxx>
17 #include <TopoDS_Shape.hxx>
19 #include <Geom_Axis2Placement.hxx>
21 #include <gp_Trsf.hxx>
22 #include <AIS_Trihedron.hxx>
23 #include <BRepPrimAPI_MakeBox.hxx>
24 #include <Graphic3d_MaterialAspect.hxx>
25 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
26 #include <TopoDS_Solid.hxx>
27 #include <BRepPrimAPI_MakeSphere.hxx>
28 #include <BRepPrimAPI_MakeCone.hxx>
29 #include <BRepPrimAPI_MakeCylinder.hxx>
30 #include <IGESToBRep_Reader.hxx>
31 #include <TopExp_Explorer.hxx>
33 #include <GCPnts_UniformDeflection.hxx>
34 #include <BRepAdaptor_Curve.hxx>
35 #include <IGESToBRep.hxx>
36 #include <V3d_Viewer.hxx>
37 #include <BRepAdaptor_CompCurve.hxx>
38 #include <GCPnts_AbscissaPoint.hxx>
39 #include <Standard_ErrorHandler.hxx>
40 #include <Standard_Overflow.hxx>
41 #include <Standard_Underflow.hxx>
42 #include <Standard_DivideByZero.hxx>
43 #include <OSD_SIGSEGV.hxx>
44 #include <OSD_Exception_ACCESS_VIOLATION.hxx>
45 #include <OSD_Exception_STACK_OVERFLOW.hxx>
47 #include <STEPCAFControl_Writer.hxx>
48 #include <STEPControl_StepModelType.hxx>
49 #include <Interface_Static.hxx>
50 #include <IFSelect_ReturnStatus.hxx>
51 #include <Standard_Failure.hxx>
52 #include <TColgp_HArray1OfPnt2d.hxx>
53 #include <Geom2dAPI_Interpolate.hxx>
54 #include <Geom2d_BSplineCurve.hxx>
55 #include <Geom2dConvert_BSplineCurveToBezierCurve.hxx>
56 #include <Geom2d_BezierCurve.hxx>
57 #include <BRep_Tool.hxx>
58 #include <GeomProjLib.hxx>
59 #include <Geom2dAPI_InterCurveCurve.hxx>
60 #include <IntRes2d_IntersectionSegment.hxx>
61 #include <TDataStd_RealArray.hxx>
62 #include <TDF_CopyLabel.hxx>
63 #include <NCollection_Vector.hxx>
64 #include <TColStd_Array1OfInteger.hxx>
65 #include <Geom_BSplineCurve.hxx>
66 #include <TColgp_Array1OfPnt.hxx>
67 #include <AIS_ListOfInteractive.hxx>
68 #include <AIS_ListIteratorOfListOfInteractive.hxx>
69 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
70 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
71 #include <BRepBuilderAPI_MakePolygon.hxx>
72 #include <gp_GTrsf.hxx>
73 #include <Poly_Triangulation.hxx>
74 #include <IGESControl_Reader.hxx>
75 #include <IGESData_IGESModel.hxx>
76 #include <IGESData_IGESEntity.hxx>
77 #include <V3d_View.hxx>
82 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
84 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
87 static Standard_Integer OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
89 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
90 if(myAISContext.IsNull()) {
91 di << "use 'vinit' command before " << argv[0] ;
95 Handle(Geom_Axis2Placement) aTrihedronAxis = new Geom_Axis2Placement(gp::XOY());
98 trsf1.SetTranslation(gp_Vec(100, 100, 0));
99 aTrihedronAxis->Transform(trsf1);
100 Handle(AIS_Trihedron) myTrihedron = new AIS_Trihedron(aTrihedronAxis);
101 myTrihedron->SetColor(Quantity_NOC_LIGHTSTEELBLUE4);
102 myTrihedron->SetSize(100);
103 myAISContext->Display(myTrihedron, Standard_True);
105 // TopoDS_Shape shape1 = (TopoDS_Shape) BRepPrimAPI_MakeBox(50,50,50);
106 TopoDS_Shape shape1 = BRepPrimAPI_MakeBox(50,50,50).Shape();
107 Handle(AIS_Shape) AS = new AIS_Shape(shape1);
108 AS->SetDisplayMode(1);
109 Graphic3d_MaterialAspect mat(Graphic3d_NOM_PLASTIC);
110 AS->SetMaterial(mat);
111 AS->SetColor(Quantity_NOC_RED);
112 myAISContext->Display(AS);
115 TouchTrsf.SetTranslation(gp_Vec(20, 20, 0));
117 myAISContext->ResetLocation(AS);
118 myAISContext->SetLocation(AS , TouchTrsf) ;
119 myAISContext->Redisplay(AS, Standard_True);
124 // Remove as bad version of QAAddOrRemoveSelected from QADraw
125 //static Standard_Integer OCC129 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
128 // di<<"Usage : " << argv[0] << " shape islocal\n";
132 // Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
134 // // ViewerTest_DoubleMapOfInteractiveAndName& aMap =
135 // // ViewerTest::GetDataMapOfAIS ();
136 // ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
138 // TCollection_AsciiString aName(argv[1]);
139 // Handle(AIS_InteractiveObject) AISObj;
141 // if(aMap.IsBound2(aName)) {
142 // AISObj = aMap.Find2(aName);
143 // if(AISObj.IsNull()){
144 // di<<"No interactive object \n";
148 // Standard_Integer aNum = -1;
150 // if(atoi(argv[2])) {
151 // aNum = anAISCtx->OpenLocalContext();
154 // if(anAISCtx->HasOpenedContext()){
155 // anAISCtx->InitSelected();
156 // anAISCtx->AddOrRemoveSelected(AISObj);
159 // anAISCtx->InitCurrent();
160 // anAISCtx->AddOrRemoveCurrentObject(AISObj);
164 // // anAISCtx->CloseLocalContext(aNum);
169 // //select this shape:
171 // di<<"Use 'vdisplay' before";
176 static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
179 di<<"Usage: OCC136\n";
183 //create some primitives:
185 Standard_Real Size=100;
186 gp_Pnt P0(0,0,0), P1(Size,Size,Size);
188 TopoDS_Solid aBox = BRepPrimAPI_MakeBox(P0,P1);
190 TopoDS_Solid aSphere = BRepPrimAPI_MakeSphere (Size*0.5);
192 gp_Ax2 anAx2(P1, gp_Dir(1,1,1));
193 TopoDS_Solid aCone = BRepPrimAPI_MakeCone(anAx2, Size*0.7, Size*0.3, Size);
195 anAx2.SetLocation(gp_Pnt(Size,0,0));
196 anAx2.SetDirection(gp_Dir(-1,-1,1));
197 TopoDS_Solid aCyl = BRepPrimAPI_MakeCylinder(anAx2, Size*0.5, Size);
199 Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
200 if(anAISCtx.IsNull()){
201 di<<"Null interactive context. Use 'vinit' at first.\n";
205 if(anAISCtx->HasOpenedContext()) anAISCtx->CloseAllContexts();
206 anAISCtx->EraseAll();
208 //load primitives to context
209 Handle(AIS_Shape) aSh1 = new AIS_Shape(aBox);
210 anAISCtx->Display(aSh1);
212 Handle(AIS_Shape) aSh2 = new AIS_Shape(aSphere);
213 anAISCtx->Display(aSh2);
215 Handle(AIS_Shape) aSh3 = new AIS_Shape(aCone);
216 anAISCtx->Display(aSh3);
218 Handle(AIS_Shape) aSh4 = new AIS_Shape(aCyl);
219 anAISCtx->Display(aSh4);
222 anAISCtx->InitCurrent();
223 anAISCtx->AddOrRemoveCurrentObject(aSh1);
224 anAISCtx->AddOrRemoveCurrentObject(aSh2);
225 anAISCtx->AddOrRemoveCurrentObject(aSh3);
226 anAISCtx->AddOrRemoveCurrentObject(aSh4);
228 //remove all this objects from context
229 anAISCtx->Clear(aSh1, Standard_False);
230 anAISCtx->Clear(aSh2, Standard_False);
231 anAISCtx->Clear(aSh3, Standard_False);
232 anAISCtx->Clear(aSh4, Standard_False);
236 static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
238 printf("Usage: %s iges_input [name]\n",argv[0]);
241 Standard_Character *Ch;
244 Ch = new Standard_Character[strlen(argv[2])+3];
246 IGESToBRep_Reader IR;
247 IR.LoadFile (argv[1]);
250 TopoDS_Shape aTopShape = IR.OneShape();
251 TopExp_Explorer ex(aTopShape, TopAbs_EDGE);
252 Standard_Integer i=0;
253 for( ; ex.More(); ex.Next()){
254 const TopoDS_Edge &E = TopoDS::Edge(ex.Current());
255 BRepAdaptor_Curve aCurve(E);
256 GCPnts_UniformDeflection plin(aCurve, 0.1);
257 di << "Num points = " << plin.NbPoints() << "\n";
260 sprintf(Ch,"%s_%i",argv[2],1);
267 static Standard_Integer BUC60661(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
271 di << "Usage : " << a[0] << " file.igs" << "\n";
275 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
277 if(myContext.IsNull()) {
278 di << "use 'vinit' command before " << a[0] << "\n";
283 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
284 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
286 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
289 Standard_Character *file1 = new Standard_Character [strlen(DD)+strlen(a[1])+2];
290 sprintf(file1,"%s/%s",DD,a[1]);
292 IGESToBRep_Reader reader;
293 Standard_Integer status = reader.LoadFile(file1);
296 reader.TransferRoots();
297 TopoDS_Shape shape = reader.OneShape();
299 Handle(AIS_Shape) importedShape = new AIS_Shape(shape);
301 Handle(V3d_Viewer) myPView = myContext->CurrentViewer();
303 if( ! myPView.IsNull() && (myPView->DefaultVisualization() == V3d_WIREFRAME) )
304 importedShape->SetDisplayMode(AIS_WireFrame);
305 else importedShape->SetDisplayMode(AIS_Shaded);
306 myContext->Display(importedShape);
309 printf("\n End of my IGES to 3D-viewer *****************>\n");
314 //====================================================
316 // Following code is inserted from
317 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
318 // ( 75455 Apr 16 18:59)
320 //====================================================
323 #include <BRepTools_WireExplorer.hxx>
324 #include <BRep_Tool.hxx>
325 #include <GCPnts_UniformAbscissa.hxx>
326 #include <TopExp.hxx>
329 // usage : OCC105 shape
332 //GCPnts_UniformAbscissa returns bad end point foe first edge. Its value is
334 //Value Pnt = -338.556216693211 -394.465571897208 0
336 //Value Pnt = -307.47165394 -340.18073533 0
338 static int OCC105(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
341 di<<"Usage : OCC105 shape\n";
344 // TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get("aa.brep"));
345 TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1]));
346 Standard_Real l = 0.5; //atof(argv[2]);
347 // Find the first vertex of the wire
348 BRepTools_WireExplorer wire_exp(myTopoDSWire);
351 TopoDS_Vertex vw1, vw2;
352 TopExp::Vertices(myTopoDSWire,vw1,vw2);
353 TopoDS_Vertex ve1, ve2;
354 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
355 TopExp::Vertices(edge,ve1,ve2);
356 if (vw1.IsSame(ve1) || vw1.IsSame(ve2))
359 // assert(vw2.IsSame(ve1) || vw2.IsSame(ve2));
363 for ( ; wire_exp.More(); wire_exp.Next())
365 di << "\n\n New Edge \n" << "\n";
366 Standard_Real newufirst, newulast;
367 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
368 Standard_Real ufirst, ulast;
369 Handle(Geom_Curve) acurve;
370 TopoDS_Vertex ve1, ve2;
371 TopExp::Vertices(edge,ve1,ve2);
372 if (ve1.IsSame(vlast))
374 acurve = BRep_Tool::Curve(edge, ufirst, ulast);
381 // assert(ve2.IsSame(vlast));
382 // assert ( wire_exp.Orientation( ) == TopAbs_REVERSED );
383 acurve = BRep_Tool::Curve( edge, ufirst, ulast );
384 newufirst = acurve->ReversedParameter( ufirst );
385 newulast = acurve->ReversedParameter( ulast );
386 acurve = acurve->Reversed( );
390 GeomAdaptor_Curve curve;
391 GCPnts_UniformAbscissa algo;
393 algo.Initialize( curve, l, newufirst, newulast );
395 di << "Not Done!!!" << "\n";
396 for (Standard_Integer Index = 1; Index<=algo.NbPoints();Index++) {
397 Standard_Real t = algo.Parameter(Index);
398 gp_Pnt pt3 = curve.Value(t);
399 di << "Parameter t = " << t << "\n";
400 di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z() << "\n";
407 #include <TColStd_SequenceOfTransient.hxx>
408 #include <GeomFill_Pipe.hxx>
409 static int pipe_OCC9 (Draw_Interpretor& di,
410 Standard_Integer n, const char ** a)
413 di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]" << "\n";
417 TColStd_SequenceOfTransient aCurveSeq;
419 for (i=2 ; i<=4; i++) {
420 Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast( DrawTrSurf::Get(a[i]) );
422 di << a[i] << " is not a curve" << "\n";
425 aCurveSeq.Append(aC);
428 GeomFill_Pipe aPipe(Handle(Geom_Curve)::DownCast( aCurveSeq(1) ),
429 Handle(Geom_Curve)::DownCast( aCurveSeq(2) ),
430 Handle(Geom_Curve)::DownCast( aCurveSeq(3) ),
434 aPipe.Perform(atof (a[6]), Standard_True);
436 aPipe.Perform(Standard_True/*, Standard_True*/);
439 Handle(Geom_Surface) aSurf = aPipe.Surface();
441 DrawTrSurf::Set(a[1], aSurf);
445 //======================================================================
447 // usage : OCC125 shell
448 //======================================================================
449 #include <ShapeFix_Shell.hxx>
451 Standard_Integer OCC125(Draw_Interpretor& di ,
456 di<<" Use OCC125 shell";
460 TopoDS_Shape S = DBRep::Get(a[1]);
463 di<<" Null shape is not allowed";
469 if (aT!=TopAbs_SHELL) {
470 di<<" Shape Type must be SHELL";
474 const TopoDS_Shell& aShell = TopoDS::Shell(S);
476 Standard_Boolean isAccountMultiConex, bNonManifold, bResult;
478 isAccountMultiConex=Standard_True;
479 bNonManifold=Standard_False;
481 Handle (ShapeFix_Shell) aFix = new ShapeFix_Shell(aShell);
482 bResult=aFix->FixFaceOrientation(aShell, isAccountMultiConex, bNonManifold);
484 di<<"bResult="<<(Standard_Integer)bResult;
487 aShape=aFix->Shape();
489 TCollection_AsciiString aName(a[1]), aDef("_sh"), aRName;
492 DBRep::Set (aRName.ToCString(), aShape);
493 di<<aRName.ToCString();
498 #include <BRepLib_FindSurface.hxx>
499 #include <BRepBuilderAPI_MakeFace.hxx>
500 Standard_Integer OCC157(Draw_Interpretor& di,
503 //static Standard_Integer findplanarsurface(Draw_Interpretor&, Standard_Integer n, const char ** a)
506 di << "bad number of arguments" <<"\n";
510 // try to read a shape:
511 TopoDS_Shape inputShape=DBRep::Get(a[2]);
512 if (inputShape.IsNull() || inputShape.ShapeType() != TopAbs_WIRE) {
513 di << "Invalid input shape"<< "\n";
516 Standard_Real toler = atof(a[3]);
517 TopoDS_Wire aWire = TopoDS::Wire(inputShape);
518 BRepLib_FindSurface FS(aWire, toler, Standard_True);
520 di<<"OCC157: OK; Planar surface is found"<<"\n";
521 Handle(Geom_Surface) aSurf = FS.Surface();
522 BRepBuilderAPI_MakeFace aMakeFace(aSurf,aWire,Standard_True);
523 if(aMakeFace.IsDone()) {
524 TopoDS_Face aFace = aMakeFace.Face();
525 DBRep::Set(a[1],aFace);
528 else di<<"OCC157: ERROR; Planar surface is not found with toler = "<<toler <<"\n";
533 // #include <MyCommandsCMD.h>
534 #include <ShapeFix_Shape.hxx>
535 #include <BRepOffset_MakeOffset.hxx>
536 #include <BRepOffsetAPI_MakeOffset.hxx>
537 #include <BRepOffset_Mode.hxx>
538 #include <GeomAbs_JoinType.hxx>
539 #include <AIS_Shape.hxx>
541 #include <BRepTools.hxx>
543 Standard_Integer OCC165(Draw_Interpretor& di ,
548 //=======================================================================
550 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv);
552 // void MyOffsets_Commands(Draw_Interpretor& theCommands)
554 // theCommands.Add("yoffset" , "yoffset" , __FILE__, YOffset, " Offset on Z Direction");
557 //=======================================================================
559 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
563 di <<"Usage : " << a[0] << " [file]"<<"\n";
568 #define _OFFSET_TELCO_
569 #ifdef _OFFSET_TELCO_
571 Standard_CString file = a[1];
573 BRep_Builder aBuilder;
574 TopoDS_Shape theShape;
575 //BRepTools::Read(theShape, Standard_CString("/dn02/users_SUN/inv/3/OCC165/2d_tr_line.brep"), aBuilder);
576 BRepTools::Read(theShape, file, aBuilder);
577 DBRep::Set("shape", theShape);
579 TopoDS_Wire theWire = TopoDS::Wire(theShape);
581 Standard_Real anOffset = 1.5;
585 Standard_Real xA = 0.0, xB = 200.0, xC = 200.0, xD = 0.0,
586 yA = 0.0, yB = 0.0, yC = 200.0, yD = 200.0,
587 zA = 0.0, zB = 0.0, zC = 0.0, zD = 0.0;
589 BRepBuilderAPI_MakePolygon theSquare;
590 TopoDS_Vertex theA = BRepBuilderAPI_MakeVertex(gp_Pnt(xA, yA, zA));
592 TopoDS_Vertex theB = BRepBuilderAPI_MakeVertex(gp_Pnt(xB, yB, zB));
594 TopoDS_Vertex theC = BRepBuilderAPI_MakeVertex(gp_Pnt(xC, yC, zC));
596 TopoDS_Vertex theD = BRepBuilderAPI_MakeVertex(gp_Pnt(xD, yD, zD));
600 TopoDS_Wire theWire = theSquare.Wire();
602 Standard_Real anOffset = 10;
605 #endif /* _OFFSET_TELCO_ */
608 TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire).Face();
609 DBRep::Set("face", theFace);
612 Standard_Real anAlt = 0.;
613 GeomAbs_JoinType theJoin = GeomAbs_Intersection;
614 //GeomAbs_Intersection; //GeomAbs_Arc;
615 BRepOffsetAPI_MakeOffset aMakeOffset(theFace, theJoin);
616 aMakeOffset.AddWire(theWire);
618 aMakeOffset.Perform(anOffset, anAlt);
620 TopoDS_Shape theOffsetShapePos = aMakeOffset.Shape();
621 DBRep::Set("offset", theOffsetShapePos);
626 #include<BRepAlgoAPI_Cut.hxx>
627 #include<BRepAlgo_Cut.hxx>
629 #include<BRepPrimAPI_MakeHalfSpace.hxx>
630 #include<Handle_Geom_CartesianPoint.hxx>
631 #include<Geom_CartesianPoint.hxx>
632 #include<AIS_Point.hxx>
634 #include <BRepBuilderAPI_MakeEdge.hxx>
635 #include <BRepBuilderAPI_MakeWire.hxx>
636 #include <BRepBuilderAPI_MakeFace.hxx>
638 static Standard_Integer OCC297 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
642 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
643 if(myAISContext.IsNull()) {
644 di << "use 'vinit' command before " << argv[0] << "\n";
649 gp_Pnt pt1_(250.,250.,0.);
650 gp_Pnt pt2_(-250.,250.,0.);
651 gp_Pnt pt3_(-250.,-250.,0.);
652 gp_Pnt pt4_(250.,-250.,0.);
653 BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
654 BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
655 BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
656 BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
658 BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
659 BRepBuilderAPI_MakeFace face_(wire_);
660 TopoDS_Face sh_ = face_.Face();
666 g_pnt = gp_Pnt(0,0,-100);
668 g_pnt = gp_Pnt(0,0,100);
670 myAISContext->EraseAll(Standard_False);
671 Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
672 Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
673 myAISContext->Display(AISPoint);
675 BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
676 TopoDS_Solid sol1_ = half_.Solid();
677 // Handle(AIS_Shape) AISHalf = new AIS_Shape(sol1_);
678 // AISHalf->SetColor(Quantity_NOC_GREEN);
679 // myAISContext->Display(AISHalf);
681 DBRep::Set("Face",sol1_);
683 gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
685 Standard_Real x=0., y=0., z=-80.;
687 BRepPrimAPI_MakeBox box(gp_Pnt(x,y,z),gp_Pnt(x+150,y+200,z+200));
688 // Handle(AIS_Shape) AISBox = new AIS_Shape(box);
689 // AISBox->SetColor(Quantity_NOC_BLUE1);
690 // myAISContext->Display(AISBox);
692 DBRep::Set("Box",box.Shape());
694 // BRepAlgoAPI_Cut cut( sol1_, box.Shape() );
695 // //BRepAlgoAPI_Cut cut( box.Shape(), sol1_ );
696 // TopoDS_Shape sh1_ = cut.Shape();
697 // Handle(AIS_Shape) AISCut = new AIS_Shape(sh1_);
698 // AISCut->SetColor(Quantity_NOC_RED);
699 // myAISContext->Display(AISCut);
701 // DBRep::Set("Cut",sh1_);
706 #include<GProp_GProps.hxx>
707 #include<BRepGProp.hxx>
709 static Standard_Integer OCC305 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
714 di <<"Usage : " << argv[0] << " file"<<"\n";
717 Standard_CString file = argv[1];
719 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
720 if(myAISContext.IsNull()) {
721 di << "use 'vinit' command before " << argv[0] << "\n";
726 BRep_Builder builder;
727 //BRepTools::Read(sh, "/dn02/users_SUN/inv/3/OCC305/testc.brep", builder);
728 BRepTools::Read(sh, file, builder);
731 builder.MakeWire(wire);
733 TopoDS_Vertex vt1, vt2;
734 TopExp_Explorer wex(sh, TopAbs_EDGE);
735 for(;wex.More();wex.Next())
737 ed = TopoDS::Edge(wex.Current());
738 TopExp::Vertices(ed, vt1, vt2);
739 builder.UpdateVertex(vt1, 0.01);
740 builder.UpdateVertex(vt2, 0.01);
741 builder.UpdateEdge(ed, 0.01);
742 builder.Add(wire, ed);
746 BRepGProp::LinearProperties(ed, lprop);
747 printf("\n length = %f", lprop.Mass());
749 DBRep::Set("Wire",wire);
750 // Handle(AIS_Shape) res = new AIS_Shape( wire );
751 // aContext->SetColor( res, Quantity_NOC_RED );
752 // aContext->Display( res );
754 // BRepOffsetAPI_MakeOffset off(wire, GeomAbs_Arc);
755 // off.Perform(0.5, 0);
757 // printf("\n IsDone = %d", off.IsDone());
759 // res = new AIS_Shape( sh );
760 // aContext->SetColor( res, Quantity_NOC_GREEN );
761 // aContext->Display( res );
767 static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
770 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
771 if(myAISContext.IsNull()) {
772 di << "use 'vinit' command before " << argv[0];
776 BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
777 Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape());
778 myAISContext->Display(anAISBox, 1);
779 anAISBox->SetSelectionMode(-1);
780 Standard_Integer myLocContInd = myAISContext->OpenLocalContext();
781 myAISContext->CloseLocalContext(myLocContInd);
782 Standard_Integer aSelMode = ((Handle(AIS_InteractiveObject)) anAISBox)->SelectionMode();
789 #include <TDocStd_Document.hxx>
790 #include <DDocStd.hxx>
791 #include <PCDM_StoreStatus.hxx>
792 #include <TDocStd_Application.hxx>
794 static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
797 di << "Usage: " << a[0] << " Doc" << "\n";
801 Handle(TDocStd_Document) D;
802 if (!DDocStd::GetDocument(a[1],D)) return 1;
804 Handle(TDocStd_Application) A;
805 if (!DDocStd::Find(A)) return 1;
807 TCollection_ExtendedString theStatusMessage;
809 di << "this document has never been saved" << "\n";
812 PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
813 if (theStatus != PCDM_SS_OK ) {
814 switch ( theStatus ) {
815 case PCDM_SS_DriverFailure: {
816 di << " Could not store , no driver found to make it " <<"\n" ;
819 case PCDM_SS_WriteFailure: {
820 di << " Write access failure " << "\n" ;
823 case PCDM_SS_Failure: {
824 di << " Write failure " << "\n" ;
832 static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
835 di << "Usage: " << a[0] << " Doc Path" << "\n";
839 Handle(TDocStd_Document) D;
840 if (!DDocStd::GetDocument(a[1],D)) return 1;
842 TCollection_ExtendedString path (a[2]);
843 Handle(TDocStd_Application) A;
844 if (!DDocStd::Find(A)) return 1;
846 TCollection_ExtendedString theStatusMessage;
847 PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
848 if (theStatus != PCDM_SS_OK ) {
849 switch ( theStatus ) {
850 case PCDM_SS_DriverFailure: {
851 di << " Could not store , no driver found to make it " <<"\n" ;
854 case PCDM_SS_WriteFailure: {
855 di << " Write access failure " << "\n" ;
858 case PCDM_SS_Failure: {
859 di << " Write failure " << "\n" ;
868 #include <BRepClass3d_SolidClassifier.hxx>
870 Standard_Integer OCC299bug (Draw_Interpretor& di,
877 di << "Usage : " << a[0] << " Solid Point [Tolerance=1.e-7]" << "\n";
881 TopoDS_Shape aS = DBRep::Get(a[1]);
883 sprintf(sbf, " Null Shape is not allowed here\n");
888 if (aS.ShapeType()!=TopAbs_SOLID) {
889 sprintf(sbf, " Shape type must be SOLID\n");
894 Standard_Real aTol=1.e-7;
895 TCollection_AsciiString sIN("IN"), sOUT("OUT of"), sON("ON"), sUNKNOWN("UNKNOWN");
896 TopAbs_State aState = TopAbs_UNKNOWN;
897 gp_Pnt aP(8., 9., 10.);
899 if (!DrawTrSurf::GetPoint(a[2], aP) ) {
900 sprintf(sbf, " Null Point is not allowed here\n");
910 BRepClass3d_SolidClassifier aSC(aS);
911 aSC.Perform(aP,aTol);
913 aState = aSC.State();
915 sprintf(sbf, "The point is "); di<<sbf;
919 sprintf(sbf, sIN.ToCString());
922 sprintf(sbf, sOUT.ToCString());
925 sprintf(sbf, sON.ToCString());
928 sprintf(sbf, sUNKNOWN.ToCString());
931 sprintf(sbf, sUNKNOWN.ToCString());
936 sprintf(sbf, " shape\n");
942 #include <OSD_Process.hxx>
943 #include <OSD_Path.hxx>
945 static Standard_Integer OCC309bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
948 di << "Usage: " << a[0] << "\n";
952 OSD_Path d = p.CurrentDirectory();
953 TCollection_AsciiString s;
955 di << "*" << s.ToCString() << "*" << "\n";
958 di << "*" << s.ToCString() << "*" <<"\n";
962 static Standard_Integer OCC310bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
965 di << "Usage: " << a[0] << "\n";
968 OSD_Path p("/where/you/want/tmp/qwerty/tmp/");
969 di << p.Trek().ToCString() << "\n";
971 di << p.Trek().ToCString() << "\n";
975 #include <BRepAlgoAPI_Fuse.hxx>
976 #include <BRepAlgoAPI_Common.hxx>
977 #include <BRepAlgo_Fuse.hxx>
978 #include <BRepAlgo_Common.hxx>
980 static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
983 // cout << "Usage: " << a[0] << endl;
986 if(nb < 1 || nb > 2) {
987 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
990 Standard_Boolean IsBRepAlgoAPI = Standard_True;
992 Standard_Integer IsB = atoi(a[1]);
994 IsBRepAlgoAPI = Standard_False;
998 BRepPrimAPI_MakeBox box1( 100, 100, 100 );
999 BRepPrimAPI_MakeBox box2( gp_Pnt( 50, 50,50 ), 200, 200, 200 );
1001 TopoDS_Shape shape1 = box1.Shape();
1002 TopoDS_Shape shape2 = box2.Shape();
1004 //#if ! defined(BRepAlgoAPI_def01)
1005 // TopoDS_Shape fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
1006 // TopoDS_Shape comm = BRepAlgoAPI_Common( shape1, shape2 );
1008 // TopoDS_Shape fuse = BRepAlgo_Fuse( shape1, shape2 );
1009 // TopoDS_Shape comm = BRepAlgo_Common( shape1, shape2 );
1011 TopoDS_Shape fuse,comm;
1012 if (IsBRepAlgoAPI) {
1013 di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )" <<"\n";
1014 di << "comm = BRepAlgoAPI_Common( shape1, shape2 )" <<"\n";
1015 fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
1016 comm = BRepAlgoAPI_Common( shape1, shape2 );
1018 di << "fuse = BRepAlgo_Fuse( shape1, shape2 )" <<"\n";
1019 fuse = BRepAlgo_Fuse( shape1, shape2 );
1020 di << "comm = BRepAlgo_Common( shape1, shape2 )" <<"\n";
1021 comm = BRepAlgo_Common( shape1, shape2 );
1027 #include <ShapeAnalysis_Edge.hxx>
1029 static Standard_Integer OCC333bug (Draw_Interpretor& di, Standard_Integer n, const char ** a)
1033 di << "Usage: " << a[0] << " edge1 edge2 [toler domaindist]" << "\n";
1036 TopoDS_Shape Sh1 = DBRep::Get(a[1]);
1037 TopoDS_Shape Sh2 = DBRep::Get(a[2]);
1038 if(Sh1.IsNull() || Sh2.IsNull()) {
1040 di<<"Invalid arguments"<<"\n";
1043 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
1044 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
1045 if(e1.IsNull() || e2.IsNull()) {
1047 di<<"Invalid type of arguments"<<"\n";
1050 Standard_Real aTol = Precision::Confusion();
1051 Standard_Real aDistDomain = 0.0;
1052 Standard_Integer k = 3;
1054 aTol = atof(a[k++]);
1056 aDistDomain = atof(a[k++]);
1058 ShapeAnalysis_Edge sae;
1059 if(sae.CheckOverlapping(e1,e2,aTol,aDistDomain)) {
1060 if(aDistDomain ==0.0) {
1062 di<<"Edges is overlaping comletly"<<"\n";
1065 di<<"Edges is overlaped"<<"\n";
1066 di<<"with tolerance = "<<aTol<<"\n";
1067 di<<"on segment length = "<<aDistDomain<<"\n";
1071 di<<"Edges is not overlaped"<<"\n";
1077 #include <DDocStd_DrawDocument.hxx>
1078 #include <TDataStd_Name.hxx>
1080 #include <XCAFDoc_ShapeTool.hxx>
1081 #include <XCAFDoc_DocumentTool.hxx>
1082 #include <TDF_LabelSequence.hxx>
1083 #include <TPrsStd_AISPresentation.hxx>
1084 #include <TDF_Data.hxx>
1085 #include <TDF_Label.hxx>
1086 #include <XCAFPrs_Driver.hxx>
1088 //------------------------------------------------------------------------------------------
1091 //------------------------------------------------------------------------------------------
1092 static Standard_Integer OCC363 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1097 // 1. Verufy amount of arguments
1098 if(argc < 3) { di <<"Error OCC363 : Use : OCC363 document filename\n"; return 1; }
1100 // 2. Retrieve DDocStd application
1101 Handle(TDocStd_Application) App;
1102 if (!DDocStd::Find(App)) { di << "Error OCC363 : There is no current DDocStd application\n";return 1;}
1105 TCollection_ExtendedString name(argv[2]);
1106 Handle(TDocStd_Document) Doc;
1107 if(App->Open(name, Doc) != PCDM_RS_OK) { di << "Error OCC363 : document was not opened successfully\n"; return 1;}
1108 Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(Doc);
1109 TDataStd_Name::Set(Doc->GetData()->Root(),argv[1]);
1110 Draw::Set(argv[1],DD);
1112 // 4. Create prsentations
1113 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1114 TDF_LabelSequence seq;
1115 shapes->GetFreeShapes ( seq );
1116 Handle(TPrsStd_AISPresentation) prs;
1117 for ( Standard_Integer i=1; i <= seq.Length(); i++ )
1118 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) )
1119 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
1121 catch(Standard_Failure) { di << "FAULTY OCC363 : Exception during reading document.\n";return 0;}
1123 di << "OCC363 OK\n";
1128 ////======================================================================================
1129 //// Function : OCC372
1131 ////======================================================================================
1132 //static Standard_Integer OCC372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1136 // OCC_CATCH_SIGNALS
1137 // // 1. Verufy amount of arguments
1138 // if(argc < 2) {di << "OCC372 FAULTY. Use : OCC372 brep-file";return 0;}
1142 // TopoDS_Shape Ref;
1143 // BRepTools::Read(Ref, argv[1], B);
1145 // // 3. Calculate location of aP3d in relation to the solid
1146 // gp_Pnt aP3d(6311.4862583184, -2841.3092756034, 16.461053497188);
1147 // BRepClass3d_SolidClassifier SC(Ref);
1148 // SC.Perform(aP3d, 1e-7);
1150 // // 4. Check returned state. The point must be inside the solid.
1151 // TopAbs_State aState=SC.State();
1155 // di<<"OCC372 FAULTY. aState = TopAbs_OUT";
1158 // di<<"OCC372 FAULTY. aState = TopAbs_ON";
1161 // di<<"OCC372 OK. aState = TopAbs_IN" ;
1164 // di<<"OCC372 FAULTY. aState = UNKNOWN";
1168 // catch (Standard_Failure) { di<<"OCC372 FAULTY. Exception raised"; }
1173 #include <BRepTopAdaptor_FClass2d.hxx>
1175 //======================================================================================
1176 // Function : OCC377
1178 //======================================================================================
1179 static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1184 // 1. Verify validity of arguments
1185 if ( argc < 1 ) {di << "Error OCC377. Use OCC377 file x y precuv \n";return 0;}
1187 // 2. Initialize parameters
1189 p2d.SetX ( atof(argv[2]) );
1190 p2d.SetY ( atof(argv[3]) );
1191 Standard_Real precuv = atof (argv[4] );
1196 BRepTools::Read ( Shape, argv[1], B );
1198 // 4. Verify whether enrtry point is on wire and reversed ones (indeed results of veridying must be same)
1199 TopExp_Explorer exp;
1200 Standard_Integer i=1;
1201 for (exp.Init(Shape.Oriented(TopAbs_FORWARD),TopAbs_WIRE); exp.More(); exp.Next(), i++)
1203 // 4.1. Verify whether enrtry point is on wire
1204 const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
1205 TopoDS_Face newFace = TopoDS::Face(Shape.EmptyCopied());
1207 TopAbs_Orientation orWire = wir.Orientation();
1208 newFace.Orientation(TopAbs_FORWARD);
1211 BRepTopAdaptor_FClass2d FClass2d1(newFace,precuv);
1212 TopAbs_State stat1 = FClass2d1.PerformInfinitePoint();
1213 //di << "Wire " << i << ": Infinite point is " <<
1214 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1216 TCollection_AsciiString TmpString;
1217 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1218 di << "Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1220 stat1 = FClass2d1.Perform(p2d);
1221 //di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1222 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1225 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1226 di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1228 // 4.2. Verify whether enrtry point is on reversed wire
1229 newFace = TopoDS::Face(Shape.EmptyCopied());
1230 newFace.Orientation(TopAbs_FORWARD);
1231 orWire = TopAbs::Reverse(orWire);
1232 B.Add(newFace,wir.Oriented(orWire));
1233 BRepTopAdaptor_FClass2d FClass2d2(newFace,precuv);
1234 TopAbs_State stat2 = FClass2d2.PerformInfinitePoint();
1235 //di << "Reversed Wire " << i << ": Infinite point is " <<
1236 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1239 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1240 di << "Reversed Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1242 stat2 = FClass2d2.Perform(p2d);
1243 //di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1244 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1247 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1248 di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1250 // 4.3. Compare results (they must be same)
1251 if(stat1 ==stat2) di << "OCC377 OK" << "\n";
1252 else {di << "OCC377 FAULTY" << "\n"; return 0;}
1255 catch(Standard_Failure)
1257 di << "OCC377 Exception";
1263 #include <ShapeUpgrade_ShapeDivideAngle.hxx>
1264 #include <ShapeBuild_ReShape.hxx>
1266 //=======================================================================
1269 //=======================================================================
1270 static Standard_Integer OCC22 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1275 // 1. Verify arguments of the command
1276 if (argc < 5) { di << "OCC22 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation"; return 0;}
1278 Standard_Boolean aConsiderLocation;
1279 if(strcmp(argv[4], "0")==0) aConsiderLocation = Standard_False;
1280 else aConsiderLocation = Standard_True;
1282 // 2. Iniitialize aShapeUpgrade
1283 ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(PI/2.);
1285 aShapeUpgrade.SetPrecision (Precision::Confusion());
1287 aShapeUpgrade.SetMaxTolerance(0.1);
1288 // subshapes to be divided
1289 TopoDS_Shape aSubShapesToBeDivided = DBRep::Get(argv[3]);
1290 if(aSubShapesToBeDivided.IsNull()) {di << "OCC22 FAULTY. Compound of subshapes to be divided is not exist. Please, verify input values. \n";return 0;}
1291 aShapeUpgrade.Init(aSubShapesToBeDivided);
1293 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1294 aShapeUpgrade.SetContext(aReshape);
1295 if(aConsiderLocation) aReshape->ModeConsiderLocation() = Standard_True;
1297 // 3. Perform splitting
1298 if (aShapeUpgrade.Perform (Standard_False)) di << "Upgrade_SplitRevolution_Done \n";
1299 else if (aShapeUpgrade.Status (ShapeExtend_OK)) di << "Upgrade_SplitRevolution_OK \n";
1300 else if (aShapeUpgrade.Status (ShapeExtend_FAIL)) { di << "OCC22 FAULTY. Operation failed. Angle was not divided\n";return 0;}
1302 // 4. Perform rebuilding shape
1303 // 4.1. Retrieve Shape
1304 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1305 if(anInitShape.IsNull()) { di << "OCC22 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1306 // 4.2 Rebuid retrieved shape
1307 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1308 // 4.3. Create result Draw shape
1309 DBRep::Set(argv[1], aResultShape);
1311 catch (Standard_Failure) {di << "OCC22 Exception \n" ;return 0;}
1317 #include <ShapeProcess_OperLibrary.hxx>
1318 #include <ShapeProcess_ShapeContext.hxx>
1319 #include <ShapeProcess.hxx>
1321 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
1322 #include <BRepMesh_IncrementalMesh.hxx>
1324 //=======================================================================
1327 //=======================================================================
1328 static Standard_Integer OCC24 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1333 // 1. Verify amount of arguments of the command
1334 if (argc < 6) { di << "OCC24 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapes ResourceFileName SequenceName"; return 0;}
1336 // 2. Retrieve parameters
1338 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1339 if(anInitShape.IsNull()) { di << "OCC24 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1340 // compound of subshapes
1341 TopoDS_Shape aSubShapes = DBRep::Get(argv[3]);
1342 if(aSubShapes.IsNull()) {di << "OCC24 FAULTY. Compound of subshapes is not exist. Please, verify input values. \n";return 0;}
1343 // name of resource file
1344 const char* aResourceFile = argv[4];
1345 // name of sequence from resource file to be executed
1346 const char* aSequenceName = argv[5];
1348 // 3. Initialize ShapeContext and perform sequence of operation specified with resource file
1349 ShapeProcess_OperLibrary::Init();
1350 Handle(ShapeProcess_ShapeContext) aShapeContext = new ShapeProcess_ShapeContext (aSubShapes, aResourceFile);
1351 aShapeContext->SetDetalisation (TopAbs_EDGE);
1352 ShapeProcess::Perform (aShapeContext, aSequenceName);
1354 // 4. Rebuild initil shape in accordance with performed operation
1355 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1356 TopTools_DataMapIteratorOfDataMapOfShapeShape anIter (aShapeContext->Map());
1357 for (; anIter.More(); anIter.Next())
1358 aReshape->Replace(anIter.Key(), anIter.Value());
1359 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1361 // 5 Create resultant Draw shape
1362 DBRep::Set(argv[1], aResultShape);
1365 catch (Standard_Failure) {di << "OCC24 Exception \n" ;return 0;}
1370 //=======================================================================
1372 //purpose : Verify whether exception occurs during building mesh
1373 //=======================================================================
1374 static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1379 // 1. Verify amount of arguments of the command
1380 if (argc < 2) { di << "OCC369 FAULTY. Use : OCC369 Shape \n"; return 0;}
1382 // 2. Retrieve shape
1383 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1384 if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
1387 BRepMesh_IncrementalMesh aMesh(aShape, 0.2, Standard_True, PI/6);
1390 catch (Standard_Failure) {di << "OCC369 Exception \n" ;return 0;}
1392 di << "OCC369 OK \n";
1396 #include <math_Vector.hxx>
1397 #include <math_Matrix.hxx>
1398 static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1401 di<<"Usage : " << argv[0] << " LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix\n";
1404 Standard_Integer LowerVector = atoi(argv[1]);
1405 Standard_Integer UpperVector = atoi(argv[2]);
1406 Standard_Real InitialValueVector = atof(argv[3]);
1407 Standard_Integer LowerRowMatrix = atoi(argv[4]);
1408 Standard_Integer UpperRowMatrix = atoi(argv[5]);
1409 Standard_Integer LowerColMatrix = atoi(argv[6]);
1410 Standard_Integer UpperColMatrix = atoi(argv[7]);
1411 Standard_Real InitialValueMatrix = atof(argv[8]);
1413 math_Vector Vector1(LowerVector, UpperVector);
1414 math_Vector Vector2(LowerVector, UpperVector);
1416 math_Vector Vector(LowerVector, UpperVector, InitialValueVector);
1417 math_Matrix Matrix(LowerRowMatrix, UpperRowMatrix, LowerColMatrix, UpperColMatrix, InitialValueMatrix);
1419 //Vector.Dump(cout);
1422 //Matrix.Dump(cout);
1425 Vector1.Multiply(Vector, Matrix);
1427 //Vector1.Dump(cout);
1428 Standard_SStream aSStream1;
1429 Vector1.Dump(aSStream1);
1433 Vector2.TMultiply(Vector, Matrix);
1435 //Vector2.Dump(cout);
1436 Standard_SStream aSStream2;
1437 Vector2.Dump(aSStream2);
1444 #include <GeomPlate_BuildPlateSurface.hxx>
1445 //=======================================================================
1448 //=======================================================================
1449 static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
1454 GeomPlate_BuildPlateSurface aBuilder;
1457 catch (Standard_RangeError) { di << "OCC525 Exception \n" ;return 0; }
1458 //catch (...) { di << "OCC525 Exception \n" ;return 0; }
1460 di << "OCC525 OK \n";
1464 #include <Viewer2dTest.hxx>
1465 #include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
1467 #include <AIS2D_InteractiveContext.hxx>
1468 #include <V2d_View.hxx>
1469 #include <AIS2D_InteractiveObject.hxx>
1470 #include <TColStd_HSequenceOfInteger.hxx>
1473 extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1475 Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1478 //=======================================================================
1481 //=======================================================================
1482 static Standard_Integer OCC543 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1484 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1485 if(aContext.IsNull()) {
1486 di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
1490 di<<"Usage : " << argv[0] << " name\n";
1493 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1495 TCollection_AsciiString name = argv[1];
1497 if (!GetMapOfAIS2D().IsBound2(name)) {
1498 // di << "There is not an object with name " << name.ToCString() << "\n";
1502 Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name);
1503 Standard_Integer PickedIndex = aShape->PickedIndex();
1504 di << "PickedIndex = " << PickedIndex << "\n";
1508 #include <BRepPrimAPI_MakeWedge.hxx>
1509 #include <gce_MakeRotation.hxx>
1510 #include <gce_MakeTranslation.hxx>
1511 #include <BRepBuilderAPI_Transform.hxx>
1512 #include <BRepPrimAPI_MakeWedge.hxx>
1513 #include <BRepAlgoAPI_Fuse.hxx>
1514 #include <BRepAlgoAPI_Cut.hxx>
1515 #include <BRepAlgo_Fuse.hxx>
1516 #include <BRepAlgo_Cut.hxx>
1517 //=======================================================================
1520 //=======================================================================
1521 static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1524 // di<<"Usage : " << argv[0] << " shape1 shape2 shape3\n";
1527 if(argc < 4 || argc > 5) {
1528 di << "Usage : " << argv[0] << " shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1531 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1533 Standard_Integer IsB = atoi(argv[4]);
1535 IsBRepAlgoAPI = Standard_False;
1536 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1538 // di << "Error: There is not BRepAlgo_Cut class" << "\n";
1544 double xperiod = 1.0;
1545 double yperiod = 1.0;
1546 double sub_thick = 0.5;
1549 //TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick );
1550 TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick ).Shape();
1552 // --------------------------------------------------------------------
1555 //TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1556 // 0.1, 0.1 , 0.4, 0.4 );
1557 TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1558 0.1, 0.1 , 0.4, 0.4 ).Shape();
1560 gp_Trsf rotate = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1561 gp_Dir(1.0,0.0,0.0),
1564 gp_Trsf translate = gce_MakeTranslation(gp_Pnt( 0.0, -0.5, 0.0),
1565 gp_Pnt( 0.25, 0.25, 0.5)
1568 rotate.PreMultiply( translate );
1570 TopoDS_Shape wedge1a = BRepBuilderAPI_Transform( wedge1, rotate );
1572 if (wedge1a.IsNull()) {
1573 di<<" Null shape1 is not allowed\n";
1576 DBRep::Set(argv[1], wedge1a);
1578 // --------------------------------------------------------------------
1581 //TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1582 // 0.1, 0.1 , 0.4, 0.4 );
1583 TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1584 0.1, 0.1 , 0.4, 0.4 ).Shape();
1586 gp_Trsf rotate2 = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1587 gp_Dir(1.0,0.0,0.0),
1590 gp_Trsf translate2 = gce_MakeTranslation(gp_Pnt( 0.0, 0.0, 0.0),
1591 gp_Pnt( 0.25, 0.25, 0.5)
1594 rotate2.PreMultiply( translate2 );
1596 TopoDS_Shape wedge2a = BRepBuilderAPI_Transform( wedge2, rotate2 );
1598 if (wedge2a.IsNull()) {
1599 di<<" Null shape2 is not allowed\n";
1602 DBRep::Set(argv[2], wedge2a);
1606 //#if ! defined(BRepAlgoAPI_def01)
1607 // TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1609 // TopoDS_Shape wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1611 TopoDS_Shape wedge_common;
1612 if (IsBRepAlgoAPI) {
1613 di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)" <<"\n";
1614 wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1616 di << "wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a)" <<"\n";
1617 wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1620 // remove wedge area from substrate
1621 //#if ! defined(BRepAlgoAPI_def01)
1622 // TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1624 // TopoDS_Shape sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1626 TopoDS_Shape sub_etch1;
1627 if (IsBRepAlgoAPI) {
1628 di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)" <<"\n";
1629 sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1631 di << "sub_etch1 = BRepAlgo_Cut(substrate, wedge_common)" <<"\n";
1632 sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1635 if (sub_etch1.IsNull()) {
1636 di<<" Null shape3 is not allowed\n";
1639 DBRep::Set(argv[3], sub_etch1);
1644 #include <Graphic2d_DisplayList.hxx>
1645 #include <Graphic2d_View.hxx>
1647 //=======================================================================
1650 //=======================================================================
1651 static Standard_Integer OCC627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1653 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1654 if(aContext.IsNull()) {
1655 di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
1659 di<<"Usage : " << argv[0] << "\n";
1663 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1664 Handle(Graphic2d_View) View = V->View();
1665 Handle(Graphic2d_DisplayList) DisplayList = View->DisplayList();
1666 Standard_Integer Length = DisplayList->Length();
1667 di << "Length = " << Length << "\n";
1672 #include <QAOCC_OCC749Prs.hxx>
1673 //=======================================================================
1674 //function : OCC749_sav
1676 //=======================================================================
1677 static Standard_Integer OCC749_sav (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1680 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1681 if(myAISContext.IsNull()) {
1682 di << "use 'vinit' command before " << argv[0];
1686 di << "Usage : " << argv[0] << " Reflection(=0/1) R1 G1 B1 R2 G2 B2" << "\n";
1690 Standard_Integer IntegerReflection = atoi(argv[1]);
1691 Standard_Boolean Reflection;
1692 if (IntegerReflection == 0) {
1693 Reflection = Standard_False;
1695 Reflection = Standard_True;
1697 Standard_Integer R1_Integer = atoi(argv[2]);
1698 Standard_Integer G1_Integer = atoi(argv[3]);
1699 Standard_Integer B1_Integer = atoi(argv[4]);
1700 Standard_Integer R2_Integer = atoi(argv[5]);
1701 Standard_Integer G2_Integer = atoi(argv[6]);
1702 Standard_Integer B2_Integer = atoi(argv[7]);
1703 Quantity_Parameter R1 = R1_Integer / 255.;
1704 Quantity_Parameter G1 = G1_Integer / 255.;
1705 Quantity_Parameter B1 = B1_Integer / 255.;
1706 Quantity_Parameter R2 = R2_Integer / 255.;
1707 Quantity_Parameter G2 = G2_Integer / 255.;
1708 Quantity_Parameter B2 = B2_Integer / 255.;
1710 Handle(QAOCC_OCC749Prs) anIntearactiveObject =
1711 new QAOCC_OCC749Prs(Reflection,
1712 Quantity_Color(R1, G1, B1, Quantity_TOC_RGB),
1713 Quantity_Color(R2, G2, B2, Quantity_TOC_RGB));
1714 myAISContext->Display(anIntearactiveObject);
1718 #include <Standard_GUID.hxx>
1719 //=======================================================================
1722 //=======================================================================
1723 static Standard_Integer OCC669 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1726 di<<"Usage : " << argv[0] << " GUID\n";
1729 Standard_GUID guid(argv[1]);
1730 //guid.ShallowDump(cout);
1731 Standard_SStream aSStream;
1732 guid.ShallowDump(aSStream);
1738 #include <XCAFDoc.hxx>
1739 //=======================================================================
1740 //function : OCC738_ShapeRef
1742 //=======================================================================
1743 static Standard_Integer OCC738_ShapeRef (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1746 di<<"Usage : " << argv[0] << "\n";
1749 const Standard_GUID& guid = XCAFDoc::ShapeRefGUID ();
1750 //guid.ShallowDump(cout);
1751 Standard_SStream aSStream;
1752 guid.ShallowDump(aSStream);
1757 //=======================================================================
1758 //function : OCC738_Assembly
1760 //=======================================================================
1761 static Standard_Integer OCC738_Assembly (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1764 di<<"Usage : " << argv[0] << "\n";
1767 const Standard_GUID& guid = XCAFDoc::AssemblyGUID ();
1768 //guid.ShallowDump(cout);
1769 Standard_SStream aSStream;
1770 guid.ShallowDump(aSStream);
1775 #if defined(DDataStd_def01)
1776 #include <DDataStd_DrawPresentation.hxx>
1777 //=======================================================================
1778 //function : OCC739_DrawPresentation
1780 //=======================================================================
1781 static Standard_Integer OCC739_DrawPresentation (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1784 di<<"Usage : " << argv[0] << "\n";
1787 const Standard_GUID& guid = DDataStd_DrawPresentation::GetID() ;
1788 //guid.ShallowDump(cout);
1789 Standard_SStream aSStream;
1790 guid.ShallowDump(aSStream);
1796 //=======================================================================
1799 //=======================================================================
1800 static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1802 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1803 if(aContext.IsNull()) {
1804 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
1809 di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation" << "\n";
1813 Standard_Boolean updateviewer = Standard_True, PutInCollector = Standard_True;
1815 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1817 TCollection_AsciiString aName(argv[1]);
1818 Handle(AIS_InteractiveObject) AISObj;
1820 if(!aMap.IsBound2(aName)) {
1821 di << "Use 'vdisplay' before" << "\n";
1824 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
1825 if(AISObj.IsNull()){
1826 di << argv[1] << " : No interactive object" << "\n";
1829 AISObj->UnsetTransformation();
1830 if (!aContext->HasOpenedContext()) {
1831 aContext->OpenLocalContext();
1833 aContext->Erase(AISObj, updateviewer, PutInCollector);
1834 aContext->UpdateCurrentViewer();
1835 aContext->Display(AISObj, updateviewer);
1836 aContext->UpdateCurrentViewer();
1841 //=======================================================================
1844 //=======================================================================
1845 #include <TColStd_Array2OfInteger.hxx>
1846 static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1849 di<<"Usage : " << argv[0] << "\n";
1852 TColStd_Array2OfInteger Array2OfInteger(1,1,1,1);
1853 Array2OfInteger.SetValue(5,5,55);
1857 #include <GeomAPI_ProjectPointOnSurf.hxx>
1858 //=======================================================================
1861 //=======================================================================
1862 static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1866 di<<"Usage : " << argv[0] << " Point Surface Umin Usup Vmin Vsup \n";
1871 DrawTrSurf::GetPoint(argv[1],aPoint3d);
1872 Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
1873 Standard_Real Umin=atof(argv[3]);
1874 Standard_Real Usup=atof(argv[4]);
1875 Standard_Real Vmin=atof(argv[5]);
1876 Standard_Real Vsup=atof(argv[6]);
1878 if (aSurface.IsNull()) {
1879 di << argv[2] << " Null surface \n" ;
1883 GeomAPI_ProjectPointOnSurf PonSurf;
1884 PonSurf.Init(aSurface, Umin, Usup, Vmin, Vsup);
1885 PonSurf.Perform(aPoint3d);
1890 //=======================================================================
1893 //=======================================================================
1894 static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1898 di<<"Usage : " << argv[0] << " wire face\n";
1902 TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
1903 TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
1904 if (awire.IsNull() || aface.IsNull()) {
1905 di << "Null object" << "\n";
1909 Standard_Integer count = 0;
1910 TopExp_Explorer TE(awire, TopAbs_VERTEX);
1912 BRepTools_WireExplorer WE;
1913 for ( WE.Init(awire,aface); WE.More(); WE.Next()) {
1914 TopoDS_Edge E = WE.Current();
1918 di << "Count = " << count << "\n";
1923 //=======================================================================
1926 //=======================================================================
1927 static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1931 di <<"Usage : " << argv[0] << " face"<<"\n";
1934 Standard_Real u1, u2, v1, v2;
1935 TopoDS_Face F = TopoDS::Face( DBRep::Get(argv[1]) ); //read the shape
1938 BRepTools::UVBounds(F, u1, u2, v1, v2);
1939 di << "Bounds: " << u1 << " " << u2 << " " << v1 << " " << v2 << "\n";
1943 #include <Expr_NamedUnknown.hxx>
1944 #include <Expr_GeneralExpression.hxx>
1945 #include <Expr_Exponential.hxx>
1946 //=======================================================================
1949 //=======================================================================
1950 static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1954 di <<"Usage : " << argv[0] << " expression"<<"\n";
1958 TCollection_AsciiString myStr(argv[1]);
1960 Handle (Expr_NamedUnknown) myNamed = new Expr_NamedUnknown(myStr);
1961 Handle (Expr_Exponential) oldExpr = new Expr_Exponential(myNamed);
1962 Handle (Expr_GeneralExpression) newExpr = oldExpr->Derivative(myNamed);
1965 TCollection_AsciiString res = newExpr->String();
1966 Standard_CString resStr = res.ToCString();
1967 TCollection_AsciiString res_old = oldExpr->String();
1968 Standard_CString res_oldStr = res_old.ToCString();
1971 di << "X = " << argv[1] << "\n";
1972 di << "Y = " << res_oldStr << "\n";
1973 di << "Y' = " << resStr << "\n";
1979 #include <TPrsStd_AISViewer.hxx>
1980 #include <TDF_Label.hxx>
1981 #include <TPrsStd_AISPresentation.hxx>
1982 //=======================================================================
1983 //function : OCC1029_AISTransparency
1984 //purpose : OCC1029_AISTransparency (DOC,entry,[real])
1985 //=======================================================================
1987 static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
1988 Standard_Integer nb,
1992 Handle(TDocStd_Document) D;
1993 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1995 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1997 Handle(TPrsStd_AISViewer) viewer;
1998 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2000 Handle(TPrsStd_AISPresentation) prs;
2001 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2003 prs->SetTransparency(atof(arg[3]));
2004 TPrsStd_AISViewer::Update(L);
2007 di << "Transparency = " << prs->Transparency() << "\n";
2012 di << arg[0] << " : Error" << "\n";
2016 //=======================================================================
2017 //function : OCC1030_AISColor
2018 //purpose : OCC1030_AISColor (DOC,entry,[color])
2019 //=======================================================================
2021 static Standard_Integer OCC1030_AISColor (Draw_Interpretor& di,
2022 Standard_Integer nb,
2026 Handle(TDocStd_Document) D;
2027 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2029 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2031 Handle(TPrsStd_AISViewer) viewer;
2032 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2034 Handle(TPrsStd_AISPresentation) prs;
2035 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2037 prs->SetColor((Quantity_NameOfColor)atoi(arg[3]));
2038 TPrsStd_AISViewer::Update(L);
2041 di << "Color = " << prs->Color() << "\n";
2045 di << arg[0] << " : Error" << "\n";
2049 //=======================================================================
2050 //function : OCC1031_AISMaterial
2051 //purpose : OCC1031_AISMaterial (DOC,entry,[material])
2052 //=======================================================================
2054 static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
2055 Standard_Integer nb,
2059 Handle(TDocStd_Document) D;
2060 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2062 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2064 Handle(TPrsStd_AISViewer) viewer;
2065 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2067 Handle(TPrsStd_AISPresentation) prs;
2068 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2070 prs->SetMaterial((Graphic3d_NameOfMaterial)atoi(arg[3]));
2071 TPrsStd_AISViewer::Update(L);
2074 di << "Material = " << prs->Material() << "\n";
2079 di << arg[0] << " : Error" << "\n";
2083 //=======================================================================
2084 //function : OCC1032_AISWidth
2085 //purpose : OCC1032_AISWidth (DOC,entry,[width])
2086 //=======================================================================
2088 static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
2089 Standard_Integer nb,
2093 Handle(TDocStd_Document) D;
2094 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2096 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2098 Handle(TPrsStd_AISViewer) viewer;
2099 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2101 Handle(TPrsStd_AISPresentation) prs;
2102 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2104 prs->SetWidth(atof(arg[3]));
2105 TPrsStd_AISViewer::Update(L);
2108 di << "Width = " << prs->Width() << "\n";
2113 di << arg[0] << " : Error" << "\n";
2117 //=======================================================================
2118 //function : OCC1033_AISMode
2119 //purpose : OCC1033_AISMode (DOC,entry,[mode])
2120 //=======================================================================
2122 static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
2123 Standard_Integer nb,
2127 Handle(TDocStd_Document) D;
2128 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2130 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2132 Handle(TPrsStd_AISViewer) viewer;
2133 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2135 Handle(TPrsStd_AISPresentation) prs;
2136 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2138 prs->SetMode(atoi(arg[3]));
2139 TPrsStd_AISViewer::Update(L);
2142 di << "Mode = " << prs->Mode() << "\n";
2147 di << arg[0] << " : Error" << "\n";
2151 //=======================================================================
2152 //function : OCC1034_AISSelectionMode
2153 //purpose : OCC1034_AISSelectionMode (DOC,entry,[selectionmode])
2154 //=======================================================================
2156 static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
2157 Standard_Integer nb,
2161 Handle(TDocStd_Document) D;
2162 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2164 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2166 Handle(TPrsStd_AISViewer) viewer;
2167 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2169 Handle(TPrsStd_AISPresentation) prs;
2170 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2172 prs->SetSelectionMode(atoi(arg[3]));
2173 TPrsStd_AISViewer::Update(L);
2176 di << "SelectionMode = " << prs->SelectionMode() << "\n";
2181 di << arg[0] << " : Error" << "\n";
2185 #include<BRepAlgoAPI_Cut.hxx>
2186 #include<BRepAlgo_Cut.hxx>
2187 //=======================================================================
2188 //function : OCC1487
2190 //=======================================================================
2191 static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2194 // cerr << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape" << endl;
2197 if(argc < 5 || argc > 6) {
2198 di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2201 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2203 Standard_Integer IsB = atoi(argv[5]);
2205 IsBRepAlgoAPI = Standard_False;
2206 // di << "Error: There is not BRepAlgo_Cut class" << "\n";
2211 Standard_Integer CaseNumber = atoi(argv[1]);
2213 //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
2214 gp_Dir myDir(1,0,0);
2215 gp_Pnt myPnt(0,-50,140);
2216 gp_Ax2 myAx2(myPnt, myDir);
2217 BRepPrimAPI_MakeCylinder o_mc1 (myAx2, 50,1000);
2219 TopoDS_Shape cyl1 = o_mc1.Shape();
2222 TopoDS_Shape o_cut_shape;
2223 if (CaseNumber == 1) {
2224 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(21.65064, -50.0, 127.5),gp_Dir(-sin(PI/3), 0.0, 0.5)), 5, 150);
2225 gp_Dir myDir_mc2(-sin(PI/3), 0.0, 0.5);
2226 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2227 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2228 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2230 cyl2 = o_mc2.Shape();
2231 //#if ! defined(BRepAlgoAPI_def01)
2232 // o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2234 // o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2236 if (IsBRepAlgoAPI) {
2237 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2238 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2240 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2241 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2244 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(978.34936, -50.0, 127.5),gp_Dir(sin(PI/3), 0.0, 0.5)), 5, 150);
2245 gp_Dir myDir_mc2(-sin(PI/3), 0.0, 0.5);
2246 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2247 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2248 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2250 cyl2 = o_mc2.Shape();
2251 //#if ! defined(BRepAlgoAPI_def01)
2252 // o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2254 // o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2256 if (IsBRepAlgoAPI) {
2257 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2258 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2260 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2261 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2265 DBRep::Set(argv[2],cyl1);
2266 DBRep::Set(argv[3],cyl2);
2267 DBRep::Set(argv[4],o_cut_shape);
2272 #include<TopTools_ListIteratorOfListOfShape.hxx>
2273 #include<BRepFilletAPI_MakeFillet.hxx>
2274 //=======================================================================
2275 //function : OCC1077
2277 //=======================================================================
2278 TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
2280 Standard_Real t3d = 1.e-4;
2281 Standard_Real t2d = 1.e-5;
2282 Standard_Real ta = 1.e-2;
2283 Standard_Real fl = 1.e-3;
2284 Standard_Real tapp_angle = 1.e-2;
2285 GeomAbs_Shape blend_cont = GeomAbs_C1;
2287 TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
2290 // Handle_TopOpeBRepBuild_HBuilder build = aBoolenaOperation.Builder();
2292 TopTools_ListIteratorOfListOfShape its;
2294 TopoDS_Compound result;
2296 B.MakeCompound(result);
2299 for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
2301 const TopoDS_Shape& cutsol = ex.Current();
2303 BRepFilletAPI_MakeFillet fill(cutsol);
2304 fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
2305 fill.SetContinuity(blend_cont, tapp_angle);
2307 // its = build->Section();
2309 its = aBoolenaOperation.SectionEdges();
2313 TopoDS_Edge E = TopoDS::Edge(its.Value());
2314 fill.Add(aRadius, E);
2321 B.Add(result, fill.Shape());
2325 B.Add(result, cutsol);
2331 TopoDS_Shape OCC1077_cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
2333 //return OCC1077_boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
2334 BRepAlgoAPI_Cut aCut(aShapeToCut, aTool);
2335 return OCC1077_boolbl(aCut,aRadius);
2338 //TopoDS_Shape OCC1077_common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
2340 // return OCC1077_boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
2343 TopoDS_Shape OCC1077_Bug()
2345 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10).Shape();
2346 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7).Shape();
2348 TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
2349 TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10),
2350 gp_Dir(0, 0, 1)), 3, 20).Shape();
2351 TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0),
2352 gp_Dir(1, 0, 0)), 3, 20).Shape();
2353 TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
2354 gp_Dir(0, 1, 0)), 3, 20).Shape();
2355 TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
2356 Handle_ShapeFix_Shape fixer = new ShapeFix_Shape(theTmp1);
2358 theTmp1 = fixer->Shape();
2359 TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
2360 fixer->Init(theTmp2);
2362 theTmp2 = fixer->Shape();
2363 TopoDS_Shape theResult = OCC1077_cut_blend(theTmp2,theCylinder3,0.7);
2364 fixer->Init(theResult);
2366 theResult = fixer->Shape();
2370 static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2372 if(argc < 1 || argc > 2) {
2373 di << "Usage : " << argv[0] << " result" << "\n";
2377 TopoDS_Shape S = OCC1077_Bug();
2378 DBRep::Set(argv[1],S);
2383 //////////////////////////////////////////////////////////////
2385 * Compute uniform distribution of points using GCPnts_UniformAbscissa
2387 //////////////////////////////////////////////////////////////
2388 static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2392 di << "Usage : " << argv[0] << " name shape step" << "\n";
2395 const char *name = argv[1];
2396 Adaptor3d_Curve *adapCurve=NULL;
2397 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
2398 if (!curve.IsNull())
2399 adapCurve = new GeomAdaptor_Curve(curve);
2402 TopoDS_Shape wire = DBRep::Get(argv[2]);
2403 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
2405 di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected"<<"\n";
2408 adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
2410 double step = atof(argv[3]);
2411 GCPnts_UniformAbscissa aUni(*adapCurve, step);
2415 di << argv[0] <<" : fail"<<"\n";
2420 int i, np = aUni.NbPoints();
2421 for (i=0; i < np; i++)
2423 double par = aUni.Parameter(i+1);
2424 gp_Pnt p = adapCurve->Value(par);
2425 char n[20], *pname=n;
2426 sprintf(n,"%s_%d",name,i+1);
2427 DrawTrSurf::Set(pname,p);
2436 static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2440 di << "Usage : " << argv[0] << " nb_of_vectors size" << "\n";
2444 Standard_Integer nb = atoi(argv[1]);
2445 Standard_Integer sz = atoi(argv[2]);
2446 Standard_Real val = 10;
2447 math_Vector **pv = new math_Vector *[nb];
2449 di<<"creating "<<nb<<" vectors "<<sz<<" elements each..."<<"\n";
2451 for (i=0; i < nb; i++) {
2452 pv[i] = new math_Vector (1, sz, val);
2453 if ((i % (nb/10)) == 0) {
2460 di<<"deleting them ..."<<"\n";
2461 for (i=0; i < nb; i++) {
2463 if ((i % (nb/10)) == 0) {
2476 static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2480 di << "Usage : " << argv[0] << " wire" << "\n";
2483 TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
2486 TopoDS_Wire wire = TopoDS::Wire(shape);
2487 // create curve parameterised by curvilinear distance
2488 BRepAdaptor_CompCurve curve(wire,Standard_True);
2489 Standard_Real length = curve.LastParameter();
2490 Standard_Real need_length = length/2;
2492 curve.D0(need_length,pnt);
2493 // create check_curve parameterised in a general way
2494 BRepAdaptor_CompCurve check_curve(wire);
2495 Standard_Real check_par =
2496 GCPnts_AbscissaPoint(check_curve, need_length, 0).Parameter();
2498 check_curve.D0(check_par,check_pnt);
2499 // check that points are coinsiding
2500 Standard_Real error_dist = pnt.Distance(check_pnt);
2501 if (error_dist > Precision::Confusion()) {
2502 //cout.precision(3);
2503 di<<"error_dist = "<<error_dist<<
2504 " ( "<<error_dist/need_length*100<<" %)"<<"\n";
2511 static char sarr[2000];
2513 static int StackOverflow(int i = -1)
2518 memcpy(arr,sarr,2000);
2520 int n = strlen(arr), s=0;
2522 s += StackOverflow(i-1);
2523 return i + s + StackOverflow(i-1);
2526 return i + StackOverflow(i-1);
2533 // this code does not work with optimize mode on Windows
2534 #pragma optimize( "", off )
2536 static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2540 di << "Usage : " << argv[0] << "\n";
2543 Standard_Boolean Succes;
2545 Succes = Standard_True;
2548 {//==== Test Divide ByZero (Integer) ========================================
2551 di << "(Integer) Divide By Zero...";
2554 Standard_Integer res, a =4, b = 0 ;
2556 di << " 4 / 0 = " << res << " Does not Caught... KO"<< "\n";
2557 Succes = Standard_False;
2559 #if defined(SOLARIS) || defined(WNT)
2560 catch(Standard_DivideByZero)
2562 catch(Standard_NumericError)
2567 catch(Standard_Failure) {
2568 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2570 di << Standard_Failure::Caught()->GetMessageString();
2571 di << ")... KO" << "\n";
2572 Succes = Standard_False;
2574 #ifndef NO_CXX_EXCEPTION
2575 // this case tests if (...) supersedes (Standard_*),
2576 // the normal behaviour is not
2578 di<<" unknown exception... (But) Ok"<<"\n";
2583 {//==== Test Divide ByZero (Real) ===========================================
2586 di << "(Real) Divide By Zero...";
2589 Standard_Real res, a= 4.0, b=0.0;
2591 di << " 4.0 / 0.0 = " << res << " Does not Caught... KO"<< "\n";
2592 Succes = Standard_False;
2594 #if defined(SOLARIS) || defined(WNT)
2595 catch(Standard_DivideByZero)
2597 catch(Standard_NumericError)
2602 catch(Standard_Failure) {
2603 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2605 di << Standard_Failure::Caught()->GetMessageString();
2606 di << ")... KO" << "\n";
2607 Succes = Standard_False;
2611 {//==== Test Overflow (Integer) =============================================
2614 di << "(Integer) Overflow...";
2617 Standard_Integer res, i=IntegerLast();
2619 //++++ cout << " -- "<<res<<"="<<i<<"+1 Does not Caught... KO"<< endl;
2620 //++++ Succes = Standard_False;
2621 di << " "<<res<<"="<<i<<"+1 Does not Caught... (But) Ok"<< "\n";
2623 catch(Standard_Overflow) {
2626 catch(Standard_Failure) {
2627 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2629 di << Standard_Failure::Caught()->GetMessageString();
2630 di << ")... KO" << "\n";
2631 Succes = Standard_False;
2635 {//==== Test Overflow (Real) ================================================
2638 di << "(Real) Overflow...";
2641 Standard_Real res, r=RealLast();
2644 sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
2646 di << "-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<< "\n";
2647 Succes = Standard_False;
2649 #if defined(SOLARIS) || defined(WNT)
2650 catch(Standard_Overflow)
2652 catch(Standard_NumericError)
2657 catch(Standard_Failure) {
2658 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2660 di << Standard_Failure::Caught()->GetMessageString();
2661 di << ")... KO" << "\n";
2662 Succes = Standard_False;
2666 {//==== Test Underflow (Real) ===============================================
2669 di << "(Real) Underflow";
2672 Standard_Real res, r=1.0e-308;
2675 //++++ cout<<"-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<<endl;
2676 //++++ Succes = Standard_False;
2677 di<<" -- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... (But) Ok"<<"\n";
2679 #if defined(SOLARIS) || defined(WNT)
2680 catch(Standard_Underflow)
2682 catch(Standard_NumericError)
2687 catch(Standard_Failure) {
2688 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2690 di << Standard_Failure::Caught()->GetMessageString();
2691 di << ")... KO" << "\n";
2692 Succes = Standard_False;
2696 {//==== Test Invalid Operation (Real) ===============================================
2699 di << "(Real) Invalid Operation...";
2702 Standard_Real res, r=-1;
2704 di<<" "<<res<<"=sqrt("<<r<<") Does not Caught... KO"<<"\n";
2705 Succes = Standard_False;
2707 catch(Standard_NumericError) {
2710 catch(Standard_Failure) {
2711 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2713 di << Standard_Failure::Caught()->GetMessageString();
2714 di << ")... KO" << "\n";
2715 Succes = Standard_False;
2719 {//==== Test Access Violation ===============================================
2722 di << "Segmentation Fault...";
2727 di << " Does not Caught... KO"<<"\n";
2728 Succes = Standard_False;
2731 catch(OSD_Exception_ACCESS_VIOLATION)
2737 } catch(Standard_Failure) {
2738 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2740 di << Standard_Failure::Caught()->GetMessageString();
2741 di << ")... KO" << "\n";
2742 Succes = Standard_False;
2747 {//==== Test Stack Overflow ===============================================
2750 di << "Stack Overflow...";
2754 di << " Does not Caught... KO"<<"\n";
2755 Succes = Standard_False;
2757 catch(OSD_Exception_STACK_OVERFLOW) {
2760 catch(Standard_Failure) {
2761 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2763 di << Standard_Failure::Caught()->GetMessageString();
2764 di << ")... KO" << "\n";
2765 Succes = Standard_False;
2771 di << "TestExcept: Successfull completion" << "\n";
2773 di << "TestExcept: failure" << "\n";
2779 #pragma optimize( "", on )
2782 static TopoDS_Compound AddTestStructure(int nCount_)
2788 BRepPrimAPI_MakeBox mkBox(1.0, 2.0, 3.0);
2789 for (int i=0; i<nCount; i++) {
2790 for (int j=0; j<nCount; j++) {
2792 trsf.SetTranslationPart(gp_Vec(5.0*i, 05.0*j, 0.0));
2793 TopLoc_Location topLoc(trsf);
2794 TopoDS_Shape tempShape=mkBox.Shape().Located(topLoc);
2795 B.Add(C, tempShape);
2801 static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2807 di << "Usage : " << argv[0] << " [nCount]" << "\n";
2812 nCount = atoi(argv[1]);
2813 STEPCAFControl_Writer writer;
2814 Handle_TDocStd_Document document;
2815 document = new TDocStd_Document("Pace Test-StepExporter-");
2816 Handle_XCAFDoc_ShapeTool shapeTool;
2817 shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
2818 shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
2819 STEPControl_StepModelType mode = STEPControl_AsIs;
2820 if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
2821 di << "Failed to set assembly mode for step data\n" << "\n";
2826 if( writer.Transfer(document, mode)) {
2827 IFSelect_ReturnStatus stat =
2828 writer.Write("TestExportStructure.step");
2831 catch(OSD_Exception_STACK_OVERFLOW) {
2832 di << "Failed : STACK OVERFLOW\n" << "\n";
2834 catch (Standard_Failure) {
2835 di << "Failed :\n" << "\n";
2836 //cout << Standard_Failure::Caught() << endl;
2837 di << Standard_Failure::Caught()->GetMessageString();
2839 di << argv[0] << " : Finish" << "\n";
2844 static Standard_Integer OCC7372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2848 di << "Usage : " << argv[0] << "\n";
2852 // 1. Create an array of points
2853 Handle(TColgp_HArray1OfPnt2d) ap = new TColgp_HArray1OfPnt2d(1,5);
2854 ap->SetValue(1,gp_Pnt2d(100.0,0.0));
2855 ap->SetValue(2,gp_Pnt2d(100.0,100.0));
2856 ap->SetValue(3,gp_Pnt2d(0.0,100.0));
2857 ap->SetValue(4,gp_Pnt2d(0.0,0.0));
2858 ap->SetValue(5,gp_Pnt2d(50.0,-50.0));
2860 // 2. Create a periodic bspline through these 5 points
2861 Geom2dAPI_Interpolate intp(ap,Standard_True,1e-6);
2863 Handle(Geom2d_BSplineCurve) bspline1 = intp.Curve();
2865 // 3. Increase degree of curve from 3 to 8
2866 bspline1->IncreaseDegree(8); // Increase degree to demonstrate the error
2867 Standard_CString CString1 = "BSplineCurve";
2868 DrawTrSurf::Set(CString1,bspline1);
2870 // 4. Convers BSpline curve to Bezier segments
2871 Geom2dConvert_BSplineCurveToBezierCurve bc(bspline1);
2873 // 5. Test the result of conversion
2874 TCollection_AsciiString aRName;
2875 for(Standard_Integer i = 1; i <= bc.NbArcs(); i++) {
2876 Handle(Geom2d_BezierCurve) arc = bc.Arc(i);
2878 aRName=aRName+TCollection_AsciiString(i);
2879 Standard_CString aRNameStr = aRName.ToCString();
2880 DrawTrSurf::Set(aRNameStr,arc);
2881 di << aRNameStr << " ";
2887 static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2891 di << "Usage : " << argv[0] << " edge1 edge2 plane" << "\n";
2894 TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
2895 if (theEdge1.IsNull()) {
2896 di << "Invalid input shape " << argv[1] << "\n";
2899 TopoDS_Edge theEdge2 = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
2900 if (theEdge2.IsNull()) {
2901 di << "Invalid input shape " << argv[2] << "\n";
2904 TopoDS_Face theFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
2905 if (theFace.IsNull()) {
2906 di << "Invalid input shape " << argv[3] << "\n";
2910 Handle(Geom_Surface) thePlane = BRep_Tool::Surface(theFace);
2912 Standard_Real aConfusion = Precision::Confusion();
2913 Standard_Real aP1first, aP1last, aP2first, aP2last;
2915 Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(theEdge1, aP1first, aP1last);
2916 Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(theEdge2, aP2first, aP2last);
2917 Handle(Geom2d_Curve) aCurve2d1 = GeomProjLib::Curve2d(aCurve1, aP1first, aP1last, thePlane);
2918 Handle(Geom2d_Curve) aCurve2d2 = GeomProjLib::Curve2d(aCurve2, aP2first, aP2last, thePlane);
2920 Geom2dAPI_InterCurveCurve anInter(aCurve2d1, aCurve2d2, aConfusion);
2922 Standard_Integer NbPoints = anInter.NbPoints();
2924 di << "NbPoints = " << NbPoints << "\n" ;
2928 for (i=1; i<=NbPoints; i++) {
2929 gp_Pnt2d aPi = anInter.Point(i);
2930 di << "Point.X(" << i << ") = " << aPi.X() << " " << "Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
2934 Standard_Integer NbSegments = anInter.NbSegments();
2936 di << "\nNbSegments = " << NbSegments << "\n" ;
2938 if (NbSegments > 0) {
2939 IntRes2d_IntersectionSegment aSegment = anInter.Intersector().Segment(1);
2941 gp_Pnt2d aP1 = aCurve2d1->Value(aSegment.FirstPoint().ParamOnFirst());
2942 gp_Pnt2d aP2 = aCurve2d2->Value(aSegment.FirstPoint().ParamOnSecond());
2944 Standard_Real aDist = aP1.Distance(aP2);
2946 di << "aP1.X() = " << aP1.X() << " " << "aP1.Y() = " << aP1.Y() << "\n" ;
2947 di << "aP2.X() = " << aP2.X() << " " << "aP2.Y() = " << aP2.Y() << "\n" ;
2949 di << "Distance = " << aDist << "\n" ;
2951 di << "Confusion = " << aConfusion << "\n" ;
2953 if (aDist > aConfusion) {
2954 di << "\n" << argv[0] << " Faulty" << "\n" ;
2956 di << "\n" << argv[0] << " OK" << "\n" ;
2959 di << "\n" << argv[0] << " OK" << "\n" ;
2964 static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2968 di << "Usage : " << argv[0] << " lower upper" << "\n";
2972 Standard_Integer LOWER = atoi(argv[1]);
2973 Standard_Integer UPPER = atoi(argv[2]);
2975 //! 0. Create an empty document with several test labels
2976 Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
2977 doc->SetUndoLimit(100);
2978 TDF_Label main_label = doc->Main();
2979 TDF_Label label1 = main_label.FindChild(1, Standard_True);
2980 TDF_Label label2 = main_label.FindChild(2, Standard_True);
2982 //! 1. Set/Get OCAF attribute
2984 TDataStd_RealArray::Set(label1, LOWER, UPPER);
2985 Handle(TDataStd_RealArray) array;
2986 if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) &&
2987 array->Lower() == LOWER && array->Upper() == UPPER)
2988 cout<<"1: OK"<<endl;
2991 cout<<"1: Failed.."<<endl;
2994 doc->CommitCommand();
2996 //! 2. Set/Get value
2999 for (i = LOWER; i <= UPPER; i++)
3000 array->SetValue(i, i);
3001 for (i = LOWER; i <= UPPER; i++)
3003 if (array->Value(i) != i)
3005 cout<<"2: Failed.."<<endl;
3009 cout<<"2: OK"<<endl;
3010 doc->CommitCommand();
3012 //! 3. Re-init the array
3014 array->Init(LOWER + 2, UPPER + 4);
3015 if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4)
3017 cout<<"3: Failed.."<<endl;
3020 for (i = LOWER + 2; i <= UPPER + 4; i++)
3021 array->SetValue(i, i);
3022 for (i = LOWER + 2; i <= UPPER + 4; i++)
3024 if (array->Value(i) != i)
3026 cout<<"3: Failed.."<<endl;
3030 cout<<"3: OK"<<endl;
3031 doc->CommitCommand();
3035 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(LOWER + 5, UPPER + 5);
3036 for (i = LOWER + 5; i <= UPPER + 5; i++)
3037 arr->SetValue(i, i);
3038 array->ChangeArray(arr);
3039 for (i = LOWER + 5; i <= UPPER + 5; i++)
3041 if (array->Value(i) != i)
3043 cout<<"4: Failed.."<<endl;
3047 cout<<"4: OK"<<endl;
3048 doc->CommitCommand();
3050 //! 5. Copy the array
3052 TDF_CopyLabel copier(label1, label2);
3054 if (!copier.IsDone())
3056 cout<<"5: Failed.."<<endl;
3059 Handle(TDataStd_RealArray) array2;
3060 if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
3062 cout<<"5: Failed.."<<endl;
3065 for (i = LOWER + 5; i <= UPPER + 5; i++)
3067 if (array->Value(i) != i)
3069 cout<<"5: Failed.."<<endl;
3073 cout<<"5: OK"<<endl;
3074 doc->CommitCommand();
3077 //! 6.a: undoes the 5th action: the copied array should disappear
3079 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3080 label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
3082 cout<<"6.a: Failed.."<<endl;
3085 //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4)
3087 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3088 array->Lower() != LOWER + 2 ||
3089 array->Upper() != UPPER + 4)
3091 cout<<"6.b: Failed.."<<endl;
3094 for (i = LOWER + 2; i <= UPPER + 4; i++)
3096 if (array->Value(i) != i)
3098 cout<<"6.b: Failed.."<<endl;
3102 //! 6.c: undoes the 3d action: the array should be changed to (lower,upper)
3104 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3105 array->Lower() != LOWER ||
3106 array->Upper() != UPPER)
3108 cout<<"6.c: Failed.."<<endl;
3111 for (i = LOWER; i <= UPPER; i++)
3113 if (array->Value(i) != i)
3115 cout<<"6.c: Failed.."<<endl;
3119 //! 6.d: undoes and redoes the 2nd action: no change is expected.
3122 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3123 array->Lower() != LOWER ||
3124 array->Upper() != UPPER)
3126 cout<<"6.d: Failed.."<<endl;
3129 for (i = LOWER; i <= UPPER; i++)
3131 if (array->Value(i) != i)
3133 cout<<"6.d: Failed.."<<endl;
3137 cout<<"6: OK"<<endl;
3139 //! 7. Re-set the array
3141 array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1);
3142 if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1)
3144 cout<<"7: Failed.."<<endl;
3147 for (i = LOWER + 1; i <= UPPER + 1; i++)
3148 array->SetValue(i, i);
3149 for (i = LOWER + 1; i <= UPPER + 1; i++)
3151 if (array->Value(i) != i)
3153 cout<<"7: Failed.."<<endl;
3157 cout<<"7: OK"<<endl;
3158 doc->CommitCommand();
3160 //! 8.Test of speed: set LOWER and UPPER equal to great integer number and
3161 //! measure the time spent by this test.
3167 static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3169 Standard_Boolean IsEvenArgc = Standard_True;
3170 if (argc % 2 == 0) {
3171 IsEvenArgc = Standard_True;
3173 IsEvenArgc = Standard_False;
3176 if (argc < 3 || IsEvenArgc)
3178 di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]" << "\n";
3182 Standard_Integer i, aValue, aPosition;
3183 NCollection_Vector<int> vec;
3184 for (i = 0; i < argc - 1; i++) {
3186 aValue = atoi(argv[i]);
3187 aPosition = atoi(argv[i+1]);
3188 vec.SetValue(aValue, aPosition);
3190 NCollection_Vector<int>::Iterator it(vec);
3192 for (j = 0; it.More(); it.Next(), j++) {
3193 //di << it.Value() << "\n";
3194 di << j << " " << it.Value() << "\n";
3200 static Standard_Integer OCC8797 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3203 di << "Usage : " << argv[0] << "\n";
3207 gp_Pnt point(0.0,0.0,0.0);
3209 TColgp_Array1OfPnt poles(0,6);
3212 point.SetCoord(1.0,1.0,0.0);
3215 point.SetCoord(2.0,1.0,0.0);
3218 point.SetCoord(3.0,0.0,0.0);
3221 point.SetCoord(4.0,1.0,0.0);
3224 point.SetCoord(5.0,1.0,0.0);
3227 point.SetCoord(6.0,0.0,0.0);
3230 TColStd_Array1OfReal knots(0,2);
3235 TColStd_Array1OfInteger multi(0,2);
3240 Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles,knots,multi,3);
3243 Standard_Real l_abcissa,l_gprop;
3244 GeomAdaptor_Curve adaptor_spline(spline);
3245 GCPnts_AbscissaPoint temp;
3246 l_abcissa=temp.Length(adaptor_spline);
3247 cout<<"Length Spline(abcissa_Pnt): "<<l_abcissa<<endl;
3250 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge (spline);
3252 BRepGProp::LinearProperties(edge,prop);
3253 l_gprop=prop.Mass();
3254 cout<<"Length Spline(GProp_GProps): "<<l_gprop<<endl;
3256 cout<<"Difference (abcissa_Pnt<->GProp_GProps): "<<l_gprop-l_abcissa<<endl;
3261 static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3265 di << "Usage : " << argv[0] << "\n";
3269 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
3270 if(AISContext.IsNull())
3272 di << "use 'vinit' command before " << argv[0] << "\n";
3277 AIS_ListOfInteractive ListOfIO_1;
3278 AISContext->ObjectsInside(ListOfIO_1);
3279 di<< "ObjectsInside = " << ListOfIO_1.Extent() <<"\n";
3280 if (!ListOfIO_1.IsEmpty() ) {
3281 AIS_ListIteratorOfListOfInteractive iter;
3282 for (iter.Initialize(ListOfIO_1); iter.More() ; iter.Next() ) {
3283 Handle(AIS_InteractiveObject) aIO=iter.Value();
3284 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3288 // ObjectsInCollector
3289 AIS_ListOfInteractive ListOfIO_2;
3290 AISContext->ObjectsInCollector(ListOfIO_2);
3291 di<< "ObjectsInCollector = " << ListOfIO_2.Extent() <<"\n";
3292 if (!ListOfIO_2.IsEmpty() ) {
3293 AIS_ListIteratorOfListOfInteractive iter;
3294 for (iter.Initialize(ListOfIO_2); iter.More() ; iter.Next() ) {
3295 Handle(AIS_InteractiveObject) aIO=iter.Value();
3296 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3303 static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3305 if ((argc < 9) || (((argc-3) % 3) != 0))
3307 di << "Usage : " << argv[0] << "polygon lastedge x1 y1 z1 x2 y2 z2 ...\n";
3310 Standard_Integer i, j, np = (argc-3) / 3;
3311 BRepBuilderAPI_MakePolygon W;
3313 for (i = 1; i <= np; i ++) {
3314 W.Add(gp_Pnt(atof(argv[j]),atof(argv[j+1]),atof(argv[j+2])));
3318 DBRep::Set(argv[1],W.Wire());
3319 DBRep::Set(argv[2],W.Edge());
3323 static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3326 di << "Usage : " << argv[0] << " ratio origin_x origin_y origin_z\n";
3329 gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
3330 gp_Dir(1., -1., 0.));
3332 aTrf.SetAffinity (aPln, atof(argv[4]));
3333 gp_XYZ aOrigin (atof(argv[1]),atof(argv[2]),atof(argv[3]));
3334 gp_XYZ aResult (aOrigin);
3335 aTrf.Transforms(aResult);
3337 sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
3338 aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
3339 aResult.X(), aResult.Y(), aResult.Z());
3344 Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3347 di << "Usage : " << argv[0] << " shape [deflection]\n";
3351 TopoDS_Shape aShape = DBRep::Get(argv[1]);
3353 if (aShape.IsNull()) {
3354 di<<" Null shape is not allowed";
3358 Standard_Real aDeflection = 0.45110277533;
3360 aDeflection = atof(argv[2]);
3362 di<<"deflection="<< aDeflection << "\n";
3364 BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, PI/9.);
3365 TopLoc_Location aLocation;
3366 Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
3368 if(aTriang.IsNull()) {
3369 di << argv[0] << " : Faulty\n" ;
3371 di << argv[0] << " : OK\n" ;
3372 di<<"NbNodes="<< aTriang->NbNodes()<< "\n";
3373 di<<"NbTriangles="<< aTriang->NbTriangles()<< "\n";
3378 static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3381 di << "Usage : " << argv[0] << " A B C\n";
3386 gp_Lin2d aLin2d (atof(argv[1]),atof(argv[2]),atof(argv[3]));
3387 gp_Pnt2d anOrigin = aLin2d.Location();
3388 di << "X_0 = " << anOrigin.X() << " Y_0 = " << anOrigin.Y() << "\n" ;
3390 catch(Standard_ConstructionError)
3392 di << argv[0] << " Exception: Sqrt(A*A + B*B) <= Resolution from gp\n";
3397 static Standard_Integer OCC15755 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3400 di << "Usage : " << argv[0] << " file shape\n";
3404 IGESControl_Reader aReader;
3405 aReader.ReadFile(argv[1]);
3406 aReader.SetReadVisible(Standard_True);
3407 aReader.TransferRoots();
3409 Handle(IGESData_IGESModel) model = aReader.IGESModel();
3410 if (model.IsNull()) {
3411 di << "model.IsNull()\n";
3414 Standard_Integer nb = model->NbEntities();
3415 for (Standard_Integer i = 1; i <= nb; i ++) {
3416 Handle(IGESData_IGESEntity) ent = model->Entity(i);
3417 Handle(TCollection_HAsciiString) name;
3418 name = ent->NameValue();
3419 Standard_CString aStr = name->ToCString();
3420 di << "NameValue = " << aStr << "\n";
3423 TopoDS_Shape shape = aReader.OneShape();
3424 DBRep::Set(argv[2],shape);
3428 // For OCC16782 testing
3429 #include <AppStd_Application.hxx>
3430 #include <TDF_Tool.hxx>
3431 #include <TColStd_HArray1OfInteger.hxx>
3433 #include <TColStd_ListIteratorOfListOfInteger.hxx>
3434 #include <TColStd_ListIteratorOfListOfReal.hxx>
3435 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
3436 #include <TDataStd_ListIteratorOfListOfByte.hxx>
3437 #include <TDF_ListIteratorOfLabelList.hxx>
3439 #include <TDataStd_Tick.hxx>
3440 #include <TDataStd_IntegerList.hxx>
3441 #include <TDataStd_RealList.hxx>
3442 #include <TDataStd_ExtStringList.hxx>
3443 #include <TDataStd_BooleanList.hxx>
3444 #include <TDataStd_ReferenceList.hxx>
3445 #include <TDataStd_BooleanArray.hxx>
3446 #include <TDataStd_ReferenceArray.hxx>
3447 #include <TDataStd_ByteArray.hxx>
3448 #include <TDataStd_NamedData.hxx>
3449 #include <TDF_Reference.hxx>
3451 Handle(AppStd_Application) app;
3452 int TestSetGet(const Handle(TDocStd_Document)& doc)
3456 TDataStd_Tick::Set(doc->Main());
3458 Handle(TDataStd_Tick) tick;
3459 if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick))
3462 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3463 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3465 doc->Main().ResumeAttribute(tick);
3466 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3469 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3470 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3473 // TDataStd_IntegerList:
3475 Handle(TDataStd_IntegerList) setintlist = TDataStd_IntegerList::Set(doc->Main());
3476 setintlist->Append(2);
3477 setintlist->Prepend(1);
3478 setintlist->InsertAfter(3, 2);
3479 setintlist->InsertBefore(0, 1);
3480 setintlist->Append(200);
3481 setintlist->Remove(0);
3482 setintlist->Remove(200);
3484 Handle(TDataStd_IntegerList) getintlist;
3485 if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist))
3487 if (getintlist->First() != 1)
3489 if (getintlist->Last() != 3)
3491 const TColStd_ListOfInteger& intlist = getintlist->List();
3492 TColStd_ListIteratorOfListOfInteger itr_intlist(intlist);
3493 for (; itr_intlist.More(); itr_intlist.Next())
3495 if (itr_intlist.Value() != 1 &&
3496 itr_intlist.Value() != 2 &&
3497 itr_intlist.Value() != 3)
3502 getintlist->Clear();
3504 // TDataStd_RealList:
3506 Handle(TDataStd_RealList) setdbllist = TDataStd_RealList::Set(doc->Main());
3507 setdbllist->Append(2.5);
3508 setdbllist->Prepend(1.5);
3509 setdbllist->InsertAfter(3.5, 2.5);
3510 setdbllist->InsertBefore(0.5, 1.5);
3511 setdbllist->Append(200.5);
3512 setdbllist->Remove(0.5);
3513 setdbllist->Remove(200.5);
3515 Handle(TDataStd_RealList) getdbllist;
3516 if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist))
3518 if (getdbllist->First() != 1.5)
3520 if (getdbllist->Last() != 3.5)
3522 const TColStd_ListOfReal& dbllist = getdbllist->List();
3523 TColStd_ListIteratorOfListOfReal itr_dbllist(dbllist);
3524 for (; itr_dbllist.More(); itr_dbllist.Next())
3526 if (itr_dbllist.Value() != 1.5 &&
3527 itr_dbllist.Value() != 2.5 &&
3528 itr_dbllist.Value() != 3.5)
3533 getdbllist->Clear();
3535 // TDataStd_ExtStringList:
3537 Handle(TDataStd_ExtStringList) setstrlist = TDataStd_ExtStringList::Set(doc->Main());
3538 setstrlist->Append("Hello");
3539 setstrlist->Prepend("Guten Tag");
3540 setstrlist->InsertAfter("Bonjour", "Guten Tag");
3541 setstrlist->InsertBefore("Bonsoir", "Hello");
3542 setstrlist->Append("Good bye");
3543 setstrlist->Remove("Bonsoir");
3544 setstrlist->Remove("Good bye");
3546 Handle(TDataStd_ExtStringList) getstrlist;
3547 if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist))
3549 if (getstrlist->First() != "Guten Tag")
3551 if (getstrlist->Last() != "Hello")
3553 const TDataStd_ListOfExtendedString& strlist = getstrlist->List();
3554 TDataStd_ListIteratorOfListOfExtendedString itr_strlist(strlist);
3555 for (; itr_strlist.More(); itr_strlist.Next())
3557 if (itr_strlist.Value() != "Guten Tag" &&
3558 itr_strlist.Value() != "Bonjour" &&
3559 itr_strlist.Value() != "Hello")
3564 getstrlist->Clear();
3566 // TDataStd_BooleanList:
3568 Handle(TDataStd_BooleanList) setboollist = TDataStd_BooleanList::Set(doc->Main());
3569 setboollist->Append(Standard_True);
3570 setboollist->Prepend(Standard_False);
3572 Handle(TDataStd_BooleanList) getboollist;
3573 if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist))
3575 if (getboollist->First() != Standard_False)
3577 if (getboollist->Last() != Standard_True)
3579 const TDataStd_ListOfByte& boollist = getboollist->List();
3580 TDataStd_ListIteratorOfListOfByte itr_boollist(boollist);
3581 for (; itr_boollist.More(); itr_boollist.Next())
3583 if (itr_boollist.Value() != Standard_True &&
3584 itr_boollist.Value() != Standard_False)
3589 getboollist->Clear();
3591 // TDataStd_ReferenceList:
3592 TDF_Label L1 = doc->Main().FindChild(100);
3593 TDF_Label L2 = doc->Main().FindChild(101);
3594 TDF_Label L3 = doc->Main().FindChild(102);
3595 TDF_Label L4 = doc->Main().FindChild(103);
3596 TDF_Label L5 = doc->Main().FindChild(104);
3598 Handle(TDataStd_ReferenceList) setreflist = TDataStd_ReferenceList::Set(doc->Main());
3599 setreflist->Append(L1);
3600 setreflist->Prepend(L2);
3601 setreflist->InsertAfter(L3, L2);
3602 setreflist->InsertBefore(L4, L1);
3603 setreflist->Append(L5);
3604 setreflist->Remove(L4);
3605 setreflist->Remove(L5);
3607 Handle(TDataStd_ReferenceList) getreflist;
3608 if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist))
3610 if (getreflist->First() != L2)
3612 if (getreflist->Last() != L1)
3614 const TDF_LabelList& reflist = getreflist->List();
3615 TDF_ListIteratorOfLabelList itr_reflist(reflist);
3616 for (; itr_reflist.More(); itr_reflist.Next())
3618 if (itr_reflist.Value() != L1 &&
3619 itr_reflist.Value() != L2 &&
3620 itr_reflist.Value() != L3)
3625 getreflist->Clear();
3627 // TDataStd_BooleanArray:
3629 Handle(TDataStd_BooleanArray) setboolarr = TDataStd_BooleanArray::Set(doc->Main(), 12, 16);
3630 setboolarr->SetValue(12, Standard_True);
3631 setboolarr->SetValue(13, Standard_False);
3632 setboolarr->SetValue(14, Standard_False);
3633 setboolarr->SetValue(15, Standard_False);
3634 setboolarr->SetValue(16, Standard_True);
3635 setboolarr->SetValue(14, Standard_True);
3637 Handle(TDataStd_BooleanArray) getboolarr;
3638 if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr))
3640 if (getboolarr->Value(12) != Standard_True)
3642 if (getboolarr->Value(13) != Standard_False)
3644 if (getboolarr->Value(14) != Standard_True)
3646 if (getboolarr->Value(15) != Standard_False)
3648 if (getboolarr->Value(16) != Standard_True)
3651 // TDataStd_ReferenceArray:
3653 Handle(TDataStd_ReferenceArray) setrefarr = TDataStd_ReferenceArray::Set(doc->Main(), 0, 4);
3654 setrefarr->SetValue(0, L1);
3655 setrefarr->SetValue(1, L2);
3656 setrefarr->SetValue(2, L3);
3657 setrefarr->SetValue(3, L4);
3658 setrefarr->SetValue(4, L5);
3660 Handle(TDataStd_ReferenceArray) getrefarr;
3661 if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr))
3663 if (getrefarr->Value(0) != L1)
3665 if (getrefarr->Value(1) != L2)
3667 if (getrefarr->Value(2) != L3)
3669 if (getrefarr->Value(3) != L4)
3671 if (getrefarr->Value(4) != L5)
3674 // TDataStd_ByteArray:
3676 Handle(TDataStd_ByteArray) setbytearr = TDataStd_ByteArray::Set(doc->Main(), 12, 16);
3677 setbytearr->SetValue(12, 0);
3678 setbytearr->SetValue(13, 1);
3679 setbytearr->SetValue(14, 2);
3680 setbytearr->SetValue(15, 3);
3681 setbytearr->SetValue(16, 255);
3683 Handle(TDataStd_ByteArray) getbytearr;
3684 if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr))
3686 if (getbytearr->Value(12) != 0)
3688 if (getbytearr->Value(13) != 1)
3690 if (getbytearr->Value(14) != 2)
3692 if (getbytearr->Value(15) != 3)
3694 if (getbytearr->Value(16) != 255)
3697 // TDataStd_NamedData:
3699 Handle(TDataStd_NamedData) setnd = TDataStd_NamedData::Set(doc->Main());
3700 setnd->SetInteger("Integer1", 1);
3701 setnd->SetInteger("Integer2", 2);
3702 setnd->SetInteger("Integer3", 8);
3703 setnd->SetInteger("Integer3", 3);
3705 Handle(TDataStd_NamedData) getnd;
3706 if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd))
3708 if (!getnd->HasIntegers())
3710 if (!getnd->HasInteger("Integer1"))
3712 if (getnd->GetInteger("Integer2") != 2)
3714 if (getnd->GetInteger("Integer3") != 3)
3720 int TestUndoRedo(const Handle(TDocStd_Document)& doc)
3724 Handle(TDataStd_Tick) tick = TDataStd_Tick::Set(doc->Main());
3725 doc->CommitCommand();
3726 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3729 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3732 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3735 // TDataStd_IntegerList:
3737 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc->Main());
3739 intlist->Prepend(1);
3740 intlist->InsertBefore(0, 1);
3741 intlist->InsertAfter(3, 2);
3742 doc->CommitCommand();
3743 if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID()))
3746 if (!intlist->IsEmpty())
3749 if (!intlist->Extent())
3751 if (intlist->First() != 0)
3753 if (intlist->Last() != 3)
3757 // TDataStd_RealList:
3759 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc->Main());
3760 dbllist->Append(2.5);
3761 dbllist->Prepend(1.5);
3762 dbllist->InsertBefore(0.5, 1.5);
3763 dbllist->InsertAfter(3.5, 2.5);
3764 doc->CommitCommand();
3765 if (!doc->Main().IsAttribute(TDataStd_RealList::GetID()))
3768 if (!dbllist->IsEmpty())
3771 if (!dbllist->Extent())
3773 if (dbllist->First() != 0.5)
3775 if (dbllist->Last() != 3.5)
3779 // TDataStd_ExtStringList:
3781 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc->Main());
3782 strlist->Append("Hello");
3783 strlist->Prepend("Guten Tag");
3784 strlist->InsertAfter("Bonjour", "Guten Tag");
3785 strlist->InsertBefore("Bonsoir", "Hello");
3786 doc->CommitCommand();
3787 if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID()))
3790 if (!strlist->IsEmpty())
3793 if (!strlist->Extent())
3795 if (strlist->First() != "Guten Tag")
3797 if (strlist->Last() != "Hello")
3801 // TDataStd_BooleanList:
3803 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc->Main());
3804 boollist->Append(Standard_True);
3805 boollist->Prepend(Standard_False);
3806 doc->CommitCommand();
3807 if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID()))
3810 if (!boollist->IsEmpty())
3813 if (!boollist->Extent())
3815 if (boollist->First() != Standard_False)
3817 if (boollist->Last() != Standard_True)
3821 // TDataStd_ReferenceList:
3822 TDF_Label L1 = doc->Main().FindChild(100);
3823 TDF_Label L2 = doc->Main().FindChild(101);
3824 TDF_Label L3 = doc->Main().FindChild(102);
3825 TDF_Label L4 = doc->Main().FindChild(103);
3827 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc->Main());
3828 reflist->Append(L1);
3829 reflist->Prepend(L2);
3830 reflist->InsertBefore(L3, L1);
3831 reflist->InsertAfter(L4, L2);
3832 doc->CommitCommand();
3833 if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID()))
3836 if (!reflist->IsEmpty())
3839 if (!reflist->Extent())
3841 if (reflist->First() != L2)
3843 if (reflist->Last() != L1)
3847 // TDataStd_BooleanArray:
3849 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc->Main(), 23, 25);
3850 boolarr->SetValue(23, Standard_True);
3851 boolarr->SetValue(25, Standard_True);
3852 doc->CommitCommand();
3854 boolarr = TDataStd_BooleanArray::Set(doc->Main(), 230, 250);
3855 boolarr->SetValue(230, Standard_True);
3856 boolarr->SetValue(250, Standard_True);
3857 doc->CommitCommand();
3859 if (boolarr->Value(23) != Standard_True)
3861 if (boolarr->Value(24) != Standard_False)
3863 if (boolarr->Value(25) != Standard_True)
3866 if (boolarr->Value(230) != Standard_True)
3868 if (boolarr->Value(240) != Standard_False)
3870 if (boolarr->Value(250) != Standard_True)
3873 // TDataStd_ReferenceArray:
3875 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc->Main(), 5, 8);
3876 refarr->SetValue(5, L1);
3877 refarr->SetValue(6, L2);
3878 refarr->SetValue(7, L3);
3879 refarr->SetValue(8, L4);
3880 doc->CommitCommand();
3881 if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID()))
3885 if (refarr->Value(5) != L1)
3887 if (refarr->Value(6) != L2)
3889 if (refarr->Value(7) != L3)
3891 if (refarr->Value(8) != L4)
3894 // TDataStd_ByteArray:
3896 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc->Main(), 23, 25);
3897 bytearr->SetValue(23, 23);
3898 bytearr->SetValue(25, 25);
3899 doc->CommitCommand();
3901 bytearr = TDataStd_ByteArray::Set(doc->Main(), 230, 250);
3902 bytearr->SetValue(230, 230);
3903 bytearr->SetValue(250, 250);
3904 doc->CommitCommand();
3906 if (bytearr->Value(23) != 23)
3908 if (bytearr->Value(25) != 25)
3911 if (bytearr->Value(230) != 230)
3913 if (bytearr->Value(250) != 250)
3916 // TDataStd_NamedData:
3918 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(doc->Main());
3919 nd->SetByte("b14", 12);
3920 nd->SetByte("b17", 18);
3921 nd->SetByte("b14", 14);
3922 nd->SetByte("b17", 17);
3923 doc->CommitCommand();
3925 nd = TDataStd_NamedData::Set(doc->Main());
3926 nd->SetReal("r14", 14);
3927 nd->SetReal("r17", 17);
3928 nd->SetReal("r14", 14.4);
3929 nd->SetReal("r17", 17.7);
3930 doc->CommitCommand();
3932 if (nd->HasStrings())
3936 if (nd->HasReal("r17"))
3938 if (!nd->HasBytes())
3940 if (nd->GetByte("b14") != 14)
3942 if (nd->GetByte("b17") != 17)
3944 if (nd->HasByte("b18"))
3947 if (!nd->HasBytes())
3949 if (!nd->HasReals())
3951 if (nd->GetByte("b14") != 14)
3953 if (nd->GetReal("r14") != 14.4)
3955 if (nd->GetReal("r17") != 17.7)
3961 int TestCopyPaste(const Handle(TDocStd_Document)& doc)
3963 TDF_Label L1 = doc->Main().FindChild(1);
3964 TDF_Label L2 = doc->Main().FindChild(2);
3965 TDF_CopyLabel copier(L1, L2);
3968 TDataStd_Tick::Set(L1);
3970 if (!copier.IsDone())
3972 if (!L2.IsAttribute(TDataStd_Tick::GetID()))
3975 // TDataStd_IntegerList:
3976 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(L1);
3978 intlist->InsertAfter(2, 1);
3980 if (!copier.IsDone())
3984 if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3986 if (intlist->First() != 1)
3988 if (intlist->Last() != 2)
3992 // TDataStd_RealList:
3993 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(L1);
3994 dbllist->Append(1.5);
3995 dbllist->InsertAfter(2.5, 1.5);
3997 if (!copier.IsDone())
4001 if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist))
4003 if (dbllist->First() != 1.5)
4005 if (dbllist->Last() != 2.5)
4009 // TDataStd_ExtStringList:
4010 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(L1);
4011 strlist->Append("Open CASCADE");
4012 strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE");
4014 if (!copier.IsDone())
4018 if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4020 if (strlist->First() != "Open CASCADE")
4022 if (strlist->Last() != " - is the best set of libraries!")
4026 // TDataStd_BooleanList:
4027 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(L1);
4028 boollist->Append(Standard_True);
4029 boollist->Prepend(Standard_False);
4031 if (!copier.IsDone())
4035 if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4037 if (boollist->First() != Standard_False)
4039 if (boollist->Last() != Standard_True)
4043 // TDataStd_ReferenceList:
4044 TDF_Label L100 = doc->Main().FindChild(100);
4045 TDF_Label L101 = doc->Main().FindChild(101);
4046 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(L1);
4047 reflist->Append(L100);
4048 reflist->InsertAfter(L101, L100);
4050 if (!copier.IsDone())
4054 if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4056 if (reflist->First() != L100)
4058 if (reflist->Last() != L101)
4062 // TDataStd_BooleanArray:
4063 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(L1, 4, 6);
4064 boolarr->SetValue(4, Standard_True);
4065 boolarr->SetValue(6, Standard_True);
4067 if (!copier.IsDone())
4070 if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4072 if (boolarr->Value(4) != Standard_True)
4074 if (boolarr->Value(5) != Standard_False)
4076 if (boolarr->Value(6) != Standard_True)
4079 // TDataStd_ReferenceArray:
4080 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(L1, 3, 4);
4081 refarr->SetValue(3, L100);
4082 refarr->SetValue(4, L101);
4084 if (!copier.IsDone())
4087 if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4089 if (refarr->Value(3) != L100)
4091 if (refarr->Value(4) != L101)
4094 // TDataStd_ByteArray:
4095 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(L1, 4, 6);
4096 bytearr->SetValue(4, 40);
4097 bytearr->SetValue(6, 60);
4099 if (!copier.IsDone())
4102 if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4104 if (bytearr->Value(4) != 40)
4106 if (bytearr->Value(6) != 60)
4109 // TDataStd_NamedData:
4110 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(L1);
4111 nd->SetInteger("Integer1", 11);
4112 nd->SetReal("Real1", 11.1);
4113 nd->SetString("String1", "11.11111111");
4114 nd->SetByte("Byte1", 111);
4115 Handle(TColStd_HArray1OfInteger) ints_arr = new TColStd_HArray1OfInteger(4, 5);
4116 ints_arr->SetValue(4, 4);
4117 ints_arr->SetValue(5, 5);
4118 nd->SetArrayOfIntegers("Integers1", ints_arr);
4120 if (!copier.IsDone())
4123 if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd))
4125 if (!nd->HasIntegers())
4127 if (!nd->HasReals())
4129 if (!nd->HasStrings())
4131 if (!nd->HasBytes())
4133 if (!nd->HasArraysOfIntegers())
4135 if (nd->HasArraysOfReals())
4137 if (!nd->HasInteger("Integer1"))
4139 if (nd->GetInteger("Integer1") != 11)
4141 if (!nd->HasReal("Real1"))
4143 if (nd->GetReal("Real1") != 11.1)
4145 if (!nd->HasString("String1"))
4147 if (nd->GetString("String1") != "11.11111111")
4149 if (!nd->HasByte("Byte1"))
4151 if (nd->GetByte("Byte1") != 111)
4153 if (!nd->HasArrayOfIntegers("Integers1"))
4155 const Handle(TColStd_HArray1OfInteger)& ints_arr_out = nd->GetArrayOfIntegers("Integers1");
4156 if (ints_arr_out.IsNull())
4158 if (ints_arr_out->Value(5) != 5)
4164 int TestOpenSave(TCollection_ExtendedString aFile1,
4165 TCollection_ExtendedString aFile2,
4166 TCollection_ExtendedString aFile3)
4169 Handle(TDocStd_Document) doc_std, doc_std_open;
4170 app->NewDocument("MDTV-Standard", doc_std);
4172 TDataStd_Tick::Set(doc_std->Main());
4173 // TDataStd_IntegerList:
4174 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc_std->Main());
4177 // TDataStd_RealList:
4178 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc_std->Main());
4179 dbllist->Append(1.5);
4180 dbllist->Append(5.5);
4181 // TDataStd_ExtStringList:
4182 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc_std->Main());
4183 strlist->Append("Auf");
4184 strlist->Append("Wiedersehen");
4185 // TDataStd_BooleanList:
4186 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc_std->Main());
4187 boollist->Append(Standard_False);
4188 boollist->Append(Standard_True);
4189 // TDataStd_ReferenceList:
4190 TCollection_AsciiString entry1, entry2, entry_first, entry_last;
4191 TDF_Label Lstd1 = doc_std->Main().FindChild(100);
4192 TDF_Tool::Entry(Lstd1, entry1);
4193 TDF_Label Lstd2 = doc_std->Main().FindChild(101);
4194 TDF_Tool::Entry(Lstd2, entry2);
4195 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc_std->Main());
4196 reflist->Append(Lstd1);
4197 reflist->Append(Lstd2);
4198 // TDataStd_BooleanArray:
4199 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc_std->Main(), 15, 18);
4200 boolarr->SetValue(15, Standard_False);
4201 boolarr->SetValue(16, Standard_True);
4202 boolarr->SetValue(17, Standard_True);
4203 boolarr->SetValue(18, Standard_True);
4204 // TDataStd_ReferenceArray:
4205 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc_std->Main(), 45, 46);
4206 refarr->SetValue(45, Lstd1);
4207 refarr->SetValue(46, Lstd2);
4208 // TDataStd_ByteArray:
4209 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc_std->Main(), 15, 18);
4210 bytearr->SetValue(15, 150);
4211 bytearr->SetValue(16, 160);
4212 bytearr->SetValue(17, 170);
4213 bytearr->SetValue(18, 180);
4214 // TDataStd_NamedData:
4215 Handle(TDataStd_NamedData) nameddata = TDataStd_NamedData::Set(doc_std->Main());
4217 TDF_Label Lstd3 = doc_std->Main().FindChild(103);
4218 Handle(TDF_Reference) ref = TDF_Reference::Set(doc_std->Main(), Lstd3);
4221 //if (app->SaveAs(doc_std, "W:\\doc.std") != PCDM_SS_OK)
4222 if (app->SaveAs(doc_std, aFile1) != PCDM_SS_OK)
4231 app->Close(doc_std);
4233 //if (app->Open("W:\\doc.std", doc_std_open) != PCDM_RS_OK)
4234 if (app->Open(aFile1, doc_std_open) != PCDM_RS_OK)
4236 if (!doc_std_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4238 if (!doc_std_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4240 if (intlist->First() != 1)
4242 if (intlist->Last() != 5)
4244 if (!doc_std_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4246 if (dbllist->First() != 1.5)
4248 if (dbllist->Last() != 5.5)
4250 if (!doc_std_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4252 if (strlist->First() != "Auf")
4254 if (strlist->Last() != "Wiedersehen")
4256 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4258 if (boollist->First() != Standard_False)
4260 if (boollist->Last() != Standard_True)
4262 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4264 TDF_Tool::Entry(reflist->First(), entry_first);
4265 if (entry1 != entry_first)
4267 TDF_Tool::Entry(reflist->Last(), entry_last);
4268 if (entry2 != entry_last)
4270 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4272 if (boolarr->Value(15) != Standard_False)
4274 if (boolarr->Value(16) != Standard_True)
4276 if (boolarr->Value(17) != Standard_True)
4278 if (boolarr->Value(18) != Standard_True)
4280 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4282 TDF_Tool::Entry(refarr->Value(45), entry_first);
4283 if (entry1 != entry_first)
4285 TDF_Tool::Entry(refarr->Value(46), entry_last);
4286 if (entry2 != entry_last)
4288 if (!doc_std_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4290 if (bytearr->Value(15) != 150)
4292 if (bytearr->Value(16) != 160)
4294 if (bytearr->Value(17) != 170)
4296 if (bytearr->Value(18) != 180)
4298 if (!doc_std_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4300 if (ref->Get().IsNull())
4302 if (ref->Get().Tag() != 103)
4306 Handle(TDocStd_Document) doc_xml, doc_xml_open;
4307 app->NewDocument("XmlOcaf", doc_xml);
4309 TDataStd_Tick::Set(doc_xml->Main());
4310 // TDataStd_IntegerList:
4311 intlist = TDataStd_IntegerList::Set(doc_xml->Main());
4314 // TDataStd_RealList:
4315 dbllist = TDataStd_RealList::Set(doc_xml->Main());
4316 dbllist->Append(1.5);
4317 dbllist->Append(5.5);
4318 // TDataStd_ExtStringList:
4319 strlist = TDataStd_ExtStringList::Set(doc_xml->Main());
4320 strlist->Append("Guten ");
4321 strlist->Append("Tag");
4322 // TDataStd_BooleanList:
4323 boollist = TDataStd_BooleanList::Set(doc_xml->Main());
4324 boollist->Append(Standard_False);
4325 boollist->Append(Standard_True);
4326 // TDataStd_ReferenceList:
4327 TDF_Label Lxml1 = doc_xml->Main().FindChild(100);
4328 TDF_Tool::Entry(Lxml1, entry1);
4329 TDF_Label Lxml2 = doc_xml->Main().FindChild(101);
4330 TDF_Tool::Entry(Lxml2, entry2);
4331 reflist = TDataStd_ReferenceList::Set(doc_xml->Main());
4332 reflist->Append(Lxml1);
4333 reflist->Append(Lxml2);
4334 // TDataStd_BooleanArray:
4335 boolarr = TDataStd_BooleanArray::Set(doc_xml->Main(), 15, 24);
4336 boolarr->SetValue(15, Standard_False);
4337 boolarr->SetValue(16, Standard_True);
4338 boolarr->SetValue(17, Standard_True);
4339 boolarr->SetValue(18, Standard_True);
4340 boolarr->SetValue(19, Standard_True);
4341 boolarr->SetValue(20, Standard_True);
4342 boolarr->SetValue(21, Standard_False);
4343 boolarr->SetValue(22, Standard_True);
4344 boolarr->SetValue(23, Standard_True);
4345 boolarr->SetValue(24, Standard_True);
4346 // TDataStd_ReferenceArray:
4347 refarr = TDataStd_ReferenceArray::Set(doc_xml->Main(), 444, 445);
4348 refarr->SetValue(444, Lxml1);
4349 refarr->SetValue(445, Lxml2);
4350 // TDataStd_ByteArray:
4351 bytearr = TDataStd_ByteArray::Set(doc_xml->Main(), 15, 24);
4352 bytearr->SetValue(15, 0);
4353 bytearr->SetValue(16, 10);
4354 bytearr->SetValue(17, 100);
4355 bytearr->SetValue(18, 200);
4356 bytearr->SetValue(19, 250);
4357 bytearr->SetValue(20, 251);
4358 bytearr->SetValue(21, 252);
4359 bytearr->SetValue(22, 253);
4360 bytearr->SetValue(23, 254);
4361 bytearr->SetValue(24, 255);
4363 Lstd3 = doc_xml->Main().FindChild(103);
4364 ref = TDF_Reference::Set(doc_xml->Main(), Lstd3);
4367 //if (app->SaveAs(doc_xml, "W:\\doc.xml") != PCDM_SS_OK)
4368 if (app->SaveAs(doc_xml, aFile2) != PCDM_SS_OK)
4372 app->Close(doc_xml);
4374 //if (app->Open("W:\\doc.xml", doc_xml_open) != PCDM_RS_OK)
4375 if (app->Open(aFile2, doc_xml_open) != PCDM_RS_OK)
4377 if (!doc_xml_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4379 if (!doc_xml_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4381 if (intlist->First() != 1)
4383 if (intlist->Last() != 5)
4385 if (!doc_xml_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4387 if (dbllist->First() != 1.5)
4389 if (dbllist->Last() != 5.5)
4391 if (!doc_xml_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4393 if (strlist->First() != "Guten ")
4395 if (strlist->Last() != "Tag")
4397 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4399 if (boollist->First() != Standard_False)
4401 if (boollist->Last() != Standard_True)
4403 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4405 TDF_Tool::Entry(reflist->First(), entry_first);
4406 if (entry1 != entry_first)
4408 TDF_Tool::Entry(reflist->Last(), entry_last);
4409 if (entry2 != entry_last)
4411 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4413 if (boolarr->Value(15) != Standard_False)
4415 if (boolarr->Value(16) != Standard_True)
4417 if (boolarr->Value(17) != Standard_True)
4419 if (boolarr->Value(18) != Standard_True)
4421 if (boolarr->Value(19) != Standard_True)
4423 if (boolarr->Value(20) != Standard_True)
4425 if (boolarr->Value(21) != Standard_False)
4427 if (boolarr->Value(22) != Standard_True)
4429 if (boolarr->Value(23) != Standard_True)
4431 if (boolarr->Value(24) != Standard_True)
4433 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4435 TDF_Tool::Entry(refarr->Value(444), entry_first);
4436 if (entry1 != entry_first)
4438 TDF_Tool::Entry(refarr->Value(445), entry_last);
4439 if (entry2 != entry_last)
4441 if (!doc_xml_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4443 if (bytearr->Value(15) != 0)
4445 if (bytearr->Value(16) != 10)
4447 if (bytearr->Value(17) != 100)
4449 if (bytearr->Value(18) != 200)
4451 if (bytearr->Value(19) != 250)
4453 if (bytearr->Value(20) != 251)
4455 if (bytearr->Value(21) != 252)
4457 if (bytearr->Value(22) != 253)
4459 if (bytearr->Value(23) != 254)
4461 if (bytearr->Value(24) != 255)
4463 if (!doc_xml_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4465 if (ref->Get().IsNull())
4467 if (ref->Get().Tag() != 103)
4471 Handle(TDocStd_Document) doc_bin, doc_bin_open;
4472 app->NewDocument("BinOcaf", doc_bin);
4474 TDataStd_Tick::Set(doc_bin->Main());
4475 // TDataStd_IntegerList:
4476 intlist = TDataStd_IntegerList::Set(doc_bin->Main());
4479 // TDataStd_RealList:
4480 dbllist = TDataStd_RealList::Set(doc_bin->Main());
4481 dbllist->Append(1.5);
4482 dbllist->Append(5.5);
4483 // TDataStd_ExtStringList:
4484 strlist = TDataStd_ExtStringList::Set(doc_bin->Main());
4485 strlist->Append("Bonjour");
4486 strlist->Append("Bonsoir");
4487 // TDataStd_BooleanList:
4488 boollist = TDataStd_BooleanList::Set(doc_bin->Main());
4489 boollist->Append(Standard_False);
4490 boollist->Append(Standard_True);
4491 // TDataStd_ReferenceList:
4492 TDF_Label Lbin1 = doc_bin->Main().FindChild(100);
4493 TDF_Tool::Entry(Lbin1, entry1);
4494 TDF_Label Lbin2 = doc_bin->Main().FindChild(101);
4495 TDF_Tool::Entry(Lbin2, entry2);
4496 reflist = TDataStd_ReferenceList::Set(doc_bin->Main());
4497 reflist->Append(Lbin1);
4498 reflist->Append(Lbin2);
4499 // TDataStd_BooleanArray:
4500 boolarr = TDataStd_BooleanArray::Set(doc_bin->Main(), 15, 24);
4501 boolarr->SetValue(15, Standard_False);
4502 boolarr->SetValue(16, Standard_True);
4503 boolarr->SetValue(17, Standard_True);
4504 boolarr->SetValue(18, Standard_True);
4505 boolarr->SetValue(19, Standard_True);
4506 boolarr->SetValue(20, Standard_True);
4507 boolarr->SetValue(21, Standard_False);
4508 boolarr->SetValue(22, Standard_True);
4509 boolarr->SetValue(23, Standard_True);
4510 boolarr->SetValue(24, Standard_True);
4511 // TDataStd_ReferenceArray:
4512 refarr = TDataStd_ReferenceArray::Set(doc_bin->Main(), 0, 1);
4513 refarr->SetValue(0, Lbin1);
4514 refarr->SetValue(1, Lbin2);
4515 // TDataStd_ByteArray:
4516 bytearr = TDataStd_ByteArray::Set(doc_bin->Main(), 15, 16);
4517 bytearr->SetValue(15, 0);
4518 bytearr->SetValue(16, 255);
4519 // TDataStd_NamedData:
4520 nameddata = TDataStd_NamedData::Set(doc_bin->Main());
4521 nameddata->SetByte("A", 12);
4522 nameddata->SetByte("B", 234);
4524 Lstd3 = doc_bin->Main().FindChild(103);
4525 ref = TDF_Reference::Set(doc_bin->Main(), Lstd3);
4528 //if (app->SaveAs(doc_bin, "W:\\doc.cbf") != PCDM_SS_OK)
4529 if (app->SaveAs(doc_bin, aFile3) != PCDM_SS_OK)
4533 app->Close(doc_bin);
4535 //if (app->Open("W:\\doc.cbf", doc_bin_open) != PCDM_RS_OK)
4536 if (app->Open(aFile3, doc_bin_open) != PCDM_RS_OK)
4538 if (!doc_bin_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4540 if (!doc_bin_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4542 if (intlist->First() != 1)
4544 if (intlist->Last() != 5)
4546 if (!doc_bin_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4548 if (dbllist->First() != 1.5)
4550 if (dbllist->Last() != 5.5)
4552 if (!doc_bin_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4554 if (strlist->First() != "Bonjour")
4556 if (strlist->Last() != "Bonsoir")
4558 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4560 if (boollist->First() != Standard_False)
4562 if (boollist->Last() != Standard_True)
4564 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4566 TDF_Tool::Entry(reflist->First(), entry_first);
4567 if (entry1 != entry_first)
4569 TDF_Tool::Entry(reflist->Last(), entry_last);
4570 if (entry2 != entry_last)
4572 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4574 if (boolarr->Value(15) != Standard_False)
4576 if (boolarr->Value(16) != Standard_True)
4578 if (boolarr->Value(17) != Standard_True)
4580 if (boolarr->Value(18) != Standard_True)
4582 if (boolarr->Value(19) != Standard_True)
4584 if (boolarr->Value(20) != Standard_True)
4586 if (boolarr->Value(21) != Standard_False)
4588 if (boolarr->Value(22) != Standard_True)
4590 if (boolarr->Value(23) != Standard_True)
4592 if (boolarr->Value(24) != Standard_True)
4594 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4596 TDF_Tool::Entry(refarr->Value(0), entry_first);
4597 if (entry1 != entry_first)
4599 TDF_Tool::Entry(refarr->Value(1), entry_last);
4600 if (entry2 != entry_last)
4602 if (!doc_bin_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4604 if (bytearr->Value(15) != 0)
4606 if (bytearr->Value(16) != 255)
4608 if (!doc_bin_open->Main().FindAttribute(TDataStd_NamedData::GetID(), nameddata))
4610 if (nameddata->GetByte("A") != 12)
4612 if (nameddata->GetByte("B") != 234)
4614 if (!doc_bin_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4616 if (ref->Get().IsNull())
4618 if (ref->Get().Tag() != 103)
4623 // For OCC16782 testing
4625 static Standard_Integer OCC16782 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4629 di << "Usage : " << argv[0] << " file.std file.xml file.cbf\n";
4632 TCollection_ExtendedString aFile1(argv[1]);
4633 TCollection_ExtendedString aFile2(argv[2]);
4634 TCollection_ExtendedString aFile3(argv[3]);
4637 app = new AppStd_Application();
4641 Handle(TDocStd_Document) doc;
4642 app->NewDocument("MDTV-Standard", doc);
4643 doc->SetUndoLimit(10);
4645 di <<"\nTestSetGet start\n";
4646 good += TestSetGet(doc);
4647 di <<"TestSetGet finish\n";
4648 di <<"Status = " << good << "\n";
4650 di <<"\nTestUndoRedo start\n";
4651 good += TestUndoRedo(doc);
4652 di <<"TestUndoRedo finish\n";
4653 di <<"Status = " << good << "\n";
4655 di <<"\nTestCopyPaste start\n";
4656 good += TestCopyPaste(doc);
4657 di <<"TestCopyPaste finish\n";
4658 di <<"Status = " << good << "\n";
4660 di <<"\nTestOpenSave start\n";
4661 good += TestOpenSave(aFile1, aFile2, aFile3);
4662 di <<"TestOpenSave finish\n";
4663 di <<"Status = " << good << "\n";
4666 di <<"\nThe " << argv[0] << " test is passed well, OK\n";
4668 di <<"\nThe " << argv[0] << " test failed, Faulty\n";
4673 static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4675 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4676 if(aContext.IsNull()) {
4677 di << argv[0] << " ERROR : use 'vinit' command before " << "\n";
4683 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4686 Standard_Integer mode = 0;
4689 mode = atoi(argv[1]);
4691 if (mode > 2 || mode < 0)
4693 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4696 Handle(V3d_View) V = ViewerTest::CurrentView();
4697 if ( !V.IsNull() ) {
4699 V->ColorScaleDisplay();
4702 V->ColorScaleErase();
4707 Standard_Boolean IsDisplayed = V->ColorScaleIsDisplayed();
4709 di <<"ColorScaleIsDisplayed = " << "1" << "\n";
4711 di <<"ColorScaleIsDisplayed = " << "0" << "\n";
4717 #include <Interface_Macros.hxx>
4718 #include <IGESControl_Controller.hxx>
4719 #include <XSDRAW.hxx>
4720 #include <Draw_ProgressIndicator.hxx>
4721 #include <XSControl_WorkSession.hxx>
4722 #include <Transfer_TransientProcess.hxx>
4723 #include <XSDRAW_Commands.hxx>
4724 #include <TColStd_HSequenceOfTransient.hxx>
4725 #include <Message_ProgressSentry.hxx>
4726 #include <XSControl_TransferReader.hxx>
4728 static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4730 DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
4731 if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
4733 // Progress indicator
4734 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
4735 progress->SetScale ( 0, 100, 1 );
4738 IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
4740 ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
4742 TCollection_AsciiString fnom,rnom;
4744 Standard_Boolean modfic = XSDRAW::FileAndVar
4745 (argv[1],argv[2],"IGESBREP",fnom,rnom);
4746 if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
4747 else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
4748 di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
4749 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
4752 OSD_Timer Chr; Chr.Reset();
4758 progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
4762 //In order to decrease number of produced edges during translation it is possible to set following parameter
4763 Interface_Static::SetIVal("read.iges.bspline.continuity",0);
4766 if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
4767 else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
4769 progress->EndScope();
4772 if (readstat != IFSelect_RetDone) {
4773 if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon"<<"\n";
4774 else di<<"No model loaded"<<"\n";
4777 // Choice of treatment
4778 Standard_Boolean fromtcl = (argc > 3);
4779 Standard_Integer modepri = 1, nent, nbs;
4780 if (fromtcl) modepri = 4;
4783 //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka
4784 //mode OnlyVisible does not work.
4785 // nent = Reader.NbRootsForTransfer();
4787 cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<flush;
4790 // amv 26.09.2003 : this is used to avoid error of enter's simbol
4793 modepri = atoi(str);
4796 if (modepri == 0) { //fin
4797 di << "Bye and good luck! " << "\n";
4801 else if (modepri <= 2) { // 1 : Visible Roots, 2 : All Roots
4802 di << "All Geometry Transfer"<<"\n";
4803 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
4804 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
4805 Handle(XSControl_WorkSession) thesession = Reader.WS();
4806 thesession->ClearContext();
4807 XSDRAW::SetTransferProcess (thesession->MapReader());
4808 progress->NewScope ( 80, "Translation" );
4810 thesession->MapReader()->SetProgress ( progress );
4812 if (modepri == 1) Reader.SetReadVisible (Standard_True);
4813 Reader.TransferRoots();
4815 thesession->MapReader()->SetProgress ( 0 );
4816 progress->EndScope();
4818 // result in only one shape for all the roots
4819 // or in one shape for one root.
4820 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
4821 Standard_Integer answer = 1;
4822 if (Reader.NbShapes() > 1) {
4823 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;
4828 answer = atoi(str_a);
4830 if ( answer == 0) continue;
4831 if ( answer == 1 || answer == 3) {
4832 TopoDS_Shape shape = Reader.OneShape();
4834 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
4836 sprintf(fname, "%s", rnom.ToCString());
4837 di << "Saving shape in variable Draw : " << fname << "\n";
4838 if (answer == 3) IGESToBRep::WriteShape (shape,1);
4841 DBRep::Set(fname,shape);
4843 catch(Standard_Failure) {
4844 di << "** Exception : ";
4845 di << Standard_Failure::Caught()->GetMessageString();
4846 di<<" ** Skip"<<"\n";
4847 di << "Saving shape in variable Draw : " << fname << "\n";
4848 IGESToBRep::WriteShape (shape,1);
4852 else if (answer == 2 || answer == 4) {
4853 Standard_Integer numshape = Reader.NbShapes();
4854 for (Standard_Integer inum = 1; inum <= numshape; inum++) {
4855 // save all the shapes
4856 TopoDS_Shape shape = Reader.Shape(inum);
4857 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
4859 sprintf(fname, "%s_%d", rnom.ToCString(),inum);
4860 di << "Saving shape in variable Draw : " << fname << "\n";
4861 if (answer == 4) IGESToBRep::WriteShape (shape,inum);
4864 DBRep::Set(fname,shape);
4866 catch(Standard_Failure) {
4867 di << "** Exception : ";
4868 di << Standard_Failure::Caught()->GetMessageString();
4869 di<<" ** Skip"<<"\n";
4876 else if (modepri == 3) { // One Entity
4877 cout << "Only One Entity"<<endl;
4878 cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<endl;
4879 cout<<" To modify : command param read.iges.bspline.continuity"<<endl;
4880 cout << " give the number of the Entity : " << flush;
4881 nent = XSDRAW::GetEntityNumber();
4883 if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
4885 nbs = Reader.NbShapes();
4886 char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nent);
4887 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
4888 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
4889 TopoDS_Shape sh = Reader.Shape(nbs);
4890 DBRep::Set (shname,sh);
4894 else if (modepri == 4) { // Selection
4895 Standard_Integer answer = 1;
4896 Handle(TColStd_HSequenceOfTransient) list;
4898 // Selection, nommee ou via tcl. tcl : raccourcis admis
4899 // * donne iges-visible + xst-transferrable-roots
4900 // *r donne xst-model-roots (TOUTES racines)
4902 if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {
4903 di << "All Geometry Transfer"<<"\n";
4904 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
4905 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
4906 Handle(XSControl_WorkSession) thesession = Reader.WS();
4907 thesession->ClearContext();
4908 XSDRAW::SetTransferProcess (thesession->MapReader());
4909 progress->NewScope ( 80, "Translation" );
4911 thesession->MapReader()->SetProgress ( progress );
4913 Reader.SetReadVisible (Standard_True);
4914 Reader.TransferRoots();
4916 thesession->MapReader()->SetProgress ( 0 );
4917 progress->EndScope();
4920 // result in only one shape for all the roots
4921 TopoDS_Shape shape = Reader.OneShape();
4924 sprintf(fname, "%s", rnom.ToCString());
4925 di << "Saving shape in variable Draw : " << fname << "\n";
4928 DBRep::Set(fname,shape);
4930 catch(Standard_Failure) {
4931 di << "** Exception : ";
4932 di << Standard_Failure::Caught()->GetMessageString();
4933 di<<" ** Skip"<<"\n";
4934 di << "Saving shape in variable Draw : " << fname << "\n";
4935 IGESToBRep::WriteShape (shape,1);
4941 modepri = 0; // d office, une seule passe
4942 if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
4944 list = XSDRAW::GetList ("xst-model-roots");
4947 TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
4948 di<<"List given by "<<compart.ToCString()<<" : ";
4949 list = XSDRAW::GetList (compart.ToCString());
4951 if (list.IsNull()) {
4952 di<<"No list defined. Give a selection name or * for all visible transferrable roots"<<"\n";
4957 cout<<"Name of Selection :"<<flush;
4958 list = XSDRAW::GetList();
4959 if (list.IsNull()) { cout<<"No list defined"<<endl; continue; }
4962 Standard_Integer nbl = list->Length();
4963 di<<"Nb entities selected : "<<nbl<<"\n";
4964 if (nbl == 0) continue;
4967 cout<<"Choice: 0 abandon 1 transfer all 2 with confirmation 3 list n0s ents :"<<flush;
4970 char str_answer[80];
4972 answer = atoi(str_answer);
4974 if (answer <= 0 || answer > 3) continue;
4976 for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
4977 Handle(Standard_Transient) ent = list->Value(ill);
4978 di<<" ";// model->Print(ent,di);
4982 if (answer == 1 || answer == 2) {
4983 Standard_Integer nbt = 0;
4984 Handle(XSControl_WorkSession) thesession = Reader.WS();
4986 XSDRAW::SetTransferProcess (thesession->MapReader());
4987 progress->NewScope ( 80, "Translation" );
4989 thesession->MapReader()->SetProgress ( progress );
4991 Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
4992 for (Standard_Integer ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
4994 nent = Reader.Model()->Number(list->Value(ill));
4995 if (nent == 0) continue;
4996 if (!Reader.TransferOne(nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
4998 nbs = Reader.NbShapes();
4999 char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
5000 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
5001 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
5002 TopoDS_Shape sh = Reader.Shape(nbs);
5003 DBRep::Set (shname,sh);
5007 thesession->MapReader()->SetProgress ( 0 );
5008 progress->EndScope();
5010 di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
5011 answer = 0; // on ne reboucle pas
5015 else di<<"Unknown mode n0 "<<modepri<<"\n";
5019 //In order to clear memory after IGES reading you could add the following code
5020 Handle(XSControl_TransferReader) TR = Reader.WS()->TransferReader();
5021 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
5024 Reader.WS()->Model()->Clear();
5025 Standard_Integer i =1;
5027 Reader.WS()->ClearData(i);
5033 #include <Geom_Plane.hxx>
5034 static Standard_Integer OCC20766 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5038 di << "Usage : " << argv[0] << " plane a b c d\n";
5042 Standard_Real A = atof(argv[2]);
5043 Standard_Real B = atof(argv[3]);
5044 Standard_Real C = atof(argv[4]);
5045 Standard_Real D = atof(argv[5]);
5047 Handle(Geom_Geometry) result;
5049 Handle(Geom_Plane) aPlane = new Geom_Plane(A, B, C, D);
5052 DrawTrSurf::Set(argv[1],result);
5056 static Standard_Integer OCC20627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5060 di << "Usage : " << argv[0] << " MaxNbr" << "\n";
5063 Standard_Integer aMaxNbr = atoi(argv[1]);
5065 for (Standard_Integer i=0;i<aMaxNbr;i++)
5067 BRepBuilderAPI_MakePolygon w(gp_Pnt(0,0,0),gp_Pnt(0,100,0),gp_Pnt(20,100,0),gp_Pnt(20,0,0));
5069 TopoDS_Wire wireShape( w.Wire());
5070 BRepBuilderAPI_MakeFace faceBuilder(wireShape);
5071 TopoDS_Face f( faceBuilder.Face());
5072 BRepMesh_IncrementalMesh im(f,1);
5073 BRepTools::Clean(f);
5078 #include <IntCurvesFace_ShapeIntersector.hxx>
5079 #include <gp_Lin.hxx>
5080 Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5084 di << "Usage : " << argv[0] << " shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf" << "\n";
5088 TopoDS_Shape shape = DBRep::Get(argv[1]);
5090 if (shape.IsNull()) {
5091 di<<" Null shape is not allowed";
5095 Standard_Real X_Pnt = atof(argv[2]);
5096 Standard_Real Y_Pnt = atof(argv[3]);
5097 Standard_Real Z_Pnt = atof(argv[4]);
5099 Standard_Real X_Dir = atof(argv[5]);
5100 Standard_Real Y_Dir = atof(argv[6]);
5101 Standard_Real Z_Dir = atof(argv[7]);
5103 Standard_Real PInf = atof(argv[8]);
5105 IntCurvesFace_ShapeIntersector intersector;
5106 intersector.Load(shape, Precision::Intersection());
5108 gp_Pnt origin(X_Pnt, Y_Pnt, Z_Pnt);
5109 gp_Dir dir(X_Dir, Y_Dir, Z_Dir);
5110 gp_Lin ray(origin, dir);
5112 Standard_Real PSup = RealLast();
5113 intersector.PerformNearest(ray, PInf, PSup);
5114 if (intersector.NbPnt() != 0)
5116 di << argv[0] << " status = 0 \n";
5117 Standard_Real w = intersector.WParameter(1);
5118 di << "w = " << w << "\n";
5120 di << argv[0] << " status = -1 \n";
5125 Standard_Integer OCC22301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5128 di << "Usage : " << argv[0] << "\n";
5132 // Create mask 1111: extent == 4
5133 TColStd_PackedMapOfInteger aFullMask;
5134 for (Standard_Integer i = 0; i < 4; i++)
5137 // Create mask 1100: extent == 2
5138 TColStd_PackedMapOfInteger aPartMask;
5139 for (Standard_Integer i = 0; i < 2; i++)
5142 di << "aFullMask = 1111" << "\n";
5143 di << "aPartMask = 1100" << "\n";
5145 Standard_Boolean isAffected;
5147 isAffected = aFullMask.Intersect(aPartMask); // true; extent == 2 (OK)
5148 di << "First time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5149 isAffected = aFullMask.Intersect(aPartMask); // true; extent == 0 (?)
5150 di << "Second time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5151 isAffected = aFullMask.Subtract(aPartMask); // false (?)
5152 di << "After two intersections: aFullMask.Subtract(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5156 #include <ShapeFix_FixSmallFace.hxx>
5157 Standard_Integer OCC22586 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5161 di << "Usage : " << argv[0] << " shape resshape\n";
5165 // try to read a shape:
5166 TopoDS_Shape aShape=DBRep::Get(argv[1]);
5167 ShapeFix_FixSmallFace aFixSmallFaces;
5168 aFixSmallFaces.Init (aShape);
5169 aFixSmallFaces.Perform();
5170 TopoDS_Shape aResShape = aFixSmallFaces.Shape();
5171 DBRep::Set(argv[2],aResShape);
5177 #include <NCollection_DataMap.hxx>
5178 Standard_Integer OCC22744 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5182 di << "Usage : " << argv[0] << "\n";
5186 TCollection_ExtendedString anExtString;
5188 Standard_ExtCharacter aNonAsciiChar = 0xff00;
5189 anExtString.Insert(1, aNonAsciiChar);
5191 di << "Is ASCII: " << ( anExtString.IsAscii() ? "true" : "false" ) << "\n";
5192 NCollection_DataMap<TCollection_ExtendedString, Standard_Integer> aMap;
5193 aMap.Bind(anExtString, 0);
5199 Standard_Integer OCC22736 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5203 di << "Usage : " << argv[0] << " X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2\n";
5207 Standard_Real X_mirrorFirstPoint = atof(argv[1]);
5208 Standard_Real Y_mirrorFirstPoint = atof(argv[2]);
5209 Standard_Real X_mirrorSecondPoint = atof(argv[3]);
5210 Standard_Real Y_mirrorSecondPoint = atof(argv[4]);
5211 Standard_Real X_p1 = atof(argv[5]);
5212 Standard_Real Y_p1 = atof(argv[6]);
5213 Standard_Real X_p2 = atof(argv[7]);
5214 Standard_Real Y_p2 = atof(argv[8]);
5216 gp_Trsf2d identityTransformation;
5218 gp_Pnt2d mirrorFirstPoint(X_mirrorFirstPoint,Y_mirrorFirstPoint);
5219 gp_Pnt2d mirrorSecondPoint(X_mirrorSecondPoint,Y_mirrorSecondPoint);
5220 gp_Ax2d mirrorAxis(mirrorFirstPoint,gp_Vec2d(mirrorFirstPoint,mirrorSecondPoint));
5222 gp_Pnt2d p1(X_p1,Y_p1);
5223 gp_Pnt2d p2(X_p2,Y_p2);
5226 M1.SetMirror(mirrorAxis);
5228 M2.SetMirror(mirrorAxis);
5230 Tcomp = M2.Multiplied(M1);
5232 Standard_Real aTol = Precision::Confusion();
5233 Standard_Integer aStatus = 0;
5235 //After applying two times the same mirror the point is located on the same location OK
5236 gp_Pnt2d p1MirrorM1 = p1.Transformed(M1);
5237 if ( Abs(p2.X() - p1MirrorM1.X()) > aTol )
5239 if ( Abs(p2.Y() - p1MirrorM1.Y()) > aTol )
5242 gp_Pnt2d p1MirrorM1M2 = p1MirrorM1.Transformed(M2);
5243 if ( Abs(p1.X() - p1MirrorM1M2.X()) > aTol )
5245 if ( Abs(p1.Y() - p1MirrorM1M2.Y()) > aTol )
5248 //If we apply the composed transformation of the same two mirrors to a point the result is //not located on the initial position.-->>ERROR
5249 gp_Pnt2d p1MirrorComp = p1.Transformed(Tcomp);
5250 if ( Abs(p1.X() - p1MirrorComp.X()) > aTol )
5252 if ( Abs(p1.Y() - p1MirrorComp.Y()) > aTol )
5255 di << "Status = " << aStatus << "\n";
5259 void QAOCC::Commands(Draw_Interpretor& theCommands) {
5260 const char *group = "QAOCC";
5262 theCommands.Add("OCC128", "OCC128", __FILE__, OCC128, group);
5264 // Remove as bad version of QAAddOrRemoveSelected from QADraw
5265 //theCommands.Add("OCC129", "OCC129 shape islocal", __FILE__, OCC129, group);
5267 theCommands.Add("OCC136", "OCC136", __FILE__, OCC136, group);
5268 theCommands.Add("BUC60610","BUC60610 iges_input [name]",__FILE__,BUC60610,group);
5269 theCommands.Add("BUC60661","BUC60661 file.igs",__FILE__,BUC60661, group);
5271 //====================================================
5273 // Following commands are inserted from
5274 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
5275 // ( 75455 Apr 16 18:59)
5277 //====================================================
5279 theCommands.Add("OCC105","OCC105 shape",__FILE__,OCC105,group);
5280 theCommands.Add("OCC9"," result path cur1 cur2 radius [tolerance]:\t test GeomFill_Pipe", __FILE__, pipe_OCC9,group);
5282 theCommands.Add("OCC125","OCC125 shell", __FILE__, OCC125,group);
5284 theCommands.Add("OCC157","findplanarsurface Result wire Tol",__FILE__,OCC157,group);
5285 //theCommands.Add("OCC165","OCC165",__FILE__,OCC165,group);
5286 theCommands.Add("OCC165","OCC165 file",__FILE__,OCC165,group);
5287 theCommands.Add("OCC297","OCC297",__FILE__,OCC297,group);
5288 //theCommands.Add("OCC305","OCC305",__FILE__,OCC305,group);
5289 theCommands.Add("OCC305","OCC305 file",__FILE__,OCC305,group);
5292 theCommands.Add("OCC166", "OCC166", __FILE__, OCC166, group);
5293 theCommands.Add("OCC381_Save", "OCC381_Save Doc", __FILE__, OCC381_Save, group);
5294 theCommands.Add("OCC381_SaveAs", "OCC381_SaveAs Doc Path", __FILE__, OCC381_SaveAs, group);
5296 theCommands.Add("OCC299","OCC299 Solid Point [Tolerance=1.e-7]", __FILE__, OCC299bug, group);
5297 theCommands.Add("OCC309","OCC309", __FILE__, OCC309bug, group);
5298 theCommands.Add("OCC310","OCC310", __FILE__, OCC310bug, group);
5300 //theCommands.Add("OCC277","OCC277", __FILE__, OCC277bug, group);
5301 theCommands.Add("OCC277","OCC277 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC277bug, group);
5303 theCommands.Add("OCC333","OCC333 edge1 edge2 [toler domaindist]; Check overlapping edges", __FILE__, OCC333bug, group);
5305 theCommands.Add("OCC363", "OCC363 document filename ", __FILE__, OCC363, group);
5307 //theCommands.Add("OCC372", "OCC372", __FILE__, OCC372, group);
5308 theCommands.Add("OCC377", "OCC377", __FILE__, OCC377, group);
5309 theCommands.Add("OCC22", "OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation", __FILE__, OCC22, group);
5310 theCommands.Add("OCC24", "OCC24 Result Shape CompoundOfSubshapes ResourceFileName", __FILE__, OCC24, group);
5311 theCommands.Add("OCC369", "OCC369 Shape", __FILE__, OCC369, group);
5312 theCommands.Add("OCC524", "OCC524 LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix", __FILE__, OCC524, group);
5313 theCommands.Add("OCC525", "OCC525", __FILE__, OCC525, group);
5314 theCommands.Add("OCC543", "OCC543 name", __FILE__, OCC543, group);
5315 //theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
5316 theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC578, group);
5317 theCommands.Add("OCC627", "OCC627", __FILE__, OCC627, group);
5318 theCommands.Add("OCC749_sav", "OCC749_sav Reflection(=0/1) R1 G1 B1 R2 G2 B2", __FILE__, OCC749_sav, group);
5319 theCommands.Add("OCC669", "OCC669 GUID", __FILE__, OCC669, group);
5320 theCommands.Add("OCC738_ShapeRef", "OCC738_ShapeRef", __FILE__, OCC738_ShapeRef, group);
5321 theCommands.Add("OCC738_Assembly", "OCC738_Assembly", __FILE__, OCC738_Assembly, group);
5322 theCommands.Add("OCC708", "OCC708 shape ; Deactivate the current transformation", __FILE__, OCC708, group);
5323 theCommands.Add("OCC670", "OCC670", __FILE__, OCC670, group);
5324 theCommands.Add("OCC867", "OCC867 Point Surface Umin Usup Vmin Vsup", __FILE__, OCC867, group);
5325 theCommands.Add("OCC909", "OCC909 wire face", __FILE__, OCC909, group);
5326 theCommands.Add("OCC921", "OCC921 face", __FILE__, OCC921, group);
5327 theCommands.Add("OCC902", "OCC902 expression", __FILE__, OCC902, group);
5329 theCommands.Add ("OCC1029_AISTransparency","OCC1029_AISTransparency (DOC, entry, [real])",__FILE__, OCC1029_AISTransparency, group);
5330 theCommands.Add ("OCC1030_AISColor", "OCC1030_AISColor (DOC, entry, [color])", __FILE__, OCC1030_AISColor, group);
5331 theCommands.Add ("OCC1031_AISMaterial", "OCC1031_AISMaterial (DOC, entry, [material])", __FILE__, OCC1031_AISMaterial, group);
5332 theCommands.Add ("OCC1032_AISWidth", "OCC1032_AISWidth (DOC, entry, [width])", __FILE__, OCC1032_AISWidth, group);
5333 theCommands.Add ("OCC1033_AISMode", "OCC1033_AISMode (DOC, entry, [mode])", __FILE__, OCC1033_AISMode, group);
5334 theCommands.Add ("OCC1034_AISSelectionMode", "OCC1034_AISSelectionMode (DOC, entry, [selectionmode])", __FILE__, OCC1034_AISSelectionMode, group);
5336 //theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape", __FILE__, OCC1487, group);
5337 theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC1487, group);
5339 theCommands.Add("OCC1077", "OCC1077 result", __FILE__, OCC1077, group);
5340 theCommands.Add("OCC5739", "OCC5739 name shape step", __FILE__, OCC5739_UniAbs, group);
5341 theCommands.Add("OCC6046", "OCC6046 nb_of_vectors size", __FILE__, OCC6046, group);
5342 theCommands.Add("OCC5698", "OCC5698 wire", __FILE__, OCC5698, group);
5343 theCommands.Add("OCC6143", "OCC6143", __FILE__, OCC6143, group);
5344 theCommands.Add("OCC7141", "OCC7141 [nCount]", __FILE__, OCC7141, group);
5345 theCommands.Add("OCC7372", "OCC7372", __FILE__, OCC7372, group);
5346 theCommands.Add("OCC8169", "OCC8169 edge1 edge2 plane", __FILE__, OCC8169, group);
5347 theCommands.Add("OCC10138", "OCC10138 lower upper", __FILE__, OCC10138, group);
5348 theCommands.Add("OCC7639", "OCC7639 index1 value1 ... [indexN valueN]", __FILE__, OCC7639, group);
5349 theCommands.Add("OCC8797", "OCC8797", __FILE__, OCC8797, group);
5350 theCommands.Add("OCC7068", "OCC7068", __FILE__, OCC7068, group);
5351 theCommands.Add("OCC11457", "OCC11457 polygon lastedge x1 y1 z1 x2 y2 z2 ...", __FILE__, OCC11457, group);
5352 theCommands.Add("OCC13963", "OCC13963 ratio origin_x origin_y origin_z", __FILE__, OCC13963, group);
5353 theCommands.Add("OCC14376", "OCC14376 shape [deflection]", __FILE__, OCC14376, group);
5354 theCommands.Add("OCC15489", "OCC15489 A B C", __FILE__, OCC15489, group);
5355 theCommands.Add("OCC15755", "OCC15755 file shape", __FILE__, OCC15755, group);
5356 theCommands.Add("OCC16782", "OCC16782 file.std file.xml file.cbf", __FILE__, OCC16782, group);
5357 theCommands.Add("OCC12584", "OCC12584 [mode = 0/1/2]", __FILE__, OCC12584, group);
5358 theCommands.Add("OCC18612", "OCC18612 [file else already loaded model] [name DRAW]", __FILE__, OCC18612igesbrep, group);
5359 theCommands.Add("OCC20766", "OCC20766 plane a b c d", __FILE__, OCC20766, group);
5360 theCommands.Add("OCC20627", "OCC20627", __FILE__, OCC20627, group);
5361 theCommands.Add("OCC17424", "OCC17424 shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf", __FILE__, OCC17424, group);
5362 theCommands.Add("OCC22301", "OCC22301", __FILE__, OCC22301, group);
5363 theCommands.Add("OCC22586", "OCC22586 shape resshape", __FILE__, OCC22586, group);
5364 theCommands.Add("OCC22736", "OCC22736 X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2", __FILE__, OCC22736, group);
5365 theCommands.Add("OCC22744", "OCC22744", __FILE__, OCC22744, group);