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