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