Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2002-05-21 |
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 | |
1cd84fee | 16 | #include <QABugs.hxx> |
7fd59977 | 17 | |
18 | #include <Draw_Interpretor.hxx> | |
19 | #include <DBRep.hxx> | |
20 | #include <DrawTrSurf.hxx> | |
7fd59977 | 21 | #include <ViewerTest.hxx> |
4a350f94 | 22 | #include <V3d_View.hxx> |
7fd59977 | 23 | #include <TopoDS_Shape.hxx> |
f376ac72 | 24 | #include <AIS_InteractiveContext.hxx> |
25 | #include <AIS_TexturedShape.hxx> | |
26 | #include <Image_PixMap.hxx> | |
27 | #include <Image_Color.hxx> | |
7fd59977 | 28 | |
29 | #include <gp_Pnt2d.hxx> | |
f6f03db9 | 30 | #include <gp_Ax1.hxx> |
7fd59977 | 31 | #include <GCE2d_MakeSegment.hxx> |
32 | #include <Geom2d_TrimmedCurve.hxx> | |
33 | #include <DrawTrSurf.hxx> | |
34 | ||
f6f03db9 | 35 | #include <Precision.hxx> |
36 | ||
7fd59977 | 37 | #include <PCollection_HAsciiString.hxx> |
38 | ||
c2ae831c | 39 | #include <cstdio> |
40 | #include <cmath> | |
41 | #include <iostream> | |
42 | #include <OSD_PerfMeter.hxx> | |
43 | #include <OSD_Timer.hxx> | |
44 | #include <BRepPrimAPI_MakeBox.hxx> | |
45 | #include <BRepPrimAPI_MakeSphere.hxx> | |
46 | #include <BRepAlgo_Cut.hxx> | |
ab2db9a5 | 47 | #include <NCollection_Map.hxx> |
dda67c1c | 48 | #include <NCollection_Handle.hxx> |
29cb310a | 49 | #include <TCollection_HAsciiString.hxx> |
2cd138b8 | 50 | #include <GeomFill_Trihedron.hxx> |
51 | #include <BRepOffsetAPI_MakePipe.hxx> | |
29cb310a | 52 | |
05d7de53 | 53 | #include <Standard_Version.hxx> |
54 | ||
29cb310a | 55 | #define QCOMPARE(val1, val2) \ |
56 | di << "Checking " #val1 " == " #val2 << \ | |
57 | ((val1) == (val2) ? ": OK\n" : ": Error\n") | |
d2786814 | 58 | |
7fd59977 | 59 | static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
60 | { | |
61 | if ( argc != 4) { | |
62 | di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d" << "\n"; | |
63 | return 1; | |
64 | } | |
65 | ||
66 | gp_Pnt2d P1, P2; | |
67 | if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) { | |
68 | di << "ERROR OCC230: " << argv[2] << " is not Pnt2d" << "\n"; | |
69 | return 1; | |
70 | } | |
71 | if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) { | |
72 | di << "ERROR OCC230: " << argv[3] << " is not Pnt2d" << "\n"; | |
73 | return 1; | |
74 | } | |
75 | ||
76 | GCE2d_MakeSegment MakeSegment(P1,P2); | |
77 | Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value(); | |
78 | DrawTrSurf::Set(argv[1], TrimmedCurve); | |
79 | return 0; | |
80 | } | |
81 | ||
82 | static Standard_Integer OCC142 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) | |
83 | { | |
84 | for(Standard_Integer i= 0;i <= 20;i++){ | |
85 | Handle(PCollection_HAsciiString) pstr = new PCollection_HAsciiString("TEST"); | |
86 | pstr->Clear(); | |
87 | } | |
88 | di << "OCC142: OK" << "\n"; | |
89 | return 0; | |
90 | } | |
91 | ||
f6f03db9 | 92 | static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
93 | { | |
94 | gp_Pnt p(0, 0, 2); | |
95 | ||
96 | gp_Trsf t1, t2; | |
97 | t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267); | |
98 | t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880); | |
99 | ||
100 | gp_Trsf tComp = t2 * t1; | |
101 | ||
102 | gp_Pnt p1(10, 3, 4); | |
103 | gp_Pnt p2 = p1.Transformed(tComp); | |
104 | gp_Pnt p3 = p1.Transformed(t1); | |
105 | p3.Transform(t2); | |
106 | ||
107 | // points must be equal | |
108 | if ( ! p2.IsEqual(p3, Precision::Confusion()) ) | |
109 | di << "ERROR OCC23361: equivalent transformations does not produce equal points" << "\n"; | |
110 | else | |
111 | di << "OCC23361: OK" << "\n"; | |
112 | ||
113 | return 0; | |
114 | } | |
115 | ||
c2ae831c | 116 | static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/) |
117 | { | |
118 | OSD_PerfMeter aPM("TestMeter",0); | |
119 | OSD_Timer aTM; | |
120 | ||
121 | // run some operation in cycle for about 2 seconds to have good values of times to compare | |
122 | int count = 0; | |
123 | printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n"); | |
124 | for (; aTM.ElapsedTime() < 2.; count++) | |
125 | { | |
126 | aPM.Start(); | |
127 | aTM.Start(); | |
128 | ||
b3a7aa39 | 129 | // do some operation that will take considerable time compared with time of starting / stopping timers |
c2ae831c | 130 | BRepPrimAPI_MakeBox aBox (10., 10., 10.); |
131 | BRepPrimAPI_MakeSphere aSphere (10.); | |
b3a7aa39 | 132 | BRepAlgo_Cut aCutter (aBox.Shape(), aSphere.Shape()); |
c2ae831c | 133 | |
134 | aTM.Stop(); | |
135 | aPM.Stop(); | |
136 | } | |
137 | ||
138 | int aNbEnters = 0; | |
139 | Standard_Real aPerfMeter_CPUtime = 0., aTimer_ElapsedTime = aTM.ElapsedTime(); | |
140 | ||
141 | perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime); | |
142 | ||
143 | Standard_Real aTimeDiff = (fabs(aTimer_ElapsedTime - aPerfMeter_CPUtime) / aTimer_ElapsedTime); | |
144 | ||
145 | printf("\nMeasurement results (%d cycles):\n", count); | |
146 | printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer elapsed time: %lf\n", aPerfMeter_CPUtime, aTimer_ElapsedTime); | |
147 | printf("Time delta is: %.3lf %%\n", aTimeDiff * 100); | |
148 | ||
149 | if (aTimeDiff > 0.2) | |
150 | di << "OCC23237: Error: too much difference between CPU and elapsed times"; | |
151 | else if (aNbEnters != count) | |
152 | di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles"; | |
153 | else | |
154 | di << "OCC23237: OK"; | |
155 | ||
156 | return 0; | |
157 | } | |
158 | ||
1365140b RL |
159 | #ifdef HAVE_TBB |
160 | ||
161 | #include <Standard_Atomic.hxx> | |
162 | #include <tbb/blocked_range.h> | |
163 | #include <tbb/parallel_for.h> | |
164 | ||
165 | class IncrementerDecrementer | |
166 | { | |
167 | public: | |
168 | IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive) | |
169 | {} | |
170 | void operator() (const tbb::blocked_range<size_t>& r) const | |
171 | { | |
172 | if (myPositive) | |
173 | for (size_t i = r.begin(); i != r.end(); ++i) | |
174 | Standard_Atomic_Increment (myVal); | |
175 | else | |
176 | for (size_t i = r.begin(); i != r.end(); ++i) | |
177 | Standard_Atomic_Decrement (myVal); | |
178 | } | |
179 | private: | |
180 | Standard_Integer* myVal; | |
181 | Standard_Boolean myPositive; | |
182 | }; | |
183 | #endif | |
184 | ||
1365140b RL |
185 | #ifdef HAVE_TBB |
186 | static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) | |
187 | { | |
188 | int aSum = 0; | |
189 | ||
190 | //check returned value | |
191 | QCOMPARE (Standard_Atomic_Decrement (&aSum), -1); | |
192 | QCOMPARE (Standard_Atomic_Increment (&aSum), 0); | |
193 | QCOMPARE (Standard_Atomic_Increment (&aSum), 1); | |
194 | QCOMPARE (Standard_Atomic_Increment (&aSum), 2); | |
195 | // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0); | |
196 | // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1); | |
197 | ||
198 | //check atomicity | |
199 | aSum = 0; | |
200 | const int N = 1 << 24; //big enough to ensure concurrency | |
201 | ||
202 | //increment | |
203 | tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, true)); | |
204 | QCOMPARE (aSum, N); | |
205 | ||
206 | //decrement | |
207 | tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, false)); | |
208 | QCOMPARE (aSum, 0); | |
209 | ||
210 | return 0; | |
211 | } | |
212 | ||
213 | #else /* HAVE_TBB */ | |
214 | ||
215 | static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char **argv) | |
216 | { | |
217 | di << "Test skipped: command " << argv[0] << " requires TBB library\n"; | |
218 | return 0; | |
219 | } | |
220 | ||
221 | #endif /* HAVE_TBB */ | |
222 | ||
e6aad0ee RL |
223 | #include <TDocStd_Application.hxx> |
224 | #include <XCAFApp_Application.hxx> | |
225 | #include <TDocStd_Document.hxx> | |
226 | #include <XCAFDoc_ShapeTool.hxx> | |
227 | #include <XCAFDoc_DocumentTool.hxx> | |
228 | #include <TDF_Label.hxx> | |
229 | #include <TDataStd_Name.hxx> | |
230 | ||
773f53f1 | 231 | static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/) |
e6aad0ee RL |
232 | { |
233 | const Handle(TDocStd_Application)& anApp = XCAFApp_Application::GetApplication(); | |
234 | Handle(TDocStd_Document) aDoc; | |
235 | anApp->NewDocument ("XmlXCAF", aDoc); | |
236 | QCOMPARE (!aDoc.IsNull(), Standard_True); | |
237 | ||
238 | Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main()); | |
239 | ||
240 | //check default value | |
241 | Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming(); | |
242 | QCOMPARE (aValue, Standard_True); | |
243 | ||
244 | //true | |
245 | XCAFDoc_ShapeTool::SetAutoNaming (Standard_True); | |
246 | TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape(); | |
247 | TDF_Label aLabel = aShTool->AddShape (aShape); | |
248 | Handle(TDataStd_Name) anAttr; | |
249 | QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True); | |
250 | ||
251 | //false | |
252 | XCAFDoc_ShapeTool::SetAutoNaming (Standard_False); | |
253 | aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape(); | |
254 | aLabel = aShTool->AddShape (aShape); | |
255 | QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True); | |
256 | ||
257 | //restore | |
258 | XCAFDoc_ShapeTool::SetAutoNaming (aValue); | |
259 | ||
260 | return 0; | |
261 | } | |
262 | ||
5d1833ef | 263 | #include <ExprIntrp_GenExp.hxx> |
264 | Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
265 | { | |
266 | ||
267 | if (argc != 3) { | |
268 | di << "Usage : " << argv[0] << " string nb\n"; | |
269 | return 1; | |
270 | } | |
271 | ||
272 | TCollection_AsciiString aToken = argv[1]; | |
273 | Standard_Integer aNb = atoi(argv[2]); | |
274 | ||
275 | Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create(); | |
276 | for (Standard_Integer i=0; i < aNb; i++) | |
277 | { | |
278 | aGen->Process(aToken); | |
279 | Handle(Expr_GeneralExpression) aExpr = aGen->Expression(); | |
280 | } | |
281 | ||
282 | return 0; | |
283 | } | |
284 | ||
35e08fe8 | 285 | Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
e187cc0a | 286 | { |
287 | gp_Mat M0; | |
288 | di << "M0 = " | |
289 | << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}" | |
290 | << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}" | |
291 | << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"; | |
292 | return 0; | |
293 | } | |
294 | ||
bead40f2 | 295 | #include <TopoDS_Face.hxx> |
296 | #include <TopoDS_Face.hxx> | |
297 | #include <TopoDS.hxx> | |
298 | #include <BRepBuilderAPI_Transform.hxx> | |
299 | #include <BRepExtrema_DistShapeShape.hxx> | |
300 | #include <BRepTools.hxx> | |
301 | ||
f24125b9 | 302 | static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di) |
bead40f2 | 303 | { |
304 | BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN); | |
305 | if(!distShapeShape.IsDone()) { | |
306 | di <<"Distance ShapeShape is Not Done\n"; | |
307 | return Standard_False; | |
308 | } | |
309 | ||
310 | if(distShapeShape.Value() > 0.01) { | |
311 | di << "Wrong Dist = " <<distShapeShape.Value() << "\n"; | |
312 | return Standard_False; | |
313 | } else | |
314 | di << "Dist0 = " <<distShapeShape.Value() <<"\n"; | |
315 | ||
316 | ////////////////////////////////////////////////////////////////////////// | |
317 | /// First Flip Y | |
318 | const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970); | |
319 | const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970); | |
320 | ||
321 | gp_Vec2d mirrorVector1(axis1P1,axis1P2); | |
322 | ||
323 | gp_Trsf2d mirror1; | |
324 | mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1)); | |
325 | ||
326 | BRepBuilderAPI_Transform transformer1(mirror1); | |
327 | transformer1.Perform(originalWire); | |
328 | if(!transformer1.IsDone()) { | |
329 | di << "Not Done1 " << "\n"; | |
330 | return Standard_False; | |
331 | } | |
332 | const TopoDS_Shape& step1ModifiedShape = transformer1.ModifiedShape(originalWire); | |
333 | ||
334 | BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN); | |
335 | if(!distShapeShape1.IsDone()) | |
336 | return Standard_False; | |
337 | if(distShapeShape1.Value() > 0.01) { | |
338 | di << "Dist = " <<distShapeShape1.Value() <<"\n"; | |
339 | return Standard_False; | |
340 | } else | |
341 | di << "Dist1 = " <<distShapeShape1.Value() <<"\n"; | |
342 | ||
343 | ////////////////////////////////////////////////////////////////////////// | |
344 | /// Second flip Y | |
345 | transformer1.Perform(step1ModifiedShape); | |
346 | if(!transformer1.IsDone()) { | |
347 | di << "Not Done1 \n"; | |
348 | return Standard_False; | |
349 | } | |
350 | const TopoDS_Shape& step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape); | |
bead40f2 | 351 | |
352 | //This is identity matrix for values but for type is gp_Rotation ?! | |
353 | gp_Trsf2d mirror11 = mirror1; | |
354 | mirror11.PreMultiply(mirror1); | |
355 | ||
356 | BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN); | |
357 | if(!distShapeShape2.IsDone()) | |
358 | return Standard_False; | |
359 | ||
360 | //This last test case give error (the value is 1008.8822038689706) | |
361 | if(distShapeShape2.Value() > 0.01) { | |
362 | di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n"; | |
363 | Standard_Integer N = distShapeShape2.NbSolution(); | |
364 | di << "Nb = " <<N <<"\n"; | |
365 | for (Standard_Integer i=1;i <= N;i++) | |
366 | di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n"; | |
367 | return Standard_False; | |
368 | } | |
369 | di << "Distance2 = " <<distShapeShape2.Value() <<"\n"; | |
370 | ||
371 | return Standard_True; | |
372 | } | |
373 | static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a) | |
374 | { | |
375 | ||
376 | if (n != 3) { | |
377 | di <<"OCC23774: invalid number of input parameters\n"; | |
378 | return 1; | |
379 | } | |
380 | ||
381 | const char *ns1 = (a[1]), *ns2 = (a[2]); | |
382 | TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2)); | |
383 | if (S1.IsNull() || S2.IsNull()) { | |
384 | di <<"OCC23774: Null input shapes\n"; | |
385 | return 1; | |
386 | } | |
387 | const TopoDS_Face& aFace = TopoDS::Face(S1); | |
388 | if(!OCC23774Test(aFace, S2, di)) | |
389 | di << "Something is wrong\n"; | |
390 | ||
391 | return 0; | |
392 | } | |
393 | ||
1ef32e96 RL |
394 | #include <GeomConvert_ApproxSurface.hxx> |
395 | #include <Geom_BSplineSurface.hxx> | |
396 | #include <Draw.hxx> | |
397 | #include <OSD_Thread.hxx> | |
398 | static void GeomConvertTest (Draw_Interpretor& di, Standard_Integer theTargetNbUPoles, Standard_CString theFileName) | |
399 | { | |
400 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theFileName); | |
401 | GeomConvert_ApproxSurface aGAS (aSurf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1); | |
402 | if (!aGAS.IsDone()) { | |
403 | di << "ApproxSurface is not done!" << "\n"; | |
404 | return; | |
405 | } | |
406 | const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface(); | |
407 | if (aBSurf.IsNull()) { | |
408 | di << "BSplineSurface is not created!" << "\n"; | |
409 | return; | |
410 | } | |
411 | di << "Number of UPoles:" << aBSurf->NbUPoles() << "\n"; | |
412 | QCOMPARE (aBSurf->NbUPoles(), theTargetNbUPoles); | |
413 | } | |
414 | ||
415 | struct aData { | |
416 | Draw_Interpretor* di; | |
417 | Standard_Integer nbupoles; | |
418 | Standard_CString filename; | |
419 | }; | |
420 | ||
421 | Standard_EXPORT Standard_Address convert(Standard_Address data) | |
422 | { | |
423 | aData* info = (aData*) data; | |
424 | GeomConvertTest(*(info->di),info->nbupoles,info->filename); | |
425 | return NULL; | |
426 | } | |
427 | ||
428 | static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
429 | { | |
430 | if (argc != 3) { | |
431 | di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; | |
432 | return 1; | |
433 | } | |
434 | struct aData aStorage; | |
435 | aStorage.di = &di; | |
436 | aStorage.nbupoles = Draw::Atoi(argv[1]); | |
437 | aStorage.filename = argv[2]; | |
438 | ||
439 | OSD_Thread aThread1(convert); | |
440 | aThread1.Run(&aStorage); | |
441 | GeomConvertTest(di,aStorage.nbupoles,aStorage.filename); | |
85c44a05 | 442 | cout << "result of thread: " << aThread1.Wait() << endl; |
1ef32e96 RL |
443 | |
444 | return 0; | |
445 | } | |
d2786814 | 446 | |
1ef32e96 RL |
447 | #include <GeomInt_IntSS.hxx> |
448 | static void GeomIntSSTest (Draw_Interpretor& di, Standard_Integer theNbSol, Standard_CString theFileName1, Standard_CString theFileName2) | |
449 | { | |
450 | Handle(Geom_Surface) aSurf1 = DrawTrSurf::GetSurface(theFileName1); | |
451 | Handle(Geom_Surface) aSurf2 = DrawTrSurf::GetSurface(theFileName2); | |
452 | GeomInt_IntSS anInter; | |
453 | anInter.Perform(aSurf1, aSurf2, Precision::Confusion(), Standard_True); | |
454 | if (!anInter.IsDone()) { | |
455 | di << "An intersection is not done!" << "\n"; | |
456 | return; | |
457 | } | |
458 | ||
459 | di << "Number of Lines:" << anInter.NbLines() << "\n"; | |
460 | QCOMPARE (anInter.NbLines(), theNbSol); | |
461 | } | |
462 | ||
463 | struct aNewData { | |
464 | Draw_Interpretor* di; | |
465 | Standard_Integer nbsol; | |
466 | Standard_CString filename1; | |
467 | Standard_CString filename2; | |
468 | }; | |
469 | Standard_EXPORT Standard_Address convert_inter(Standard_Address data) | |
470 | { | |
471 | aNewData* info = (aNewData*) data; | |
472 | GeomIntSSTest(*(info->di),info->nbsol,info->filename1,info->filename2); | |
473 | return NULL; | |
474 | } | |
475 | ||
476 | static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
477 | { | |
478 | if (argc != 4) { | |
479 | di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; | |
480 | return 1; | |
481 | } | |
482 | struct aNewData aStorage; | |
483 | aStorage.di = &di; | |
484 | aStorage.nbsol = Draw::Atoi(argv[1]); | |
485 | aStorage.filename1 = argv[2]; | |
486 | aStorage.filename2 = argv[3]; | |
487 | ||
488 | OSD_Thread aThread1(convert_inter); | |
489 | aThread1.Run(&aStorage); | |
490 | GeomIntSSTest(di,aStorage.nbsol,aStorage.filename1,aStorage.filename2); | |
85c44a05 | 491 | cout << "result of thread: " << aThread1.Wait() << endl; |
1ef32e96 RL |
492 | |
493 | return 0; | |
494 | } | |
495 | ||
496 | #include <Geom_SurfaceOfRevolution.hxx> | |
06be28a4 RL |
497 | static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) |
498 | { | |
499 | if (argc < 2) { | |
500 | di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n"; | |
501 | return 1; | |
502 | } | |
503 | ||
504 | Standard_Integer ucontinuity = 1; | |
505 | Standard_Integer vcontinuity = 1; | |
506 | Standard_Boolean iscnu = false; | |
507 | Standard_Boolean iscnv = false; | |
508 | ||
509 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]); | |
510 | ||
511 | QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu); | |
512 | QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv); | |
513 | ||
514 | return 0; | |
515 | } | |
516 | ||
1939140c | 517 | #include <gp_Ax1.hxx> |
518 | #include <gp_Ax22d.hxx> | |
519 | #include <Geom_Plane.hxx> | |
520 | #include <Geom2d_Circle.hxx> | |
521 | #include <Geom2d_TrimmedCurve.hxx> | |
522 | #include <BRepBuilderAPI_MakeEdge.hxx> | |
523 | #include <BRepPrimAPI_MakeRevol.hxx> | |
524 | #include <Geom2d_OffsetCurve.hxx> | |
525 | ||
526 | static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
527 | { | |
528 | // Check the command arguments | |
529 | if ( argc != 1 ) | |
530 | { | |
531 | di << "Error: " << argv[0] << " - invalid number of arguments" << "\n"; | |
532 | di << "Usage: type help " << argv[0] << "\n"; | |
533 | return 1; // TCL_ERROR | |
534 | } | |
535 | ||
536 | gp_Ax1 RotoAx( gp::Origin(), gp::DZ() ); | |
537 | gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() ); | |
538 | Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() ); | |
539 | ||
540 | di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>" << "\n"; | |
541 | di << "-----------------------------------------------------------------------" << "\n"; | |
542 | ||
543 | Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0); | |
544 | Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0); | |
545 | TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane); | |
546 | ||
547 | DBRep::Set("e1", E1); | |
548 | ||
549 | BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx); | |
550 | TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() ); | |
551 | ||
552 | DBRep::Set("f1", F1); | |
553 | ||
554 | di << "Result: f1" << "\n"; | |
555 | ||
556 | di << "<<<< Preparing sample surface of revolution based on offset curve >>>>" << "\n"; | |
557 | di << "-----------------------------------------------------------------------" << "\n"; | |
558 | ||
559 | Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5); | |
560 | TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane); | |
561 | ||
562 | DBRep::Set("e2", E2); | |
563 | ||
564 | BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx); | |
565 | TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() ); | |
566 | ||
567 | DBRep::Set("f2", F2); | |
568 | ||
569 | di << "Result: f2" << "\n"; | |
570 | ||
571 | return 0; | |
572 | } | |
573 | ||
2e9fd4bc | 574 | #include <Geom_Curve.hxx> |
575 | #include <Geom_Surface.hxx> | |
576 | #include <Precision.hxx> | |
577 | #include <ShapeConstruct_ProjectCurveOnSurface.hxx> | |
578 | //======================================================================= | |
579 | //function : OCC24008 | |
580 | //purpose : | |
581 | //======================================================================= | |
582 | static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
583 | { | |
584 | if (argc != 3) { | |
585 | di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; | |
586 | return 1; | |
587 | } | |
588 | Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]); | |
589 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]); | |
590 | if (aCurve.IsNull()) { | |
591 | di << "Curve was not read" << "\n"; | |
592 | return 1; | |
593 | } | |
594 | if (aSurf.IsNull()) { | |
595 | di << "Surface was not read" << "\n"; | |
596 | return 1; | |
597 | } | |
598 | ShapeConstruct_ProjectCurveOnSurface aProj; | |
599 | aProj.Init (aSurf, Precision::Confusion()); | |
600 | try { | |
601 | Handle(Geom2d_Curve) aPCurve; | |
602 | aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve); | |
603 | if (aPCurve.IsNull()) { | |
604 | di << "PCurve was not created" << "\n"; | |
605 | return 1; | |
606 | } | |
607 | } catch (...) { | |
608 | di << "Exception was caught" << "\n"; | |
609 | } | |
610 | return 0; | |
611 | } | |
612 | ||
470ebb43 | 613 | #include <GeomAdaptor_Surface.hxx> |
614 | #include <Draw.hxx> | |
615 | //======================================================================= | |
616 | //function : OCC23945 | |
617 | //purpose : | |
618 | //======================================================================= | |
619 | ||
35e08fe8 | 620 | static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a) |
470ebb43 | 621 | { |
622 | if (n < 5) return 1; | |
623 | ||
624 | Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]); | |
625 | if (aS.IsNull()) return 1; | |
626 | ||
627 | GeomAdaptor_Surface GS(aS); | |
628 | ||
629 | Standard_Real U = Draw::Atof(a[2]); | |
630 | Standard_Real V = Draw::Atof(a[3]); | |
631 | ||
632 | Standard_Boolean DrawPoint = ( n%3 == 2); | |
633 | if ( DrawPoint) n--; | |
634 | ||
635 | gp_Pnt P; | |
636 | if (n >= 13) { | |
637 | gp_Vec DU,DV; | |
638 | if (n >= 22) { | |
639 | gp_Vec D2U,D2V,D2UV; | |
640 | GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV); | |
641 | Draw::Set(a[13],D2U.X()); | |
642 | Draw::Set(a[14],D2U.Y()); | |
643 | Draw::Set(a[15],D2U.Z()); | |
644 | Draw::Set(a[16],D2V.X()); | |
645 | Draw::Set(a[17],D2V.Y()); | |
646 | Draw::Set(a[18],D2V.Z()); | |
647 | Draw::Set(a[19],D2UV.X()); | |
648 | Draw::Set(a[20],D2UV.Y()); | |
649 | Draw::Set(a[21],D2UV.Z()); | |
650 | } | |
651 | else | |
652 | GS.D1(U,V,P,DU,DV); | |
653 | ||
654 | Draw::Set(a[7],DU.X()); | |
655 | Draw::Set(a[8],DU.Y()); | |
656 | Draw::Set(a[9],DU.Z()); | |
657 | Draw::Set(a[10],DV.X()); | |
658 | Draw::Set(a[11],DV.Y()); | |
659 | Draw::Set(a[12],DV.Z()); | |
660 | } | |
661 | else | |
662 | GS.D0(U,V,P); | |
663 | ||
664 | if ( n > 6) { | |
665 | Draw::Set(a[4],P.X()); | |
666 | Draw::Set(a[5],P.Y()); | |
667 | Draw::Set(a[6],P.Z()); | |
668 | } | |
669 | if ( DrawPoint) { | |
670 | DrawTrSurf::Set(a[n],P); | |
671 | } | |
672 | ||
673 | return 0; | |
674 | } | |
675 | ||
4bee43a9 P |
676 | #include <Voxel_BoolDS.hxx> |
677 | #include <Voxel_FastConverter.hxx> | |
678 | #include <Voxel_BooleanOperation.hxx> | |
679 | static Standard_Integer OCC24019 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
680 | { | |
681 | if ( argc != 2 ) { | |
682 | di << "Error: " << argv[0] << " - invalid number of arguments" << "\n"; | |
683 | return 1; | |
684 | } | |
685 | ||
686 | TCollection_AsciiString aFileName = argv[1]; | |
687 | TopoDS_Shape aShape; | |
688 | BRep_Builder aBuilder; | |
689 | ||
690 | if (!BRepTools::Read(aShape, aFileName.ToCString(), aBuilder)) { | |
691 | di << "Error: Could not read a shape!" << "\n"; | |
692 | return 1; | |
693 | } | |
694 | ||
695 | TopoDS_Solid aShape1 = BRepPrimAPI_MakeSphere(gp_Pnt(20,25,35), 7); | |
696 | ||
697 | Standard_Real deflection = 0.005; | |
698 | Standard_Integer nbThreads = 1; | |
699 | Standard_Integer nbx = 200, nby = 200, nbz = 200; | |
700 | Voxel_BoolDS theVoxels(0,0,0, 50, 50, 50, nbx, nby, nbz); | |
701 | Voxel_BoolDS theVoxels1(0,0,0, 50, 50, 50, nbx, nby, nbz); | |
702 | ||
703 | Standard_Integer progress = 0; | |
704 | Voxel_FastConverter fcp(aShape, theVoxels, deflection, nbx, nby, nbz, nbThreads); | |
705 | fcp.ConvertUsingSAT(progress, 1); | |
706 | fcp.FillInVolume(1); | |
707 | ||
708 | Voxel_FastConverter fcp1(aShape1, theVoxels1, deflection, nbx, nby, nbz, nbThreads); | |
709 | fcp1.ConvertUsingSAT(progress, 1); | |
710 | fcp1.FillInVolume(1); | |
711 | ||
712 | Voxel_BooleanOperation op; | |
713 | Standard_Boolean result = op.Cut(theVoxels1, theVoxels); | |
714 | if ( result != 1 ) { | |
715 | di << "Error: invalid boolean operation" << "\n"; | |
716 | } else { | |
717 | di << "OK: boolean operation is ok" << "\n"; | |
718 | } | |
719 | ||
720 | return 0; | |
721 | } | |
722 | ||
29cb310a | 723 | //======================================================================= |
724 | //function : OCC11758 | |
725 | //purpose : | |
726 | //======================================================================= | |
498ce76b | 727 | static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**) |
29cb310a | 728 | { |
729 | if (n != 1) return 1; | |
730 | ||
731 | const char* theStr = "0123456789"; | |
732 | Standard_Integer i, j; | |
733 | for ( i = 0; i < 5; ++i ) { | |
734 | // TCollection_AsciiString(const Standard_CString astring) | |
735 | TCollection_AsciiString a(theStr+i); | |
736 | // IsEqual (const Standard_CString other)const | |
737 | //assert( a == theStr+i ); | |
738 | QCOMPARE ( a , theStr+i ); | |
739 | ||
740 | //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen ) | |
741 | TCollection_AsciiString b(theStr+i, 3); | |
742 | //assert( b.Length() == 3 ); | |
743 | //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 ); | |
744 | //assert( strlen( b.ToCString() ) == 3 ); | |
745 | QCOMPARE ( b.Length() , 3 ); | |
746 | QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 ); | |
747 | QCOMPARE ( b.Length() , 3 ); | |
748 | ||
749 | //TCollection_AsciiString(const Standard_Integer aValue) | |
750 | TCollection_AsciiString c(i); | |
751 | //assert( c.IsIntegerValue() ); | |
752 | //assert( c.IntegerValue() == i ); | |
753 | QCOMPARE ( c.IsIntegerValue() , Standard_True ); | |
754 | QCOMPARE ( c.IntegerValue() , i ); | |
755 | ||
756 | //TCollection_AsciiString(const Standard_Real aValue) | |
757 | TCollection_AsciiString d( 0.1*i ); | |
758 | //assert( d.IsRealValue() ); | |
759 | //assert( TCollection_AsciiString(3.3) == "3.3"); | |
760 | QCOMPARE ( d.IsRealValue() , Standard_True ); | |
761 | QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" ); | |
762 | ||
763 | //TCollection_AsciiString(const TCollection_AsciiString& astring) | |
764 | TCollection_AsciiString e(d); | |
765 | //assert( e == d ); | |
766 | //assert( e.Length() == d.Length() ); | |
767 | //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 ); | |
768 | QCOMPARE ( e ,d ); | |
769 | QCOMPARE ( e.Length() , d.Length() ); | |
770 | QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 ); | |
771 | ||
772 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
773 | // const Standard_Character other ) | |
774 | TCollection_AsciiString f(e,'\a'); | |
775 | //assert( f.Length() == e.Length() + 1 ); | |
776 | //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 ); | |
777 | //assert( f.Value( f.Length() ) == '\a'); | |
778 | QCOMPARE ( f.Length() , e.Length() + 1 ); | |
779 | QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 ); | |
780 | QCOMPARE ( f.Value( f.Length() ) , '\a' ); | |
781 | ||
782 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
783 | // const Standard_CString other ) | |
784 | TCollection_AsciiString g(f, theStr); | |
785 | //assert( g.Length() == f.Length() + strlen( theStr )); | |
786 | //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 ); | |
787 | //assert( g.Search( theStr ) == f.Length() + 1 ); | |
788 | QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) ); | |
789 | QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 ); | |
790 | QCOMPARE ( g.Search( theStr ) , f.Length() + 1 ); | |
791 | ||
792 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
793 | // const TCollection_AsciiString& other ) | |
794 | TCollection_AsciiString h(d,a); | |
795 | //assert( h.Length() == d.Length() + a.Length() ); | |
796 | //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 ); | |
797 | //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 ); | |
798 | QCOMPARE ( h.Length() , d.Length() + a.Length() ); | |
799 | QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 ); | |
800 | QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 ); | |
801 | ||
802 | // AssignCat(const Standard_CString other) | |
803 | c.AssignCat( a.ToCString() ); | |
804 | //assert( c.Length() == 1 + a.Length() ); | |
805 | //assert( c.Search( a ) == 2 ); | |
806 | QCOMPARE ( c.Length() , 1 + a.Length() ); | |
807 | QCOMPARE ( c.Search( a ) , 2 ); | |
808 | ||
809 | // AssignCat(const TCollection_AsciiString& other) | |
810 | Standard_Integer dl = d.Length(); | |
811 | d.AssignCat( a ); | |
812 | //assert( d.Length() == dl + a.Length() ); | |
813 | //assert( d.Search( a ) == dl + 1 ); | |
814 | QCOMPARE ( d.Length() , dl + a.Length() ); | |
815 | QCOMPARE ( d.Search( a ) , dl + 1 ); | |
816 | ||
817 | // Capitalize() | |
818 | TCollection_AsciiString capitalize("aBC"); | |
819 | capitalize.Capitalize(); | |
820 | //assert( capitalize == "Abc" ); | |
821 | QCOMPARE ( capitalize , "Abc" ); | |
822 | ||
823 | // Copy(const Standard_CString fromwhere) | |
824 | d = theStr+i; | |
825 | //assert( d == theStr+i ); | |
826 | QCOMPARE ( d , theStr+i ); | |
827 | ||
828 | // Copy(const TCollection_AsciiString& fromwhere) | |
829 | d = h; | |
830 | // IsEqual (const TCollection_AsciiString& other)const | |
831 | //assert( d == h ); | |
832 | QCOMPARE ( d , h ); | |
833 | ||
834 | // Insert(const Standard_Integer where, const Standard_CString what) | |
835 | dl = d.Length(); | |
836 | d.Insert( 2, theStr ); | |
837 | //assert( d.Length() == dl + strlen( theStr )); | |
838 | //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 ); | |
839 | QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) ); | |
840 | QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 ); | |
841 | ||
842 | //Insert(const Standard_Integer where,const Standard_Character what) | |
843 | d = theStr; | |
844 | d.Insert( i+1, 'i' ); | |
845 | //assert( d.Length() == strlen( theStr ) + 1 ); | |
846 | //assert( d.Value( i+1 ) == 'i'); | |
847 | //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 ); | |
848 | QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 ); | |
849 | QCOMPARE ( d.Value( i+1 ) , 'i' ); | |
850 | QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 ); | |
851 | ||
852 | //Insert(const Standard_Integer where,const TCollection_AsciiString& what) | |
853 | d = theStr; | |
854 | d.Insert( i+1, TCollection_AsciiString( "i" )); | |
855 | //assert( d.Length() == strlen( theStr ) + 1 ); | |
856 | //assert( d.Value( i+1 ) == 'i'); | |
857 | //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 ); | |
858 | QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 ); | |
859 | QCOMPARE ( d.Value( i+1 ) , 'i' ); | |
860 | QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 ); | |
861 | ||
862 | // IsDifferent (const Standard_CString other)const | |
863 | //assert( d.IsDifferent( theStr )); | |
864 | //assert( d.IsDifferent( "theStr" )); | |
865 | //assert( d.IsDifferent( "" )); | |
866 | //assert( !d.IsDifferent( d.ToCString() )); | |
867 | QCOMPARE ( d.IsDifferent( theStr ) , Standard_True ); | |
868 | QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True ); | |
869 | QCOMPARE ( d.IsDifferent( "" ) , Standard_True ); | |
870 | QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True ); | |
871 | ||
872 | // IsDifferent (const TCollection_AsciiString& other)const | |
873 | //assert( d.IsDifferent( TCollection_AsciiString() )); | |
874 | //assert( d.IsDifferent( a )); | |
875 | //assert( d.IsDifferent( h )); | |
876 | //assert( !d.IsDifferent( d )); | |
877 | QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True ); | |
878 | QCOMPARE ( d.IsDifferent( a ) , Standard_True ); | |
879 | QCOMPARE ( d.IsDifferent( h ) , Standard_True ); | |
880 | QCOMPARE ( !d.IsDifferent( d ) , Standard_True ); | |
881 | ||
882 | // IsLess (const Standard_CString other)const | |
883 | //assert( TCollection_AsciiString ("0"). IsLess("1")); | |
884 | //assert( TCollection_AsciiString ("0"). IsLess("00")); | |
885 | //assert( TCollection_AsciiString (""). IsLess("0")); | |
886 | //assert( !TCollection_AsciiString("1"). IsLess("0")); | |
887 | //assert( !TCollection_AsciiString("00").IsLess("0")); | |
888 | //assert( !TCollection_AsciiString("0"). IsLess("")); | |
889 | //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1)); | |
890 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True ); | |
891 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True ); | |
892 | QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True ); | |
893 | QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True ); | |
894 | QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True ); | |
895 | QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True ); | |
896 | QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True ); | |
897 | ||
898 | // IsLess (const TCollection_AsciiString& other)const | |
899 | //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" ))); | |
900 | //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00"))); | |
901 | //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" ))); | |
902 | //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" ))); | |
903 | //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" ))); | |
904 | //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" ))); | |
905 | //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1))); | |
906 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True ); | |
907 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True ); | |
908 | QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
909 | QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
910 | QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
911 | QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True ); | |
912 | QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True ); | |
913 | ||
914 | // IsGreater (const Standard_CString other)const | |
915 | //assert( !TCollection_AsciiString("0"). IsGreater("1")); | |
916 | //assert( !TCollection_AsciiString("0"). IsGreater("00")); | |
917 | //assert( !TCollection_AsciiString(""). IsGreater("0")); | |
918 | //assert( TCollection_AsciiString ("1"). IsGreater("0")); | |
919 | //assert( TCollection_AsciiString ("00").IsGreater("0")); | |
920 | //assert( TCollection_AsciiString ("0"). IsGreater("")); | |
921 | //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i)); | |
922 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True ); | |
923 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True ); | |
924 | QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True ); | |
925 | QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True ); | |
926 | QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True ); | |
927 | QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True ); | |
928 | QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True ); | |
929 | ||
930 | // IsGreater (const TCollection_AsciiString& other)const | |
931 | //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" ))); | |
932 | //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00"))); | |
933 | //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" ))); | |
934 | //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" ))); | |
935 | //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" ))); | |
936 | //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" ))); | |
937 | //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i))); | |
938 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True ); | |
939 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True ); | |
940 | QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
941 | QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
942 | QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
943 | QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True ); | |
944 | QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True ); | |
945 | ||
946 | // void Read(Standard_IStream& astream) | |
947 | std::istringstream is( theStr ); | |
948 | e.Read( is ); | |
949 | //assert( e == theStr ); | |
950 | QCOMPARE ( e , theStr ); | |
951 | ||
952 | // Standard_Integer SearchFromEnd (const Standard_CString what)const | |
953 | //assert( e.SearchFromEnd( theStr + i ) == i + 1 ); | |
954 | QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 ); | |
955 | ||
956 | // SetValue(const Standard_Integer where, const Standard_CString what) | |
957 | e.SetValue( i+1, "what"); | |
958 | //assert( e.Search( "what" ) == i+1 ); | |
959 | //assert( e.Length() == strlen( theStr )); | |
960 | QCOMPARE ( e.Search( "what" ) , i+1 ); | |
961 | QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) ); | |
962 | ||
963 | // TCollection_AsciiString Split (const Standard_Integer where) | |
964 | e = theStr; | |
965 | d = e.Split( i+1 ); | |
966 | //assert( d.Length() + e.Length() == strlen( theStr )); | |
967 | QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) ); | |
968 | ||
969 | // TCollection_AsciiString SubString (const Standard_Integer FromIndex, | |
970 | // const Standard_Integer ToIndex) const | |
971 | e = theStr; | |
972 | d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 ); | |
973 | //assert( d.Length() == 3 ); | |
974 | //assert( d.Value(1) == theStr[ i ]); | |
975 | QCOMPARE ( d.Length() , 3 ); | |
976 | QCOMPARE ( d.Value(1) , theStr[ i ] ); | |
977 | ||
978 | // TCollection_AsciiString Token (const Standard_CString separators, | |
979 | // const Standard_Integer whichone) const | |
980 | e = " "; | |
981 | for ( j = 0; j < i; ++j ) { | |
982 | e += TCollection_AsciiString( theStr[j] ) + " "; | |
983 | //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 )); | |
984 | QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) ); | |
985 | } | |
986 | } | |
987 | for ( i = 0; i < 5; ++i ) | |
988 | { | |
989 | // TCollection_ExtendedString (const Standard_CString astring, | |
990 | // const Standard_Boolean isMultiByte) | |
991 | const TCollection_ExtendedString a( theStr+i ); | |
992 | //assert( TCollection_AsciiString( a ) == theStr+i ); | |
993 | QCOMPARE ( TCollection_AsciiString( a ) , theStr+i ); | |
994 | ||
995 | //TCollection_ExtendedString (const Standard_ExtString astring) | |
996 | const TCollection_ExtendedString b( a.ToExtString() ); | |
997 | //assert( a == b ); | |
998 | QCOMPARE ( a , b ); | |
999 | ||
1000 | // TCollection_ExtendedString (const Standard_Integer length, | |
1001 | // const Standard_ExtCharacter filler ) | |
1002 | const TCollection_ExtendedString c( i, 1 ); | |
1003 | //assert( c.Length() == i ); | |
1004 | QCOMPARE ( c.Length() , i ); | |
1005 | if ( c.Length() > 0 ) { | |
1006 | //assert( c.Value( i ) == 1 ); | |
1007 | QCOMPARE ( c.Value( i ) , 1 ); | |
1008 | } | |
1009 | ||
1010 | // TCollection_ExtendedString (const Standard_Integer aValue) | |
1011 | TCollection_ExtendedString d( i ); | |
1012 | const TCollection_AsciiString da( d ); | |
1013 | //assert( da.IsIntegerValue() ); | |
1014 | //assert( da.IntegerValue() == i ); | |
1015 | QCOMPARE ( da.IsIntegerValue() , Standard_True ); | |
1016 | QCOMPARE ( da.IntegerValue(), i ); | |
1017 | ||
1018 | // TCollection_ExtendedString (const Standard_Real aValue) | |
1019 | const TCollection_ExtendedString e( 0.1 * i ); | |
1020 | const TCollection_AsciiString ea( e ); | |
1021 | //assert( ea.IsRealValue() ); | |
1022 | //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 ); | |
1023 | QCOMPARE ( ea.IsRealValue() , Standard_True ); | |
1024 | QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True ); | |
1025 | ||
1026 | // TCollection_ExtendedString (const TCollection_ExtendedString& astring) | |
1027 | const TCollection_ExtendedString f(e); | |
1028 | //assert( f.Length() == e.Length()); | |
1029 | //assert( f == e ); | |
1030 | QCOMPARE ( f.Length() , e.Length() ); | |
1031 | QCOMPARE ( f , e ); | |
1032 | ||
1033 | // TCollection_ExtendedString (const TCollection_AsciiString& astring) | |
1034 | const TCollection_ExtendedString g( ea ); | |
1035 | //assert( g.Length() == ea.Length() ); | |
1036 | //assert( TCollection_AsciiString( g ) == ea ); | |
1037 | QCOMPARE ( g.Length() , ea.Length() ); | |
1038 | QCOMPARE ( TCollection_AsciiString( g ) , ea ); | |
1039 | ||
1040 | // AssignCat (const TCollection_ExtendedString& other) | |
1041 | const TCollection_ExtendedString sep(","); | |
1042 | d.AssignCat( sep ); | |
1043 | d.AssignCat( g ); | |
1044 | //assert( d.Length() == 2 + g.Length() ); | |
1045 | //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i )); | |
1046 | //assert( d.Token( sep.ToExtString(), 2 ) == g ); | |
1047 | QCOMPARE ( d.Length() , 2 + g.Length() ); | |
1048 | QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) ); | |
1049 | QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g ); | |
1050 | ||
1051 | // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const | |
1052 | const TCollection_ExtendedString cat = a.Cat( sep ); | |
1053 | //assert( cat.Length() == a.Length() + sep.Length() ); | |
1054 | //assert( cat.Search( a ) == 1 ); | |
1055 | //assert( cat.Search( sep ) == a.Length() + 1 ); | |
1056 | QCOMPARE ( cat.Length() , a.Length() + sep.Length() ); | |
1057 | QCOMPARE ( cat.Search( a ) , 1 ); | |
1058 | QCOMPARE ( cat.Search( sep ) , a.Length() + 1 ); | |
1059 | ||
1060 | // Copy (const TCollection_ExtendedString& fromwhere) | |
1061 | d = cat; | |
1062 | //assert( d.Length() == cat.Length() ); | |
1063 | //assert( d == cat ); | |
1064 | QCOMPARE ( d.Length() , cat.Length() ); | |
1065 | QCOMPARE ( d , cat ); | |
1066 | ||
1067 | // IsEqual (const Standard_ExtString other) const | |
1068 | //assert( d.IsEqual( d.ToExtString() )); | |
1069 | QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True ); | |
1070 | ||
1071 | // IsDifferent (const Standard_ExtString other ) const | |
1072 | //assert( d.IsDifferent( a.ToExtString() )); | |
1073 | QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True ); | |
1074 | ||
1075 | // IsDifferent (const TCollection_ExtendedString& other) const | |
1076 | //assert( d.IsDifferent( a )); | |
1077 | QCOMPARE ( d.IsDifferent( a ) , Standard_True ); | |
1078 | ||
1079 | // IsLess (const Standard_ExtString other) const | |
1080 | const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1); | |
1081 | //assert( l0. IsLess( l1.ToExtString() )); | |
1082 | //assert( l0. IsLess( l00.ToExtString() )); | |
1083 | //assert( l. IsLess( l0.ToExtString() )); | |
1084 | //assert( ! l1. IsLess( l0.ToExtString() )); | |
1085 | //assert( ! l00.IsLess( l0.ToExtString() )); | |
1086 | //assert( ! l0. IsLess( l.ToExtString() )); | |
1087 | //assert( ls.IsLess( ls1.ToExtString() )); | |
1088 | QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True ); | |
1089 | QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True ); | |
1090 | QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True ); | |
1091 | QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True ); | |
1092 | QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True ); | |
1093 | QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True ); | |
1094 | QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True ); | |
1095 | ||
1096 | // IsLess (const TCollection_ExtendedString& other) const | |
1097 | //assert( l0. IsLess( l1 )); | |
1098 | //assert( l0. IsLess( l00 )); | |
1099 | //assert( l. IsLess( l0 )); | |
1100 | //assert( ! l1. IsLess( l0 )); | |
1101 | //assert( ! l00.IsLess( l0 )); | |
1102 | //assert( ! l0. IsLess( l )); | |
1103 | //assert( ls.IsLess( ls1 )); | |
1104 | QCOMPARE ( l0. IsLess( l1 ) , Standard_True ); | |
1105 | QCOMPARE ( l0. IsLess( l00 ) , Standard_True ); | |
1106 | QCOMPARE ( l. IsLess( l0 ) , Standard_True ); | |
1107 | QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True ); | |
1108 | QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True ); | |
1109 | QCOMPARE ( ! l0. IsLess( l ) , Standard_True ); | |
1110 | QCOMPARE ( ls.IsLess( ls1 ) , Standard_True ); | |
1111 | ||
1112 | // IsGreater (const Standard_ExtString other) const | |
1113 | //assert( ! l0.IsGreater( l1.ToExtString() )); | |
1114 | //assert( ! l0.IsGreater( l00.ToExtString() )); | |
1115 | //assert( ! l. IsGreater( l0.ToExtString() )); | |
1116 | //assert( l1. IsGreater( l0.ToExtString() )); | |
1117 | //assert( l00.IsGreater( l0.ToExtString() )); | |
1118 | //assert( l0. IsGreater( l.ToExtString() )); | |
1119 | //assert( ls1.IsGreater( ls.ToExtString() )); | |
1120 | QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True ); | |
1121 | QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True ); | |
1122 | QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True ); | |
1123 | QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True ); | |
1124 | QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True ); | |
1125 | QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True ); | |
1126 | QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True ); | |
1127 | ||
1128 | // IsGreater (const TCollection_ExtendedString& other) const | |
1129 | //assert( ! l0.IsGreater( l1)); | |
1130 | //assert( ! l0.IsGreater( l00)); | |
1131 | //assert( ! l. IsGreater( l0)); | |
1132 | //assert( l1. IsGreater( l0)); | |
1133 | //assert( l00.IsGreater( l0)); | |
1134 | //assert( l0. IsGreater( l)); | |
1135 | //assert( ls1.IsGreater( ls)); | |
1136 | QCOMPARE ( ! l0.IsGreater( l1) , Standard_True ); | |
1137 | QCOMPARE ( ! l0.IsGreater( l00) , Standard_True ); | |
1138 | QCOMPARE ( ! l. IsGreater( l0) , Standard_True ); | |
1139 | QCOMPARE ( l1. IsGreater( l0) , Standard_True ); | |
1140 | QCOMPARE ( l00.IsGreater( l0) , Standard_True ); | |
1141 | QCOMPARE ( l0. IsGreater( l) , Standard_True ); | |
1142 | QCOMPARE ( ls1.IsGreater( ls) , Standard_True ); | |
1143 | ||
1144 | // ========================== | |
1145 | //TCollection_HAsciiString:: | |
1146 | // ========================== | |
1147 | ||
1148 | // IsDifferent(const Handle(TCollection_HAsciiString)& S) | |
1149 | Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i ); | |
1150 | Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 ); | |
1151 | //assert( ha1->IsDifferent( ha2 )); | |
1152 | //assert( !ha1->IsDifferent( ha1 )); | |
1153 | QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True ); | |
1154 | QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True ); | |
1155 | ||
1156 | // IsSameString (const Handle(TCollection_HAsciiString)& S) | |
1157 | //assert( !ha1->IsSameString( ha2 )); | |
1158 | //assert( ha1->IsSameString( ha1 )); | |
1159 | QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True ); | |
1160 | QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True ); | |
1161 | ||
1162 | // IsSameState (const Handle(TCollection_HAsciiString)& other) const | |
1163 | //assert( !ha1->IsSameState( ha2 )); | |
1164 | //assert( ha1->IsSameState( ha1 )); | |
1165 | QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True ); | |
1166 | QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True ); | |
1167 | ||
1168 | // IsSameString (const Handle(TCollection_HAsciiString)& S , | |
1169 | // const Standard_Boolean CaseSensitive) const | |
1170 | //assert( !ha1->IsSameString( ha2, true )); | |
1171 | //assert( ha1->IsSameString( ha1, true )); | |
1172 | //assert( !ha1->IsSameString( ha2, false )); | |
1173 | //assert( ha1->IsSameString( ha1, false )); | |
1174 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True ); | |
1175 | QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True ); | |
1176 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True ); | |
1177 | QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True ); | |
1178 | ||
1179 | ha1->SetValue( 1, "AbC0000000"); | |
1180 | ha2->SetValue( 1, "aBc0000000"); | |
1181 | //assert( !ha1->IsSameString( ha2, true )); | |
1182 | //assert( ha1->IsSameString( ha2, false )); | |
1183 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True ); | |
1184 | QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True ); | |
1185 | } | |
1186 | return 0; | |
1187 | } | |
1188 | ||
788cbaf4 | 1189 | #include <Geom_CylindricalSurface.hxx> |
1190 | #include <IntTools_FaceFace.hxx> | |
1191 | #include <IntTools_Curve.hxx> | |
1192 | #include <IntTools_PntOn2Faces.hxx> | |
1193 | ||
1194 | static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) | |
1195 | { | |
1196 | if(theNArg < 2) | |
1197 | { | |
1198 | theDI << "Wrong a number of arguments!\n"; | |
1199 | return 1; | |
1200 | } | |
1201 | ||
857ffd5e | 1202 | Handle(Geom_Plane) plane(new Geom_Plane( |
788cbaf4 | 1203 | gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678), |
1204 | gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000), | |
1205 | gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000)))); | |
1206 | Handle(Geom_CylindricalSurface) cylinder( | |
1207 | new Geom_CylindricalSurface( | |
1208 | gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465), | |
1209 | gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000), | |
1210 | gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)), | |
1211 | 19.712534607908712)); | |
1212 | ||
1213 | DrawTrSurf::Set("pln", plane); | |
1214 | theDI << "pln\n"; | |
1215 | DrawTrSurf::Set("cyl", cylinder); | |
1216 | theDI << "cyl\n"; | |
1217 | ||
1218 | BRep_Builder builder; | |
1219 | TopoDS_Face face1, face2; | |
1220 | builder.MakeFace(face1, plane, Precision::Confusion()); | |
1221 | builder.MakeFace(face2, cylinder, Precision::Confusion()); | |
1222 | IntTools_FaceFace anInters; | |
1223 | anInters.SetParameters(false, true, true, Precision::Confusion()); | |
1224 | anInters.Perform(face1, face2); | |
1225 | ||
1226 | if (!anInters.IsDone()) | |
1227 | { | |
1228 | theDI<<"No intersections found!"<<"\n"; | |
1229 | ||
1230 | return 1; | |
1231 | } | |
1232 | ||
1233 | //Handle(Geom_Curve) aResult; | |
1234 | //gp_Pnt aPoint; | |
1235 | ||
1236 | const IntTools_SequenceOfCurves& aCvsX=anInters.Lines(); | |
1237 | const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points(); | |
1238 | ||
1239 | char buf[1024]; | |
1240 | Standard_Integer aNbCurves, aNbPoints; | |
1241 | ||
1242 | aNbCurves=aCvsX.Length(); | |
1243 | aNbPoints=aPntsX.Length(); | |
1244 | ||
1245 | if (aNbCurves >= 2) | |
1246 | { | |
1247 | for (Standard_Integer i=1; i<=aNbCurves; ++i) | |
1248 | { | |
1249 | Sprintf(buf, "%s_%d",theArgv[1],i); | |
1250 | theDI << buf << " "; | |
1251 | ||
1252 | const IntTools_Curve& aIC = aCvsX(i); | |
1253 | const Handle(Geom_Curve)& aC3D= aIC.Curve(); | |
1254 | DrawTrSurf::Set(buf,aC3D); | |
1255 | } | |
1256 | } | |
1257 | else if (aNbCurves == 1) | |
1258 | { | |
1259 | const IntTools_Curve& aIC = aCvsX(1); | |
1260 | const Handle(Geom_Curve)& aC3D= aIC.Curve(); | |
1261 | Sprintf(buf, "%s",theArgv[1]); | |
1262 | theDI << buf << " "; | |
1263 | DrawTrSurf::Set(buf,aC3D); | |
1264 | } | |
1265 | ||
1266 | for (Standard_Integer i = 1; i<=aNbPoints; ++i) | |
1267 | { | |
1268 | const IntTools_PntOn2Faces& aPi=aPntsX(i); | |
1269 | const gp_Pnt& aP=aPi.P1().Pnt(); | |
1270 | ||
1271 | Sprintf(buf,"%s_p_%d",theArgv[1],i); | |
1272 | theDI << buf << " "; | |
1273 | DrawTrSurf::Set(buf, aP); | |
1274 | } | |
1275 | ||
1276 | return 0; | |
1277 | } | |
1278 | ||
1b7602c8 | 1279 | #include <BRepAlgo_NormalProjection.hxx> |
1280 | static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1281 | { | |
1282 | if (argc != 3) { | |
1283 | di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)"; | |
1284 | return 1; | |
1285 | } | |
1286 | ||
1287 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
1288 | if(myAISContext.IsNull()) { | |
1289 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1290 | return 1; | |
1291 | } | |
1292 | ||
1293 | TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1])); | |
1294 | TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2])); | |
1295 | ||
1296 | BRepAlgo_NormalProjection anormpro(m_Face1); | |
1297 | anormpro.Add(m_Edge); | |
1298 | anormpro.SetDefaultParams(); | |
1299 | ||
1300 | //anormpro.Compute3d(); | |
1301 | //anormpro.SetLimit(); | |
1302 | ||
1303 | anormpro.Build(); | |
1304 | ||
1305 | if (anormpro.IsDone()) | |
1306 | { | |
1307 | TopoDS_Shape rshape = anormpro.Projection(); | |
1308 | Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape); | |
1309 | myAISContext->SetColor(myShape, Quantity_Color(Quantity_NOC_YELLOW)); | |
1310 | myAISContext->Display(myShape, Standard_True); | |
1311 | } | |
1312 | ||
1313 | return 0; | |
1314 | } | |
1315 | ||
01ee00d9 | 1316 | #include <Voxel_FastConverter.hxx> |
1317 | static Standard_Integer OCC24051 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1318 | { | |
1319 | if (argc != 1) { | |
1320 | di << "Usage : " << argv[0] << " should be one argument (command name only)"; | |
1321 | return 1; | |
1322 | } | |
1323 | ||
1324 | TopoDS_Shape shape = BRepPrimAPI_MakeBox(gp_Pnt(5, 10, 10), 10, 20, 30).Shape(); | |
1325 | Standard_Integer progress = 0; | |
1326 | Standard_Real deflection = 0.005; | |
1327 | Standard_Integer nbx = 200, nby = 200, nbz = 200; | |
1328 | Voxel_BoolDS theVoxels(-50,-50,-30, 100, 100, 100, nbx, nby, nbz); | |
1329 | Voxel_BoolDS theVoxels1(-50,-50,-30, 100, 100, 100, nbx, nby, nbz); | |
1330 | Standard_Integer nbThreads = 5; | |
1331 | Voxel_FastConverter fcp(shape, theVoxels, deflection, nbx, nby, nbz, nbThreads, Standard_True); | |
1332 | ||
1333 | #ifdef WNT | |
1334 | #pragma omp parallel for | |
1335 | for(int i = 0; i < nbThreads; i++) | |
1336 | fcp.ConvertUsingSAT(progress, i+1); | |
1337 | #endif | |
1338 | ||
1339 | fcp.ConvertUsingSAT(progress); | |
1340 | ||
1341 | return 0; | |
1342 | } | |
1343 | ||
69fd2d1b | 1344 | #include <BRepFeat_SplitShape.hxx> |
1345 | #include <ShapeAnalysis_ShapeContents.hxx> | |
1346 | #include <BRepAlgo.hxx> | |
1347 | static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1348 | { | |
1349 | if (argc != 3) { | |
1350 | di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)"; | |
1351 | return 1; | |
1352 | } | |
1353 | ||
1354 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
1355 | if(myAISContext.IsNull()) { | |
1356 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1357 | return 1; | |
1358 | } | |
1359 | ||
1360 | TopoDS_Shape result; | |
1361 | TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1])); | |
1362 | TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2])); | |
1363 | ||
1364 | BRepFeat_SplitShape asplit(face); | |
1365 | asplit.Add(wire, face); | |
1366 | asplit.Build(); | |
1367 | result = asplit.Shape(); | |
1368 | ShapeAnalysis_ShapeContents ana; | |
1369 | ana.Perform(result); | |
1370 | ana.NbFaces(); | |
1371 | ||
1372 | if (!(BRepAlgo::IsValid(result))) { | |
1373 | di << "Result was checked and it is INVALID" << "\n"; | |
1374 | } else { | |
1375 | di << "Result was checked and it is VALID" << "\n"; | |
1376 | } | |
1377 | ||
1378 | Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result); | |
1379 | myAISContext->Display(myShape, Standard_True); | |
1380 | ||
1381 | return 0; | |
1382 | } | |
1383 | ||
c764e804 | 1384 | #include <Geom_Circle.hxx> |
1385 | #include <GeomAdaptor_Curve.hxx> | |
1386 | #include <Extrema_ExtPC.hxx> | |
1387 | #include <gp_Cylinder.hxx> | |
1388 | #include <ElSLib.hxx> | |
1389 | static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1390 | { | |
1391 | if (argc != 1) { | |
1392 | di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; | |
1393 | return 1; | |
1394 | } | |
1395 | ||
1396 | gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 ); | |
1397 | gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() ); | |
1398 | Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 ); | |
1399 | GeomAdaptor_Curve aC3D( aCircle ); | |
1400 | ||
1401 | Extrema_ExtPC aExtPC( aP3D, aC3D ); | |
1402 | //Standard_Real aParam = (aExtPC.Point(1)).Parameter(); | |
1403 | gp_Pnt aProj = (aExtPC.Point(1)).Value(); | |
1404 | di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n"; | |
1405 | ||
1406 | // Result of deviation | |
1407 | gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() ); | |
1408 | gp_Cylinder aCylinder( aCylAxis, 1890. ); | |
1409 | ||
1410 | Standard_Real aU = 0., aV = 0.; | |
1411 | ElSLib::Parameters( aCylinder, aProj, aU, aV ); | |
1412 | di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n"; | |
1413 | ||
1414 | return 0; | |
1415 | } | |
1416 | ||
89d8607f | 1417 | #include <Extrema_FuncExtPS.hxx> |
1418 | #include <math_FunctionSetRoot.hxx> | |
1419 | #include <math_Vector.hxx> | |
1420 | #include <BRepBuilderAPI_MakeVertex.hxx> | |
1421 | static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) | |
1422 | { | |
1423 | Standard_Integer anArgIter = 1; | |
1424 | if (theNArg < 5) | |
1425 | { | |
1426 | theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]"<<"\n"; | |
1427 | return 1; | |
1428 | } | |
1429 | ||
1430 | // get target shape | |
1431 | Standard_CString aFaceName = theArgv[anArgIter++]; | |
1432 | Standard_CString aVertName = theArgv[anArgIter++]; | |
1433 | const TopoDS_Shape aShapeF = DBRep::Get (aFaceName); | |
1434 | const TopoDS_Shape aShapeV = DBRep::Get (aVertName); | |
1435 | const Standard_Real aUFrom = Atof (theArgv[anArgIter++]); | |
1436 | const Standard_Real aVFrom = Atof (theArgv[anArgIter++]); | |
1437 | const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100; | |
1438 | if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE) | |
1439 | { | |
1440 | std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl; | |
1441 | return 1; | |
1442 | } | |
1443 | if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX) | |
1444 | { | |
1445 | std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl; | |
1446 | return 1; | |
1447 | } | |
1448 | const TopoDS_Face aFace = TopoDS::Face (aShapeF); | |
1449 | const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV); | |
1450 | GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace)); | |
1451 | ||
1452 | gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes; | |
1453 | ||
1454 | Extrema_FuncExtPS anExtFunc; | |
1455 | math_FunctionSetRoot aRoot (anExtFunc, aNbIts); | |
1456 | ||
1457 | math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2); | |
1458 | aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion(); | |
1459 | aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite(); | |
1460 | aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite(); | |
1461 | aFromUV(1) = aUFrom; aFromUV(2) = aVFrom; | |
1462 | ||
1463 | anExtFunc.Initialize (aSurf); | |
1464 | anExtFunc.SetPoint (aPnt); | |
1465 | aRoot.SetTolerance (aTolUV); | |
1466 | aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup); | |
1467 | if (!aRoot.IsDone()) | |
1468 | { | |
1469 | std::cerr << "No results!\n"; | |
1470 | return 1; | |
1471 | } | |
1472 | ||
1473 | theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n"; | |
1474 | ||
1475 | aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes); | |
1476 | DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes)); | |
1477 | return 0; | |
1478 | } | |
1479 | ||
ab2db9a5 | 1480 | //! Check boolean operations on NCollection_Map |
1481 | static Standard_Integer OCC24271 (Draw_Interpretor& di, | |
1482 | Standard_Integer /*theArgNb*/, | |
1483 | const char** /*theArgVec*/) | |
1484 | { | |
1485 | // input data | |
1486 | const Standard_Integer aLeftLower = 1; | |
1487 | const Standard_Integer aLeftUpper = 10; | |
1488 | const Standard_Integer aRightLower = 5; | |
1489 | const Standard_Integer aRightUpper = 15; | |
1490 | ||
1491 | // define arguments | |
1492 | NCollection_Map<Standard_Integer> aMapLeft; | |
1493 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1494 | { | |
1495 | aMapLeft.Add (aKeyIter); | |
1496 | } | |
1497 | ||
1498 | NCollection_Map<Standard_Integer> aMapRight; | |
1499 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter) | |
1500 | { | |
1501 | aMapRight.Add (aKeyIter); | |
1502 | } | |
1503 | ||
1504 | QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False); | |
1505 | QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False); | |
1506 | ||
1507 | // validate Union operation | |
1508 | NCollection_Map<Standard_Integer> aMapUnion; | |
1509 | aMapUnion.Union (aMapLeft, aMapRight); | |
1510 | QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1); | |
1511 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter) | |
1512 | { | |
1513 | QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True); | |
1514 | } | |
1515 | ||
1516 | // validate Intersection operation | |
1517 | NCollection_Map<Standard_Integer> aMapSect; | |
1518 | aMapSect.Intersection (aMapLeft, aMapRight); | |
1519 | QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1); | |
1520 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1521 | { | |
1522 | QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True); | |
1523 | } | |
1524 | QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True); | |
1525 | QCOMPARE (aMapRight.Contains (aMapSect), Standard_True); | |
1526 | ||
1527 | // validate Substruction operation | |
1528 | NCollection_Map<Standard_Integer> aMapSubsLR; | |
1529 | aMapSubsLR.Subtraction (aMapLeft, aMapRight); | |
1530 | QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower); | |
1531 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter) | |
1532 | { | |
1533 | QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True); | |
1534 | } | |
1535 | ||
1536 | NCollection_Map<Standard_Integer> aMapSubsRL; | |
1537 | aMapSubsRL.Subtraction (aMapRight, aMapLeft); | |
1538 | QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper); | |
1539 | for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter) | |
1540 | { | |
1541 | QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True); | |
1542 | } | |
1543 | ||
1544 | // validate Difference operation | |
1545 | NCollection_Map<Standard_Integer> aMapDiff; | |
1546 | aMapDiff.Difference (aMapLeft, aMapRight); | |
1547 | QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper); | |
1548 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter) | |
1549 | { | |
1550 | QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True); | |
1551 | } | |
1552 | for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter) | |
1553 | { | |
1554 | QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True); | |
1555 | } | |
1556 | ||
1557 | // validate Exchange operation | |
1558 | NCollection_Map<Standard_Integer> aMapSwap; | |
1559 | aMapSwap.Exchange (aMapSect); | |
1560 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1561 | { | |
1562 | QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True); | |
1563 | } | |
1564 | QCOMPARE (aMapSect.IsEmpty(), Standard_True); | |
1565 | aMapSwap.Add (34); | |
1566 | aMapSect.Add (43); | |
1567 | ||
1568 | NCollection_Map<Standard_Integer> aMapCopy (aMapSwap); | |
1569 | QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True); | |
1570 | aMapCopy.Remove (34); | |
1571 | aMapCopy.Add (43); | |
1572 | QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False); | |
1573 | ||
1574 | return 0; | |
1575 | } | |
1576 | ||
e6c9f595 | 1577 | #define QVERIFY(val1) \ |
1578 | di << "Checking " #val1 " == Standard_True" << \ | |
1579 | ((val1) == Standard_True ? ": OK\n" : ": Error\n") | |
1580 | ||
1581 | #include <GeomInt_IntSS.hxx> | |
1582 | #include <Geom_ConicalSurface.hxx> | |
1583 | #include <Standard_ErrorHandler.hxx> | |
1584 | //======================================================================= | |
1585 | //function : OCC23972 | |
1586 | //purpose : | |
1587 | //======================================================================= | |
1588 | static void DoGeomIntSSTest (const Handle(Geom_Surface)& theSurf1, | |
1589 | const Handle(Geom_Surface)& theSurf2, | |
1590 | const Standard_Integer theNbSol, | |
1591 | Draw_Interpretor& di) | |
1592 | { | |
1593 | try { | |
1594 | OCC_CATCH_SIGNALS | |
1595 | GeomInt_IntSS anInter; | |
1596 | anInter.Perform (theSurf1, theSurf2, Precision::Confusion(), Standard_True); | |
1597 | QVERIFY (anInter.IsDone()); | |
1598 | QCOMPARE (anInter.NbLines(), theNbSol); | |
1599 | } catch (...) { | |
1600 | QVERIFY (Standard_False); | |
1601 | } | |
1602 | } | |
1603 | ||
1604 | namespace { | |
1605 | static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc, | |
1606 | const gp_Dir& theDir, | |
1607 | const gp_Dir& theXDir, | |
1608 | const Standard_Real theRad, | |
1609 | const Standard_Real theSin, | |
1610 | const Standard_Real theCos) | |
1611 | { | |
1612 | const Standard_Real anA = atan (theSin / theCos); | |
1613 | gp_Ax3 anAxis (theLoc, theDir, theXDir); | |
1614 | Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad); | |
1615 | return aSurf; | |
1616 | } | |
1617 | } | |
1618 | ||
1619 | static Standard_Integer OCC23972 (Draw_Interpretor& di,Standard_Integer n, const char**) | |
1620 | { | |
1621 | if (n != 1) return 1; | |
1622 | ||
1623 | //process specific cones, cannot read them from files because due to rounding the original error | |
1624 | //in math_FunctionRoots gets hidden | |
1625 | Handle(Geom_Surface) aS1 = CreateCone ( | |
1626 | gp_Pnt (123.694345356663, 789.9, 68.15), | |
1627 | gp_Dir (-1, 3.48029791472957e-016, -8.41302743359754e-017), | |
1628 | gp_Dir (-3.48029791472957e-016, -1, -3.17572289932207e-016), | |
1629 | 3.28206830417112, | |
1630 | 0.780868809443031, | |
1631 | 0.624695047554424); | |
1632 | Handle(Geom_Surface) aS2 = CreateCone ( | |
1633 | gp_Pnt (123.694345356663, 784.9, 68.15), | |
1634 | gp_Dir (-1, -2.5209507537117e-016, -1.49772808948866e-016), | |
1635 | gp_Dir (1.49772808948866e-016, 3.17572289932207e-016, -1), | |
1636 | 3.28206830417112, | |
1637 | 0.780868809443031, | |
1638 | 0.624695047554424); | |
1639 | ||
1640 | DoGeomIntSSTest (aS1, aS2, 2, di); | |
1641 | ||
1642 | return 0; | |
1643 | } | |
1644 | ||
e3096dec | 1645 | #include <ShapeFix_EdgeProjAux.hxx> |
1646 | static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) | |
1647 | { | |
1648 | if (argc < 5) { | |
1649 | di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n"; | |
1650 | return 1; | |
1651 | } | |
1652 | ||
1653 | TopoDS_Shape aSh = DBRep::Get(argv[1]); | |
1654 | if (aSh.IsNull()) { | |
1655 | di << argv[0] << " Error: Null input edge\n"; | |
1656 | return 1; | |
1657 | } | |
1658 | const TopoDS_Edge& anEdge = TopoDS::Edge (aSh); | |
1659 | ||
1660 | Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]); | |
1661 | if (aC.IsNull()) { | |
1662 | di << argv[0] << " Error: Null input curve\n"; | |
1663 | return 1; | |
1664 | } | |
1665 | ||
1666 | Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]); | |
1667 | if (aS.IsNull()) { | |
1668 | di << argv[0] << " Error: Null input surface\n"; | |
1669 | return 1; | |
1670 | } | |
1671 | ||
1672 | Standard_Real prec = Draw::Atof(argv[4]); | |
1673 | ||
1674 | //prepare data | |
1675 | TopoDS_Face aFace; | |
1676 | BRep_Builder aB; | |
1677 | aB.MakeFace (aFace, aS, Precision::Confusion()); | |
1678 | aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion()); | |
1679 | aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter()); | |
1680 | ||
1681 | //call algorithm | |
1682 | ShapeFix_EdgeProjAux aProj (aFace, anEdge); | |
1683 | aProj.Compute (prec); | |
1684 | ||
1685 | Standard_Boolean isfirstdone = aProj.IsFirstDone(); | |
1686 | Standard_Boolean islastdone = aProj.IsLastDone(); | |
1687 | ||
1688 | Standard_Real first = 0.; | |
1689 | Standard_Real last = 0.; | |
1690 | Standard_Integer isfirstdoneInteger = 0; | |
1691 | Standard_Integer islastdoneInteger = 0; | |
1692 | ||
1693 | ||
1694 | if (isfirstdone) { | |
1695 | first = aProj.FirstParam(); | |
1696 | isfirstdoneInteger = 1; | |
1697 | } | |
1698 | ||
1699 | if (islastdone) { | |
1700 | last= aProj.LastParam(); | |
1701 | islastdoneInteger = 1; | |
1702 | } | |
1703 | ||
1704 | di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n"; | |
1705 | ||
1706 | return 0; | |
1707 | } | |
1708 | ||
05d7de53 | 1709 | template<typename T, typename HT> |
1710 | static void DoIsNull(Draw_Interpretor& di) | |
1711 | { | |
1712 | HT aHandle; | |
1713 | // QVERIFY (aHandle.IsNull()); | |
1714 | QCOMPARE (aHandle.IsNull(), Standard_True); | |
1715 | const T* p = aHandle.Access(); | |
1716 | #if OCC_VERSION_HEX > 0x060700 | |
1717 | //QVERIFY (!p); | |
1718 | //QVERIFY (p == 0); | |
1719 | QCOMPARE (!p, Standard_True); | |
1720 | QCOMPARE (p == 0, Standard_True); | |
1721 | #endif | |
1722 | ||
1723 | aHandle = new T; | |
1724 | //QVERIFY (!aHandle.IsNull()); | |
1725 | QCOMPARE (!aHandle.IsNull(), Standard_True); | |
1726 | p = aHandle.Access(); | |
1727 | //QVERIFY (p); | |
1728 | //QVERIFY (p != 0); | |
1729 | QCOMPARE (p != NULL, Standard_True); | |
1730 | QCOMPARE (p != 0, Standard_True); | |
1731 | } | |
1732 | ||
1733 | //======================================================================= | |
1734 | //function : OCC24533 | |
1735 | //purpose : | |
1736 | //======================================================================= | |
1737 | static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**) | |
1738 | { | |
1739 | if (n != 1) return 1; | |
1740 | ||
857ffd5e | 1741 | DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di); |
1742 | DoIsNull<Standard_Persistent, Handle(Standard_Persistent)>(di); | |
05d7de53 | 1743 | |
1744 | return 0; | |
1745 | } | |
1746 | ||
dda67c1c | 1747 | // Dummy class to test interface for compilation issues |
1748 | class QABugs_HandleClass : public Standard_Transient | |
1749 | { | |
1750 | public: | |
1751 | Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec) | |
1752 | { | |
1753 | std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n"; | |
1754 | return 0; | |
1755 | } | |
1756 | DEFINE_STANDARD_RTTI(QABugs_HandleClass) // Type definition | |
1757 | }; | |
1758 | DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient) | |
1759 | IMPLEMENT_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient) | |
1760 | IMPLEMENT_STANDARD_RTTIEXT(QABugs_HandleClass, Standard_Transient) | |
1761 | ||
1762 | // Dummy class to test interface for compilation issues | |
1763 | struct QABugs_NHandleClass | |
1764 | { | |
1765 | Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec) | |
1766 | { | |
1767 | std::cerr << "QABugs_NHandleClass[" << this << "] " << "" << theArgVec[0] << "\n"; | |
1768 | return 0; | |
1769 | } | |
1770 | }; | |
1771 | ||
574d7236 | 1772 | #include <XCAFDoc_ColorTool.hxx> |
1773 | #include <STEPControl_StepModelType.hxx> | |
1774 | #include <STEPCAFControl_Writer.hxx> | |
1775 | static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1776 | { | |
1777 | if (argc != 1) { | |
1778 | di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; | |
1779 | return 1; | |
1780 | } | |
1781 | Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");; | |
1782 | TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape(); | |
1783 | TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape(); | |
1784 | XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1); | |
1785 | TDataStd_Name::Set(lab1, "Box1"); | |
1786 | ||
1787 | Quantity_Color yellow(1,1,0, Quantity_TOC_RGB); | |
1788 | XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen); | |
1789 | XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0); | |
1790 | ||
1791 | STEPControl_StepModelType mode = STEPControl_AsIs; | |
1792 | STEPCAFControl_Writer writer; | |
1793 | if ( ! writer.Transfer (aDoc, mode ) ) | |
1794 | { | |
1795 | di << "The document cannot be translated or gives no result" << "\n"; | |
1796 | return 1; | |
1797 | } | |
1798 | ||
1799 | writer.Write("test_box.step"); | |
1800 | return 0; | |
1801 | } | |
1802 | ||
1803 | ||
0c674248 | 1804 | //======================================================================= |
1805 | //function : OCC23950 | |
1806 | //purpose : | |
1807 | //======================================================================= | |
1808 | static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1809 | { | |
1fa7cb8c | 1810 | if (argc != 2) { |
1811 | di << "Usage : " << argv[0] << " step_file\n"; | |
0c674248 | 1812 | return 1; |
1813 | } | |
1814 | ||
1815 | Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy"); | |
1816 | TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0)); | |
1817 | gp_Trsf t0; | |
1818 | TopLoc_Location location0 (t0); | |
1819 | ||
1820 | TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape (); | |
1821 | XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6); | |
1822 | TDataStd_Name::Set(lab1, "Point1"); | |
1823 | ||
1824 | TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape (); | |
1825 | TDataStd_Name::Set(labelA0, "ASSEMBLY"); | |
1826 | ||
1827 | TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0); | |
1828 | ||
1829 | Quantity_Color yellow(1,1,0, Quantity_TOC_RGB); | |
1830 | XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen); | |
1831 | XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0); | |
1832 | ||
1833 | STEPControl_StepModelType mode = STEPControl_AsIs; | |
1834 | STEPCAFControl_Writer writer; | |
1835 | if (! writer.Transfer (aDoc, mode)) | |
1836 | { | |
1837 | di << "The document cannot be translated or gives no result" << "\n"; | |
1838 | return 1; | |
1839 | } | |
1840 | ||
1fa7cb8c | 1841 | writer.Write (argv[1]); |
0c674248 | 1842 | return 0; |
1843 | } | |
1844 | ||
f376ac72 | 1845 | //======================================================================= |
1846 | //function : OCC24622 | |
1847 | //purpose : The command tests sourcing Image_PixMap to AIS_TexturedShape | |
1848 | //======================================================================= | |
1849 | static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec) | |
1850 | { | |
1851 | if (theArgNb != 2) | |
1852 | { | |
1853 | std::cout << "Usage : " << theArgVec[0] << " texture={1D|2D}"; | |
1854 | return 1; | |
1855 | } | |
1856 | ||
1857 | const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext(); | |
1858 | if (anAISContext.IsNull()) | |
1859 | { | |
1860 | std::cout << "Please initialize view with \"vinit\".\n"; | |
1861 | return 1; | |
1862 | } | |
1863 | ||
1864 | Handle(Image_PixMap) anImage = new Image_PixMap(); | |
1865 | ||
b56dd33f | 1866 | static const Image_ColorRGB aBitmap[8] = |
1867 | { | |
1868 | {{255, 0, 0}}, {{0, 148, 255}}, {{ 0, 148, 255}}, {{255, 94, 0}}, | |
1869 | {{255, 121, 0}}, {{76, 255, 0}}, {{76, 255, 0}}, {{255, 202, 0}} | |
f376ac72 | 1870 | }; |
1871 | ||
1872 | TCollection_AsciiString aTextureTypeArg (theArgVec[1]); | |
1873 | aTextureTypeArg.UpperCase(); | |
1874 | if (aTextureTypeArg == "1D") | |
1875 | { | |
1876 | anImage->InitWrapper (Image_PixMap::ImgRGB, (Standard_Byte*)aBitmap, 8, 1); | |
1877 | } | |
1878 | else if (aTextureTypeArg == "2D") | |
1879 | { | |
1880 | anImage->InitTrash (Image_PixMap::ImgRGB, 8, 8); | |
f376ac72 | 1881 | for (Standard_Integer aRow = 0; aRow < 8; ++aRow) |
1882 | { | |
1883 | for (Standard_Integer aCol = 0; aCol < 8; ++aCol) | |
1884 | { | |
ca0c0b11 | 1885 | anImage->ChangeValue<Image_ColorRGB> (aRow, aCol) = aBitmap[aRow]; |
f376ac72 | 1886 | } |
1887 | } | |
1888 | } | |
1889 | else | |
1890 | { | |
1891 | std::cout << "Please specify type of texture to test {1D|2D}.\n"; | |
1892 | return 1; | |
1893 | } | |
1894 | ||
1895 | TopoDS_Shape aBlankShape = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape(); | |
1896 | ||
1897 | Handle(AIS_TexturedShape) aTexturedShape = new AIS_TexturedShape (aBlankShape); | |
1898 | aTexturedShape->SetTexturePixMap (anImage); | |
1899 | anAISContext->Display (aTexturedShape, 3, 0); | |
1900 | ||
1901 | return 0; | |
1902 | } | |
1903 | ||
2cd138b8 | 1904 | //======================================================================= |
1905 | //function : OCC24667 | |
1906 | //purpose : | |
1907 | //======================================================================= | |
1908 | static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
1909 | { | |
1910 | if (n == 1) | |
1911 | { | |
1912 | di << "OCC24667 result Wire_spine Profile [Mode [Approx]]" << "\n"; | |
1913 | di << "Mode = 0 - CorrectedFrenet," << "\n"; | |
1914 | di << " = 1 - Frenet," << "\n"; | |
1915 | di << " = 2 - DiscreteTrihedron" << "\n"; | |
1916 | di << "Approx - force C1-approximation if result is C0" << "\n"; | |
1917 | return 0; | |
1918 | } | |
1919 | ||
1920 | if (n > 1 && n < 4) return 1; | |
1921 | ||
1922 | TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE); | |
1923 | if ( Spine.IsNull()) return 1; | |
1924 | ||
1925 | TopoDS_Shape Profile = DBRep::Get(a[3]); | |
1926 | if ( Profile.IsNull()) return 1; | |
1927 | ||
1928 | GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet; | |
1929 | if (n >= 5) | |
1930 | { | |
1931 | Standard_Integer iMode = atoi(a[4]); | |
1932 | if (iMode == 1) | |
1933 | Mode = GeomFill_IsFrenet; | |
1934 | else if (iMode == 2) | |
1935 | Mode = GeomFill_IsDiscreteTrihedron; | |
1936 | } | |
1937 | ||
1938 | Standard_Boolean ForceApproxC1 = Standard_False; | |
1939 | if (n >= 6) | |
1940 | ForceApproxC1 = Standard_True; | |
1941 | ||
1942 | BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine), | |
1943 | Profile, | |
1944 | Mode, | |
1945 | ForceApproxC1); | |
1946 | ||
1947 | TopoDS_Shape S = aPipe.Shape(); | |
1948 | TopoDS_Shape aSF = aPipe.FirstShape(); | |
1949 | TopoDS_Shape aSL = aPipe.LastShape(); | |
1950 | ||
1951 | DBRep::Set(a[1],S); | |
1952 | ||
1953 | TCollection_AsciiString aStrF(a[1], "_f"); | |
1954 | TCollection_AsciiString aStrL(a[1], "_l"); | |
1955 | ||
1956 | DBRep::Set(aStrF.ToCString(), aSF); | |
1957 | DBRep::Set(aStrL.ToCString(), aSL); | |
1958 | ||
1959 | return 0; | |
1960 | } | |
1961 | ||
3497d552 | 1962 | #include <IGESControl_Reader.hxx> |
1963 | #include <IGESControl_Controller.hxx> | |
1964 | #include <IGESData_IGESEntity.hxx> | |
1965 | #include <BRepCheck_Analyzer.hxx> | |
1966 | #include <PTColStd_TransientPersistentMap.hxx> | |
1967 | #include <PTopoDS_HShape.hxx> | |
1968 | #include <Storage_Data.hxx> | |
1969 | #include <TopExp_Explorer.hxx> | |
1970 | #include <MgtBRep.hxx> | |
1971 | #include <FSD_File.hxx> | |
1972 | #include <ShapeSchema.hxx> | |
1973 | #include <TColStd_HSequenceOfTransient.hxx> | |
1974 | #include <PTColStd_PersistentTransientMap.hxx> | |
1975 | #include <Storage_Root.hxx> | |
1976 | ||
1977 | static Standard_Integer OCC24565 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1978 | { | |
1979 | if (argc != 3) { | |
1980 | di << "Usage : " << argv[0] << " FileNameIGS FileNameSTOR"; | |
1981 | return 1; | |
1982 | } | |
1983 | ||
1984 | Standard_CString sFileNameIGS = argv[1]; | |
1985 | Standard_CString sFileNameSTOR = argv[2]; | |
1986 | ||
1987 | IGESControl_Reader ICReader; | |
1988 | ||
1989 | /* * * * * * * | |
1990 | * Read the IGES file and make sure it is valid | |
1991 | * | |
1992 | * * * * * * */ | |
1993 | IGESControl_Controller::Init(); | |
1994 | ||
1995 | if (!ICReader.ReadFile(sFileNameIGS)) { | |
1996 | printf("%s:%d - Error reading '%s'\n",__FUNCTION__,__LINE__,sFileNameIGS);fflush(stdout); | |
1997 | return -1; | |
1998 | } | |
1999 | ||
2000 | int nbShapes = ICReader.NbShapes(); | |
2001 | ||
2002 | printf("%s:%d - nbShapes = '%d'\n",__FUNCTION__,__LINE__,nbShapes);fflush(stdout); | |
2003 | ||
2004 | TopoDS_Shape Shape; | |
2005 | if(nbShapes == 0) | |
2006 | { | |
2007 | Handle(TColStd_HSequenceOfTransient) faces=ICReader.GiveList("iges-faces"); | |
2008 | Handle(TColStd_HSequenceOfTransient) surfaceList=ICReader.GiveList("xst-transferrable-roots",faces); | |
2009 | ||
2010 | if (surfaceList.IsNull()) | |
2011 | { | |
2012 | printf("%s:%d - surfaceList.IsNull()\n",__FUNCTION__,__LINE__);fflush(stdout); | |
2013 | return -1; | |
2014 | } | |
2015 | BRep_Builder builder; | |
2016 | TopoDS_Compound* pC = new TopoDS_Compound(); | |
2017 | builder.MakeCompound(*pC); | |
2018 | ||
2019 | for (int j=1;j<=surfaceList->Length();j++) | |
2020 | { | |
2021 | Handle(IGESData_IGESEntity) igesEntity=Handle(IGESData_IGESEntity)::DownCast(surfaceList->Value(j)); | |
2022 | if (igesEntity.IsNull()) continue; | |
2023 | ICReader.ClearShapes(); | |
2024 | Standard_Boolean rv; | |
2025 | try { | |
2026 | rv=ICReader.TransferEntity(igesEntity); | |
2027 | } | |
2028 | catch (...) { | |
2029 | rv=Standard_False; | |
2030 | } | |
2031 | if (!rv) { | |
2032 | printf("%s:%d - Error transferring IGES entity\n",__FUNCTION__,__LINE__);fflush(stdout); | |
2033 | printf("%s:%d - FormNumber = %d, TypeNumber = %d\n",__FUNCTION__,__LINE__,igesEntity->FormNumber(),igesEntity->TypeNumber());fflush(stdout); | |
2034 | return -1; | |
2035 | } | |
2036 | ||
2037 | TopoDS_Shape S; | |
2038 | try { | |
2039 | S=ICReader.Shape(); | |
2040 | } | |
2041 | catch(...) { | |
2042 | printf("%s:%d - Error reading IGES entity\n",__FUNCTION__,__LINE__);fflush(stdout); | |
2043 | printf("%s:%d - FormNumber = %d, TypeNumber = %d\n",__FUNCTION__,__LINE__,igesEntity->FormNumber(),igesEntity->TypeNumber());fflush(stdout); | |
2044 | return -1; | |
2045 | } | |
2046 | if (S.IsNull()) { | |
2047 | printf("%s:%d - NULL Surface encountered\n",__FUNCTION__,__LINE__); | |
2048 | return -1; | |
2049 | } | |
2050 | ||
2051 | try | |
2052 | { | |
2053 | builder.Add(*pC,S); | |
2054 | } | |
2055 | catch(...) | |
2056 | { | |
2057 | printf("%s: Exception adding face.\n",__FUNCTION__); | |
2058 | } | |
2059 | } | |
2060 | Shape = TopoDS_Shape(*pC); | |
2061 | } | |
2062 | else | |
2063 | { | |
2064 | Shape = ICReader.OneShape(); | |
2065 | } | |
2066 | { | |
2067 | BRepCheck_Analyzer brca(Shape); | |
2068 | ||
2069 | if(!brca.IsValid()) | |
2070 | { | |
2071 | printf("%s: Invalid shape after reading IGES file.\n",__FUNCTION__); | |
2072 | } | |
2073 | } | |
2074 | ||
2075 | /* * * * * * * | |
2076 | * Write the contents of the Shape to a STOR file | |
2077 | * | |
2078 | * * * * * * */ | |
2079 | PTColStd_TransientPersistentMap aMapTP; | |
2080 | Handle(PTopoDS_HShape) aPShape_write; | |
2081 | Handle(Storage_Data) d_write=new Storage_Data; | |
2082 | char Name[32]; | |
2083 | ||
2084 | TopExp_Explorer Ex; | |
2085 | int i; | |
2086 | int max_i = 0; | |
2087 | ||
2088 | for (i=0,Ex.Init(Shape,TopAbs_FACE);Ex.More();i++,Ex.Next()) | |
2089 | { | |
2090 | ||
2091 | max_i = i; | |
2092 | try { | |
2093 | aPShape_write=MgtBRep::Translate(Ex.Current(),aMapTP,MgtBRep_WithoutTriangle); | |
2094 | } | |
2095 | catch (...) { | |
2096 | printf("%s: Error translating surface '%d'\n",__FUNCTION__,i); | |
2097 | } | |
2098 | ||
2099 | sprintf(Name,"S%010d",i); | |
2100 | ||
2101 | { | |
2102 | BRepCheck_Analyzer brca(Ex.Current()); | |
2103 | if(!brca.IsValid()) | |
2104 | { | |
2105 | printf("INVALID face '%s' in the shape, which will be written to the STOR file.\n",Name); | |
2106 | } | |
2107 | } | |
2108 | try { | |
2109 | d_write->AddRoot(Name,aPShape_write); | |
2110 | } | |
2111 | catch (...) { | |
2112 | printf("%s: Error adding surface '%d', RootName = '%s'\n",__FUNCTION__,i,Name); | |
2113 | } | |
2114 | } | |
2115 | printf("%s: Going to write %d surfaces.\n",__FUNCTION__,max_i+1); | |
2116 | ||
2117 | FSD_File f_write; | |
2118 | if(f_write.Open(sFileNameSTOR, Storage_VSWrite)!=Storage_VSOk) | |
2119 | { | |
2120 | printf("%s: Error opening file: %s\n", __FUNCTION__,sFileNameSTOR); | |
2121 | return -1; | |
2122 | } | |
2123 | Handle(ShapeSchema) s_write=new ShapeSchema; | |
2124 | s_write->Write(f_write,d_write); | |
2125 | f_write.Close(); | |
2126 | printf("%s: Wrote to the STOR file.\n",__FUNCTION__); | |
2127 | ||
2128 | /* * * * * * * | |
2129 | * Read the contents of the Shape from a STOR file | |
2130 | * | |
2131 | * * * * * * */ | |
2132 | FSD_File f_read; | |
2133 | if(f_read.Open(sFileNameSTOR, Storage_VSRead)!=Storage_VSOk) | |
2134 | { | |
2135 | printf("%s: Error opening file: %s\n", __FUNCTION__,sFileNameSTOR); | |
2136 | return -1; | |
2137 | } | |
2138 | Handle(ShapeSchema) s_read=new ShapeSchema; | |
2139 | Handle(Storage_Data) d_read=s_read->Read(f_read); | |
2140 | ||
2141 | Handle(Standard_Persistent) p; | |
2142 | Handle(Storage_Root) r; | |
2143 | Handle(PTopoDS_HShape) aPShape_read; | |
2144 | PTColStd_PersistentTransientMap aMapPT; | |
2145 | TopoDS_Shape S_read; | |
2146 | ||
2147 | printf("%s: Extracting %d faces from the STOR file.\n",__FUNCTION__,max_i+1); | |
2148 | for(int i = 0; i <= max_i; ++i) | |
2149 | { | |
2150 | sprintf(Name,"S%010d",i); | |
2151 | r=d_read->Find(Name); | |
2152 | if(r.IsNull()) | |
2153 | { | |
2154 | printf("%s:%d '%s' IsNull().\n",__FUNCTION__,__LINE__,Name);fflush(stdout); | |
2155 | continue; | |
2156 | } | |
2157 | p=r->Object(); | |
2158 | aPShape_read = Handle(PTopoDS_HShape)::DownCast(p); | |
2159 | try { | |
2160 | MgtBRep::Translate(aPShape_read,aMapPT,S_read,MgtBRep_WithoutTriangle); | |
2161 | } | |
2162 | catch (Standard_Failure) { | |
2163 | Handle(Standard_Failure) E=Standard_Failure::Caught(); | |
2164 | std::string str; | |
2165 | str="Exception: "; | |
2166 | str+=E->DynamicType()->Name(); | |
2167 | str+=" => "; | |
2168 | str+=E->GetMessageString(); | |
2169 | printf("%s(1): %s: %s\n",__FUNCTION__,Name,str.c_str());fflush(stdout); | |
2170 | } | |
2171 | catch (...) { | |
2172 | printf("%s(1): Unhandled exception in MgtBRep::Translate\n",__FUNCTION__); | |
2173 | } | |
2174 | ||
2175 | BRepCheck_Analyzer brca(S_read); | |
2176 | ||
2177 | if(!brca.IsValid()) | |
2178 | { | |
2179 | printf("%s: Read INVALID face (%s)!\n",__FUNCTION__,Name); | |
2180 | } | |
2181 | } | |
2182 | ||
2183 | printf("Completed.\n");fflush(stdout); | |
2184 | ||
2185 | return 0; | |
2186 | } | |
2187 | ||
70167e69 RL |
2188 | #include <Handle_BRepTools_NurbsConvertModification.hxx> |
2189 | #include <BRepPrimAPI_MakeCylinder.hxx> | |
2190 | #include <BRepBuilderAPI_Copy.hxx> | |
2191 | #include <BRepTools_NurbsConvertModification.hxx> | |
2192 | static TopoDS_Shape CreateTestShape (int& theShapeNb) | |
2193 | { | |
2194 | TopoDS_Compound aComp; | |
2195 | BRep_Builder aBuilder; | |
2196 | aBuilder.MakeCompound (aComp); | |
2197 | //NURBS modifier is used to increase footprint of each shape | |
2198 | Handle_BRepTools_NurbsConvertModification aNurbsModif = new BRepTools_NurbsConvertModification; | |
2199 | TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid(); | |
2200 | BRepTools_Modifier aModifier (aRefShape, aNurbsModif); | |
2201 | if (aModifier.IsDone()) { | |
2202 | aRefShape = aModifier.ModifiedShape (aRefShape); | |
2203 | } | |
2204 | int aSiblingNb = 0; | |
2205 | for (; theShapeNb > 0; --theShapeNb) { | |
2206 | TopoDS_Shape aShape; | |
2207 | if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists | |
2208 | aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape(); | |
2209 | } else { | |
2210 | aShape = CreateTestShape (theShapeNb); | |
2211 | } | |
2212 | aBuilder.Add (aComp, aShape); | |
2213 | } | |
2214 | return aComp; | |
2215 | } | |
2216 | ||
2217 | #include <AppStd_Application.hxx> | |
2218 | #include <TDataStd_Integer.hxx> | |
2219 | #include <TNaming_Builder.hxx> | |
2220 | static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
2221 | { | |
2222 | if (argc != 1) { | |
2223 | di << "Usage: " << argv[0] << " invalid number of arguments"<<"\n"; | |
2224 | return 1; | |
2225 | } | |
2226 | TCollection_ExtendedString aFileName ("testdocument.xml"); | |
2227 | PCDM_StoreStatus aSStatus = PCDM_SS_Failure; | |
2228 | ||
2229 | Handle(TDocStd_Application) anApp = new AppStd_Application; | |
2230 | { | |
2231 | Handle(TDocStd_Document) aDoc; | |
2232 | anApp->NewDocument ("XmlOcaf", aDoc); | |
2233 | TDF_Label aLab = aDoc->Main(); | |
2234 | TDataStd_Integer::Set (aLab, 0); | |
2235 | int n = 10000; //must be big enough | |
2236 | TopoDS_Shape aShape = CreateTestShape (n); | |
2237 | TNaming_Builder aBuilder (aLab); | |
2238 | aBuilder.Generated (aShape); | |
2239 | ||
2240 | aSStatus = anApp->SaveAs (aDoc, aFileName); | |
2241 | anApp->Close (aDoc); | |
2242 | } | |
2243 | QCOMPARE (aSStatus, PCDM_SS_OK); | |
2244 | return 0; | |
2245 | } | |
2246 | ||
d01cc61d | 2247 | #include <AppStdL_Application.hxx> |
2248 | #include <TDocStd_Application.hxx> | |
2249 | #include <TDataStd_Integer.hxx> | |
2250 | #include <TDF_AttributeIterator.hxx> | |
2251 | //======================================================================= | |
2252 | //function : OCC24755 | |
2253 | //purpose : | |
2254 | //======================================================================= | |
2255 | static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
2256 | { | |
2257 | if (n != 1) | |
2258 | { | |
2259 | std::cout << "Usage : " << a[0] << "\n"; | |
2260 | return 1; | |
2261 | } | |
2262 | ||
2263 | Handle(TDocStd_Application) anApp = new AppStdL_Application; | |
2264 | Handle(TDocStd_Document) aDoc; | |
2265 | anApp->NewDocument ("MDTV-Standard", aDoc); | |
2266 | TDF_Label aLab = aDoc->Main(); | |
2267 | TDataStd_Integer::Set (aLab, 0); | |
2268 | TDataStd_Name::Set (aLab, "test"); | |
2269 | ||
2270 | TDF_AttributeIterator i (aLab); | |
2271 | Handle(TDF_Attribute) anAttr = i.Value(); | |
2272 | QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True); | |
2273 | i.Next(); | |
2274 | anAttr = i.Value(); | |
2275 | QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True); | |
2276 | ||
2277 | return 0; | |
2278 | } | |
2279 | ||
a73267f2 | 2280 | struct MyStubObject |
2281 | { | |
2282 | MyStubObject() : ptr(0L) {} | |
2283 | MyStubObject(void* thePtr) : ptr(thePtr) {} | |
2284 | char overhead[40]; | |
2285 | void* ptr; | |
2286 | }; | |
2287 | ||
2288 | //======================================================================= | |
2289 | //function : OCC24834 | |
2290 | //purpose : | |
2291 | //======================================================================= | |
2292 | static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
2293 | { | |
2294 | if (n != 1) | |
2295 | { | |
2296 | std::cout << "Usage : " << a[0] << "\n"; | |
2297 | return 1; | |
2298 | } | |
5a89733f | 2299 | |
2300 | int i = sizeof (char*); | |
2301 | if (i > 4) { | |
2d7b28ac | 2302 | std::cout << "64-bit architecture is not supported.\n"; |
2303 | return 0; | |
2304 | } | |
a73267f2 | 2305 | |
2306 | NCollection_List<MyStubObject> aList; | |
2307 | const Standard_Integer aSmallBlockSize = 40; | |
2308 | const Standard_Integer aLargeBlockSize = 1500000; | |
2309 | ||
2310 | // quick populate memory with large blocks | |
2311 | try | |
2312 | { | |
2313 | for (;;) | |
2314 | { | |
2315 | aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize))); | |
2316 | } | |
2317 | } | |
2318 | catch (Standard_Failure) | |
2319 | { | |
2320 | di << "caught out of memory for large blocks: OK\n"; | |
2321 | } | |
2322 | catch (...) | |
2323 | { | |
2324 | di << "skept out of memory for large blocks: Error\n"; | |
2325 | } | |
2326 | ||
2327 | // allocate small blocks | |
2328 | try | |
2329 | { | |
2330 | for (;;) | |
2331 | { | |
2332 | aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize))); | |
2333 | } | |
2334 | } | |
2335 | catch (Standard_Failure) | |
2336 | { | |
2337 | di << "caught out of memory for small blocks: OK\n"; | |
2338 | } | |
2339 | catch (...) | |
2340 | { | |
2341 | di << "skept out of memory for small blocks: Error\n"; | |
2342 | } | |
2343 | ||
2344 | // release all allocated blocks | |
2345 | for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next()) | |
2346 | { | |
2347 | Standard::Free(it.Value().ptr); | |
2348 | } | |
2349 | return 0; | |
2350 | } | |
2351 | ||
8696d65d | 2352 | |
2353 | #include <Geom2dAPI_InterCurveCurve.hxx> | |
2354 | #include <IntRes2d_IntersectionPoint.hxx> | |
2355 | //======================================================================= | |
2356 | //function : OCC24889 | |
2357 | //purpose : | |
2358 | //======================================================================= | |
2359 | static Standard_Integer OCC24889 (Draw_Interpretor& theDI, | |
2360 | Standard_Integer /*theNArg*/, | |
2361 | const char** /*theArgs*/) | |
2362 | { | |
2363 | // Curves | |
2364 | Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle( | |
2365 | gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 ); | |
2366 | ||
2367 | Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle( | |
2368 | gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 ); | |
2369 | ||
2370 | Handle( Geom2d_TrimmedCurve ) aTrim[2] = { | |
2371 | new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ), | |
2372 | new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 ) | |
2373 | }; | |
2374 | ||
2375 | DrawTrSurf::Set("c_1", aTrim[0]); | |
2376 | DrawTrSurf::Set("c_2", aTrim[1]); | |
2377 | ||
2378 | // Intersection | |
2379 | const Standard_Real aTol = Precision::Confusion(); | |
2380 | Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol ); | |
2381 | ||
2382 | const IntRes2d_IntersectionPoint& aIntPnt = | |
2383 | aIntTool.Intersector().Point( 1 ); | |
2384 | ||
2385 | gp_Pnt2d aIntRes = aIntTool.Point( 1 ); | |
2386 | Standard_Real aPar[2] = { | |
2387 | aIntPnt.ParamOnFirst(), | |
2388 | aIntPnt.ParamOnSecond() | |
2389 | }; | |
2390 | ||
2391 | //theDI.precision( 5 ); | |
2392 | theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n"; | |
2393 | for (int i = 0; i < 2; ++i) | |
2394 | { | |
2395 | theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() << | |
2396 | "; LastParam = " << aTrim[i]->LastParameter() << | |
2397 | "; IntParameter = " << aPar[i] << "\n"; | |
2398 | } | |
2399 | ||
2400 | return 0; | |
2401 | } | |
2402 | ||
5493d334 | 2403 | #include <math_GlobOptMin.hxx> |
2404 | #include <math_MultipleVarFunctionWithHessian.hxx> | |
2405 | //======================================================================= | |
2406 | //function : OCC25004 | |
2407 | //purpose : Check extremaCC on Branin function. | |
2408 | //======================================================================= | |
2409 | // Function is: | |
2410 | // f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s | |
2411 | // Standard borders are: | |
2412 | // -5 <= u <= 10 | |
2413 | // 0 <= v <= 15 | |
2414 | class BraninFunction : public math_MultipleVarFunctionWithHessian | |
2415 | { | |
2416 | public: | |
2417 | BraninFunction() | |
2418 | { | |
2419 | a = 1.0; | |
2420 | b = 5.1 / (4.0 * M_PI * M_PI); | |
2421 | c = 5.0 / M_PI; | |
2422 | r = 6.0; | |
2423 | s = 10.0; | |
2424 | t = 1.0 / (8.0 * M_PI); | |
2425 | } | |
2426 | virtual Standard_Integer NbVariables() const | |
2427 | { | |
2428 | return 2; | |
2429 | } | |
2430 | virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F) | |
2431 | { | |
2432 | Standard_Real u = X(1); | |
2433 | Standard_Real v = X(2); | |
2434 | ||
2435 | Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function. | |
2436 | Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion. | |
2437 | F = a * aSqPt * aSqPt + aLnPt + s; | |
2438 | return Standard_True; | |
2439 | } | |
2440 | virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G) | |
2441 | { | |
2442 | Standard_Real u = X(1); | |
2443 | Standard_Real v = X(2); | |
2444 | ||
2445 | Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function. | |
2446 | G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u); | |
2447 | G(2) = 2 * a * aSqPt; | |
2448 | ||
2449 | return Standard_True; | |
2450 | } | |
2451 | virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G) | |
2452 | { | |
2453 | Value(X,F); | |
2454 | Gradient(X,G); | |
2455 | ||
2456 | return Standard_True; | |
2457 | } | |
2458 | virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H) | |
2459 | { | |
2460 | Value(X,F); | |
2461 | Gradient(X,G); | |
2462 | ||
2463 | Standard_Real u = X(1); | |
2464 | Standard_Real v = X(2); | |
2465 | ||
2466 | Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function. | |
2467 | Standard_Real aTmpPt = c - 2 * b *u; // Tmp part. | |
2468 | H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u); | |
2469 | H(1,2) = 2 * a * aTmpPt; | |
2470 | H(2,1) = H(1,2); | |
2471 | H(2,2) = 2 * a; | |
2472 | ||
2473 | return Standard_True; | |
2474 | } | |
2475 | ||
2476 | private: | |
2477 | // Standard parameters. | |
2478 | Standard_Real a, b, c, r, s, t; | |
2479 | }; | |
2480 | ||
2481 | static Standard_Integer OCC25004 (Draw_Interpretor& theDI, | |
2482 | Standard_Integer /*theNArg*/, | |
2483 | const char** /*theArgs*/) | |
2484 | { | |
2485 | math_MultipleVarFunction* aFunc = new BraninFunction(); | |
2486 | ||
2487 | math_Vector aLower(1,2), aUpper(1,2); | |
2488 | aLower(1) = -5; | |
2489 | aLower(2) = 0; | |
2490 | aUpper(1) = 10; | |
2491 | aUpper(2) = 15; | |
2492 | ||
2493 | Standard_Integer aGridOrder = 16; | |
2494 | math_Vector aFuncValues(1, aGridOrder * aGridOrder); | |
2495 | ||
2496 | Standard_Real aLipConst = 0; | |
2497 | math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2); | |
2498 | ||
2499 | // Get Lipshitz constant estimation on regular grid. | |
2500 | Standard_Integer i, j, idx = 1; | |
2501 | for(i = 1; i <= aGridOrder; i++) | |
2502 | { | |
2503 | for(j = 1; j <= aGridOrder; j++) | |
2504 | { | |
2505 | aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0); | |
2506 | aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0); | |
2507 | ||
2508 | aFunc->Value(aCurrPnt1, aFuncValues(idx)); | |
2509 | idx++; | |
2510 | } | |
2511 | } | |
2512 | ||
2513 | Standard_Integer k, l; | |
2514 | Standard_Integer idx1, idx2; | |
2515 | for(i = 1; i <= aGridOrder; i++) | |
2516 | for(j = 1; j <= aGridOrder; j++) | |
2517 | for(k = 1; k <= aGridOrder; k++) | |
2518 | for(l = 1; l <= aGridOrder; l++) | |
2519 | { | |
2520 | if (i == k && j == l) | |
2521 | continue; | |
2522 | ||
2523 | aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0); | |
2524 | aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0); | |
2525 | idx1 = (i - 1) * aGridOrder + j; | |
2526 | ||
2527 | aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0); | |
2528 | aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0); | |
2529 | idx2 = (k - 1) * aGridOrder + l; | |
2530 | ||
2531 | aCurrPnt1.Add(-aCurrPnt2); | |
2532 | Standard_Real dist = aCurrPnt1.Norm(); | |
2533 | ||
2534 | Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist; | |
2535 | if (C > aLipConst) | |
2536 | aLipConst = C; | |
2537 | } | |
2538 | ||
2539 | math_GlobOptMin aFinder(aFunc, aLower, aUpper, aLipConst); | |
2540 | aFinder.Perform(); | |
2541 | //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475) | |
2542 | ||
2543 | Standard_Real anExtValue = aFinder.GetF(); | |
2544 | theDI << "F = " << anExtValue << "\n"; | |
2545 | ||
2546 | Standard_Integer aNbExt = aFinder.NbExtrema(); | |
2547 | theDI << "NbExtrema = " << aNbExt << "\n"; | |
2548 | ||
2549 | return 0; | |
2550 | } | |
8696d65d | 2551 | |
b6c0b841 RL |
2552 | #include <OSD_Environment.hxx> |
2553 | #include <Plugin.hxx> | |
2554 | #include <Plugin_Macro.hxx> | |
2555 | #include <Resource_Manager.hxx> | |
2556 | ||
2557 | #define THE_QATEST_DOC_FORMAT "My Proprietary Format" | |
2558 | ||
2559 | #define QA_CHECK(theDesc, theExpr, theValue) \ | |
2560 | {\ | |
2561 | const bool isTrue = !!(theExpr); \ | |
2562 | std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \ | |
2563 | } | |
2564 | ||
2565 | class Test_TDocStd_Application : public TDocStd_Application | |
2566 | { | |
2567 | public: | |
2568 | ||
2569 | static void initGlobalPluginMap (const TCollection_AsciiString& thePlugin, | |
2570 | const TCollection_AsciiString& theSaver, | |
2571 | const TCollection_AsciiString& theLoader) | |
2572 | { | |
2573 | const Handle(Resource_Manager)& aManager = Plugin::AdditionalPluginMap(); | |
2574 | aManager->SetResource ((theSaver + ".Location").ToCString(), thePlugin.ToCString()); | |
2575 | aManager->SetResource ((theLoader + ".Location").ToCString(), thePlugin.ToCString()); | |
2576 | } | |
2577 | ||
2578 | Test_TDocStd_Application (const TCollection_AsciiString& thePlugin, | |
2579 | const TCollection_AsciiString& theSaver, | |
2580 | const TCollection_AsciiString& theLoader) | |
2581 | { | |
2582 | initGlobalPluginMap (thePlugin, theSaver, theLoader); | |
2583 | ||
2584 | // explicitly initialize resource manager | |
2585 | myResources = new Resource_Manager (""); | |
2586 | myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT); | |
2587 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document"); | |
2588 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml"); | |
2589 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".StoragePlugin", theSaver.ToCString()); | |
2590 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".RetrievalPlugin", theLoader.ToCString()); | |
2591 | } | |
2592 | ||
2593 | virtual Standard_CString ResourcesName() { return ""; } | |
2594 | virtual void Formats (TColStd_SequenceOfExtendedString& theFormats) { theFormats.Clear(); } | |
2595 | }; | |
2596 | ||
2597 | //======================================================================= | |
2598 | //function : OCC24925 | |
2599 | //purpose : | |
2600 | //======================================================================= | |
2601 | static Standard_Integer OCC24925 (Draw_Interpretor& theDI, | |
2602 | Standard_Integer theArgNb, | |
2603 | const char** theArgVec) | |
2604 | { | |
2605 | if (theArgNb != 2 | |
2606 | && theArgNb != 5) | |
2607 | { | |
2608 | std::cout << "Error: wrong syntax! See usage:\n"; | |
2609 | theDI.PrintHelp (theArgVec[0]); | |
2610 | return 1; | |
2611 | } | |
2612 | ||
2613 | Standard_Integer anArgIter = 1; | |
2614 | TCollection_ExtendedString aFileName = theArgVec[anArgIter++]; | |
2615 | TCollection_AsciiString aPlugin = "TKXml"; | |
2616 | TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx | |
2617 | TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx | |
2618 | if (anArgIter < theArgNb) | |
2619 | { | |
2620 | aPlugin = theArgVec[anArgIter++]; | |
2621 | aSaver = theArgVec[anArgIter++]; | |
2622 | aLoader = theArgVec[anArgIter++]; | |
2623 | } | |
2624 | ||
2625 | PCDM_StoreStatus aSStatus = PCDM_SS_Failure; | |
2626 | PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError; | |
2627 | ||
2628 | Handle(TDocStd_Application) anApp = new Test_TDocStd_Application (aPlugin, aSaver, aLoader); | |
2629 | { | |
2630 | Handle(TDocStd_Document) aDoc; | |
2631 | anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc); | |
2632 | TDF_Label aLab = aDoc->Main(); | |
2633 | TDataStd_Integer::Set (aLab, 0); | |
2634 | TDataStd_Name::Set (aLab, "QABugs_19.cxx"); | |
2635 | ||
2636 | aSStatus = anApp->SaveAs (aDoc, aFileName); | |
2637 | anApp->Close (aDoc); | |
2638 | } | |
2639 | QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true); | |
2640 | ||
2641 | { | |
2642 | Handle(TDocStd_Document) aDoc; | |
2643 | aRStatus = anApp->Open (aFileName, aDoc); | |
2644 | anApp->Close (aDoc); | |
2645 | } | |
2646 | QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true); | |
2647 | return 0; | |
2648 | } | |
2649 | ||
a967f104 | 2650 | //======================================================================= |
2651 | //function : OCC25043 | |
2652 | //purpose : | |
2653 | //======================================================================= | |
2654 | #include <BRepAlgoAPI_Check.hxx> | |
2655 | static Standard_Integer OCC25043 (Draw_Interpretor& theDI, | |
2656 | Standard_Integer theArgNb, | |
2657 | const char** theArgVec) | |
2658 | { | |
2659 | if (theArgNb != 2) { | |
2660 | theDI << "Usage: " << theArgVec[0] << " shape\n"; | |
2661 | return 1; | |
2662 | } | |
2663 | ||
2664 | TopoDS_Shape aShape = DBRep::Get(theArgVec[1]); | |
2665 | if (aShape.IsNull()) | |
2666 | { | |
2667 | theDI << theArgVec[1] << " shape is NULL\n"; | |
2668 | return 1; | |
2669 | } | |
2670 | ||
2671 | BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True); | |
2672 | ||
2673 | if (!anAlgoApiCheck.IsValid()) | |
2674 | { | |
2675 | BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result()); | |
2676 | for (; anCheckIter.More(); anCheckIter.Next()) | |
2677 | { | |
2678 | const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value(); | |
2679 | const BOPCol_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1(); | |
2680 | BOPCol_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes); | |
2681 | for (; aFaultyIter.More(); aFaultyIter.Next()) | |
2682 | { | |
2683 | const TopoDS_Shape& aFaultyShape = aFaultyIter.Value(); | |
2684 | ||
2685 | Standard_Boolean anIsFaultyShapeFound = Standard_False; | |
2686 | TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType()); | |
2687 | for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next()) | |
2688 | { | |
2689 | if (anExp.Current().IsEqual(aFaultyShape)) | |
2690 | anIsFaultyShapeFound = Standard_True; | |
2691 | } | |
2692 | ||
2693 | if (!anIsFaultyShapeFound) | |
2694 | { | |
2695 | theDI << "Error. Faulty Shape is NOT found in source shape.\n"; | |
2696 | return 0; | |
2697 | } | |
2698 | else | |
2699 | { | |
2700 | theDI << "Info. Faulty shape if found in source shape\n"; | |
2701 | } | |
2702 | } | |
2703 | } | |
2704 | } | |
2705 | else | |
2706 | { | |
2707 | theDI << "Error. Problems are not detected. Test is not performed."; | |
2708 | } | |
2709 | ||
2710 | return 0; | |
2711 | } | |
2712 | ||
4a350f94 | 2713 | //======================================================================= |
2714 | //function : OCC24606 | |
2715 | //purpose : | |
2716 | //======================================================================= | |
2717 | static Standard_Integer OCC24606 (Draw_Interpretor& theDI, | |
2718 | Standard_Integer theArgNb, | |
2719 | const char** theArgVec) | |
2720 | { | |
2721 | if (theArgNb > 1) | |
2722 | { | |
2723 | std::cerr << "Error: incorrect number of arguments.\n"; | |
2724 | theDI << "Usage : " << theArgVec[0] << "\n"; | |
2725 | return 1; | |
2726 | } | |
2727 | ||
2728 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
2729 | if (aView.IsNull()) | |
2730 | { | |
2731 | std::cerr << "Errro: no active view, please call 'vinit'.\n"; | |
2732 | return 1; | |
2733 | } | |
2734 | ||
2735 | aView->DepthFitAll(); | |
2736 | aView->FitAll(); | |
2737 | ||
2738 | return 0; | |
2739 | } | |
2740 | ||
e4b5c45a | 2741 | //======================================================================= |
2742 | //function : OCC23010 | |
2743 | //purpose : | |
2744 | //======================================================================= | |
2745 | #include <STEPCAFControl_Reader.hxx> | |
2746 | ||
2747 | class mOcafApplication : public TDocStd_Application | |
2748 | { | |
2749 | void Formats(TColStd_SequenceOfExtendedString& Formats) | |
2750 | { | |
2751 | Formats.Append(TCollection_ExtendedString("mOcafApplication")); | |
2752 | } | |
2753 | Standard_CString ResourcesName() | |
2754 | { | |
2755 | return Standard_CString("Resources"); | |
2756 | } | |
2757 | }; | |
2758 | ||
2759 | static Standard_Integer OCC23010 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
2760 | { | |
2761 | if (argc != 2) { | |
2762 | di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; | |
2763 | return 1; | |
2764 | } | |
2765 | std::string fileName=argv[1]; | |
2766 | mOcafApplication *mCasApp = new mOcafApplication(); | |
2767 | Handle(TDocStd_Document) doc; | |
2768 | mCasApp->NewDocument("MDTV-XCAF", doc); | |
2769 | STEPCAFControl_Reader stepReader; | |
2770 | IFSelect_ReturnStatus status = stepReader.ReadFile (fileName.c_str()); | |
2771 | if (status != IFSelect_RetDone) | |
2772 | return false; | |
2773 | stepReader.SetColorMode(Standard_True); | |
2774 | stepReader.SetLayerMode(Standard_True); | |
2775 | stepReader.SetNameMode(Standard_True); | |
2776 | stepReader.Transfer(doc); // ERROR HERE!!! | |
2777 | delete mCasApp; | |
2778 | return 0; | |
2779 | } | |
2780 | ||
b6c0b841 | 2781 | /*****************************************************************************/ |
8696d65d | 2782 | |
1cd84fee | 2783 | void QABugs::Commands_19(Draw_Interpretor& theCommands) { |
1365140b | 2784 | const char *group = "QABugs"; |
7fd59977 | 2785 | |
dda67c1c | 2786 | Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass(); |
2787 | theCommands.Add ("OCC24202_1", "Test Handle-based procedure", | |
2788 | __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group); | |
2789 | NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass(); | |
2790 | theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure", | |
2791 | __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group); | |
2792 | ||
7fd59977 | 2793 | theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group); |
2794 | theCommands.Add ("OCC142", "OCC142", __FILE__, OCC142, group); | |
f6f03db9 | 2795 | theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group); |
1365140b RL |
2796 | theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group); |
2797 | theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group); | |
e6aad0ee | 2798 | theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group); |
5d1833ef | 2799 | theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group); |
e187cc0a | 2800 | theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group); |
bead40f2 | 2801 | theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group); |
06be28a4 | 2802 | theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group); |
1ef32e96 RL |
2803 | theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group); |
2804 | theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group); | |
1939140c | 2805 | theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group); |
05d7de53 | 2806 | theCommands.Add ("OCC23945", "OCC23945 surfname U V X Y Z [DUX DUY DUZ DVX DVY DVZ [D2UX D2UY D2UZ D2VX D2VY D2VZ D2UVX D2UVY D2UVZ]]", __FILE__, OCC23945,group); |
2e9fd4bc | 2807 | theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group); |
4bee43a9 | 2808 | theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group); |
29cb310a | 2809 | theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group); |
788cbaf4 | 2810 | theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group); |
89d8607f | 2811 | theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group); |
ab2db9a5 | 2812 | theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group); |
e6c9f595 | 2813 | theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group); |
e3096dec | 2814 | theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group); |
05d7de53 | 2815 | theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group); |
1b7602c8 | 2816 | theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group); |
01ee00d9 | 2817 | theCommands.Add ("OCC24051", "OCC24051", __FILE__, OCC24051, group); |
69fd2d1b | 2818 | theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group); |
2cd138b8 | 2819 | theCommands.Add ("OCC24622", "OCC24622 texture={1D|2D}\n Tests sourcing of 1D/2D pixmaps for AIS_TexturedShape", __FILE__, OCC24622, group); |
2820 | theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group); | |
3497d552 | 2821 | theCommands.Add ("OCC24565", "OCC24565 FileNameIGS FileNameSTOR", __FILE__, OCC24565, group); |
d01cc61d | 2822 | theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group); |
a73267f2 | 2823 | theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group); |
8696d65d | 2824 | theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group); |
574d7236 | 2825 | theCommands.Add ("OCC23951", "OCC23951", __FILE__, OCC23951, group); |
70167e69 | 2826 | theCommands.Add ("OCC24931", "OCC24931", __FILE__, OCC24931, group); |
c764e804 | 2827 | theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group); |
1fa7cb8c | 2828 | theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group); |
5493d334 | 2829 | theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group); |
b6c0b841 RL |
2830 | theCommands.Add ("OCC24925", |
2831 | "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]" | |
2832 | "\nOCAF persistence without setting environment variables", | |
2833 | __FILE__, OCC24925, group); | |
e4b5c45a | 2834 | theCommands.Add ("OCC23010", "OCC23010 STEP_file", __FILE__, OCC23010, group); |
a967f104 | 2835 | theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group); |
4a350f94 | 2836 | theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group); |
7fd59977 | 2837 | return; |
2838 | } |