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