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