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