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