0022762: Bug in Graphic3d_Vector::IsParallel
[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>
15e8b082 791#include <PCDM_StoreStatus.hxx>
7fd59977 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 }
15e8b082
M
812 PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
813 if (theStatus != PCDM_SS_OK ) {
7fd59977 814 switch ( theStatus ) {
15e8b082 815 case PCDM_SS_DriverFailure: {
7fd59977 816 di << " Could not store , no driver found to make it " <<"\n" ;
817 break ;
818 }
15e8b082 819 case PCDM_SS_WriteFailure: {
7fd59977 820 di << " Write access failure " << "\n" ;
821 break;
822 }
15e8b082 823 case PCDM_SS_Failure: {
7fd59977 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;
15e8b082
M
847 PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
848 if (theStatus != PCDM_SS_OK ) {
7fd59977 849 switch ( theStatus ) {
15e8b082 850 case PCDM_SS_DriverFailure: {
7fd59977 851 di << " Could not store , no driver found to make it " <<"\n" ;
852 break ;
853 }
15e8b082 854 case PCDM_SS_WriteFailure: {
7fd59977 855 di << " Write access failure " << "\n" ;
856 break;
857 }
15e8b082 858 case PCDM_SS_Failure: {
7fd59977 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;
15e8b082 1107 if(App->Open(name, Doc) != PCDM_RS_OK) { di << "Error OCC363 : document was not opened successfully\n"; return 1;}
7fd59977 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
c6541a0c 1283 ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(M_PI/2.);
7fd59977 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
c6541a0c 1387 BRepMesh_IncrementalMesh aMesh(aShape, 0.2, Standard_True, M_PI/6);
7fd59977 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
7fd59977 1672#include <Standard_GUID.hxx>
1673//=======================================================================
1674//function : OCC669
1675//purpose :
1676//=======================================================================
1677static Standard_Integer OCC669 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1678{
1679 if(argc != 2){
1680 di<<"Usage : " << argv[0] << " GUID\n";
1681 return -1;
1682 }
1683 Standard_GUID guid(argv[1]);
1684 //guid.ShallowDump(cout);
1685 Standard_SStream aSStream;
1686 guid.ShallowDump(aSStream);
1687 di << aSStream;
1688 di<<"\n";
1689 return 0;
1690}
1691
1692#include <XCAFDoc.hxx>
1693//=======================================================================
1694//function : OCC738_ShapeRef
1695//purpose :
1696//=======================================================================
1697static Standard_Integer OCC738_ShapeRef (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1698{
1699 if(argc != 1){
1700 di<<"Usage : " << argv[0] << "\n";
1701 return -1;
1702 }
1703 const Standard_GUID& guid = XCAFDoc::ShapeRefGUID ();
1704 //guid.ShallowDump(cout);
1705 Standard_SStream aSStream;
1706 guid.ShallowDump(aSStream);
1707 di << aSStream;
1708 return 0;
1709}
1710
1711//=======================================================================
1712//function : OCC738_Assembly
1713//purpose :
1714//=======================================================================
1715static Standard_Integer OCC738_Assembly (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1716{
1717 if(argc != 1){
1718 di<<"Usage : " << argv[0] << "\n";
1719 return -1;
1720 }
1721 const Standard_GUID& guid = XCAFDoc::AssemblyGUID ();
1722 //guid.ShallowDump(cout);
1723 Standard_SStream aSStream;
1724 guid.ShallowDump(aSStream);
1725 di << aSStream;
1726 return 0;
1727}
1728
1729#if defined(DDataStd_def01)
1730#include <DDataStd_DrawPresentation.hxx>
1731//=======================================================================
1732//function : OCC739_DrawPresentation
1733//purpose :
1734//=======================================================================
1735static Standard_Integer OCC739_DrawPresentation (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1736{
1737 if(argc != 1){
1738 di<<"Usage : " << argv[0] << "\n";
1739 return -1;
1740 }
1741 const Standard_GUID& guid = DDataStd_DrawPresentation::GetID() ;
1742 //guid.ShallowDump(cout);
1743 Standard_SStream aSStream;
1744 guid.ShallowDump(aSStream);
1745 di << aSStream;
1746 return 0;
1747}
1748#endif
1749
1750//=======================================================================
1751//function : OCC708
1752//purpose :
1753//=======================================================================
1754static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1755{
1756 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1757 if(aContext.IsNull()) {
1758 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
1759 return 1;
1760 }
1761
1762 if ( argc != 2) {
1763 di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation" << "\n";
1764 return 1;
1765 }
1766
1767 Standard_Boolean updateviewer = Standard_True, PutInCollector = Standard_True;
1768
1769 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1770
1771 TCollection_AsciiString aName(argv[1]);
1772 Handle(AIS_InteractiveObject) AISObj;
1773
1774 if(!aMap.IsBound2(aName)) {
1775 di << "Use 'vdisplay' before" << "\n";
1776 return 1;
1777 } else {
1778 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
1779 if(AISObj.IsNull()){
1780 di << argv[1] << " : No interactive object" << "\n";
1781 return 1;
1782 }
1783 AISObj->UnsetTransformation();
1784 if (!aContext->HasOpenedContext()) {
1785 aContext->OpenLocalContext();
1786 }
1787 aContext->Erase(AISObj, updateviewer, PutInCollector);
1788 aContext->UpdateCurrentViewer();
1789 aContext->Display(AISObj, updateviewer);
1790 aContext->UpdateCurrentViewer();
1791 }
1792 return 0;
1793}
1794
1795//=======================================================================
1796//function : OCC670
1797//purpose :
1798//=======================================================================
1799#include <TColStd_Array2OfInteger.hxx>
1800static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1801{
1802 if(argc != 1){
1803 di<<"Usage : " << argv[0] << "\n";
1804 return -1;
1805 }
1806 TColStd_Array2OfInteger Array2OfInteger(1,1,1,1);
1807 Array2OfInteger.SetValue(5,5,55);
1808 return 0;
1809}
1810
1811#include <GeomAPI_ProjectPointOnSurf.hxx>
1812//=======================================================================
1813//function : OCC867
1814//purpose :
1815//=======================================================================
1816static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1817{
1818 if (argc!=7)
1819 {
1820 di<<"Usage : " << argv[0] << " Point Surface Umin Usup Vmin Vsup \n";
1821 return 1;
1822 }
1823
1824 gp_Pnt aPoint3d;
1825 DrawTrSurf::GetPoint(argv[1],aPoint3d);
1826 Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
1827 Standard_Real Umin=atof(argv[3]);
1828 Standard_Real Usup=atof(argv[4]);
1829 Standard_Real Vmin=atof(argv[5]);
1830 Standard_Real Vsup=atof(argv[6]);
1831
1832 if (aSurface.IsNull()) {
1833 di << argv[2] << " Null surface \n" ;
1834 return 1;
1835 }
1836
1837 GeomAPI_ProjectPointOnSurf PonSurf;
1838 PonSurf.Init(aSurface, Umin, Usup, Vmin, Vsup);
1839 PonSurf.Perform(aPoint3d);
1840
1841 return 0;
1842}
1843
1844//=======================================================================
1845//function : OCC909
1846//purpose :
1847//=======================================================================
1848static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1849{
1850 if (argc!=3)
1851 {
1852 di<<"Usage : " << argv[0] << " wire face\n";
1853 return 1;
1854 }
1855
1856 TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
1857 TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
1858 if (awire.IsNull() || aface.IsNull()) {
1859 di << "Null object" << "\n";
1860 return 1;
1861 }
1862
1863 Standard_Integer count = 0;
1864 TopExp_Explorer TE(awire, TopAbs_VERTEX);
1865 if ( TE.More()) {
1866 BRepTools_WireExplorer WE;
1867 for ( WE.Init(awire,aface); WE.More(); WE.Next()) {
1868 TopoDS_Edge E = WE.Current();
1869 count++;
1870 }
1871 }
1872 di << "Count = " << count << "\n";
1873
1874 return 0;
1875}
1876
1877//=======================================================================
1878//function : OCC921
1879//purpose :
1880//=======================================================================
1881static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1882{
1883 if (argc =! 2)
1884 {
1885 di <<"Usage : " << argv[0] << " face"<<"\n";
1886 return 1;
1887 }
1888 Standard_Real u1, u2, v1, v2;
1889 TopoDS_Face F = TopoDS::Face( DBRep::Get(argv[1]) ); //read the shape
1890 if (F.IsNull())
1891 return 1;
1892 BRepTools::UVBounds(F, u1, u2, v1, v2);
1893 di << "Bounds: " << u1 << " " << u2 << " " << v1 << " " << v2 << "\n";
1894 return 0;
1895}
1896
1897#include <Expr_NamedUnknown.hxx>
1898#include <Expr_GeneralExpression.hxx>
1899#include <Expr_Exponential.hxx>
1900//=======================================================================
1901//function : OCC902
1902//purpose :
1903//=======================================================================
1904static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1905{
1906 if (argc =! 2)
1907 {
1908 di <<"Usage : " << argv[0] << " expression"<<"\n";
1909 return 1;
1910 }
1911
1912 TCollection_AsciiString myStr(argv[1]);
1913
1914 Handle (Expr_NamedUnknown) myNamed = new Expr_NamedUnknown(myStr);
1915 Handle (Expr_Exponential) oldExpr = new Expr_Exponential(myNamed);
1916 Handle (Expr_GeneralExpression) newExpr = oldExpr->Derivative(myNamed);
1917
1918
1919 TCollection_AsciiString res = newExpr->String();
1920 Standard_CString resStr = res.ToCString();
1921 TCollection_AsciiString res_old = oldExpr->String();
1922 Standard_CString res_oldStr = res_old.ToCString();
1923
1924
1925 di << "X = " << argv[1] << "\n";
1926 di << "Y = " << res_oldStr << "\n";
1927 di << "Y' = " << resStr << "\n";
1928
1929 return 0;
1930}
1931
1932#include <DDF.hxx>
1933#include <TPrsStd_AISViewer.hxx>
1934#include <TDF_Label.hxx>
1935#include <TPrsStd_AISPresentation.hxx>
1936//=======================================================================
1937//function : OCC1029_AISTransparency
1938//purpose : OCC1029_AISTransparency (DOC,entry,[real])
1939//=======================================================================
1940
1941static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
1942 Standard_Integer nb,
1943 const char ** arg)
1944{
1945 if (nb >= 3 ) {
1946 Handle(TDocStd_Document) D;
1947 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1948 TDF_Label L;
1949 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1950
1951 Handle(TPrsStd_AISViewer) viewer;
1952 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1953
1954 Handle(TPrsStd_AISPresentation) prs;
1955 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1956 if( nb == 4 ) {
1957 prs->SetTransparency(atof(arg[3]));
1958 TPrsStd_AISViewer::Update(L);
1959 }
1960 else {
1961 di << "Transparency = " << prs->Transparency() << "\n";
1962 }
1963 return 0;
1964 }
1965 }
1966 di << arg[0] << " : Error" << "\n";
1967 return 1;
1968}
1969
1970//=======================================================================
1971//function : OCC1030_AISColor
1972//purpose : OCC1030_AISColor (DOC,entry,[color])
1973//=======================================================================
1974
1975static Standard_Integer OCC1030_AISColor (Draw_Interpretor& di,
1976 Standard_Integer nb,
1977 const char ** arg)
1978{
1979 if (nb >= 3) {
1980 Handle(TDocStd_Document) D;
1981 if (!DDocStd::GetDocument(arg[1],D)) return 1;
1982 TDF_Label L;
1983 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
1984
1985 Handle(TPrsStd_AISViewer) viewer;
1986 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
1987
1988 Handle(TPrsStd_AISPresentation) prs;
1989 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1990 if( nb == 4 ) {
1991 prs->SetColor((Quantity_NameOfColor)atoi(arg[3]));
1992 TPrsStd_AISViewer::Update(L);
1993 }
1994 else
1995 di << "Color = " << prs->Color() << "\n";
1996 return 0;
1997 }
1998 }
1999 di << arg[0] << " : Error" << "\n";
2000 return 1;
2001}
2002
2003//=======================================================================
2004//function : OCC1031_AISMaterial
2005//purpose : OCC1031_AISMaterial (DOC,entry,[material])
2006//=======================================================================
2007
2008static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
2009 Standard_Integer nb,
2010 const char ** arg)
2011{
2012 if (nb >= 3) {
2013 Handle(TDocStd_Document) D;
2014 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2015 TDF_Label L;
2016 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2017
2018 Handle(TPrsStd_AISViewer) viewer;
2019 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2020
2021 Handle(TPrsStd_AISPresentation) prs;
2022 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2023 if( nb == 4 ) {
2024 prs->SetMaterial((Graphic3d_NameOfMaterial)atoi(arg[3]));
2025 TPrsStd_AISViewer::Update(L);
2026 }
2027 else {
2028 di << "Material = " << prs->Material() << "\n";
2029 }
2030 return 0;
2031 }
2032 }
2033 di << arg[0] << " : Error" << "\n";
2034 return 1;
2035}
2036
2037//=======================================================================
2038//function : OCC1032_AISWidth
2039//purpose : OCC1032_AISWidth (DOC,entry,[width])
2040//=======================================================================
2041
2042static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
2043 Standard_Integer nb,
2044 const char ** arg)
2045{
2046 if (nb >= 3) {
2047 Handle(TDocStd_Document) D;
2048 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2049 TDF_Label L;
2050 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2051
2052 Handle(TPrsStd_AISViewer) viewer;
2053 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2054
2055 Handle(TPrsStd_AISPresentation) prs;
2056 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2057 if( nb == 4 ) {
2058 prs->SetWidth(atof(arg[3]));
2059 TPrsStd_AISViewer::Update(L);
2060 }
2061 else {
2062 di << "Width = " << prs->Width() << "\n";
2063 }
2064 return 0;
2065 }
2066 }
2067 di << arg[0] << " : Error" << "\n";
2068 return 1;
2069}
2070
2071//=======================================================================
2072//function : OCC1033_AISMode
2073//purpose : OCC1033_AISMode (DOC,entry,[mode])
2074//=======================================================================
2075
2076static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
2077 Standard_Integer nb,
2078 const char ** arg)
2079{
2080 if (nb >= 3) {
2081 Handle(TDocStd_Document) D;
2082 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2083 TDF_Label L;
2084 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2085
2086 Handle(TPrsStd_AISViewer) viewer;
2087 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2088
2089 Handle(TPrsStd_AISPresentation) prs;
2090 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2091 if( nb == 4 ) {
2092 prs->SetMode(atoi(arg[3]));
2093 TPrsStd_AISViewer::Update(L);
2094 }
2095 else {
2096 di << "Mode = " << prs->Mode() << "\n";
2097 }
2098 return 0;
2099 }
2100 }
2101 di << arg[0] << " : Error" << "\n";
2102 return 1;
2103}
2104
2105//=======================================================================
2106//function : OCC1034_AISSelectionMode
2107//purpose : OCC1034_AISSelectionMode (DOC,entry,[selectionmode])
2108//=======================================================================
2109
2110static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
2111 Standard_Integer nb,
2112 const char ** arg)
2113{
2114 if (nb >= 3) {
2115 Handle(TDocStd_Document) D;
2116 if (!DDocStd::GetDocument(arg[1],D)) return 1;
2117 TDF_Label L;
2118 if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
2119
2120 Handle(TPrsStd_AISViewer) viewer;
2121 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
2122
2123 Handle(TPrsStd_AISPresentation) prs;
2124 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
2125 if( nb == 4 ) {
2126 prs->SetSelectionMode(atoi(arg[3]));
2127 TPrsStd_AISViewer::Update(L);
2128 }
2129 else {
2130 di << "SelectionMode = " << prs->SelectionMode() << "\n";
2131 }
2132 return 0;
2133 }
2134 }
2135 di << arg[0] << " : Error" << "\n";
2136 return 1;
2137}
2138
2139#include<BRepAlgoAPI_Cut.hxx>
2140#include<BRepAlgo_Cut.hxx>
2141//=======================================================================
2142//function : OCC1487
2143//purpose :
2144//=======================================================================
2145static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2146{
2147 //if(argc != 5) {
2148 // cerr << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape" << endl;
2149 // return -1;
2150 //}
2151 if(argc < 5 || argc > 6) {
2152 di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2153 return 1;
2154 }
2155 Standard_Boolean IsBRepAlgoAPI = Standard_True;
2156 if (argc == 6) {
2157 Standard_Integer IsB = atoi(argv[5]);
2158 if (IsB != 1) {
2159 IsBRepAlgoAPI = Standard_False;
2160// di << "Error: There is not BRepAlgo_Cut class" << "\n";
2161// return 1;
2162 }
2163 }
2164
2165 Standard_Integer CaseNumber = atoi(argv[1]);
2166
2167 //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
2168 gp_Dir myDir(1,0,0);
2169 gp_Pnt myPnt(0,-50,140);
2170 gp_Ax2 myAx2(myPnt, myDir);
2171 BRepPrimAPI_MakeCylinder o_mc1 (myAx2, 50,1000);
2172
2173 TopoDS_Shape cyl1 = o_mc1.Shape();
2174
2175 TopoDS_Shape cyl2;
2176 TopoDS_Shape o_cut_shape;
2177 if (CaseNumber == 1) {
c6541a0c
D
2178 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(21.65064, -50.0, 127.5),gp_Dir(-sin(M_PI/3), 0.0, 0.5)), 5, 150);
2179 gp_Dir myDir_mc2(-sin(M_PI/3), 0.0, 0.5);
7fd59977 2180 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2181 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2182 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2183
2184 cyl2 = o_mc2.Shape();
2185//#if ! defined(BRepAlgoAPI_def01)
2186// o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2187//#else
2188// o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2189//#endif
2190 if (IsBRepAlgoAPI) {
2191 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2192 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2193 } else {
2194 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2195 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2196 }
2197 } else {
c6541a0c
D
2198 //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(978.34936, -50.0, 127.5),gp_Dir(sin(M_PI/3), 0.0, 0.5)), 5, 150);
2199 gp_Dir myDir_mc2(-sin(M_PI/3), 0.0, 0.5);
7fd59977 2200 gp_Pnt myPnt_mc2(21.65064, -50.0, 127.5);
2201 gp_Ax2 myAx2_mc2(myPnt_mc2, myDir_mc2);
2202 BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
2203
2204 cyl2 = o_mc2.Shape();
2205//#if ! defined(BRepAlgoAPI_def01)
2206// o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2207//#else
2208// o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2209//#endif
2210 if (IsBRepAlgoAPI) {
2211 di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2212 o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
2213 } else {
2214 di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
2215 o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
2216 }
2217 }
2218
2219 DBRep::Set(argv[2],cyl1);
2220 DBRep::Set(argv[3],cyl2);
2221 DBRep::Set(argv[4],o_cut_shape);
2222
2223 return 0;
2224}
2225
2226#include<TopTools_ListIteratorOfListOfShape.hxx>
2227#include<BRepFilletAPI_MakeFillet.hxx>
2228//=======================================================================
2229//function : OCC1077
2230//purpose :
2231//=======================================================================
2232TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,const Standard_Real aRadius)
2233{
2234 Standard_Real t3d = 1.e-4;
2235 Standard_Real t2d = 1.e-5;
2236 Standard_Real ta = 1.e-2;
2237 Standard_Real fl = 1.e-3;
2238 Standard_Real tapp_angle = 1.e-2;
2239 GeomAbs_Shape blend_cont = GeomAbs_C1;
2240
2241 TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
2242
2243//#ifdef OCC40
2244// Handle_TopOpeBRepBuild_HBuilder build = aBoolenaOperation.Builder();
2245//#endif
2246 TopTools_ListIteratorOfListOfShape its;
2247
2248 TopoDS_Compound result;
2249 BRep_Builder B;
2250 B.MakeCompound(result);
2251
2252 TopExp_Explorer ex;
2253 for (ex.Init(ShapeCut, TopAbs_SOLID); ex.More(); ex.Next())
2254 {
2255 const TopoDS_Shape& cutsol = ex.Current();
2256
2257 BRepFilletAPI_MakeFillet fill(cutsol);
2258 fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
2259 fill.SetContinuity(blend_cont, tapp_angle);
2260//#ifdef OCC40
2261// its = build->Section();
2262//#else //OCC40DEV
2263 its = aBoolenaOperation.SectionEdges();
2264//#endif
2265 while (its.More())
2266 {
2267 TopoDS_Edge E = TopoDS::Edge(its.Value());
2268 fill.Add(aRadius, E);
2269 its.Next();
2270 }
2271
2272 fill.Build();
2273 if (fill.IsDone())
2274 {
2275 B.Add(result, fill.Shape());
2276 }
2277 else
2278 {
2279 B.Add(result, cutsol);
2280 }
2281 }
2282 return result;
2283}
2284
2285TopoDS_Shape OCC1077_cut_blend(const TopoDS_Shape& aShapeToCut, const TopoDS_Shape& aTool, const Standard_Real aRadius)
2286{
2287 //return OCC1077_boolbl(BRepAlgoAPI_Cut(aShapeToCut, aTool),aRadius);
2288 BRepAlgoAPI_Cut aCut(aShapeToCut, aTool);
2289 return OCC1077_boolbl(aCut,aRadius);
2290}
2291
2292//TopoDS_Shape OCC1077_common_blend(const TopoDS_Shape& aShape1, const TopoDS_Shape& aShape2, const Standard_Real aRadius)
2293//{
2294// return OCC1077_boolbl(BRepAlgoAPI_Common(aShape1, aShape2),aRadius);
2295//}
2296
2297TopoDS_Shape OCC1077_Bug()
2298{
2299 TopoDS_Shape theBox = BRepPrimAPI_MakeBox(gp_Pnt(-5, - 5, - 5), 10, 10, 10).Shape();
2300 TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(7).Shape();
2301
2302 TopoDS_Shape theCommon = BRepAlgoAPI_Common(theBox,theSphere);
2303 TopoDS_Shape theCylinder1 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, - 10),
2304 gp_Dir(0, 0, 1)), 3, 20).Shape();
2305 TopoDS_Shape theCylinder2 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(-10, 0, 0),
2306 gp_Dir(1, 0, 0)), 3, 20).Shape();
2307 TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
2308 gp_Dir(0, 1, 0)), 3, 20).Shape();
2309 TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
2310 Handle_ShapeFix_Shape fixer = new ShapeFix_Shape(theTmp1);
2311 fixer->Perform();
2312 theTmp1 = fixer->Shape();
2313 TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
2314 fixer->Init(theTmp2);
2315 fixer->Perform();
2316 theTmp2 = fixer->Shape();
2317 TopoDS_Shape theResult = OCC1077_cut_blend(theTmp2,theCylinder3,0.7);
2318 fixer->Init(theResult);
2319 fixer->Perform();
2320 theResult = fixer->Shape();
2321 return theResult;
2322}
2323
2324static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2325{
2326 if(argc < 1 || argc > 2) {
2327 di << "Usage : " << argv[0] << " result" << "\n";
2328 return 1;
2329 }
2330
2331 TopoDS_Shape S = OCC1077_Bug();
2332 DBRep::Set(argv[1],S);
2333
2334 return 0;
2335}
2336
2337//////////////////////////////////////////////////////////////
2338/*!
2339 * Compute uniform distribution of points using GCPnts_UniformAbscissa
2340 */
2341//////////////////////////////////////////////////////////////
2342static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2343{
2344 if (argc < 4)
2345 {
2346 di << "Usage : " << argv[0] << " name shape step" << "\n";
2347 return 1;
2348 }
2349 const char *name = argv[1];
2350 Adaptor3d_Curve *adapCurve=NULL;
2351 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
2352 if (!curve.IsNull())
2353 adapCurve = new GeomAdaptor_Curve(curve);
2354 else
2355 {
2356 TopoDS_Shape wire = DBRep::Get(argv[2]);
2357 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
2358 {
2359 di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected"<<"\n";
2360 return 1;
2361 }
2362 adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
2363 }
2364 double step = atof(argv[3]);
2365 GCPnts_UniformAbscissa aUni(*adapCurve, step);
2366 int res;
2367 if (!aUni.IsDone())
2368 {
2369 di << argv[0] <<" : fail"<<"\n";
2370 res = 1;
2371 }
2372 else
2373 {
2374 int i, np = aUni.NbPoints();
2375 for (i=0; i < np; i++)
2376 {
2377 double par = aUni.Parameter(i+1);
2378 gp_Pnt p = adapCurve->Value(par);
2379 char n[20], *pname=n;
2380 sprintf(n,"%s_%d",name,i+1);
2381 DrawTrSurf::Set(pname,p);
2382 di<<pname<<" ";
2383 }
2384 res = 0;
2385 }
2386 delete adapCurve;
2387 return res;
2388}
2389
2390static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2391{
2392 if (argc != 3)
2393 {
2394 di << "Usage : " << argv[0] << " nb_of_vectors size" << "\n";
2395 return 1;
2396 }
2397
2398 Standard_Integer nb = atoi(argv[1]);
2399 Standard_Integer sz = atoi(argv[2]);
2400 Standard_Real val = 10;
2401 math_Vector **pv = new math_Vector *[nb];
2402
2403 di<<"creating "<<nb<<" vectors "<<sz<<" elements each..."<<"\n";
2404 Standard_Integer i;
2405 for (i=0; i < nb; i++) {
2406 pv[i] = new math_Vector (1, sz, val);
2407 if ((i % (nb/10)) == 0) {
2408 di<<" "<<i;
2409 //cout.flush();
2410 di<<"\n";
2411 }
2412 }
2413 di<<" done"<<"\n";
2414 di<<"deleting them ..."<<"\n";
2415 for (i=0; i < nb; i++) {
2416 delete pv[i];
2417 if ((i % (nb/10)) == 0) {
2418 di<<" "<<i;
2419 //cout.flush();
2420 di<<"\n";
2421 }
2422 }
2423 di<<" done"<<"\n";
2424
2425 delete [] pv;
2426
2427 return 0;
2428}
2429
2430static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2431{
2432 if (argc != 2)
2433 {
2434 di << "Usage : " << argv[0] << " wire" << "\n";
2435 return 1;
2436 }
2437 TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
2438 if (shape.IsNull())
2439 return 1;
2440 TopoDS_Wire wire = TopoDS::Wire(shape);
2441 // create curve parameterised by curvilinear distance
2442 BRepAdaptor_CompCurve curve(wire,Standard_True);
2443 Standard_Real length = curve.LastParameter();
2444 Standard_Real need_length = length/2;
2445 gp_Pnt pnt;
2446 curve.D0(need_length,pnt);
2447 // create check_curve parameterised in a general way
2448 BRepAdaptor_CompCurve check_curve(wire);
2449 Standard_Real check_par =
2450 GCPnts_AbscissaPoint(check_curve, need_length, 0).Parameter();
2451 gp_Pnt check_pnt;
2452 check_curve.D0(check_par,check_pnt);
2453 // check that points are coinsiding
2454 Standard_Real error_dist = pnt.Distance(check_pnt);
2455 if (error_dist > Precision::Confusion()) {
2456 //cout.precision(3);
2457 di<<"error_dist = "<<error_dist<<
2458 " ( "<<error_dist/need_length*100<<" %)"<<"\n";
2459 return 0;
2460 }
2461 di<<"OK"<<"\n";
2462 return 0;
2463}
2464
2465static char sarr[2000];
2466static int si=1;
2467static int StackOverflow(int i = -1)
2468{
2469 char arr[2000];
2470 if (si == 1) {
2471 si = 0;
2472 memcpy(arr,sarr,2000);
2473 arr[1999]=0;
2474 int n = strlen(arr), s=0;
2475 while (n--)
2476 s += StackOverflow(i-1);
2477 return i + s + StackOverflow(i-1);
2478 }
2479 else if (i != 0) {
2480 return i + StackOverflow(i-1);
2481 }
2482 si = 1;
2483 return i;
2484}
2485
2486#ifdef WNT
2487// this code does not work with optimize mode on Windows
2488#pragma optimize( "", off )
2489#endif
2490static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2491{
2492 if (argc != 1)
2493 {
2494 di << "Usage : " << argv[0] << "\n";
2495 return 1;
2496 }
2497 Standard_Boolean Succes;
2498
2499 Succes = Standard_True;
2500 //OSD::SetSignal();
2501
2502 {//==== Test Divide ByZero (Integer) ========================================
2503 try{
2504 OCC_CATCH_SIGNALS
2505 di << "(Integer) Divide By Zero...";
2506 //cout.flush();
2507 di << "\n";
2508 Standard_Integer res, a =4, b = 0 ;
2509 res = a / b;
2510 di << " 4 / 0 = " << res << " Does not Caught... KO"<< "\n";
2511 Succes = Standard_False;
2512 }
2513#if defined(SOLARIS) || defined(WNT)
2514 catch(Standard_DivideByZero)
2515#else
2516 catch(Standard_NumericError)
2517#endif
2518 {
2519 di << " Ok"<< "\n";
2520 }
2521 catch(Standard_Failure) {
2522 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2523 di << " Caught (";
2524 di << Standard_Failure::Caught()->GetMessageString();
2525 di << ")... KO" << "\n";
2526 Succes = Standard_False;
2527 }
2528#ifndef NO_CXX_EXCEPTION
2529 // this case tests if (...) supersedes (Standard_*),
2530 // the normal behaviour is not
2531 catch(...) {
2532 di<<" unknown exception... (But) Ok"<<"\n";
2533 }
2534#endif
2535 }
2536
2537 {//==== Test Divide ByZero (Real) ===========================================
2538 try{
2539 OCC_CATCH_SIGNALS
2540 di << "(Real) Divide By Zero...";
2541 //cout.flush();
2542 di << "\n";
2543 Standard_Real res, a= 4.0, b=0.0;
2544 res = a / b;
2545 di << " 4.0 / 0.0 = " << res << " Does not Caught... KO"<< "\n";
2546 Succes = Standard_False;
2547 }
2548#if defined(SOLARIS) || defined(WNT)
2549 catch(Standard_DivideByZero)
2550#else
2551 catch(Standard_NumericError)
2552#endif
2553 {
2554 di << " Ok"<< "\n";
2555 }
2556 catch(Standard_Failure) {
2557 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2558 di << " Caught (";
2559 di << Standard_Failure::Caught()->GetMessageString();
2560 di << ")... KO" << "\n";
2561 Succes = Standard_False;
2562 }
2563 }
2564
2565 {//==== Test Overflow (Integer) =============================================
2566 try{
2567 OCC_CATCH_SIGNALS
2568 di << "(Integer) Overflow...";
2569 //cout.flush();
2570 di << "\n";
2571 Standard_Integer res, i=IntegerLast();
2572 res = i + 1;
2573 //++++ cout << " -- "<<res<<"="<<i<<"+1 Does not Caught... KO"<< endl;
2574 //++++ Succes = Standard_False;
2575 di << " "<<res<<"="<<i<<"+1 Does not Caught... (But) Ok"<< "\n";
2576 }
2577 catch(Standard_Overflow) {
2578 di << " Ok"<< "\n";
2579 }
2580 catch(Standard_Failure) {
2581 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2582 di << " Caught (";
2583 di << Standard_Failure::Caught()->GetMessageString();
2584 di << ")... KO" << "\n";
2585 Succes = Standard_False;
2586 }
2587 }
2588
2589 {//==== Test Overflow (Real) ================================================
2590 try{
2591 OCC_CATCH_SIGNALS
2592 di << "(Real) Overflow...";
2593 //cout.flush();
2594 di << "\n";
2595 Standard_Real res, r=RealLast();
2596 res = r * r;
2597
2598 sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
2599
2600 di << "-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<< "\n";
2601 Succes = Standard_False;
2602 }
2603#if defined(SOLARIS) || defined(WNT)
2604 catch(Standard_Overflow)
2605#else
2606 catch(Standard_NumericError)
2607#endif
2608 {
2609 di << " Ok"<< "\n";
2610 }
2611 catch(Standard_Failure) {
2612 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2613 di << " Caught (";
2614 di << Standard_Failure::Caught()->GetMessageString();
2615 di << ")... KO" << "\n";
2616 Succes = Standard_False;
2617 }
2618 }
2619
2620 {//==== Test Underflow (Real) ===============================================
2621 try{
2622 OCC_CATCH_SIGNALS
2623 di << "(Real) Underflow";
2624 //cout.flush();
2625 di << "\n";
2626 Standard_Real res, r=1.0e-308;
2627 res = r * r;
2628 //res = res + 1.;
2629 //++++ cout<<"-- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... KO"<<endl;
2630 //++++ Succes = Standard_False;
2631 di<<" -- "<<res<<"="<<r<<"*"<<r<<" Does not Caught... (But) Ok"<<"\n";
2632 }
2633#if defined(SOLARIS) || defined(WNT)
2634 catch(Standard_Underflow)
2635#else
2636 catch(Standard_NumericError)
2637#endif
2638 {
2639 di << " Ok"<< "\n";
2640 }
2641 catch(Standard_Failure) {
2642 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2643 di << " Caught (";
2644 di << Standard_Failure::Caught()->GetMessageString();
2645 di << ")... KO" << "\n";
2646 Succes = Standard_False;
2647 }
2648 }
2649
2650 {//==== Test Invalid Operation (Real) ===============================================
2651 try{
2652 OCC_CATCH_SIGNALS
2653 di << "(Real) Invalid Operation...";
2654 //cout.flush();
2655 di << "\n";
2656 Standard_Real res, r=-1;
2657 res = sqrt(r);
2658 di<<" "<<res<<"=sqrt("<<r<<") Does not Caught... KO"<<"\n";
2659 Succes = Standard_False;
2660 }
2661 catch(Standard_NumericError) {
2662 di << " Ok"<< "\n";
2663 }
2664 catch(Standard_Failure) {
2665 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2666 di << " Caught (";
2667 di << Standard_Failure::Caught()->GetMessageString();
2668 di << ")... KO" << "\n";
2669 Succes = Standard_False;
2670 }
2671 }
2672
2673 {//==== Test Access Violation ===============================================
2674 try {
2675 OCC_CATCH_SIGNALS
2676 di << "Segmentation Fault...";
2677 //cout.flush();
2678 di << "\n";
2679 int* pint=NULL;
2680 *pint = 4;
2681 di << " Does not Caught... KO"<<"\n";
2682 Succes = Standard_False;
2683 }
2684#ifdef WNT
2685 catch(OSD_Exception_ACCESS_VIOLATION)
2686#else
2687 catch(OSD_SIGSEGV)
2688#endif
2689 {
2690 di << " Ok"<< "\n";
2691 } catch(Standard_Failure) {
2692 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2693 di << " Caught (";
2694 di << Standard_Failure::Caught()->GetMessageString();
2695 di << ")... KO" << "\n";
2696 Succes = Standard_False;
2697 }
2698 }
2699
2700#ifdef WNT
2701 {//==== Test Stack Overflow ===============================================
2702 try {
2703 OCC_CATCH_SIGNALS
2704 di << "Stack Overflow...";
2705 //cout.flush();
2706 di << "\n";
2707 StackOverflow();
2708 di << " Does not Caught... KO"<<"\n";
2709 Succes = Standard_False;
2710 }
2711 catch(OSD_Exception_STACK_OVERFLOW) {
2712 di << " Ok"<< "\n";
2713 }
2714 catch(Standard_Failure) {
2715 //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
2716 di << " Caught (";
2717 di << Standard_Failure::Caught()->GetMessageString();
2718 di << ")... KO" << "\n";
2719 Succes = Standard_False;
2720 }
2721 }
2722#endif
2723
2724 if(Succes) {
2725 di << "TestExcept: Successfull completion" << "\n";
2726 } else {
2727 di << "TestExcept: failure" << "\n";
2728 }
2729
2730 return 0;
2731}
2732#ifdef WNT
2733#pragma optimize( "", on )
2734#endif
2735
2736static TopoDS_Compound AddTestStructure(int nCount_)
2737{
2738 BRep_Builder B;
2739 int nCount=nCount_;
2740 TopoDS_Compound C;
2741 B.MakeCompound(C);
2742 BRepPrimAPI_MakeBox mkBox(1.0, 2.0, 3.0);
2743 for (int i=0; i<nCount; i++) {
2744 for (int j=0; j<nCount; j++) {
2745 gp_Trsf trsf;
2746 trsf.SetTranslationPart(gp_Vec(5.0*i, 05.0*j, 0.0));
2747 TopLoc_Location topLoc(trsf);
2748 TopoDS_Shape tempShape=mkBox.Shape().Located(topLoc);
2749 B.Add(C, tempShape);
2750 }
2751 }
2752 return C;
2753}
2754
2755static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2756{
2757 int nCount = 10;
2758
2759 if (argc > 2)
2760 {
2761 di << "Usage : " << argv[0] << " [nCount]" << "\n";
2762 return 1;
2763 }
2764
2765 if (argc > 1)
2766 nCount = atoi(argv[1]);
2767 STEPCAFControl_Writer writer;
2768 Handle_TDocStd_Document document;
2769 document = new TDocStd_Document("Pace Test-StepExporter-");
2770 Handle_XCAFDoc_ShapeTool shapeTool;
2771 shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
2772 shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
2773 STEPControl_StepModelType mode = STEPControl_AsIs;
2774 if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
2775 di << "Failed to set assembly mode for step data\n" << "\n";
2776 return 0;
2777 }
2778 try {
2779 OCC_CATCH_SIGNALS
2780 if( writer.Transfer(document, mode)) {
2781 IFSelect_ReturnStatus stat =
2782 writer.Write("TestExportStructure.step");
2783 }
2784 }
2785 catch(OSD_Exception_STACK_OVERFLOW) {
2786 di << "Failed : STACK OVERFLOW\n" << "\n";
2787 }
2788 catch (Standard_Failure) {
2789 di << "Failed :\n" << "\n";
2790 //cout << Standard_Failure::Caught() << endl;
2791 di << Standard_Failure::Caught()->GetMessageString();
2792 }
2793 di << argv[0] << " : Finish" << "\n";
2794
2795 return 0;
2796}
2797
2798static Standard_Integer OCC7372 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2799{
2800 if (argc != 1)
2801 {
2802 di << "Usage : " << argv[0] << "\n";
2803 return 1;
2804 }
2805
2806 // 1. Create an array of points
2807 Handle(TColgp_HArray1OfPnt2d) ap = new TColgp_HArray1OfPnt2d(1,5);
2808 ap->SetValue(1,gp_Pnt2d(100.0,0.0));
2809 ap->SetValue(2,gp_Pnt2d(100.0,100.0));
2810 ap->SetValue(3,gp_Pnt2d(0.0,100.0));
2811 ap->SetValue(4,gp_Pnt2d(0.0,0.0));
2812 ap->SetValue(5,gp_Pnt2d(50.0,-50.0));
2813
2814 // 2. Create a periodic bspline through these 5 points
2815 Geom2dAPI_Interpolate intp(ap,Standard_True,1e-6);
2816 intp.Perform();
2817 Handle(Geom2d_BSplineCurve) bspline1 = intp.Curve();
2818
2819 // 3. Increase degree of curve from 3 to 8
2820 bspline1->IncreaseDegree(8); // Increase degree to demonstrate the error
2821 Standard_CString CString1 = "BSplineCurve";
2822 DrawTrSurf::Set(CString1,bspline1);
2823
2824 // 4. Convers BSpline curve to Bezier segments
2825 Geom2dConvert_BSplineCurveToBezierCurve bc(bspline1);
2826
2827 // 5. Test the result of conversion
2828 TCollection_AsciiString aRName;
2829 for(Standard_Integer i = 1; i <= bc.NbArcs(); i++) {
2830 Handle(Geom2d_BezierCurve) arc = bc.Arc(i);
2831 aRName="segment_";
2832 aRName=aRName+TCollection_AsciiString(i);
2833 Standard_CString aRNameStr = aRName.ToCString();
2834 DrawTrSurf::Set(aRNameStr,arc);
2835 di << aRNameStr << " ";
2836 }
2837
2838 return 0;
2839}
2840
2841static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2842{
2843 if (argc != 4)
2844 {
2845 di << "Usage : " << argv[0] << " edge1 edge2 plane" << "\n";
2846 return 1;
2847 }
2848 TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
2849 if (theEdge1.IsNull()) {
2850 di << "Invalid input shape " << argv[1] << "\n";
2851 return 1;
2852 }
2853 TopoDS_Edge theEdge2 = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
2854 if (theEdge2.IsNull()) {
2855 di << "Invalid input shape " << argv[2] << "\n";
2856 return 1;
2857 }
2858 TopoDS_Face theFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
2859 if (theFace.IsNull()) {
2860 di << "Invalid input shape " << argv[3] << "\n";
2861 return 1;
2862 }
2863
2864 Handle(Geom_Surface) thePlane = BRep_Tool::Surface(theFace);
2865
2866 Standard_Real aConfusion = Precision::Confusion();
2867 Standard_Real aP1first, aP1last, aP2first, aP2last;
2868
2869 Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(theEdge1, aP1first, aP1last);
2870 Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(theEdge2, aP2first, aP2last);
2871 Handle(Geom2d_Curve) aCurve2d1 = GeomProjLib::Curve2d(aCurve1, aP1first, aP1last, thePlane);
2872 Handle(Geom2d_Curve) aCurve2d2 = GeomProjLib::Curve2d(aCurve2, aP2first, aP2last, thePlane);
2873
2874 Geom2dAPI_InterCurveCurve anInter(aCurve2d1, aCurve2d2, aConfusion);
2875
2876 Standard_Integer NbPoints = anInter.NbPoints();
2877
2878 di << "NbPoints = " << NbPoints << "\n" ;
2879
2880 if (NbPoints > 0) {
2881 Standard_Integer i;
2882 for (i=1; i<=NbPoints; i++) {
2883 gp_Pnt2d aPi = anInter.Point(i);
2884 di << "Point.X(" << i << ") = " << aPi.X() << " " << "Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
2885 }
2886 }
2887
2888 Standard_Integer NbSegments = anInter.NbSegments();
2889
2890 di << "\nNbSegments = " << NbSegments << "\n" ;
2891
2892 if (NbSegments > 0) {
2893 IntRes2d_IntersectionSegment aSegment = anInter.Intersector().Segment(1);
2894
2895 gp_Pnt2d aP1 = aCurve2d1->Value(aSegment.FirstPoint().ParamOnFirst());
2896 gp_Pnt2d aP2 = aCurve2d2->Value(aSegment.FirstPoint().ParamOnSecond());
2897
2898 Standard_Real aDist = aP1.Distance(aP2);
2899
2900 di << "aP1.X() = " << aP1.X() << " " << "aP1.Y() = " << aP1.Y() << "\n" ;
2901 di << "aP2.X() = " << aP2.X() << " " << "aP2.Y() = " << aP2.Y() << "\n" ;
2902
2903 di << "Distance = " << aDist << "\n" ;
2904
2905 di << "Confusion = " << aConfusion << "\n" ;
2906
2907 if (aDist > aConfusion) {
2908 di << "\n" << argv[0] << " Faulty" << "\n" ;
2909 } else {
2910 di << "\n" << argv[0] << " OK" << "\n" ;
2911 }
2912 } else {
2913 di << "\n" << argv[0] << " OK" << "\n" ;
2914 }
2915
2916 return 0;
2917}
2918static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
2919{
2920 if (argc != 3)
2921 {
2922 di << "Usage : " << argv[0] << " lower upper" << "\n";
2923 return 1;
2924 }
2925
2926 Standard_Integer LOWER = atoi(argv[1]);
2927 Standard_Integer UPPER = atoi(argv[2]);
2928
2929 //! 0. Create an empty document with several test labels
2930 Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
2931 doc->SetUndoLimit(100);
2932 TDF_Label main_label = doc->Main();
2933 TDF_Label label1 = main_label.FindChild(1, Standard_True);
2934 TDF_Label label2 = main_label.FindChild(2, Standard_True);
2935
2936 //! 1. Set/Get OCAF attribute
2937 doc->OpenCommand();
2938 TDataStd_RealArray::Set(label1, LOWER, UPPER);
2939 Handle(TDataStd_RealArray) array;
2940 if (label1.FindAttribute(TDataStd_RealArray::GetID(), array) &&
2941 array->Lower() == LOWER && array->Upper() == UPPER)
2942 cout<<"1: OK"<<endl;
2943 else
2944 {
2945 cout<<"1: Failed.."<<endl;
2946 return 1;
2947 }
2948 doc->CommitCommand();
2949
2950 //! 2. Set/Get value
2951 doc->OpenCommand();
2952 Standard_Integer i;
2953 for (i = LOWER; i <= UPPER; i++)
2954 array->SetValue(i, i);
2955 for (i = LOWER; i <= UPPER; i++)
2956 {
2957 if (array->Value(i) != i)
2958 {
2959 cout<<"2: Failed.."<<endl;
2960 return 2;
2961 }
2962 }
2963 cout<<"2: OK"<<endl;
2964 doc->CommitCommand();
2965
2966 //! 3. Re-init the array
2967 doc->OpenCommand();
2968 array->Init(LOWER + 2, UPPER + 4);
2969 if (array->Lower() != LOWER + 2 && array->Upper() != UPPER + 4)
2970 {
2971 cout<<"3: Failed.."<<endl;
2972 return 3;
2973 }
2974 for (i = LOWER + 2; i <= UPPER + 4; i++)
2975 array->SetValue(i, i);
2976 for (i = LOWER + 2; i <= UPPER + 4; i++)
2977 {
2978 if (array->Value(i) != i)
2979 {
2980 cout<<"3: Failed.."<<endl;
2981 return 3;
2982 }
2983 }
2984 cout<<"3: OK"<<endl;
2985 doc->CommitCommand();
2986
2987 //! 4. Change array
2988 doc->OpenCommand();
2989 Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(LOWER + 5, UPPER + 5);
2990 for (i = LOWER + 5; i <= UPPER + 5; i++)
2991 arr->SetValue(i, i);
2992 array->ChangeArray(arr);
2993 for (i = LOWER + 5; i <= UPPER + 5; i++)
2994 {
2995 if (array->Value(i) != i)
2996 {
2997 cout<<"4: Failed.."<<endl;
2998 return 4;
2999 }
3000 }
3001 cout<<"4: OK"<<endl;
3002 doc->CommitCommand();
3003
3004 //! 5. Copy the array
3005 doc->OpenCommand();
3006 TDF_CopyLabel copier(label1, label2);
3007 copier.Perform();
3008 if (!copier.IsDone())
3009 {
3010 cout<<"5: Failed.."<<endl;
3011 return 5;
3012 }
3013 Handle(TDataStd_RealArray) array2;
3014 if (!label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
3015 {
3016 cout<<"5: Failed.."<<endl;
3017 return 5;
3018 }
3019 for (i = LOWER + 5; i <= UPPER + 5; i++)
3020 {
3021 if (array->Value(i) != i)
3022 {
3023 cout<<"5: Failed.."<<endl;
3024 return 5;
3025 }
3026 }
3027 cout<<"5: OK"<<endl;
3028 doc->CommitCommand();
3029
3030 //! 6. Undo/Redo
3031 //! 6.a: undoes the 5th action: the copied array should disappear
3032 doc->Undo();
3033 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3034 label2.FindAttribute(TDataStd_RealArray::GetID(), array2))
3035 {
3036 cout<<"6.a: Failed.."<<endl;
3037 return 6;
3038 }
3039 //! 6.b: undoes the 4th action: the array should be changed to (lower+2,upper+4)
3040 doc->Undo();
3041 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3042 array->Lower() != LOWER + 2 ||
3043 array->Upper() != UPPER + 4)
3044 {
3045 cout<<"6.b: Failed.."<<endl;
3046 return 6;
3047 }
3048 for (i = LOWER + 2; i <= UPPER + 4; i++)
3049 {
3050 if (array->Value(i) != i)
3051 {
3052 cout<<"6.b: Failed.."<<endl;
3053 return 6;
3054 }
3055 }
3056 //! 6.c: undoes the 3d action: the array should be changed to (lower,upper)
3057 doc->Undo();
3058 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3059 array->Lower() != LOWER ||
3060 array->Upper() != UPPER)
3061 {
3062 cout<<"6.c: Failed.."<<endl;
3063 return 6;
3064 }
3065 for (i = LOWER; i <= UPPER; i++)
3066 {
3067 if (array->Value(i) != i)
3068 {
3069 cout<<"6.c: Failed.."<<endl;
3070 return 6;
3071 }
3072 }
3073 //! 6.d: undoes and redoes the 2nd action: no change is expected.
3074 doc->Undo();
3075 doc->Redo();
3076 if (!label1.FindAttribute(TDataStd_RealArray::GetID(), array) ||
3077 array->Lower() != LOWER ||
3078 array->Upper() != UPPER)
3079 {
3080 cout<<"6.d: Failed.."<<endl;
3081 return 6;
3082 }
3083 for (i = LOWER; i <= UPPER; i++)
3084 {
3085 if (array->Value(i) != i)
3086 {
3087 cout<<"6.d: Failed.."<<endl;
3088 return 6;
3089 }
3090 }
3091 cout<<"6: OK"<<endl;
3092
3093 //! 7. Re-set the array
3094 doc->OpenCommand();
3095 array = TDataStd_RealArray::Set(label1, LOWER + 1, UPPER + 1);
3096 if (array->Lower() != LOWER + 1 && array->Upper() != UPPER + 1)
3097 {
3098 cout<<"7: Failed.."<<endl;
3099 return 7;
3100 }
3101 for (i = LOWER + 1; i <= UPPER + 1; i++)
3102 array->SetValue(i, i);
3103 for (i = LOWER + 1; i <= UPPER + 1; i++)
3104 {
3105 if (array->Value(i) != i)
3106 {
3107 cout<<"7: Failed.."<<endl;
3108 return 7;
3109 }
3110 }
3111 cout<<"7: OK"<<endl;
3112 doc->CommitCommand();
3113
3114 //! 8.Test of speed: set LOWER and UPPER equal to great integer number and
3115 //! measure the time spent by this test.
3116 //! Good luck!
3117
3118 return 0;
3119}
3120
3121static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3122{
3123 Standard_Boolean IsEvenArgc = Standard_True;
3124 if (argc % 2 == 0) {
3125 IsEvenArgc = Standard_True;
3126 } else {
3127 IsEvenArgc = Standard_False;
3128 }
3129
3130 if (argc < 3 || IsEvenArgc)
3131 {
3132 di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]" << "\n";
3133 return 1;
3134 }
3135
3136 Standard_Integer i, aValue, aPosition;
3137 NCollection_Vector<int> vec;
3138 for (i = 0; i < argc - 1; i++) {
3139 i++;
3140 aValue = atoi(argv[i]);
3141 aPosition = atoi(argv[i+1]);
3142 vec.SetValue(aValue, aPosition);
3143 }
3144 NCollection_Vector<int>::Iterator it(vec);
3145 Standard_Integer j;
3146 for (j = 0; it.More(); it.Next(), j++) {
3147 //di << it.Value() << "\n";
3148 di << j << " " << it.Value() << "\n";
3149 }
3150
3151 return 0;
3152}
3153
3154static Standard_Integer OCC8797 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3155{
3156 if (argc != 1) {
3157 di << "Usage : " << argv[0] << "\n";
3158 return 1;
3159 }
3160
3161 gp_Pnt point(0.0,0.0,0.0);
3162
3163 TColgp_Array1OfPnt poles(0,6);
3164 poles(0)=point;
3165
3166 point.SetCoord(1.0,1.0,0.0);
3167 poles(1)=point;
3168
3169 point.SetCoord(2.0,1.0,0.0);
3170 poles(2)=point;
3171
3172 point.SetCoord(3.0,0.0,0.0);
3173 poles(3)=point;
3174
3175 point.SetCoord(4.0,1.0,0.0);
3176 poles(4)=point;
3177
3178 point.SetCoord(5.0,1.0,0.0);
3179 poles(5)=point;
3180
3181 point.SetCoord(6.0,0.0,0.0);
3182 poles(6)=point;
3183
3184 TColStd_Array1OfReal knots(0,2);
3185 knots(0)=0.0;
3186 knots(1)=0.5;
3187 knots(2)=1.0;
3188
3189 TColStd_Array1OfInteger multi(0,2);
3190 multi(0)=4;
3191 multi(1)=3;
3192 multi(2)=4;
3193
3194 Handle(Geom_BSplineCurve) spline = new Geom_BSplineCurve(poles,knots,multi,3);
3195
3196 //length!! 1.
3197 Standard_Real l_abcissa,l_gprop;
3198 GeomAdaptor_Curve adaptor_spline(spline);
3199 GCPnts_AbscissaPoint temp;
3200 l_abcissa=temp.Length(adaptor_spline);
3201 cout<<"Length Spline(abcissa_Pnt): "<<l_abcissa<<endl;
3202
3203 //length!! 2.
3204 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge (spline);
3205 GProp_GProps prop;
3206 BRepGProp::LinearProperties(edge,prop);
3207 l_gprop=prop.Mass();
3208 cout<<"Length Spline(GProp_GProps): "<<l_gprop<<endl;
3209
3210 cout<<"Difference (abcissa_Pnt<->GProp_GProps): "<<l_gprop-l_abcissa<<endl;
3211
3212 return 0;
3213}
3214
3215static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3216{
3217 if (argc != 1)
3218 {
3219 di << "Usage : " << argv[0] << "\n";
3220 return 1;
3221 }
3222
3223 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
3224 if(AISContext.IsNull())
3225 {
3226 di << "use 'vinit' command before " << argv[0] << "\n";
3227 return 1;
3228 }
3229
3230 // ObjectsInside
3231 AIS_ListOfInteractive ListOfIO_1;
3232 AISContext->ObjectsInside(ListOfIO_1);
3233 di<< "ObjectsInside = " << ListOfIO_1.Extent() <<"\n";
3234 if (!ListOfIO_1.IsEmpty() ) {
3235 AIS_ListIteratorOfListOfInteractive iter;
3236 for (iter.Initialize(ListOfIO_1); iter.More() ; iter.Next() ) {
3237 Handle(AIS_InteractiveObject) aIO=iter.Value();
3238 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3239 }
3240 }
3241
3242 // ObjectsInCollector
3243 AIS_ListOfInteractive ListOfIO_2;
3244 AISContext->ObjectsInCollector(ListOfIO_2);
3245 di<< "ObjectsInCollector = " << ListOfIO_2.Extent() <<"\n";
3246 if (!ListOfIO_2.IsEmpty() ) {
3247 AIS_ListIteratorOfListOfInteractive iter;
3248 for (iter.Initialize(ListOfIO_2); iter.More() ; iter.Next() ) {
3249 Handle(AIS_InteractiveObject) aIO=iter.Value();
3250 di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
3251 }
3252 }
3253
3254 return 0;
3255}
3256
3257static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3258{
3259 if ((argc < 9) || (((argc-3) % 3) != 0))
3260 {
3261 di << "Usage : " << argv[0] << "polygon lastedge x1 y1 z1 x2 y2 z2 ...\n";
3262 return 1;
3263 }
3264 Standard_Integer i, j, np = (argc-3) / 3;
3265 BRepBuilderAPI_MakePolygon W;
3266 j = 3;
3267 for (i = 1; i <= np; i ++) {
3268 W.Add(gp_Pnt(atof(argv[j]),atof(argv[j+1]),atof(argv[j+2])));
3269 j += 3;
3270 }
3271 W.Close();
3272 DBRep::Set(argv[1],W.Wire());
3273 DBRep::Set(argv[2],W.Edge());
3274 return 0;
3275}
3276
3277static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3278{
3279 if (argc < 5) {
3280 di << "Usage : " << argv[0] << " ratio origin_x origin_y origin_z\n";
3281 return 1;
3282 }
3283 gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
3284 gp_Dir(1., -1., 0.));
3285 gp_GTrsf aTrf;
3286 aTrf.SetAffinity (aPln, atof(argv[4]));
3287 gp_XYZ aOrigin (atof(argv[1]),atof(argv[2]),atof(argv[3]));
3288 gp_XYZ aResult (aOrigin);
3289 aTrf.Transforms(aResult);
3290 char sbf[512];
3291 sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
3292 aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
3293 aResult.X(), aResult.Y(), aResult.Z());
3294 di<<sbf;
3295 return 0;
3296}
3297
3298Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3299{
3300 if (argc < 2) {
3301 di << "Usage : " << argv[0] << " shape [deflection]\n";
3302 return 1;
3303 }
3304
3305 TopoDS_Shape aShape = DBRep::Get(argv[1]);
3306
3307 if (aShape.IsNull()) {
3308 di<<" Null shape is not allowed";
3309 return 1;
3310 }
3311
3312 Standard_Real aDeflection = 0.45110277533;
3313 if (argc > 2) {
3314 aDeflection = atof(argv[2]);
3315 }
3316 di<<"deflection="<< aDeflection << "\n";
3317
c6541a0c 3318 BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI/9.);
7fd59977 3319 TopLoc_Location aLocation;
3320 Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
3321
3322 if(aTriang.IsNull()) {
3323 di << argv[0] << " : Faulty\n" ;
3324 } else {
3325 di << argv[0] << " : OK\n" ;
3326 di<<"NbNodes="<< aTriang->NbNodes()<< "\n";
3327 di<<"NbTriangles="<< aTriang->NbTriangles()<< "\n";
3328 }
3329 return 0;
3330}
3331
3332static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3333{
3334 if (argc != 4) {
3335 di << "Usage : " << argv[0] << " A B C\n";
3336 return 1;
3337 }
3338 try
3339 {
3340 gp_Lin2d aLin2d (atof(argv[1]),atof(argv[2]),atof(argv[3]));
3341 gp_Pnt2d anOrigin = aLin2d.Location();
3342 di << "X_0 = " << anOrigin.X() << " Y_0 = " << anOrigin.Y() << "\n" ;
3343 }
3344 catch(Standard_ConstructionError)
3345 {
3346 di << argv[0] << " Exception: Sqrt(A*A + B*B) <= Resolution from gp\n";
3347 }
3348 return 0;
3349}
3350
3351static Standard_Integer OCC15755 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
3352{
3353 if (argc != 3) {
3354 di << "Usage : " << argv[0] << " file shape\n";
3355 return 1;
3356 }
3357
3358 IGESControl_Reader aReader;
3359 aReader.ReadFile(argv[1]);
3360 aReader.SetReadVisible(Standard_True);
3361 aReader.TransferRoots();
3362
3363 Handle(IGESData_IGESModel) model = aReader.IGESModel();
3364 if (model.IsNull()) {
3365 di << "model.IsNull()\n";
3366 return 1;
3367 }
3368 Standard_Integer nb = model->NbEntities();
3369 for (Standard_Integer i = 1; i <= nb; i ++) {
3370 Handle(IGESData_IGESEntity) ent = model->Entity(i);
3371 Handle(TCollection_HAsciiString) name;
3372 name = ent->NameValue();
3373 Standard_CString aStr = name->ToCString();
3374 di << "NameValue = " << aStr << "\n";
3375 }
3376
3377 TopoDS_Shape shape = aReader.OneShape();
3378 DBRep::Set(argv[2],shape);
3379 return 0;
3380}
3381
3382// For OCC16782 testing
3383#include <AppStd_Application.hxx>
3384#include <TDF_Tool.hxx>
3385#include <TColStd_HArray1OfInteger.hxx>
3386// Iterators
3387#include <TColStd_ListIteratorOfListOfInteger.hxx>
3388#include <TColStd_ListIteratorOfListOfReal.hxx>
3389#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
3390#include <TDataStd_ListIteratorOfListOfByte.hxx>
3391#include <TDF_ListIteratorOfLabelList.hxx>
3392// Attributes
3393#include <TDataStd_Tick.hxx>
3394#include <TDataStd_IntegerList.hxx>
3395#include <TDataStd_RealList.hxx>
3396#include <TDataStd_ExtStringList.hxx>
3397#include <TDataStd_BooleanList.hxx>
3398#include <TDataStd_ReferenceList.hxx>
3399#include <TDataStd_BooleanArray.hxx>
3400#include <TDataStd_ReferenceArray.hxx>
3401#include <TDataStd_ByteArray.hxx>
3402#include <TDataStd_NamedData.hxx>
3403#include <TDF_Reference.hxx>
3404//
3405Handle(AppStd_Application) app;
3406int TestSetGet(const Handle(TDocStd_Document)& doc)
3407{
3408 // TDataStd_Tick:
3409 // Set
3410 TDataStd_Tick::Set(doc->Main());
3411 // Get
3412 Handle(TDataStd_Tick) tick;
3413 if (!doc->Main().FindAttribute(TDataStd_Tick::GetID(), tick))
3414 return 1;
3415 // Forget
3416 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3417 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3418 return 2;
3419 doc->Main().ResumeAttribute(tick);
3420 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3421 return 3;
3422 // Forget
3423 doc->Main().ForgetAttribute(TDataStd_Tick::GetID());
3424 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3425 return 2;
3426
3427 // TDataStd_IntegerList:
3428 // Set
3429 Handle(TDataStd_IntegerList) setintlist = TDataStd_IntegerList::Set(doc->Main());
3430 setintlist->Append(2);
3431 setintlist->Prepend(1);
3432 setintlist->InsertAfter(3, 2);
3433 setintlist->InsertBefore(0, 1);
3434 setintlist->Append(200);
3435 setintlist->Remove(0);
3436 setintlist->Remove(200);
3437 // Get
3438 Handle(TDataStd_IntegerList) getintlist;
3439 if (!doc->Main().FindAttribute(TDataStd_IntegerList::GetID(), getintlist))
3440 return 1;
3441 if (getintlist->First() != 1)
3442 return 2;
3443 if (getintlist->Last() != 3)
3444 return 3;
3445 const TColStd_ListOfInteger& intlist = getintlist->List();
3446 TColStd_ListIteratorOfListOfInteger itr_intlist(intlist);
3447 for (; itr_intlist.More(); itr_intlist.Next())
3448 {
3449 if (itr_intlist.Value() != 1 &&
3450 itr_intlist.Value() != 2 &&
3451 itr_intlist.Value() != 3)
3452 {
3453 return 4;
3454 }
3455 }
3456 getintlist->Clear();
3457
3458 // TDataStd_RealList:
3459 // Set
3460 Handle(TDataStd_RealList) setdbllist = TDataStd_RealList::Set(doc->Main());
3461 setdbllist->Append(2.5);
3462 setdbllist->Prepend(1.5);
3463 setdbllist->InsertAfter(3.5, 2.5);
3464 setdbllist->InsertBefore(0.5, 1.5);
3465 setdbllist->Append(200.5);
3466 setdbllist->Remove(0.5);
3467 setdbllist->Remove(200.5);
3468 // Get
3469 Handle(TDataStd_RealList) getdbllist;
3470 if (!doc->Main().FindAttribute(TDataStd_RealList::GetID(), getdbllist))
3471 return 1;
3472 if (getdbllist->First() != 1.5)
3473 return 2;
3474 if (getdbllist->Last() != 3.5)
3475 return 3;
3476 const TColStd_ListOfReal& dbllist = getdbllist->List();
3477 TColStd_ListIteratorOfListOfReal itr_dbllist(dbllist);
3478 for (; itr_dbllist.More(); itr_dbllist.Next())
3479 {
3480 if (itr_dbllist.Value() != 1.5 &&
3481 itr_dbllist.Value() != 2.5 &&
3482 itr_dbllist.Value() != 3.5)
3483 {
3484 return 4;
3485 }
3486 }
3487 getdbllist->Clear();
3488
3489 // TDataStd_ExtStringList:
3490 // Set
3491 Handle(TDataStd_ExtStringList) setstrlist = TDataStd_ExtStringList::Set(doc->Main());
3492 setstrlist->Append("Hello");
3493 setstrlist->Prepend("Guten Tag");
3494 setstrlist->InsertAfter("Bonjour", "Guten Tag");
3495 setstrlist->InsertBefore("Bonsoir", "Hello");
3496 setstrlist->Append("Good bye");
3497 setstrlist->Remove("Bonsoir");
3498 setstrlist->Remove("Good bye");
3499 // Get
3500 Handle(TDataStd_ExtStringList) getstrlist;
3501 if (!doc->Main().FindAttribute(TDataStd_ExtStringList::GetID(), getstrlist))
3502 return 1;
3503 if (getstrlist->First() != "Guten Tag")
3504 return 2;
3505 if (getstrlist->Last() != "Hello")
3506 return 3;
3507 const TDataStd_ListOfExtendedString& strlist = getstrlist->List();
3508 TDataStd_ListIteratorOfListOfExtendedString itr_strlist(strlist);
3509 for (; itr_strlist.More(); itr_strlist.Next())
3510 {
3511 if (itr_strlist.Value() != "Guten Tag" &&
3512 itr_strlist.Value() != "Bonjour" &&
3513 itr_strlist.Value() != "Hello")
3514 {
3515 return 4;
3516 }
3517 }
3518 getstrlist->Clear();
3519
3520 // TDataStd_BooleanList:
3521 // Set
3522 Handle(TDataStd_BooleanList) setboollist = TDataStd_BooleanList::Set(doc->Main());
3523 setboollist->Append(Standard_True);
3524 setboollist->Prepend(Standard_False);
3525 // Get
3526 Handle(TDataStd_BooleanList) getboollist;
3527 if (!doc->Main().FindAttribute(TDataStd_BooleanList::GetID(), getboollist))
3528 return 1;
3529 if (getboollist->First() != Standard_False)
3530 return 2;
3531 if (getboollist->Last() != Standard_True)
3532 return 3;
3533 const TDataStd_ListOfByte& boollist = getboollist->List();
3534 TDataStd_ListIteratorOfListOfByte itr_boollist(boollist);
3535 for (; itr_boollist.More(); itr_boollist.Next())
3536 {
3537 if (itr_boollist.Value() != Standard_True &&
3538 itr_boollist.Value() != Standard_False)
3539 {
3540 return 4;
3541 }
3542 }
3543 getboollist->Clear();
3544
3545 // TDataStd_ReferenceList:
3546 TDF_Label L1 = doc->Main().FindChild(100);
3547 TDF_Label L2 = doc->Main().FindChild(101);
3548 TDF_Label L3 = doc->Main().FindChild(102);
3549 TDF_Label L4 = doc->Main().FindChild(103);
3550 TDF_Label L5 = doc->Main().FindChild(104);
3551 // Set
3552 Handle(TDataStd_ReferenceList) setreflist = TDataStd_ReferenceList::Set(doc->Main());
3553 setreflist->Append(L1);
3554 setreflist->Prepend(L2);
3555 setreflist->InsertAfter(L3, L2);
3556 setreflist->InsertBefore(L4, L1);
3557 setreflist->Append(L5);
3558 setreflist->Remove(L4);
3559 setreflist->Remove(L5);
3560 // Get
3561 Handle(TDataStd_ReferenceList) getreflist;
3562 if (!doc->Main().FindAttribute(TDataStd_ReferenceList::GetID(), getreflist))
3563 return 1;
3564 if (getreflist->First() != L2)
3565 return 2;
3566 if (getreflist->Last() != L1)
3567 return 3;
3568 const TDF_LabelList& reflist = getreflist->List();
3569 TDF_ListIteratorOfLabelList itr_reflist(reflist);
3570 for (; itr_reflist.More(); itr_reflist.Next())
3571 {
3572 if (itr_reflist.Value() != L1 &&
3573 itr_reflist.Value() != L2 &&
3574 itr_reflist.Value() != L3)
3575 {
3576 return 4;
3577 }
3578 }
3579 getreflist->Clear();
3580
3581 // TDataStd_BooleanArray:
3582 // Set
3583 Handle(TDataStd_BooleanArray) setboolarr = TDataStd_BooleanArray::Set(doc->Main(), 12, 16);
3584 setboolarr->SetValue(12, Standard_True);
3585 setboolarr->SetValue(13, Standard_False);
3586 setboolarr->SetValue(14, Standard_False);
3587 setboolarr->SetValue(15, Standard_False);
3588 setboolarr->SetValue(16, Standard_True);
3589 setboolarr->SetValue(14, Standard_True);
3590 // Get
3591 Handle(TDataStd_BooleanArray) getboolarr;
3592 if (!doc->Main().FindAttribute(TDataStd_BooleanArray::GetID(), getboolarr))
3593 return 1;
3594 if (getboolarr->Value(12) != Standard_True)
3595 return 2;
3596 if (getboolarr->Value(13) != Standard_False)
3597 return 2;
3598 if (getboolarr->Value(14) != Standard_True)
3599 return 2;
3600 if (getboolarr->Value(15) != Standard_False)
3601 return 2;
3602 if (getboolarr->Value(16) != Standard_True)
3603 return 2;
3604
3605 // TDataStd_ReferenceArray:
3606 // Set
3607 Handle(TDataStd_ReferenceArray) setrefarr = TDataStd_ReferenceArray::Set(doc->Main(), 0, 4);
3608 setrefarr->SetValue(0, L1);
3609 setrefarr->SetValue(1, L2);
3610 setrefarr->SetValue(2, L3);
3611 setrefarr->SetValue(3, L4);
3612 setrefarr->SetValue(4, L5);
3613 // Get
3614 Handle(TDataStd_ReferenceArray) getrefarr;
3615 if (!doc->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), getrefarr))
3616 return 1;
3617 if (getrefarr->Value(0) != L1)
3618 return 2;
3619 if (getrefarr->Value(1) != L2)
3620 return 2;
3621 if (getrefarr->Value(2) != L3)
3622 return 2;
3623 if (getrefarr->Value(3) != L4)
3624 return 2;
3625 if (getrefarr->Value(4) != L5)
3626 return 2;
3627
3628 // TDataStd_ByteArray:
3629 // Set
3630 Handle(TDataStd_ByteArray) setbytearr = TDataStd_ByteArray::Set(doc->Main(), 12, 16);
3631 setbytearr->SetValue(12, 0);
3632 setbytearr->SetValue(13, 1);
3633 setbytearr->SetValue(14, 2);
3634 setbytearr->SetValue(15, 3);
3635 setbytearr->SetValue(16, 255);
3636 // Get
3637 Handle(TDataStd_ByteArray) getbytearr;
3638 if (!doc->Main().FindAttribute(TDataStd_ByteArray::GetID(), getbytearr))
3639 return 1;
3640 if (getbytearr->Value(12) != 0)
3641 return 2;
3642 if (getbytearr->Value(13) != 1)
3643 return 2;
3644 if (getbytearr->Value(14) != 2)
3645 return 2;
3646 if (getbytearr->Value(15) != 3)
3647 return 2;
3648 if (getbytearr->Value(16) != 255)
3649 return 2;
3650
3651 // TDataStd_NamedData:
3652 // Set:
3653 Handle(TDataStd_NamedData) setnd = TDataStd_NamedData::Set(doc->Main());
3654 setnd->SetInteger("Integer1", 1);
3655 setnd->SetInteger("Integer2", 2);
3656 setnd->SetInteger("Integer3", 8);
3657 setnd->SetInteger("Integer3", 3);
3658 // Get:
3659 Handle(TDataStd_NamedData) getnd;
3660 if (!doc->Main().FindAttribute(TDataStd_NamedData::GetID(), getnd))
3661 return 1;
3662 if (!getnd->HasIntegers())
3663 return 2;
3664 if (!getnd->HasInteger("Integer1"))
3665 return 3;
3666 if (getnd->GetInteger("Integer2") != 2)
3667 return 4;
3668 if (getnd->GetInteger("Integer3") != 3)
3669 return 4;
3670
3671 return 0;
3672}
3673
3674int TestUndoRedo(const Handle(TDocStd_Document)& doc)
3675{
3676 // TDataStd_Tick:
3677 doc->OpenCommand();
3678 Handle(TDataStd_Tick) tick = TDataStd_Tick::Set(doc->Main());
3679 doc->CommitCommand();
3680 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3681 return 1;
3682 doc->Undo();
3683 if (doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3684 return 2;
3685 doc->Redo();
3686 if (!doc->Main().IsAttribute(TDataStd_Tick::GetID()))
3687 return 3;
3688
3689 // TDataStd_IntegerList:
3690 doc->OpenCommand();
3691 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc->Main());
3692 intlist->Append(2);
3693 intlist->Prepend(1);
3694 intlist->InsertBefore(0, 1);
3695 intlist->InsertAfter(3, 2);
3696 doc->CommitCommand();
3697 if (!doc->Main().IsAttribute(TDataStd_IntegerList::GetID()))
3698 return 1;
3699 doc->Undo();
3700 if (!intlist->IsEmpty())
3701 return 2;
3702 doc->Redo();
3703 if (!intlist->Extent())
3704 return 3;
3705 if (intlist->First() != 0)
3706 return 4;
3707 if (intlist->Last() != 3)
3708 return 5;
3709 intlist->Clear();
3710
3711 // TDataStd_RealList:
3712 doc->OpenCommand();
3713 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc->Main());
3714 dbllist->Append(2.5);
3715 dbllist->Prepend(1.5);
3716 dbllist->InsertBefore(0.5, 1.5);
3717 dbllist->InsertAfter(3.5, 2.5);
3718 doc->CommitCommand();
3719 if (!doc->Main().IsAttribute(TDataStd_RealList::GetID()))
3720 return 1;
3721 doc->Undo();
3722 if (!dbllist->IsEmpty())
3723 return 2;
3724 doc->Redo();
3725 if (!dbllist->Extent())
3726 return 3;
3727 if (dbllist->First() != 0.5)
3728 return 4;
3729 if (dbllist->Last() != 3.5)
3730 return 5;
3731 dbllist->Clear();
3732
3733 // TDataStd_ExtStringList:
3734 doc->OpenCommand();
3735 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc->Main());
3736 strlist->Append("Hello");
3737 strlist->Prepend("Guten Tag");
3738 strlist->InsertAfter("Bonjour", "Guten Tag");
3739 strlist->InsertBefore("Bonsoir", "Hello");
3740 doc->CommitCommand();
3741 if (!doc->Main().IsAttribute(TDataStd_ExtStringList::GetID()))
3742 return 1;
3743 doc->Undo();
3744 if (!strlist->IsEmpty())
3745 return 2;
3746 doc->Redo();
3747 if (!strlist->Extent())
3748 return 3;
3749 if (strlist->First() != "Guten Tag")
3750 return 4;
3751 if (strlist->Last() != "Hello")
3752 return 5;
3753 strlist->Clear();
3754
3755 // TDataStd_BooleanList:
3756 doc->OpenCommand();
3757 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc->Main());
3758 boollist->Append(Standard_True);
3759 boollist->Prepend(Standard_False);
3760 doc->CommitCommand();
3761 if (!doc->Main().IsAttribute(TDataStd_BooleanList::GetID()))
3762 return 1;
3763 doc->Undo();
3764 if (!boollist->IsEmpty())
3765 return 2;
3766 doc->Redo();
3767 if (!boollist->Extent())
3768 return 3;
3769 if (boollist->First() != Standard_False)
3770 return 4;
3771 if (boollist->Last() != Standard_True)
3772 return 5;
3773 boollist->Clear();
3774
3775 // TDataStd_ReferenceList:
3776 TDF_Label L1 = doc->Main().FindChild(100);
3777 TDF_Label L2 = doc->Main().FindChild(101);
3778 TDF_Label L3 = doc->Main().FindChild(102);
3779 TDF_Label L4 = doc->Main().FindChild(103);
3780 doc->OpenCommand();
3781 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc->Main());
3782 reflist->Append(L1);
3783 reflist->Prepend(L2);
3784 reflist->InsertBefore(L3, L1);
3785 reflist->InsertAfter(L4, L2);
3786 doc->CommitCommand();
3787 if (!doc->Main().IsAttribute(TDataStd_ReferenceList::GetID()))
3788 return 1;
3789 doc->Undo();
3790 if (!reflist->IsEmpty())
3791 return 2;
3792 doc->Redo();
3793 if (!reflist->Extent())
3794 return 3;
3795 if (reflist->First() != L2)
3796 return 4;
3797 if (reflist->Last() != L1)
3798 return 5;
3799 reflist->Clear();
3800
3801 // TDataStd_BooleanArray:
3802 doc->OpenCommand();
3803 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc->Main(), 23, 25);
3804 boolarr->SetValue(23, Standard_True);
3805 boolarr->SetValue(25, Standard_True);
3806 doc->CommitCommand();
3807 doc->OpenCommand();
3808 boolarr = TDataStd_BooleanArray::Set(doc->Main(), 230, 250);
3809 boolarr->SetValue(230, Standard_True);
3810 boolarr->SetValue(250, Standard_True);
3811 doc->CommitCommand();
3812 doc->Undo();
3813 if (boolarr->Value(23) != Standard_True)
3814 return 2;
3815 if (boolarr->Value(24) != Standard_False)
3816 return 2;
3817 if (boolarr->Value(25) != Standard_True)
3818 return 2;
3819 doc->Redo();
3820 if (boolarr->Value(230) != Standard_True)
3821 return 3;
3822 if (boolarr->Value(240) != Standard_False)
3823 return 3;
3824 if (boolarr->Value(250) != Standard_True)
3825 return 3;
3826
3827 // TDataStd_ReferenceArray:
3828 doc->OpenCommand();
3829 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc->Main(), 5, 8);
3830 refarr->SetValue(5, L1);
3831 refarr->SetValue(6, L2);
3832 refarr->SetValue(7, L3);
3833 refarr->SetValue(8, L4);
3834 doc->CommitCommand();
3835 if (!doc->Main().IsAttribute(TDataStd_ReferenceArray::GetID()))
3836 return 1;
3837 doc->Undo();
3838 doc->Redo();
3839 if (refarr->Value(5) != L1)
3840 return 4;
3841 if (refarr->Value(6) != L2)
3842 return 4;
3843 if (refarr->Value(7) != L3)
3844 return 4;
3845 if (refarr->Value(8) != L4)
3846 return 4;
3847
3848 // TDataStd_ByteArray:
3849 doc->OpenCommand();
3850 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc->Main(), 23, 25);
3851 bytearr->SetValue(23, 23);
3852 bytearr->SetValue(25, 25);
3853 doc->CommitCommand();
3854 doc->OpenCommand();
3855 bytearr = TDataStd_ByteArray::Set(doc->Main(), 230, 250);
3856 bytearr->SetValue(230, 230);
3857 bytearr->SetValue(250, 250);
3858 doc->CommitCommand();
3859 doc->Undo();
3860 if (bytearr->Value(23) != 23)
3861 return 2;
3862 if (bytearr->Value(25) != 25)
3863 return 2;
3864 doc->Redo();
3865 if (bytearr->Value(230) != 230)
3866 return 3;
3867 if (bytearr->Value(250) != 250)
3868 return 3;
3869
3870 // TDataStd_NamedData:
3871 doc->OpenCommand();
3872 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(doc->Main());
3873 nd->SetByte("b14", 12);
3874 nd->SetByte("b17", 18);
3875 nd->SetByte("b14", 14);
3876 nd->SetByte("b17", 17);
3877 doc->CommitCommand();
3878 doc->OpenCommand();
3879 nd = TDataStd_NamedData::Set(doc->Main());
3880 nd->SetReal("r14", 14);
3881 nd->SetReal("r17", 17);
3882 nd->SetReal("r14", 14.4);
3883 nd->SetReal("r17", 17.7);
3884 doc->CommitCommand();
3885 doc->Undo();
3886 if (nd->HasStrings())
3887 return 1;
3888 if (nd->HasReals())
3889 return 1;
3890 if (nd->HasReal("r17"))
3891 return 2;
3892 if (!nd->HasBytes())
3893 return 3;
3894 if (nd->GetByte("b14") != 14)
3895 return 4;
3896 if (nd->GetByte("b17") != 17)
3897 return 4;
3898 if (nd->HasByte("b18"))
3899 return 5;
3900 doc->Redo();
3901 if (!nd->HasBytes())
3902 return 1;
3903 if (!nd->HasReals())
3904 return 1;
3905 if (nd->GetByte("b14") != 14)
3906 return 2;
3907 if (nd->GetReal("r14") != 14.4)
3908 return 2;
3909 if (nd->GetReal("r17") != 17.7)
3910 return 2;
3911
3912 return 0;
3913}
3914
3915int TestCopyPaste(const Handle(TDocStd_Document)& doc)
3916{
3917 TDF_Label L1 = doc->Main().FindChild(1);
3918 TDF_Label L2 = doc->Main().FindChild(2);
3919 TDF_CopyLabel copier(L1, L2);
3920
3921 // TDataStd_Tick:
3922 TDataStd_Tick::Set(L1);
3923 copier.Perform();
3924 if (!copier.IsDone())
3925 return 1;
3926 if (!L2.IsAttribute(TDataStd_Tick::GetID()))
3927 return 2;
3928
3929 // TDataStd_IntegerList:
3930 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(L1);
3931 intlist->Append(1);
3932 intlist->InsertAfter(2, 1);
3933 copier.Perform();
3934 if (!copier.IsDone())
3935 return 1;
3936 intlist->Clear();
3937 intlist.Nullify();
3938 if (!L2.FindAttribute(TDataStd_IntegerList::GetID(), intlist))
3939 return 2;
3940 if (intlist->First() != 1)
3941 return 3;
3942 if (intlist->Last() != 2)
3943 return 4;
3944 intlist->Clear();
3945
3946 // TDataStd_RealList:
3947 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(L1);
3948 dbllist->Append(1.5);
3949 dbllist->InsertAfter(2.5, 1.5);
3950 copier.Perform();
3951 if (!copier.IsDone())
3952 return 1;
3953 dbllist->Clear();
3954 dbllist.Nullify();
3955 if (!L2.FindAttribute(TDataStd_RealList::GetID(), dbllist))
3956 return 2;
3957 if (dbllist->First() != 1.5)
3958 return 3;
3959 if (dbllist->Last() != 2.5)
3960 return 4;
3961 dbllist->Clear();
3962
3963 // TDataStd_ExtStringList:
3964 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(L1);
3965 strlist->Append("Open CASCADE");
3966 strlist->InsertAfter(" - is the best set of libraries!", "Open CASCADE");
3967 copier.Perform();
3968 if (!copier.IsDone())
3969 return 1;
3970 strlist->Clear();
3971 strlist.Nullify();
3972 if (!L2.FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
3973 return 2;
3974 if (strlist->First() != "Open CASCADE")
3975 return 3;
3976 if (strlist->Last() != " - is the best set of libraries!")
3977 return 4;
3978 strlist->Clear();
3979
3980 // TDataStd_BooleanList:
3981 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(L1);
3982 boollist->Append(Standard_True);
3983 boollist->Prepend(Standard_False);
3984 copier.Perform();
3985 if (!copier.IsDone())
3986 return 1;
3987 boollist->Clear();
3988 boollist.Nullify();
3989 if (!L2.FindAttribute(TDataStd_BooleanList::GetID(), boollist))
3990 return 2;
3991 if (boollist->First() != Standard_False)
3992 return 3;
3993 if (boollist->Last() != Standard_True)
3994 return 4;
3995 boollist->Clear();
3996
3997 // TDataStd_ReferenceList:
3998 TDF_Label L100 = doc->Main().FindChild(100);
3999 TDF_Label L101 = doc->Main().FindChild(101);
4000 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(L1);
4001 reflist->Append(L100);
4002 reflist->InsertAfter(L101, L100);
4003 copier.Perform();
4004 if (!copier.IsDone())
4005 return 1;
4006 reflist->Clear();
4007 reflist.Nullify();
4008 if (!L2.FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4009 return 2;
4010 if (reflist->First() != L100)
4011 return 3;
4012 if (reflist->Last() != L101)
4013 return 4;
4014 reflist->Clear();
4015
4016 // TDataStd_BooleanArray:
4017 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(L1, 4, 6);
4018 boolarr->SetValue(4, Standard_True);
4019 boolarr->SetValue(6, Standard_True);
4020 copier.Perform();
4021 if (!copier.IsDone())
4022 return 1;
4023 boolarr.Nullify();
4024 if (!L2.FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4025 return 2;
4026 if (boolarr->Value(4) != Standard_True)
4027 return 3;
4028 if (boolarr->Value(5) != Standard_False)
4029 return 3;
4030 if (boolarr->Value(6) != Standard_True)
4031 return 3;
4032
4033 // TDataStd_ReferenceArray:
4034 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(L1, 3, 4);
4035 refarr->SetValue(3, L100);
4036 refarr->SetValue(4, L101);
4037 copier.Perform();
4038 if (!copier.IsDone())
4039 return 1;
4040 refarr.Nullify();
4041 if (!L2.FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4042 return 2;
4043 if (refarr->Value(3) != L100)
4044 return 3;
4045 if (refarr->Value(4) != L101)
4046 return 3;
4047
4048 // TDataStd_ByteArray:
4049 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(L1, 4, 6);
4050 bytearr->SetValue(4, 40);
4051 bytearr->SetValue(6, 60);
4052 copier.Perform();
4053 if (!copier.IsDone())
4054 return 1;
4055 bytearr.Nullify();
4056 if (!L2.FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4057 return 2;
4058 if (bytearr->Value(4) != 40)
4059 return 3;
4060 if (bytearr->Value(6) != 60)
4061 return 3;
4062
4063 // TDataStd_NamedData:
4064 Handle(TDataStd_NamedData) nd = TDataStd_NamedData::Set(L1);
4065 nd->SetInteger("Integer1", 11);
4066 nd->SetReal("Real1", 11.1);
4067 nd->SetString("String1", "11.11111111");
4068 nd->SetByte("Byte1", 111);
4069 Handle(TColStd_HArray1OfInteger) ints_arr = new TColStd_HArray1OfInteger(4, 5);
4070 ints_arr->SetValue(4, 4);
4071 ints_arr->SetValue(5, 5);
4072 nd->SetArrayOfIntegers("Integers1", ints_arr);
4073 copier.Perform();
4074 if (!copier.IsDone())
4075 return 1;
4076 nd.Nullify();
4077 if (!L2.FindAttribute(TDataStd_NamedData::GetID(), nd))
4078 return 2;
4079 if (!nd->HasIntegers())
4080 return 3;
4081 if (!nd->HasReals())
4082 return 3;
4083 if (!nd->HasStrings())
4084 return 3;
4085 if (!nd->HasBytes())
4086 return 3;
4087 if (!nd->HasArraysOfIntegers())
4088 return 3;
4089 if (nd->HasArraysOfReals())
4090 return 3;
4091 if (!nd->HasInteger("Integer1"))
4092 return 4;
4093 if (nd->GetInteger("Integer1") != 11)
4094 return 4;
4095 if (!nd->HasReal("Real1"))
4096 return 4;
4097 if (nd->GetReal("Real1") != 11.1)
4098 return 4;
4099 if (!nd->HasString("String1"))
4100 return 4;
4101 if (nd->GetString("String1") != "11.11111111")
4102 return 4;
4103 if (!nd->HasByte("Byte1"))
4104 return 4;
4105 if (nd->GetByte("Byte1") != 111)
4106 return 4;
4107 if (!nd->HasArrayOfIntegers("Integers1"))
4108 return 4;
4109 const Handle(TColStd_HArray1OfInteger)& ints_arr_out = nd->GetArrayOfIntegers("Integers1");
4110 if (ints_arr_out.IsNull())
4111 return 4;
4112 if (ints_arr_out->Value(5) != 5)
4113 return 4;
4114
4115 return 0;
4116}
4117
4118int TestOpenSave(TCollection_ExtendedString aFile1,
4119 TCollection_ExtendedString aFile2,
4120 TCollection_ExtendedString aFile3)
4121{
4122 // Std
4123 Handle(TDocStd_Document) doc_std, doc_std_open;
4124 app->NewDocument("MDTV-Standard", doc_std);
4125 // TDataStd_Tick:
4126 TDataStd_Tick::Set(doc_std->Main());
4127 // TDataStd_IntegerList:
4128 Handle(TDataStd_IntegerList) intlist = TDataStd_IntegerList::Set(doc_std->Main());
4129 intlist->Append(1);
4130 intlist->Append(5);
4131 // TDataStd_RealList:
4132 Handle(TDataStd_RealList) dbllist = TDataStd_RealList::Set(doc_std->Main());
4133 dbllist->Append(1.5);
4134 dbllist->Append(5.5);
4135 // TDataStd_ExtStringList:
4136 Handle(TDataStd_ExtStringList) strlist = TDataStd_ExtStringList::Set(doc_std->Main());
4137 strlist->Append("Auf");
4138 strlist->Append("Wiedersehen");
4139 // TDataStd_BooleanList:
4140 Handle(TDataStd_BooleanList) boollist = TDataStd_BooleanList::Set(doc_std->Main());
4141 boollist->Append(Standard_False);
4142 boollist->Append(Standard_True);
4143 // TDataStd_ReferenceList:
4144 TCollection_AsciiString entry1, entry2, entry_first, entry_last;
4145 TDF_Label Lstd1 = doc_std->Main().FindChild(100);
4146 TDF_Tool::Entry(Lstd1, entry1);
4147 TDF_Label Lstd2 = doc_std->Main().FindChild(101);
4148 TDF_Tool::Entry(Lstd2, entry2);
4149 Handle(TDataStd_ReferenceList) reflist = TDataStd_ReferenceList::Set(doc_std->Main());
4150 reflist->Append(Lstd1);
4151 reflist->Append(Lstd2);
4152 // TDataStd_BooleanArray:
4153 Handle(TDataStd_BooleanArray) boolarr = TDataStd_BooleanArray::Set(doc_std->Main(), 15, 18);
4154 boolarr->SetValue(15, Standard_False);
4155 boolarr->SetValue(16, Standard_True);
4156 boolarr->SetValue(17, Standard_True);
4157 boolarr->SetValue(18, Standard_True);
4158 // TDataStd_ReferenceArray:
4159 Handle(TDataStd_ReferenceArray) refarr = TDataStd_ReferenceArray::Set(doc_std->Main(), 45, 46);
4160 refarr->SetValue(45, Lstd1);
4161 refarr->SetValue(46, Lstd2);
4162 // TDataStd_ByteArray:
4163 Handle(TDataStd_ByteArray) bytearr = TDataStd_ByteArray::Set(doc_std->Main(), 15, 18);
4164 bytearr->SetValue(15, 150);
4165 bytearr->SetValue(16, 160);
4166 bytearr->SetValue(17, 170);
4167 bytearr->SetValue(18, 180);
4168 // TDataStd_NamedData:
4169 Handle(TDataStd_NamedData) nameddata = TDataStd_NamedData::Set(doc_std->Main());
4170 // TDF_Reference:
4171 TDF_Label Lstd3 = doc_std->Main().FindChild(103);
4172 Handle(TDF_Reference) ref = TDF_Reference::Set(doc_std->Main(), Lstd3);
4173 //
4174 // Save
15e8b082
M
4175 //if (app->SaveAs(doc_std, "W:\\doc.std") != PCDM_SS_OK)
4176 if (app->SaveAs(doc_std, aFile1) != PCDM_SS_OK)
7fd59977 4177 return 1;
4178 intlist.Nullify();
4179 dbllist.Nullify();
4180 strlist.Nullify();
4181 boollist.Nullify();
4182 reflist.Nullify();
4183 boolarr.Nullify();
4184 ref.Nullify();
4185 app->Close(doc_std);
4186 doc_std.Nullify();
15e8b082
M
4187 //if (app->Open("W:\\doc.std", doc_std_open) != PCDM_RS_OK)
4188 if (app->Open(aFile1, doc_std_open) != PCDM_RS_OK)
7fd59977 4189 return 2;
4190 if (!doc_std_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4191 return 3;
4192 if (!doc_std_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4193 return 4;
4194 if (intlist->First() != 1)
4195 return 5;
4196 if (intlist->Last() != 5)
4197 return 6;
4198 if (!doc_std_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4199 return 4;
4200 if (dbllist->First() != 1.5)
4201 return 5;
4202 if (dbllist->Last() != 5.5)
4203 return 6;
4204 if (!doc_std_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4205 return 4;
4206 if (strlist->First() != "Auf")
4207 return 5;
4208 if (strlist->Last() != "Wiedersehen")
4209 return 6;
4210 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4211 return 4;
4212 if (boollist->First() != Standard_False)
4213 return 5;
4214 if (boollist->Last() != Standard_True)
4215 return 6;
4216 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4217 return 4;
4218 TDF_Tool::Entry(reflist->First(), entry_first);
4219 if (entry1 != entry_first)
4220 return 5;
4221 TDF_Tool::Entry(reflist->Last(), entry_last);
4222 if (entry2 != entry_last)
4223 return 6;
4224 if (!doc_std_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4225 return 4;
4226 if (boolarr->Value(15) != Standard_False)
4227 return 5;
4228 if (boolarr->Value(16) != Standard_True)
4229 return 5;
4230 if (boolarr->Value(17) != Standard_True)
4231 return 5;
4232 if (boolarr->Value(18) != Standard_True)
4233 return 5;
4234 if (!doc_std_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4235 return 4;
4236 TDF_Tool::Entry(refarr->Value(45), entry_first);
4237 if (entry1 != entry_first)
4238 return 5;
4239 TDF_Tool::Entry(refarr->Value(46), entry_last);
4240 if (entry2 != entry_last)
4241 return 6;
4242 if (!doc_std_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4243 return 4;
4244 if (bytearr->Value(15) != 150)
4245 return 5;
4246 if (bytearr->Value(16) != 160)
4247 return 5;
4248 if (bytearr->Value(17) != 170)
4249 return 5;
4250 if (bytearr->Value(18) != 180)
4251 return 5;
4252 if (!doc_std_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4253 return 4;
4254 if (ref->Get().IsNull())
4255 return 5;
4256 if (ref->Get().Tag() != 103)
4257 return 5;
4258
4259 // Xml
4260 Handle(TDocStd_Document) doc_xml, doc_xml_open;
4261 app->NewDocument("XmlOcaf", doc_xml);
4262 // TDataStd_Tick:
4263 TDataStd_Tick::Set(doc_xml->Main());
4264 // TDataStd_IntegerList:
4265 intlist = TDataStd_IntegerList::Set(doc_xml->Main());
4266 intlist->Append(1);
4267 intlist->Append(5);
4268 // TDataStd_RealList:
4269 dbllist = TDataStd_RealList::Set(doc_xml->Main());
4270 dbllist->Append(1.5);
4271 dbllist->Append(5.5);
4272 // TDataStd_ExtStringList:
4273 strlist = TDataStd_ExtStringList::Set(doc_xml->Main());
4274 strlist->Append("Guten ");
4275 strlist->Append("Tag");
4276 // TDataStd_BooleanList:
4277 boollist = TDataStd_BooleanList::Set(doc_xml->Main());
4278 boollist->Append(Standard_False);
4279 boollist->Append(Standard_True);
4280 // TDataStd_ReferenceList:
4281 TDF_Label Lxml1 = doc_xml->Main().FindChild(100);
4282 TDF_Tool::Entry(Lxml1, entry1);
4283 TDF_Label Lxml2 = doc_xml->Main().FindChild(101);
4284 TDF_Tool::Entry(Lxml2, entry2);
4285 reflist = TDataStd_ReferenceList::Set(doc_xml->Main());
4286 reflist->Append(Lxml1);
4287 reflist->Append(Lxml2);
4288 // TDataStd_BooleanArray:
4289 boolarr = TDataStd_BooleanArray::Set(doc_xml->Main(), 15, 24);
4290 boolarr->SetValue(15, Standard_False);
4291 boolarr->SetValue(16, Standard_True);
4292 boolarr->SetValue(17, Standard_True);
4293 boolarr->SetValue(18, Standard_True);
4294 boolarr->SetValue(19, Standard_True);
4295 boolarr->SetValue(20, Standard_True);
4296 boolarr->SetValue(21, Standard_False);
4297 boolarr->SetValue(22, Standard_True);
4298 boolarr->SetValue(23, Standard_True);
4299 boolarr->SetValue(24, Standard_True);
4300 // TDataStd_ReferenceArray:
4301 refarr = TDataStd_ReferenceArray::Set(doc_xml->Main(), 444, 445);
4302 refarr->SetValue(444, Lxml1);
4303 refarr->SetValue(445, Lxml2);
4304 // TDataStd_ByteArray:
4305 bytearr = TDataStd_ByteArray::Set(doc_xml->Main(), 15, 24);
4306 bytearr->SetValue(15, 0);
4307 bytearr->SetValue(16, 10);
4308 bytearr->SetValue(17, 100);
4309 bytearr->SetValue(18, 200);
4310 bytearr->SetValue(19, 250);
4311 bytearr->SetValue(20, 251);
4312 bytearr->SetValue(21, 252);
4313 bytearr->SetValue(22, 253);
4314 bytearr->SetValue(23, 254);
4315 bytearr->SetValue(24, 255);
4316 // TDF_Reference:
4317 Lstd3 = doc_xml->Main().FindChild(103);
4318 ref = TDF_Reference::Set(doc_xml->Main(), Lstd3);
4319 //
4320 // Save
15e8b082
M
4321 //if (app->SaveAs(doc_xml, "W:\\doc.xml") != PCDM_SS_OK)
4322 if (app->SaveAs(doc_xml, aFile2) != PCDM_SS_OK)
7fd59977 4323 return 1;
4324 intlist.Nullify();
4325 ref.Nullify();
4326 app->Close(doc_xml);
4327 doc_xml.Nullify();
15e8b082
M
4328 //if (app->Open("W:\\doc.xml", doc_xml_open) != PCDM_RS_OK)
4329 if (app->Open(aFile2, doc_xml_open) != PCDM_RS_OK)
7fd59977 4330 return 2;
4331 if (!doc_xml_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4332 return 3;
4333 if (!doc_xml_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4334 return 4;
4335 if (intlist->First() != 1)
4336 return 5;
4337 if (intlist->Last() != 5)
4338 return 6;
4339 if (!doc_xml_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4340 return 4;
4341 if (dbllist->First() != 1.5)
4342 return 5;
4343 if (dbllist->Last() != 5.5)
4344 return 6;
4345 if (!doc_xml_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4346 return 4;
4347 if (strlist->First() != "Guten ")
4348 return 5;
4349 if (strlist->Last() != "Tag")
4350 return 6;
4351 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4352 return 4;
4353 if (boollist->First() != Standard_False)
4354 return 5;
4355 if (boollist->Last() != Standard_True)
4356 return 6;
4357 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4358 return 4;
4359 TDF_Tool::Entry(reflist->First(), entry_first);
4360 if (entry1 != entry_first)
4361 return 5;
4362 TDF_Tool::Entry(reflist->Last(), entry_last);
4363 if (entry2 != entry_last)
4364 return 6;
4365 if (!doc_xml_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4366 return 4;
4367 if (boolarr->Value(15) != Standard_False)
4368 return 5;
4369 if (boolarr->Value(16) != Standard_True)
4370 return 5;
4371 if (boolarr->Value(17) != Standard_True)
4372 return 5;
4373 if (boolarr->Value(18) != Standard_True)
4374 return 5;
4375 if (boolarr->Value(19) != Standard_True)
4376 return 5;
4377 if (boolarr->Value(20) != Standard_True)
4378 return 5;
4379 if (boolarr->Value(21) != Standard_False)
4380 return 5;
4381 if (boolarr->Value(22) != Standard_True)
4382 return 5;
4383 if (boolarr->Value(23) != Standard_True)
4384 return 5;
4385 if (boolarr->Value(24) != Standard_True)
4386 return 5;
4387 if (!doc_xml_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4388 return 4;
4389 TDF_Tool::Entry(refarr->Value(444), entry_first);
4390 if (entry1 != entry_first)
4391 return 5;
4392 TDF_Tool::Entry(refarr->Value(445), entry_last);
4393 if (entry2 != entry_last)
4394 return 6;
4395 if (!doc_xml_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4396 return 4;
4397 if (bytearr->Value(15) != 0)
4398 return 5;
4399 if (bytearr->Value(16) != 10)
4400 return 5;
4401 if (bytearr->Value(17) != 100)
4402 return 5;
4403 if (bytearr->Value(18) != 200)
4404 return 5;
4405 if (bytearr->Value(19) != 250)
4406 return 5;
4407 if (bytearr->Value(20) != 251)
4408 return 5;
4409 if (bytearr->Value(21) != 252)
4410 return 5;
4411 if (bytearr->Value(22) != 253)
4412 return 5;
4413 if (bytearr->Value(23) != 254)
4414 return 5;
4415 if (bytearr->Value(24) != 255)
4416 return 5;
4417 if (!doc_xml_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4418 return 4;
4419 if (ref->Get().IsNull())
4420 return 5;
4421 if (ref->Get().Tag() != 103)
4422 return 5;
4423
4424 // Bin
4425 Handle(TDocStd_Document) doc_bin, doc_bin_open;
4426 app->NewDocument("BinOcaf", doc_bin);
4427 // TDataStd_Tick:
4428 TDataStd_Tick::Set(doc_bin->Main());
4429 // TDataStd_IntegerList:
4430 intlist = TDataStd_IntegerList::Set(doc_bin->Main());
4431 intlist->Append(1);
4432 intlist->Append(5);
4433 // TDataStd_RealList:
4434 dbllist = TDataStd_RealList::Set(doc_bin->Main());
4435 dbllist->Append(1.5);
4436 dbllist->Append(5.5);
4437 // TDataStd_ExtStringList:
4438 strlist = TDataStd_ExtStringList::Set(doc_bin->Main());
4439 strlist->Append("Bonjour");
4440 strlist->Append("Bonsoir");
4441 // TDataStd_BooleanList:
4442 boollist = TDataStd_BooleanList::Set(doc_bin->Main());
4443 boollist->Append(Standard_False);
4444 boollist->Append(Standard_True);
4445 // TDataStd_ReferenceList:
4446 TDF_Label Lbin1 = doc_bin->Main().FindChild(100);
4447 TDF_Tool::Entry(Lbin1, entry1);
4448 TDF_Label Lbin2 = doc_bin->Main().FindChild(101);
4449 TDF_Tool::Entry(Lbin2, entry2);
4450 reflist = TDataStd_ReferenceList::Set(doc_bin->Main());
4451 reflist->Append(Lbin1);
4452 reflist->Append(Lbin2);
4453 // TDataStd_BooleanArray:
4454 boolarr = TDataStd_BooleanArray::Set(doc_bin->Main(), 15, 24);
4455 boolarr->SetValue(15, Standard_False);
4456 boolarr->SetValue(16, Standard_True);
4457 boolarr->SetValue(17, Standard_True);
4458 boolarr->SetValue(18, Standard_True);
4459 boolarr->SetValue(19, Standard_True);
4460 boolarr->SetValue(20, Standard_True);
4461 boolarr->SetValue(21, Standard_False);
4462 boolarr->SetValue(22, Standard_True);
4463 boolarr->SetValue(23, Standard_True);
4464 boolarr->SetValue(24, Standard_True);
4465 // TDataStd_ReferenceArray:
4466 refarr = TDataStd_ReferenceArray::Set(doc_bin->Main(), 0, 1);
4467 refarr->SetValue(0, Lbin1);
4468 refarr->SetValue(1, Lbin2);
4469 // TDataStd_ByteArray:
4470 bytearr = TDataStd_ByteArray::Set(doc_bin->Main(), 15, 16);
4471 bytearr->SetValue(15, 0);
4472 bytearr->SetValue(16, 255);
4473 // TDataStd_NamedData:
4474 nameddata = TDataStd_NamedData::Set(doc_bin->Main());
4475 nameddata->SetByte("A", 12);
4476 nameddata->SetByte("B", 234);
4477 // TDF_Reference:
4478 Lstd3 = doc_bin->Main().FindChild(103);
4479 ref = TDF_Reference::Set(doc_bin->Main(), Lstd3);
4480 //
4481 // Save
15e8b082
M
4482 //if (app->SaveAs(doc_bin, "W:\\doc.cbf") != PCDM_SS_OK)
4483 if (app->SaveAs(doc_bin, aFile3) != PCDM_SS_OK)
7fd59977 4484 return 1;
4485 intlist.Nullify();
4486 ref.Nullify();
4487 app->Close(doc_bin);
4488 doc_bin.Nullify();
15e8b082
M
4489 //if (app->Open("W:\\doc.cbf", doc_bin_open) != PCDM_RS_OK)
4490 if (app->Open(aFile3, doc_bin_open) != PCDM_RS_OK)
7fd59977 4491 return 2;
4492 if (!doc_bin_open->Main().IsAttribute(TDataStd_Tick::GetID()))
4493 return 3;
4494 if (!doc_bin_open->Main().FindAttribute(TDataStd_IntegerList::GetID(), intlist))
4495 return 4;
4496 if (intlist->First() != 1)
4497 return 5;
4498 if (intlist->Last() != 5)
4499 return 6;
4500 if (!doc_bin_open->Main().FindAttribute(TDataStd_RealList::GetID(), dbllist))
4501 return 4;
4502 if (dbllist->First() != 1.5)
4503 return 5;
4504 if (dbllist->Last() != 5.5)
4505 return 6;
4506 if (!doc_bin_open->Main().FindAttribute(TDataStd_ExtStringList::GetID(), strlist))
4507 return 4;
4508 if (strlist->First() != "Bonjour")
4509 return 5;
4510 if (strlist->Last() != "Bonsoir")
4511 return 6;
4512 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanList::GetID(), boollist))
4513 return 4;
4514 if (boollist->First() != Standard_False)
4515 return 5;
4516 if (boollist->Last() != Standard_True)
4517 return 6;
4518 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceList::GetID(), reflist))
4519 return 4;
4520 TDF_Tool::Entry(reflist->First(), entry_first);
4521 if (entry1 != entry_first)
4522 return 5;
4523 TDF_Tool::Entry(reflist->Last(), entry_last);
4524 if (entry2 != entry_last)
4525 return 6;
4526 if (!doc_bin_open->Main().FindAttribute(TDataStd_BooleanArray::GetID(), boolarr))
4527 return 4;
4528 if (boolarr->Value(15) != Standard_False)
4529 return 5;
4530 if (boolarr->Value(16) != Standard_True)
4531 return 5;
4532 if (boolarr->Value(17) != Standard_True)
4533 return 5;
4534 if (boolarr->Value(18) != Standard_True)
4535 return 5;
4536 if (boolarr->Value(19) != Standard_True)
4537 return 5;
4538 if (boolarr->Value(20) != Standard_True)
4539 return 5;
4540 if (boolarr->Value(21) != Standard_False)
4541 return 5;
4542 if (boolarr->Value(22) != Standard_True)
4543 return 5;
4544 if (boolarr->Value(23) != Standard_True)
4545 return 5;
4546 if (boolarr->Value(24) != Standard_True)
4547 return 5;
4548 if (!doc_bin_open->Main().FindAttribute(TDataStd_ReferenceArray::GetID(), refarr))
4549 return 4;
4550 TDF_Tool::Entry(refarr->Value(0), entry_first);
4551 if (entry1 != entry_first)
4552 return 5;
4553 TDF_Tool::Entry(refarr->Value(1), entry_last);
4554 if (entry2 != entry_last)
4555 return 6;
4556 if (!doc_bin_open->Main().FindAttribute(TDataStd_ByteArray::GetID(), bytearr))
4557 return 4;
4558 if (bytearr->Value(15) != 0)
4559 return 5;
4560 if (bytearr->Value(16) != 255)
4561 return 5;
4562 if (!doc_bin_open->Main().FindAttribute(TDataStd_NamedData::GetID(), nameddata))
4563 return 4;
4564 if (nameddata->GetByte("A") != 12)
4565 return 5;
4566 if (nameddata->GetByte("B") != 234)
4567 return 5;
4568 if (!doc_bin_open->Main().FindAttribute(TDF_Reference::GetID(), ref))
4569 return 4;
4570 if (ref->Get().IsNull())
4571 return 5;
4572 if (ref->Get().Tag() != 103)
4573 return 5;
4574
4575 return 0;
4576}
4577// For OCC16782 testing
4578
4579static Standard_Integer OCC16782 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4580{
4581 if (argc != 4)
4582 {
4583 di << "Usage : " << argv[0] << " file.std file.xml file.cbf\n";
4584 return 1;
4585 }
4586 TCollection_ExtendedString aFile1(argv[1]);
4587 TCollection_ExtendedString aFile2(argv[2]);
4588 TCollection_ExtendedString aFile3(argv[3]);
4589
4590 if (app.IsNull())
4591 app = new AppStd_Application();
4592
4593 int good = 0;
4594
4595 Handle(TDocStd_Document) doc;
4596 app->NewDocument("MDTV-Standard", doc);
4597 doc->SetUndoLimit(10);
4598
4599 di <<"\nTestSetGet start\n";
4600 good += TestSetGet(doc);
4601 di <<"TestSetGet finish\n";
4602 di <<"Status = " << good << "\n";
4603
4604 di <<"\nTestUndoRedo start\n";
4605 good += TestUndoRedo(doc);
4606 di <<"TestUndoRedo finish\n";
4607 di <<"Status = " << good << "\n";
4608
4609 di <<"\nTestCopyPaste start\n";
4610 good += TestCopyPaste(doc);
4611 di <<"TestCopyPaste finish\n";
4612 di <<"Status = " << good << "\n";
4613
4614 di <<"\nTestOpenSave start\n";
4615 good += TestOpenSave(aFile1, aFile2, aFile3);
4616 di <<"TestOpenSave finish\n";
4617 di <<"Status = " << good << "\n";
4618
4619 if (!good)
4620 di <<"\nThe " << argv[0] << " test is passed well, OK\n";
4621 else
4622 di <<"\nThe " << argv[0] << " test failed, Faulty\n";
4623
4624 return 0;
4625}
4626
4627static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4628{
4629 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
4630 if(aContext.IsNull()) {
4631 di << argv[0] << " ERROR : use 'vinit' command before " << "\n";
4632 return -1;
4633 }
4634
4635 if (argc > 2)
4636 {
4637 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4638 return 1;
4639 }
4640 Standard_Integer mode = 0;
4641 if (argc == 2)
4642 {
4643 mode = atoi(argv[1]);
4644 }
4645 if (mode > 2 || mode < 0)
4646 {
4647 di << "Usage : " << argv[0] << " [mode = 0/1/2]\n";
4648 return 1;
4649 }
4650 Handle(V3d_View) V = ViewerTest::CurrentView();
4651 if ( !V.IsNull() ) {
4652 if (mode == 0) {
4653 V->ColorScaleDisplay();
4654 }
4655 if (mode == 1) {
4656 V->ColorScaleErase();
4657 V->UpdateLights();
4658 V->Update();
4659 }
4660 if (mode == 2) {
4661 Standard_Boolean IsDisplayed = V->ColorScaleIsDisplayed();
4662 if (IsDisplayed)
4663 di <<"ColorScaleIsDisplayed = " << "1" << "\n";
4664 else
4665 di <<"ColorScaleIsDisplayed = " << "0" << "\n";
4666 }
4667 }
4668 return 0;
4669}
4670
4671#include <Interface_Macros.hxx>
4672#include <IGESControl_Controller.hxx>
4673#include <XSDRAW.hxx>
4674#include <Draw_ProgressIndicator.hxx>
4675#include <XSControl_WorkSession.hxx>
4676#include <Transfer_TransientProcess.hxx>
4677#include <XSDRAW_Commands.hxx>
4678#include <TColStd_HSequenceOfTransient.hxx>
4679#include <Message_ProgressSentry.hxx>
4680#include <XSControl_TransferReader.hxx>
4681
4682static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4683{
4684 DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
4685 if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
4686
4687 // Progress indicator
4688 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
4689 progress->SetScale ( 0, 100, 1 );
4690 progress->Show();
4691
4692 IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
4693 if (ctl.IsNull())
4694 ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
4695
4696 TCollection_AsciiString fnom,rnom;
4697
4698 Standard_Boolean modfic = XSDRAW::FileAndVar
4699 (argv[1],argv[2],"IGESBREP",fnom,rnom);
4700 if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
4701 else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
4702 di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
4703 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
4704
4705#ifdef CHRONOMESURE
4706 OSD_Timer Chr; Chr.Reset();
4707 IDT_SetLevel(3);
4708#endif
4709
4710
4711// Reading the file
4712 progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
4713 progress->Show();
4714
4715 // *New*
4716 //In order to decrease number of produced edges during translation it is possible to set following parameter
4717 Interface_Static::SetIVal("read.iges.bspline.continuity",0);
4718 // *New*
4719
4720 if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
4721 else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
4722
4723 progress->EndScope();
4724 progress->Show();
4725
4726 if (readstat != IFSelect_RetDone) {
4727 if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon"<<"\n";
4728 else di<<"No model loaded"<<"\n";
4729 return 1;
4730 }
4731// Choice of treatment
4732 Standard_Boolean fromtcl = (argc > 3);
4733 Standard_Integer modepri = 1, nent, nbs;
4734 if (fromtcl) modepri = 4;
4735
4736 while (modepri) {
4737 //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka
4738 //mode OnlyVisible does not work.
4739 // nent = Reader.NbRootsForTransfer();
4740 if (!fromtcl) {
4741 cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<flush;
4742 modepri = -1;
4743
4744// amv 26.09.2003 : this is used to avoid error of enter's simbol
4745 char str[80];
4746 cin>>str;
4747 modepri = atoi(str);
4748 }
4749
4750 if (modepri == 0) { //fin
4751 di << "Bye and good luck! " << "\n";
4752 break;
4753 }
4754
4755 else if (modepri <= 2) { // 1 : Visible Roots, 2 : All Roots
4756 di << "All Geometry Transfer"<<"\n";
4757 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
4758 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
4759 Handle(XSControl_WorkSession) thesession = Reader.WS();
4760 thesession->ClearContext();
4761 XSDRAW::SetTransferProcess (thesession->MapReader());
4762 progress->NewScope ( 80, "Translation" );
4763 progress->Show();
4764 thesession->MapReader()->SetProgress ( progress );
4765
4766 if (modepri == 1) Reader.SetReadVisible (Standard_True);
4767 Reader.TransferRoots();
4768
4769 thesession->MapReader()->SetProgress ( 0 );
4770 progress->EndScope();
4771 progress->Show();
4772 // result in only one shape for all the roots
4773 // or in one shape for one root.
4774 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
4775 Standard_Integer answer = 1;
4776 if (Reader.NbShapes() > 1) {
4777 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;
4778 answer = -1;
4779 //amv 26.09.2003
4780 char str_a[80];
4781 cin >> str_a;
4782 answer = atoi(str_a);
4783 }
4784 if ( answer == 0) continue;
4785 if ( answer == 1 || answer == 3) {
4786 TopoDS_Shape shape = Reader.OneShape();
4787 // save the shape
4788 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
4789 char fname[110];
4790 sprintf(fname, "%s", rnom.ToCString());
4791 di << "Saving shape in variable Draw : " << fname << "\n";
4792 if (answer == 3) IGESToBRep::WriteShape (shape,1);
4793 try {
4794 OCC_CATCH_SIGNALS
4795 DBRep::Set(fname,shape);
4796 }
4797 catch(Standard_Failure) {
4798 di << "** Exception : ";
4799 di << Standard_Failure::Caught()->GetMessageString();
4800 di<<" ** Skip"<<"\n";
4801 di << "Saving shape in variable Draw : " << fname << "\n";
4802 IGESToBRep::WriteShape (shape,1);
4803 }
4804 }
4805
4806 else if (answer == 2 || answer == 4) {
4807 Standard_Integer numshape = Reader.NbShapes();
4808 for (Standard_Integer inum = 1; inum <= numshape; inum++) {
4809 // save all the shapes
4810 TopoDS_Shape shape = Reader.Shape(inum);
4811 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
4812 char fname[110];
4813 sprintf(fname, "%s_%d", rnom.ToCString(),inum);
4814 di << "Saving shape in variable Draw : " << fname << "\n";
4815 if (answer == 4) IGESToBRep::WriteShape (shape,inum);
4816 try {
4817 OCC_CATCH_SIGNALS
4818 DBRep::Set(fname,shape);
4819 }
4820 catch(Standard_Failure) {
4821 di << "** Exception : ";
4822 di << Standard_Failure::Caught()->GetMessageString();
4823 di<<" ** Skip"<<"\n";
4824 }
4825 }
4826 }
4827 else return 0;
4828 }
4829
4830 else if (modepri == 3) { // One Entity
4831 cout << "Only One Entity"<<endl;
4832 cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<endl;
4833 cout<<" To modify : command param read.iges.bspline.continuity"<<endl;
4834 cout << " give the number of the Entity : " << flush;
4835 nent = XSDRAW::GetEntityNumber();
4836
4837 if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
4838 else {
4839 nbs = Reader.NbShapes();
4840 char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nent);
4841 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
4842 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
4843 TopoDS_Shape sh = Reader.Shape(nbs);
4844 DBRep::Set (shname,sh);
4845 }
4846 }
4847
4848 else if (modepri == 4) { // Selection
4849 Standard_Integer answer = 1;
4850 Handle(TColStd_HSequenceOfTransient) list;
4851
4852// Selection, nommee ou via tcl. tcl : raccourcis admis
4853// * donne iges-visible + xst-transferrable-roots
4854// *r donne xst-model-roots (TOUTES racines)
4855
4856 if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {
4857 di << "All Geometry Transfer"<<"\n";
4858 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
4859 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
4860 Handle(XSControl_WorkSession) thesession = Reader.WS();
4861 thesession->ClearContext();
4862 XSDRAW::SetTransferProcess (thesession->MapReader());
4863 progress->NewScope ( 80, "Translation" );
4864 progress->Show();
4865 thesession->MapReader()->SetProgress ( progress );
4866
4867 Reader.SetReadVisible (Standard_True);
4868 Reader.TransferRoots();
4869
4870 thesession->MapReader()->SetProgress ( 0 );
4871 progress->EndScope();
4872 progress->Show();
4873
4874 // result in only one shape for all the roots
4875 TopoDS_Shape shape = Reader.OneShape();
4876 // save the shape
4877 char fname[110];
4878 sprintf(fname, "%s", rnom.ToCString());
4879 di << "Saving shape in variable Draw : " << fname << "\n";
4880 try {
4881 OCC_CATCH_SIGNALS
4882 DBRep::Set(fname,shape);
4883 }
4884 catch(Standard_Failure) {
4885 di << "** Exception : ";
4886 di << Standard_Failure::Caught()->GetMessageString();
4887 di<<" ** Skip"<<"\n";
4888 di << "Saving shape in variable Draw : " << fname << "\n";
4889 IGESToBRep::WriteShape (shape,1);
4890 }
4891 return 0;
4892 }
4893
4894 if(fromtcl) {
4895 modepri = 0; // d office, une seule passe
4896 if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
4897 di<<"All Roots : ";
4898 list = XSDRAW::GetList ("xst-model-roots");
4899 }
4900 else {
4901 TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
4902 di<<"List given by "<<compart.ToCString()<<" : ";
4903 list = XSDRAW::GetList (compart.ToCString());
4904 }
4905 if (list.IsNull()) {
4906 di<<"No list defined. Give a selection name or * for all visible transferrable roots"<<"\n";
4907 continue;
4908 }
4909 }
4910 else {
4911 cout<<"Name of Selection :"<<flush;
4912 list = XSDRAW::GetList();
4913 if (list.IsNull()) { cout<<"No list defined"<<endl; continue; }
4914 }
4915
4916 Standard_Integer nbl = list->Length();
4917 di<<"Nb entities selected : "<<nbl<<"\n";
4918 if (nbl == 0) continue;
4919 while (answer) {
4920 if (!fromtcl) {
4921 cout<<"Choice: 0 abandon 1 transfer all 2 with confirmation 3 list n0s ents :"<<flush;
4922 answer = -1;
4923 // anv 26.09.2003
4924 char str_answer[80];
4925 cin>>str_answer;
4926 answer = atoi(str_answer);
4927 }
4928 if (answer <= 0 || answer > 3) continue;
4929 if (answer == 3) {
4930 for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
4931 Handle(Standard_Transient) ent = list->Value(ill);
4932 di<<" ";// model->Print(ent,di);
4933 }
4934 di<<"\n";
4935 }
4936 if (answer == 1 || answer == 2) {
4937 Standard_Integer nbt = 0;
4938 Handle(XSControl_WorkSession) thesession = Reader.WS();
4939
4940 XSDRAW::SetTransferProcess (thesession->MapReader());
4941 progress->NewScope ( 80, "Translation" );
4942 progress->Show();
4943 thesession->MapReader()->SetProgress ( progress );
4944
4945 Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
4946 for (Standard_Integer ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
4947
4948 nent = Reader.Model()->Number(list->Value(ill));
4949 if (nent == 0) continue;
4950 if (!Reader.TransferOne(nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
4951 else {
4952 nbs = Reader.NbShapes();
4953 char shname[30]; sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
4954 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
4955 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
4956 TopoDS_Shape sh = Reader.Shape(nbs);
4957 DBRep::Set (shname,sh);
4958 nbt++;
4959 }
4960 }
4961 thesession->MapReader()->SetProgress ( 0 );
4962 progress->EndScope();
4963 progress->Show();
4964 di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
4965 answer = 0; // on ne reboucle pas
4966 }
4967 }
4968 }
4969 else di<<"Unknown mode n0 "<<modepri<<"\n";
4970 }
4971
4972 // *New*
4973 //In order to clear memory after IGES reading you could add the following code
4974 Handle(XSControl_TransferReader) TR = Reader.WS()->TransferReader();
4975 Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
4976 TP->Clear();
4977 TR->Clear(2);
4978 Reader.WS()->Model()->Clear();
4979 Standard_Integer i =1;
4980 for( ; i <= 7; i++)
4981 Reader.WS()->ClearData(i);
4982 // *New*
4983
4984 return 0;
4985}
4986
4987#include <Geom_Plane.hxx>
4988static Standard_Integer OCC20766 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
4989{
4990 if (argc != 6)
4991 {
4992 di << "Usage : " << argv[0] << " plane a b c d\n";
4993 return 1;
4994 }
4995
4996 Standard_Real A = atof(argv[2]);
4997 Standard_Real B = atof(argv[3]);
4998 Standard_Real C = atof(argv[4]);
4999 Standard_Real D = atof(argv[5]);
5000
5001 Handle(Geom_Geometry) result;
5002
5003 Handle(Geom_Plane) aPlane = new Geom_Plane(A, B, C, D);
5004 result = aPlane;
5005
5006 DrawTrSurf::Set(argv[1],result);
5007 return 0;
5008}
5009
5010static Standard_Integer OCC20627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5011{
5012 if(argc!=2)
5013 {
5014 di << "Usage : " << argv[0] << " MaxNbr" << "\n";
5015 return -1;
5016 }
5017 Standard_Integer aMaxNbr = atoi(argv[1]);
5018
5019 for (Standard_Integer i=0;i<aMaxNbr;i++)
5020 {
5021 BRepBuilderAPI_MakePolygon w(gp_Pnt(0,0,0),gp_Pnt(0,100,0),gp_Pnt(20,100,0),gp_Pnt(20,0,0));
5022 w.Close();
5023 TopoDS_Wire wireShape( w.Wire());
5024 BRepBuilderAPI_MakeFace faceBuilder(wireShape);
5025 TopoDS_Face f( faceBuilder.Face());
5026 BRepMesh_IncrementalMesh im(f,1);
5027 BRepTools::Clean(f);
5028 }
5029 return 0;
5030}
5031
ef8ca55b
D
5032#include <Graphic3d_Vector.hxx>
5033Standard_Integer OCC22762 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5034{
5035 if (argc!=7)
5036 {
5037 di << "Wrong number of arguments" << "\n";
5038 return -1;
5039 }
5040 Standard_Real X1_Pnt = atof(argv[1]);
5041 Standard_Real Y1_Pnt = atof(argv[2]);
5042 Standard_Real Z1_Pnt = atof(argv[3]);
5043 Standard_Real X2_Pnt = atof(argv[4]);
5044 Standard_Real Y2_Pnt = atof(argv[5]);
5045 Standard_Real Z2_Pnt = atof(argv[6]);
5046
5047 Graphic3d_Vector AV1(X1_Pnt, Y1_Pnt, Z1_Pnt);
5048 Graphic3d_Vector AV2(X2_Pnt, Y2_Pnt, Z2_Pnt);
5049
5050 di << "Result is: " << (Graphic3d_Vector::IsParallel(AV1, AV2) ? "true" : "false") << "\n" ;
5051 return 0;
5052}
5053
5054
5055
5056
7fd59977 5057#include <IntCurvesFace_ShapeIntersector.hxx>
5058#include <gp_Lin.hxx>
5059Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5060{
5061 if(argc!=9)
5062 {
5063 di << "Usage : " << argv[0] << " shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf" << "\n";
5064 return -1;
5065 }
5066
5067 TopoDS_Shape shape = DBRep::Get(argv[1]);
5068
5069 if (shape.IsNull()) {
5070 di<<" Null shape is not allowed";
5071 return 1;
5072 }
5073
5074 Standard_Real X_Pnt = atof(argv[2]);
5075 Standard_Real Y_Pnt = atof(argv[3]);
5076 Standard_Real Z_Pnt = atof(argv[4]);
5077
5078 Standard_Real X_Dir = atof(argv[5]);
5079 Standard_Real Y_Dir = atof(argv[6]);
5080 Standard_Real Z_Dir = atof(argv[7]);
5081
5082 Standard_Real PInf = atof(argv[8]);
5083
5084 IntCurvesFace_ShapeIntersector intersector;
5085 intersector.Load(shape, Precision::Intersection());
5086
5087 gp_Pnt origin(X_Pnt, Y_Pnt, Z_Pnt);
5088 gp_Dir dir(X_Dir, Y_Dir, Z_Dir);
5089 gp_Lin ray(origin, dir);
5090
5091 Standard_Real PSup = RealLast();
5092 intersector.PerformNearest(ray, PInf, PSup);
5093 if (intersector.NbPnt() != 0)
5094 {
5095 di << argv[0] << " status = 0 \n";
5096 Standard_Real w = intersector.WParameter(1);
5097 di << "w = " << w << "\n";
5098 } else {
5099 di << argv[0] << " status = -1 \n";
5100 }
5101 return 0;
5102}
5103
62110ee7
M
5104Standard_Integer OCC22301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5105{
5106 if (argc != 1) {
5107 di << "Usage : " << argv[0] << "\n";
5108 return 1;
5109 }
5110
5111 // Create mask 1111: extent == 4
5112 TColStd_PackedMapOfInteger aFullMask;
5113 for (Standard_Integer i = 0; i < 4; i++)
5114 aFullMask.Add(i);
5115
5116 // Create mask 1100: extent == 2
5117 TColStd_PackedMapOfInteger aPartMask;
5118 for (Standard_Integer i = 0; i < 2; i++)
5119 aPartMask.Add(i);
5120
5121 di << "aFullMask = 1111" << "\n";
5122 di << "aPartMask = 1100" << "\n";
5123
5124 Standard_Boolean isAffected;
5125
5126 isAffected = aFullMask.Intersect(aPartMask); // true; extent == 2 (OK)
5127 di << "First time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5128 isAffected = aFullMask.Intersect(aPartMask); // true; extent == 0 (?)
5129 di << "Second time: aFullMask.Intersect(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5130 isAffected = aFullMask.Subtract(aPartMask); // false (?)
5131 di << "After two intersections: aFullMask.Subtract(aPartMask), isAffected = " << (Standard_Integer)isAffected << "\n";
5132
5133 return 0;
5134}
5135#include <ShapeFix_FixSmallFace.hxx>
5136Standard_Integer OCC22586 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5137{
5138
5139 if (argc != 3) {
5140 di << "Usage : " << argv[0] << " shape resshape\n";
5141 return 1;
5142 }
5143
5144 // try to read a shape:
5145 TopoDS_Shape aShape=DBRep::Get(argv[1]);
5146 ShapeFix_FixSmallFace aFixSmallFaces;
5147 aFixSmallFaces.Init (aShape);
5148 aFixSmallFaces.Perform();
5149 TopoDS_Shape aResShape = aFixSmallFaces.Shape();
5150 DBRep::Set(argv[2],aResShape);
5151
5152 return 0;
5153
5154}
5155
7fa0a598
S
5156#include <NCollection_DataMap.hxx>
5157Standard_Integer OCC22744 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5158{
5159
5160 if (argc != 1) {
5161 di << "Usage : " << argv[0] << "\n";
5162 return 1;
5163 }
5164
5165 TCollection_ExtendedString anExtString;
5166
5167 Standard_ExtCharacter aNonAsciiChar = 0xff00;
5168 anExtString.Insert(1, aNonAsciiChar);
5169
5170 di << "Is ASCII: " << ( anExtString.IsAscii() ? "true" : "false" ) << "\n";
5171 NCollection_DataMap<TCollection_ExtendedString, Standard_Integer> aMap;
5172 aMap.Bind(anExtString, 0);
5173
5174 return 0;
5175
5176}
5177
4714a7a6
SJ
5178Standard_Integer OCC22736 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5179{
5180
5181 if (argc != 9) {
5182 di << "Usage : " << argv[0] << " X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2\n";
5183 return 1;
5184 }
5185
5186 Standard_Real X_mirrorFirstPoint = atof(argv[1]);
5187 Standard_Real Y_mirrorFirstPoint = atof(argv[2]);
5188 Standard_Real X_mirrorSecondPoint = atof(argv[3]);
5189 Standard_Real Y_mirrorSecondPoint = atof(argv[4]);
5190 Standard_Real X_p1 = atof(argv[5]);
5191 Standard_Real Y_p1 = atof(argv[6]);
5192 Standard_Real X_p2 = atof(argv[7]);
5193 Standard_Real Y_p2 = atof(argv[8]);
5194
5195 gp_Trsf2d identityTransformation;
5196
5197 gp_Pnt2d mirrorFirstPoint(X_mirrorFirstPoint,Y_mirrorFirstPoint);
5198 gp_Pnt2d mirrorSecondPoint(X_mirrorSecondPoint,Y_mirrorSecondPoint);
5199 gp_Ax2d mirrorAxis(mirrorFirstPoint,gp_Vec2d(mirrorFirstPoint,mirrorSecondPoint));
5200
5201 gp_Pnt2d p1(X_p1,Y_p1);
5202 gp_Pnt2d p2(X_p2,Y_p2);
5203
5204 gp_Trsf2d M1;
5205 M1.SetMirror(mirrorAxis);
5206 gp_Trsf2d M2;
5207 M2.SetMirror(mirrorAxis);
5208 gp_Trsf2d Tcomp;
5209 Tcomp = M2.Multiplied(M1);
5210
5211 Standard_Real aTol = Precision::Confusion();
5212 Standard_Integer aStatus = 0;
5213
5214 //After applying two times the same mirror the point is located on the same location OK
5215 gp_Pnt2d p1MirrorM1 = p1.Transformed(M1);
5216 if ( Abs(p2.X() - p1MirrorM1.X()) > aTol )
5217 aStatus = 2;
5218 if ( Abs(p2.Y() - p1MirrorM1.Y()) > aTol )
5219 aStatus = 3;
5220
5221 gp_Pnt2d p1MirrorM1M2 = p1MirrorM1.Transformed(M2);
5222 if ( Abs(p1.X() - p1MirrorM1M2.X()) > aTol )
5223 aStatus = 4;
5224 if ( Abs(p1.Y() - p1MirrorM1M2.Y()) > aTol )
5225 aStatus = 5;
5226
5227 //If we apply the composed transformation of the same two mirrors to a point the result is //not located on the initial position.-->>ERROR
5228 gp_Pnt2d p1MirrorComp = p1.Transformed(Tcomp);
5229 if ( Abs(p1.X() - p1MirrorComp.X()) > aTol )
5230 aStatus = 6;
5231 if ( Abs(p1.Y() - p1MirrorComp.Y()) > aTol )
5232 aStatus = 7;
5233
5234 di << "Status = " << aStatus << "\n";
5235 return 0;
4714a7a6
SJ
5236}
5237
251450e5
P
5238#include <BOPTColStd_CArray1OfInteger.hxx>
5239//=======================================================================
5240//function : DumpArray
5241//purpose :
5242//=======================================================================
5243void DumpArray(const BOPTColStd_CArray1OfInteger& aC,
5244 Draw_Interpretor& aDI)
5245{
5246 Standard_Integer iLength, iFactLength, iBlockLength;
5247 //
5248 iLength=aC.Length();
5249 iFactLength=aC.FactLength();
5250 iBlockLength=aC.BlockLength();
5251 //
5252 aDI<< "Length: " <<iLength << "\n";
5253 aDI<< "FactLength: " <<iFactLength << "\n";
5254 aDI<< "BlockLength: " <<iBlockLength << "\n";
5255}
5256//=======================================================================
5257//function : bcarray
5258//purpose :
5259//=======================================================================
5260Standard_Integer bcarray (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
5261{
5262
5263 if (argc != 1) {
5264 di << "Usage : " << argv[0] << "\n";
5265 return 1;
5266 }
5267
5268 Standard_Integer i, aNb, aBL;
5269 BOPTColStd_CArray1OfInteger aC;
5270 //
5271 aBL=100000;
5272 aC.SetBlockLength(aBL);
5273 //
5274 for (i=1; i<=10; ++i) {
5275 aC.Append(-i*10);
5276 }
5277 di<< "\nstate before release the unused memory\n";
5278 DumpArray(aC, di);
5279 //
5280 aC.Purge();
5281 //
5282 di<< "\nstate after release the unused memory\n";
5283 DumpArray(aC, di);
5284 //
5285 return 0;
5286}
5287
7fd59977 5288void QAOCC::Commands(Draw_Interpretor& theCommands) {
5289 const char *group = "QAOCC";
5290
5291 theCommands.Add("OCC128", "OCC128", __FILE__, OCC128, group);
5292
5293 // Remove as bad version of QAAddOrRemoveSelected from QADraw
5294 //theCommands.Add("OCC129", "OCC129 shape islocal", __FILE__, OCC129, group);
5295
5296 theCommands.Add("OCC136", "OCC136", __FILE__, OCC136, group);
5297 theCommands.Add("BUC60610","BUC60610 iges_input [name]",__FILE__,BUC60610,group);
5298 theCommands.Add("BUC60661","BUC60661 file.igs",__FILE__,BUC60661, group);
5299
5300//====================================================
5301//
5302// Following commands are inserted from
5303// /dn03/KAS/dev/QAopt/src/QADraw/QADraw_TOPOLOGY.cxx
5304// ( 75455 Apr 16 18:59)
5305//
5306//====================================================
5307
5308 theCommands.Add("OCC105","OCC105 shape",__FILE__,OCC105,group);
5309 theCommands.Add("OCC9"," result path cur1 cur2 radius [tolerance]:\t test GeomFill_Pipe", __FILE__, pipe_OCC9,group);
5310
5311 theCommands.Add("OCC125","OCC125 shell", __FILE__, OCC125,group);
5312
5313 theCommands.Add("OCC157","findplanarsurface Result wire Tol",__FILE__,OCC157,group);
5314 //theCommands.Add("OCC165","OCC165",__FILE__,OCC165,group);
5315 theCommands.Add("OCC165","OCC165 file",__FILE__,OCC165,group);
5316 theCommands.Add("OCC297","OCC297",__FILE__,OCC297,group);
5317 //theCommands.Add("OCC305","OCC305",__FILE__,OCC305,group);
5318 theCommands.Add("OCC305","OCC305 file",__FILE__,OCC305,group);
5319
5320 // New commands:
5321 theCommands.Add("OCC166", "OCC166", __FILE__, OCC166, group);
5322 theCommands.Add("OCC381_Save", "OCC381_Save Doc", __FILE__, OCC381_Save, group);
5323 theCommands.Add("OCC381_SaveAs", "OCC381_SaveAs Doc Path", __FILE__, OCC381_SaveAs, group);
5324
5325 theCommands.Add("OCC299","OCC299 Solid Point [Tolerance=1.e-7]", __FILE__, OCC299bug, group);
5326 theCommands.Add("OCC309","OCC309", __FILE__, OCC309bug, group);
5327 theCommands.Add("OCC310","OCC310", __FILE__, OCC310bug, group);
5328
5329 //theCommands.Add("OCC277","OCC277", __FILE__, OCC277bug, group);
5330 theCommands.Add("OCC277","OCC277 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC277bug, group);
5331
5332 theCommands.Add("OCC333","OCC333 edge1 edge2 [toler domaindist]; Check overlapping edges", __FILE__, OCC333bug, group);
5333
5334 theCommands.Add("OCC363", "OCC363 document filename ", __FILE__, OCC363, group);
5335 // Must use OCC299
5336 //theCommands.Add("OCC372", "OCC372", __FILE__, OCC372, group);
5337 theCommands.Add("OCC377", "OCC377", __FILE__, OCC377, group);
5338 theCommands.Add("OCC22", "OCC22 Result Shape CompoundOfSubshapesToBeDivided ConsiderLocation", __FILE__, OCC22, group);
5339 theCommands.Add("OCC24", "OCC24 Result Shape CompoundOfSubshapes ResourceFileName", __FILE__, OCC24, group);
5340 theCommands.Add("OCC369", "OCC369 Shape", __FILE__, OCC369, group);
5341 theCommands.Add("OCC524", "OCC524 LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix", __FILE__, OCC524, group);
5342 theCommands.Add("OCC525", "OCC525", __FILE__, OCC525, group);
5343 theCommands.Add("OCC543", "OCC543 name", __FILE__, OCC543, group);
5344 //theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
5345 theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC578, group);
5346 theCommands.Add("OCC627", "OCC627", __FILE__, OCC627, group);
7fd59977 5347 theCommands.Add("OCC669", "OCC669 GUID", __FILE__, OCC669, group);
5348 theCommands.Add("OCC738_ShapeRef", "OCC738_ShapeRef", __FILE__, OCC738_ShapeRef, group);
5349 theCommands.Add("OCC738_Assembly", "OCC738_Assembly", __FILE__, OCC738_Assembly, group);
5350 theCommands.Add("OCC708", "OCC708 shape ; Deactivate the current transformation", __FILE__, OCC708, group);
5351 theCommands.Add("OCC670", "OCC670", __FILE__, OCC670, group);
5352 theCommands.Add("OCC867", "OCC867 Point Surface Umin Usup Vmin Vsup", __FILE__, OCC867, group);
5353 theCommands.Add("OCC909", "OCC909 wire face", __FILE__, OCC909, group);
5354 theCommands.Add("OCC921", "OCC921 face", __FILE__, OCC921, group);
5355 theCommands.Add("OCC902", "OCC902 expression", __FILE__, OCC902, group);
5356
5357 theCommands.Add ("OCC1029_AISTransparency","OCC1029_AISTransparency (DOC, entry, [real])",__FILE__, OCC1029_AISTransparency, group);
5358 theCommands.Add ("OCC1030_AISColor", "OCC1030_AISColor (DOC, entry, [color])", __FILE__, OCC1030_AISColor, group);
5359 theCommands.Add ("OCC1031_AISMaterial", "OCC1031_AISMaterial (DOC, entry, [material])", __FILE__, OCC1031_AISMaterial, group);
5360 theCommands.Add ("OCC1032_AISWidth", "OCC1032_AISWidth (DOC, entry, [width])", __FILE__, OCC1032_AISWidth, group);
5361 theCommands.Add ("OCC1033_AISMode", "OCC1033_AISMode (DOC, entry, [mode])", __FILE__, OCC1033_AISMode, group);
5362 theCommands.Add ("OCC1034_AISSelectionMode", "OCC1034_AISSelectionMode (DOC, entry, [selectionmode])", __FILE__, OCC1034_AISSelectionMode, group);
5363
5364 //theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape", __FILE__, OCC1487, group);
5365 theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC1487, group);
5366
5367 theCommands.Add("OCC1077", "OCC1077 result", __FILE__, OCC1077, group);
5368 theCommands.Add("OCC5739", "OCC5739 name shape step", __FILE__, OCC5739_UniAbs, group);
5369 theCommands.Add("OCC6046", "OCC6046 nb_of_vectors size", __FILE__, OCC6046, group);
5370 theCommands.Add("OCC5698", "OCC5698 wire", __FILE__, OCC5698, group);
5371 theCommands.Add("OCC6143", "OCC6143", __FILE__, OCC6143, group);
5372 theCommands.Add("OCC7141", "OCC7141 [nCount]", __FILE__, OCC7141, group);
5373 theCommands.Add("OCC7372", "OCC7372", __FILE__, OCC7372, group);
5374 theCommands.Add("OCC8169", "OCC8169 edge1 edge2 plane", __FILE__, OCC8169, group);
5375 theCommands.Add("OCC10138", "OCC10138 lower upper", __FILE__, OCC10138, group);
5376 theCommands.Add("OCC7639", "OCC7639 index1 value1 ... [indexN valueN]", __FILE__, OCC7639, group);
5377 theCommands.Add("OCC8797", "OCC8797", __FILE__, OCC8797, group);
5378 theCommands.Add("OCC7068", "OCC7068", __FILE__, OCC7068, group);
5379 theCommands.Add("OCC11457", "OCC11457 polygon lastedge x1 y1 z1 x2 y2 z2 ...", __FILE__, OCC11457, group);
5380 theCommands.Add("OCC13963", "OCC13963 ratio origin_x origin_y origin_z", __FILE__, OCC13963, group);
5381 theCommands.Add("OCC14376", "OCC14376 shape [deflection]", __FILE__, OCC14376, group);
5382 theCommands.Add("OCC15489", "OCC15489 A B C", __FILE__, OCC15489, group);
5383 theCommands.Add("OCC15755", "OCC15755 file shape", __FILE__, OCC15755, group);
5384 theCommands.Add("OCC16782", "OCC16782 file.std file.xml file.cbf", __FILE__, OCC16782, group);
5385 theCommands.Add("OCC12584", "OCC12584 [mode = 0/1/2]", __FILE__, OCC12584, group);
5386 theCommands.Add("OCC18612", "OCC18612 [file else already loaded model] [name DRAW]", __FILE__, OCC18612igesbrep, group);
5387 theCommands.Add("OCC20766", "OCC20766 plane a b c d", __FILE__, OCC20766, group);
5388 theCommands.Add("OCC20627", "OCC20627", __FILE__, OCC20627, group);
5389 theCommands.Add("OCC17424", "OCC17424 shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf", __FILE__, OCC17424, group);
62110ee7
M
5390 theCommands.Add("OCC22301", "OCC22301", __FILE__, OCC22301, group);
5391 theCommands.Add("OCC22586", "OCC22586 shape resshape", __FILE__, OCC22586, group);
4714a7a6 5392 theCommands.Add("OCC22736", "OCC22736 X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2", __FILE__, OCC22736, group);
7fa0a598 5393 theCommands.Add("OCC22744", "OCC22744", __FILE__, OCC22744, group);
251450e5 5394 theCommands.Add("bcarray", "bcarray", __FILE__, bcarray, group);
ef8ca55b 5395 theCommands.Add("OCC22762", "OCC22762 x1 y1 z1 x2 y2 z3", __FILE__, OCC22762, group);
7fd59977 5396 return;
5397}