0022038: Suppress "!!!No Error" message in BRepTools::Write in debug mode
[occt.git] / src / QAOCC / QAOCC.cxx
CommitLineData
7fd59977 1// File: QAOCC.cxx
2// Created: Wed Mar 20 09:42:59 2002
3// Author: QA Admin
4// <qa@umnox.nnov.matra-dtv.fr>
5
6
7#include <stdio.h>
8
9#include <QAOCC.hxx>
10
11#include <Draw_Interpretor.hxx>
12#include <DBRep.hxx>
13#include <DrawTrSurf.hxx>
14#include <AIS_InteractiveContext.hxx>
15#include <ViewerTest.hxx>
16#include <AIS_Shape.hxx>
17#include <TopoDS_Shape.hxx>
18
19#include <Geom_Axis2Placement.hxx>
20#include <gp.hxx>
21#include <gp_Trsf.hxx>
22#include <AIS_Trihedron.hxx>
23#include <BRepPrimAPI_MakeBox.hxx>
24#include <Graphic3d_MaterialAspect.hxx>
25#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
26#include <TopoDS_Solid.hxx>
27#include <BRepPrimAPI_MakeSphere.hxx>
28#include <BRepPrimAPI_MakeCone.hxx>
29#include <BRepPrimAPI_MakeCylinder.hxx>
30#include <IGESToBRep_Reader.hxx>
31#include <TopExp_Explorer.hxx>
32#include <TopoDS.hxx>
33#include <GCPnts_UniformDeflection.hxx>
34#include <BRepAdaptor_Curve.hxx>
35#include <IGESToBRep.hxx>
36#include <V3d_Viewer.hxx>
37#include <BRepAdaptor_CompCurve.hxx>
38#include <GCPnts_AbscissaPoint.hxx>
39#include <Standard_ErrorHandler.hxx>
40#include <Standard_Overflow.hxx>
41#include <Standard_Underflow.hxx>
42#include <Standard_DivideByZero.hxx>
43#include <OSD_SIGSEGV.hxx>
44#include <OSD_Exception_ACCESS_VIOLATION.hxx>
45#include <OSD_Exception_STACK_OVERFLOW.hxx>
46#include <OSD.hxx>
47#include <STEPCAFControl_Writer.hxx>
48#include <STEPControl_StepModelType.hxx>
49#include <Interface_Static.hxx>
50#include <IFSelect_ReturnStatus.hxx>
51#include <Standard_Failure.hxx>
52#include <TColgp_HArray1OfPnt2d.hxx>
53#include <Geom2dAPI_Interpolate.hxx>
54#include <Geom2d_BSplineCurve.hxx>
55#include <Geom2dConvert_BSplineCurveToBezierCurve.hxx>
56#include <Geom2d_BezierCurve.hxx>
57#include <BRep_Tool.hxx>
58#include <GeomProjLib.hxx>
59#include <Geom2dAPI_InterCurveCurve.hxx>
60#include <IntRes2d_IntersectionSegment.hxx>
61#include <TDataStd_RealArray.hxx>
62#include <TDF_CopyLabel.hxx>
63#include <NCollection_Vector.hxx>
64#include <TColStd_Array1OfInteger.hxx>
65#include <Geom_BSplineCurve.hxx>
66#include <TColgp_Array1OfPnt.hxx>
67#include <AIS_ListOfInteractive.hxx>
68#include <AIS_ListIteratorOfListOfInteractive.hxx>
69#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
70#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
71#include <BRepBuilderAPI_MakePolygon.hxx>
72#include <gp_GTrsf.hxx>
73#include <Poly_Triangulation.hxx>
74#include <IGESControl_Reader.hxx>
75#include <IGESData_IGESModel.hxx>
76#include <IGESData_IGESEntity.hxx>
77#include <V3d_View.hxx>
78
79#include <tcl.h>
80
81#if ! defined(WNT)
82extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
83#else
84Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
85#endif
86
87static Standard_Integer OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
88{
89 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
90 if(myAISContext.IsNull()) {
91 di << "use 'vinit' command before " << argv[0] ;
92 return 1;
93 }
94
95 Handle(Geom_Axis2Placement) aTrihedronAxis = new Geom_Axis2Placement(gp::XOY());
96
97 gp_Trsf trsf1;
98 trsf1.SetTranslation(gp_Vec(100, 100, 0));
99 aTrihedronAxis->Transform(trsf1);
100 Handle(AIS_Trihedron) myTrihedron = new AIS_Trihedron(aTrihedronAxis);
101 myTrihedron->SetColor(Quantity_NOC_LIGHTSTEELBLUE4);
102 myTrihedron->SetSize(100);
103 myAISContext->Display(myTrihedron, Standard_True);
104
105// TopoDS_Shape shape1 = (TopoDS_Shape) BRepPrimAPI_MakeBox(50,50,50);
106 TopoDS_Shape shape1 = BRepPrimAPI_MakeBox(50,50,50).Shape();
107 Handle(AIS_Shape) AS = new AIS_Shape(shape1);
108 AS->SetDisplayMode(1);
109 Graphic3d_MaterialAspect mat(Graphic3d_NOM_PLASTIC);
110 AS->SetMaterial(mat);
111 AS->SetColor(Quantity_NOC_RED);
112 myAISContext->Display(AS);
113
114 gp_Trsf TouchTrsf;
115 TouchTrsf.SetTranslation(gp_Vec(20, 20, 0));
116
117 myAISContext->ResetLocation(AS);
118 myAISContext->SetLocation(AS , TouchTrsf) ;
119 myAISContext->Redisplay(AS, Standard_True);
120
121 return 0;
122}
123
124 // Remove as bad version of QAAddOrRemoveSelected from QADraw
125//static Standard_Integer OCC129 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
126//{
127// if( argc != 3) {
128// di<<"Usage : " << argv[0] << " shape islocal\n";
129// return 1;
130// }
131// //get AIS_Shape:
132// Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
133//
134// // ViewerTest_DoubleMapOfInteractiveAndName& aMap =
135// // ViewerTest::GetDataMapOfAIS ();
136// ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
137//
138// TCollection_AsciiString aName(argv[1]);
139// Handle(AIS_InteractiveObject) AISObj;
140//
141// if(aMap.IsBound2(aName)) {
142// AISObj = aMap.Find2(aName);
143// if(AISObj.IsNull()){
144// di<<"No interactive object \n";
145// return 1;
146// }
147//
148// Standard_Integer aNum = -1;
149//
150// if(atoi(argv[2])) {
151// aNum = anAISCtx->OpenLocalContext();
152// }
153//
154// if(anAISCtx->HasOpenedContext()){
155// anAISCtx->InitSelected();
156// anAISCtx->AddOrRemoveSelected(AISObj);
157// }
158// else {
159// anAISCtx->InitCurrent();
160// anAISCtx->AddOrRemoveCurrentObject(AISObj);
161// }
162//
163// if(aNum >= 0) {
164// // anAISCtx->CloseLocalContext(aNum);
165// }
166//
167// return 0;
168// }
169// //select this shape:
170// else {
171// di<<"Use 'vdisplay' before";
172// return 1;
173// }
174//}
175
176static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
177{
178 if(argc > 1){
179 di<<"Usage: OCC136\n";
180 return 1;
181 }
182
183 //create some primitives:
184 // Two basic points:
185 Standard_Real Size=100;
186 gp_Pnt P0(0,0,0), P1(Size,Size,Size);
187 //box
188 TopoDS_Solid aBox = BRepPrimAPI_MakeBox(P0,P1);
189 //sphere
190 TopoDS_Solid aSphere = BRepPrimAPI_MakeSphere (Size*0.5);
191 //cone
192 gp_Ax2 anAx2(P1, gp_Dir(1,1,1));
193 TopoDS_Solid aCone = BRepPrimAPI_MakeCone(anAx2, Size*0.7, Size*0.3, Size);
194 //cylinder
195 anAx2.SetLocation(gp_Pnt(Size,0,0));
196 anAx2.SetDirection(gp_Dir(-1,-1,1));
197 TopoDS_Solid aCyl = BRepPrimAPI_MakeCylinder(anAx2, Size*0.5, Size);
198
199 Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
200 if(anAISCtx.IsNull()){
201 di<<"Null interactive context. Use 'vinit' at first.\n";
202 return 1;
203 }
204
205 if(anAISCtx->HasOpenedContext()) anAISCtx->CloseAllContexts();
206 anAISCtx->EraseAll();
207
208 //load primitives to context
209 Handle(AIS_Shape) aSh1 = new AIS_Shape(aBox);
210 anAISCtx->Display(aSh1);
211
212 Handle(AIS_Shape) aSh2 = new AIS_Shape(aSphere);
213 anAISCtx->Display(aSh2);
214
215 Handle(AIS_Shape) aSh3 = new AIS_Shape(aCone);
216 anAISCtx->Display(aSh3);
217
218 Handle(AIS_Shape) aSh4 = new AIS_Shape(aCyl);
219 anAISCtx->Display(aSh4);
220
221 //set selected
222 anAISCtx->InitCurrent();
223 anAISCtx->AddOrRemoveCurrentObject(aSh1);
224 anAISCtx->AddOrRemoveCurrentObject(aSh2);
225 anAISCtx->AddOrRemoveCurrentObject(aSh3);
226 anAISCtx->AddOrRemoveCurrentObject(aSh4);
227
228 //remove all this objects from context
229 anAISCtx->Clear(aSh1, Standard_False);
230 anAISCtx->Clear(aSh2, Standard_False);
231 anAISCtx->Clear(aSh3, Standard_False);
232 anAISCtx->Clear(aSh4, Standard_False);
233 return 0;
234}
235
236static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
237 if(argc < 2){
238 printf("Usage: %s iges_input [name]\n",argv[0]);
239 return(1);
240 }
241 Standard_Character *Ch;
242
243 if(argc > 2) {
244 Ch = new Standard_Character[strlen(argv[2])+3];
245 }
246 IGESToBRep_Reader IR;
247 IR.LoadFile (argv[1]);
248 IR.Clear();
249 IR.TransferRoots();
250 TopoDS_Shape aTopShape = IR.OneShape();
251 TopExp_Explorer ex(aTopShape, TopAbs_EDGE);
252 Standard_Integer i=0;
253 for( ; ex.More(); ex.Next()){
254 const TopoDS_Edge &E = TopoDS::Edge(ex.Current());
255 BRepAdaptor_Curve aCurve(E);
256 GCPnts_UniformDeflection plin(aCurve, 0.1);
257 di << "Num points = " << plin.NbPoints() << "\n";
258 if(argc > 2) {
259 i++;
260 sprintf(Ch,"%s_%i",argv[2],1);
261 DBRep::Set(Ch,E);
262 }
263 }
264 return (1);
265}
266
267static Standard_Integer BUC60661(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
268{
269 if(argc!=2)
270 {
271 di << "Usage : " << a[0] << " file.igs" << "\n";
272 return -1;
273 }
274
275 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
276
277 if(myContext.IsNull()) {
278 di << "use 'vinit' command before " << a[0] << "\n";
279 return -1;
280 }
281
282 // MKV 30.03.05
283#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
284 const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
285#else
286 Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
287#endif
288
289 Standard_Character *file1 = new Standard_Character [strlen(DD)+strlen(a[1])+2];
290 sprintf(file1,"%s/%s",DD,a[1]);
291
292 IGESToBRep_Reader reader;
293 Standard_Integer status = reader.LoadFile(file1);
294 if( !status ) {
295 IGESToBRep::Init();
296 reader.TransferRoots();
297 TopoDS_Shape shape = reader.OneShape();
298
299 Handle(AIS_Shape) importedShape = new AIS_Shape(shape);
300
301 Handle(V3d_Viewer) myPView = myContext->CurrentViewer();
302
303 if( ! myPView.IsNull() && (myPView->DefaultVisualization() == V3d_WIREFRAME) )
304 importedShape->SetDisplayMode(AIS_WireFrame);
305 else importedShape->SetDisplayMode(AIS_Shaded);
306 myContext->Display(importedShape);
307 }
308
309 printf("\n End of my IGES to 3D-viewer *****************>\n");
310 return 0;
311}
312
313
314//====================================================
315//
316// Following code is inserted from
317// /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
318// ( 75455 Apr 16 18:59)
319//
320//====================================================
321
322//OCC105
323#include <BRepTools_WireExplorer.hxx>
324#include <BRep_Tool.hxx>
325#include <GCPnts_UniformAbscissa.hxx>
326#include <TopExp.hxx>
327
328//
329// usage : OCC105 shape
330//
331// comments:
332//GCPnts_UniformAbscissa returns bad end point foe first edge. Its value is
333
334//Value Pnt = -338.556216693211 -394.465571897208 0
335//should be
336//Value Pnt = -307.47165394 -340.18073533 0
337
338static int OCC105(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
339{
340 if (argc != 2){
341 di<<"Usage : OCC105 shape\n";
342 return 1;
343 }
344// TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get("aa.brep"));
345 TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1]));
346 Standard_Real l = 0.5; //atof(argv[2]);
347 // Find the first vertex of the wire
348 BRepTools_WireExplorer wire_exp(myTopoDSWire);
349 TopoDS_Vertex vlast;
350 {
351 TopoDS_Vertex vw1, vw2;
352 TopExp::Vertices(myTopoDSWire,vw1,vw2);
353 TopoDS_Vertex ve1, ve2;
354 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
355 TopExp::Vertices(edge,ve1,ve2);
356 if (vw1.IsSame(ve1) || vw1.IsSame(ve2))
357 vlast = vw1;
358 else {
359// assert(vw2.IsSame(ve1) || vw2.IsSame(ve2));
360 vlast = vw2;
361 }
362 }
363 for ( ; wire_exp.More(); wire_exp.Next())
364 {
365 di << "\n\n New Edge \n" << "\n";
366 Standard_Real newufirst, newulast;
367 TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current());
368 Standard_Real ufirst, ulast;
369 Handle(Geom_Curve) acurve;
370 TopoDS_Vertex ve1, ve2;
371 TopExp::Vertices(edge,ve1,ve2);
372 if (ve1.IsSame(vlast))
373 {
374 acurve = BRep_Tool::Curve(edge, ufirst, ulast);
375 newufirst = ufirst;
376 newulast = ulast;
377 vlast = ve2;
378 }
379 else
380 {
381// assert(ve2.IsSame(vlast));
382// assert ( wire_exp.Orientation( ) == TopAbs_REVERSED );
383 acurve = BRep_Tool::Curve( edge, ufirst, ulast );
384 newufirst = acurve->ReversedParameter( ufirst );
385 newulast = acurve->ReversedParameter( ulast );
386 acurve = acurve->Reversed( );
387 vlast = ve1;
388 }
389
390 GeomAdaptor_Curve curve;
391 GCPnts_UniformAbscissa algo;
392 curve.Load(acurve);
393 algo.Initialize( curve, l, newufirst, newulast );
394 if (!algo.IsDone())
395 di << "Not Done!!!" << "\n";
396 for (Standard_Integer Index = 1; Index<=algo.NbPoints();Index++) {
397 Standard_Real t = algo.Parameter(Index);
398 gp_Pnt pt3 = curve.Value(t);
399 di << "Parameter t = " << t << "\n";
400 di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z() << "\n";
401 }
402 }
403 return 0;
404
405}
406
407#include <TColStd_SequenceOfTransient.hxx>
408#include <GeomFill_Pipe.hxx>
409static int pipe_OCC9 (Draw_Interpretor& di,
410 Standard_Integer n, const char ** a)
411{
412 if (n < 6) {
413 di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]" << "\n";
414 return 1;
415 }
416
417 TColStd_SequenceOfTransient aCurveSeq;
418 Standard_Integer i;
419 for (i=2 ; i<=4; i++) {
420 Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast( DrawTrSurf::Get(a[i]) );
421 if (aC.IsNull()) {
422 di << a[i] << " is not a curve" << "\n";
423 return 1;
424 }
425 aCurveSeq.Append(aC);
426 }
427
428 GeomFill_Pipe aPipe(Handle(Geom_Curve)::DownCast( aCurveSeq(1) ),
429 Handle(Geom_Curve)::DownCast( aCurveSeq(2) ),
430 Handle(Geom_Curve)::DownCast( aCurveSeq(3) ),
431 atof (a[5]) );
432
433 if (n == 7) {
434 aPipe.Perform(atof (a[6]), Standard_True);
435 } else {
436 aPipe.Perform(Standard_True/*, Standard_True*/);
437 }
438
439 Handle(Geom_Surface) aSurf = aPipe.Surface();
440
441 DrawTrSurf::Set(a[1], aSurf);
442 return 0;
443}
444
445//======================================================================
446// OCC125
447// usage : OCC125 shell
448//======================================================================
449#include <ShapeFix_Shell.hxx>
450
451Standard_Integer OCC125(Draw_Interpretor& di ,
452 Standard_Integer n,
453 const char ** a)
454{
455 if (n!=2) {
456 di<<" Use OCC125 shell";
457 return 1;
458 }
459
460 TopoDS_Shape S = DBRep::Get(a[1]);
461
462 if (S.IsNull()) {
463 di<<" Null shape is not allowed";
464 return 1;
465 }
466
467 TopAbs_ShapeEnum aT;
468 aT=S.ShapeType();
469 if (aT!=TopAbs_SHELL) {
470 di<<" Shape Type must be SHELL";
471 return 1;
472 }
473
474 const TopoDS_Shell& aShell = TopoDS::Shell(S);
475 //
476 Standard_Boolean isAccountMultiConex, bNonManifold, bResult;
477
478 isAccountMultiConex=Standard_True;
479 bNonManifold=Standard_False;
480
481 Handle (ShapeFix_Shell) aFix = new ShapeFix_Shell(aShell);
482 bResult=aFix->FixFaceOrientation(aShell, isAccountMultiConex, bNonManifold);
483
484 di<<"bResult="<<(Standard_Integer)bResult;
485
486 TopoDS_Shape aShape;
487 aShape=aFix->Shape();
488
489 TCollection_AsciiString aName(a[1]), aDef("_sh"), aRName;
490 aRName=aName;
491 aRName=aRName+aDef;
492 DBRep::Set (aRName.ToCString(), aShape);
493 di<<aRName.ToCString();
494 //
495 return 0;
496}
497
498#include <BRepLib_FindSurface.hxx>
499#include <BRepBuilderAPI_MakeFace.hxx>
500Standard_Integer OCC157(Draw_Interpretor& di,
501 Standard_Integer n,
502 const char ** a)
503//static Standard_Integer findplanarsurface(Draw_Interpretor&, Standard_Integer n, const char ** a)
504{
505 if (n<3) {
506 di << "bad number of arguments" <<"\n";
507 return 1;
508 }
509
510 // try to read a shape:
511 TopoDS_Shape inputShape=DBRep::Get(a[2]);
512 if (inputShape.IsNull() || inputShape.ShapeType() != TopAbs_WIRE) {
513 di << "Invalid input shape"<< "\n";
514 return 1;
515 }
516 Standard_Real toler = atof(a[3]);
517 TopoDS_Wire aWire = TopoDS::Wire(inputShape);
518 BRepLib_FindSurface FS(aWire, toler, Standard_True);
519 if(FS.Found()) {
520 di<<"OCC157: OK; Planar surface is found"<<"\n";
521 Handle(Geom_Surface) aSurf = FS.Surface();
522 BRepBuilderAPI_MakeFace aMakeFace(aSurf,aWire,Standard_True);
523 if(aMakeFace.IsDone()) {
524 TopoDS_Face aFace = aMakeFace.Face();
525 DBRep::Set(a[1],aFace);
526 }
527 }
528 else di<<"OCC157: ERROR; Planar surface is not found with toler = "<<toler <<"\n";
529 return 0;
530
531}
532
533// #include <MyCommandsCMD.h>
534#include <ShapeFix_Shape.hxx>
535#include <BRepOffset_MakeOffset.hxx>
536#include <BRepOffsetAPI_MakeOffset.hxx>
537#include <BRepOffset_Mode.hxx>
538#include <GeomAbs_JoinType.hxx>
539#include <AIS_Shape.hxx>
540
541#include <BRepTools.hxx>
542
543Standard_Integer OCC165(Draw_Interpretor& di ,
544 Standard_Integer n,
545 const char ** a)
546
547
548//=======================================================================
549
550// static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv);
551
552// void MyOffsets_Commands(Draw_Interpretor& theCommands)
553// {
554// theCommands.Add("yoffset" , "yoffset" , __FILE__, YOffset, " Offset on Z Direction");
555// }
556
557//=======================================================================
558
559// static int YOffset (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
560 {
561 if (n > 2)
562 {
563 di <<"Usage : " << a[0] << " [file]"<<"\n";
564 return 1;
565 }
566 di.Eval ("axo");
567
568#define _OFFSET_TELCO_
569#ifdef _OFFSET_TELCO_
570
571 Standard_CString file = a[1];
572
573 BRep_Builder aBuilder;
574 TopoDS_Shape theShape;
575 //BRepTools::Read(theShape, Standard_CString("/dn02/users_SUN/inv/3/OCC165/2d_tr_line.brep"), aBuilder);
576 BRepTools::Read(theShape, file, aBuilder);
577 DBRep::Set("shape", theShape);
578
579 TopoDS_Wire theWire = TopoDS::Wire(theShape);
580
581 Standard_Real anOffset = 1.5;
582
583#else
584
585 Standard_Real xA = 0.0, xB = 200.0, xC = 200.0, xD = 0.0,
586 yA = 0.0, yB = 0.0, yC = 200.0, yD = 200.0,
587 zA = 0.0, zB = 0.0, zC = 0.0, zD = 0.0;
588
589 BRepBuilderAPI_MakePolygon theSquare;
590 TopoDS_Vertex theA = BRepBuilderAPI_MakeVertex(gp_Pnt(xA, yA, zA));
591 theSquare.Add(theA);
592 TopoDS_Vertex theB = BRepBuilderAPI_MakeVertex(gp_Pnt(xB, yB, zB));
593 theSquare.Add(theB);
594 TopoDS_Vertex theC = BRepBuilderAPI_MakeVertex(gp_Pnt(xC, yC, zC));
595 theSquare.Add(theC);
596 TopoDS_Vertex theD = BRepBuilderAPI_MakeVertex(gp_Pnt(xD, yD, zD));
597 theSquare.Add(theD);
598
599 theSquare.Close();
600 TopoDS_Wire theWire = theSquare.Wire();
601
602 Standard_Real anOffset = 10;
603
604
605#endif /* _OFFSET_TELCO_ */
606
607
608 TopoDS_Face theFace = BRepBuilderAPI_MakeFace(theWire).Face();
609 DBRep::Set("face", theFace);
610
611
612 Standard_Real anAlt = 0.;
613 GeomAbs_JoinType theJoin = GeomAbs_Intersection;
614//GeomAbs_Intersection; //GeomAbs_Arc;
615 BRepOffsetAPI_MakeOffset aMakeOffset(theFace, theJoin);
616 aMakeOffset.AddWire(theWire);
617
618 aMakeOffset.Perform(anOffset, anAlt);
619
620 TopoDS_Shape theOffsetShapePos = aMakeOffset.Shape();
621 DBRep::Set("offset", theOffsetShapePos);
622 return 0;
623// return TCL_OK;
624}
625
626#include<BRepAlgoAPI_Cut.hxx>
627#include<BRepAlgo_Cut.hxx>
628
629#include<BRepPrimAPI_MakeHalfSpace.hxx>
630#include<Handle_Geom_CartesianPoint.hxx>
631#include<Geom_CartesianPoint.hxx>
632#include<AIS_Point.hxx>
633
634#include <BRepBuilderAPI_MakeEdge.hxx>
635#include <BRepBuilderAPI_MakeWire.hxx>
636#include <BRepBuilderAPI_MakeFace.hxx>
637
638static Standard_Integer OCC297 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
639
640{
641
642 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
643 if(myAISContext.IsNull()) {
644 di << "use 'vinit' command before " << argv[0] << "\n";
645 return -1;
646 }
647
648
649 gp_Pnt pt1_(250.,250.,0.);
650 gp_Pnt pt2_(-250.,250.,0.);
651 gp_Pnt pt3_(-250.,-250.,0.);
652 gp_Pnt pt4_(250.,-250.,0.);
653 BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
654 BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
655 BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
656 BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
657
658 BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
659 BRepBuilderAPI_MakeFace face_(wire_);
660 TopoDS_Face sh_ = face_.Face();
661
662 int up = 1;
663
664 gp_Pnt g_pnt;
665 if(up)
666 g_pnt = gp_Pnt(0,0,-100);
667 else
668 g_pnt = gp_Pnt(0,0,100);
669
670 myAISContext->EraseAll(Standard_False);
671 Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
672 Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
673 myAISContext->Display(AISPoint);
674
675 BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
676 TopoDS_Solid sol1_ = half_.Solid();
677// Handle(AIS_Shape) AISHalf = new AIS_Shape(sol1_);
678// AISHalf->SetColor(Quantity_NOC_GREEN);
679// myAISContext->Display(AISHalf);
680
681 DBRep::Set("Face",sol1_);
682
683 gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
684
685 Standard_Real x=0., y=0., z=-80.;
686
687 BRepPrimAPI_MakeBox box(gp_Pnt(x,y,z),gp_Pnt(x+150,y+200,z+200));
688// Handle(AIS_Shape) AISBox = new AIS_Shape(box);
689// AISBox->SetColor(Quantity_NOC_BLUE1);
690// myAISContext->Display(AISBox);
691
692 DBRep::Set("Box",box.Shape());
693
694// BRepAlgoAPI_Cut cut( sol1_, box.Shape() );
695// //BRepAlgoAPI_Cut cut( box.Shape(), sol1_ );
696// TopoDS_Shape sh1_ = cut.Shape();
697// Handle(AIS_Shape) AISCut = new AIS_Shape(sh1_);
698// AISCut->SetColor(Quantity_NOC_RED);
699// myAISContext->Display(AISCut);
700
701// DBRep::Set("Cut",sh1_);
702
703 return 0;
704
705}
706#include<GProp_GProps.hxx>
707#include<BRepGProp.hxx>
708
709static Standard_Integer OCC305 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
710
711{
712 if (argc =! 2)
713 {
714 di <<"Usage : " << argv[0] << " file"<<"\n";
715 return 1;
716 }
717 Standard_CString file = argv[1];
718
719 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
720 if(myAISContext.IsNull()) {
721 di << "use 'vinit' command before " << argv[0] << "\n";
722 return -1;
723 }
724
725TopoDS_Shape sh;
726BRep_Builder builder;
727//BRepTools::Read(sh, "/dn02/users_SUN/inv/3/OCC305/testc.brep", builder);
728BRepTools::Read(sh, file, builder);
729
730TopoDS_Wire wire;
731builder.MakeWire(wire);
732TopoDS_Edge ed;
733TopoDS_Vertex vt1, vt2;
734TopExp_Explorer wex(sh, TopAbs_EDGE);
735for(;wex.More();wex.Next())
736{
737 ed = TopoDS::Edge(wex.Current());
738 TopExp::Vertices(ed, vt1, vt2);
739 builder.UpdateVertex(vt1, 0.01);
740 builder.UpdateVertex(vt2, 0.01);
741 builder.UpdateEdge(ed, 0.01);
742 builder.Add(wire, ed);
743
744
745 GProp_GProps lprop;
746 BRepGProp::LinearProperties(ed, lprop);
747 printf("\n length = %f", lprop.Mass());
748}
749 DBRep::Set("Wire",wire);
750// Handle(AIS_Shape) res = new AIS_Shape( wire );
751// aContext->SetColor( res, Quantity_NOC_RED );
752// aContext->Display( res );
753
754// BRepOffsetAPI_MakeOffset off(wire, GeomAbs_Arc);
755// off.Perform(0.5, 0);
756
757// printf("\n IsDone = %d", off.IsDone());
758// sh = off.Shape();
759// res = new AIS_Shape( sh );
760// aContext->SetColor( res, Quantity_NOC_GREEN );
761// aContext->Display( res );
762
763 return 0;
764
765}
766
767static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
768{
769
770 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
771 if(myAISContext.IsNull()) {
772 di << "use 'vinit' command before " << argv[0];
773 return 1;
774 }
775
776 BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
777 Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape());
778 myAISContext->Display(anAISBox, 1);
779 anAISBox->SetSelectionMode(-1);
780 Standard_Integer myLocContInd = myAISContext->OpenLocalContext();
781 myAISContext->CloseLocalContext(myLocContInd);
782 Standard_Integer aSelMode = ((Handle(AIS_InteractiveObject)) anAISBox)->SelectionMode();
783 if(aSelMode != -1)
784 return 1;
785
786 return 0;
787}
788
789#include <TDocStd_Document.hxx>
790#include <DDocStd.hxx>
791#include <CDF_StoreStatus.hxx>
792#include <TDocStd_Application.hxx>
793
794static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
795{
796 if (nb != 2) {
797 di << "Usage: " << a[0] << " Doc" << "\n";
798 return 1;
799 }
800
801 Handle(TDocStd_Document) D;
802 if (!DDocStd::GetDocument(a[1],D)) return 1;
803
804 Handle(TDocStd_Application) A;
805 if (!DDocStd::Find(A)) return 1;
806
807 TCollection_ExtendedString theStatusMessage;
808 if (!D->IsSaved()) {
809 di << "this document has never been saved" << "\n";
810 return 0;
811 }
812 CDF_StoreStatus theStatus = A->Save(D, theStatusMessage);
813 if (theStatus != CDF_SS_OK ) {
814 switch ( theStatus ) {
815 case CDF_SS_DriverFailure: {
816 di << " Could not store , no driver found to make it " <<"\n" ;
817 break ;
818 }
819 case CDF_SS_WriteFailure: {
820 di << " Write access failure " << "\n" ;
821 break;
822 }
823 case CDF_SS_Failure: {
824 di << " Write failure " << "\n" ;
825 }
826 }
827 return 1;
828 }
829 return 0;
830}
831
832static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
833{
834 if (nb != 3) {
835 di << "Usage: " << a[0] << " Doc Path" << "\n";
836 return 1;
837 }
838
839 Handle(TDocStd_Document) D;
840 if (!DDocStd::GetDocument(a[1],D)) return 1;
841
842 TCollection_ExtendedString path (a[2]);
843 Handle(TDocStd_Application) A;
844 if (!DDocStd::Find(A)) return 1;
845
846 TCollection_ExtendedString theStatusMessage;
847 CDF_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
848 if (theStatus != CDF_SS_OK ) {
849 switch ( theStatus ) {
850 case CDF_SS_DriverFailure: {
851 di << " Could not store , no driver found to make it " <<"\n" ;
852 break ;
853 }
854 case CDF_SS_WriteFailure: {
855 di << " Write access failure " << "\n" ;
856 break;
857 }
858 case CDF_SS_Failure: {
859 di << " Write failure " << "\n" ;
860 }
861 }
862 return 1;
863 }
864
865 return 0;
866}
867
868#include <BRepClass3d_SolidClassifier.hxx>
869
870Standard_Integer OCC299bug (Draw_Interpretor& di,
871 Standard_Integer n,
872 const char ** a)
873{
874 char sbf[512];
875
876 if (n < 3) {
877 di << "Usage : " << a[0] << " Solid Point [Tolerance=1.e-7]" << "\n";
878 return -1;
879 }
880
881 TopoDS_Shape aS = DBRep::Get(a[1]);
882 if (aS.IsNull()) {
883 sprintf(sbf, " Null Shape is not allowed here\n");
884 di<<sbf;
885 return 1;
886 }
887
888 if (aS.ShapeType()!=TopAbs_SOLID) {
889 sprintf(sbf, " Shape type must be SOLID\n");
890 di<<sbf;
891 return 1;
892 }
893 //
894 Standard_Real aTol=1.e-7;
895 TCollection_AsciiString sIN("IN"), sOUT("OUT of"), sON("ON"), sUNKNOWN("UNKNOWN");
896 TopAbs_State aState = TopAbs_UNKNOWN;
897 gp_Pnt aP(8., 9., 10.);
898
899 if (!DrawTrSurf::GetPoint(a[2], aP) ) {
900 sprintf(sbf, " Null Point is not allowed here\n");
901 di<<sbf;
902 return 1;
903 }
904
905 aTol=1.e-7;
906 if (n==4) {
907 aTol=atof(a[3]);
908 }
909 //
910 BRepClass3d_SolidClassifier aSC(aS);
911 aSC.Perform(aP,aTol);
912 //
913 aState = aSC.State();
914 //
915 sprintf(sbf, "The point is "); di<<sbf;
916 //
917 switch (aState) {
918 case TopAbs_IN:
919 sprintf(sbf, sIN.ToCString());
920 break;
921 case TopAbs_OUT:
922 sprintf(sbf, sOUT.ToCString());
923 break;
924 case TopAbs_ON:
925 sprintf(sbf, sON.ToCString());
926 break;
927 case TopAbs_UNKNOWN:
928 sprintf(sbf, sUNKNOWN.ToCString());
929 break;
930 default:
931 sprintf(sbf, sUNKNOWN.ToCString());
932 break;
933 }
934 di<<sbf;
935 //
936 sprintf(sbf, " shape\n");
937 di<<sbf;
938
939 return 0;
940}
941
942#include <OSD_Process.hxx>
943#include <OSD_Path.hxx>
944
945static Standard_Integer OCC309bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
946{
947 if (nb != 1) {
948 di << "Usage: " << a[0] << "\n";
949 return 1;
950 }
951 OSD_Process p;
952 OSD_Path d = p.CurrentDirectory();
953 TCollection_AsciiString s;
954 d.SystemName(s);
955 di << "*" << s.ToCString() << "*" << "\n";
956 d.UpTrek();
957 d.SystemName(s);
958 di << "*" << s.ToCString() << "*" <<"\n";
959 return 0;
960}
961
962static Standard_Integer OCC310bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
963{
964 if (nb != 1) {
965 di << "Usage: " << a[0] << "\n";
966 return 1;
967 }
968 OSD_Path p("/where/you/want/tmp/qwerty/tmp/");
969 di << p.Trek().ToCString() << "\n";
970 p.UpTrek();
971 di << p.Trek().ToCString() << "\n";
972 return 0;
973}
974
975#include <BRepAlgoAPI_Fuse.hxx>
976#include <BRepAlgoAPI_Common.hxx>
977#include <BRepAlgo_Fuse.hxx>
978#include <BRepAlgo_Common.hxx>
979
980static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
981{
982 //if (nb != 1) {
983 // cout << "Usage: " << a[0] << endl;
984 // return 1;
985 //}
986 if(nb < 1 || nb > 2) {
987 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
988 return 1;
989 }
990 Standard_Boolean IsBRepAlgoAPI = Standard_True;
991 if (nb == 2) {
992 Standard_Integer IsB = atoi(a[1]);
993 if (IsB != 1) {
994 IsBRepAlgoAPI = Standard_False;
995 }
996 }
997
998 BRepPrimAPI_MakeBox box1( 100, 100, 100 );
999 BRepPrimAPI_MakeBox box2( gp_Pnt( 50, 50,50 ), 200, 200, 200 );
1000
1001 TopoDS_Shape shape1 = box1.Shape();
1002 TopoDS_Shape shape2 = box2.Shape();
1003
1004//#if ! defined(BRepAlgoAPI_def01)
1005// TopoDS_Shape fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
1006// TopoDS_Shape comm = BRepAlgoAPI_Common( shape1, shape2 );
1007//#else
1008// TopoDS_Shape fuse = BRepAlgo_Fuse( shape1, shape2 );
1009// TopoDS_Shape comm = BRepAlgo_Common( shape1, shape2 );
1010//#endif
1011 TopoDS_Shape fuse,comm;
1012 if (IsBRepAlgoAPI) {
1013 di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )" <<"\n";
1014 di << "comm = BRepAlgoAPI_Common( shape1, shape2 )" <<"\n";
1015 fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
1016 comm = BRepAlgoAPI_Common( shape1, shape2 );
1017 } else {
1018 di << "fuse = BRepAlgo_Fuse( shape1, shape2 )" <<"\n";
1019 fuse = BRepAlgo_Fuse( shape1, shape2 );
1020 di << "comm = BRepAlgo_Common( shape1, shape2 )" <<"\n";
1021 comm = BRepAlgo_Common( shape1, shape2 );
1022 }
1023
1024 return 0;
1025}
1026
1027#include <ShapeAnalysis_Edge.hxx>
1028
1029static Standard_Integer OCC333bug (Draw_Interpretor& di, Standard_Integer n, const char ** a)
1030{
1031 if( n < 3) {
1032 di<<"-1"<<"\n";
1033 di << "Usage: " << a[0] << " edge1 edge2 [toler domaindist]" << "\n";
1034 return 1;
1035 }
1036 TopoDS_Shape Sh1 = DBRep::Get(a[1]);
1037 TopoDS_Shape Sh2 = DBRep::Get(a[2]);
1038 if(Sh1.IsNull() || Sh2.IsNull()) {
1039 di<<"-2"<<"\n";
1040 di<<"Invalid arguments"<<"\n";
1041 return 1;
1042 }
1043 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
1044 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
1045 if(e1.IsNull() || e2.IsNull()) {
1046 di<<"-3"<<"\n";
1047 di<<"Invalid type of arguments"<<"\n";
1048 return 1;
1049 }
1050 Standard_Real aTol = Precision::Confusion();
1051 Standard_Real aDistDomain = 0.0;
1052 Standard_Integer k = 3;
1053 if(k < n)
1054 aTol = atof(a[k++]);
1055 if(k < n)
1056 aDistDomain = atof(a[k++]);
1057
1058 ShapeAnalysis_Edge sae;
1059 if(sae.CheckOverlapping(e1,e2,aTol,aDistDomain)) {
1060 if(aDistDomain ==0.0) {
1061 di<<"1"<<"\n";
1062 di<<"Edges is overlaping comletly"<<"\n";
1063 } else {
1064 di<<"2"<<"\n";
1065 di<<"Edges is overlaped"<<"\n";
1066 di<<"with tolerance = "<<aTol<<"\n";
1067 di<<"on segment length = "<<aDistDomain<<"\n";
1068 }
1069 } else {
1070 di<<"3"<<"\n";
1071 di<<"Edges is not overlaped"<<"\n";
1072 }
1073 return 0;
1074}
1075
1076
1077#include <DDocStd_DrawDocument.hxx>
1078#include <TDataStd_Name.hxx>
1079#include <Draw.hxx>
1080#include <XCAFDoc_ShapeTool.hxx>
1081#include <XCAFDoc_DocumentTool.hxx>
1082#include <TDF_LabelSequence.hxx>
1083#include <TPrsStd_AISPresentation.hxx>
1084#include <TDF_Data.hxx>
1085#include <TDF_Label.hxx>
1086#include <XCAFPrs_Driver.hxx>
1087
1088//------------------------------------------------------------------------------------------
1089// name : OCC363
1090// Purpose :
1091//------------------------------------------------------------------------------------------
1092static Standard_Integer OCC363 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1093{
1094 try
1095 {
1096 OCC_CATCH_SIGNALS
1097 // 1. Verufy amount of arguments
1098 if(argc < 3) { di <<"Error OCC363 : Use : OCC363 document filename\n"; return 1; }
1099
1100 // 2. Retrieve DDocStd application
1101 Handle(TDocStd_Application) App;
1102 if (!DDocStd::Find(App)) { di << "Error OCC363 : There is no current DDocStd application\n";return 1;}
1103
1104 // 3. Open document
1105 TCollection_ExtendedString name(argv[2]);
1106 Handle(TDocStd_Document) Doc;
1107 if(App->Open(name, Doc) != CDF_RS_OK) { di << "Error OCC363 : document was not opened successfully\n"; return 1;}
1108 Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(Doc);
1109 TDataStd_Name::Set(Doc->GetData()->Root(),argv[1]);
1110 Draw::Set(argv[1],DD);
1111
1112 // 4. Create prsentations
1113 Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
1114 TDF_LabelSequence seq;
1115 shapes->GetFreeShapes ( seq );
1116 Handle(TPrsStd_AISPresentation) prs;
1117 for ( Standard_Integer i=1; i <= seq.Length(); i++ )
1118 if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) )
1119 prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
1120 }
1121 catch(Standard_Failure) { di << "FAULTY OCC363 : Exception during reading document.\n";return 0;}
1122
1123 di << "OCC363 OK\n";
1124 return 0;
1125}
1126
1127// Must use OCC299
1128////======================================================================================
1129//// Function : OCC372
1130//// Purpose :
1131////======================================================================================
1132//static Standard_Integer OCC372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1133//{
1134// try
1135// {
1136// OCC_CATCH_SIGNALS
1137// // 1. Verufy amount of arguments
1138// if(argc < 2) {di << "OCC372 FAULTY. Use : OCC372 brep-file";return 0;}
1139//
1140// // 2. Read solid
1141// BRep_Builder B;
1142// TopoDS_Shape Ref;
1143// BRepTools::Read(Ref, argv[1], B);
1144//
1145// // 3. Calculate location of aP3d in relation to the solid
1146// gp_Pnt aP3d(6311.4862583184, -2841.3092756034, 16.461053497188);
1147// BRepClass3d_SolidClassifier SC(Ref);
1148// SC.Perform(aP3d, 1e-7);
1149//
1150// // 4. Check returned state. The point must be inside the solid.
1151// TopAbs_State aState=SC.State();
1152// switch (aState)
1153// {
1154// case TopAbs_OUT:
1155// di<<"OCC372 FAULTY. aState = TopAbs_OUT";
1156// return 0;
1157// case TopAbs_ON:
1158// di<<"OCC372 FAULTY. aState = TopAbs_ON";
1159// return 0;
1160// case TopAbs_IN:
1161// di<<"OCC372 OK. aState = TopAbs_IN" ;
1162// return 0;
1163// default:
1164// di<<"OCC372 FAULTY. aState = UNKNOWN";
1165// return 0;
1166// }
1167// }
1168// catch (Standard_Failure) { di<<"OCC372 FAULTY. Exception raised"; }
1169//
1170// return 0;
1171//}
1172
1173#include <BRepTopAdaptor_FClass2d.hxx>
1174
1175//======================================================================================
1176// Function : OCC377
1177// Purpose :
1178//======================================================================================
1179static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1180{
1181 try
1182 {
1183 OCC_CATCH_SIGNALS
1184 // 1. Verify validity of arguments
1185 if ( argc < 1 ) {di << "Error OCC377. Use OCC377 file x y precuv \n";return 0;}
1186
1187 // 2. Initialize parameters
1188 gp_Pnt2d p2d;
1189 p2d.SetX ( atof(argv[2]) );
1190 p2d.SetY ( atof(argv[3]) );
1191 Standard_Real precuv = atof (argv[4] );
1192
1193 // 3. Read shape
1194 BRep_Builder B;
1195 TopoDS_Shape Shape;
1196 BRepTools::Read ( Shape, argv[1], B );
1197
1198 // 4. Verify whether enrtry point is on wire and reversed ones (indeed results of veridying must be same)
1199 TopExp_Explorer exp;
1200 Standard_Integer i=1;
1201 for (exp.Init(Shape.Oriented(TopAbs_FORWARD),TopAbs_WIRE); exp.More(); exp.Next(), i++)
1202 {
1203 // 4.1. Verify whether enrtry point is on wire
1204 const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
1205 TopoDS_Face newFace = TopoDS::Face(Shape.EmptyCopied());
1206
1207 TopAbs_Orientation orWire = wir.Orientation();
1208 newFace.Orientation(TopAbs_FORWARD);
1209 B.Add(newFace,wir);
1210
1211 BRepTopAdaptor_FClass2d FClass2d1(newFace,precuv);
1212 TopAbs_State stat1 = FClass2d1.PerformInfinitePoint();
1213 //di << "Wire " << i << ": Infinite point is " <<
1214 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1215
1216 TCollection_AsciiString TmpString;
1217 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1218 di << "Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1219
1220 stat1 = FClass2d1.Perform(p2d);
1221 //di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1222 // ( stat1 == TopAbs_IN ? "IN" : stat1 == TopAbs_OUT ? "OUT" : stat1 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1223
1224 TmpString.Clear();
1225 stat1 == TopAbs_IN ? TmpString.AssignCat("IN") : stat1 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat1 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1226 di << "Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1227
1228 // 4.2. Verify whether enrtry point is on reversed wire
1229 newFace = TopoDS::Face(Shape.EmptyCopied());
1230 newFace.Orientation(TopAbs_FORWARD);
1231 orWire = TopAbs::Reverse(orWire);
1232 B.Add(newFace,wir.Oriented(orWire));
1233 BRepTopAdaptor_FClass2d FClass2d2(newFace,precuv);
1234 TopAbs_State stat2 = FClass2d2.PerformInfinitePoint();
1235 //di << "Reversed Wire " << i << ": Infinite point is " <<
1236 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1237
1238 TmpString.Clear();
1239 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1240 di << "Reversed Wire " << i << ": Infinite point is " << TmpString.ToCString() << "\n";
1241
1242 stat2 = FClass2d2.Perform(p2d);
1243 //di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " <<
1244 // ( stat2 == TopAbs_IN ? "IN" : stat2 == TopAbs_OUT ? "OUT" : stat2 == TopAbs_ON ? "ON" : "UNKNOWN" ) << "\n";
1245
1246 TmpString.Clear();
1247 stat2 == TopAbs_IN ? TmpString.AssignCat("IN") : stat2 == TopAbs_OUT ? TmpString.AssignCat("OUT") : stat2 == TopAbs_ON ? TmpString.AssignCat("ON") : TmpString.AssignCat("UNKNOWN");
1248 di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
1249
1250 // 4.3. Compare results (they must be same)
1251 if(stat1 ==stat2) di << "OCC377 OK" << "\n";
1252 else {di << "OCC377 FAULTY" << "\n"; return 0;}
1253 }
1254 }
1255 catch(Standard_Failure)
1256 {
1257 di << "OCC377 Exception";
1258 }
1259
1260 return 0;
1261}
1262
1263#include <ShapeUpgrade_ShapeDivideAngle.hxx>
1264#include <ShapeBuild_ReShape.hxx>
1265
1266//=======================================================================
1267//function : OCC22
1268//purpose :
1269//=======================================================================
1270static Standard_Integer OCC22 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1271{
1272 try
1273 {
1274 OCC_CATCH_SIGNALS
1275 // 1. Verify arguments of the command
1276 if (argc < 5) { di << "OCC22 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation"; return 0;}
1277
1278 Standard_Boolean aConsiderLocation;
1279 if(strcmp(argv[4], "0")==0) aConsiderLocation = Standard_False;
1280 else aConsiderLocation = Standard_True;
1281
1282 // 2. Iniitialize aShapeUpgrade
1283 ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(PI/2.);
1284 // precision
1285 aShapeUpgrade.SetPrecision (Precision::Confusion());
1286 // tolerance
1287 aShapeUpgrade.SetMaxTolerance(0.1);
1288 // subshapes to be divided
1289 TopoDS_Shape aSubShapesToBeDivided = DBRep::Get(argv[3]);
1290 if(aSubShapesToBeDivided.IsNull()) {di << "OCC22 FAULTY. Compound of subshapes to be divided is not exist. Please, verify input values. \n";return 0;}
1291 aShapeUpgrade.Init(aSubShapesToBeDivided);
1292 // context
1293 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1294 aShapeUpgrade.SetContext(aReshape);
1295 if(aConsiderLocation) aReshape->ModeConsiderLocation() = Standard_True;
1296
1297 // 3. Perform splitting
1298 if (aShapeUpgrade.Perform (Standard_False)) di << "Upgrade_SplitRevolution_Done \n";
1299 else if (aShapeUpgrade.Status (ShapeExtend_OK)) di << "Upgrade_SplitRevolution_OK \n";
1300 else if (aShapeUpgrade.Status (ShapeExtend_FAIL)) { di << "OCC22 FAULTY. Operation failed. Angle was not divided\n";return 0;}
1301
1302 // 4. Perform rebuilding shape
1303 // 4.1. Retrieve Shape
1304 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1305 if(anInitShape.IsNull()) { di << "OCC22 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1306 // 4.2 Rebuid retrieved shape
1307 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1308 // 4.3. Create result Draw shape
1309 DBRep::Set(argv[1], aResultShape);
1310 }
1311 catch (Standard_Failure) {di << "OCC22 Exception \n" ;return 0;}
1312
1313 return 0;
1314}
1315
1316
1317#include <ShapeProcess_OperLibrary.hxx>
1318#include <ShapeProcess_ShapeContext.hxx>
1319#include <ShapeProcess.hxx>
1320
1321#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
1322#include <BRepMesh_IncrementalMesh.hxx>
1323
1324//=======================================================================
1325//function : OCC24
1326//purpose :
1327//=======================================================================
1328static Standard_Integer OCC24 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1329{
1330 try
1331 {
1332 OCC_CATCH_SIGNALS
1333 // 1. Verify amount of arguments of the command
1334 if (argc < 6) { di << "OCC24 FAULTY. Use : OCC22 Result Shape CompoundOfSubshapes ResourceFileName SequenceName"; return 0;}
1335
1336 // 2. Retrieve parameters
1337 // initial shape
1338 TopoDS_Shape anInitShape = DBRep::Get(argv[2]);
1339 if(anInitShape.IsNull()) { di << "OCC24 FAULTY. Initial shape is not exist. Please verify input values \n"; return 0;}
1340 // compound of subshapes
1341 TopoDS_Shape aSubShapes = DBRep::Get(argv[3]);
1342 if(aSubShapes.IsNull()) {di << "OCC24 FAULTY. Compound of subshapes is not exist. Please, verify input values. \n";return 0;}
1343 // name of resource file
1344 const char* aResourceFile = argv[4];
1345 // name of sequence from resource file to be executed
1346 const char* aSequenceName = argv[5];
1347
1348 // 3. Initialize ShapeContext and perform sequence of operation specified with resource file
1349 ShapeProcess_OperLibrary::Init();
1350 Handle(ShapeProcess_ShapeContext) aShapeContext = new ShapeProcess_ShapeContext (aSubShapes, aResourceFile);
1351 aShapeContext->SetDetalisation (TopAbs_EDGE);
1352 ShapeProcess::Perform (aShapeContext, aSequenceName);
1353
1354 // 4. Rebuild initil shape in accordance with performed operation
1355 Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
1356 TopTools_DataMapIteratorOfDataMapOfShapeShape anIter (aShapeContext->Map());
1357 for (; anIter.More(); anIter.Next())
1358 aReshape->Replace(anIter.Key(), anIter.Value());
1359 TopoDS_Shape aResultShape = aReshape->Apply(anInitShape);
1360
1361 // 5 Create resultant Draw shape
1362 DBRep::Set(argv[1], aResultShape);
1363
1364 }
1365 catch (Standard_Failure) {di << "OCC24 Exception \n" ;return 0;}
1366
1367 return 0;
1368}
1369
1370//=======================================================================
1371//function : OCC369
1372//purpose : Verify whether exception occurs during building mesh
1373//=======================================================================
1374static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1375{
1376 try
1377 {
1378 OCC_CATCH_SIGNALS
1379 // 1. Verify amount of arguments of the command
1380 if (argc < 2) { di << "OCC369 FAULTY. Use : OCC369 Shape \n"; return 0;}
1381
1382 // 2. Retrieve shape
1383 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1384 if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
1385
1386 // 3. Build mesh
1387 BRepMesh_IncrementalMesh aMesh(aShape, 0.2, Standard_True, PI/6);
1388
1389 }
1390 catch (Standard_Failure) {di << "OCC369 Exception \n" ;return 0;}
1391
1392 di << "OCC369 OK \n";
1393 return 0;
1394}
1395
1396#include <math_Vector.hxx>
1397#include <math_Matrix.hxx>
1398static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1399{
1400 if(argc != 9){
1401 di<<"Usage : " << argv[0] << " LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix\n";
1402 return 1;
1403 }
1404 Standard_Integer LowerVector = atoi(argv[1]);
1405 Standard_Integer UpperVector = atoi(argv[2]);
1406 Standard_Real InitialValueVector = atof(argv[3]);
1407 Standard_Integer LowerRowMatrix = atoi(argv[4]);
1408 Standard_Integer UpperRowMatrix = atoi(argv[5]);
1409 Standard_Integer LowerColMatrix = atoi(argv[6]);
1410 Standard_Integer UpperColMatrix = atoi(argv[7]);
1411 Standard_Real InitialValueMatrix = atof(argv[8]);
1412
1413 math_Vector Vector1(LowerVector, UpperVector);
1414 math_Vector Vector2(LowerVector, UpperVector);
1415
1416 math_Vector Vector(LowerVector, UpperVector, InitialValueVector);
1417 math_Matrix Matrix(LowerRowMatrix, UpperRowMatrix, LowerColMatrix, UpperColMatrix, InitialValueMatrix);
1418
1419 //Vector.Dump(cout);
1420 //cout<<endl;
1421
1422 //Matrix.Dump(cout);
1423 //cout<<endl;
1424
1425 Vector1.Multiply(Vector, Matrix);
1426
1427 //Vector1.Dump(cout);
1428 Standard_SStream aSStream1;
1429 Vector1.Dump(aSStream1);
1430 di << aSStream1;
1431 di<<"\n";
1432
1433 Vector2.TMultiply(Vector, Matrix);
1434
1435 //Vector2.Dump(cout);
1436 Standard_SStream aSStream2;
1437 Vector2.Dump(aSStream2);
1438 di << aSStream2;
1439 di<<"\n";
1440
1441 return 0;
1442}
1443
1444#include <GeomPlate_BuildPlateSurface.hxx>
1445//=======================================================================
1446//function : OCC525
1447//purpose :
1448//=======================================================================
1449static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
1450{
1451 try
1452 {
1453 OCC_CATCH_SIGNALS
1454 GeomPlate_BuildPlateSurface aBuilder;
1455 aBuilder.Perform();
1456 }
1457 catch (Standard_RangeError) { di << "OCC525 Exception \n" ;return 0; }
1458 //catch (...) { di << "OCC525 Exception \n" ;return 0; }
1459
1460 di << "OCC525 OK \n";
1461 return 0;
1462}
1463
1464#include <Viewer2dTest.hxx>
1465#include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
1466
1467#include <AIS2D_InteractiveContext.hxx>
1468#include <V2d_View.hxx>
1469#include <AIS2D_InteractiveObject.hxx>
1470#include <TColStd_HSequenceOfInteger.hxx>
1471
1472#if ! defined(WNT)
1473extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1474#else
1475Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1476#endif
1477
1478//=======================================================================
1479//function : OCC543
1480//purpose :
1481//=======================================================================
1482static Standard_Integer OCC543 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1483{
1484 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1485 if(aContext.IsNull()) {
1486 di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
1487 return -1;
1488 }
1489 if(argc != 2){
1490 di<<"Usage : " << argv[0] << " name\n";
1491 return -1;
1492 }
1493 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1494
1495 TCollection_AsciiString name = argv[1];
1496
1497 if (!GetMapOfAIS2D().IsBound2(name)) {
1498// di << "There is not an object with name " << name.ToCString() << "\n";
1499// return -1;
1500 }
1501
1502 Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name);
1503 Standard_Integer PickedIndex = aShape->PickedIndex();
1504 di << "PickedIndex = " << PickedIndex << "\n";
1505 return 0;
1506}
1507
1508#include <BRepPrimAPI_MakeWedge.hxx>
1509#include <gce_MakeRotation.hxx>
1510#include <gce_MakeTranslation.hxx>
1511#include <BRepBuilderAPI_Transform.hxx>
1512#include <BRepPrimAPI_MakeWedge.hxx>
1513#include <BRepAlgoAPI_Fuse.hxx>
1514#include <BRepAlgoAPI_Cut.hxx>
1515#include <BRepAlgo_Fuse.hxx>
1516#include <BRepAlgo_Cut.hxx>
1517//=======================================================================
1518//function : OCC578
1519//purpose :
1520//=======================================================================
1521static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1522{
1523 //if (argc!=4) {
1524 // di<<"Usage : " << argv[0] << " shape1 shape2 shape3\n";
1525 // return 1;
1526 //}
1527 if(argc < 4 || argc > 5) {
1528 di << "Usage : " << argv[0] << " shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1529 return 1;
1530 }
1531 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1532 if (argc == 5) {
1533 Standard_Integer IsB = atoi(argv[4]);
1534 if (IsB != 1) {
1535 IsBRepAlgoAPI = Standard_False;
1536// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1537// return 1;
1538// di << "Error: There is not BRepAlgo_Cut class" << "\n";
1539// return 1;
1540 }
1541 }
1542
1543 gp_Pnt P0(0,0,0.0);
1544 double xperiod = 1.0;
1545 double yperiod = 1.0;
1546 double sub_thick = 0.5;
1547
1548 // mask_substrate
1549 //TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick );
1550 TopoDS_Shape substrate = BRepPrimAPI_MakeBox( P0, xperiod, yperiod, sub_thick ).Shape();
1551
1552 // --------------------------------------------------------------------
1553
1554 // wedge
1555 //TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1556 // 0.1, 0.1 , 0.4, 0.4 );
1557 TopoDS_Shape wedge1 = BRepPrimAPI_MakeWedge(0.5, 0.05, 0.5,
1558 0.1, 0.1 , 0.4, 0.4 ).Shape();
1559
1560 gp_Trsf rotate = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1561 gp_Dir(1.0,0.0,0.0),
1562 1.570795 );
1563
1564 gp_Trsf translate = gce_MakeTranslation(gp_Pnt( 0.0, -0.5, 0.0),
1565 gp_Pnt( 0.25, 0.25, 0.5)
1566 );
1567
1568 rotate.PreMultiply( translate );
1569
1570 TopoDS_Shape wedge1a = BRepBuilderAPI_Transform( wedge1, rotate );
1571
1572 if (wedge1a.IsNull()) {
1573 di<<" Null shape1 is not allowed\n";
1574 return 1;
1575 }
1576 DBRep::Set(argv[1], wedge1a);
1577
1578 // --------------------------------------------------------------------
1579
1580 // wedge top
1581 //TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1582 // 0.1, 0.1 , 0.4, 0.4 );
1583 TopoDS_Shape wedge2 = BRepPrimAPI_MakeWedge(0.5, 0.3, 0.5,
1584 0.1, 0.1 , 0.4, 0.4 ).Shape();
1585
1586 gp_Trsf rotate2 = gce_MakeRotation ( gp_Pnt(0.0,0.0,0.0),
1587 gp_Dir(1.0,0.0,0.0),
1588 1.570795 * 3.0 );
1589
1590 gp_Trsf translate2 = gce_MakeTranslation(gp_Pnt( 0.0, 0.0, 0.0),
1591 gp_Pnt( 0.25, 0.25, 0.5)
1592 );
1593
1594 rotate2.PreMultiply( translate2 );
1595
1596 TopoDS_Shape wedge2a = BRepBuilderAPI_Transform( wedge2, rotate2 );
1597
1598 if (wedge2a.IsNull()) {
1599 di<<" Null shape2 is not allowed\n";
1600 return 1;
1601 }
1602 DBRep::Set(argv[2], wedge2a);
1603
1604
1605 // combine wedges
1606//#if ! defined(BRepAlgoAPI_def01)
1607// TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1608//#else
1609// TopoDS_Shape wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1610//#endif
1611 TopoDS_Shape wedge_common;
1612 if (IsBRepAlgoAPI) {
1613 di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)" <<"\n";
1614 wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
1615 } else {
1616 di << "wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a)" <<"\n";
1617 wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
1618 }
1619
1620 // remove wedge area from substrate
1621//#if ! defined(BRepAlgoAPI_def01)
1622// TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1623//#else
1624// TopoDS_Shape sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1625//#endif
1626 TopoDS_Shape sub_etch1;
1627 if (IsBRepAlgoAPI) {
1628 di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)" <<"\n";
1629 sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
1630 } else {
1631 di << "sub_etch1 = BRepAlgo_Cut(substrate, wedge_common)" <<"\n";
1632 sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
1633 }
1634
1635 if (sub_etch1.IsNull()) {
1636 di<<" Null shape3 is not allowed\n";
1637 return 1;
1638 }
1639 DBRep::Set(argv[3], sub_etch1);
1640
1641 return 0;
1642}
1643
1644#include <Graphic2d_DisplayList.hxx>
1645#include <Graphic2d_View.hxx>
1646
1647//=======================================================================
1648//function : OCC627
1649//purpose :
1650//=======================================================================
1651static Standard_Integer OCC627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1652{
1653 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1654 if(aContext.IsNull()) {
1655 di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
1656 return -1;
1657 }
1658 if(argc != 1){
1659 di<<"Usage : " << argv[0] << "\n";
1660 return -1;
1661 }
1662
1663 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1664 Handle(Graphic2d_View) View = V->View();
1665 Handle(Graphic2d_DisplayList) DisplayList = View->DisplayList();
1666 Standard_Integer Length = DisplayList->Length();
1667 di << "Length = " << Length << "\n";
1668
1669 return 0;
1670}
1671
1672#include <QAOCC_OCC749Prs.hxx>
1673//=======================================================================
1674//function : OCC749_sav
1675//purpose :
1676//=======================================================================
1677static Standard_Integer OCC749_sav (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1678{
1679
1680 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
1681 if(myAISContext.IsNull()) {
1682 di << "use 'vinit' command before " << argv[0];
1683 return 1;
1684 }
1685 if(argc != 8) {
1686 di << "Usage : " << argv[0] << " Reflection(=0/1) R1 G1 B1 R2 G2 B2" << "\n";
1687 return -1;
1688 }
1689
1690 Standard_Integer IntegerReflection = atoi(argv[1]);
1691 Standard_Boolean Reflection;
1692 if (IntegerReflection == 0) {
1693 Reflection = Standard_False;
1694 } else {
1695 Reflection = Standard_True;
1696 }
1697 Standard_Integer R1_Integer = atoi(argv[2]);
1698 Standard_Integer G1_Integer = atoi(argv[3]);
1699 Standard_Integer B1_Integer = atoi(argv[4]);
1700 Standard_Integer R2_Integer = atoi(argv[5]);
1701 Standard_Integer G2_Integer = atoi(argv[6]);
1702 Standard_Integer B2_Integer = atoi(argv[7]);
1703 Quantity_Parameter R1 = R1_Integer / 255.;
1704 Quantity_Parameter G1 = G1_Integer / 255.;
1705 Quantity_Parameter B1 = B1_Integer / 255.;
1706 Quantity_Parameter R2 = R2_Integer / 255.;
1707 Quantity_Parameter G2 = G2_Integer / 255.;
1708 Quantity_Parameter B2 = B2_Integer / 255.;
1709
1710 Handle(QAOCC_OCC749Prs) anIntearactiveObject =
1711 new QAOCC_OCC749Prs(Reflection,
1712 Quantity_Color(R1, G1, B1, Quantity_TOC_RGB),
1713 Quantity_Color(R2, G2, B2, Quantity_TOC_RGB));
1714 myAISContext->Display(anIntearactiveObject);
1715 return 0;
1716}
1717
1718#include <Standard_GUID.hxx>
1719//=======================================================================
1720//function : OCC669
1721//purpose :
1722//=======================================================================
1723static Standard_Integer OCC669 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1724{
1725 if(argc != 2){
1726 di<<"Usage : " << argv[0] << " GUID\n";
1727 return -1;
1728 }
1729 Standard_GUID guid(argv[1]);
1730 //guid.ShallowDump(cout);
1731 Standard_SStream aSStream;
1732 guid.ShallowDump(aSStream);
1733 di << aSStream;
1734 di<<"\n";
1735 return 0;
1736}
1737
1738#include <XCAFDoc.hxx>
1739//=======================================================================
1740//function : OCC738_ShapeRef
1741//purpose :
1742//=======================================================================
1743static Standard_Integer OCC738_ShapeRef (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1744{
1745 if(argc != 1){
1746 di<<"Usage : " << argv[0] << "\n";
1747 return -1;
1748 }
1749 const Standard_GUID& guid = XCAFDoc::ShapeRefGUID ();
1750 //guid.ShallowDump(cout);
1751 Standard_SStream aSStream;
1752 guid.ShallowDump(aSStream);
1753 di << aSStream;
1754 return 0;
1755}
1756
1757//=======================================================================
1758//function : OCC738_Assembly
1759//purpose :
1760//=======================================================================
1761static Standard_Integer OCC738_Assembly (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1762{
1763 if(argc != 1){
1764 di<<"Usage : " << argv[0] << "\n";
1765 return -1;
1766 }
1767 const Standard_GUID& guid = XCAFDoc::AssemblyGUID ();
1768 //guid.ShallowDump(cout);
1769 Standard_SStream aSStream;
1770 guid.ShallowDump(aSStream);
1771 di << aSStream;
1772 return 0;
1773}
1774
1775#if defined(DDataStd_def01)
1776#include <DDataStd_DrawPresentation.hxx>
1777//=======================================================================
1778//function : OCC739_DrawPresentation
1779//purpose :
1780//=======================================================================
1781static Standard_Integer OCC739_DrawPresentation (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1782{
1783 if(argc != 1){
1784 di<<"Usage : " << argv[0] << "\n";
1785 return -1;
1786 }
1787 const Standard_GUID& guid = DDataStd_DrawPresentation::GetID() ;
1788 //guid.ShallowDump(cout);
1789 Standard_SStream aSStream;
1790 guid.ShallowDump(aSStream);
1791 di << aSStream;
1792 return 0;
1793}
1794#endif
1795
1796//=======================================================================
1797//function : OCC708
1798//purpose :
1799//=======================================================================
1800static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1801{
1802 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1803 if(aContext.IsNull()) {
1804 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
1805 return 1;
1806 }
1807
1808 if ( argc != 2) {
1809 di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation" << "\n";
1810 return 1;
1811 }
1812
1813 Standard_Boolean updateviewer = Standard_True, PutInCollector = Standard_True;
1814
1815 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1816
1817 TCollection_AsciiString aName(argv[1]);
1818 Handle(AIS_InteractiveObject) AISObj;
1819
1820 if(!aMap.IsBound2(aName)) {
1821 di << "Use 'vdisplay' before" << "\n";
1822 return 1;
1823 } else {
1824 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
1825 if(AISObj.IsNull()){
1826 di << argv[1] << " : No interactive object" << "\n";
1827 return 1;
1828 }
1829 AISObj->UnsetTransformation();
1830 if (!aContext->HasOpenedContext()) {
1831 aContext->OpenLocalContext();
1832 }
1833 aContext->Erase(AISObj, updateviewer, PutInCollector);
1834 aContext->UpdateCurrentViewer();
1835 aContext->Display(AISObj, updateviewer);
1836 aContext->UpdateCurrentViewer();
1837 }
1838 return 0;
1839}
1840
1841//=======================================================================
1842//function : OCC670
1843//purpose :
1844//=======================================================================
1845#include <TColStd_Array2OfInteger.hxx>
1846static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1847{
1848 if(argc != 1){
1849 di<<"Usage : " << argv[0] << "\n";
1850 return -1;
1851 }
1852 TColStd_Array2OfInteger Array2OfInteger(1,1,1,1);
1853 Array2OfInteger.SetValue(5,5,55);
1854 return 0;
1855}
1856
1857#include <GeomAPI_ProjectPointOnSurf.hxx>
1858//=======================================================================
1859//function : OCC867
1860//purpose :
1861//=======================================================================
1862static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1863{
1864 if (argc!=7)
1865 {
1866 di<<"Usage : " << argv[0] << " Point Surface Umin Usup Vmin Vsup \n";
1867 return 1;
1868 }
1869
1870 gp_Pnt aPoint3d;
1871 DrawTrSurf::GetPoint(argv[1],aPoint3d);
1872 Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
1873 Standard_Real Umin=atof(argv[3]);
1874 Standard_Real Usup=atof(argv[4]);
1875 Standard_Real Vmin=atof(argv[5]);
1876 Standard_Real Vsup=atof(argv[6]);
1877
1878 if (aSurface.IsNull()) {
1879 di << argv[2] << " Null surface \n" ;
1880 return 1;
1881 }
1882
1883 GeomAPI_ProjectPointOnSurf PonSurf;
1884 PonSurf.Init(aSurface, Umin, Usup, Vmin, Vsup);
1885 PonSurf.Perform(aPoint3d);
1886
1887 return 0;
1888}
1889
1890//=======================================================================
1891//function : OCC909
1892//purpose :
1893//=======================================================================
1894static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1895{
1896 if (argc!=3)
1897 {
1898 di<<"Usage : " << argv[0] << " wire face\n";
1899 return 1;
1900 }
1901
1902 TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
1903 TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
1904 if (awire.IsNull() || aface.IsNull()) {
1905 di << "Null object" << "\n";
1906 return 1;
1907 }
1908
1909 Standard_Integer count = 0;
1910 TopExp_Explorer TE(awire, TopAbs_VERTEX);
1911 if ( TE.More()) {
1912 BRepTools_WireExplorer WE;
1913 for ( WE.Init(awire,aface); WE.More(); WE.Next()) {
1914 TopoDS_Edge E = WE.Current();
1915 count++;
1916 }
1917 }
1918 di << "Count = " << count << "\n";
1919
1920 return 0;
1921}
1922
1923//=======================================================================
1924//function : OCC921
1925//purpose :
1926//=======================================================================
1927static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1928{
1929 if (argc =! 2)
1930 {
1931 di <<"Usage : " << argv[0] << " face"<<"\n";
1932 return 1;
1933 }
1934 Standard_Real u1, u2, v1, v2;
1935 TopoDS_Face F = TopoDS::Face( DBRep::Get(argv[1]) ); //read the shape
1936 if (F.IsNull())
1937 return 1;
1938 BRepTools::UVBounds(F, u1, u2, v1, v2);
1939 di << "Bounds: " << u1 << " " << u2 << " " << v1 << " " << v2 << "\n";
1940 return 0;
1941}
1942
1943#include <Expr_NamedUnknown.hxx>
1944#include <Expr_GeneralExpression.hxx>
1945#include <Expr_Exponential.hxx>
1946//=======================================================================
1947//function : OCC902
1948//purpose :
1949//=======================================================================
1950static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1951{
1952 if (argc =! 2)
1953 {
1954 di <<"Usage : " << argv[0] << " expression"<<"\n";
1955 return 1;
1956 }
1957
1958 TCollection_AsciiString myStr(argv[1]);
1959
1960 Handle (Expr_NamedUnknown) myNamed = new Expr_NamedUnknown(myStr);
1961 Handle (Expr_Exponential) oldExpr = new Expr_Exponential(myNamed);
1962 Handle (Expr_GeneralExpression) newExpr = oldExpr->Derivative(myNamed);
1963
1964
1965 TCollection_AsciiString res = newExpr->String();
1966 Standard_CString resStr = res.ToCString();
1967 TCollection_AsciiString res_old = oldExpr->String();
1968 Standard_CString res_oldStr = res_old.ToCString();
1969
1970
1971 di << "X = " << argv[1] << "\n";
1972 di << "Y = " << res_oldStr << "\n";
1973 di << "Y' = " << resStr << "\n";
1974
1975 return 0;
1976}
1977
1978#include <DDF.hxx>
1979#include <TPrsStd_AISViewer.hxx>
1980#include <TDF_Label.hxx>
1981#include <TPrsStd_AISPresentation.hxx>
1982//=======================================================================
1983//function : OCC1029_AISTransparency
1984//purpose : OCC1029_AISTransparency (DOC,entry,[real])
1985//=======================================================================
1986
1987static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
1988 Standard_Integer nb,
1989 const char ** arg)
1990{
1991 if (nb >= 3 ) {
1992 Handle(TDocStd_Document) D;
1993 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1994 TDF_Label L;
1995 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1996
1997 Handle(TPrsStd_AISViewer) viewer;
1998 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1999
2000 Handle(TPrsStd_AISPresentation) prs;
2001 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2002 if( nb == 4 ) {
2003 prs->SetTransparency(atof(arg[3]));
2004 TPrsStd_AISViewer::Update(L);
2005 }
2006 else {
2007 di << "Transparency = " << prs->Transparency() << "\n";
2008 }
2009 return 0;
2010 }
2011 }
2012 di << arg[0] << " : Error" << "\n";
2013 return 1;
2014}
2015
2016//=======================================================================
2017//function : OCC1030_AISColor
2018//purpose : OCC1030_AISColor (DOC,entry,[color])
2019//=======================================================================
2020
2021static Standard_Integer OCC1030_AISColor (Draw_Interpretor& di,
2022 Standard_Integer nb,
2023 const char ** arg)
2024{
2025 if (nb >= 3) {
2026 Handle(TDocStd_Document) D;
2027 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2028 TDF_Label L;
2029 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2030
2031 Handle(TPrsStd_AISViewer) viewer;
2032 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2033
2034 Handle(TPrsStd_AISPresentation) prs;
2035 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2036 if( nb == 4 ) {
2037 prs->SetColor((Quantity_NameOfColor)atoi(arg[3]));
2038 TPrsStd_AISViewer::Update(L);
2039 }
2040 else
2041 di << "Color = " << prs->Color() << "\n";
2042 return 0;
2043 }
2044 }
2045 di << arg[0] << " : Error" << "\n";
2046 return 1;
2047}
2048
2049//=======================================================================
2050//function : OCC1031_AISMaterial
2051//purpose : OCC1031_AISMaterial (DOC,entry,[material])
2052//=======================================================================
2053
2054static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
2055 Standard_Integer nb,
2056 const char ** arg)
2057{
2058 if (nb >= 3) {
2059 Handle(TDocStd_Document) D;
2060 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2061 TDF_Label L;
2062 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2063
2064 Handle(TPrsStd_AISViewer) viewer;
2065 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2066
2067 Handle(TPrsStd_AISPresentation) prs;
2068 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2069 if( nb == 4 ) {
2070 prs->SetMaterial((Graphic3d_NameOfMaterial)atoi(arg[3]));
2071 TPrsStd_AISViewer::Update(L);
2072 }
2073 else {
2074 di << "Material = " << prs->Material() << "\n";
2075 }
2076 return 0;
2077 }
2078 }
2079 di << arg[0] << " : Error" << "\n";
2080 return 1;
2081}
2082
2083//=======================================================================
2084//function : OCC1032_AISWidth
2085//purpose : OCC1032_AISWidth (DOC,entry,[width])
2086//=======================================================================
2087
2088static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
2089 Standard_Integer nb,
2090 const char ** arg)
2091{
2092 if (nb >= 3) {
2093 Handle(TDocStd_Document) D;
2094 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2095 TDF_Label L;
2096 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2097
2098 Handle(TPrsStd_AISViewer) viewer;
2099 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2100
2101 Handle(TPrsStd_AISPresentation) prs;
2102 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2103 if( nb == 4 ) {
2104 prs->SetWidth(atof(arg[3]));
2105 TPrsStd_AISViewer::Update(L);
2106 }
2107 else {
2108 di << "Width = " << prs->Width() << "\n";
2109 }
2110 return 0;
2111 }
2112 }
2113 di << arg[0] << " : Error" << "\n";
2114 return 1;
2115}
2116
2117//=======================================================================
2118//function : OCC1033_AISMode
2119//purpose : OCC1033_AISMode (DOC,entry,[mode])
2120//=======================================================================
2121
2122static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
2123 Standard_Integer nb,
2124 const char ** arg)
2125{
2126 if (nb >= 3) {
2127 Handle(TDocStd_Document) D;
2128 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2129 TDF_Label L;
2130 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2131
2132 Handle(TPrsStd_AISViewer) viewer;
2133 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2134
2135 Handle(TPrsStd_AISPresentation) prs;
2136 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2137 if( nb == 4 ) {
2138 prs->SetMode(atoi(arg[3]));
2139 TPrsStd_AISViewer::Update(L);
2140 }
2141 else {
2142 di << "Mode = " << prs->Mode() << "\n";
2143 }
2144 return 0;
2145 }
2146 }
2147 di << arg[0] << " : Error" << "\n";
2148 return 1;
2149}
2150
2151//=======================================================================
2152//function : OCC1034_AISSelectionMode
2153//purpose : OCC1034_AISSelectionMode (DOC,entry,[selectionmode])
2154//=======================================================================
2155
2156static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
2157 Standard_Integer nb,
2158 const char ** arg)
2159{
2160 if (nb >= 3) {
2161 Handle(TDocStd_Document) D;
2162 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2163 TDF_Label L;
2164 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2165
2166 Handle(TPrsStd_AISViewer) viewer;
2167 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2168
2169 Handle(TPrsStd_AISPresentation) prs;
2170 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2171 if( nb == 4 ) {
2172 prs->SetSelectionMode(atoi(arg[3]));
2173 TPrsStd_AISViewer::Update(L);
2174 }
2175 else {
2176 di << "SelectionMode = " << prs->SelectionMode() << "\n";
2177 }
2178 return 0;
2179 }
2180 }
2181 di << arg[0] << " : Error" << "\n";
2182 return 1;
2183}
2184
2185#include<BRepAlgoAPI_Cut.hxx>
2186#include<BRepAlgo_Cut.hxx>
2187//=======================================================================
2188//function : OCC1487
2189//purpose :
2190//=======================================================================
2191static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2192{
2193 //if(argc != 5) {
2194 // cerr << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape" << endl;
2195 // return -1;
2196 //}
2197 if(argc < 5 || argc > 6) {
2198 di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2199 return 1;
2200 }
2201 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2202 if (argc == 6) {
2203 Standard_Integer IsB = atoi(argv[5]);
2204 if (IsB != 1) {
2205 IsBRepAlgoAPI = Standard_False;
2206// di << "Error: There is not BRepAlgo_Cut class" << "\n";
2207// return 1;
2208 }
2209 }
2210
2211 Standard_Integer CaseNumber = atoi(argv[1]);
2212
2213 //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
2214 gp_Dir myDir(1,0,0);
2215 gp_Pnt myPnt(0,-50,140);
2216 gp_Ax2 myAx2(myPnt, myDir);
2217 BRepPrimAPI_MakeCylinder o_mc1 (myAx2, 50,1000);
2218
2219 TopoDS_Shape cyl1 = o_mc1.Shape();
2220
2221 TopoDS_Shape cyl2;
2222 TopoDS_Shape o_cut_shape;
2223 if (CaseNumber == 1) {
2224 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(21.65064, -50.0, 127.5),gp_Dir(-sin(PI/3), 0.0, 0.5)), 5, 150);
2225 gp_Dir myDir_mc2(-sin(PI/3), 0.0, 0.5);
2226 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2227 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2228 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2229
2230 cyl2 = o_mc2.Shape();
2231//#if ! defined(BRepAlgoAPI_def01)
2232// o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2233//#else
2234// o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2235//#endif
2236 if (IsBRepAlgoAPI) {
2237 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2238 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2239 } else {
2240 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2241 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2242 }
2243 } else {
2244 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(978.34936, -50.0, 127.5),gp_Dir(sin(PI/3), 0.0, 0.5)), 5, 150);
2245 gp_Dir myDir_mc2(-sin(PI/3), 0.0, 0.5);
2246 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2247 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2248 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2249
2250 cyl2 = o_mc2.Shape();
2251//#if ! defined(BRepAlgoAPI_def01)
2252// o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2253//#else
2254// o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2255//#endif
2256 if (IsBRepAlgoAPI) {
2257 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2258 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2259 } else {
2260 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2261 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2262 }
2263 }
2264
2265 DBRep::Set(argv[2],cyl1);
2266 DBRep::Set(argv[3],cyl2);
2267 DBRep::Set(argv[4],o_cut_shape);
2268
2269 return 0;
2270}
2271
2272#include<TopTools_ListIteratorOfListOfShape.hxx>
2273#include<BRepFilletAPI_MakeFillet.hxx>
2274//=======================================================================
2275//function : OCC1077
2276//purpose :
2277//=======================================================================
2278TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
2279{
2280 Standard_Real t3d = 1.e-4;
2281 Standard_Real t2d = 1.e-5;
2282 Standard_Real ta = 1.e-2;
2283 Standard_Real fl = 1.e-3;
2284 Standard_Real tapp_angle = 1.e-2;
2285 GeomAbs_Shape blend_cont = GeomAbs_C1;
2286
2287 TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
2288
2289//#ifdef OCC40
2290// Handle_TopOpeBRepBuild_HBuilder build = aBoolenaOperation.Builder();
2291//#endif
2292 TopTools_ListIteratorOfListOfShape its;
2293
2294 TopoDS_Compound result;
2295 BRep_Builder B;
2296 B.MakeCompound(result);
2297
2298 TopExp_Explorer ex;
2299 for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
2300 {
2301 const TopoDS_Shape& cutsol = ex.Current();
2302
2303 BRepFilletAPI_MakeFillet fill(cutsol);
2304 fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
2305 fill.SetContinuity(blend_cont, tapp_angle);
2306//#ifdef OCC40
2307// its = build->Section();
2308//#else //OCC40DEV
2309 its = aBoolenaOperation.SectionEdges();
2310//#endif
2311 while (its.More())
2312 {
2313 TopoDS_Edge E = TopoDS::Edge(its.Value());
2314 fill.Add(aRadius, E);
2315 its.Next();
2316 }
2317
2318 fill.Build();
2319 if (fill.IsDone())
2320 {
2321 B.Add(result, fill.Shape());
2322 }
2323 else
2324 {
2325 B.Add(result, cutsol);
2326 }
2327 }
2328 return result;
2329}
2330
2331TopoDS_Shape OCC1077_cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
2332{
2333 //return OCC1077_boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
2334 BRepAlgoAPI_Cut aCut(aShapeToCut, aTool);
2335 return OCC1077_boolbl(aCut,aRadius);
2336}
2337
2338//TopoDS_Shape OCC1077_common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
2339//{
2340// return OCC1077_boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
2341//}
2342
2343TopoDS_Shape OCC1077_Bug()
2344{
2345 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10).Shape();
2346 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7).Shape();
2347
2348 TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
2349 TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10),
2350 gp_Dir(0, 0, 1)), 3, 20).Shape();
2351 TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0),
2352 gp_Dir(1, 0, 0)), 3, 20).Shape();
2353 TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
2354 gp_Dir(0, 1, 0)), 3, 20).Shape();
2355 TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
2356 Handle_ShapeFix_Shape fixer = new ShapeFix_Shape(theTmp1);
2357 fixer->Perform();
2358 theTmp1 = fixer->Shape();
2359 TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
2360 fixer->Init(theTmp2);
2361 fixer->Perform();
2362 theTmp2 = fixer->Shape();
2363 TopoDS_Shape theResult = OCC1077_cut_blend(theTmp2,theCylinder3,0.7);
2364 fixer->Init(theResult);
2365 fixer->Perform();
2366 theResult = fixer->Shape();
2367 return theResult;
2368}
2369
2370static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2371{
2372 if(argc < 1 || argc > 2) {
2373 di << "Usage : " << argv[0] << " result" << "\n";
2374 return 1;
2375 }
2376
2377 TopoDS_Shape S = OCC1077_Bug();
2378 DBRep::Set(argv[1],S);
2379
2380 return 0;
2381}
2382
2383//////////////////////////////////////////////////////////////
2384/*!
2385 * Compute uniform distribution of points using GCPnts_UniformAbscissa
2386 */
2387//////////////////////////////////////////////////////////////
2388static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2389{
2390 if (argc < 4)
2391 {
2392 di << "Usage : " << argv[0] << " name shape step" << "\n";
2393 return 1;
2394 }
2395 const char *name = argv[1];
2396 Adaptor3d_Curve *adapCurve=NULL;
2397 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
2398 if (!curve.IsNull())
2399 adapCurve = new GeomAdaptor_Curve(curve);
2400 else
2401 {
2402 TopoDS_Shape wire = DBRep::Get(argv[2]);
2403 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
2404 {
2405 di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected"<<"\n";
2406 return 1;
2407 }
2408 adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
2409 }
2410 double step = atof(argv[3]);
2411 GCPnts_UniformAbscissa aUni(*adapCurve, step);
2412 int res;
2413 if (!aUni.IsDone())
2414 {
2415 di << argv[0] <<" : fail"<<"\n";
2416 res = 1;
2417 }
2418 else
2419 {
2420 int i, np = aUni.NbPoints();
2421 for (i=0; i < np; i++)
2422 {
2423 double par = aUni.Parameter(i+1);
2424 gp_Pnt p = adapCurve->Value(par);
2425 char n[20], *pname=n;
2426 sprintf(n,"%s_%d",name,i+1);
2427 DrawTrSurf::Set(pname,p);
2428 di<<pname<<" ";
2429 }
2430 res = 0;
2431 }
2432 delete adapCurve;
2433 return res;
2434}
2435
2436static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2437{
2438 if (argc != 3)
2439 {
2440 di << "Usage : " << argv[0] << " nb_of_vectors size" << "\n";
2441 return 1;
2442 }
2443
2444 Standard_Integer nb = atoi(argv[1]);
2445 Standard_Integer sz = atoi(argv[2]);
2446 Standard_Real val = 10;
2447 math_Vector **pv = new math_Vector *[nb];
2448
2449 di<<"creating "<<nb<<" vectors "<<sz<<" elements each..."<<"\n";
2450 Standard_Integer i;
2451 for (i=0; i < nb; i++) {
2452 pv[i] = new math_Vector (1, sz, val);
2453 if ((i % (nb/10)) == 0) {
2454 di<<" "<<i;
2455 //cout.flush();
2456 di<<"\n";
2457 }
2458 }
2459 di<<" done"<<"\n";
2460 di<<"deleting them ..."<<"\n";
2461 for (i=0; i < nb; i++) {
2462 delete pv[i];
2463 if ((i % (nb/10)) == 0) {
2464 di<<" "<<i;
2465 //cout.flush();
2466 di<<"\n";
2467 }
2468 }
2469 di<<" done"<<"\n";
2470
2471 delete [] pv;
2472
2473 return 0;
2474}
2475
2476static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2477{
2478 if (argc != 2)
2479 {
2480 di << "Usage : " << argv[0] << " wire" << "\n";
2481 return 1;
2482 }
2483 TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
2484 if (shape.IsNull())
2485 return 1;
2486 TopoDS_Wire wire = TopoDS::Wire(shape);
2487 // create curve parameterised by curvilinear distance
2488 BRepAdaptor_CompCurve curve(wire,Standard_True);
2489 Standard_Real length = curve.LastParameter();
2490 Standard_Real need_length = length/2;
2491 gp_Pnt pnt;
2492 curve.D0(need_length,pnt);
2493 // create check_curve parameterised in a general way
2494 BRepAdaptor_CompCurve check_curve(wire);
2495 Standard_Real check_par =
2496 GCPnts_AbscissaPoint(check_curve, need_length, 0).Parameter();
2497 gp_Pnt check_pnt;
2498 check_curve.D0(check_par,check_pnt);
2499 // check that points are coinsiding
2500 Standard_Real error_dist = pnt.Distance(check_pnt);
2501 if (error_dist > Precision::Confusion()) {
2502 //cout.precision(3);
2503 di<<"error_dist = "<<error_dist<<
2504 " ( "<<error_dist/need_length*100<<" %)"<<"\n";
2505 return 0;
2506 }
2507 di<<"OK"<<"\n";
2508 return 0;
2509}
2510
2511static char sarr[2000];
2512static int si=1;
2513static int StackOverflow(int i = -1)
2514{
2515 char arr[2000];
2516 if (si == 1) {
2517 si = 0;
2518 memcpy(arr,sarr,2000);
2519 arr[1999]=0;
2520 int n = strlen(arr), s=0;
2521 while (n--)
2522 s += StackOverflow(i-1);
2523 return i + s + StackOverflow(i-1);
2524 }
2525 else if (i != 0) {
2526 return i + StackOverflow(i-1);
2527 }
2528 si = 1;
2529 return i;
2530}
2531
2532#ifdef WNT
2533// this code does not work with optimize mode on Windows
2534#pragma optimize( "", off )
2535#endif
2536static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2537{
2538 if (argc != 1)
2539 {
2540 di << "Usage : " << argv[0] << "\n";
2541 return 1;
2542 }
2543 Standard_Boolean Succes;
2544
2545 Succes = Standard_True;
2546 //OSD::SetSignal();
2547
2548 {//==== Test Divide ByZero (Integer) ========================================
2549 try{
2550 OCC_CATCH_SIGNALS
2551 di << "(Integer) Divide By Zero...";
2552 //cout.flush();
2553 di << "\n";
2554 Standard_Integer res, a =4, b = 0 ;
2555 res = a / b;
2556 di << " 4 / 0 = " << res << " Does not Caught... KO"<< "\n";
2557 Succes = Standard_False;
2558 }
2559#if defined(SOLARIS) || defined(WNT)
2560 catch(Standard_DivideByZero)
2561#else
2562 catch(Standard_NumericError)
2563#endif
2564 {
2565 di << " Ok"<< "\n";
2566 }
2567 catch(Standard_Failure) {
2568 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2569 di << " Caught (";
2570 di << Standard_Failure::Caught()->GetMessageString();
2571 di << ")... KO" << "\n";
2572 Succes = Standard_False;
2573 }
2574#ifndef NO_CXX_EXCEPTION
2575 // this case tests if (...) supersedes (Standard_*),
2576 // the normal behaviour is not
2577 catch(...) {
2578 di<<" unknown exception... (But) Ok"<<"\n";
2579 }
2580#endif
2581 }
2582
2583 {//==== Test Divide ByZero (Real) ===========================================
2584 try{
2585 OCC_CATCH_SIGNALS
2586 di << "(Real) Divide By Zero...";
2587 //cout.flush();
2588 di << "\n";
2589 Standard_Real res, a= 4.0, b=0.0;
2590 res = a / b;
2591 di << " 4.0 / 0.0 = " << res << " Does not Caught... KO"<< "\n";
2592 Succes = Standard_False;
2593 }
2594#if defined(SOLARIS) || defined(WNT)
2595 catch(Standard_DivideByZero)
2596#else
2597 catch(Standard_NumericError)
2598#endif
2599 {
2600 di << " Ok"<< "\n";
2601 }
2602 catch(Standard_Failure) {
2603 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2604 di << " Caught (";
2605 di << Standard_Failure::Caught()->GetMessageString();
2606 di << ")... KO" << "\n";
2607 Succes = Standard_False;
2608 }
2609 }
2610
2611 {//==== Test Overflow (Integer) =============================================
2612 try{
2613 OCC_CATCH_SIGNALS
2614 di << "(Integer) Overflow...";
2615 //cout.flush();
2616 di << "\n";
2617 Standard_Integer res, i=IntegerLast();
2618 res = i + 1;
2619 //++++ cout << " -- "<<res<<"="<<i<<"+1 Does not Caught... KO"<< endl;
2620 //++++ Succes = Standard_False;
2621 di << " "<<res<<"="<<i<<"+1 Does not Caught... (But) Ok"<< "\n";
2622 }
2623 catch(Standard_Overflow) {
2624 di << " Ok"<< "\n";
2625 }
2626 catch(Standard_Failure) {
2627 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2628 di << " Caught (";
2629 di << Standard_Failure::Caught()->GetMessageString();
2630 di << ")... KO" << "\n";
2631 Succes = Standard_False;
2632 }
2633 }
2634
2635 {//==== Test Overflow (Real) ================================================
2636 try{
2637 OCC_CATCH_SIGNALS
2638 di << "(Real) Overflow...";
2639 //cout.flush();
2640 di << "\n";
2641 Standard_Real res, r=RealLast();
2642 res = r * r;
2643
2644 sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
2645
2646 di << "-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<< "\n";
2647 Succes = Standard_False;
2648 }
2649#if defined(SOLARIS) || defined(WNT)
2650 catch(Standard_Overflow)
2651#else
2652 catch(Standard_NumericError)
2653#endif
2654 {
2655 di << " Ok"<< "\n";
2656 }
2657 catch(Standard_Failure) {
2658 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2659 di << " Caught (";
2660 di << Standard_Failure::Caught()->GetMessageString();
2661 di << ")... KO" << "\n";
2662 Succes = Standard_False;
2663 }
2664 }
2665
2666 {//==== Test Underflow (Real) ===============================================
2667 try{
2668 OCC_CATCH_SIGNALS
2669 di << "(Real) Underflow";
2670 //cout.flush();
2671 di << "\n";
2672 Standard_Real res, r=1.0e-308;
2673 res = r * r;
2674 //res = res + 1.;
2675 //++++ cout<<"-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<<endl;
2676 //++++ Succes = Standard_False;
2677 di<<" -- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... (But) Ok"<<"\n";
2678 }
2679#if defined(SOLARIS) || defined(WNT)
2680 catch(Standard_Underflow)
2681#else
2682 catch(Standard_NumericError)
2683#endif
2684 {
2685 di << " Ok"<< "\n";
2686 }
2687 catch(Standard_Failure) {
2688 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2689 di << " Caught (";
2690 di << Standard_Failure::Caught()->GetMessageString();
2691 di << ")... KO" << "\n";
2692 Succes = Standard_False;
2693 }
2694 }
2695
2696 {//==== Test Invalid Operation (Real) ===============================================
2697 try{
2698 OCC_CATCH_SIGNALS
2699 di << "(Real) Invalid Operation...";
2700 //cout.flush();
2701 di << "\n";
2702 Standard_Real res, r=-1;
2703 res = sqrt(r);
2704 di<<" "<<res<<"=sqrt("<<r<<") Does not Caught... KO"<<"\n";
2705 Succes = Standard_False;
2706 }
2707 catch(Standard_NumericError) {
2708 di << " Ok"<< "\n";
2709 }
2710 catch(Standard_Failure) {
2711 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2712 di << " Caught (";
2713 di << Standard_Failure::Caught()->GetMessageString();
2714 di << ")... KO" << "\n";
2715 Succes = Standard_False;
2716 }
2717 }
2718
2719 {//==== Test Access Violation ===============================================
2720 try {
2721 OCC_CATCH_SIGNALS
2722 di << "Segmentation Fault...";
2723 //cout.flush();
2724 di << "\n";
2725 int* pint=NULL;
2726 *pint = 4;
2727 di << " Does not Caught... KO"<<"\n";
2728 Succes = Standard_False;
2729 }
2730#ifdef WNT
2731 catch(OSD_Exception_ACCESS_VIOLATION)
2732#else
2733 catch(OSD_SIGSEGV)
2734#endif
2735 {
2736 di << " Ok"<< "\n";
2737 } catch(Standard_Failure) {
2738 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2739 di << " Caught (";
2740 di << Standard_Failure::Caught()->GetMessageString();
2741 di << ")... KO" << "\n";
2742 Succes = Standard_False;
2743 }
2744 }
2745
2746#ifdef WNT
2747 {//==== Test Stack Overflow ===============================================
2748 try {
2749 OCC_CATCH_SIGNALS
2750 di << "Stack Overflow...";
2751 //cout.flush();
2752 di << "\n";
2753 StackOverflow();
2754 di << " Does not Caught... KO"<<"\n";
2755 Succes = Standard_False;
2756 }
2757 catch(OSD_Exception_STACK_OVERFLOW) {
2758 di << " Ok"<< "\n";
2759 }
2760 catch(Standard_Failure) {
2761 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2762 di << " Caught (";
2763 di << Standard_Failure::Caught()->GetMessageString();
2764 di << ")... KO" << "\n";
2765 Succes = Standard_False;
2766 }
2767 }
2768#endif
2769
2770 if(Succes) {
2771 di << "TestExcept: Successfull completion" << "\n";
2772 } else {
2773 di << "TestExcept: failure" << "\n";
2774 }
2775
2776 return 0;
2777}
2778#ifdef WNT
2779#pragma optimize( "", on )
2780#endif
2781
2782static TopoDS_Compound AddTestStructure(int nCount_)
2783{
2784 BRep_Builder B;
2785 int nCount=nCount_;
2786 TopoDS_Compound C;
2787 B.MakeCompound(C);
2788 BRepPrimAPI_MakeBox mkBox(1.0, 2.0, 3.0);
2789 for (int i=0; i<nCount; i++) {
2790 for (int j=0; j<nCount; j++) {
2791 gp_Trsf trsf;
2792 trsf.SetTranslationPart(gp_Vec(5.0*i, 05.0*j, 0.0));
2793 TopLoc_Location topLoc(trsf);
2794 TopoDS_Shape tempShape=mkBox.Shape().Located(topLoc);
2795 B.Add(C, tempShape);
2796 }
2797 }
2798 return C;
2799}
2800
2801static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2802{
2803 int nCount = 10;
2804
2805 if (argc > 2)
2806 {
2807 di << "Usage : " << argv[0] << " [nCount]" << "\n";
2808 return 1;
2809 }
2810
2811 if (argc > 1)
2812 nCount = atoi(argv[1]);
2813 STEPCAFControl_Writer writer;
2814 Handle_TDocStd_Document document;
2815 document = new TDocStd_Document("Pace Test-StepExporter-");
2816 Handle_XCAFDoc_ShapeTool shapeTool;
2817 shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
2818 shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
2819 STEPControl_StepModelType mode = STEPControl_AsIs;
2820 if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
2821 di << "Failed to set assembly mode for step data\n" << "\n";
2822 return 0;
2823 }
2824 try {
2825 OCC_CATCH_SIGNALS
2826 if( writer.Transfer(document, mode)) {
2827 IFSelect_ReturnStatus stat =
2828 writer.Write("TestExportStructure.step");
2829 }
2830 }
2831 catch(OSD_Exception_STACK_OVERFLOW) {
2832 di << "Failed : STACK OVERFLOW\n" << "\n";
2833 }
2834 catch (Standard_Failure) {
2835 di << "Failed :\n" << "\n";
2836 //cout << Standard_Failure::Caught() << endl;
2837 di << Standard_Failure::Caught()->GetMessageString();
2838 }
2839 di << argv[0] << " : Finish" << "\n";
2840
2841 return 0;
2842}
2843
2844static Standard_Integer OCC7372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2845{
2846 if (argc != 1)
2847 {
2848 di << "Usage : " << argv[0] << "\n";
2849 return 1;
2850 }
2851
2852 // 1. Create an array of points
2853 Handle(TColgp_HArray1OfPnt2d) ap = new TColgp_HArray1OfPnt2d(1,5);
2854 ap->SetValue(1,gp_Pnt2d(100.0,0.0));
2855 ap->SetValue(2,gp_Pnt2d(100.0,100.0));
2856 ap->SetValue(3,gp_Pnt2d(0.0,100.0));
2857 ap->SetValue(4,gp_Pnt2d(0.0,0.0));
2858 ap->SetValue(5,gp_Pnt2d(50.0,-50.0));
2859
2860 // 2. Create a periodic bspline through these 5 points
2861 Geom2dAPI_Interpolate intp(ap,Standard_True,1e-6);
2862 intp.Perform();
2863 Handle(Geom2d_BSplineCurve) bspline1 = intp.Curve();
2864
2865 // 3. Increase degree of curve from 3 to 8
2866 bspline1->IncreaseDegree(8); // Increase degree to demonstrate the error
2867 Standard_CString CString1 = "BSplineCurve";
2868 DrawTrSurf::Set(CString1,bspline1);
2869
2870 // 4. Convers BSpline curve to Bezier segments
2871 Geom2dConvert_BSplineCurveToBezierCurve bc(bspline1);
2872
2873 // 5. Test the result of conversion
2874 TCollection_AsciiString aRName;
2875 for(Standard_Integer i = 1; i <= bc.NbArcs(); i++) {
2876 Handle(Geom2d_BezierCurve) arc = bc.Arc(i);
2877 aRName="segment_";
2878 aRName=aRName+TCollection_AsciiString(i);
2879 Standard_CString aRNameStr = aRName.ToCString();
2880 DrawTrSurf::Set(aRNameStr,arc);
2881 di << aRNameStr << " ";
2882 }
2883
2884 return 0;
2885}
2886
2887static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2888{
2889 if (argc != 4)
2890 {
2891 di << "Usage : " << argv[0] << " edge1 edge2 plane" << "\n";
2892 return 1;
2893 }
2894 TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
2895 if (theEdge1.IsNull()) {
2896 di << "Invalid input shape " << argv[1] << "\n";
2897 return 1;
2898 }
2899 TopoDS_Edge theEdge2 = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
2900 if (theEdge2.IsNull()) {
2901 di << "Invalid input shape " << argv[2] << "\n";
2902 return 1;
2903 }
2904 TopoDS_Face theFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
2905 if (theFace.IsNull()) {
2906 di << "Invalid input shape " << argv[3] << "\n";
2907 return 1;
2908 }
2909
2910 Handle(Geom_Surface) thePlane = BRep_Tool::Surface(theFace);
2911
2912 Standard_Real aConfusion = Precision::Confusion();
2913 Standard_Real aP1first, aP1last, aP2first, aP2last;
2914
2915 Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(theEdge1, aP1first, aP1last);
2916 Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(theEdge2, aP2first, aP2last);
2917 Handle(Geom2d_Curve) aCurve2d1 = GeomProjLib::Curve2d(aCurve1, aP1first, aP1last, thePlane);
2918 Handle(Geom2d_Curve) aCurve2d2 = GeomProjLib::Curve2d(aCurve2, aP2first, aP2last, thePlane);
2919
2920 Geom2dAPI_InterCurveCurve anInter(aCurve2d1, aCurve2d2, aConfusion);
2921
2922 Standard_Integer NbPoints = anInter.NbPoints();
2923
2924 di << "NbPoints = " << NbPoints << "\n" ;
2925
2926 if (NbPoints > 0) {
2927 Standard_Integer i;
2928 for (i=1; i<=NbPoints; i++) {
2929 gp_Pnt2d aPi = anInter.Point(i);
2930 di << "Point.X(" << i << ") = " << aPi.X() << " " << "Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
2931 }
2932 }
2933
2934 Standard_Integer NbSegments = anInter.NbSegments();
2935
2936 di << "\nNbSegments = " << NbSegments << "\n" ;
2937
2938 if (NbSegments > 0) {
2939 IntRes2d_IntersectionSegment aSegment = anInter.Intersector().Segment(1);
2940
2941 gp_Pnt2d aP1 = aCurve2d1->Value(aSegment.FirstPoint().ParamOnFirst());
2942 gp_Pnt2d aP2 = aCurve2d2->Value(aSegment.FirstPoint().ParamOnSecond());
2943
2944 Standard_Real aDist = aP1.Distance(aP2);
2945
2946 di << "aP1.X() = " << aP1.X() << " " << "aP1.Y() = " << aP1.Y() << "\n" ;
2947 di << "aP2.X() = " << aP2.X() << " " << "aP2.Y() = " << aP2.Y() << "\n" ;
2948
2949 di << "Distance = " << aDist << "\n" ;
2950
2951 di << "Confusion = " << aConfusion << "\n" ;
2952
2953 if (aDist > aConfusion) {
2954 di << "\n" << argv[0] << " Faulty" << "\n" ;
2955 } else {
2956 di << "\n" << argv[0] << " OK" << "\n" ;
2957 }
2958 } else {
2959 di << "\n" << argv[0] << " OK" << "\n" ;
2960 }
2961
2962 return 0;
2963}
2964static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2965{
2966 if (argc != 3)
2967 {
2968 di << "Usage : " << argv[0] << " lower upper" << "\n";
2969 return 1;
2970 }
2971
2972 Standard_Integer LOWER = atoi(argv[1]);
2973 Standard_Integer UPPER = atoi(argv[2]);
2974
2975 //! 0. Create an empty document with several test labels
2976 Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
2977 doc->SetUndoLimit(100);
2978 TDF_Label main_label = doc->Main();
2979 TDF_Label label1 = main_label.FindChild(1, Standard_True);
2980 TDF_Label label2 = main_label.FindChild(2, Standard_True);
2981
2982 //! 1. Set/Get OCAF attribute
2983 doc->OpenCommand();
2984 TDataStd_RealArray::Set(label1, LOWER, UPPER);
2985 Handle(TDataStd_RealArray) array;
2986 if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) &&
2987 array->Lower() == LOWER && array->Upper() == UPPER)
2988 cout<<"1: OK"<<endl;
2989 else
2990 {
2991 cout<<"1: Failed.."<<endl;
2992 return 1;
2993 }
2994 doc->CommitCommand();
2995
2996 //! 2. Set/Get value
2997 doc->OpenCommand();
2998 Standard_Integer i;
2999 for (i = LOWER; i <= UPPER; i++)
3000 array->SetValue(i, i);
3001 for (i = LOWER; i <= UPPER; i++)
3002 {
3003 if (array->Value(i) != i)
3004 {
3005 cout<<"2: Failed.."<<endl;
3006 return 2;
3007 }
3008 }
3009 cout<<"2: OK"<<endl;
3010 doc->CommitCommand();
3011
3012 //! 3. Re-init the array
3013 doc->OpenCommand();
3014 array->Init(LOWER + 2, UPPER + 4);
3015 if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4)
3016 {
3017 cout<<"3: Failed.."<<endl;
3018 return 3;
3019 }
3020 for (i = LOWER + 2; i <= UPPER + 4; i++)
3021 array->SetValue(i, i);
3022 for (i = LOWER + 2; i <= UPPER + 4; i++)
3023 {
3024 if (array->Value(i) != i)
3025 {
3026 cout<<"3: Failed.."<<endl;
3027 return 3;
3028 }
3029 }
3030 cout<<"3: OK"<<endl;
3031 doc->CommitCommand();
3032
3033 //! 4. Change array
3034 doc->OpenCommand();
3035 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(LOWER + 5, UPPER + 5);
3036 for (i = LOWER + 5; i <= UPPER + 5; i++)
3037 arr->SetValue(i, i);
3038 array->ChangeArray(arr);
3039 for (i = LOWER + 5; i <= UPPER + 5; i++)
3040 {
3041 if (array->Value(i) != i)
3042 {
3043 cout<<"4: Failed.."<<endl;
3044 return 4;
3045 }
3046 }
3047 cout<<"4: OK"<<endl;
3048 doc->CommitCommand();
3049
3050 //! 5. Copy the array
3051 doc->OpenCommand();
3052 TDF_CopyLabel copier(label1, label2);
3053 copier.Perform();
3054 if (!copier.IsDone())
3055 {
3056 cout<<"5: Failed.."<<endl;
3057 return 5;
3058 }
3059 Handle(TDataStd_RealArray) array2;
3060 if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
3061 {
3062 cout<<"5: Failed.."<<endl;
3063 return 5;
3064 }
3065 for (i = LOWER + 5; i <= UPPER + 5; i++)
3066 {
3067 if (array->Value(i) != i)
3068 {
3069 cout<<"5: Failed.."<<endl;
3070 return 5;
3071 }
3072 }
3073 cout<<"5: OK"<<endl;
3074 doc->CommitCommand();
3075
3076 //! 6. Undo/Redo
3077 //! 6.a: undoes the 5th action: the copied array should disappear
3078 doc->Undo();
3079 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3080 label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
3081 {
3082 cout<<"6.a: Failed.."<<endl;
3083 return 6;
3084 }
3085 //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4)
3086 doc->Undo();
3087 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3088 array->Lower() != LOWER + 2 ||
3089 array->Upper() != UPPER + 4)
3090 {
3091 cout<<"6.b: Failed.."<<endl;
3092 return 6;
3093 }
3094 for (i = LOWER + 2; i <= UPPER + 4; i++)
3095 {
3096 if (array->Value(i) != i)
3097 {
3098 cout<<"6.b: Failed.."<<endl;
3099 return 6;
3100 }
3101 }
3102 //! 6.c: undoes the 3d action: the array should be changed to (lower,upper)
3103 doc->Undo();
3104 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3105 array->Lower() != LOWER ||
3106 array->Upper() != UPPER)
3107 {
3108 cout<<"6.c: Failed.."<<endl;
3109 return 6;
3110 }
3111 for (i = LOWER; i <= UPPER; i++)
3112 {
3113 if (array->Value(i) != i)
3114 {
3115 cout<<"6.c: Failed.."<<endl;
3116 return 6;
3117 }
3118 }
3119 //! 6.d: undoes and redoes the 2nd action: no change is expected.
3120 doc->Undo();
3121 doc->Redo();
3122 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3123 array->Lower() != LOWER ||
3124 array->Upper() != UPPER)
3125 {
3126 cout<<"6.d: Failed.."<<endl;
3127 return 6;
3128 }
3129 for (i = LOWER; i <= UPPER; i++)
3130 {
3131 if (array->Value(i) != i)
3132 {
3133 cout<<"6.d: Failed.."<<endl;
3134 return 6;
3135 }
3136 }
3137 cout<<"6: OK"<<endl;
3138
3139 //! 7. Re-set the array
3140 doc->OpenCommand();
3141 array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1);
3142 if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1)
3143 {
3144 cout<<"7: Failed.."<<endl;
3145 return 7;
3146 }
3147 for (i = LOWER + 1; i <= UPPER + 1; i++)
3148 array->SetValue(i, i);
3149 for (i = LOWER + 1; i <= UPPER + 1; i++)
3150 {
3151 if (array->Value(i) != i)
3152 {
3153 cout<<"7: Failed.."<<endl;
3154 return 7;
3155 }
3156 }
3157 cout<<"7: OK"<<endl;
3158 doc->CommitCommand();
3159
3160 //! 8.Test of speed: set LOWER and UPPER equal to great integer number and
3161 //! measure the time spent by this test.
3162 //! Good luck!
3163
3164 return 0;
3165}
3166
3167static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3168{
3169 Standard_Boolean IsEvenArgc = Standard_True;
3170 if (argc % 2 == 0) {
3171 IsEvenArgc = Standard_True;
3172 } else {
3173 IsEvenArgc = Standard_False;
3174 }
3175
3176 if (argc < 3 || IsEvenArgc)
3177 {
3178 di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]" << "\n";
3179 return 1;
3180 }
3181
3182 Standard_Integer i, aValue, aPosition;
3183 NCollection_Vector<int> vec;
3184 for (i = 0; i < argc - 1; i++) {
3185 i++;
3186 aValue = atoi(argv[i]);
3187 aPosition = atoi(argv[i+1]);
3188 vec.SetValue(aValue, aPosition);
3189 }
3190 NCollection_Vector<int>::Iterator it(vec);
3191 Standard_Integer j;
3192 for (j = 0; it.More(); it.Next(), j++) {
3193 //di << it.Value() << "\n";
3194 di << j << " " << it.Value() << "\n";
3195 }
3196
3197 return 0;
3198}
3199
3200static Standard_Integer OCC8797 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3201{
3202 if (argc != 1) {
3203 di << "Usage : " << argv[0] << "\n";
3204 return 1;
3205 }
3206
3207 gp_Pnt point(0.0,0.0,0.0);
3208
3209 TColgp_Array1OfPnt poles(0,6);
3210 poles(0)=point;
3211
3212 point.SetCoord(1.0,1.0,0.0);
3213 poles(1)=point;
3214
3215 point.SetCoord(2.0,1.0,0.0);
3216 poles(2)=point;
3217
3218 point.SetCoord(3.0,0.0,0.0);
3219 poles(3)=point;
3220
3221 point.SetCoord(4.0,1.0,0.0);
3222 poles(4)=point;
3223
3224 point.SetCoord(5.0,1.0,0.0);
3225 poles(5)=point;
3226
3227 point.SetCoord(6.0,0.0,0.0);
3228 poles(6)=point;
3229
3230 TColStd_Array1OfReal knots(0,2);
3231 knots(0)=0.0;
3232 knots(1)=0.5;
3233 knots(2)=1.0;
3234
3235 TColStd_Array1OfInteger multi(0,2);
3236 multi(0)=4;
3237 multi(1)=3;
3238 multi(2)=4;
3239
3240 Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles,knots,multi,3);
3241
3242 //length!! 1.
3243 Standard_Real l_abcissa,l_gprop;
3244 GeomAdaptor_Curve adaptor_spline(spline);
3245 GCPnts_AbscissaPoint temp;
3246 l_abcissa=temp.Length(adaptor_spline);
3247 cout<<"Length Spline(abcissa_Pnt): "<<l_abcissa<<endl;
3248
3249 //length!! 2.
3250 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge (spline);
3251 GProp_GProps prop;
3252 BRepGProp::LinearProperties(edge,prop);
3253 l_gprop=prop.Mass();
3254 cout<<"Length Spline(GProp_GProps): "<<l_gprop<<endl;
3255
3256 cout<<"Difference (abcissa_Pnt<->GProp_GProps): "<<l_gprop-l_abcissa<<endl;
3257
3258 return 0;
3259}
3260
3261static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3262{
3263 if (argc != 1)
3264 {
3265 di << "Usage : " << argv[0] << "\n";
3266 return 1;
3267 }
3268
3269 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
3270 if(AISContext.IsNull())
3271 {
3272 di << "use 'vinit' command before " << argv[0] << "\n";
3273 return 1;
3274 }
3275
3276 // ObjectsInside
3277 AIS_ListOfInteractive ListOfIO_1;
3278 AISContext->ObjectsInside(ListOfIO_1);
3279 di<< "ObjectsInside = " << ListOfIO_1.Extent() <<"\n";
3280 if (!ListOfIO_1.IsEmpty() ) {
3281 AIS_ListIteratorOfListOfInteractive iter;
3282 for (iter.Initialize(ListOfIO_1); iter.More() ; iter.Next() ) {
3283 Handle(AIS_InteractiveObject) aIO=iter.Value();
3284 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3285 }
3286 }
3287
3288 // ObjectsInCollector
3289 AIS_ListOfInteractive ListOfIO_2;
3290 AISContext->ObjectsInCollector(ListOfIO_2);
3291 di<< "ObjectsInCollector = " << ListOfIO_2.Extent() <<"\n";
3292 if (!ListOfIO_2.IsEmpty() ) {
3293 AIS_ListIteratorOfListOfInteractive iter;
3294 for (iter.Initialize(ListOfIO_2); iter.More() ; iter.Next() ) {
3295 Handle(AIS_InteractiveObject) aIO=iter.Value();
3296 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3297 }
3298 }
3299
3300 return 0;
3301}
3302
3303static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3304{
3305 if ((argc < 9) || (((argc-3) % 3) != 0))
3306 {
3307 di << "Usage : " << argv[0] << "polygon lastedge x1 y1 z1 x2 y2 z2 ...\n";
3308 return 1;
3309 }
3310 Standard_Integer i, j, np = (argc-3) / 3;
3311 BRepBuilderAPI_MakePolygon W;
3312 j = 3;
3313 for (i = 1; i <= np; i ++) {
3314 W.Add(gp_Pnt(atof(argv[j]),atof(argv[j+1]),atof(argv[j+2])));
3315 j += 3;
3316 }
3317 W.Close();
3318 DBRep::Set(argv[1],W.Wire());
3319 DBRep::Set(argv[2],W.Edge());
3320 return 0;
3321}
3322
3323static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3324{
3325 if (argc < 5) {
3326 di << "Usage : " << argv[0] << " ratio origin_x origin_y origin_z\n";
3327 return 1;
3328 }
3329 gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
3330 gp_Dir(1., -1., 0.));
3331 gp_GTrsf aTrf;
3332 aTrf.SetAffinity (aPln, atof(argv[4]));
3333 gp_XYZ aOrigin (atof(argv[1]),atof(argv[2]),atof(argv[3]));
3334 gp_XYZ aResult (aOrigin);
3335 aTrf.Transforms(aResult);
3336 char sbf[512];
3337 sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
3338 aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
3339 aResult.X(), aResult.Y(), aResult.Z());
3340 di<<sbf;
3341 return 0;
3342}
3343
3344Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3345{
3346 if (argc < 2) {
3347 di << "Usage : " << argv[0] << " shape [deflection]\n";
3348 return 1;
3349 }
3350
3351 TopoDS_Shape aShape = DBRep::Get(argv[1]);
3352
3353 if (aShape.IsNull()) {
3354 di<<" Null shape is not allowed";
3355 return 1;
3356 }
3357
3358 Standard_Real aDeflection = 0.45110277533;
3359 if (argc > 2) {
3360 aDeflection = atof(argv[2]);
3361 }
3362 di<<"deflection="<< aDeflection << "\n";
3363
3364 BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, PI/9.);
3365 TopLoc_Location aLocation;
3366 Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
3367
3368 if(aTriang.IsNull()) {
3369 di << argv[0] << " : Faulty\n" ;
3370 } else {
3371 di << argv[0] << " : OK\n" ;
3372 di<<"NbNodes="<< aTriang->NbNodes()<< "\n";
3373 di<<"NbTriangles="<< aTriang->NbTriangles()<< "\n";
3374 }
3375 return 0;
3376}
3377
3378static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3379{
3380 if (argc != 4) {
3381 di << "Usage : " << argv[0] << " A B C\n";
3382 return 1;
3383 }
3384 try
3385 {
3386 gp_Lin2d aLin2d (atof(argv[1]),atof(argv[2]),atof(argv[3]));
3387 gp_Pnt2d anOrigin = aLin2d.Location();
3388 di << "X_0 = " << anOrigin.X() << " Y_0 = " << anOrigin.Y() << "\n" ;
3389 }
3390 catch(Standard_ConstructionError)
3391 {
3392 di << argv[0] << " Exception: Sqrt(A*A + B*B) <= Resolution from gp\n";
3393 }
3394 return 0;
3395}
3396
3397static Standard_Integer OCC15755 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3398{
3399 if (argc != 3) {
3400 di << "Usage : " << argv[0] << " file shape\n";
3401 return 1;
3402 }
3403
3404 IGESControl_Reader aReader;
3405 aReader.ReadFile(argv[1]);
3406 aReader.SetReadVisible(Standard_True);
3407 aReader.TransferRoots();
3408
3409 Handle(IGESData_IGESModel) model = aReader.IGESModel();
3410 if (model.IsNull()) {
3411 di << "model.IsNull()\n";
3412 return 1;
3413 }
3414 Standard_Integer nb = model->NbEntities();
3415 for (Standard_Integer i = 1; i <= nb; i ++) {
3416 Handle(IGESData_IGESEntity) ent = model->Entity(i);
3417 Handle(TCollection_HAsciiString) name;
3418 name = ent->NameValue();
3419 Standard_CString aStr = name->ToCString();
3420 di << "NameValue = " << aStr << "\n";
3421 }
3422
3423 TopoDS_Shape shape = aReader.OneShape();
3424 DBRep::Set(argv[2],shape);
3425 return 0;
3426}
3427
3428// For OCC16782 testing
3429#include <AppStd_Application.hxx>
3430#include <TDF_Tool.hxx>
3431#include <TColStd_HArray1OfInteger.hxx>
3432// Iterators
3433#include <TColStd_ListIteratorOfListOfInteger.hxx>
3434#include <TColStd_ListIteratorOfListOfReal.hxx>
3435#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
3436#include <TDataStd_ListIteratorOfListOfByte.hxx>
3437#include <TDF_ListIteratorOfLabelList.hxx>
3438// Attributes
3439#include <TDataStd_Tick.hxx>
3440#include <TDataStd_IntegerList.hxx>
3441#include <TDataStd_RealList.hxx>
3442#include <TDataStd_ExtStringList.hxx>
3443#include <TDataStd_BooleanList.hxx>
3444#include <TDataStd_ReferenceList.hxx>
3445#include <TDataStd_BooleanArray.hxx>
3446#include <TDataStd_ReferenceArray.hxx>
3447#include <TDataStd_ByteArray.hxx>
3448#include <TDataStd_NamedData.hxx>
3449#include <TDF_Reference.hxx>
3450//
3451Handle(AppStd_Application) app;
3452int TestSetGet(const Handle(TDocStd_Document)& doc)
3453{
3454 // TDataStd_Tick:
3455 // Set
3456 TDataStd_Tick::Set(doc->Main());
3457 // Get
3458 Handle(TDataStd_Tick) tick;
3459 if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick))
3460 return 1;
3461 // Forget
3462 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3463 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3464 return 2;
3465 doc->Main().ResumeAttribute(tick);
3466 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3467 return 3;
3468 // Forget
3469 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3470 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3471 return 2;
3472
3473 // TDataStd_IntegerList:
3474 // Set
3475 Handle(TDataStd_IntegerList) setintlist = TDataStd_IntegerList::Set(doc->Main());
3476 setintlist->Append(2);
3477 setintlist->Prepend(1);
3478 setintlist->InsertAfter(3, 2);
3479 setintlist->InsertBefore(0, 1);
3480 setintlist->Append(200);
3481 setintlist->Remove(0);
3482 setintlist->Remove(200);
3483 // Get
3484 Handle(TDataStd_IntegerList) getintlist;
3485 if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist))
3486 return 1;
3487 if (getintlist->First() != 1)
3488 return 2;
3489 if (getintlist->Last() != 3)
3490 return 3;
3491 const TColStd_ListOfInteger& intlist = getintlist->List();
3492 TColStd_ListIteratorOfListOfInteger itr_intlist(intlist);
3493 for (; itr_intlist.More(); itr_intlist.Next())
3494 {
3495 if (itr_intlist.Value() != 1 &&
3496 itr_intlist.Value() != 2 &&
3497 itr_intlist.Value() != 3)
3498 {
3499 return 4;
3500 }
3501 }
3502 getintlist->Clear();
3503
3504 // TDataStd_RealList:
3505 // Set
3506 Handle(TDataStd_RealList) setdbllist = TDataStd_RealList::Set(doc->Main());
3507 setdbllist->Append(2.5);
3508 setdbllist->Prepend(1.5);
3509 setdbllist->InsertAfter(3.5, 2.5);
3510 setdbllist->InsertBefore(0.5, 1.5);
3511 setdbllist->Append(200.5);
3512 setdbllist->Remove(0.5);
3513 setdbllist->Remove(200.5);
3514 // Get
3515 Handle(TDataStd_RealList) getdbllist;
3516 if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist))
3517 return 1;
3518 if (getdbllist->First() != 1.5)
3519 return 2;
3520 if (getdbllist->Last() != 3.5)
3521 return 3;
3522 const TColStd_ListOfReal& dbllist = getdbllist->List();
3523 TColStd_ListIteratorOfListOfReal itr_dbllist(dbllist);
3524 for (; itr_dbllist.More(); itr_dbllist.Next())
3525 {
3526 if (itr_dbllist.Value() != 1.5 &&
3527 itr_dbllist.Value() != 2.5 &&
3528 itr_dbllist.Value() != 3.5)
3529 {
3530 return 4;
3531 }
3532 }
3533 getdbllist->Clear();
3534
3535 // TDataStd_ExtStringList:
3536 // Set
3537 Handle(TDataStd_ExtStringList) setstrlist = TDataStd_ExtStringList::Set(doc->Main());
3538 setstrlist->Append("Hello");
3539 setstrlist->Prepend("Guten Tag");
3540 setstrlist->InsertAfter("Bonjour", "Guten Tag");
3541 setstrlist->InsertBefore("Bonsoir", "Hello");
3542 setstrlist->Append("Good bye");
3543 setstrlist->Remove("Bonsoir");
3544 setstrlist->Remove("Good bye");
3545 // Get
3546 Handle(TDataStd_ExtStringList) getstrlist;
3547 if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist))
3548 return 1;
3549 if (getstrlist->First() != "Guten Tag")
3550 return 2;
3551 if (getstrlist->Last() != "Hello")
3552 return 3;
3553 const TDataStd_ListOfExtendedString& strlist = getstrlist->List();
3554 TDataStd_ListIteratorOfListOfExtendedString itr_strlist(strlist);
3555 for (; itr_strlist.More(); itr_strlist.Next())
3556 {
3557 if (itr_strlist.Value() != "Guten Tag" &&
3558 itr_strlist.Value() != "Bonjour" &&
3559 itr_strlist.Value() != "Hello")
3560 {
3561 return 4;
3562 }
3563 }
3564 getstrlist->Clear();
3565
3566 // TDataStd_BooleanList:
3567 // Set
3568 Handle(TDataStd_BooleanList) setboollist = TDataStd_BooleanList::Set(doc->Main());
3569 setboollist->Append(Standard_True);
3570 setboollist->Prepend(Standard_False);
3571 // Get
3572 Handle(TDataStd_BooleanList) getboollist;
3573 if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist))
3574 return 1;
3575 if (getboollist->First() != Standard_False)
3576 return 2;
3577 if (getboollist->Last() != Standard_True)
3578 return 3;
3579 const TDataStd_ListOfByte& boollist = getboollist->List();
3580 TDataStd_ListIteratorOfListOfByte itr_boollist(boollist);
3581 for (; itr_boollist.More(); itr_boollist.Next())
3582 {
3583 if (itr_boollist.Value() != Standard_True &&
3584 itr_boollist.Value() != Standard_False)
3585 {
3586 return 4;
3587 }
3588 }
3589 getboollist->Clear();
3590
3591 // TDataStd_ReferenceList:
3592 TDF_Label L1 = doc->Main().FindChild(100);
3593 TDF_Label L2 = doc->Main().FindChild(101);
3594 TDF_Label L3 = doc->Main().FindChild(102);
3595 TDF_Label L4 = doc->Main().FindChild(103);
3596 TDF_Label L5 = doc->Main().FindChild(104);
3597 // Set
3598 Handle(TDataStd_ReferenceList) setreflist = TDataStd_ReferenceList::Set(doc->Main());
3599 setreflist->Append(L1);
3600 setreflist->Prepend(L2);
3601 setreflist->InsertAfter(L3, L2);
3602 setreflist->InsertBefore(L4, L1);
3603 setreflist->Append(L5);
3604 setreflist->Remove(L4);
3605 setreflist->Remove(L5);
3606 // Get
3607 Handle(TDataStd_ReferenceList) getreflist;
3608 if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist))
3609 return 1;
3610 if (getreflist->First() != L2)
3611 return 2;
3612 if (getreflist->Last() != L1)
3613 return 3;
3614 const TDF_LabelList& reflist = getreflist->List();
3615 TDF_ListIteratorOfLabelList itr_reflist(reflist);
3616 for (; itr_reflist.More(); itr_reflist.Next())
3617 {
3618 if (itr_reflist.Value() != L1 &&
3619 itr_reflist.Value() != L2 &&
3620 itr_reflist.Value() != L3)
3621 {
3622 return 4;
3623 }
3624 }
3625 getreflist->Clear();
3626
3627 // TDataStd_BooleanArray:
3628 // Set
3629 Handle(TDataStd_BooleanArray) setboolarr = TDataStd_BooleanArray::Set(doc->Main(), 12, 16);
3630 setboolarr->SetValue(12, Standard_True);
3631 setboolarr->SetValue(13, Standard_False);
3632 setboolarr->SetValue(14, Standard_False);
3633 setboolarr->SetValue(15, Standard_False);
3634 setboolarr->SetValue(16, Standard_True);
3635 setboolarr->SetValue(14, Standard_True);
3636 // Get
3637 Handle(TDataStd_BooleanArray) getboolarr;
3638 if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr))
3639 return 1;
3640 if (getboolarr->Value(12) != Standard_True)
3641 return 2;
3642 if (getboolarr->Value(13) != Standard_False)
3643 return 2;
3644 if (getboolarr->Value(14) != Standard_True)
3645 return 2;
3646 if (getboolarr->Value(15) != Standard_False)
3647 return 2;
3648 if (getboolarr->Value(16) != Standard_True)
3649 return 2;
3650
3651 // TDataStd_ReferenceArray:
3652 // Set
3653 Handle(TDataStd_ReferenceArray) setrefarr = TDataStd_ReferenceArray::Set(doc->Main(), 0, 4);
3654 setrefarr->SetValue(0, L1);
3655 setrefarr->SetValue(1, L2);
3656 setrefarr->SetValue(2, L3);
3657 setrefarr->SetValue(3, L4);
3658 setrefarr->SetValue(4, L5);
3659 // Get
3660 Handle(TDataStd_ReferenceArray) getrefarr;
3661 if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr))
3662 return 1;
3663 if (getrefarr->Value(0) != L1)
3664 return 2;
3665 if (getrefarr->Value(1) != L2)
3666 return 2;
3667 if (getrefarr->Value(2) != L3)
3668 return 2;
3669 if (getrefarr->Value(3) != L4)
3670 return 2;
3671 if (getrefarr->Value(4) != L5)
3672 return 2;
3673
3674 // TDataStd_ByteArray:
3675 // Set
3676 Handle(TDataStd_ByteArray) setbytearr = TDataStd_ByteArray::Set(doc->Main(), 12, 16);
3677 setbytearr->SetValue(12, 0);
3678 setbytearr->SetValue(13, 1);
3679 setbytearr->SetValue(14, 2);
3680 setbytearr->SetValue(15, 3);
3681 setbytearr->SetValue(16, 255);
3682 // Get
3683 Handle(TDataStd_ByteArray) getbytearr;
3684 if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr))
3685 return 1;
3686 if (getbytearr->Value(12) != 0)
3687 return 2;
3688 if (getbytearr->Value(13) != 1)
3689 return 2;
3690 if (getbytearr->Value(14) != 2)
3691 return 2;
3692 if (getbytearr->Value(15) != 3)
3693 return 2;
3694 if (getbytearr->Value(16) != 255)
3695 return 2;
3696
3697 // TDataStd_NamedData:
3698 // Set:
3699 Handle(TDataStd_NamedData) setnd = TDataStd_NamedData::Set(doc->Main());
3700 setnd->SetInteger("Integer1", 1);
3701 setnd->SetInteger("Integer2", 2);
3702 setnd->SetInteger("Integer3", 8);
3703 setnd->SetInteger("Integer3", 3);
3704 // Get:
3705 Handle(TDataStd_NamedData) getnd;
3706 if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd))
3707 return 1;
3708 if (!getnd->HasIntegers())
3709 return 2;
3710 if (!getnd->HasInteger("Integer1"))
3711 return 3;
3712 if (getnd->GetInteger("Integer2") != 2)
3713 return 4;
3714 if (getnd->GetInteger("Integer3") != 3)
3715 return 4;
3716
3717 return 0;
3718}
3719
3720int TestUndoRedo(const Handle(TDocStd_Document)& doc)
3721{
3722 // TDataStd_Tick:
3723 doc->OpenCommand();
3724 Handle(TDataStd_Tick) tick = TDataStd_Tick::Set(doc->Main());
3725 doc->CommitCommand();
3726 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3727 return 1;
3728 doc->Undo();
3729 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3730 return 2;
3731 doc->Redo();
3732 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3733 return 3;
3734
3735 // TDataStd_IntegerList:
3736 doc->OpenCommand();
3737 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc->Main());
3738 intlist->Append(2);
3739 intlist->Prepend(1);
3740 intlist->InsertBefore(0, 1);
3741 intlist->InsertAfter(3, 2);
3742 doc->CommitCommand();
3743 if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID()))
3744 return 1;
3745 doc->Undo();
3746 if (!intlist->IsEmpty())
3747 return 2;
3748 doc->Redo();
3749 if (!intlist->Extent())
3750 return 3;
3751 if (intlist->First() != 0)
3752 return 4;
3753 if (intlist->Last() != 3)
3754 return 5;
3755 intlist->Clear();
3756
3757 // TDataStd_RealList:
3758 doc->OpenCommand();
3759 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc->Main());
3760 dbllist->Append(2.5);
3761 dbllist->Prepend(1.5);
3762 dbllist->InsertBefore(0.5, 1.5);
3763 dbllist->InsertAfter(3.5, 2.5);
3764 doc->CommitCommand();
3765 if (!doc->Main().IsAttribute(TDataStd_RealList::GetID()))
3766 return 1;
3767 doc->Undo();
3768 if (!dbllist->IsEmpty())
3769 return 2;
3770 doc->Redo();
3771 if (!dbllist->Extent())
3772 return 3;
3773 if (dbllist->First() != 0.5)
3774 return 4;
3775 if (dbllist->Last() != 3.5)
3776 return 5;
3777 dbllist->Clear();
3778
3779 // TDataStd_ExtStringList:
3780 doc->OpenCommand();
3781 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc->Main());
3782 strlist->Append("Hello");
3783 strlist->Prepend("Guten Tag");
3784 strlist->InsertAfter("Bonjour", "Guten Tag");
3785 strlist->InsertBefore("Bonsoir", "Hello");
3786 doc->CommitCommand();
3787 if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID()))
3788 return 1;
3789 doc->Undo();
3790 if (!strlist->IsEmpty())
3791 return 2;
3792 doc->Redo();
3793 if (!strlist->Extent())
3794 return 3;
3795 if (strlist->First() != "Guten Tag")
3796 return 4;
3797 if (strlist->Last() != "Hello")
3798 return 5;
3799 strlist->Clear();
3800
3801 // TDataStd_BooleanList:
3802 doc->OpenCommand();
3803 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc->Main());
3804 boollist->Append(Standard_True);
3805 boollist->Prepend(Standard_False);
3806 doc->CommitCommand();
3807 if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID()))
3808 return 1;
3809 doc->Undo();
3810 if (!boollist->IsEmpty())
3811 return 2;
3812 doc->Redo();
3813 if (!boollist->Extent())
3814 return 3;
3815 if (boollist->First() != Standard_False)
3816 return 4;
3817 if (boollist->Last() != Standard_True)
3818 return 5;
3819 boollist->Clear();
3820
3821 // TDataStd_ReferenceList:
3822 TDF_Label L1 = doc->Main().FindChild(100);
3823 TDF_Label L2 = doc->Main().FindChild(101);
3824 TDF_Label L3 = doc->Main().FindChild(102);
3825 TDF_Label L4 = doc->Main().FindChild(103);
3826 doc->OpenCommand();
3827 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc->Main());
3828 reflist->Append(L1);
3829 reflist->Prepend(L2);
3830 reflist->InsertBefore(L3, L1);
3831 reflist->InsertAfter(L4, L2);
3832 doc->CommitCommand();
3833 if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID()))
3834 return 1;
3835 doc->Undo();
3836 if (!reflist->IsEmpty())
3837 return 2;
3838 doc->Redo();
3839 if (!reflist->Extent())
3840 return 3;
3841 if (reflist->First() != L2)
3842 return 4;
3843 if (reflist->Last() != L1)
3844 return 5;
3845 reflist->Clear();
3846
3847 // TDataStd_BooleanArray:
3848 doc->OpenCommand();
3849 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc->Main(), 23, 25);
3850 boolarr->SetValue(23, Standard_True);
3851 boolarr->SetValue(25, Standard_True);
3852 doc->CommitCommand();
3853 doc->OpenCommand();
3854 boolarr = TDataStd_BooleanArray::Set(doc->Main(), 230, 250);
3855 boolarr->SetValue(230, Standard_True);
3856 boolarr->SetValue(250, Standard_True);
3857 doc->CommitCommand();
3858 doc->Undo();
3859 if (boolarr->Value(23) != Standard_True)
3860 return 2;
3861 if (boolarr->Value(24) != Standard_False)
3862 return 2;
3863 if (boolarr->Value(25) != Standard_True)
3864 return 2;
3865 doc->Redo();
3866 if (boolarr->Value(230) != Standard_True)
3867 return 3;
3868 if (boolarr->Value(240) != Standard_False)
3869 return 3;
3870 if (boolarr->Value(250) != Standard_True)
3871 return 3;
3872
3873 // TDataStd_ReferenceArray:
3874 doc->OpenCommand();
3875 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc->Main(), 5, 8);
3876 refarr->SetValue(5, L1);
3877 refarr->SetValue(6, L2);
3878 refarr->SetValue(7, L3);
3879 refarr->SetValue(8, L4);
3880 doc->CommitCommand();
3881 if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID()))
3882 return 1;
3883 doc->Undo();
3884 doc->Redo();
3885 if (refarr->Value(5) != L1)
3886 return 4;
3887 if (refarr->Value(6) != L2)
3888 return 4;
3889 if (refarr->Value(7) != L3)
3890 return 4;
3891 if (refarr->Value(8) != L4)
3892 return 4;
3893
3894 // TDataStd_ByteArray:
3895 doc->OpenCommand();
3896 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc->Main(), 23, 25);
3897 bytearr->SetValue(23, 23);
3898 bytearr->SetValue(25, 25);
3899 doc->CommitCommand();
3900 doc->OpenCommand();
3901 bytearr = TDataStd_ByteArray::Set(doc->Main(), 230, 250);
3902 bytearr->SetValue(230, 230);
3903 bytearr->SetValue(250, 250);
3904 doc->CommitCommand();
3905 doc->Undo();
3906 if (bytearr->Value(23) != 23)
3907 return 2;
3908 if (bytearr->Value(25) != 25)
3909 return 2;
3910 doc->Redo();
3911 if (bytearr->Value(230) != 230)
3912 return 3;
3913 if (bytearr->Value(250) != 250)
3914 return 3;
3915
3916 // TDataStd_NamedData:
3917 doc->OpenCommand();
3918 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(doc->Main());
3919 nd->SetByte("b14", 12);
3920 nd->SetByte("b17", 18);
3921 nd->SetByte("b14", 14);
3922 nd->SetByte("b17", 17);
3923 doc->CommitCommand();
3924 doc->OpenCommand();
3925 nd = TDataStd_NamedData::Set(doc->Main());
3926 nd->SetReal("r14", 14);
3927 nd->SetReal("r17", 17);
3928 nd->SetReal("r14", 14.4);
3929 nd->SetReal("r17", 17.7);
3930 doc->CommitCommand();
3931 doc->Undo();
3932 if (nd->HasStrings())
3933 return 1;
3934 if (nd->HasReals())
3935 return 1;
3936 if (nd->HasReal("r17"))
3937 return 2;
3938 if (!nd->HasBytes())
3939 return 3;
3940 if (nd->GetByte("b14") != 14)
3941 return 4;
3942 if (nd->GetByte("b17") != 17)
3943 return 4;
3944 if (nd->HasByte("b18"))
3945 return 5;
3946 doc->Redo();
3947 if (!nd->HasBytes())
3948 return 1;
3949 if (!nd->HasReals())
3950 return 1;
3951 if (nd->GetByte("b14") != 14)
3952 return 2;
3953 if (nd->GetReal("r14") != 14.4)
3954 return 2;
3955 if (nd->GetReal("r17") != 17.7)
3956 return 2;
3957
3958 return 0;
3959}
3960
3961int TestCopyPaste(const Handle(TDocStd_Document)& doc)
3962{
3963 TDF_Label L1 = doc->Main().FindChild(1);
3964 TDF_Label L2 = doc->Main().FindChild(2);
3965 TDF_CopyLabel copier(L1, L2);
3966
3967 // TDataStd_Tick:
3968 TDataStd_Tick::Set(L1);
3969 copier.Perform();
3970 if (!copier.IsDone())
3971 return 1;
3972 if (!L2.IsAttribute(TDataStd_Tick::GetID()))
3973 return 2;
3974
3975 // TDataStd_IntegerList:
3976 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(L1);
3977 intlist->Append(1);
3978 intlist->InsertAfter(2, 1);
3979 copier.Perform();
3980 if (!copier.IsDone())
3981 return 1;
3982 intlist->Clear();
3983 intlist.Nullify();
3984 if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3985 return 2;
3986 if (intlist->First() != 1)
3987 return 3;
3988 if (intlist->Last() != 2)
3989 return 4;
3990 intlist->Clear();
3991
3992 // TDataStd_RealList:
3993 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(L1);
3994 dbllist->Append(1.5);
3995 dbllist->InsertAfter(2.5, 1.5);
3996 copier.Perform();
3997 if (!copier.IsDone())
3998 return 1;
3999 dbllist->Clear();
4000 dbllist.Nullify();
4001 if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist))
4002 return 2;
4003 if (dbllist->First() != 1.5)
4004 return 3;
4005 if (dbllist->Last() != 2.5)
4006 return 4;
4007 dbllist->Clear();
4008
4009 // TDataStd_ExtStringList:
4010 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(L1);
4011 strlist->Append("Open CASCADE");
4012 strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE");
4013 copier.Perform();
4014 if (!copier.IsDone())
4015 return 1;
4016 strlist->Clear();
4017 strlist.Nullify();
4018 if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4019 return 2;
4020 if (strlist->First() != "Open CASCADE")
4021 return 3;
4022 if (strlist->Last() != " - is the best set of libraries!")
4023 return 4;
4024 strlist->Clear();
4025
4026 // TDataStd_BooleanList:
4027 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(L1);
4028 boollist->Append(Standard_True);
4029 boollist->Prepend(Standard_False);
4030 copier.Perform();
4031 if (!copier.IsDone())
4032 return 1;
4033 boollist->Clear();
4034 boollist.Nullify();
4035 if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4036 return 2;
4037 if (boollist->First() != Standard_False)
4038 return 3;
4039 if (boollist->Last() != Standard_True)
4040 return 4;
4041 boollist->Clear();
4042
4043 // TDataStd_ReferenceList:
4044 TDF_Label L100 = doc->Main().FindChild(100);
4045 TDF_Label L101 = doc->Main().FindChild(101);
4046 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(L1);
4047 reflist->Append(L100);
4048 reflist->InsertAfter(L101, L100);
4049 copier.Perform();
4050 if (!copier.IsDone())
4051 return 1;
4052 reflist->Clear();
4053 reflist.Nullify();
4054 if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4055 return 2;
4056 if (reflist->First() != L100)
4057 return 3;
4058 if (reflist->Last() != L101)
4059 return 4;
4060 reflist->Clear();
4061
4062 // TDataStd_BooleanArray:
4063 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(L1, 4, 6);
4064 boolarr->SetValue(4, Standard_True);
4065 boolarr->SetValue(6, Standard_True);
4066 copier.Perform();
4067 if (!copier.IsDone())
4068 return 1;
4069 boolarr.Nullify();
4070 if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4071 return 2;
4072 if (boolarr->Value(4) != Standard_True)
4073 return 3;
4074 if (boolarr->Value(5) != Standard_False)
4075 return 3;
4076 if (boolarr->Value(6) != Standard_True)
4077 return 3;
4078
4079 // TDataStd_ReferenceArray:
4080 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(L1, 3, 4);
4081 refarr->SetValue(3, L100);
4082 refarr->SetValue(4, L101);
4083 copier.Perform();
4084 if (!copier.IsDone())
4085 return 1;
4086 refarr.Nullify();
4087 if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4088 return 2;
4089 if (refarr->Value(3) != L100)
4090 return 3;
4091 if (refarr->Value(4) != L101)
4092 return 3;
4093
4094 // TDataStd_ByteArray:
4095 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(L1, 4, 6);
4096 bytearr->SetValue(4, 40);
4097 bytearr->SetValue(6, 60);
4098 copier.Perform();
4099 if (!copier.IsDone())
4100 return 1;
4101 bytearr.Nullify();
4102 if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4103 return 2;
4104 if (bytearr->Value(4) != 40)
4105 return 3;
4106 if (bytearr->Value(6) != 60)
4107 return 3;
4108
4109 // TDataStd_NamedData:
4110 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(L1);
4111 nd->SetInteger("Integer1", 11);
4112 nd->SetReal("Real1", 11.1);
4113 nd->SetString("String1", "11.11111111");
4114 nd->SetByte("Byte1", 111);
4115 Handle(TColStd_HArray1OfInteger) ints_arr = new TColStd_HArray1OfInteger(4, 5);
4116 ints_arr->SetValue(4, 4);
4117 ints_arr->SetValue(5, 5);
4118 nd->SetArrayOfIntegers("Integers1", ints_arr);
4119 copier.Perform();
4120 if (!copier.IsDone())
4121 return 1;
4122 nd.Nullify();
4123 if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd))
4124 return 2;
4125 if (!nd->HasIntegers())
4126 return 3;
4127 if (!nd->HasReals())
4128 return 3;
4129 if (!nd->HasStrings())
4130 return 3;
4131 if (!nd->HasBytes())
4132 return 3;
4133 if (!nd->HasArraysOfIntegers())
4134 return 3;
4135 if (nd->HasArraysOfReals())
4136 return 3;
4137 if (!nd->HasInteger("Integer1"))
4138 return 4;
4139 if (nd->GetInteger("Integer1") != 11)
4140 return 4;
4141 if (!nd->HasReal("Real1"))
4142 return 4;
4143 if (nd->GetReal("Real1") != 11.1)
4144 return 4;
4145 if (!nd->HasString("String1"))
4146 return 4;
4147 if (nd->GetString("String1") != "11.11111111")
4148 return 4;
4149 if (!nd->HasByte("Byte1"))
4150 return 4;
4151 if (nd->GetByte("Byte1") != 111)
4152 return 4;
4153 if (!nd->HasArrayOfIntegers("Integers1"))
4154 return 4;
4155 const Handle(TColStd_HArray1OfInteger)& ints_arr_out = nd->GetArrayOfIntegers("Integers1");
4156 if (ints_arr_out.IsNull())
4157 return 4;
4158 if (ints_arr_out->Value(5) != 5)
4159 return 4;
4160
4161 return 0;
4162}
4163
4164int TestOpenSave(TCollection_ExtendedString aFile1,
4165 TCollection_ExtendedString aFile2,
4166 TCollection_ExtendedString aFile3)
4167{
4168 // Std
4169 Handle(TDocStd_Document) doc_std, doc_std_open;
4170 app->NewDocument("MDTV-Standard", doc_std);
4171 // TDataStd_Tick:
4172 TDataStd_Tick::Set(doc_std->Main());
4173 // TDataStd_IntegerList:
4174 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc_std->Main());
4175 intlist->Append(1);
4176 intlist->Append(5);
4177 // TDataStd_RealList:
4178 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc_std->Main());
4179 dbllist->Append(1.5);
4180 dbllist->Append(5.5);
4181 // TDataStd_ExtStringList:
4182 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc_std->Main());
4183 strlist->Append("Auf");
4184 strlist->Append("Wiedersehen");
4185 // TDataStd_BooleanList:
4186 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc_std->Main());
4187 boollist->Append(Standard_False);
4188 boollist->Append(Standard_True);
4189 // TDataStd_ReferenceList:
4190 TCollection_AsciiString entry1, entry2, entry_first, entry_last;
4191 TDF_Label Lstd1 = doc_std->Main().FindChild(100);
4192 TDF_Tool::Entry(Lstd1, entry1);
4193 TDF_Label Lstd2 = doc_std->Main().FindChild(101);
4194 TDF_Tool::Entry(Lstd2, entry2);
4195 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc_std->Main());
4196 reflist->Append(Lstd1);
4197 reflist->Append(Lstd2);
4198 // TDataStd_BooleanArray:
4199 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc_std->Main(), 15, 18);
4200 boolarr->SetValue(15, Standard_False);
4201 boolarr->SetValue(16, Standard_True);
4202 boolarr->SetValue(17, Standard_True);
4203 boolarr->SetValue(18, Standard_True);
4204 // TDataStd_ReferenceArray:
4205 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc_std->Main(), 45, 46);
4206 refarr->SetValue(45, Lstd1);
4207 refarr->SetValue(46, Lstd2);
4208 // TDataStd_ByteArray:
4209 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc_std->Main(), 15, 18);
4210 bytearr->SetValue(15, 150);
4211 bytearr->SetValue(16, 160);
4212 bytearr->SetValue(17, 170);
4213 bytearr->SetValue(18, 180);
4214 // TDataStd_NamedData:
4215 Handle(TDataStd_NamedData) nameddata = TDataStd_NamedData::Set(doc_std->Main());
4216 // TDF_Reference:
4217 TDF_Label Lstd3 = doc_std->Main().FindChild(103);
4218 Handle(TDF_Reference) ref = TDF_Reference::Set(doc_std->Main(), Lstd3);
4219 //
4220 // Save
4221 //if (app->SaveAs(doc_std, "W:\\doc.std") != CDF_SS_OK)
4222 if (app->SaveAs(doc_std, aFile1) != CDF_SS_OK)
4223 return 1;
4224 intlist.Nullify();
4225 dbllist.Nullify();
4226 strlist.Nullify();
4227 boollist.Nullify();
4228 reflist.Nullify();
4229 boolarr.Nullify();
4230 ref.Nullify();
4231 app->Close(doc_std);
4232 doc_std.Nullify();
4233 //if (app->Open("W:\\doc.std", doc_std_open) != CDF_RS_OK)
4234 if (app->Open(aFile1, doc_std_open) != CDF_RS_OK)
4235 return 2;
4236 if (!doc_std_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4237 return 3;
4238 if (!doc_std_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4239 return 4;
4240 if (intlist->First() != 1)
4241 return 5;
4242 if (intlist->Last() != 5)
4243 return 6;
4244 if (!doc_std_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4245 return 4;
4246 if (dbllist->First() != 1.5)
4247 return 5;
4248 if (dbllist->Last() != 5.5)
4249 return 6;
4250 if (!doc_std_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4251 return 4;
4252 if (strlist->First() != "Auf")
4253 return 5;
4254 if (strlist->Last() != "Wiedersehen")
4255 return 6;
4256 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4257 return 4;
4258 if (boollist->First() != Standard_False)
4259 return 5;
4260 if (boollist->Last() != Standard_True)
4261 return 6;
4262 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4263 return 4;
4264 TDF_Tool::Entry(reflist->First(), entry_first);
4265 if (entry1 != entry_first)
4266 return 5;
4267 TDF_Tool::Entry(reflist->Last(), entry_last);
4268 if (entry2 != entry_last)
4269 return 6;
4270 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4271 return 4;
4272 if (boolarr->Value(15) != Standard_False)
4273 return 5;
4274 if (boolarr->Value(16) != Standard_True)
4275 return 5;
4276 if (boolarr->Value(17) != Standard_True)
4277 return 5;
4278 if (boolarr->Value(18) != Standard_True)
4279 return 5;
4280 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4281 return 4;
4282 TDF_Tool::Entry(refarr->Value(45), entry_first);
4283 if (entry1 != entry_first)
4284 return 5;
4285 TDF_Tool::Entry(refarr->Value(46), entry_last);
4286 if (entry2 != entry_last)
4287 return 6;
4288 if (!doc_std_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4289 return 4;
4290 if (bytearr->Value(15) != 150)
4291 return 5;
4292 if (bytearr->Value(16) != 160)
4293 return 5;
4294 if (bytearr->Value(17) != 170)
4295 return 5;
4296 if (bytearr->Value(18) != 180)
4297 return 5;
4298 if (!doc_std_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4299 return 4;
4300 if (ref->Get().IsNull())
4301 return 5;
4302 if (ref->Get().Tag() != 103)
4303 return 5;
4304
4305 // Xml
4306 Handle(TDocStd_Document) doc_xml, doc_xml_open;
4307 app->NewDocument("XmlOcaf", doc_xml);
4308 // TDataStd_Tick:
4309 TDataStd_Tick::Set(doc_xml->Main());
4310 // TDataStd_IntegerList:
4311 intlist = TDataStd_IntegerList::Set(doc_xml->Main());
4312 intlist->Append(1);
4313 intlist->Append(5);
4314 // TDataStd_RealList:
4315 dbllist = TDataStd_RealList::Set(doc_xml->Main());
4316 dbllist->Append(1.5);
4317 dbllist->Append(5.5);
4318 // TDataStd_ExtStringList:
4319 strlist = TDataStd_ExtStringList::Set(doc_xml->Main());
4320 strlist->Append("Guten ");
4321 strlist->Append("Tag");
4322 // TDataStd_BooleanList:
4323 boollist = TDataStd_BooleanList::Set(doc_xml->Main());
4324 boollist->Append(Standard_False);
4325 boollist->Append(Standard_True);
4326 // TDataStd_ReferenceList:
4327 TDF_Label Lxml1 = doc_xml->Main().FindChild(100);
4328 TDF_Tool::Entry(Lxml1, entry1);
4329 TDF_Label Lxml2 = doc_xml->Main().FindChild(101);
4330 TDF_Tool::Entry(Lxml2, entry2);
4331 reflist = TDataStd_ReferenceList::Set(doc_xml->Main());
4332 reflist->Append(Lxml1);
4333 reflist->Append(Lxml2);
4334 // TDataStd_BooleanArray:
4335 boolarr = TDataStd_BooleanArray::Set(doc_xml->Main(), 15, 24);
4336 boolarr->SetValue(15, Standard_False);
4337 boolarr->SetValue(16, Standard_True);
4338 boolarr->SetValue(17, Standard_True);
4339 boolarr->SetValue(18, Standard_True);
4340 boolarr->SetValue(19, Standard_True);
4341 boolarr->SetValue(20, Standard_True);
4342 boolarr->SetValue(21, Standard_False);
4343 boolarr->SetValue(22, Standard_True);
4344 boolarr->SetValue(23, Standard_True);
4345 boolarr->SetValue(24, Standard_True);
4346 // TDataStd_ReferenceArray:
4347 refarr = TDataStd_ReferenceArray::Set(doc_xml->Main(), 444, 445);
4348 refarr->SetValue(444, Lxml1);
4349 refarr->SetValue(445, Lxml2);
4350 // TDataStd_ByteArray:
4351 bytearr = TDataStd_ByteArray::Set(doc_xml->Main(), 15, 24);
4352 bytearr->SetValue(15, 0);
4353 bytearr->SetValue(16, 10);
4354 bytearr->SetValue(17, 100);
4355 bytearr->SetValue(18, 200);
4356 bytearr->SetValue(19, 250);
4357 bytearr->SetValue(20, 251);
4358 bytearr->SetValue(21, 252);
4359 bytearr->SetValue(22, 253);
4360 bytearr->SetValue(23, 254);
4361 bytearr->SetValue(24, 255);
4362 // TDF_Reference:
4363 Lstd3 = doc_xml->Main().FindChild(103);
4364 ref = TDF_Reference::Set(doc_xml->Main(), Lstd3);
4365 //
4366 // Save
4367 //if (app->SaveAs(doc_xml, "W:\\doc.xml") != CDF_SS_OK)
4368 if (app->SaveAs(doc_xml, aFile2) != CDF_SS_OK)
4369 return 1;
4370 intlist.Nullify();
4371 ref.Nullify();
4372 app->Close(doc_xml);
4373 doc_xml.Nullify();
4374 //if (app->Open("W:\\doc.xml", doc_xml_open) != CDF_RS_OK)
4375 if (app->Open(aFile2, doc_xml_open) != CDF_RS_OK)
4376 return 2;
4377 if (!doc_xml_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4378 return 3;
4379 if (!doc_xml_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4380 return 4;
4381 if (intlist->First() != 1)
4382 return 5;
4383 if (intlist->Last() != 5)
4384 return 6;
4385 if (!doc_xml_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4386 return 4;
4387 if (dbllist->First() != 1.5)
4388 return 5;
4389 if (dbllist->Last() != 5.5)
4390 return 6;
4391 if (!doc_xml_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4392 return 4;
4393 if (strlist->First() != "Guten ")
4394 return 5;
4395 if (strlist->Last() != "Tag")
4396 return 6;
4397 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4398 return 4;
4399 if (boollist->First() != Standard_False)
4400 return 5;
4401 if (boollist->Last() != Standard_True)
4402 return 6;
4403 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4404 return 4;
4405 TDF_Tool::Entry(reflist->First(), entry_first);
4406 if (entry1 != entry_first)
4407 return 5;
4408 TDF_Tool::Entry(reflist->Last(), entry_last);
4409 if (entry2 != entry_last)
4410 return 6;
4411 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4412 return 4;
4413 if (boolarr->Value(15) != Standard_False)
4414 return 5;
4415 if (boolarr->Value(16) != Standard_True)
4416 return 5;
4417 if (boolarr->Value(17) != Standard_True)
4418 return 5;
4419 if (boolarr->Value(18) != Standard_True)
4420 return 5;
4421 if (boolarr->Value(19) != Standard_True)
4422 return 5;
4423 if (boolarr->Value(20) != Standard_True)
4424 return 5;
4425 if (boolarr->Value(21) != Standard_False)
4426 return 5;
4427 if (boolarr->Value(22) != Standard_True)
4428 return 5;
4429 if (boolarr->Value(23) != Standard_True)
4430 return 5;
4431 if (boolarr->Value(24) != Standard_True)
4432 return 5;
4433 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4434 return 4;
4435 TDF_Tool::Entry(refarr->Value(444), entry_first);
4436 if (entry1 != entry_first)
4437 return 5;
4438 TDF_Tool::Entry(refarr->Value(445), entry_last);
4439 if (entry2 != entry_last)
4440 return 6;
4441 if (!doc_xml_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4442 return 4;
4443 if (bytearr->Value(15) != 0)
4444 return 5;
4445 if (bytearr->Value(16) != 10)
4446 return 5;
4447 if (bytearr->Value(17) != 100)
4448 return 5;
4449 if (bytearr->Value(18) != 200)
4450 return 5;
4451 if (bytearr->Value(19) != 250)
4452 return 5;
4453 if (bytearr->Value(20) != 251)
4454 return 5;
4455 if (bytearr->Value(21) != 252)
4456 return 5;
4457 if (bytearr->Value(22) != 253)
4458 return 5;
4459 if (bytearr->Value(23) != 254)
4460 return 5;
4461 if (bytearr->Value(24) != 255)
4462 return 5;
4463 if (!doc_xml_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4464 return 4;
4465 if (ref->Get().IsNull())
4466 return 5;
4467 if (ref->Get().Tag() != 103)
4468 return 5;
4469
4470 // Bin
4471 Handle(TDocStd_Document) doc_bin, doc_bin_open;
4472 app->NewDocument("BinOcaf", doc_bin);
4473 // TDataStd_Tick:
4474 TDataStd_Tick::Set(doc_bin->Main());
4475 // TDataStd_IntegerList:
4476 intlist = TDataStd_IntegerList::Set(doc_bin->Main());
4477 intlist->Append(1);
4478 intlist->Append(5);
4479 // TDataStd_RealList:
4480 dbllist = TDataStd_RealList::Set(doc_bin->Main());
4481 dbllist->Append(1.5);
4482 dbllist->Append(5.5);
4483 // TDataStd_ExtStringList:
4484 strlist = TDataStd_ExtStringList::Set(doc_bin->Main());
4485 strlist->Append("Bonjour");
4486 strlist->Append("Bonsoir");
4487 // TDataStd_BooleanList:
4488 boollist = TDataStd_BooleanList::Set(doc_bin->Main());
4489 boollist->Append(Standard_False);
4490 boollist->Append(Standard_True);
4491 // TDataStd_ReferenceList:
4492 TDF_Label Lbin1 = doc_bin->Main().FindChild(100);
4493 TDF_Tool::Entry(Lbin1, entry1);
4494 TDF_Label Lbin2 = doc_bin->Main().FindChild(101);
4495 TDF_Tool::Entry(Lbin2, entry2);
4496 reflist = TDataStd_ReferenceList::Set(doc_bin->Main());
4497 reflist->Append(Lbin1);
4498 reflist->Append(Lbin2);
4499 // TDataStd_BooleanArray:
4500 boolarr = TDataStd_BooleanArray::Set(doc_bin->Main(), 15, 24);
4501 boolarr->SetValue(15, Standard_False);
4502 boolarr->SetValue(16, Standard_True);
4503 boolarr->SetValue(17, Standard_True);
4504 boolarr->SetValue(18, Standard_True);
4505 boolarr->SetValue(19, Standard_True);
4506 boolarr->SetValue(20, Standard_True);
4507 boolarr->SetValue(21, Standard_False);
4508 boolarr->SetValue(22, Standard_True);
4509 boolarr->SetValue(23, Standard_True);
4510 boolarr->SetValue(24, Standard_True);
4511 // TDataStd_ReferenceArray:
4512 refarr = TDataStd_ReferenceArray::Set(doc_bin->Main(), 0, 1);
4513 refarr->SetValue(0, Lbin1);
4514 refarr->SetValue(1, Lbin2);
4515 // TDataStd_ByteArray:
4516 bytearr = TDataStd_ByteArray::Set(doc_bin->Main(), 15, 16);
4517 bytearr->SetValue(15, 0);
4518 bytearr->SetValue(16, 255);
4519 // TDataStd_NamedData:
4520 nameddata = TDataStd_NamedData::Set(doc_bin->Main());
4521 nameddata->SetByte("A", 12);
4522 nameddata->SetByte("B", 234);
4523 // TDF_Reference:
4524 Lstd3 = doc_bin->Main().FindChild(103);
4525 ref = TDF_Reference::Set(doc_bin->Main(), Lstd3);
4526 //
4527 // Save
4528 //if (app->SaveAs(doc_bin, "W:\\doc.cbf") != CDF_SS_OK)
4529 if (app->SaveAs(doc_bin, aFile3) != CDF_SS_OK)
4530 return 1;
4531 intlist.Nullify();
4532 ref.Nullify();
4533 app->Close(doc_bin);
4534 doc_bin.Nullify();
4535 //if (app->Open("W:\\doc.cbf", doc_bin_open) != CDF_RS_OK)
4536 if (app->Open(aFile3, doc_bin_open) != CDF_RS_OK)
4537 return 2;
4538 if (!doc_bin_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4539 return 3;
4540 if (!doc_bin_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4541 return 4;
4542 if (intlist->First() != 1)
4543 return 5;
4544 if (intlist->Last() != 5)
4545 return 6;
4546 if (!doc_bin_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4547 return 4;
4548 if (dbllist->First() != 1.5)
4549 return 5;
4550 if (dbllist->Last() != 5.5)
4551 return 6;
4552 if (!doc_bin_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4553 return 4;
4554 if (strlist->First() != "Bonjour")
4555 return 5;
4556 if (strlist->Last() != "Bonsoir")
4557 return 6;
4558 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4559 return 4;
4560 if (boollist->First() != Standard_False)
4561 return 5;
4562 if (boollist->Last() != Standard_True)
4563 return 6;
4564 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4565 return 4;
4566 TDF_Tool::Entry(reflist->First(), entry_first);
4567 if (entry1 != entry_first)
4568 return 5;
4569 TDF_Tool::Entry(reflist->Last(), entry_last);
4570 if (entry2 != entry_last)
4571 return 6;
4572 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4573 return 4;
4574 if (boolarr->Value(15) != Standard_False)
4575 return 5;
4576 if (boolarr->Value(16) != Standard_True)
4577 return 5;
4578 if (boolarr->Value(17) != Standard_True)
4579 return 5;
4580 if (boolarr->Value(18) != Standard_True)
4581 return 5;
4582 if (boolarr->Value(19) != Standard_True)
4583 return 5;
4584 if (boolarr->Value(20) != Standard_True)
4585 return 5;
4586 if (boolarr->Value(21) != Standard_False)
4587 return 5;
4588 if (boolarr->Value(22) != Standard_True)
4589 return 5;
4590 if (boolarr->Value(23) != Standard_True)
4591 return 5;
4592 if (boolarr->Value(24) != Standard_True)
4593 return 5;
4594 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4595 return 4;
4596 TDF_Tool::Entry(refarr->Value(0), entry_first);
4597 if (entry1 != entry_first)
4598 return 5;
4599 TDF_Tool::Entry(refarr->Value(1), entry_last);
4600 if (entry2 != entry_last)
4601 return 6;
4602 if (!doc_bin_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4603 return 4;
4604 if (bytearr->Value(15) != 0)
4605 return 5;
4606 if (bytearr->Value(16) != 255)
4607 return 5;
4608 if (!doc_bin_open->Main().FindAttribute(TDataStd_NamedData::GetID(), nameddata))
4609 return 4;
4610 if (nameddata->GetByte("A") != 12)
4611 return 5;
4612 if (nameddata->GetByte("B") != 234)
4613 return 5;
4614 if (!doc_bin_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4615 return 4;
4616 if (ref->Get().IsNull())
4617 return 5;
4618 if (ref->Get().Tag() != 103)
4619 return 5;
4620
4621 return 0;
4622}
4623// For OCC16782 testing
4624
4625static Standard_Integer OCC16782 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4626{
4627 if (argc != 4)
4628 {
4629 di << "Usage : " << argv[0] << " file.std file.xml file.cbf\n";
4630 return 1;
4631 }
4632 TCollection_ExtendedString aFile1(argv[1]);
4633 TCollection_ExtendedString aFile2(argv[2]);
4634 TCollection_ExtendedString aFile3(argv[3]);
4635
4636 if (app.IsNull())
4637 app = new AppStd_Application();
4638
4639 int good = 0;
4640
4641 Handle(TDocStd_Document) doc;
4642 app->NewDocument("MDTV-Standard", doc);
4643 doc->SetUndoLimit(10);
4644
4645 di <<"\nTestSetGet start\n";
4646 good += TestSetGet(doc);
4647 di <<"TestSetGet finish\n";
4648 di <<"Status = " << good << "\n";
4649
4650 di <<"\nTestUndoRedo start\n";
4651 good += TestUndoRedo(doc);
4652 di <<"TestUndoRedo finish\n";
4653 di <<"Status = " << good << "\n";
4654
4655 di <<"\nTestCopyPaste start\n";
4656 good += TestCopyPaste(doc);
4657 di <<"TestCopyPaste finish\n";
4658 di <<"Status = " << good << "\n";
4659
4660 di <<"\nTestOpenSave start\n";
4661 good += TestOpenSave(aFile1, aFile2, aFile3);
4662 di <<"TestOpenSave finish\n";
4663 di <<"Status = " << good << "\n";
4664
4665 if (!good)
4666 di <<"\nThe " << argv[0] << " test is passed well, OK\n";
4667 else
4668 di <<"\nThe " << argv[0] << " test failed, Faulty\n";
4669
4670 return 0;
4671}
4672
4673static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4674{
4675 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4676 if(aContext.IsNull()) {
4677 di << argv[0] << " ERROR : use 'vinit' command before " << "\n";
4678 return -1;
4679 }
4680
4681 if (argc > 2)
4682 {
4683 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4684 return 1;
4685 }
4686 Standard_Integer mode = 0;
4687 if (argc == 2)
4688 {
4689 mode = atoi(argv[1]);
4690 }
4691 if (mode > 2 || mode < 0)
4692 {
4693 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4694 return 1;
4695 }
4696 Handle(V3d_View) V = ViewerTest::CurrentView();
4697 if ( !V.IsNull() ) {
4698 if (mode == 0) {
4699 V->ColorScaleDisplay();
4700 }
4701 if (mode == 1) {
4702 V->ColorScaleErase();
4703 V->UpdateLights();
4704 V->Update();
4705 }
4706 if (mode == 2) {
4707 Standard_Boolean IsDisplayed = V->ColorScaleIsDisplayed();
4708 if (IsDisplayed)
4709 di <<"ColorScaleIsDisplayed = " << "1" << "\n";
4710 else
4711 di <<"ColorScaleIsDisplayed = " << "0" << "\n";
4712 }
4713 }
4714 return 0;
4715}
4716
4717#include <Interface_Macros.hxx>
4718#include <IGESControl_Controller.hxx>
4719#include <XSDRAW.hxx>
4720#include <Draw_ProgressIndicator.hxx>
4721#include <XSControl_WorkSession.hxx>
4722#include <Transfer_TransientProcess.hxx>
4723#include <XSDRAW_Commands.hxx>
4724#include <TColStd_HSequenceOfTransient.hxx>
4725#include <Message_ProgressSentry.hxx>
4726#include <XSControl_TransferReader.hxx>
4727
4728static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4729{
4730 DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
4731 if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
4732
4733 // Progress indicator
4734 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
4735 progress->SetScale ( 0, 100, 1 );
4736 progress->Show();
4737
4738 IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
4739 if (ctl.IsNull())
4740 ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
4741
4742 TCollection_AsciiString fnom,rnom;
4743
4744 Standard_Boolean modfic = XSDRAW::FileAndVar
4745 (argv[1],argv[2],"IGESBREP",fnom,rnom);
4746 if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
4747 else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
4748 di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
4749 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
4750
4751#ifdef CHRONOMESURE
4752 OSD_Timer Chr; Chr.Reset();
4753 IDT_SetLevel(3);
4754#endif
4755
4756
4757// Reading the file
4758 progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
4759 progress->Show();
4760
4761 // *New*
4762 //In order to decrease number of produced edges during translation it is possible to set following parameter
4763 Interface_Static::SetIVal("read.iges.bspline.continuity",0);
4764 // *New*
4765
4766 if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
4767 else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
4768
4769 progress->EndScope();
4770 progress->Show();
4771
4772 if (readstat != IFSelect_RetDone) {
4773 if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon"<<"\n";
4774 else di<<"No model loaded"<<"\n";
4775 return 1;
4776 }
4777// Choice of treatment
4778 Standard_Boolean fromtcl = (argc > 3);
4779 Standard_Integer modepri = 1, nent, nbs;
4780 if (fromtcl) modepri = 4;
4781
4782 while (modepri) {
4783 //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka
4784 //mode OnlyVisible does not work.
4785 // nent = Reader.NbRootsForTransfer();
4786 if (!fromtcl) {
4787 cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<flush;
4788 modepri = -1;
4789
4790// amv 26.09.2003 : this is used to avoid error of enter's simbol
4791 char str[80];
4792 cin>>str;
4793 modepri = atoi(str);
4794 }
4795
4796 if (modepri == 0) { //fin
4797 di << "Bye and good luck! " << "\n";
4798 break;
4799 }
4800
4801 else if (modepri <= 2) { // 1 : Visible Roots, 2 : All Roots
4802 di << "All Geometry Transfer"<<"\n";
4803 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
4804 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
4805 Handle(XSControl_WorkSession) thesession = Reader.WS();
4806 thesession->ClearContext();
4807 XSDRAW::SetTransferProcess (thesession->MapReader());
4808 progress->NewScope ( 80, "Translation" );
4809 progress->Show();
4810 thesession->MapReader()->SetProgress ( progress );
4811
4812 if (modepri == 1) Reader.SetReadVisible (Standard_True);
4813 Reader.TransferRoots();
4814
4815 thesession->MapReader()->SetProgress ( 0 );
4816 progress->EndScope();
4817 progress->Show();
4818 // result in only one shape for all the roots
4819 // or in one shape for one root.
4820 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
4821 Standard_Integer answer = 1;
4822 if (Reader.NbShapes() > 1) {
4823 cout << " pass(0) one shape for all (1)\n or one shape per root (2)\n + WriteBRep (one for all : 3) (one per root : 4) : " << flush;
4824 answer = -1;
4825 //amv 26.09.2003
4826 char str_a[80];
4827 cin >> str_a;
4828 answer = atoi(str_a);
4829 }
4830 if ( answer == 0) continue;
4831 if ( answer == 1 || answer == 3) {
4832 TopoDS_Shape shape = Reader.OneShape();
4833 // save the shape
4834 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
4835 char fname[110];
4836 sprintf(fname, "%s", rnom.ToCString());
4837 di << "Saving shape in variable Draw : " << fname << "\n";
4838 if (answer == 3) IGESToBRep::WriteShape (shape,1);
4839 try {
4840 OCC_CATCH_SIGNALS
4841 DBRep::Set(fname,shape);
4842 }
4843 catch(Standard_Failure) {
4844 di << "** Exception : ";
4845 di << Standard_Failure::Caught()->GetMessageString();
4846 di<<" ** Skip"<<"\n";
4847 di << "Saving shape in variable Draw : " << fname << "\n";
4848 IGESToBRep::WriteShape (shape,1);
4849 }
4850 }
4851
4852 else if (answer == 2 || answer == 4) {
4853 Standard_Integer numshape = Reader.NbShapes();
4854 for (Standard_Integer inum = 1; inum <= numshape; inum++) {
4855 // save all the shapes
4856 TopoDS_Shape shape = Reader.Shape(inum);
4857 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
4858 char fname[110];
4859 sprintf(fname, "%s_%d", rnom.ToCString(),inum);
4860 di << "Saving shape in variable Draw : " << fname << "\n";
4861 if (answer == 4) IGESToBRep::WriteShape (shape,inum);
4862 try {
4863 OCC_CATCH_SIGNALS
4864 DBRep::Set(fname,shape);
4865 }
4866 catch(Standard_Failure) {
4867 di << "** Exception : ";
4868 di << Standard_Failure::Caught()->GetMessageString();
4869 di<<" ** Skip"<<"\n";
4870 }
4871 }
4872 }
4873 else return 0;
4874 }
4875
4876 else if (modepri == 3) { // One Entity
4877 cout << "Only One Entity"<<endl;
4878 cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<endl;
4879 cout<<" To modify : command param read.iges.bspline.continuity"<<endl;
4880 cout << " give the number of the Entity : " << flush;
4881 nent = XSDRAW::GetEntityNumber();
4882
4883 if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
4884 else {
4885 nbs = Reader.NbShapes();
4886 char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nent);
4887 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
4888 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
4889 TopoDS_Shape sh = Reader.Shape(nbs);
4890 DBRep::Set (shname,sh);
4891 }
4892 }
4893
4894 else if (modepri == 4) { // Selection
4895 Standard_Integer answer = 1;
4896 Handle(TColStd_HSequenceOfTransient) list;
4897
4898// Selection, nommee ou via tcl. tcl : raccourcis admis
4899// * donne iges-visible + xst-transferrable-roots
4900// *r donne xst-model-roots (TOUTES racines)
4901
4902 if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {
4903 di << "All Geometry Transfer"<<"\n";
4904 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
4905 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
4906 Handle(XSControl_WorkSession) thesession = Reader.WS();
4907 thesession->ClearContext();
4908 XSDRAW::SetTransferProcess (thesession->MapReader());
4909 progress->NewScope ( 80, "Translation" );
4910 progress->Show();
4911 thesession->MapReader()->SetProgress ( progress );
4912
4913 Reader.SetReadVisible (Standard_True);
4914 Reader.TransferRoots();
4915
4916 thesession->MapReader()->SetProgress ( 0 );
4917 progress->EndScope();
4918 progress->Show();
4919
4920 // result in only one shape for all the roots
4921 TopoDS_Shape shape = Reader.OneShape();
4922 // save the shape
4923 char fname[110];
4924 sprintf(fname, "%s", rnom.ToCString());
4925 di << "Saving shape in variable Draw : " << fname << "\n";
4926 try {
4927 OCC_CATCH_SIGNALS
4928 DBRep::Set(fname,shape);
4929 }
4930 catch(Standard_Failure) {
4931 di << "** Exception : ";
4932 di << Standard_Failure::Caught()->GetMessageString();
4933 di<<" ** Skip"<<"\n";
4934 di << "Saving shape in variable Draw : " << fname << "\n";
4935 IGESToBRep::WriteShape (shape,1);
4936 }
4937 return 0;
4938 }
4939
4940 if(fromtcl) {
4941 modepri = 0; // d office, une seule passe
4942 if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
4943 di<<"All Roots : ";
4944 list = XSDRAW::GetList ("xst-model-roots");
4945 }
4946 else {
4947 TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
4948 di<<"List given by "<<compart.ToCString()<<" : ";
4949 list = XSDRAW::GetList (compart.ToCString());
4950 }
4951 if (list.IsNull()) {
4952 di<<"No list defined. Give a selection name or * for all visible transferrable roots"<<"\n";
4953 continue;
4954 }
4955 }
4956 else {
4957 cout<<"Name of Selection :"<<flush;
4958 list = XSDRAW::GetList();
4959 if (list.IsNull()) { cout<<"No list defined"<<endl; continue; }
4960 }
4961
4962 Standard_Integer nbl = list->Length();
4963 di<<"Nb entities selected : "<<nbl<<"\n";
4964 if (nbl == 0) continue;
4965 while (answer) {
4966 if (!fromtcl) {
4967 cout<<"Choice: 0 abandon 1 transfer all 2 with confirmation 3 list n0s ents :"<<flush;
4968 answer = -1;
4969 // anv 26.09.2003
4970 char str_answer[80];
4971 cin>>str_answer;
4972 answer = atoi(str_answer);
4973 }
4974 if (answer <= 0 || answer > 3) continue;
4975 if (answer == 3) {
4976 for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
4977 Handle(Standard_Transient) ent = list->Value(ill);
4978 di<<" ";// model->Print(ent,di);
4979 }
4980 di<<"\n";
4981 }
4982 if (answer == 1 || answer == 2) {
4983 Standard_Integer nbt = 0;
4984 Handle(XSControl_WorkSession) thesession = Reader.WS();
4985
4986 XSDRAW::SetTransferProcess (thesession->MapReader());
4987 progress->NewScope ( 80, "Translation" );
4988 progress->Show();
4989 thesession->MapReader()->SetProgress ( progress );
4990
4991 Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
4992 for (Standard_Integer ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
4993
4994 nent = Reader.Model()->Number(list->Value(ill));
4995 if (nent == 0) continue;
4996 if (!Reader.TransferOne(nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
4997 else {
4998 nbs = Reader.NbShapes();
4999 char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
5000 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
5001 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
5002 TopoDS_Shape sh = Reader.Shape(nbs);
5003 DBRep::Set (shname,sh);
5004 nbt++;
5005 }
5006 }
5007 thesession->MapReader()->SetProgress ( 0 );
5008 progress->EndScope();
5009 progress->Show();
5010 di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
5011 answer = 0; // on ne reboucle pas
5012 }
5013 }
5014 }
5015 else di<<"Unknown mode n0 "<<modepri<<"\n";
5016 }
5017
5018 // *New*
5019 //In order to clear memory after IGES reading you could add the following code
5020 Handle(XSControl_TransferReader) TR = Reader.WS()->TransferReader();
5021 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
5022 TP->Clear();
5023 TR->Clear(2);
5024 Reader.WS()->Model()->Clear();
5025 Standard_Integer i =1;
5026 for( ; i <= 7; i++)
5027 Reader.WS()->ClearData(i);
5028 // *New*
5029
5030 return 0;
5031}
5032
5033#include <Geom_Plane.hxx>
5034static Standard_Integer OCC20766 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5035{
5036 if (argc != 6)
5037 {
5038 di << "Usage : " << argv[0] << " plane a b c d\n";
5039 return 1;
5040 }
5041
5042 Standard_Real A = atof(argv[2]);
5043 Standard_Real B = atof(argv[3]);
5044 Standard_Real C = atof(argv[4]);
5045 Standard_Real D = atof(argv[5]);
5046
5047 Handle(Geom_Geometry) result;
5048
5049 Handle(Geom_Plane) aPlane = new Geom_Plane(A, B, C, D);
5050 result = aPlane;
5051
5052 DrawTrSurf::Set(argv[1],result);
5053 return 0;
5054}
5055
5056static Standard_Integer OCC20627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5057{
5058 if(argc!=2)
5059 {
5060 di << "Usage : " << argv[0] << " MaxNbr" << "\n";
5061 return -1;
5062 }
5063 Standard_Integer aMaxNbr = atoi(argv[1]);
5064
5065 for (Standard_Integer i=0;i<aMaxNbr;i++)
5066 {
5067 BRepBuilderAPI_MakePolygon w(gp_Pnt(0,0,0),gp_Pnt(0,100,0),gp_Pnt(20,100,0),gp_Pnt(20,0,0));
5068 w.Close();
5069 TopoDS_Wire wireShape( w.Wire());
5070 BRepBuilderAPI_MakeFace faceBuilder(wireShape);
5071 TopoDS_Face f( faceBuilder.Face());
5072 BRepMesh_IncrementalMesh im(f,1);
5073 BRepTools::Clean(f);
5074 }
5075 return 0;
5076}
5077
5078#include <IntCurvesFace_ShapeIntersector.hxx>
5079#include <gp_Lin.hxx>
5080Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5081{
5082 if(argc!=9)
5083 {
5084 di << "Usage : " << argv[0] << " shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf" << "\n";
5085 return -1;
5086 }
5087
5088 TopoDS_Shape shape = DBRep::Get(argv[1]);
5089
5090 if (shape.IsNull()) {
5091 di<<" Null shape is not allowed";
5092 return 1;
5093 }
5094
5095 Standard_Real X_Pnt = atof(argv[2]);
5096 Standard_Real Y_Pnt = atof(argv[3]);
5097 Standard_Real Z_Pnt = atof(argv[4]);
5098
5099 Standard_Real X_Dir = atof(argv[5]);
5100 Standard_Real Y_Dir = atof(argv[6]);
5101 Standard_Real Z_Dir = atof(argv[7]);
5102
5103 Standard_Real PInf = atof(argv[8]);
5104
5105 IntCurvesFace_ShapeIntersector intersector;
5106 intersector.Load(shape, Precision::Intersection());
5107
5108 gp_Pnt origin(X_Pnt, Y_Pnt, Z_Pnt);
5109 gp_Dir dir(X_Dir, Y_Dir, Z_Dir);
5110 gp_Lin ray(origin, dir);
5111
5112 Standard_Real PSup = RealLast();
5113 intersector.PerformNearest(ray, PInf, PSup);
5114 if (intersector.NbPnt() != 0)
5115 {
5116 di << argv[0] << " status = 0 \n";
5117 Standard_Real w = intersector.WParameter(1);
5118 di << "w = " << w << "\n";
5119 } else {
5120 di << argv[0] << " status = -1 \n";
5121 }
5122 return 0;
5123}
5124
5125void QAOCC::Commands(Draw_Interpretor& theCommands) {
5126 const char *group = "QAOCC";
5127
5128 theCommands.Add("OCC128", "OCC128", __FILE__, OCC128, group);
5129
5130 // Remove as bad version of QAAddOrRemoveSelected from QADraw
5131 //theCommands.Add("OCC129", "OCC129 shape islocal", __FILE__, OCC129, group);
5132
5133 theCommands.Add("OCC136", "OCC136", __FILE__, OCC136, group);
5134 theCommands.Add("BUC60610","BUC60610 iges_input [name]",__FILE__,BUC60610,group);
5135 theCommands.Add("BUC60661","BUC60661 file.igs",__FILE__,BUC60661, group);
5136
5137//====================================================
5138//
5139// Following commands are inserted from
5140// /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
5141// ( 75455 Apr 16 18:59)
5142//
5143//====================================================
5144
5145 theCommands.Add("OCC105","OCC105 shape",__FILE__,OCC105,group);
5146 theCommands.Add("OCC9"," result path cur1 cur2 radius [tolerance]:\t test GeomFill_Pipe", __FILE__, pipe_OCC9,group);
5147
5148 theCommands.Add("OCC125","OCC125 shell", __FILE__, OCC125,group);
5149
5150 theCommands.Add("OCC157","findplanarsurface Result wire Tol",__FILE__,OCC157,group);
5151 //theCommands.Add("OCC165","OCC165",__FILE__,OCC165,group);
5152 theCommands.Add("OCC165","OCC165 file",__FILE__,OCC165,group);
5153 theCommands.Add("OCC297","OCC297",__FILE__,OCC297,group);
5154 //theCommands.Add("OCC305","OCC305",__FILE__,OCC305,group);
5155 theCommands.Add("OCC305","OCC305 file",__FILE__,OCC305,group);
5156
5157 // New commands:
5158 theCommands.Add("OCC166", "OCC166", __FILE__, OCC166, group);
5159 theCommands.Add("OCC381_Save", "OCC381_Save Doc", __FILE__, OCC381_Save, group);
5160 theCommands.Add("OCC381_SaveAs", "OCC381_SaveAs Doc Path", __FILE__, OCC381_SaveAs, group);
5161
5162 theCommands.Add("OCC299","OCC299 Solid Point [Tolerance=1.e-7]", __FILE__, OCC299bug, group);
5163 theCommands.Add("OCC309","OCC309", __FILE__, OCC309bug, group);
5164 theCommands.Add("OCC310","OCC310", __FILE__, OCC310bug, group);
5165
5166 //theCommands.Add("OCC277","OCC277", __FILE__, OCC277bug, group);
5167 theCommands.Add("OCC277","OCC277 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC277bug, group);
5168
5169 theCommands.Add("OCC333","OCC333 edge1 edge2 [toler domaindist]; Check overlapping edges", __FILE__, OCC333bug, group);
5170
5171 theCommands.Add("OCC363", "OCC363 document filename ", __FILE__, OCC363, group);
5172 // Must use OCC299
5173 //theCommands.Add("OCC372", "OCC372", __FILE__, OCC372, group);
5174 theCommands.Add("OCC377", "OCC377", __FILE__, OCC377, group);
5175 theCommands.Add("OCC22", "OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation", __FILE__, OCC22, group);
5176 theCommands.Add("OCC24", "OCC24 Result Shape CompoundOfSubshapes ResourceFileName", __FILE__, OCC24, group);
5177 theCommands.Add("OCC369", "OCC369 Shape", __FILE__, OCC369, group);
5178 theCommands.Add("OCC524", "OCC524 LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix", __FILE__, OCC524, group);
5179 theCommands.Add("OCC525", "OCC525", __FILE__, OCC525, group);
5180 theCommands.Add("OCC543", "OCC543 name", __FILE__, OCC543, group);
5181 //theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
5182 theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC578, group);
5183 theCommands.Add("OCC627", "OCC627", __FILE__, OCC627, group);
5184 theCommands.Add("OCC749_sav", "OCC749_sav Reflection(=0/1) R1 G1 B1 R2 G2 B2", __FILE__, OCC749_sav, group);
5185 theCommands.Add("OCC669", "OCC669 GUID", __FILE__, OCC669, group);
5186 theCommands.Add("OCC738_ShapeRef", "OCC738_ShapeRef", __FILE__, OCC738_ShapeRef, group);
5187 theCommands.Add("OCC738_Assembly", "OCC738_Assembly", __FILE__, OCC738_Assembly, group);
5188 theCommands.Add("OCC708", "OCC708 shape ; Deactivate the current transformation", __FILE__, OCC708, group);
5189 theCommands.Add("OCC670", "OCC670", __FILE__, OCC670, group);
5190 theCommands.Add("OCC867", "OCC867 Point Surface Umin Usup Vmin Vsup", __FILE__, OCC867, group);
5191 theCommands.Add("OCC909", "OCC909 wire face", __FILE__, OCC909, group);
5192 theCommands.Add("OCC921", "OCC921 face", __FILE__, OCC921, group);
5193 theCommands.Add("OCC902", "OCC902 expression", __FILE__, OCC902, group);
5194
5195 theCommands.Add ("OCC1029_AISTransparency","OCC1029_AISTransparency (DOC, entry, [real])",__FILE__, OCC1029_AISTransparency, group);
5196 theCommands.Add ("OCC1030_AISColor", "OCC1030_AISColor (DOC, entry, [color])", __FILE__, OCC1030_AISColor, group);
5197 theCommands.Add ("OCC1031_AISMaterial", "OCC1031_AISMaterial (DOC, entry, [material])", __FILE__, OCC1031_AISMaterial, group);
5198 theCommands.Add ("OCC1032_AISWidth", "OCC1032_AISWidth (DOC, entry, [width])", __FILE__, OCC1032_AISWidth, group);
5199 theCommands.Add ("OCC1033_AISMode", "OCC1033_AISMode (DOC, entry, [mode])", __FILE__, OCC1033_AISMode, group);
5200 theCommands.Add ("OCC1034_AISSelectionMode", "OCC1034_AISSelectionMode (DOC, entry, [selectionmode])", __FILE__, OCC1034_AISSelectionMode, group);
5201
5202 //theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape", __FILE__, OCC1487, group);
5203 theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC1487, group);
5204
5205 theCommands.Add("OCC1077", "OCC1077 result", __FILE__, OCC1077, group);
5206 theCommands.Add("OCC5739", "OCC5739 name shape step", __FILE__, OCC5739_UniAbs, group);
5207 theCommands.Add("OCC6046", "OCC6046 nb_of_vectors size", __FILE__, OCC6046, group);
5208 theCommands.Add("OCC5698", "OCC5698 wire", __FILE__, OCC5698, group);
5209 theCommands.Add("OCC6143", "OCC6143", __FILE__, OCC6143, group);
5210 theCommands.Add("OCC7141", "OCC7141 [nCount]", __FILE__, OCC7141, group);
5211 theCommands.Add("OCC7372", "OCC7372", __FILE__, OCC7372, group);
5212 theCommands.Add("OCC8169", "OCC8169 edge1 edge2 plane", __FILE__, OCC8169, group);
5213 theCommands.Add("OCC10138", "OCC10138 lower upper", __FILE__, OCC10138, group);
5214 theCommands.Add("OCC7639", "OCC7639 index1 value1 ... [indexN valueN]", __FILE__, OCC7639, group);
5215 theCommands.Add("OCC8797", "OCC8797", __FILE__, OCC8797, group);
5216 theCommands.Add("OCC7068", "OCC7068", __FILE__, OCC7068, group);
5217 theCommands.Add("OCC11457", "OCC11457 polygon lastedge x1 y1 z1 x2 y2 z2 ...", __FILE__, OCC11457, group);
5218 theCommands.Add("OCC13963", "OCC13963 ratio origin_x origin_y origin_z", __FILE__, OCC13963, group);
5219 theCommands.Add("OCC14376", "OCC14376 shape [deflection]", __FILE__, OCC14376, group);
5220 theCommands.Add("OCC15489", "OCC15489 A B C", __FILE__, OCC15489, group);
5221 theCommands.Add("OCC15755", "OCC15755 file shape", __FILE__, OCC15755, group);
5222 theCommands.Add("OCC16782", "OCC16782 file.std file.xml file.cbf", __FILE__, OCC16782, group);
5223 theCommands.Add("OCC12584", "OCC12584 [mode = 0/1/2]", __FILE__, OCC12584, group);
5224 theCommands.Add("OCC18612", "OCC18612 [file else already loaded model] [name DRAW]", __FILE__, OCC18612igesbrep, group);
5225 theCommands.Add("OCC20766", "OCC20766 plane a b c d", __FILE__, OCC20766, group);
5226 theCommands.Add("OCC20627", "OCC20627", __FILE__, OCC20627, group);
5227 theCommands.Add("OCC17424", "OCC17424 shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf", __FILE__, OCC17424, group);
5228 return;
5229}