1 // Created on: 2002-03-20
2 // Created by: QA Admin
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
26 #include <Draw_Interpretor.hxx>
28 #include <DrawTrSurf.hxx>
29 #include <AIS_InteractiveContext.hxx>
30 #include <ViewerTest.hxx>
31 #include <AIS_Shape.hxx>
32 #include <TopoDS_Shape.hxx>
34 #include <Geom_Axis2Placement.hxx>
36 #include <gp_Trsf.hxx>
37 #include <AIS_Trihedron.hxx>
38 #include <BRepPrimAPI_MakeBox.hxx>
39 #include <Graphic3d_MaterialAspect.hxx>
40 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
41 #include <TopoDS_Solid.hxx>
42 #include <BRepPrimAPI_MakeSphere.hxx>
43 #include <BRepPrimAPI_MakeCone.hxx>
44 #include <BRepPrimAPI_MakeCylinder.hxx>
45 #include <IGESToBRep_Reader.hxx>
46 #include <TopExp_Explorer.hxx>
48 #include <GCPnts_UniformDeflection.hxx>
49 #include <BRepAdaptor_Curve.hxx>
50 #include <IGESToBRep.hxx>
51 #include <V3d_Viewer.hxx>
52 #include <BRepAdaptor_CompCurve.hxx>
53 #include <GCPnts_AbscissaPoint.hxx>
54 #include <Standard_ErrorHandler.hxx>
55 #include <Standard_Overflow.hxx>
56 #include <Standard_Underflow.hxx>
57 #include <Standard_DivideByZero.hxx>
58 #include <OSD_SIGSEGV.hxx>
59 #include <OSD_Exception_ACCESS_VIOLATION.hxx>
60 #include <OSD_Exception_STACK_OVERFLOW.hxx>
62 #include <STEPCAFControl_Writer.hxx>
63 #include <STEPControl_StepModelType.hxx>
64 #include <Interface_Static.hxx>
65 #include <IFSelect_ReturnStatus.hxx>
66 #include <Standard_Failure.hxx>
67 #include <TColgp_HArray1OfPnt2d.hxx>
68 #include <Geom2dAPI_Interpolate.hxx>
69 #include <Geom2d_BSplineCurve.hxx>
70 #include <Geom2dConvert_BSplineCurveToBezierCurve.hxx>
71 #include <Geom2d_BezierCurve.hxx>
72 #include <BRep_Tool.hxx>
73 #include <GeomProjLib.hxx>
74 #include <Geom2dAPI_InterCurveCurve.hxx>
75 #include <IntRes2d_IntersectionSegment.hxx>
76 #include <TDataStd_RealArray.hxx>
77 #include <TDF_CopyLabel.hxx>
78 #include <NCollection_Vector.hxx>
79 #include <TColStd_Array1OfInteger.hxx>
80 #include <Geom_BSplineCurve.hxx>
81 #include <TColgp_Array1OfPnt.hxx>
82 #include <AIS_ListOfInteractive.hxx>
83 #include <AIS_ListIteratorOfListOfInteractive.hxx>
84 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
85 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
86 #include <BRepBuilderAPI_MakePolygon.hxx>
87 #include <gp_GTrsf.hxx>
88 #include <Poly_Triangulation.hxx>
89 #include <IGESControl_Reader.hxx>
90 #include <IGESData_IGESModel.hxx>
91 #include <IGESData_IGESEntity.hxx>
92 #include <V3d_View.hxx>
97 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
99 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
102 static Standard_Integer OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
104 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
105 if(myAISContext.IsNull()) {
106 di << "use 'vinit' command before " << argv[0] ;
110 Handle(Geom_Axis2Placement) aTrihedronAxis = new Geom_Axis2Placement(gp::XOY());
113 trsf1.SetTranslation(gp_Vec(100, 100, 0));
114 aTrihedronAxis->Transform(trsf1);
115 Handle(AIS_Trihedron) myTrihedron = new AIS_Trihedron(aTrihedronAxis);
116 myTrihedron->SetColor(Quantity_NOC_LIGHTSTEELBLUE4);
117 myTrihedron->SetSize(100);
118 myAISContext->Display(myTrihedron, Standard_True);
120 // TopoDS_Shape shape1 = (TopoDS_Shape) BRepPrimAPI_MakeBox(50,50,50);
121 TopoDS_Shape shape1 = BRepPrimAPI_MakeBox(50,50,50).Shape();
122 Handle(AIS_Shape) AS = new AIS_Shape(shape1);
123 AS->SetDisplayMode(1);
124 Graphic3d_MaterialAspect mat(Graphic3d_NOM_PLASTIC);
125 AS->SetMaterial(mat);
126 AS->SetColor(Quantity_NOC_RED);
127 myAISContext->Display(AS);
130 TouchTrsf.SetTranslation(gp_Vec(20, 20, 0));
132 myAISContext->ResetLocation(AS);
133 myAISContext->SetLocation(AS , TouchTrsf) ;
134 myAISContext->Redisplay(AS, Standard_True);
139 // Remove as bad version of QAAddOrRemoveSelected from QADraw
140 //static Standard_Integer OCC129 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
143 // di<<"Usage : " << argv[0] << " shape islocal\n";
147 // Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
149 // // ViewerTest_DoubleMapOfInteractiveAndName& aMap =
150 // // ViewerTest::GetDataMapOfAIS ();
151 // ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
153 // TCollection_AsciiString aName(argv[1]);
154 // Handle(AIS_InteractiveObject) AISObj;
156 // if(aMap.IsBound2(aName)) {
157 // AISObj = aMap.Find2(aName);
158 // if(AISObj.IsNull()){
159 // di<<"No interactive object \n";
163 // Standard_Integer aNum = -1;
165 // if(atoi(argv[2])) {
166 // aNum = anAISCtx->OpenLocalContext();
169 // if(anAISCtx->HasOpenedContext()){
170 // anAISCtx->InitSelected();
171 // anAISCtx->AddOrRemoveSelected(AISObj);
174 // anAISCtx->InitCurrent();
175 // anAISCtx->AddOrRemoveCurrentObject(AISObj);
179 // // anAISCtx->CloseLocalContext(aNum);
184 // //select this shape:
186 // di<<"Use 'vdisplay' before";
191 static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
194 di<<"Usage: OCC136\n";
198 //create some primitives:
200 Standard_Real Size=100;
201 gp_Pnt P0(0,0,0), P1(Size,Size,Size);
203 TopoDS_Solid aBox = BRepPrimAPI_MakeBox(P0,P1);
205 TopoDS_Solid aSphere = BRepPrimAPI_MakeSphere (Size*0.5);
207 gp_Ax2 anAx2(P1, gp_Dir(1,1,1));
208 TopoDS_Solid aCone = BRepPrimAPI_MakeCone(anAx2, Size*0.7, Size*0.3, Size);
210 anAx2.SetLocation(gp_Pnt(Size,0,0));
211 anAx2.SetDirection(gp_Dir(-1,-1,1));
212 TopoDS_Solid aCyl = BRepPrimAPI_MakeCylinder(anAx2, Size*0.5, Size);
214 Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
215 if(anAISCtx.IsNull()){
216 di<<"Null interactive context. Use 'vinit' at first.\n";
220 if(anAISCtx->HasOpenedContext()) anAISCtx->CloseAllContexts();
221 anAISCtx->EraseAll();
223 //load primitives to context
224 Handle(AIS_Shape) aSh1 = new AIS_Shape(aBox);
225 anAISCtx->Display(aSh1);
227 Handle(AIS_Shape) aSh2 = new AIS_Shape(aSphere);
228 anAISCtx->Display(aSh2);
230 Handle(AIS_Shape) aSh3 = new AIS_Shape(aCone);
231 anAISCtx->Display(aSh3);
233 Handle(AIS_Shape) aSh4 = new AIS_Shape(aCyl);
234 anAISCtx->Display(aSh4);
237 anAISCtx->InitCurrent();
238 anAISCtx->AddOrRemoveCurrentObject(aSh1);
239 anAISCtx->AddOrRemoveCurrentObject(aSh2);
240 anAISCtx->AddOrRemoveCurrentObject(aSh3);
241 anAISCtx->AddOrRemoveCurrentObject(aSh4);
243 //remove all this objects from context
244 anAISCtx->Clear(aSh1, Standard_False);
245 anAISCtx->Clear(aSh2, Standard_False);
246 anAISCtx->Clear(aSh3, Standard_False);
247 anAISCtx->Clear(aSh4, Standard_False);
251 static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
253 printf("Usage: %s iges_input [name]\n",argv[0]);
256 Standard_Character *Ch;
259 Ch = new Standard_Character[strlen(argv[2])+3];
261 IGESToBRep_Reader IR;
262 IR.LoadFile (argv[1]);
265 TopoDS_Shape aTopShape = IR.OneShape();
266 TopExp_Explorer ex(aTopShape, TopAbs_EDGE);
267 Standard_Integer i=0;
268 for( ; ex.More(); ex.Next()){
269 const TopoDS_Edge &E = TopoDS::Edge(ex.Current());
270 BRepAdaptor_Curve aCurve(E);
271 GCPnts_UniformDeflection plin(aCurve, 0.1);
272 di << "Num points = " << plin.NbPoints() << "\n";
275 sprintf(Ch,"%s_%i",argv[2],1);
282 static Standard_Integer BUC60661(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
286 di << "Usage : " << a[0] << " file.igs" << "\n";
290 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
292 if(myContext.IsNull()) {
293 di << "use 'vinit' command before " << a[0] << "\n";
298 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
299 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
301 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
304 Standard_Character *file1 = new Standard_Character [strlen(DD)+strlen(a[1])+2];
305 sprintf(file1,"%s/%s",DD,a[1]);
307 IGESToBRep_Reader reader;
308 Standard_Integer status = reader.LoadFile(file1);
311 reader.TransferRoots();
312 TopoDS_Shape shape = reader.OneShape();
314 Handle(AIS_Shape) importedShape = new AIS_Shape(shape);
316 Handle(V3d_Viewer) myPView = myContext->CurrentViewer();
318 if( ! myPView.IsNull() && (myPView->DefaultVisualization() == V3d_WIREFRAME) )
319 importedShape->SetDisplayMode(AIS_WireFrame);
320 else importedShape->SetDisplayMode(AIS_Shaded);
321 myContext->Display(importedShape);
324 printf("\n End of my IGES to 3D-viewer *****************>\n");
329 //====================================================
331 // Following code is inserted from
332 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
333 // ( 75455 Apr 16 18:59)
335 //====================================================
338 #include <BRepTools_WireExplorer.hxx>
339 #include <BRep_Tool.hxx>
340 #include <GCPnts_UniformAbscissa.hxx>
341 #include <TopExp.hxx>
344 // usage : OCC105 shape
347 //GCPnts_UniformAbscissa returns bad end point foe first edge. Its value is
349 //Value Pnt = -338.556216693211 -394.465571897208 0
351 //Value Pnt = -307.47165394 -340.18073533 0
353 static int OCC105(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
356 di<<"Usage : OCC105 shape\n";
359 // TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get("aa.brep"));
360 TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1]));
361 Standard_Real l = 0.5; //atof(argv[2]);
362 // Find the first vertex of the wire
363 BRepTools_WireExplorer wire_exp(myTopoDSWire);
366 TopoDS_Vertex vw1, vw2;
367 TopExp::Vertices(myTopoDSWire,vw1,vw2);
368 TopoDS_Vertex ve1, ve2;
369 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
370 TopExp::Vertices(edge,ve1,ve2);
371 if (vw1.IsSame(ve1) || vw1.IsSame(ve2))
374 // assert(vw2.IsSame(ve1) || vw2.IsSame(ve2));
378 for ( ; wire_exp.More(); wire_exp.Next())
380 di << "\n\n New Edge \n" << "\n";
381 Standard_Real newufirst, newulast;
382 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
383 Standard_Real ufirst, ulast;
384 Handle(Geom_Curve) acurve;
385 TopoDS_Vertex ve1, ve2;
386 TopExp::Vertices(edge,ve1,ve2);
387 if (ve1.IsSame(vlast))
389 acurve = BRep_Tool::Curve(edge, ufirst, ulast);
396 // assert(ve2.IsSame(vlast));
397 // assert ( wire_exp.Orientation( ) == TopAbs_REVERSED );
398 acurve = BRep_Tool::Curve( edge, ufirst, ulast );
399 newufirst = acurve->ReversedParameter( ufirst );
400 newulast = acurve->ReversedParameter( ulast );
401 acurve = acurve->Reversed( );
405 GeomAdaptor_Curve curve;
406 GCPnts_UniformAbscissa algo;
408 algo.Initialize( curve, l, newufirst, newulast );
410 di << "Not Done!!!" << "\n";
411 for (Standard_Integer Index = 1; Index<=algo.NbPoints();Index++) {
412 Standard_Real t = algo.Parameter(Index);
413 gp_Pnt pt3 = curve.Value(t);
414 di << "Parameter t = " << t << "\n";
415 di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z() << "\n";
422 #include <TColStd_SequenceOfTransient.hxx>
423 #include <GeomFill_Pipe.hxx>
424 static int pipe_OCC9 (Draw_Interpretor& di,
425 Standard_Integer n, const char ** a)
428 di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]" << "\n";
432 TColStd_SequenceOfTransient aCurveSeq;
434 for (i=2 ; i<=4; i++) {
435 Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast( DrawTrSurf::Get(a[i]) );
437 di << a[i] << " is not a curve" << "\n";
440 aCurveSeq.Append(aC);
443 GeomFill_Pipe aPipe(Handle(Geom_Curve)::DownCast( aCurveSeq(1) ),
444 Handle(Geom_Curve)::DownCast( aCurveSeq(2) ),
445 Handle(Geom_Curve)::DownCast( aCurveSeq(3) ),
449 aPipe.Perform(atof (a[6]), Standard_True);
451 aPipe.Perform(Standard_True/*, Standard_True*/);
454 Handle(Geom_Surface) aSurf = aPipe.Surface();
456 DrawTrSurf::Set(a[1], aSurf);
460 //======================================================================
462 // usage : OCC125 shell
463 //======================================================================
464 #include <ShapeFix_Shell.hxx>
466 Standard_Integer OCC125(Draw_Interpretor& di ,
471 di<<" Use OCC125 shell";
475 TopoDS_Shape S = DBRep::Get(a[1]);
478 di<<" Null shape is not allowed";
484 if (aT!=TopAbs_SHELL) {
485 di<<" Shape Type must be SHELL";
489 const TopoDS_Shell& aShell = TopoDS::Shell(S);
491 Standard_Boolean isAccountMultiConex, bNonManifold, bResult;
493 isAccountMultiConex=Standard_True;
494 bNonManifold=Standard_False;
496 Handle (ShapeFix_Shell) aFix = new ShapeFix_Shell(aShell);
497 bResult=aFix->FixFaceOrientation(aShell, isAccountMultiConex, bNonManifold);
499 di<<"bResult="<<(Standard_Integer)bResult;
502 aShape=aFix->Shape();
504 TCollection_AsciiString aName(a[1]), aDef("_sh"), aRName;
507 DBRep::Set (aRName.ToCString(), aShape);
508 di<<aRName.ToCString();
513 #include <BRepLib_FindSurface.hxx>
514 #include <BRepBuilderAPI_MakeFace.hxx>
515 Standard_Integer OCC157(Draw_Interpretor& di,
518 //static Standard_Integer findplanarsurface(Draw_Interpretor&, Standard_Integer n, const char ** a)
521 di << "bad number of arguments" <<"\n";
525 // try to read a shape:
526 TopoDS_Shape inputShape=DBRep::Get(a[2]);
527 if (inputShape.IsNull() || inputShape.ShapeType() != TopAbs_WIRE) {
528 di << "Invalid input shape"<< "\n";
531 Standard_Real toler = atof(a[3]);
532 TopoDS_Wire aWire = TopoDS::Wire(inputShape);
533 BRepLib_FindSurface FS(aWire, toler, Standard_True);
535 di<<"OCC157: OK; Planar surface is found"<<"\n";
536 Handle(Geom_Surface) aSurf = FS.Surface();
537 BRepBuilderAPI_MakeFace aMakeFace(aSurf,aWire,Standard_True);
538 if(aMakeFace.IsDone()) {
539 TopoDS_Face aFace = aMakeFace.Face();
540 DBRep::Set(a[1],aFace);
543 else di<<"OCC157: ERROR; Planar surface is not found with toler = "<<toler <<"\n";
548 // #include <MyCommandsCMD.h>
549 #include <ShapeFix_Shape.hxx>
550 #include <BRepOffset_MakeOffset.hxx>
551 #include <BRepOffsetAPI_MakeOffset.hxx>
552 #include <BRepOffset_Mode.hxx>
553 #include <GeomAbs_JoinType.hxx>
554 #include <AIS_Shape.hxx>
556 #include <BRepTools.hxx>
558 Standard_Integer OCC165(Draw_Interpretor& di ,
563 //=======================================================================
565 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv);
567 // void MyOffsets_Commands(Draw_Interpretor& theCommands)
569 // theCommands.Add("yoffset" , "yoffset" , __FILE__, YOffset, " Offset on Z Direction");
572 //=======================================================================
574 // static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
578 di <<"Usage : " << a[0] << " [file]"<<"\n";
583 #define _OFFSET_TELCO_
584 #ifdef _OFFSET_TELCO_
586 Standard_CString file = a[1];
588 BRep_Builder aBuilder;
589 TopoDS_Shape theShape;
590 //BRepTools::Read(theShape, Standard_CString("/dn02/users_SUN/inv/3/OCC165/2d_tr_line.brep"), aBuilder);
591 BRepTools::Read(theShape, file, aBuilder);
592 DBRep::Set("shape", theShape);
594 TopoDS_Wire theWire = TopoDS::Wire(theShape);
596 Standard_Real anOffset = 1.5;
600 Standard_Real xA = 0.0, xB = 200.0, xC = 200.0, xD = 0.0,
601 yA = 0.0, yB = 0.0, yC = 200.0, yD = 200.0,
602 zA = 0.0, zB = 0.0, zC = 0.0, zD = 0.0;
604 BRepBuilderAPI_MakePolygon theSquare;
605 TopoDS_Vertex theA = BRepBuilderAPI_MakeVertex(gp_Pnt(xA, yA, zA));
607 TopoDS_Vertex theB = BRepBuilderAPI_MakeVertex(gp_Pnt(xB, yB, zB));
609 TopoDS_Vertex theC = BRepBuilderAPI_MakeVertex(gp_Pnt(xC, yC, zC));
611 TopoDS_Vertex theD = BRepBuilderAPI_MakeVertex(gp_Pnt(xD, yD, zD));
615 TopoDS_Wire theWire = theSquare.Wire();
617 Standard_Real anOffset = 10;
620 #endif /* _OFFSET_TELCO_ */
623 TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire).Face();
624 DBRep::Set("face", theFace);
627 Standard_Real anAlt = 0.;
628 GeomAbs_JoinType theJoin = GeomAbs_Intersection;
629 //GeomAbs_Intersection; //GeomAbs_Arc;
630 BRepOffsetAPI_MakeOffset aMakeOffset(theFace, theJoin);
631 aMakeOffset.AddWire(theWire);
633 aMakeOffset.Perform(anOffset, anAlt);
635 TopoDS_Shape theOffsetShapePos = aMakeOffset.Shape();
636 DBRep::Set("offset", theOffsetShapePos);
641 #include<BRepAlgoAPI_Cut.hxx>
642 #include<BRepAlgo_Cut.hxx>
644 #include<BRepPrimAPI_MakeHalfSpace.hxx>
645 #include<Handle_Geom_CartesianPoint.hxx>
646 #include<Geom_CartesianPoint.hxx>
647 #include<AIS_Point.hxx>
649 #include <BRepBuilderAPI_MakeEdge.hxx>
650 #include <BRepBuilderAPI_MakeWire.hxx>
651 #include <BRepBuilderAPI_MakeFace.hxx>
653 static Standard_Integer OCC297 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
657 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
658 if(myAISContext.IsNull()) {
659 di << "use 'vinit' command before " << argv[0] << "\n";
664 gp_Pnt pt1_(250.,250.,0.);
665 gp_Pnt pt2_(-250.,250.,0.);
666 gp_Pnt pt3_(-250.,-250.,0.);
667 gp_Pnt pt4_(250.,-250.,0.);
668 BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
669 BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
670 BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
671 BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
673 BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
674 BRepBuilderAPI_MakeFace face_(wire_);
675 TopoDS_Face sh_ = face_.Face();
681 g_pnt = gp_Pnt(0,0,-100);
683 g_pnt = gp_Pnt(0,0,100);
685 myAISContext->EraseAll(Standard_False);
686 Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
687 Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
688 myAISContext->Display(AISPoint);
690 BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
691 TopoDS_Solid sol1_ = half_.Solid();
692 // Handle(AIS_Shape) AISHalf = new AIS_Shape(sol1_);
693 // AISHalf->SetColor(Quantity_NOC_GREEN);
694 // myAISContext->Display(AISHalf);
696 DBRep::Set("Face",sol1_);
698 gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
700 Standard_Real x=0., y=0., z=-80.;
702 BRepPrimAPI_MakeBox box(gp_Pnt(x,y,z),gp_Pnt(x+150,y+200,z+200));
703 // Handle(AIS_Shape) AISBox = new AIS_Shape(box);
704 // AISBox->SetColor(Quantity_NOC_BLUE1);
705 // myAISContext->Display(AISBox);
707 DBRep::Set("Box",box.Shape());
709 // BRepAlgoAPI_Cut cut( sol1_, box.Shape() );
710 // //BRepAlgoAPI_Cut cut( box.Shape(), sol1_ );
711 // TopoDS_Shape sh1_ = cut.Shape();
712 // Handle(AIS_Shape) AISCut = new AIS_Shape(sh1_);
713 // AISCut->SetColor(Quantity_NOC_RED);
714 // myAISContext->Display(AISCut);
716 // DBRep::Set("Cut",sh1_);
721 #include<GProp_GProps.hxx>
722 #include<BRepGProp.hxx>
724 static Standard_Integer OCC305 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
729 di <<"Usage : " << argv[0] << " file"<<"\n";
732 Standard_CString file = argv[1];
734 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
735 if(myAISContext.IsNull()) {
736 di << "use 'vinit' command before " << argv[0] << "\n";
741 BRep_Builder builder;
742 //BRepTools::Read(sh, "/dn02/users_SUN/inv/3/OCC305/testc.brep", builder);
743 BRepTools::Read(sh, file, builder);
746 builder.MakeWire(wire);
748 TopoDS_Vertex vt1, vt2;
749 TopExp_Explorer wex(sh, TopAbs_EDGE);
750 for(;wex.More();wex.Next())
752 ed = TopoDS::Edge(wex.Current());
753 TopExp::Vertices(ed, vt1, vt2);
754 builder.UpdateVertex(vt1, 0.01);
755 builder.UpdateVertex(vt2, 0.01);
756 builder.UpdateEdge(ed, 0.01);
757 builder.Add(wire, ed);
761 BRepGProp::LinearProperties(ed, lprop);
762 printf("\n length = %f", lprop.Mass());
764 DBRep::Set("Wire",wire);
765 // Handle(AIS_Shape) res = new AIS_Shape( wire );
766 // aContext->SetColor( res, Quantity_NOC_RED );
767 // aContext->Display( res );
769 // BRepOffsetAPI_MakeOffset off(wire, GeomAbs_Arc);
770 // off.Perform(0.5, 0);
772 // printf("\n IsDone = %d", off.IsDone());
774 // res = new AIS_Shape( sh );
775 // aContext->SetColor( res, Quantity_NOC_GREEN );
776 // aContext->Display( res );
782 static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
785 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
786 if(myAISContext.IsNull()) {
787 di << "use 'vinit' command before " << argv[0];
791 BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
792 Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape());
793 myAISContext->Display(anAISBox, 1);
794 anAISBox->SetSelectionMode(-1);
795 Standard_Integer myLocContInd = myAISContext->OpenLocalContext();
796 myAISContext->CloseLocalContext(myLocContInd);
797 Standard_Integer aSelMode = ((Handle(AIS_InteractiveObject)) anAISBox)->SelectionMode();
804 #include <TDocStd_Document.hxx>
805 #include <DDocStd.hxx>
806 #include <PCDM_StoreStatus.hxx>
807 #include <TDocStd_Application.hxx>
809 static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
812 di << "Usage: " << a[0] << " Doc" << "\n";
816 Handle(TDocStd_Document) D;
817 if (!DDocStd::GetDocument(a[1],D)) return 1;
819 Handle(TDocStd_Application) A;
820 if (!DDocStd::Find(A)) return 1;
822 TCollection_ExtendedString theStatusMessage;
824 di << "this document has never been saved" << "\n";
827 PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
828 if (theStatus != PCDM_SS_OK ) {
829 switch ( theStatus ) {
830 case PCDM_SS_DriverFailure: {
831 di << " Could not store , no driver found to make it " <<"\n" ;
834 case PCDM_SS_WriteFailure: {
835 di << " Write access failure " << "\n" ;
838 case PCDM_SS_Failure: {
839 di << " Write failure " << "\n" ;
847 static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
850 di << "Usage: " << a[0] << " Doc Path" << "\n";
854 Handle(TDocStd_Document) D;
855 if (!DDocStd::GetDocument(a[1],D)) return 1;
857 TCollection_ExtendedString path (a[2]);
858 Handle(TDocStd_Application) A;
859 if (!DDocStd::Find(A)) return 1;
861 TCollection_ExtendedString theStatusMessage;
862 PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
863 if (theStatus != PCDM_SS_OK ) {
864 switch ( theStatus ) {
865 case PCDM_SS_DriverFailure: {
866 di << " Could not store , no driver found to make it " <<"\n" ;
869 case PCDM_SS_WriteFailure: {
870 di << " Write access failure " << "\n" ;
873 case PCDM_SS_Failure: {
874 di << " Write failure " << "\n" ;
883 #include <BRepClass3d_SolidClassifier.hxx>
885 Standard_Integer OCC299bug (Draw_Interpretor& di,
892 di << "Usage : " << a[0] << " Solid Point [Tolerance=1.e-7]" << "\n";
896 TopoDS_Shape aS = DBRep::Get(a[1]);
898 sprintf(sbf, " Null Shape is not allowed here\n");
903 if (aS.ShapeType()!=TopAbs_SOLID) {
904 sprintf(sbf, " Shape type must be SOLID\n");
909 Standard_Real aTol=1.e-7;
910 TCollection_AsciiString sIN("IN"), sOUT("OUT of"), sON("ON"), sUNKNOWN("UNKNOWN");
911 TopAbs_State aState = TopAbs_UNKNOWN;
912 gp_Pnt aP(8., 9., 10.);
914 if (!DrawTrSurf::GetPoint(a[2], aP) ) {
915 sprintf(sbf, " Null Point is not allowed here\n");
925 BRepClass3d_SolidClassifier aSC(aS);
926 aSC.Perform(aP,aTol);
928 aState = aSC.State();
930 sprintf(sbf, "The point is "); di<<sbf;
934 sprintf(sbf, sIN.ToCString());
937 sprintf(sbf, sOUT.ToCString());
940 sprintf(sbf, sON.ToCString());
943 sprintf(sbf, sUNKNOWN.ToCString());
946 sprintf(sbf, sUNKNOWN.ToCString());
951 sprintf(sbf, " shape\n");
957 #include <OSD_Process.hxx>
958 #include <OSD_Path.hxx>
960 static Standard_Integer OCC309bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
963 di << "Usage: " << a[0] << "\n";
967 OSD_Path d = p.CurrentDirectory();
968 TCollection_AsciiString s;
970 di << "*" << s.ToCString() << "*" << "\n";
973 di << "*" << s.ToCString() << "*" <<"\n";
977 static Standard_Integer OCC310bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
980 di << "Usage: " << a[0] << "\n";
983 OSD_Path p("/where/you/want/tmp/qwerty/tmp/");
984 di << p.Trek().ToCString() << "\n";
986 di << p.Trek().ToCString() << "\n";
990 #include <BRepAlgoAPI_Fuse.hxx>
991 #include <BRepAlgoAPI_Common.hxx>
992 #include <BRepAlgo_Fuse.hxx>
993 #include <BRepAlgo_Common.hxx>
995 static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
998 // cout << "Usage: " << a[0] << endl;
1001 if(nb < 1 || nb > 2) {
1002 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1005 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1007 Standard_Integer IsB = atoi(a[1]);
1009 IsBRepAlgoAPI = Standard_False;
1013 BRepPrimAPI_MakeBox box1( 100, 100, 100 );
1014 BRepPrimAPI_MakeBox box2( gp_Pnt( 50, 50,50 ), 200, 200, 200 );
1016 TopoDS_Shape shape1 = box1.Shape();
1017 TopoDS_Shape shape2 = box2.Shape();
1019 //#if ! defined(BRepAlgoAPI_def01)
1020 // TopoDS_Shape fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
1021 // TopoDS_Shape comm = BRepAlgoAPI_Common( shape1, shape2 );
1023 // TopoDS_Shape fuse = BRepAlgo_Fuse( shape1, shape2 );
1024 // TopoDS_Shape comm = BRepAlgo_Common( shape1, shape2 );
1026 TopoDS_Shape fuse,comm;
1027 if (IsBRepAlgoAPI) {
1028 di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )" <<"\n";
1029 di << "comm = BRepAlgoAPI_Common( shape1, shape2 )" <<"\n";
1030 fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
1031 comm = BRepAlgoAPI_Common( shape1, shape2 );
1033 di << "fuse = BRepAlgo_Fuse( shape1, shape2 )" <<"\n";
1034 fuse = BRepAlgo_Fuse( shape1, shape2 );
1035 di << "comm = BRepAlgo_Common( shape1, shape2 )" <<"\n";
1036 comm = BRepAlgo_Common( shape1, shape2 );
1042 #include <ShapeAnalysis_Edge.hxx>
1044 static Standard_Integer OCC333bug (Draw_Interpretor& di, Standard_Integer n, const char ** a)
1048 di << "Usage: " << a[0] << " edge1 edge2 [toler domaindist]" << "\n";
1051 TopoDS_Shape Sh1 = DBRep::Get(a[1]);
1052 TopoDS_Shape Sh2 = DBRep::Get(a[2]);
1053 if(Sh1.IsNull() || Sh2.IsNull()) {
1055 di<<"Invalid arguments"<<"\n";
1058 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
1059 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
1060 if(e1.IsNull() || e2.IsNull()) {
1062 di<<"Invalid type of arguments"<<"\n";
1065 Standard_Real aTol = Precision::Confusion();
1066 Standard_Real aDistDomain = 0.0;
1067 Standard_Integer k = 3;
1069 aTol = atof(a[k++]);
1071 aDistDomain = atof(a[k++]);
1073 ShapeAnalysis_Edge sae;
1074 if(sae.CheckOverlapping(e1,e2,aTol,aDistDomain)) {
1075 if(aDistDomain ==0.0) {
1077 di<<"Edges is overlaping comletly"<<"\n";
1080 di<<"Edges is overlaped"<<"\n";
1081 di<<"with tolerance = "<<aTol<<"\n";
1082 di<<"on segment length = "<<aDistDomain<<"\n";
1086 di<<"Edges is not overlaped"<<"\n";
1092 #include <DDocStd_DrawDocument.hxx>
1093 #include <TDataStd_Name.hxx>
1095 #include <XCAFDoc_ShapeTool.hxx>
1096 #include <XCAFDoc_DocumentTool.hxx>
1097 #include <TDF_LabelSequence.hxx>
1098 #include <TPrsStd_AISPresentation.hxx>
1099 #include <TDF_Data.hxx>
1100 #include <TDF_Label.hxx>
1101 #include <XCAFPrs_Driver.hxx>
1103 //------------------------------------------------------------------------------------------
1106 //------------------------------------------------------------------------------------------
1107 static Standard_Integer OCC363 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1112 // 1. Verufy amount of arguments
1113 if(argc < 3) { di <<"Error OCC363 : Use : OCC363 document filename\n"; return 1; }
1115 // 2. Retrieve DDocStd application
1116 Handle(TDocStd_Application) App;
1117 if (!DDocStd::Find(App)) { di << "Error OCC363 : There is no current DDocStd application\n";return 1;}
1120 TCollection_ExtendedString name(argv[2]);
1121 Handle(TDocStd_Document) Doc;
1122 if(App->Open(name, Doc) != PCDM_RS_OK) { di << "Error OCC363 : document was not opened successfully\n"; return 1;}
1123 Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(Doc);
1124 TDataStd_Name::Set(Doc->GetData()->Root(),argv[1]);
1125 Draw::Set(argv[1],DD);
1127 // 4. Create prsentations
1128 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1129 TDF_LabelSequence seq;
1130 shapes->GetFreeShapes ( seq );
1131 Handle(TPrsStd_AISPresentation) prs;
1132 for ( Standard_Integer i=1; i <= seq.Length(); i++ )
1133 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) )
1134 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
1136 catch(Standard_Failure) { di << "FAULTY OCC363 : Exception during reading document.\n";return 0;}
1138 di << "OCC363 OK\n";
1143 ////======================================================================================
1144 //// Function : OCC372
1146 ////======================================================================================
1147 //static Standard_Integer OCC372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1151 // OCC_CATCH_SIGNALS
1152 // // 1. Verufy amount of arguments
1153 // if(argc < 2) {di << "OCC372 FAULTY. Use : OCC372 brep-file";return 0;}
1157 // TopoDS_Shape Ref;
1158 // BRepTools::Read(Ref, argv[1], B);
1160 // // 3. Calculate location of aP3d in relation to the solid
1161 // gp_Pnt aP3d(6311.4862583184, -2841.3092756034, 16.461053497188);
1162 // BRepClass3d_SolidClassifier SC(Ref);
1163 // SC.Perform(aP3d, 1e-7);
1165 // // 4. Check returned state. The point must be inside the solid.
1166 // TopAbs_State aState=SC.State();
1170 // di<<"OCC372 FAULTY. aState = TopAbs_OUT";
1173 // di<<"OCC372 FAULTY. aState = TopAbs_ON";
1176 // di<<"OCC372 OK. aState = TopAbs_IN" ;
1179 // di<<"OCC372 FAULTY. aState = UNKNOWN";
1183 // catch (Standard_Failure) { di<<"OCC372 FAULTY. Exception raised"; }
1188 #include <BRepTopAdaptor_FClass2d.hxx>
1190 //======================================================================================
1191 // Function : OCC377
1193 //======================================================================================
1194 static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1199 // 1. Verify validity of arguments
1200 if ( argc < 1 ) {di << "Error OCC377. Use OCC377 file x y precuv \n";return 0;}
1202 // 2. Initialize parameters
1204 p2d.SetX ( atof(argv[2]) );
1205 p2d.SetY ( atof(argv[3]) );
1206 Standard_Real precuv = atof (argv[4] );
1211 BRepTools::Read ( Shape, argv[1], B );
1213 // 4. Verify whether enrtry point is on wire and reversed ones (indeed results of veridying must be same)
1214 TopExp_Explorer exp;
1215 Standard_Integer i=1;
1216 for (exp.Init(Shape.Oriented(TopAbs_FORWARD),TopAbs_WIRE); exp.More(); exp.Next(), i++)
1218 // 4.1. Verify whether enrtry point is on wire
1219 const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
1220 TopoDS_Face newFace = TopoDS::Face(Shape.EmptyCopied());
1222 TopAbs_Orientation orWire = wir.Orientation();
1223 newFace.Orientation(TopAbs_FORWARD);
1226 BRepTopAdaptor_FClass2d FClass2d1(newFace,precuv);
1227 TopAbs_State stat1 = FClass2d1.PerformInfinitePoint();
1228 //di << "Wire " << i << ": Infinite point is " <<
1229 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1231 TCollection_AsciiString TmpString;
1232 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1233 di << "Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1235 stat1 = FClass2d1.Perform(p2d);
1236 //di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1237 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1240 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1241 di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1243 // 4.2. Verify whether enrtry point is on reversed wire
1244 newFace = TopoDS::Face(Shape.EmptyCopied());
1245 newFace.Orientation(TopAbs_FORWARD);
1246 orWire = TopAbs::Reverse(orWire);
1247 B.Add(newFace,wir.Oriented(orWire));
1248 BRepTopAdaptor_FClass2d FClass2d2(newFace,precuv);
1249 TopAbs_State stat2 = FClass2d2.PerformInfinitePoint();
1250 //di << "Reversed Wire " << i << ": Infinite point is " <<
1251 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1254 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1255 di << "Reversed Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1257 stat2 = FClass2d2.Perform(p2d);
1258 //di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1259 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1262 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1263 di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1265 // 4.3. Compare results (they must be same)
1266 if(stat1 ==stat2) di << "OCC377 OK" << "\n";
1267 else {di << "OCC377 FAULTY" << "\n"; return 0;}
1270 catch(Standard_Failure)
1272 di << "OCC377 Exception";
1278 #include <ShapeUpgrade_ShapeDivideAngle.hxx>
1279 #include <ShapeBuild_ReShape.hxx>
1281 //=======================================================================
1284 //=======================================================================
1285 static Standard_Integer OCC22 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1290 // 1. Verify arguments of the command
1291 if (argc < 5) { di << "OCC22 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation"; return 0;}
1293 Standard_Boolean aConsiderLocation;
1294 if(strcmp(argv[4], "0")==0) aConsiderLocation = Standard_False;
1295 else aConsiderLocation = Standard_True;
1297 // 2. Iniitialize aShapeUpgrade
1298 ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(M_PI/2.);
1300 aShapeUpgrade.SetPrecision (Precision::Confusion());
1302 aShapeUpgrade.SetMaxTolerance(0.1);
1303 // subshapes to be divided
1304 TopoDS_Shape aSubShapesToBeDivided = DBRep::Get(argv[3]);
1305 if(aSubShapesToBeDivided.IsNull()) {di << "OCC22 FAULTY. Compound of subshapes to be divided is not exist. Please, verify input values. \n";return 0;}
1306 aShapeUpgrade.Init(aSubShapesToBeDivided);
1308 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1309 aShapeUpgrade.SetContext(aReshape);
1310 if(aConsiderLocation) aReshape->ModeConsiderLocation() = Standard_True;
1312 // 3. Perform splitting
1313 if (aShapeUpgrade.Perform (Standard_False)) di << "Upgrade_SplitRevolution_Done \n";
1314 else if (aShapeUpgrade.Status (ShapeExtend_OK)) di << "Upgrade_SplitRevolution_OK \n";
1315 else if (aShapeUpgrade.Status (ShapeExtend_FAIL)) { di << "OCC22 FAULTY. Operation failed. Angle was not divided\n";return 0;}
1317 // 4. Perform rebuilding shape
1318 // 4.1. Retrieve Shape
1319 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1320 if(anInitShape.IsNull()) { di << "OCC22 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1321 // 4.2 Rebuid retrieved shape
1322 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1323 // 4.3. Create result Draw shape
1324 DBRep::Set(argv[1], aResultShape);
1326 catch (Standard_Failure) {di << "OCC22 Exception \n" ;return 0;}
1332 #include <ShapeProcess_OperLibrary.hxx>
1333 #include <ShapeProcess_ShapeContext.hxx>
1334 #include <ShapeProcess.hxx>
1336 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
1337 #include <BRepMesh_IncrementalMesh.hxx>
1339 //=======================================================================
1342 //=======================================================================
1343 static Standard_Integer OCC24 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1348 // 1. Verify amount of arguments of the command
1349 if (argc < 6) { di << "OCC24 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapes ResourceFileName SequenceName"; return 0;}
1351 // 2. Retrieve parameters
1353 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1354 if(anInitShape.IsNull()) { di << "OCC24 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1355 // compound of subshapes
1356 TopoDS_Shape aSubShapes = DBRep::Get(argv[3]);
1357 if(aSubShapes.IsNull()) {di << "OCC24 FAULTY. Compound of subshapes is not exist. Please, verify input values. \n";return 0;}
1358 // name of resource file
1359 const char* aResourceFile = argv[4];
1360 // name of sequence from resource file to be executed
1361 const char* aSequenceName = argv[5];
1363 // 3. Initialize ShapeContext and perform sequence of operation specified with resource file
1364 ShapeProcess_OperLibrary::Init();
1365 Handle(ShapeProcess_ShapeContext) aShapeContext = new ShapeProcess_ShapeContext (aSubShapes, aResourceFile);
1366 aShapeContext->SetDetalisation (TopAbs_EDGE);
1367 ShapeProcess::Perform (aShapeContext, aSequenceName);
1369 // 4. Rebuild initil shape in accordance with performed operation
1370 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1371 TopTools_DataMapIteratorOfDataMapOfShapeShape anIter (aShapeContext->Map());
1372 for (; anIter.More(); anIter.Next())
1373 aReshape->Replace(anIter.Key(), anIter.Value());
1374 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1376 // 5 Create resultant Draw shape
1377 DBRep::Set(argv[1], aResultShape);
1380 catch (Standard_Failure) {di << "OCC24 Exception \n" ;return 0;}
1385 //=======================================================================
1387 //purpose : Verify whether exception occurs during building mesh
1388 //=======================================================================
1389 static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1394 // 1. Verify amount of arguments of the command
1395 if (argc < 2) { di << "OCC369 FAULTY. Use : OCC369 Shape \n"; return 0;}
1397 // 2. Retrieve shape
1398 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1399 if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
1402 BRepMesh_IncrementalMesh aMesh(aShape, 0.2, Standard_True, M_PI/6);
1405 catch (Standard_Failure) {di << "OCC369 Exception \n" ;return 0;}
1407 di << "OCC369 OK \n";
1411 #include <math_Vector.hxx>
1412 #include <math_Matrix.hxx>
1413 static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1416 di<<"Usage : " << argv[0] << " LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix\n";
1419 Standard_Integer LowerVector = atoi(argv[1]);
1420 Standard_Integer UpperVector = atoi(argv[2]);
1421 Standard_Real InitialValueVector = atof(argv[3]);
1422 Standard_Integer LowerRowMatrix = atoi(argv[4]);
1423 Standard_Integer UpperRowMatrix = atoi(argv[5]);
1424 Standard_Integer LowerColMatrix = atoi(argv[6]);
1425 Standard_Integer UpperColMatrix = atoi(argv[7]);
1426 Standard_Real InitialValueMatrix = atof(argv[8]);
1428 math_Vector Vector1(LowerVector, UpperVector);
1429 math_Vector Vector2(LowerVector, UpperVector);
1431 math_Vector Vector(LowerVector, UpperVector, InitialValueVector);
1432 math_Matrix Matrix(LowerRowMatrix, UpperRowMatrix, LowerColMatrix, UpperColMatrix, InitialValueMatrix);
1434 //Vector.Dump(cout);
1437 //Matrix.Dump(cout);
1440 Vector1.Multiply(Vector, Matrix);
1442 //Vector1.Dump(cout);
1443 Standard_SStream aSStream1;
1444 Vector1.Dump(aSStream1);
1448 Vector2.TMultiply(Vector, Matrix);
1450 //Vector2.Dump(cout);
1451 Standard_SStream aSStream2;
1452 Vector2.Dump(aSStream2);
1459 #include <GeomPlate_BuildPlateSurface.hxx>
1460 //=======================================================================
1463 //=======================================================================
1464 static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
1469 GeomPlate_BuildPlateSurface aBuilder;
1472 catch (Standard_RangeError) { di << "OCC525 Exception \n" ;return 0; }
1473 //catch (...) { di << "OCC525 Exception \n" ;return 0; }
1475 di << "OCC525 OK \n";
1479 #include <Viewer2dTest.hxx>
1480 #include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
1482 #include <AIS2D_InteractiveContext.hxx>
1483 #include <V2d_View.hxx>
1484 #include <AIS2D_InteractiveObject.hxx>
1485 #include <TColStd_HSequenceOfInteger.hxx>
1488 extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1490 Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1493 //=======================================================================
1496 //=======================================================================
1497 static Standard_Integer OCC543 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1499 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1500 if(aContext.IsNull()) {
1501 di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
1505 di<<"Usage : " << argv[0] << " name\n";
1508 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1510 TCollection_AsciiString name = argv[1];
1512 if (!GetMapOfAIS2D().IsBound2(name)) {
1513 // di << "There is not an object with name " << name.ToCString() << "\n";
1517 Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name);
1518 Standard_Integer PickedIndex = aShape->PickedIndex();
1519 di << "PickedIndex = " << PickedIndex << "\n";
1523 #include <BRepPrimAPI_MakeWedge.hxx>
1524 #include <gce_MakeRotation.hxx>
1525 #include <gce_MakeTranslation.hxx>
1526 #include <BRepBuilderAPI_Transform.hxx>
1527 #include <BRepPrimAPI_MakeWedge.hxx>
1528 #include <BRepAlgoAPI_Fuse.hxx>
1529 #include <BRepAlgoAPI_Cut.hxx>
1530 #include <BRepAlgo_Fuse.hxx>
1531 #include <BRepAlgo_Cut.hxx>
1532 //=======================================================================
1535 //=======================================================================
1536 static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1539 // di<<"Usage : " << argv[0] << " shape1 shape2 shape3\n";
1542 if(argc < 4 || argc > 5) {
1543 di << "Usage : " << argv[0] << " shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1546 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1548 Standard_Integer IsB = atoi(argv[4]);
1550 IsBRepAlgoAPI = Standard_False;
1551 // di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1553 // di << "Error: There is not BRepAlgo_Cut class" << "\n";
1559 double xperiod = 1.0;
1560 double yperiod = 1.0;
1561 double sub_thick = 0.5;
1564 //TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick );
1565 TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick ).Shape();
1567 // --------------------------------------------------------------------
1570 //TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1571 // 0.1, 0.1 , 0.4, 0.4 );
1572 TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1573 0.1, 0.1 , 0.4, 0.4 ).Shape();
1575 gp_Trsf rotate = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1576 gp_Dir(1.0,0.0,0.0),
1579 gp_Trsf translate = gce_MakeTranslation(gp_Pnt( 0.0, -0.5, 0.0),
1580 gp_Pnt( 0.25, 0.25, 0.5)
1583 rotate.PreMultiply( translate );
1585 TopoDS_Shape wedge1a = BRepBuilderAPI_Transform( wedge1, rotate );
1587 if (wedge1a.IsNull()) {
1588 di<<" Null shape1 is not allowed\n";
1591 DBRep::Set(argv[1], wedge1a);
1593 // --------------------------------------------------------------------
1596 //TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1597 // 0.1, 0.1 , 0.4, 0.4 );
1598 TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1599 0.1, 0.1 , 0.4, 0.4 ).Shape();
1601 gp_Trsf rotate2 = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1602 gp_Dir(1.0,0.0,0.0),
1605 gp_Trsf translate2 = gce_MakeTranslation(gp_Pnt( 0.0, 0.0, 0.0),
1606 gp_Pnt( 0.25, 0.25, 0.5)
1609 rotate2.PreMultiply( translate2 );
1611 TopoDS_Shape wedge2a = BRepBuilderAPI_Transform( wedge2, rotate2 );
1613 if (wedge2a.IsNull()) {
1614 di<<" Null shape2 is not allowed\n";
1617 DBRep::Set(argv[2], wedge2a);
1621 //#if ! defined(BRepAlgoAPI_def01)
1622 // TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1624 // TopoDS_Shape wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1626 TopoDS_Shape wedge_common;
1627 if (IsBRepAlgoAPI) {
1628 di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)" <<"\n";
1629 wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1631 di << "wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a)" <<"\n";
1632 wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1635 // remove wedge area from substrate
1636 //#if ! defined(BRepAlgoAPI_def01)
1637 // TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1639 // TopoDS_Shape sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1641 TopoDS_Shape sub_etch1;
1642 if (IsBRepAlgoAPI) {
1643 di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)" <<"\n";
1644 sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1646 di << "sub_etch1 = BRepAlgo_Cut(substrate, wedge_common)" <<"\n";
1647 sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1650 if (sub_etch1.IsNull()) {
1651 di<<" Null shape3 is not allowed\n";
1654 DBRep::Set(argv[3], sub_etch1);
1659 #include <Graphic2d_DisplayList.hxx>
1660 #include <Graphic2d_View.hxx>
1662 //=======================================================================
1665 //=======================================================================
1666 static Standard_Integer OCC627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1668 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1669 if(aContext.IsNull()) {
1670 di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
1674 di<<"Usage : " << argv[0] << "\n";
1678 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1679 Handle(Graphic2d_View) View = V->View();
1680 Handle(Graphic2d_DisplayList) DisplayList = View->DisplayList();
1681 Standard_Integer Length = DisplayList->Length();
1682 di << "Length = " << Length << "\n";
1687 #include <Standard_GUID.hxx>
1688 //=======================================================================
1691 //=======================================================================
1692 static Standard_Integer OCC669 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1695 di<<"Usage : " << argv[0] << " GUID\n";
1698 Standard_GUID guid(argv[1]);
1699 //guid.ShallowDump(cout);
1700 Standard_SStream aSStream;
1701 guid.ShallowDump(aSStream);
1707 #include <XCAFDoc.hxx>
1708 //=======================================================================
1709 //function : OCC738_ShapeRef
1711 //=======================================================================
1712 static Standard_Integer OCC738_ShapeRef (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1715 di<<"Usage : " << argv[0] << "\n";
1718 const Standard_GUID& guid = XCAFDoc::ShapeRefGUID ();
1719 //guid.ShallowDump(cout);
1720 Standard_SStream aSStream;
1721 guid.ShallowDump(aSStream);
1726 //=======================================================================
1727 //function : OCC738_Assembly
1729 //=======================================================================
1730 static Standard_Integer OCC738_Assembly (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1733 di<<"Usage : " << argv[0] << "\n";
1736 const Standard_GUID& guid = XCAFDoc::AssemblyGUID ();
1737 //guid.ShallowDump(cout);
1738 Standard_SStream aSStream;
1739 guid.ShallowDump(aSStream);
1744 #if defined(DDataStd_def01)
1745 #include <DDataStd_DrawPresentation.hxx>
1746 //=======================================================================
1747 //function : OCC739_DrawPresentation
1749 //=======================================================================
1750 static Standard_Integer OCC739_DrawPresentation (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1753 di<<"Usage : " << argv[0] << "\n";
1756 const Standard_GUID& guid = DDataStd_DrawPresentation::GetID() ;
1757 //guid.ShallowDump(cout);
1758 Standard_SStream aSStream;
1759 guid.ShallowDump(aSStream);
1765 //=======================================================================
1768 //=======================================================================
1769 static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1771 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1772 if(aContext.IsNull()) {
1773 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
1778 di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation" << "\n";
1782 Standard_Boolean updateviewer = Standard_True, PutInCollector = Standard_True;
1784 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1786 TCollection_AsciiString aName(argv[1]);
1787 Handle(AIS_InteractiveObject) AISObj;
1789 if(!aMap.IsBound2(aName)) {
1790 di << "Use 'vdisplay' before" << "\n";
1793 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
1794 if(AISObj.IsNull()){
1795 di << argv[1] << " : No interactive object" << "\n";
1798 AISObj->UnsetTransformation();
1799 if (!aContext->HasOpenedContext()) {
1800 aContext->OpenLocalContext();
1802 aContext->Erase(AISObj, updateviewer, PutInCollector);
1803 aContext->UpdateCurrentViewer();
1804 aContext->Display(AISObj, updateviewer);
1805 aContext->UpdateCurrentViewer();
1810 //=======================================================================
1813 //=======================================================================
1814 #include <TColStd_Array2OfInteger.hxx>
1815 static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1818 di<<"Usage : " << argv[0] << "\n";
1821 TColStd_Array2OfInteger Array2OfInteger(1,1,1,1);
1822 Array2OfInteger.SetValue(5,5,55);
1826 #include <GeomAPI_ProjectPointOnSurf.hxx>
1827 //=======================================================================
1830 //=======================================================================
1831 static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1835 di<<"Usage : " << argv[0] << " Point Surface Umin Usup Vmin Vsup \n";
1840 DrawTrSurf::GetPoint(argv[1],aPoint3d);
1841 Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
1842 Standard_Real Umin=atof(argv[3]);
1843 Standard_Real Usup=atof(argv[4]);
1844 Standard_Real Vmin=atof(argv[5]);
1845 Standard_Real Vsup=atof(argv[6]);
1847 if (aSurface.IsNull()) {
1848 di << argv[2] << " Null surface \n" ;
1852 GeomAPI_ProjectPointOnSurf PonSurf;
1853 PonSurf.Init(aSurface, Umin, Usup, Vmin, Vsup);
1854 PonSurf.Perform(aPoint3d);
1859 //=======================================================================
1862 //=======================================================================
1863 static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1867 di<<"Usage : " << argv[0] << " wire face\n";
1871 TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
1872 TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
1873 if (awire.IsNull() || aface.IsNull()) {
1874 di << "Null object" << "\n";
1878 Standard_Integer count = 0;
1879 TopExp_Explorer TE(awire, TopAbs_VERTEX);
1881 BRepTools_WireExplorer WE;
1882 for ( WE.Init(awire,aface); WE.More(); WE.Next()) {
1883 TopoDS_Edge E = WE.Current();
1887 di << "Count = " << count << "\n";
1892 //=======================================================================
1895 //=======================================================================
1896 static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1900 di <<"Usage : " << argv[0] << " face"<<"\n";
1903 Standard_Real u1, u2, v1, v2;
1904 TopoDS_Face F = TopoDS::Face( DBRep::Get(argv[1]) ); //read the shape
1907 BRepTools::UVBounds(F, u1, u2, v1, v2);
1908 di << "Bounds: " << u1 << " " << u2 << " " << v1 << " " << v2 << "\n";
1912 #include <Expr_NamedUnknown.hxx>
1913 #include <Expr_GeneralExpression.hxx>
1914 #include <Expr_Exponential.hxx>
1915 //=======================================================================
1918 //=======================================================================
1919 static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1923 di <<"Usage : " << argv[0] << " expression"<<"\n";
1927 TCollection_AsciiString myStr(argv[1]);
1929 Handle (Expr_NamedUnknown) myNamed = new Expr_NamedUnknown(myStr);
1930 Handle (Expr_Exponential) oldExpr = new Expr_Exponential(myNamed);
1931 Handle (Expr_GeneralExpression) newExpr = oldExpr->Derivative(myNamed);
1934 TCollection_AsciiString res = newExpr->String();
1935 Standard_CString resStr = res.ToCString();
1936 TCollection_AsciiString res_old = oldExpr->String();
1937 Standard_CString res_oldStr = res_old.ToCString();
1940 di << "X = " << argv[1] << "\n";
1941 di << "Y = " << res_oldStr << "\n";
1942 di << "Y' = " << resStr << "\n";
1948 #include <TPrsStd_AISViewer.hxx>
1949 #include <TDF_Label.hxx>
1950 #include <TPrsStd_AISPresentation.hxx>
1951 //=======================================================================
1952 //function : OCC1029_AISTransparency
1953 //purpose : OCC1029_AISTransparency (DOC,entry,[real])
1954 //=======================================================================
1956 static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
1957 Standard_Integer nb,
1961 Handle(TDocStd_Document) D;
1962 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1964 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1966 Handle(TPrsStd_AISViewer) viewer;
1967 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1969 Handle(TPrsStd_AISPresentation) prs;
1970 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1972 prs->SetTransparency(atof(arg[3]));
1973 TPrsStd_AISViewer::Update(L);
1976 di << "Transparency = " << prs->Transparency() << "\n";
1981 di << arg[0] << " : Error" << "\n";
1985 //=======================================================================
1986 //function : OCC1030_AISColor
1987 //purpose : OCC1030_AISColor (DOC,entry,[color])
1988 //=======================================================================
1990 static Standard_Integer OCC1030_AISColor (Draw_Interpretor& di,
1991 Standard_Integer nb,
1995 Handle(TDocStd_Document) D;
1996 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1998 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2000 Handle(TPrsStd_AISViewer) viewer;
2001 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2003 Handle(TPrsStd_AISPresentation) prs;
2004 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2006 prs->SetColor((Quantity_NameOfColor)atoi(arg[3]));
2007 TPrsStd_AISViewer::Update(L);
2010 di << "Color = " << prs->Color() << "\n";
2014 di << arg[0] << " : Error" << "\n";
2018 //=======================================================================
2019 //function : OCC1031_AISMaterial
2020 //purpose : OCC1031_AISMaterial (DOC,entry,[material])
2021 //=======================================================================
2023 static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
2024 Standard_Integer nb,
2028 Handle(TDocStd_Document) D;
2029 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2031 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2033 Handle(TPrsStd_AISViewer) viewer;
2034 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2036 Handle(TPrsStd_AISPresentation) prs;
2037 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2039 prs->SetMaterial((Graphic3d_NameOfMaterial)atoi(arg[3]));
2040 TPrsStd_AISViewer::Update(L);
2043 di << "Material = " << prs->Material() << "\n";
2048 di << arg[0] << " : Error" << "\n";
2052 //=======================================================================
2053 //function : OCC1032_AISWidth
2054 //purpose : OCC1032_AISWidth (DOC,entry,[width])
2055 //=======================================================================
2057 static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
2058 Standard_Integer nb,
2062 Handle(TDocStd_Document) D;
2063 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2065 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2067 Handle(TPrsStd_AISViewer) viewer;
2068 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2070 Handle(TPrsStd_AISPresentation) prs;
2071 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2073 prs->SetWidth(atof(arg[3]));
2074 TPrsStd_AISViewer::Update(L);
2077 di << "Width = " << prs->Width() << "\n";
2082 di << arg[0] << " : Error" << "\n";
2086 //=======================================================================
2087 //function : OCC1033_AISMode
2088 //purpose : OCC1033_AISMode (DOC,entry,[mode])
2089 //=======================================================================
2091 static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
2092 Standard_Integer nb,
2096 Handle(TDocStd_Document) D;
2097 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2099 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2101 Handle(TPrsStd_AISViewer) viewer;
2102 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2104 Handle(TPrsStd_AISPresentation) prs;
2105 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2107 prs->SetMode(atoi(arg[3]));
2108 TPrsStd_AISViewer::Update(L);
2111 di << "Mode = " << prs->Mode() << "\n";
2116 di << arg[0] << " : Error" << "\n";
2120 //=======================================================================
2121 //function : OCC1034_AISSelectionMode
2122 //purpose : OCC1034_AISSelectionMode (DOC,entry,[selectionmode])
2123 //=======================================================================
2125 static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
2126 Standard_Integer nb,
2130 Handle(TDocStd_Document) D;
2131 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2133 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2135 Handle(TPrsStd_AISViewer) viewer;
2136 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2138 Handle(TPrsStd_AISPresentation) prs;
2139 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2141 prs->SetSelectionMode(atoi(arg[3]));
2142 TPrsStd_AISViewer::Update(L);
2145 di << "SelectionMode = " << prs->SelectionMode() << "\n";
2150 di << arg[0] << " : Error" << "\n";
2154 #include<BRepAlgoAPI_Cut.hxx>
2155 #include<BRepAlgo_Cut.hxx>
2156 //=======================================================================
2157 //function : OCC1487
2159 //=======================================================================
2160 static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2163 // cerr << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape" << endl;
2166 if(argc < 5 || argc > 6) {
2167 di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2170 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2172 Standard_Integer IsB = atoi(argv[5]);
2174 IsBRepAlgoAPI = Standard_False;
2175 // di << "Error: There is not BRepAlgo_Cut class" << "\n";
2180 Standard_Integer CaseNumber = atoi(argv[1]);
2182 //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
2183 gp_Dir myDir(1,0,0);
2184 gp_Pnt myPnt(0,-50,140);
2185 gp_Ax2 myAx2(myPnt, myDir);
2186 BRepPrimAPI_MakeCylinder o_mc1 (myAx2, 50,1000);
2188 TopoDS_Shape cyl1 = o_mc1.Shape();
2191 TopoDS_Shape o_cut_shape;
2192 if (CaseNumber == 1) {
2193 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(21.65064, -50.0, 127.5),gp_Dir(-sin(M_PI/3), 0.0, 0.5)), 5, 150);
2194 gp_Dir myDir_mc2(-sin(M_PI/3), 0.0, 0.5);
2195 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2196 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2197 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2199 cyl2 = o_mc2.Shape();
2200 //#if ! defined(BRepAlgoAPI_def01)
2201 // o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2203 // o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2205 if (IsBRepAlgoAPI) {
2206 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2207 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2209 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2210 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2213 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(978.34936, -50.0, 127.5),gp_Dir(sin(M_PI/3), 0.0, 0.5)), 5, 150);
2214 gp_Dir myDir_mc2(-sin(M_PI/3), 0.0, 0.5);
2215 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2216 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2217 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2219 cyl2 = o_mc2.Shape();
2220 //#if ! defined(BRepAlgoAPI_def01)
2221 // o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2223 // o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2225 if (IsBRepAlgoAPI) {
2226 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2227 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2229 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2230 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2234 DBRep::Set(argv[2],cyl1);
2235 DBRep::Set(argv[3],cyl2);
2236 DBRep::Set(argv[4],o_cut_shape);
2241 #include<TopTools_ListIteratorOfListOfShape.hxx>
2242 #include<BRepFilletAPI_MakeFillet.hxx>
2243 //=======================================================================
2244 //function : OCC1077
2246 //=======================================================================
2247 TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
2249 Standard_Real t3d = 1.e-4;
2250 Standard_Real t2d = 1.e-5;
2251 Standard_Real ta = 1.e-2;
2252 Standard_Real fl = 1.e-3;
2253 Standard_Real tapp_angle = 1.e-2;
2254 GeomAbs_Shape blend_cont = GeomAbs_C1;
2256 TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
2259 // Handle_TopOpeBRepBuild_HBuilder build = aBoolenaOperation.Builder();
2261 TopTools_ListIteratorOfListOfShape its;
2263 TopoDS_Compound result;
2265 B.MakeCompound(result);
2268 for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
2270 const TopoDS_Shape& cutsol = ex.Current();
2272 BRepFilletAPI_MakeFillet fill(cutsol);
2273 fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
2274 fill.SetContinuity(blend_cont, tapp_angle);
2276 // its = build->Section();
2278 its = aBoolenaOperation.SectionEdges();
2282 TopoDS_Edge E = TopoDS::Edge(its.Value());
2283 fill.Add(aRadius, E);
2290 B.Add(result, fill.Shape());
2294 B.Add(result, cutsol);
2300 TopoDS_Shape OCC1077_cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
2302 //return OCC1077_boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
2303 BRepAlgoAPI_Cut aCut(aShapeToCut, aTool);
2304 return OCC1077_boolbl(aCut,aRadius);
2307 //TopoDS_Shape OCC1077_common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
2309 // return OCC1077_boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
2312 TopoDS_Shape OCC1077_Bug()
2314 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10).Shape();
2315 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7).Shape();
2317 TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
2318 TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10),
2319 gp_Dir(0, 0, 1)), 3, 20).Shape();
2320 TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0),
2321 gp_Dir(1, 0, 0)), 3, 20).Shape();
2322 TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
2323 gp_Dir(0, 1, 0)), 3, 20).Shape();
2324 TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
2325 Handle_ShapeFix_Shape fixer = new ShapeFix_Shape(theTmp1);
2327 theTmp1 = fixer->Shape();
2328 TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
2329 fixer->Init(theTmp2);
2331 theTmp2 = fixer->Shape();
2332 TopoDS_Shape theResult = OCC1077_cut_blend(theTmp2,theCylinder3,0.7);
2333 fixer->Init(theResult);
2335 theResult = fixer->Shape();
2339 static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2341 if(argc < 1 || argc > 2) {
2342 di << "Usage : " << argv[0] << " result" << "\n";
2346 TopoDS_Shape S = OCC1077_Bug();
2347 DBRep::Set(argv[1],S);
2352 //////////////////////////////////////////////////////////////
2354 * Compute uniform distribution of points using GCPnts_UniformAbscissa
2356 //////////////////////////////////////////////////////////////
2357 static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2361 di << "Usage : " << argv[0] << " name shape step" << "\n";
2364 const char *name = argv[1];
2365 Adaptor3d_Curve *adapCurve=NULL;
2366 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
2367 if (!curve.IsNull())
2368 adapCurve = new GeomAdaptor_Curve(curve);
2371 TopoDS_Shape wire = DBRep::Get(argv[2]);
2372 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
2374 di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected"<<"\n";
2377 adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
2379 double step = atof(argv[3]);
2380 GCPnts_UniformAbscissa aUni(*adapCurve, step);
2384 di << argv[0] <<" : fail"<<"\n";
2389 int i, np = aUni.NbPoints();
2390 for (i=0; i < np; i++)
2392 double par = aUni.Parameter(i+1);
2393 gp_Pnt p = adapCurve->Value(par);
2394 char n[20], *pname=n;
2395 sprintf(n,"%s_%d",name,i+1);
2396 DrawTrSurf::Set(pname,p);
2405 static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2409 di << "Usage : " << argv[0] << " nb_of_vectors size" << "\n";
2413 Standard_Integer nb = atoi(argv[1]);
2414 Standard_Integer sz = atoi(argv[2]);
2415 Standard_Real val = 10;
2416 math_Vector **pv = new math_Vector *[nb];
2418 di<<"creating "<<nb<<" vectors "<<sz<<" elements each..."<<"\n";
2420 for (i=0; i < nb; i++) {
2421 pv[i] = new math_Vector (1, sz, val);
2422 if ((i % (nb/10)) == 0) {
2429 di<<"deleting them ..."<<"\n";
2430 for (i=0; i < nb; i++) {
2432 if ((i % (nb/10)) == 0) {
2445 static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2449 di << "Usage : " << argv[0] << " wire" << "\n";
2452 TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
2455 TopoDS_Wire wire = TopoDS::Wire(shape);
2456 // create curve parameterised by curvilinear distance
2457 BRepAdaptor_CompCurve curve(wire,Standard_True);
2458 Standard_Real length = curve.LastParameter();
2459 Standard_Real need_length = length/2;
2461 curve.D0(need_length,pnt);
2462 // create check_curve parameterised in a general way
2463 BRepAdaptor_CompCurve check_curve(wire);
2464 Standard_Real check_par =
2465 GCPnts_AbscissaPoint(check_curve, need_length, 0).Parameter();
2467 check_curve.D0(check_par,check_pnt);
2468 // check that points are coinsiding
2469 Standard_Real error_dist = pnt.Distance(check_pnt);
2470 if (error_dist > Precision::Confusion()) {
2471 //cout.precision(3);
2472 di<<"error_dist = "<<error_dist<<
2473 " ( "<<error_dist/need_length*100<<" %)"<<"\n";
2480 static char sarr[2000];
2482 static int StackOverflow(int i = -1)
2487 memcpy(arr,sarr,2000);
2489 int n = strlen(arr), s=0;
2491 s += StackOverflow(i-1);
2492 return i + s + StackOverflow(i-1);
2495 return i + StackOverflow(i-1);
2502 // this code does not work with optimize mode on Windows
2503 #pragma optimize( "", off )
2505 static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2509 di << "Usage : " << argv[0] << "\n";
2512 Standard_Boolean Succes;
2514 Succes = Standard_True;
2517 {//==== Test Divide ByZero (Integer) ========================================
2520 di << "(Integer) Divide By Zero...";
2523 Standard_Integer res, a =4, b = 0 ;
2525 di << " 4 / 0 = " << res << " Does not Caught... KO"<< "\n";
2526 Succes = Standard_False;
2528 #if defined(SOLARIS) || defined(WNT)
2529 catch(Standard_DivideByZero)
2531 catch(Standard_NumericError)
2536 catch(Standard_Failure) {
2537 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2539 di << Standard_Failure::Caught()->GetMessageString();
2540 di << ")... KO" << "\n";
2541 Succes = Standard_False;
2543 #ifndef NO_CXX_EXCEPTION
2544 // this case tests if (...) supersedes (Standard_*),
2545 // the normal behaviour is not
2547 di<<" unknown exception... (But) Ok"<<"\n";
2552 {//==== Test Divide ByZero (Real) ===========================================
2555 di << "(Real) Divide By Zero...";
2558 Standard_Real res, a= 4.0, b=0.0;
2560 di << " 4.0 / 0.0 = " << res << " Does not Caught... KO"<< "\n";
2561 Succes = Standard_False;
2563 #if defined(SOLARIS) || defined(WNT)
2564 catch(Standard_DivideByZero)
2566 catch(Standard_NumericError)
2571 catch(Standard_Failure) {
2572 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2574 di << Standard_Failure::Caught()->GetMessageString();
2575 di << ")... KO" << "\n";
2576 Succes = Standard_False;
2580 {//==== Test Overflow (Integer) =============================================
2583 di << "(Integer) Overflow...";
2586 Standard_Integer res, i=IntegerLast();
2588 //++++ cout << " -- "<<res<<"="<<i<<"+1 Does not Caught... KO"<< endl;
2589 //++++ Succes = Standard_False;
2590 di << " "<<res<<"="<<i<<"+1 Does not Caught... (But) Ok"<< "\n";
2592 catch(Standard_Overflow) {
2595 catch(Standard_Failure) {
2596 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2598 di << Standard_Failure::Caught()->GetMessageString();
2599 di << ")... KO" << "\n";
2600 Succes = Standard_False;
2604 {//==== Test Overflow (Real) ================================================
2607 di << "(Real) Overflow...";
2610 Standard_Real res, r=RealLast();
2613 sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
2615 di << "-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<< "\n";
2616 Succes = Standard_False;
2618 #if defined(SOLARIS) || defined(WNT)
2619 catch(Standard_Overflow)
2621 catch(Standard_NumericError)
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 Underflow (Real) ===============================================
2638 di << "(Real) Underflow";
2641 Standard_Real res, r=1.0e-308;
2644 //++++ cout<<"-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<<endl;
2645 //++++ Succes = Standard_False;
2646 di<<" -- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... (But) Ok"<<"\n";
2648 #if defined(SOLARIS) || defined(WNT)
2649 catch(Standard_Underflow)
2651 catch(Standard_NumericError)
2656 catch(Standard_Failure) {
2657 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2659 di << Standard_Failure::Caught()->GetMessageString();
2660 di << ")... KO" << "\n";
2661 Succes = Standard_False;
2665 {//==== Test Invalid Operation (Real) ===============================================
2668 di << "(Real) Invalid Operation...";
2671 Standard_Real res, r=-1;
2673 di<<" "<<res<<"=sqrt("<<r<<") Does not Caught... KO"<<"\n";
2674 Succes = Standard_False;
2676 catch(Standard_NumericError) {
2679 catch(Standard_Failure) {
2680 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2682 di << Standard_Failure::Caught()->GetMessageString();
2683 di << ")... KO" << "\n";
2684 Succes = Standard_False;
2688 {//==== Test Access Violation ===============================================
2691 di << "Segmentation Fault...";
2696 di << " Does not Caught... KO"<<"\n";
2697 Succes = Standard_False;
2700 catch(OSD_Exception_ACCESS_VIOLATION)
2706 } catch(Standard_Failure) {
2707 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2709 di << Standard_Failure::Caught()->GetMessageString();
2710 di << ")... KO" << "\n";
2711 Succes = Standard_False;
2716 {//==== Test Stack Overflow ===============================================
2719 di << "Stack Overflow...";
2723 di << " Does not Caught... KO"<<"\n";
2724 Succes = Standard_False;
2726 catch(OSD_Exception_STACK_OVERFLOW) {
2729 catch(Standard_Failure) {
2730 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2732 di << Standard_Failure::Caught()->GetMessageString();
2733 di << ")... KO" << "\n";
2734 Succes = Standard_False;
2740 di << "TestExcept: Successfull completion" << "\n";
2742 di << "TestExcept: failure" << "\n";
2748 #pragma optimize( "", on )
2751 static TopoDS_Compound AddTestStructure(int nCount_)
2757 BRepPrimAPI_MakeBox mkBox(1.0, 2.0, 3.0);
2758 for (int i=0; i<nCount; i++) {
2759 for (int j=0; j<nCount; j++) {
2761 trsf.SetTranslationPart(gp_Vec(5.0*i, 05.0*j, 0.0));
2762 TopLoc_Location topLoc(trsf);
2763 TopoDS_Shape tempShape=mkBox.Shape().Located(topLoc);
2764 B.Add(C, tempShape);
2770 static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2776 di << "Usage : " << argv[0] << " [nCount]" << "\n";
2781 nCount = atoi(argv[1]);
2782 STEPCAFControl_Writer writer;
2783 Handle_TDocStd_Document document;
2784 document = new TDocStd_Document("Pace Test-StepExporter-");
2785 Handle_XCAFDoc_ShapeTool shapeTool;
2786 shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
2787 shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
2788 STEPControl_StepModelType mode = STEPControl_AsIs;
2789 if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
2790 di << "Failed to set assembly mode for step data\n" << "\n";
2795 if( writer.Transfer(document, mode)) {
2796 IFSelect_ReturnStatus stat =
2797 writer.Write("TestExportStructure.step");
2800 catch(OSD_Exception_STACK_OVERFLOW) {
2801 di << "Failed : STACK OVERFLOW\n" << "\n";
2803 catch (Standard_Failure) {
2804 di << "Failed :\n" << "\n";
2805 //cout << Standard_Failure::Caught() << endl;
2806 di << Standard_Failure::Caught()->GetMessageString();
2808 di << argv[0] << " : Finish" << "\n";
2813 static Standard_Integer OCC7372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2817 di << "Usage : " << argv[0] << "\n";
2821 // 1. Create an array of points
2822 Handle(TColgp_HArray1OfPnt2d) ap = new TColgp_HArray1OfPnt2d(1,5);
2823 ap->SetValue(1,gp_Pnt2d(100.0,0.0));
2824 ap->SetValue(2,gp_Pnt2d(100.0,100.0));
2825 ap->SetValue(3,gp_Pnt2d(0.0,100.0));
2826 ap->SetValue(4,gp_Pnt2d(0.0,0.0));
2827 ap->SetValue(5,gp_Pnt2d(50.0,-50.0));
2829 // 2. Create a periodic bspline through these 5 points
2830 Geom2dAPI_Interpolate intp(ap,Standard_True,1e-6);
2832 Handle(Geom2d_BSplineCurve) bspline1 = intp.Curve();
2834 // 3. Increase degree of curve from 3 to 8
2835 bspline1->IncreaseDegree(8); // Increase degree to demonstrate the error
2836 Standard_CString CString1 = "BSplineCurve";
2837 DrawTrSurf::Set(CString1,bspline1);
2839 // 4. Convers BSpline curve to Bezier segments
2840 Geom2dConvert_BSplineCurveToBezierCurve bc(bspline1);
2842 // 5. Test the result of conversion
2843 TCollection_AsciiString aRName;
2844 for(Standard_Integer i = 1; i <= bc.NbArcs(); i++) {
2845 Handle(Geom2d_BezierCurve) arc = bc.Arc(i);
2847 aRName=aRName+TCollection_AsciiString(i);
2848 Standard_CString aRNameStr = aRName.ToCString();
2849 DrawTrSurf::Set(aRNameStr,arc);
2850 di << aRNameStr << " ";
2856 static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2860 di << "Usage : " << argv[0] << " edge1 edge2 plane" << "\n";
2863 TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
2864 if (theEdge1.IsNull()) {
2865 di << "Invalid input shape " << argv[1] << "\n";
2868 TopoDS_Edge theEdge2 = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
2869 if (theEdge2.IsNull()) {
2870 di << "Invalid input shape " << argv[2] << "\n";
2873 TopoDS_Face theFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
2874 if (theFace.IsNull()) {
2875 di << "Invalid input shape " << argv[3] << "\n";
2879 Handle(Geom_Surface) thePlane = BRep_Tool::Surface(theFace);
2881 Standard_Real aConfusion = Precision::Confusion();
2882 Standard_Real aP1first, aP1last, aP2first, aP2last;
2884 Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(theEdge1, aP1first, aP1last);
2885 Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(theEdge2, aP2first, aP2last);
2886 Handle(Geom2d_Curve) aCurve2d1 = GeomProjLib::Curve2d(aCurve1, aP1first, aP1last, thePlane);
2887 Handle(Geom2d_Curve) aCurve2d2 = GeomProjLib::Curve2d(aCurve2, aP2first, aP2last, thePlane);
2889 Geom2dAPI_InterCurveCurve anInter(aCurve2d1, aCurve2d2, aConfusion);
2891 Standard_Integer NbPoints = anInter.NbPoints();
2893 di << "NbPoints = " << NbPoints << "\n" ;
2897 for (i=1; i<=NbPoints; i++) {
2898 gp_Pnt2d aPi = anInter.Point(i);
2899 di << "Point.X(" << i << ") = " << aPi.X() << " " << "Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
2903 Standard_Integer NbSegments = anInter.NbSegments();
2905 di << "\nNbSegments = " << NbSegments << "\n" ;
2907 if (NbSegments > 0) {
2908 IntRes2d_IntersectionSegment aSegment = anInter.Intersector().Segment(1);
2910 gp_Pnt2d aP1 = aCurve2d1->Value(aSegment.FirstPoint().ParamOnFirst());
2911 gp_Pnt2d aP2 = aCurve2d2->Value(aSegment.FirstPoint().ParamOnSecond());
2913 Standard_Real aDist = aP1.Distance(aP2);
2915 di << "aP1.X() = " << aP1.X() << " " << "aP1.Y() = " << aP1.Y() << "\n" ;
2916 di << "aP2.X() = " << aP2.X() << " " << "aP2.Y() = " << aP2.Y() << "\n" ;
2918 di << "Distance = " << aDist << "\n" ;
2920 di << "Confusion = " << aConfusion << "\n" ;
2922 if (aDist > aConfusion) {
2923 di << "\n" << argv[0] << " Faulty" << "\n" ;
2925 di << "\n" << argv[0] << " OK" << "\n" ;
2928 di << "\n" << argv[0] << " OK" << "\n" ;
2933 static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2937 di << "Usage : " << argv[0] << " lower upper" << "\n";
2941 Standard_Integer LOWER = atoi(argv[1]);
2942 Standard_Integer UPPER = atoi(argv[2]);
2944 //! 0. Create an empty document with several test labels
2945 Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
2946 doc->SetUndoLimit(100);
2947 TDF_Label main_label = doc->Main();
2948 TDF_Label label1 = main_label.FindChild(1, Standard_True);
2949 TDF_Label label2 = main_label.FindChild(2, Standard_True);
2951 //! 1. Set/Get OCAF attribute
2953 TDataStd_RealArray::Set(label1, LOWER, UPPER);
2954 Handle(TDataStd_RealArray) array;
2955 if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) &&
2956 array->Lower() == LOWER && array->Upper() == UPPER)
2957 cout<<"1: OK"<<endl;
2960 cout<<"1: Failed.."<<endl;
2963 doc->CommitCommand();
2965 //! 2. Set/Get value
2968 for (i = LOWER; i <= UPPER; i++)
2969 array->SetValue(i, i);
2970 for (i = LOWER; i <= UPPER; i++)
2972 if (array->Value(i) != i)
2974 cout<<"2: Failed.."<<endl;
2978 cout<<"2: OK"<<endl;
2979 doc->CommitCommand();
2981 //! 3. Re-init the array
2983 array->Init(LOWER + 2, UPPER + 4);
2984 if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4)
2986 cout<<"3: Failed.."<<endl;
2989 for (i = LOWER + 2; i <= UPPER + 4; i++)
2990 array->SetValue(i, i);
2991 for (i = LOWER + 2; i <= UPPER + 4; i++)
2993 if (array->Value(i) != i)
2995 cout<<"3: Failed.."<<endl;
2999 cout<<"3: OK"<<endl;
3000 doc->CommitCommand();
3004 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(LOWER + 5, UPPER + 5);
3005 for (i = LOWER + 5; i <= UPPER + 5; i++)
3006 arr->SetValue(i, i);
3007 array->ChangeArray(arr);
3008 for (i = LOWER + 5; i <= UPPER + 5; i++)
3010 if (array->Value(i) != i)
3012 cout<<"4: Failed.."<<endl;
3016 cout<<"4: OK"<<endl;
3017 doc->CommitCommand();
3019 //! 5. Copy the array
3021 TDF_CopyLabel copier(label1, label2);
3023 if (!copier.IsDone())
3025 cout<<"5: Failed.."<<endl;
3028 Handle(TDataStd_RealArray) array2;
3029 if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
3031 cout<<"5: Failed.."<<endl;
3034 for (i = LOWER + 5; i <= UPPER + 5; i++)
3036 if (array->Value(i) != i)
3038 cout<<"5: Failed.."<<endl;
3042 cout<<"5: OK"<<endl;
3043 doc->CommitCommand();
3046 //! 6.a: undoes the 5th action: the copied array should disappear
3048 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3049 label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
3051 cout<<"6.a: Failed.."<<endl;
3054 //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4)
3056 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3057 array->Lower() != LOWER + 2 ||
3058 array->Upper() != UPPER + 4)
3060 cout<<"6.b: Failed.."<<endl;
3063 for (i = LOWER + 2; i <= UPPER + 4; i++)
3065 if (array->Value(i) != i)
3067 cout<<"6.b: Failed.."<<endl;
3071 //! 6.c: undoes the 3d action: the array should be changed to (lower,upper)
3073 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3074 array->Lower() != LOWER ||
3075 array->Upper() != UPPER)
3077 cout<<"6.c: Failed.."<<endl;
3080 for (i = LOWER; i <= UPPER; i++)
3082 if (array->Value(i) != i)
3084 cout<<"6.c: Failed.."<<endl;
3088 //! 6.d: undoes and redoes the 2nd action: no change is expected.
3091 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3092 array->Lower() != LOWER ||
3093 array->Upper() != UPPER)
3095 cout<<"6.d: Failed.."<<endl;
3098 for (i = LOWER; i <= UPPER; i++)
3100 if (array->Value(i) != i)
3102 cout<<"6.d: Failed.."<<endl;
3106 cout<<"6: OK"<<endl;
3108 //! 7. Re-set the array
3110 array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1);
3111 if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1)
3113 cout<<"7: Failed.."<<endl;
3116 for (i = LOWER + 1; i <= UPPER + 1; i++)
3117 array->SetValue(i, i);
3118 for (i = LOWER + 1; i <= UPPER + 1; i++)
3120 if (array->Value(i) != i)
3122 cout<<"7: Failed.."<<endl;
3126 cout<<"7: OK"<<endl;
3127 doc->CommitCommand();
3129 //! 8.Test of speed: set LOWER and UPPER equal to great integer number and
3130 //! measure the time spent by this test.
3136 static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3138 Standard_Boolean IsEvenArgc = Standard_True;
3139 if (argc % 2 == 0) {
3140 IsEvenArgc = Standard_True;
3142 IsEvenArgc = Standard_False;
3145 if (argc < 3 || IsEvenArgc)
3147 di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]" << "\n";
3151 Standard_Integer i, aValue, aPosition;
3152 NCollection_Vector<int> vec;
3153 for (i = 0; i < argc - 1; i++) {
3155 aValue = atoi(argv[i]);
3156 aPosition = atoi(argv[i+1]);
3157 vec.SetValue(aValue, aPosition);
3159 NCollection_Vector<int>::Iterator it(vec);
3161 for (j = 0; it.More(); it.Next(), j++) {
3162 //di << it.Value() << "\n";
3163 di << j << " " << it.Value() << "\n";
3169 static Standard_Integer OCC8797 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3172 di << "Usage : " << argv[0] << "\n";
3176 gp_Pnt point(0.0,0.0,0.0);
3178 TColgp_Array1OfPnt poles(0,6);
3181 point.SetCoord(1.0,1.0,0.0);
3184 point.SetCoord(2.0,1.0,0.0);
3187 point.SetCoord(3.0,0.0,0.0);
3190 point.SetCoord(4.0,1.0,0.0);
3193 point.SetCoord(5.0,1.0,0.0);
3196 point.SetCoord(6.0,0.0,0.0);
3199 TColStd_Array1OfReal knots(0,2);
3204 TColStd_Array1OfInteger multi(0,2);
3209 Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles,knots,multi,3);
3212 Standard_Real l_abcissa,l_gprop;
3213 GeomAdaptor_Curve adaptor_spline(spline);
3214 GCPnts_AbscissaPoint temp;
3215 l_abcissa=temp.Length(adaptor_spline);
3216 cout<<"Length Spline(abcissa_Pnt): "<<l_abcissa<<endl;
3219 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge (spline);
3221 BRepGProp::LinearProperties(edge,prop);
3222 l_gprop=prop.Mass();
3223 cout<<"Length Spline(GProp_GProps): "<<l_gprop<<endl;
3225 cout<<"Difference (abcissa_Pnt<->GProp_GProps): "<<l_gprop-l_abcissa<<endl;
3230 static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3234 di << "Usage : " << argv[0] << "\n";
3238 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
3239 if(AISContext.IsNull())
3241 di << "use 'vinit' command before " << argv[0] << "\n";
3246 AIS_ListOfInteractive ListOfIO_1;
3247 AISContext->ObjectsInside(ListOfIO_1);
3248 di<< "ObjectsInside = " << ListOfIO_1.Extent() <<"\n";
3249 if (!ListOfIO_1.IsEmpty() ) {
3250 AIS_ListIteratorOfListOfInteractive iter;
3251 for (iter.Initialize(ListOfIO_1); iter.More() ; iter.Next() ) {
3252 Handle(AIS_InteractiveObject) aIO=iter.Value();
3253 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3257 // ObjectsInCollector
3258 AIS_ListOfInteractive ListOfIO_2;
3259 AISContext->ObjectsInCollector(ListOfIO_2);
3260 di<< "ObjectsInCollector = " << ListOfIO_2.Extent() <<"\n";
3261 if (!ListOfIO_2.IsEmpty() ) {
3262 AIS_ListIteratorOfListOfInteractive iter;
3263 for (iter.Initialize(ListOfIO_2); iter.More() ; iter.Next() ) {
3264 Handle(AIS_InteractiveObject) aIO=iter.Value();
3265 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3272 static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3274 if ((argc < 9) || (((argc-3) % 3) != 0))
3276 di << "Usage : " << argv[0] << "polygon lastedge x1 y1 z1 x2 y2 z2 ...\n";
3279 Standard_Integer i, j, np = (argc-3) / 3;
3280 BRepBuilderAPI_MakePolygon W;
3282 for (i = 1; i <= np; i ++) {
3283 W.Add(gp_Pnt(atof(argv[j]),atof(argv[j+1]),atof(argv[j+2])));
3287 DBRep::Set(argv[1],W.Wire());
3288 DBRep::Set(argv[2],W.Edge());
3292 static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3295 di << "Usage : " << argv[0] << " ratio origin_x origin_y origin_z\n";
3298 gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
3299 gp_Dir(1., -1., 0.));
3301 aTrf.SetAffinity (aPln, atof(argv[4]));
3302 gp_XYZ aOrigin (atof(argv[1]),atof(argv[2]),atof(argv[3]));
3303 gp_XYZ aResult (aOrigin);
3304 aTrf.Transforms(aResult);
3306 sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
3307 aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
3308 aResult.X(), aResult.Y(), aResult.Z());
3313 Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3316 di << "Usage : " << argv[0] << " shape [deflection]\n";
3320 TopoDS_Shape aShape = DBRep::Get(argv[1]);
3322 if (aShape.IsNull()) {
3323 di<<" Null shape is not allowed";
3327 Standard_Real aDeflection = 0.45110277533;
3329 aDeflection = atof(argv[2]);
3331 di<<"deflection="<< aDeflection << "\n";
3333 BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI/9.);
3334 TopLoc_Location aLocation;
3335 Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
3337 if(aTriang.IsNull()) {
3338 di << argv[0] << " : Faulty\n" ;
3340 di << argv[0] << " : OK\n" ;
3341 di<<"NbNodes="<< aTriang->NbNodes()<< "\n";
3342 di<<"NbTriangles="<< aTriang->NbTriangles()<< "\n";
3347 static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3350 di << "Usage : " << argv[0] << " A B C\n";
3355 gp_Lin2d aLin2d (atof(argv[1]),atof(argv[2]),atof(argv[3]));
3356 gp_Pnt2d anOrigin = aLin2d.Location();
3357 di << "X_0 = " << anOrigin.X() << " Y_0 = " << anOrigin.Y() << "\n" ;
3359 catch(Standard_ConstructionError)
3361 di << argv[0] << " Exception: Sqrt(A*A + B*B) <= Resolution from gp\n";
3366 static Standard_Integer OCC15755 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3369 di << "Usage : " << argv[0] << " file shape\n";
3373 IGESControl_Reader aReader;
3374 aReader.ReadFile(argv[1]);
3375 aReader.SetReadVisible(Standard_True);
3376 aReader.TransferRoots();
3378 Handle(IGESData_IGESModel) model = aReader.IGESModel();
3379 if (model.IsNull()) {
3380 di << "model.IsNull()\n";
3383 Standard_Integer nb = model->NbEntities();
3384 for (Standard_Integer i = 1; i <= nb; i ++) {
3385 Handle(IGESData_IGESEntity) ent = model->Entity(i);
3386 Handle(TCollection_HAsciiString) name;
3387 name = ent->NameValue();
3388 Standard_CString aStr = name->ToCString();
3389 di << "NameValue = " << aStr << "\n";
3392 TopoDS_Shape shape = aReader.OneShape();
3393 DBRep::Set(argv[2],shape);
3397 // For OCC16782 testing
3398 #include <AppStd_Application.hxx>
3399 #include <TDF_Tool.hxx>
3400 #include <TColStd_HArray1OfInteger.hxx>
3402 #include <TColStd_ListIteratorOfListOfInteger.hxx>
3403 #include <TColStd_ListIteratorOfListOfReal.hxx>
3404 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
3405 #include <TDataStd_ListIteratorOfListOfByte.hxx>
3406 #include <TDF_ListIteratorOfLabelList.hxx>
3408 #include <TDataStd_Tick.hxx>
3409 #include <TDataStd_IntegerList.hxx>
3410 #include <TDataStd_RealList.hxx>
3411 #include <TDataStd_ExtStringList.hxx>
3412 #include <TDataStd_BooleanList.hxx>
3413 #include <TDataStd_ReferenceList.hxx>
3414 #include <TDataStd_BooleanArray.hxx>
3415 #include <TDataStd_ReferenceArray.hxx>
3416 #include <TDataStd_ByteArray.hxx>
3417 #include <TDataStd_NamedData.hxx>
3418 #include <TDF_Reference.hxx>
3420 Handle(AppStd_Application) app;
3421 int TestSetGet(const Handle(TDocStd_Document)& doc)
3425 TDataStd_Tick::Set(doc->Main());
3427 Handle(TDataStd_Tick) tick;
3428 if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick))
3431 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3432 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3434 doc->Main().ResumeAttribute(tick);
3435 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3438 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3439 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3442 // TDataStd_IntegerList:
3444 Handle(TDataStd_IntegerList) setintlist = TDataStd_IntegerList::Set(doc->Main());
3445 setintlist->Append(2);
3446 setintlist->Prepend(1);
3447 setintlist->InsertAfter(3, 2);
3448 setintlist->InsertBefore(0, 1);
3449 setintlist->Append(200);
3450 setintlist->Remove(0);
3451 setintlist->Remove(200);
3453 Handle(TDataStd_IntegerList) getintlist;
3454 if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist))
3456 if (getintlist->First() != 1)
3458 if (getintlist->Last() != 3)
3460 const TColStd_ListOfInteger& intlist = getintlist->List();
3461 TColStd_ListIteratorOfListOfInteger itr_intlist(intlist);
3462 for (; itr_intlist.More(); itr_intlist.Next())
3464 if (itr_intlist.Value() != 1 &&
3465 itr_intlist.Value() != 2 &&
3466 itr_intlist.Value() != 3)
3471 getintlist->Clear();
3473 // TDataStd_RealList:
3475 Handle(TDataStd_RealList) setdbllist = TDataStd_RealList::Set(doc->Main());
3476 setdbllist->Append(2.5);
3477 setdbllist->Prepend(1.5);
3478 setdbllist->InsertAfter(3.5, 2.5);
3479 setdbllist->InsertBefore(0.5, 1.5);
3480 setdbllist->Append(200.5);
3481 setdbllist->Remove(0.5);
3482 setdbllist->Remove(200.5);
3484 Handle(TDataStd_RealList) getdbllist;
3485 if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist))
3487 if (getdbllist->First() != 1.5)
3489 if (getdbllist->Last() != 3.5)
3491 const TColStd_ListOfReal& dbllist = getdbllist->List();
3492 TColStd_ListIteratorOfListOfReal itr_dbllist(dbllist);
3493 for (; itr_dbllist.More(); itr_dbllist.Next())
3495 if (itr_dbllist.Value() != 1.5 &&
3496 itr_dbllist.Value() != 2.5 &&
3497 itr_dbllist.Value() != 3.5)
3502 getdbllist->Clear();
3504 // TDataStd_ExtStringList:
3506 Handle(TDataStd_ExtStringList) setstrlist = TDataStd_ExtStringList::Set(doc->Main());
3507 setstrlist->Append("Hello");
3508 setstrlist->Prepend("Guten Tag");
3509 setstrlist->InsertAfter("Bonjour", "Guten Tag");
3510 setstrlist->InsertBefore("Bonsoir", "Hello");
3511 setstrlist->Append("Good bye");
3512 setstrlist->Remove("Bonsoir");
3513 setstrlist->Remove("Good bye");
3515 Handle(TDataStd_ExtStringList) getstrlist;
3516 if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist))
3518 if (getstrlist->First() != "Guten Tag")
3520 if (getstrlist->Last() != "Hello")
3522 const TDataStd_ListOfExtendedString& strlist = getstrlist->List();
3523 TDataStd_ListIteratorOfListOfExtendedString itr_strlist(strlist);
3524 for (; itr_strlist.More(); itr_strlist.Next())
3526 if (itr_strlist.Value() != "Guten Tag" &&
3527 itr_strlist.Value() != "Bonjour" &&
3528 itr_strlist.Value() != "Hello")
3533 getstrlist->Clear();
3535 // TDataStd_BooleanList:
3537 Handle(TDataStd_BooleanList) setboollist = TDataStd_BooleanList::Set(doc->Main());
3538 setboollist->Append(Standard_True);
3539 setboollist->Prepend(Standard_False);
3541 Handle(TDataStd_BooleanList) getboollist;
3542 if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist))
3544 if (getboollist->First() != Standard_False)
3546 if (getboollist->Last() != Standard_True)
3548 const TDataStd_ListOfByte& boollist = getboollist->List();
3549 TDataStd_ListIteratorOfListOfByte itr_boollist(boollist);
3550 for (; itr_boollist.More(); itr_boollist.Next())
3552 if (itr_boollist.Value() != Standard_True &&
3553 itr_boollist.Value() != Standard_False)
3558 getboollist->Clear();
3560 // TDataStd_ReferenceList:
3561 TDF_Label L1 = doc->Main().FindChild(100);
3562 TDF_Label L2 = doc->Main().FindChild(101);
3563 TDF_Label L3 = doc->Main().FindChild(102);
3564 TDF_Label L4 = doc->Main().FindChild(103);
3565 TDF_Label L5 = doc->Main().FindChild(104);
3567 Handle(TDataStd_ReferenceList) setreflist = TDataStd_ReferenceList::Set(doc->Main());
3568 setreflist->Append(L1);
3569 setreflist->Prepend(L2);
3570 setreflist->InsertAfter(L3, L2);
3571 setreflist->InsertBefore(L4, L1);
3572 setreflist->Append(L5);
3573 setreflist->Remove(L4);
3574 setreflist->Remove(L5);
3576 Handle(TDataStd_ReferenceList) getreflist;
3577 if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist))
3579 if (getreflist->First() != L2)
3581 if (getreflist->Last() != L1)
3583 const TDF_LabelList& reflist = getreflist->List();
3584 TDF_ListIteratorOfLabelList itr_reflist(reflist);
3585 for (; itr_reflist.More(); itr_reflist.Next())
3587 if (itr_reflist.Value() != L1 &&
3588 itr_reflist.Value() != L2 &&
3589 itr_reflist.Value() != L3)
3594 getreflist->Clear();
3596 // TDataStd_BooleanArray:
3598 Handle(TDataStd_BooleanArray) setboolarr = TDataStd_BooleanArray::Set(doc->Main(), 12, 16);
3599 setboolarr->SetValue(12, Standard_True);
3600 setboolarr->SetValue(13, Standard_False);
3601 setboolarr->SetValue(14, Standard_False);
3602 setboolarr->SetValue(15, Standard_False);
3603 setboolarr->SetValue(16, Standard_True);
3604 setboolarr->SetValue(14, Standard_True);
3606 Handle(TDataStd_BooleanArray) getboolarr;
3607 if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr))
3609 if (getboolarr->Value(12) != Standard_True)
3611 if (getboolarr->Value(13) != Standard_False)
3613 if (getboolarr->Value(14) != Standard_True)
3615 if (getboolarr->Value(15) != Standard_False)
3617 if (getboolarr->Value(16) != Standard_True)
3620 // TDataStd_ReferenceArray:
3622 Handle(TDataStd_ReferenceArray) setrefarr = TDataStd_ReferenceArray::Set(doc->Main(), 0, 4);
3623 setrefarr->SetValue(0, L1);
3624 setrefarr->SetValue(1, L2);
3625 setrefarr->SetValue(2, L3);
3626 setrefarr->SetValue(3, L4);
3627 setrefarr->SetValue(4, L5);
3629 Handle(TDataStd_ReferenceArray) getrefarr;
3630 if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr))
3632 if (getrefarr->Value(0) != L1)
3634 if (getrefarr->Value(1) != L2)
3636 if (getrefarr->Value(2) != L3)
3638 if (getrefarr->Value(3) != L4)
3640 if (getrefarr->Value(4) != L5)
3643 // TDataStd_ByteArray:
3645 Handle(TDataStd_ByteArray) setbytearr = TDataStd_ByteArray::Set(doc->Main(), 12, 16);
3646 setbytearr->SetValue(12, 0);
3647 setbytearr->SetValue(13, 1);
3648 setbytearr->SetValue(14, 2);
3649 setbytearr->SetValue(15, 3);
3650 setbytearr->SetValue(16, 255);
3652 Handle(TDataStd_ByteArray) getbytearr;
3653 if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr))
3655 if (getbytearr->Value(12) != 0)
3657 if (getbytearr->Value(13) != 1)
3659 if (getbytearr->Value(14) != 2)
3661 if (getbytearr->Value(15) != 3)
3663 if (getbytearr->Value(16) != 255)
3666 // TDataStd_NamedData:
3668 Handle(TDataStd_NamedData) setnd = TDataStd_NamedData::Set(doc->Main());
3669 setnd->SetInteger("Integer1", 1);
3670 setnd->SetInteger("Integer2", 2);
3671 setnd->SetInteger("Integer3", 8);
3672 setnd->SetInteger("Integer3", 3);
3674 Handle(TDataStd_NamedData) getnd;
3675 if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd))
3677 if (!getnd->HasIntegers())
3679 if (!getnd->HasInteger("Integer1"))
3681 if (getnd->GetInteger("Integer2") != 2)
3683 if (getnd->GetInteger("Integer3") != 3)
3689 int TestUndoRedo(const Handle(TDocStd_Document)& doc)
3693 Handle(TDataStd_Tick) tick = TDataStd_Tick::Set(doc->Main());
3694 doc->CommitCommand();
3695 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3698 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3701 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3704 // TDataStd_IntegerList:
3706 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc->Main());
3708 intlist->Prepend(1);
3709 intlist->InsertBefore(0, 1);
3710 intlist->InsertAfter(3, 2);
3711 doc->CommitCommand();
3712 if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID()))
3715 if (!intlist->IsEmpty())
3718 if (!intlist->Extent())
3720 if (intlist->First() != 0)
3722 if (intlist->Last() != 3)
3726 // TDataStd_RealList:
3728 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc->Main());
3729 dbllist->Append(2.5);
3730 dbllist->Prepend(1.5);
3731 dbllist->InsertBefore(0.5, 1.5);
3732 dbllist->InsertAfter(3.5, 2.5);
3733 doc->CommitCommand();
3734 if (!doc->Main().IsAttribute(TDataStd_RealList::GetID()))
3737 if (!dbllist->IsEmpty())
3740 if (!dbllist->Extent())
3742 if (dbllist->First() != 0.5)
3744 if (dbllist->Last() != 3.5)
3748 // TDataStd_ExtStringList:
3750 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc->Main());
3751 strlist->Append("Hello");
3752 strlist->Prepend("Guten Tag");
3753 strlist->InsertAfter("Bonjour", "Guten Tag");
3754 strlist->InsertBefore("Bonsoir", "Hello");
3755 doc->CommitCommand();
3756 if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID()))
3759 if (!strlist->IsEmpty())
3762 if (!strlist->Extent())
3764 if (strlist->First() != "Guten Tag")
3766 if (strlist->Last() != "Hello")
3770 // TDataStd_BooleanList:
3772 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc->Main());
3773 boollist->Append(Standard_True);
3774 boollist->Prepend(Standard_False);
3775 doc->CommitCommand();
3776 if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID()))
3779 if (!boollist->IsEmpty())
3782 if (!boollist->Extent())
3784 if (boollist->First() != Standard_False)
3786 if (boollist->Last() != Standard_True)
3790 // TDataStd_ReferenceList:
3791 TDF_Label L1 = doc->Main().FindChild(100);
3792 TDF_Label L2 = doc->Main().FindChild(101);
3793 TDF_Label L3 = doc->Main().FindChild(102);
3794 TDF_Label L4 = doc->Main().FindChild(103);
3796 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc->Main());
3797 reflist->Append(L1);
3798 reflist->Prepend(L2);
3799 reflist->InsertBefore(L3, L1);
3800 reflist->InsertAfter(L4, L2);
3801 doc->CommitCommand();
3802 if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID()))
3805 if (!reflist->IsEmpty())
3808 if (!reflist->Extent())
3810 if (reflist->First() != L2)
3812 if (reflist->Last() != L1)
3816 // TDataStd_BooleanArray:
3818 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc->Main(), 23, 25);
3819 boolarr->SetValue(23, Standard_True);
3820 boolarr->SetValue(25, Standard_True);
3821 doc->CommitCommand();
3823 boolarr = TDataStd_BooleanArray::Set(doc->Main(), 230, 250);
3824 boolarr->SetValue(230, Standard_True);
3825 boolarr->SetValue(250, Standard_True);
3826 doc->CommitCommand();
3828 if (boolarr->Value(23) != Standard_True)
3830 if (boolarr->Value(24) != Standard_False)
3832 if (boolarr->Value(25) != Standard_True)
3835 if (boolarr->Value(230) != Standard_True)
3837 if (boolarr->Value(240) != Standard_False)
3839 if (boolarr->Value(250) != Standard_True)
3842 // TDataStd_ReferenceArray:
3844 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc->Main(), 5, 8);
3845 refarr->SetValue(5, L1);
3846 refarr->SetValue(6, L2);
3847 refarr->SetValue(7, L3);
3848 refarr->SetValue(8, L4);
3849 doc->CommitCommand();
3850 if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID()))
3854 if (refarr->Value(5) != L1)
3856 if (refarr->Value(6) != L2)
3858 if (refarr->Value(7) != L3)
3860 if (refarr->Value(8) != L4)
3863 // TDataStd_ByteArray:
3865 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc->Main(), 23, 25);
3866 bytearr->SetValue(23, 23);
3867 bytearr->SetValue(25, 25);
3868 doc->CommitCommand();
3870 bytearr = TDataStd_ByteArray::Set(doc->Main(), 230, 250);
3871 bytearr->SetValue(230, 230);
3872 bytearr->SetValue(250, 250);
3873 doc->CommitCommand();
3875 if (bytearr->Value(23) != 23)
3877 if (bytearr->Value(25) != 25)
3880 if (bytearr->Value(230) != 230)
3882 if (bytearr->Value(250) != 250)
3885 // TDataStd_NamedData:
3887 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(doc->Main());
3888 nd->SetByte("b14", 12);
3889 nd->SetByte("b17", 18);
3890 nd->SetByte("b14", 14);
3891 nd->SetByte("b17", 17);
3892 doc->CommitCommand();
3894 nd = TDataStd_NamedData::Set(doc->Main());
3895 nd->SetReal("r14", 14);
3896 nd->SetReal("r17", 17);
3897 nd->SetReal("r14", 14.4);
3898 nd->SetReal("r17", 17.7);
3899 doc->CommitCommand();
3901 if (nd->HasStrings())
3905 if (nd->HasReal("r17"))
3907 if (!nd->HasBytes())
3909 if (nd->GetByte("b14") != 14)
3911 if (nd->GetByte("b17") != 17)
3913 if (nd->HasByte("b18"))
3916 if (!nd->HasBytes())
3918 if (!nd->HasReals())
3920 if (nd->GetByte("b14") != 14)
3922 if (nd->GetReal("r14") != 14.4)
3924 if (nd->GetReal("r17") != 17.7)
3930 int TestCopyPaste(const Handle(TDocStd_Document)& doc)
3932 TDF_Label L1 = doc->Main().FindChild(1);
3933 TDF_Label L2 = doc->Main().FindChild(2);
3934 TDF_CopyLabel copier(L1, L2);
3937 TDataStd_Tick::Set(L1);
3939 if (!copier.IsDone())
3941 if (!L2.IsAttribute(TDataStd_Tick::GetID()))
3944 // TDataStd_IntegerList:
3945 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(L1);
3947 intlist->InsertAfter(2, 1);
3949 if (!copier.IsDone())
3953 if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3955 if (intlist->First() != 1)
3957 if (intlist->Last() != 2)
3961 // TDataStd_RealList:
3962 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(L1);
3963 dbllist->Append(1.5);
3964 dbllist->InsertAfter(2.5, 1.5);
3966 if (!copier.IsDone())
3970 if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist))
3972 if (dbllist->First() != 1.5)
3974 if (dbllist->Last() != 2.5)
3978 // TDataStd_ExtStringList:
3979 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(L1);
3980 strlist->Append("Open CASCADE");
3981 strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE");
3983 if (!copier.IsDone())
3987 if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
3989 if (strlist->First() != "Open CASCADE")
3991 if (strlist->Last() != " - is the best set of libraries!")
3995 // TDataStd_BooleanList:
3996 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(L1);
3997 boollist->Append(Standard_True);
3998 boollist->Prepend(Standard_False);
4000 if (!copier.IsDone())
4004 if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4006 if (boollist->First() != Standard_False)
4008 if (boollist->Last() != Standard_True)
4012 // TDataStd_ReferenceList:
4013 TDF_Label L100 = doc->Main().FindChild(100);
4014 TDF_Label L101 = doc->Main().FindChild(101);
4015 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(L1);
4016 reflist->Append(L100);
4017 reflist->InsertAfter(L101, L100);
4019 if (!copier.IsDone())
4023 if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4025 if (reflist->First() != L100)
4027 if (reflist->Last() != L101)
4031 // TDataStd_BooleanArray:
4032 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(L1, 4, 6);
4033 boolarr->SetValue(4, Standard_True);
4034 boolarr->SetValue(6, Standard_True);
4036 if (!copier.IsDone())
4039 if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4041 if (boolarr->Value(4) != Standard_True)
4043 if (boolarr->Value(5) != Standard_False)
4045 if (boolarr->Value(6) != Standard_True)
4048 // TDataStd_ReferenceArray:
4049 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(L1, 3, 4);
4050 refarr->SetValue(3, L100);
4051 refarr->SetValue(4, L101);
4053 if (!copier.IsDone())
4056 if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4058 if (refarr->Value(3) != L100)
4060 if (refarr->Value(4) != L101)
4063 // TDataStd_ByteArray:
4064 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(L1, 4, 6);
4065 bytearr->SetValue(4, 40);
4066 bytearr->SetValue(6, 60);
4068 if (!copier.IsDone())
4071 if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4073 if (bytearr->Value(4) != 40)
4075 if (bytearr->Value(6) != 60)
4078 // TDataStd_NamedData:
4079 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(L1);
4080 nd->SetInteger("Integer1", 11);
4081 nd->SetReal("Real1", 11.1);
4082 nd->SetString("String1", "11.11111111");
4083 nd->SetByte("Byte1", 111);
4084 Handle(TColStd_HArray1OfInteger) ints_arr = new TColStd_HArray1OfInteger(4, 5);
4085 ints_arr->SetValue(4, 4);
4086 ints_arr->SetValue(5, 5);
4087 nd->SetArrayOfIntegers("Integers1", ints_arr);
4089 if (!copier.IsDone())
4092 if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd))
4094 if (!nd->HasIntegers())
4096 if (!nd->HasReals())
4098 if (!nd->HasStrings())
4100 if (!nd->HasBytes())
4102 if (!nd->HasArraysOfIntegers())
4104 if (nd->HasArraysOfReals())
4106 if (!nd->HasInteger("Integer1"))
4108 if (nd->GetInteger("Integer1") != 11)
4110 if (!nd->HasReal("Real1"))
4112 if (nd->GetReal("Real1") != 11.1)
4114 if (!nd->HasString("String1"))
4116 if (nd->GetString("String1") != "11.11111111")
4118 if (!nd->HasByte("Byte1"))
4120 if (nd->GetByte("Byte1") != 111)
4122 if (!nd->HasArrayOfIntegers("Integers1"))
4124 const Handle(TColStd_HArray1OfInteger)& ints_arr_out = nd->GetArrayOfIntegers("Integers1");
4125 if (ints_arr_out.IsNull())
4127 if (ints_arr_out->Value(5) != 5)
4133 int TestOpenSave(TCollection_ExtendedString aFile1,
4134 TCollection_ExtendedString aFile2,
4135 TCollection_ExtendedString aFile3)
4138 Handle(TDocStd_Document) doc_std, doc_std_open;
4139 app->NewDocument("MDTV-Standard", doc_std);
4141 TDataStd_Tick::Set(doc_std->Main());
4142 // TDataStd_IntegerList:
4143 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc_std->Main());
4146 // TDataStd_RealList:
4147 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc_std->Main());
4148 dbllist->Append(1.5);
4149 dbllist->Append(5.5);
4150 // TDataStd_ExtStringList:
4151 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc_std->Main());
4152 strlist->Append("Auf");
4153 strlist->Append("Wiedersehen");
4154 // TDataStd_BooleanList:
4155 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc_std->Main());
4156 boollist->Append(Standard_False);
4157 boollist->Append(Standard_True);
4158 // TDataStd_ReferenceList:
4159 TCollection_AsciiString entry1, entry2, entry_first, entry_last;
4160 TDF_Label Lstd1 = doc_std->Main().FindChild(100);
4161 TDF_Tool::Entry(Lstd1, entry1);
4162 TDF_Label Lstd2 = doc_std->Main().FindChild(101);
4163 TDF_Tool::Entry(Lstd2, entry2);
4164 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc_std->Main());
4165 reflist->Append(Lstd1);
4166 reflist->Append(Lstd2);
4167 // TDataStd_BooleanArray:
4168 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc_std->Main(), 15, 18);
4169 boolarr->SetValue(15, Standard_False);
4170 boolarr->SetValue(16, Standard_True);
4171 boolarr->SetValue(17, Standard_True);
4172 boolarr->SetValue(18, Standard_True);
4173 // TDataStd_ReferenceArray:
4174 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc_std->Main(), 45, 46);
4175 refarr->SetValue(45, Lstd1);
4176 refarr->SetValue(46, Lstd2);
4177 // TDataStd_ByteArray:
4178 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc_std->Main(), 15, 18);
4179 bytearr->SetValue(15, 150);
4180 bytearr->SetValue(16, 160);
4181 bytearr->SetValue(17, 170);
4182 bytearr->SetValue(18, 180);
4183 // TDataStd_NamedData:
4184 Handle(TDataStd_NamedData) nameddata = TDataStd_NamedData::Set(doc_std->Main());
4186 TDF_Label Lstd3 = doc_std->Main().FindChild(103);
4187 Handle(TDF_Reference) ref = TDF_Reference::Set(doc_std->Main(), Lstd3);
4190 //if (app->SaveAs(doc_std, "W:\\doc.std") != PCDM_SS_OK)
4191 if (app->SaveAs(doc_std, aFile1) != PCDM_SS_OK)
4200 app->Close(doc_std);
4202 //if (app->Open("W:\\doc.std", doc_std_open) != PCDM_RS_OK)
4203 if (app->Open(aFile1, doc_std_open) != PCDM_RS_OK)
4205 if (!doc_std_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4207 if (!doc_std_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4209 if (intlist->First() != 1)
4211 if (intlist->Last() != 5)
4213 if (!doc_std_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4215 if (dbllist->First() != 1.5)
4217 if (dbllist->Last() != 5.5)
4219 if (!doc_std_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4221 if (strlist->First() != "Auf")
4223 if (strlist->Last() != "Wiedersehen")
4225 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4227 if (boollist->First() != Standard_False)
4229 if (boollist->Last() != Standard_True)
4231 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4233 TDF_Tool::Entry(reflist->First(), entry_first);
4234 if (entry1 != entry_first)
4236 TDF_Tool::Entry(reflist->Last(), entry_last);
4237 if (entry2 != entry_last)
4239 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4241 if (boolarr->Value(15) != Standard_False)
4243 if (boolarr->Value(16) != Standard_True)
4245 if (boolarr->Value(17) != Standard_True)
4247 if (boolarr->Value(18) != Standard_True)
4249 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4251 TDF_Tool::Entry(refarr->Value(45), entry_first);
4252 if (entry1 != entry_first)
4254 TDF_Tool::Entry(refarr->Value(46), entry_last);
4255 if (entry2 != entry_last)
4257 if (!doc_std_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4259 if (bytearr->Value(15) != 150)
4261 if (bytearr->Value(16) != 160)
4263 if (bytearr->Value(17) != 170)
4265 if (bytearr->Value(18) != 180)
4267 if (!doc_std_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4269 if (ref->Get().IsNull())
4271 if (ref->Get().Tag() != 103)
4275 Handle(TDocStd_Document) doc_xml, doc_xml_open;
4276 app->NewDocument("XmlOcaf", doc_xml);
4278 TDataStd_Tick::Set(doc_xml->Main());
4279 // TDataStd_IntegerList:
4280 intlist = TDataStd_IntegerList::Set(doc_xml->Main());
4283 // TDataStd_RealList:
4284 dbllist = TDataStd_RealList::Set(doc_xml->Main());
4285 dbllist->Append(1.5);
4286 dbllist->Append(5.5);
4287 // TDataStd_ExtStringList:
4288 strlist = TDataStd_ExtStringList::Set(doc_xml->Main());
4289 strlist->Append("Guten ");
4290 strlist->Append("Tag");
4291 // TDataStd_BooleanList:
4292 boollist = TDataStd_BooleanList::Set(doc_xml->Main());
4293 boollist->Append(Standard_False);
4294 boollist->Append(Standard_True);
4295 // TDataStd_ReferenceList:
4296 TDF_Label Lxml1 = doc_xml->Main().FindChild(100);
4297 TDF_Tool::Entry(Lxml1, entry1);
4298 TDF_Label Lxml2 = doc_xml->Main().FindChild(101);
4299 TDF_Tool::Entry(Lxml2, entry2);
4300 reflist = TDataStd_ReferenceList::Set(doc_xml->Main());
4301 reflist->Append(Lxml1);
4302 reflist->Append(Lxml2);
4303 // TDataStd_BooleanArray:
4304 boolarr = TDataStd_BooleanArray::Set(doc_xml->Main(), 15, 24);
4305 boolarr->SetValue(15, Standard_False);
4306 boolarr->SetValue(16, Standard_True);
4307 boolarr->SetValue(17, Standard_True);
4308 boolarr->SetValue(18, Standard_True);
4309 boolarr->SetValue(19, Standard_True);
4310 boolarr->SetValue(20, Standard_True);
4311 boolarr->SetValue(21, Standard_False);
4312 boolarr->SetValue(22, Standard_True);
4313 boolarr->SetValue(23, Standard_True);
4314 boolarr->SetValue(24, Standard_True);
4315 // TDataStd_ReferenceArray:
4316 refarr = TDataStd_ReferenceArray::Set(doc_xml->Main(), 444, 445);
4317 refarr->SetValue(444, Lxml1);
4318 refarr->SetValue(445, Lxml2);
4319 // TDataStd_ByteArray:
4320 bytearr = TDataStd_ByteArray::Set(doc_xml->Main(), 15, 24);
4321 bytearr->SetValue(15, 0);
4322 bytearr->SetValue(16, 10);
4323 bytearr->SetValue(17, 100);
4324 bytearr->SetValue(18, 200);
4325 bytearr->SetValue(19, 250);
4326 bytearr->SetValue(20, 251);
4327 bytearr->SetValue(21, 252);
4328 bytearr->SetValue(22, 253);
4329 bytearr->SetValue(23, 254);
4330 bytearr->SetValue(24, 255);
4332 Lstd3 = doc_xml->Main().FindChild(103);
4333 ref = TDF_Reference::Set(doc_xml->Main(), Lstd3);
4336 //if (app->SaveAs(doc_xml, "W:\\doc.xml") != PCDM_SS_OK)
4337 if (app->SaveAs(doc_xml, aFile2) != PCDM_SS_OK)
4341 app->Close(doc_xml);
4343 //if (app->Open("W:\\doc.xml", doc_xml_open) != PCDM_RS_OK)
4344 if (app->Open(aFile2, doc_xml_open) != PCDM_RS_OK)
4346 if (!doc_xml_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4348 if (!doc_xml_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4350 if (intlist->First() != 1)
4352 if (intlist->Last() != 5)
4354 if (!doc_xml_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4356 if (dbllist->First() != 1.5)
4358 if (dbllist->Last() != 5.5)
4360 if (!doc_xml_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4362 if (strlist->First() != "Guten ")
4364 if (strlist->Last() != "Tag")
4366 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4368 if (boollist->First() != Standard_False)
4370 if (boollist->Last() != Standard_True)
4372 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4374 TDF_Tool::Entry(reflist->First(), entry_first);
4375 if (entry1 != entry_first)
4377 TDF_Tool::Entry(reflist->Last(), entry_last);
4378 if (entry2 != entry_last)
4380 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4382 if (boolarr->Value(15) != Standard_False)
4384 if (boolarr->Value(16) != Standard_True)
4386 if (boolarr->Value(17) != Standard_True)
4388 if (boolarr->Value(18) != Standard_True)
4390 if (boolarr->Value(19) != Standard_True)
4392 if (boolarr->Value(20) != Standard_True)
4394 if (boolarr->Value(21) != Standard_False)
4396 if (boolarr->Value(22) != Standard_True)
4398 if (boolarr->Value(23) != Standard_True)
4400 if (boolarr->Value(24) != Standard_True)
4402 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4404 TDF_Tool::Entry(refarr->Value(444), entry_first);
4405 if (entry1 != entry_first)
4407 TDF_Tool::Entry(refarr->Value(445), entry_last);
4408 if (entry2 != entry_last)
4410 if (!doc_xml_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4412 if (bytearr->Value(15) != 0)
4414 if (bytearr->Value(16) != 10)
4416 if (bytearr->Value(17) != 100)
4418 if (bytearr->Value(18) != 200)
4420 if (bytearr->Value(19) != 250)
4422 if (bytearr->Value(20) != 251)
4424 if (bytearr->Value(21) != 252)
4426 if (bytearr->Value(22) != 253)
4428 if (bytearr->Value(23) != 254)
4430 if (bytearr->Value(24) != 255)
4432 if (!doc_xml_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4434 if (ref->Get().IsNull())
4436 if (ref->Get().Tag() != 103)
4440 Handle(TDocStd_Document) doc_bin, doc_bin_open;
4441 app->NewDocument("BinOcaf", doc_bin);
4443 TDataStd_Tick::Set(doc_bin->Main());
4444 // TDataStd_IntegerList:
4445 intlist = TDataStd_IntegerList::Set(doc_bin->Main());
4448 // TDataStd_RealList:
4449 dbllist = TDataStd_RealList::Set(doc_bin->Main());
4450 dbllist->Append(1.5);
4451 dbllist->Append(5.5);
4452 // TDataStd_ExtStringList:
4453 strlist = TDataStd_ExtStringList::Set(doc_bin->Main());
4454 strlist->Append("Bonjour");
4455 strlist->Append("Bonsoir");
4456 // TDataStd_BooleanList:
4457 boollist = TDataStd_BooleanList::Set(doc_bin->Main());
4458 boollist->Append(Standard_False);
4459 boollist->Append(Standard_True);
4460 // TDataStd_ReferenceList:
4461 TDF_Label Lbin1 = doc_bin->Main().FindChild(100);
4462 TDF_Tool::Entry(Lbin1, entry1);
4463 TDF_Label Lbin2 = doc_bin->Main().FindChild(101);
4464 TDF_Tool::Entry(Lbin2, entry2);
4465 reflist = TDataStd_ReferenceList::Set(doc_bin->Main());
4466 reflist->Append(Lbin1);
4467 reflist->Append(Lbin2);
4468 // TDataStd_BooleanArray:
4469 boolarr = TDataStd_BooleanArray::Set(doc_bin->Main(), 15, 24);
4470 boolarr->SetValue(15, Standard_False);
4471 boolarr->SetValue(16, Standard_True);
4472 boolarr->SetValue(17, Standard_True);
4473 boolarr->SetValue(18, Standard_True);
4474 boolarr->SetValue(19, Standard_True);
4475 boolarr->SetValue(20, Standard_True);
4476 boolarr->SetValue(21, Standard_False);
4477 boolarr->SetValue(22, Standard_True);
4478 boolarr->SetValue(23, Standard_True);
4479 boolarr->SetValue(24, Standard_True);
4480 // TDataStd_ReferenceArray:
4481 refarr = TDataStd_ReferenceArray::Set(doc_bin->Main(), 0, 1);
4482 refarr->SetValue(0, Lbin1);
4483 refarr->SetValue(1, Lbin2);
4484 // TDataStd_ByteArray:
4485 bytearr = TDataStd_ByteArray::Set(doc_bin->Main(), 15, 16);
4486 bytearr->SetValue(15, 0);
4487 bytearr->SetValue(16, 255);
4488 // TDataStd_NamedData:
4489 nameddata = TDataStd_NamedData::Set(doc_bin->Main());
4490 nameddata->SetByte("A", 12);
4491 nameddata->SetByte("B", 234);
4493 Lstd3 = doc_bin->Main().FindChild(103);
4494 ref = TDF_Reference::Set(doc_bin->Main(), Lstd3);
4497 //if (app->SaveAs(doc_bin, "W:\\doc.cbf") != PCDM_SS_OK)
4498 if (app->SaveAs(doc_bin, aFile3) != PCDM_SS_OK)
4502 app->Close(doc_bin);
4504 //if (app->Open("W:\\doc.cbf", doc_bin_open) != PCDM_RS_OK)
4505 if (app->Open(aFile3, doc_bin_open) != PCDM_RS_OK)
4507 if (!doc_bin_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4509 if (!doc_bin_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4511 if (intlist->First() != 1)
4513 if (intlist->Last() != 5)
4515 if (!doc_bin_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4517 if (dbllist->First() != 1.5)
4519 if (dbllist->Last() != 5.5)
4521 if (!doc_bin_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4523 if (strlist->First() != "Bonjour")
4525 if (strlist->Last() != "Bonsoir")
4527 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4529 if (boollist->First() != Standard_False)
4531 if (boollist->Last() != Standard_True)
4533 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4535 TDF_Tool::Entry(reflist->First(), entry_first);
4536 if (entry1 != entry_first)
4538 TDF_Tool::Entry(reflist->Last(), entry_last);
4539 if (entry2 != entry_last)
4541 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4543 if (boolarr->Value(15) != Standard_False)
4545 if (boolarr->Value(16) != Standard_True)
4547 if (boolarr->Value(17) != Standard_True)
4549 if (boolarr->Value(18) != Standard_True)
4551 if (boolarr->Value(19) != Standard_True)
4553 if (boolarr->Value(20) != Standard_True)
4555 if (boolarr->Value(21) != Standard_False)
4557 if (boolarr->Value(22) != Standard_True)
4559 if (boolarr->Value(23) != Standard_True)
4561 if (boolarr->Value(24) != Standard_True)
4563 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4565 TDF_Tool::Entry(refarr->Value(0), entry_first);
4566 if (entry1 != entry_first)
4568 TDF_Tool::Entry(refarr->Value(1), entry_last);
4569 if (entry2 != entry_last)
4571 if (!doc_bin_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4573 if (bytearr->Value(15) != 0)
4575 if (bytearr->Value(16) != 255)
4577 if (!doc_bin_open->Main().FindAttribute(TDataStd_NamedData::GetID(), nameddata))
4579 if (nameddata->GetByte("A") != 12)
4581 if (nameddata->GetByte("B") != 234)
4583 if (!doc_bin_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4585 if (ref->Get().IsNull())
4587 if (ref->Get().Tag() != 103)
4592 // For OCC16782 testing
4594 static Standard_Integer OCC16782 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4598 di << "Usage : " << argv[0] << " file.std file.xml file.cbf\n";
4601 TCollection_ExtendedString aFile1(argv[1]);
4602 TCollection_ExtendedString aFile2(argv[2]);
4603 TCollection_ExtendedString aFile3(argv[3]);
4606 app = new AppStd_Application();
4610 Handle(TDocStd_Document) doc;
4611 app->NewDocument("MDTV-Standard", doc);
4612 doc->SetUndoLimit(10);
4614 di <<"\nTestSetGet start\n";
4615 good += TestSetGet(doc);
4616 di <<"TestSetGet finish\n";
4617 di <<"Status = " << good << "\n";
4619 di <<"\nTestUndoRedo start\n";
4620 good += TestUndoRedo(doc);
4621 di <<"TestUndoRedo finish\n";
4622 di <<"Status = " << good << "\n";
4624 di <<"\nTestCopyPaste start\n";
4625 good += TestCopyPaste(doc);
4626 di <<"TestCopyPaste finish\n";
4627 di <<"Status = " << good << "\n";
4629 di <<"\nTestOpenSave start\n";
4630 good += TestOpenSave(aFile1, aFile2, aFile3);
4631 di <<"TestOpenSave finish\n";
4632 di <<"Status = " << good << "\n";
4635 di <<"\nThe " << argv[0] << " test is passed well, OK\n";
4637 di <<"\nThe " << argv[0] << " test failed, Faulty\n";
4642 static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4644 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4645 if(aContext.IsNull()) {
4646 di << argv[0] << " ERROR : use 'vinit' command before " << "\n";
4652 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4655 Standard_Integer mode = 0;
4658 mode = atoi(argv[1]);
4660 if (mode > 2 || mode < 0)
4662 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4665 Handle(V3d_View) V = ViewerTest::CurrentView();
4666 if ( !V.IsNull() ) {
4668 V->ColorScaleDisplay();
4671 V->ColorScaleErase();
4676 Standard_Boolean IsDisplayed = V->ColorScaleIsDisplayed();
4678 di <<"ColorScaleIsDisplayed = " << "1" << "\n";
4680 di <<"ColorScaleIsDisplayed = " << "0" << "\n";
4686 #include <Interface_Macros.hxx>
4687 #include <IGESControl_Controller.hxx>
4688 #include <XSDRAW.hxx>
4689 #include <Draw_ProgressIndicator.hxx>
4690 #include <XSControl_WorkSession.hxx>
4691 #include <Transfer_TransientProcess.hxx>
4692 #include <XSDRAW_Commands.hxx>
4693 #include <TColStd_HSequenceOfTransient.hxx>
4694 #include <Message_ProgressSentry.hxx>
4695 #include <XSControl_TransferReader.hxx>
4697 static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4699 DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
4700 if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
4702 // Progress indicator
4703 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
4704 progress->SetScale ( 0, 100, 1 );
4707 IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
4709 ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
4711 TCollection_AsciiString fnom,rnom;
4713 Standard_Boolean modfic = XSDRAW::FileAndVar
4714 (argv[1],argv[2],"IGESBREP",fnom,rnom);
4715 if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
4716 else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
4717 di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
4718 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
4721 OSD_Timer Chr; Chr.Reset();
4727 progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
4731 //In order to decrease number of produced edges during translation it is possible to set following parameter
4732 Interface_Static::SetIVal("read.iges.bspline.continuity",0);
4735 if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
4736 else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
4738 progress->EndScope();
4741 if (readstat != IFSelect_RetDone) {
4742 if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon"<<"\n";
4743 else di<<"No model loaded"<<"\n";
4746 // Choice of treatment
4747 Standard_Boolean fromtcl = (argc > 3);
4748 Standard_Integer modepri = 1, nent, nbs;
4749 if (fromtcl) modepri = 4;
4752 //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka
4753 //mode OnlyVisible does not work.
4754 // nent = Reader.NbRootsForTransfer();
4756 cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<flush;
4759 // amv 26.09.2003 : this is used to avoid error of enter's simbol
4762 modepri = atoi(str);
4765 if (modepri == 0) { //fin
4766 di << "Bye and good luck! " << "\n";
4770 else if (modepri <= 2) { // 1 : Visible Roots, 2 : All Roots
4771 di << "All Geometry Transfer"<<"\n";
4772 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
4773 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
4774 Handle(XSControl_WorkSession) thesession = Reader.WS();
4775 thesession->ClearContext();
4776 XSDRAW::SetTransferProcess (thesession->MapReader());
4777 progress->NewScope ( 80, "Translation" );
4779 thesession->MapReader()->SetProgress ( progress );
4781 if (modepri == 1) Reader.SetReadVisible (Standard_True);
4782 Reader.TransferRoots();
4784 thesession->MapReader()->SetProgress ( 0 );
4785 progress->EndScope();
4787 // result in only one shape for all the roots
4788 // or in one shape for one root.
4789 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
4790 Standard_Integer answer = 1;
4791 if (Reader.NbShapes() > 1) {
4792 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;
4797 answer = atoi(str_a);
4799 if ( answer == 0) continue;
4800 if ( answer == 1 || answer == 3) {
4801 TopoDS_Shape shape = Reader.OneShape();
4803 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
4805 sprintf(fname, "%s", rnom.ToCString());
4806 di << "Saving shape in variable Draw : " << fname << "\n";
4807 if (answer == 3) IGESToBRep::WriteShape (shape,1);
4810 DBRep::Set(fname,shape);
4812 catch(Standard_Failure) {
4813 di << "** Exception : ";
4814 di << Standard_Failure::Caught()->GetMessageString();
4815 di<<" ** Skip"<<"\n";
4816 di << "Saving shape in variable Draw : " << fname << "\n";
4817 IGESToBRep::WriteShape (shape,1);
4821 else if (answer == 2 || answer == 4) {
4822 Standard_Integer numshape = Reader.NbShapes();
4823 for (Standard_Integer inum = 1; inum <= numshape; inum++) {
4824 // save all the shapes
4825 TopoDS_Shape shape = Reader.Shape(inum);
4826 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
4828 sprintf(fname, "%s_%d", rnom.ToCString(),inum);
4829 di << "Saving shape in variable Draw : " << fname << "\n";
4830 if (answer == 4) IGESToBRep::WriteShape (shape,inum);
4833 DBRep::Set(fname,shape);
4835 catch(Standard_Failure) {
4836 di << "** Exception : ";
4837 di << Standard_Failure::Caught()->GetMessageString();
4838 di<<" ** Skip"<<"\n";
4845 else if (modepri == 3) { // One Entity
4846 cout << "Only One Entity"<<endl;
4847 cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<endl;
4848 cout<<" To modify : command param read.iges.bspline.continuity"<<endl;
4849 cout << " give the number of the Entity : " << flush;
4850 nent = XSDRAW::GetEntityNumber();
4852 if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
4854 nbs = Reader.NbShapes();
4855 char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nent);
4856 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
4857 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
4858 TopoDS_Shape sh = Reader.Shape(nbs);
4859 DBRep::Set (shname,sh);
4863 else if (modepri == 4) { // Selection
4864 Standard_Integer answer = 1;
4865 Handle(TColStd_HSequenceOfTransient) list;
4867 // Selection, nommee ou via tcl. tcl : raccourcis admis
4868 // * donne iges-visible + xst-transferrable-roots
4869 // *r donne xst-model-roots (TOUTES racines)
4871 if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {
4872 di << "All Geometry Transfer"<<"\n";
4873 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
4874 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
4875 Handle(XSControl_WorkSession) thesession = Reader.WS();
4876 thesession->ClearContext();
4877 XSDRAW::SetTransferProcess (thesession->MapReader());
4878 progress->NewScope ( 80, "Translation" );
4880 thesession->MapReader()->SetProgress ( progress );
4882 Reader.SetReadVisible (Standard_True);
4883 Reader.TransferRoots();
4885 thesession->MapReader()->SetProgress ( 0 );
4886 progress->EndScope();
4889 // result in only one shape for all the roots
4890 TopoDS_Shape shape = Reader.OneShape();
4893 sprintf(fname, "%s", rnom.ToCString());
4894 di << "Saving shape in variable Draw : " << fname << "\n";
4897 DBRep::Set(fname,shape);
4899 catch(Standard_Failure) {
4900 di << "** Exception : ";
4901 di << Standard_Failure::Caught()->GetMessageString();
4902 di<<" ** Skip"<<"\n";
4903 di << "Saving shape in variable Draw : " << fname << "\n";
4904 IGESToBRep::WriteShape (shape,1);
4910 modepri = 0; // d office, une seule passe
4911 if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
4913 list = XSDRAW::GetList ("xst-model-roots");
4916 TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
4917 di<<"List given by "<<compart.ToCString()<<" : ";
4918 list = XSDRAW::GetList (compart.ToCString());
4920 if (list.IsNull()) {
4921 di<<"No list defined. Give a selection name or * for all visible transferrable roots"<<"\n";
4926 cout<<"Name of Selection :"<<flush;
4927 list = XSDRAW::GetList();
4928 if (list.IsNull()) { cout<<"No list defined"<<endl; continue; }
4931 Standard_Integer nbl = list->Length();
4932 di<<"Nb entities selected : "<<nbl<<"\n";
4933 if (nbl == 0) continue;
4936 cout<<"Choice: 0 abandon 1 transfer all 2 with confirmation 3 list n0s ents :"<<flush;
4939 char str_answer[80];
4941 answer = atoi(str_answer);
4943 if (answer <= 0 || answer > 3) continue;
4945 for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
4946 Handle(Standard_Transient) ent = list->Value(ill);
4947 di<<" ";// model->Print(ent,di);
4951 if (answer == 1 || answer == 2) {
4952 Standard_Integer nbt = 0;
4953 Handle(XSControl_WorkSession) thesession = Reader.WS();
4955 XSDRAW::SetTransferProcess (thesession->MapReader());
4956 progress->NewScope ( 80, "Translation" );
4958 thesession->MapReader()->SetProgress ( progress );
4960 Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
4961 for (Standard_Integer ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
4963 nent = Reader.Model()->Number(list->Value(ill));
4964 if (nent == 0) continue;
4965 if (!Reader.TransferOne(nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
4967 nbs = Reader.NbShapes();
4968 char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
4969 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
4970 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
4971 TopoDS_Shape sh = Reader.Shape(nbs);
4972 DBRep::Set (shname,sh);
4976 thesession->MapReader()->SetProgress ( 0 );
4977 progress->EndScope();
4979 di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
4980 answer = 0; // on ne reboucle pas
4984 else di<<"Unknown mode n0 "<<modepri<<"\n";
4988 //In order to clear memory after IGES reading you could add the following code
4989 Handle(XSControl_TransferReader) TR = Reader.WS()->TransferReader();
4990 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
4993 Reader.WS()->Model()->Clear();
4994 Standard_Integer i =1;
4996 Reader.WS()->ClearData(i);
5002 #include <Geom_Plane.hxx>
5003 static Standard_Integer OCC20766 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5007 di << "Usage : " << argv[0] << " plane a b c d\n";
5011 Standard_Real A = atof(argv[2]);
5012 Standard_Real B = atof(argv[3]);
5013 Standard_Real C = atof(argv[4]);
5014 Standard_Real D = atof(argv[5]);
5016 Handle(Geom_Geometry) result;
5018 Handle(Geom_Plane) aPlane = new Geom_Plane(A, B, C, D);
5021 DrawTrSurf::Set(argv[1],result);
5025 static Standard_Integer OCC20627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5029 di << "Usage : " << argv[0] << " MaxNbr" << "\n";
5032 Standard_Integer aMaxNbr = atoi(argv[1]);
5034 for (Standard_Integer i=0;i<aMaxNbr;i++)
5036 BRepBuilderAPI_MakePolygon w(gp_Pnt(0,0,0),gp_Pnt(0,100,0),gp_Pnt(20,100,0),gp_Pnt(20,0,0));
5038 TopoDS_Wire wireShape( w.Wire());
5039 BRepBuilderAPI_MakeFace faceBuilder(wireShape);
5040 TopoDS_Face f( faceBuilder.Face());
5041 BRepMesh_IncrementalMesh im(f,1);
5042 BRepTools::Clean(f);
5047 #include <Graphic3d_Vector.hxx>
5048 Standard_Integer OCC22762 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5052 di << "Wrong number of arguments" << "\n";
5055 Standard_Real X1_Pnt = atof(argv[1]);
5056 Standard_Real Y1_Pnt = atof(argv[2]);
5057 Standard_Real Z1_Pnt = atof(argv[3]);
5058 Standard_Real X2_Pnt = atof(argv[4]);
5059 Standard_Real Y2_Pnt = atof(argv[5]);
5060 Standard_Real Z2_Pnt = atof(argv[6]);
5062 Graphic3d_Vector AV1(X1_Pnt, Y1_Pnt, Z1_Pnt);
5063 Graphic3d_Vector AV2(X2_Pnt, Y2_Pnt, Z2_Pnt);
5065 di << "Result is: " << (Graphic3d_Vector::IsParallel(AV1, AV2) ? "true" : "false") << "\n" ;
5072 #include <IntCurvesFace_ShapeIntersector.hxx>
5073 #include <gp_Lin.hxx>
5074 Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5078 di << "Usage : " << argv[0] << " shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf" << "\n";
5082 TopoDS_Shape shape = DBRep::Get(argv[1]);
5084 if (shape.IsNull()) {
5085 di<<" Null shape is not allowed";
5089 Standard_Real X_Pnt = atof(argv[2]);
5090 Standard_Real Y_Pnt = atof(argv[3]);
5091 Standard_Real Z_Pnt = atof(argv[4]);
5093 Standard_Real X_Dir = atof(argv[5]);
5094 Standard_Real Y_Dir = atof(argv[6]);
5095 Standard_Real Z_Dir = atof(argv[7]);
5097 Standard_Real PInf = atof(argv[8]);
5099 IntCurvesFace_ShapeIntersector intersector;
5100 intersector.Load(shape, Precision::Intersection());
5102 gp_Pnt origin(X_Pnt, Y_Pnt, Z_Pnt);
5103 gp_Dir dir(X_Dir, Y_Dir, Z_Dir);
5104 gp_Lin ray(origin, dir);
5106 Standard_Real PSup = RealLast();
5107 intersector.PerformNearest(ray, PInf, PSup);
5108 if (intersector.NbPnt() != 0)
5110 di << argv[0] << " status = 0 \n";
5111 Standard_Real w = intersector.WParameter(1);
5112 di << "w = " << w << "\n";
5114 di << argv[0] << " status = -1 \n";
5119 Standard_Integer OCC22301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5122 di << "Usage : " << argv[0] << "\n";
5126 // Create mask 1111: extent == 4
5127 TColStd_PackedMapOfInteger aFullMask;
5128 for (Standard_Integer i = 0; i < 4; i++)
5131 // Create mask 1100: extent == 2
5132 TColStd_PackedMapOfInteger aPartMask;
5133 for (Standard_Integer i = 0; i < 2; i++)
5136 di << "aFullMask = 1111" << "\n";
5137 di << "aPartMask = 1100" << "\n";
5139 Standard_Boolean isAffected;
5141 isAffected = aFullMask.Intersect(aPartMask); // true; extent == 2 (OK)
5142 di << "First time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5143 isAffected = aFullMask.Intersect(aPartMask); // true; extent == 0 (?)
5144 di << "Second time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5145 isAffected = aFullMask.Subtract(aPartMask); // false (?)
5146 di << "After two intersections: aFullMask.Subtract(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5150 #include <ShapeFix_FixSmallFace.hxx>
5151 Standard_Integer OCC22586 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5155 di << "Usage : " << argv[0] << " shape resshape\n";
5159 // try to read a shape:
5160 TopoDS_Shape aShape=DBRep::Get(argv[1]);
5161 ShapeFix_FixSmallFace aFixSmallFaces;
5162 aFixSmallFaces.Init (aShape);
5163 aFixSmallFaces.Perform();
5164 TopoDS_Shape aResShape = aFixSmallFaces.Shape();
5165 DBRep::Set(argv[2],aResShape);
5171 #include <NCollection_DataMap.hxx>
5172 Standard_Integer OCC22744 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5176 di << "Usage : " << argv[0] << "\n";
5180 TCollection_ExtendedString anExtString;
5182 Standard_ExtCharacter aNonAsciiChar = 0xff00;
5183 anExtString.Insert(1, aNonAsciiChar);
5185 di << "Is ASCII: " << ( anExtString.IsAscii() ? "true" : "false" ) << "\n";
5186 NCollection_DataMap<TCollection_ExtendedString, Standard_Integer> aMap;
5187 aMap.Bind(anExtString, 0);
5193 Standard_Integer OCC22558 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5196 di << "Wrong number of arguments" << argv[0] << "\n";
5200 Standard_Real X_vec = atof(argv[1]);
5201 Standard_Real Y_vec = atof(argv[2]);
5202 Standard_Real Z_vec = atof(argv[3]);
5204 Standard_Real X_dir = atof(argv[4]);
5205 Standard_Real Y_dir = atof(argv[5]);
5206 Standard_Real Z_dir = atof(argv[6]);
5208 Standard_Real X_pnt = atof(argv[7]);
5209 Standard_Real Y_pnt = atof(argv[8]);
5210 Standard_Real Z_pnt = atof(argv[9]);
5212 gp_Dir toSym(X_vec, Y_vec, Z_vec);
5213 gp_Dir dir(X_dir, Y_dir, Z_dir);
5214 gp_Pnt loc(X_pnt, Y_pnt, Z_pnt);
5215 gp_Ax2 symObj(loc,dir);
5216 toSym.Mirror(symObj);
5218 di << "The result " << toSym.X() << " " << toSym.Y() << " " << toSym.Z() << "\n";
5223 Standard_Integer OCC22736 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5227 di << "Usage : " << argv[0] << " X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2\n";
5231 Standard_Real X_mirrorFirstPoint = atof(argv[1]);
5232 Standard_Real Y_mirrorFirstPoint = atof(argv[2]);
5233 Standard_Real X_mirrorSecondPoint = atof(argv[3]);
5234 Standard_Real Y_mirrorSecondPoint = atof(argv[4]);
5235 Standard_Real X_p1 = atof(argv[5]);
5236 Standard_Real Y_p1 = atof(argv[6]);
5237 Standard_Real X_p2 = atof(argv[7]);
5238 Standard_Real Y_p2 = atof(argv[8]);
5240 gp_Trsf2d identityTransformation;
5242 gp_Pnt2d mirrorFirstPoint(X_mirrorFirstPoint,Y_mirrorFirstPoint);
5243 gp_Pnt2d mirrorSecondPoint(X_mirrorSecondPoint,Y_mirrorSecondPoint);
5244 gp_Ax2d mirrorAxis(mirrorFirstPoint,gp_Vec2d(mirrorFirstPoint,mirrorSecondPoint));
5246 gp_Pnt2d p1(X_p1,Y_p1);
5247 gp_Pnt2d p2(X_p2,Y_p2);
5250 M1.SetMirror(mirrorAxis);
5252 M2.SetMirror(mirrorAxis);
5254 Tcomp = M2.Multiplied(M1);
5256 Standard_Real aTol = Precision::Confusion();
5257 Standard_Integer aStatus = 0;
5259 //After applying two times the same mirror the point is located on the same location OK
5260 gp_Pnt2d p1MirrorM1 = p1.Transformed(M1);
5261 if ( Abs(p2.X() - p1MirrorM1.X()) > aTol )
5263 if ( Abs(p2.Y() - p1MirrorM1.Y()) > aTol )
5266 gp_Pnt2d p1MirrorM1M2 = p1MirrorM1.Transformed(M2);
5267 if ( Abs(p1.X() - p1MirrorM1M2.X()) > aTol )
5269 if ( Abs(p1.Y() - p1MirrorM1M2.Y()) > aTol )
5272 //If we apply the composed transformation of the same two mirrors to a point the result is //not located on the initial position.-->>ERROR
5273 gp_Pnt2d p1MirrorComp = p1.Transformed(Tcomp);
5274 if ( Abs(p1.X() - p1MirrorComp.X()) > aTol )
5276 if ( Abs(p1.Y() - p1MirrorComp.Y()) > aTol )
5279 di << "Status = " << aStatus << "\n";
5283 #include <BOPTColStd_CArray1OfInteger.hxx>
5284 //=======================================================================
5285 //function : DumpArray
5287 //=======================================================================
5288 void DumpArray(const BOPTColStd_CArray1OfInteger& aC,
5289 Draw_Interpretor& aDI)
5291 Standard_Integer iLength, iFactLength, iBlockLength;
5293 iLength=aC.Length();
5294 iFactLength=aC.FactLength();
5295 iBlockLength=aC.BlockLength();
5297 aDI<< "Length: " <<iLength << "\n";
5298 aDI<< "FactLength: " <<iFactLength << "\n";
5299 aDI<< "BlockLength: " <<iBlockLength << "\n";
5301 //=======================================================================
5302 //function : bcarray
5304 //=======================================================================
5305 Standard_Integer bcarray (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5309 di << "Usage : " << argv[0] << "\n";
5313 Standard_Integer i, aNb, aBL;
5314 BOPTColStd_CArray1OfInteger aC;
5317 aC.SetBlockLength(aBL);
5319 for (i=1; i<=10; ++i) {
5322 di<< "\nstate before release the unused memory\n";
5327 di<< "\nstate after release the unused memory\n";
5333 void QAOCC::Commands(Draw_Interpretor& theCommands) {
5334 const char *group = "QAOCC";
5336 theCommands.Add("OCC128", "OCC128", __FILE__, OCC128, group);
5338 // Remove as bad version of QAAddOrRemoveSelected from QADraw
5339 //theCommands.Add("OCC129", "OCC129 shape islocal", __FILE__, OCC129, group);
5341 theCommands.Add("OCC136", "OCC136", __FILE__, OCC136, group);
5342 theCommands.Add("BUC60610","BUC60610 iges_input [name]",__FILE__,BUC60610,group);
5343 theCommands.Add("BUC60661","BUC60661 file.igs",__FILE__,BUC60661, group);
5345 //====================================================
5347 // Following commands are inserted from
5348 // /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
5349 // ( 75455 Apr 16 18:59)
5351 //====================================================
5353 theCommands.Add("OCC105","OCC105 shape",__FILE__,OCC105,group);
5354 theCommands.Add("OCC9"," result path cur1 cur2 radius [tolerance]:\t test GeomFill_Pipe", __FILE__, pipe_OCC9,group);
5356 theCommands.Add("OCC125","OCC125 shell", __FILE__, OCC125,group);
5358 theCommands.Add("OCC157","findplanarsurface Result wire Tol",__FILE__,OCC157,group);
5359 //theCommands.Add("OCC165","OCC165",__FILE__,OCC165,group);
5360 theCommands.Add("OCC165","OCC165 file",__FILE__,OCC165,group);
5361 theCommands.Add("OCC297","OCC297",__FILE__,OCC297,group);
5362 //theCommands.Add("OCC305","OCC305",__FILE__,OCC305,group);
5363 theCommands.Add("OCC305","OCC305 file",__FILE__,OCC305,group);
5366 theCommands.Add("OCC166", "OCC166", __FILE__, OCC166, group);
5367 theCommands.Add("OCC381_Save", "OCC381_Save Doc", __FILE__, OCC381_Save, group);
5368 theCommands.Add("OCC381_SaveAs", "OCC381_SaveAs Doc Path", __FILE__, OCC381_SaveAs, group);
5370 theCommands.Add("OCC299","OCC299 Solid Point [Tolerance=1.e-7]", __FILE__, OCC299bug, group);
5371 theCommands.Add("OCC309","OCC309", __FILE__, OCC309bug, group);
5372 theCommands.Add("OCC310","OCC310", __FILE__, OCC310bug, group);
5374 //theCommands.Add("OCC277","OCC277", __FILE__, OCC277bug, group);
5375 theCommands.Add("OCC277","OCC277 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC277bug, group);
5377 theCommands.Add("OCC333","OCC333 edge1 edge2 [toler domaindist]; Check overlapping edges", __FILE__, OCC333bug, group);
5379 theCommands.Add("OCC363", "OCC363 document filename ", __FILE__, OCC363, group);
5381 //theCommands.Add("OCC372", "OCC372", __FILE__, OCC372, group);
5382 theCommands.Add("OCC377", "OCC377", __FILE__, OCC377, group);
5383 theCommands.Add("OCC22", "OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation", __FILE__, OCC22, group);
5384 theCommands.Add("OCC24", "OCC24 Result Shape CompoundOfSubshapes ResourceFileName", __FILE__, OCC24, group);
5385 theCommands.Add("OCC369", "OCC369 Shape", __FILE__, OCC369, group);
5386 theCommands.Add("OCC524", "OCC524 LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix", __FILE__, OCC524, group);
5387 theCommands.Add("OCC525", "OCC525", __FILE__, OCC525, group);
5388 theCommands.Add("OCC543", "OCC543 name", __FILE__, OCC543, group);
5389 //theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
5390 theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC578, group);
5391 theCommands.Add("OCC627", "OCC627", __FILE__, OCC627, group);
5392 theCommands.Add("OCC669", "OCC669 GUID", __FILE__, OCC669, group);
5393 theCommands.Add("OCC738_ShapeRef", "OCC738_ShapeRef", __FILE__, OCC738_ShapeRef, group);
5394 theCommands.Add("OCC738_Assembly", "OCC738_Assembly", __FILE__, OCC738_Assembly, group);
5395 theCommands.Add("OCC708", "OCC708 shape ; Deactivate the current transformation", __FILE__, OCC708, group);
5396 theCommands.Add("OCC670", "OCC670", __FILE__, OCC670, group);
5397 theCommands.Add("OCC867", "OCC867 Point Surface Umin Usup Vmin Vsup", __FILE__, OCC867, group);
5398 theCommands.Add("OCC909", "OCC909 wire face", __FILE__, OCC909, group);
5399 theCommands.Add("OCC921", "OCC921 face", __FILE__, OCC921, group);
5400 theCommands.Add("OCC902", "OCC902 expression", __FILE__, OCC902, group);
5402 theCommands.Add ("OCC1029_AISTransparency","OCC1029_AISTransparency (DOC, entry, [real])",__FILE__, OCC1029_AISTransparency, group);
5403 theCommands.Add ("OCC1030_AISColor", "OCC1030_AISColor (DOC, entry, [color])", __FILE__, OCC1030_AISColor, group);
5404 theCommands.Add ("OCC1031_AISMaterial", "OCC1031_AISMaterial (DOC, entry, [material])", __FILE__, OCC1031_AISMaterial, group);
5405 theCommands.Add ("OCC1032_AISWidth", "OCC1032_AISWidth (DOC, entry, [width])", __FILE__, OCC1032_AISWidth, group);
5406 theCommands.Add ("OCC1033_AISMode", "OCC1033_AISMode (DOC, entry, [mode])", __FILE__, OCC1033_AISMode, group);
5407 theCommands.Add ("OCC1034_AISSelectionMode", "OCC1034_AISSelectionMode (DOC, entry, [selectionmode])", __FILE__, OCC1034_AISSelectionMode, group);
5409 //theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape", __FILE__, OCC1487, group);
5410 theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC1487, group);
5412 theCommands.Add("OCC1077", "OCC1077 result", __FILE__, OCC1077, group);
5413 theCommands.Add("OCC5739", "OCC5739 name shape step", __FILE__, OCC5739_UniAbs, group);
5414 theCommands.Add("OCC6046", "OCC6046 nb_of_vectors size", __FILE__, OCC6046, group);
5415 theCommands.Add("OCC5698", "OCC5698 wire", __FILE__, OCC5698, group);
5416 theCommands.Add("OCC6143", "OCC6143", __FILE__, OCC6143, group);
5417 theCommands.Add("OCC7141", "OCC7141 [nCount]", __FILE__, OCC7141, group);
5418 theCommands.Add("OCC7372", "OCC7372", __FILE__, OCC7372, group);
5419 theCommands.Add("OCC8169", "OCC8169 edge1 edge2 plane", __FILE__, OCC8169, group);
5420 theCommands.Add("OCC10138", "OCC10138 lower upper", __FILE__, OCC10138, group);
5421 theCommands.Add("OCC7639", "OCC7639 index1 value1 ... [indexN valueN]", __FILE__, OCC7639, group);
5422 theCommands.Add("OCC8797", "OCC8797", __FILE__, OCC8797, group);
5423 theCommands.Add("OCC7068", "OCC7068", __FILE__, OCC7068, group);
5424 theCommands.Add("OCC11457", "OCC11457 polygon lastedge x1 y1 z1 x2 y2 z2 ...", __FILE__, OCC11457, group);
5425 theCommands.Add("OCC13963", "OCC13963 ratio origin_x origin_y origin_z", __FILE__, OCC13963, group);
5426 theCommands.Add("OCC14376", "OCC14376 shape [deflection]", __FILE__, OCC14376, group);
5427 theCommands.Add("OCC15489", "OCC15489 A B C", __FILE__, OCC15489, group);
5428 theCommands.Add("OCC15755", "OCC15755 file shape", __FILE__, OCC15755, group);
5429 theCommands.Add("OCC16782", "OCC16782 file.std file.xml file.cbf", __FILE__, OCC16782, group);
5430 theCommands.Add("OCC12584", "OCC12584 [mode = 0/1/2]", __FILE__, OCC12584, group);
5431 theCommands.Add("OCC18612", "OCC18612 [file else already loaded model] [name DRAW]", __FILE__, OCC18612igesbrep, group);
5432 theCommands.Add("OCC20766", "OCC20766 plane a b c d", __FILE__, OCC20766, group);
5433 theCommands.Add("OCC20627", "OCC20627", __FILE__, OCC20627, group);
5434 theCommands.Add("OCC17424", "OCC17424 shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf", __FILE__, OCC17424, group);
5435 theCommands.Add("OCC22301", "OCC22301", __FILE__, OCC22301, group);
5436 theCommands.Add("OCC22586", "OCC22586 shape resshape", __FILE__, OCC22586, group);
5437 theCommands.Add("OCC22736", "OCC22736 X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2", __FILE__, OCC22736, group);
5438 theCommands.Add("OCC22744", "OCC22744", __FILE__, OCC22744, group);
5439 theCommands.Add("bcarray", "bcarray", __FILE__, bcarray, group);
5440 theCommands.Add("OCC22762", "OCC22762 x1 y1 z1 x2 y2 z3", __FILE__, OCC22762, group);
5441 theCommands.Add("OCC22558", "OCC22558 x_vec y_vec z_vec x_dir y_dir z_dit x_pnt y_pnt z_pnt", __FILE__, OCC22558, group);