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