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