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 | // |
973c2be1 | 7 | // This library is free software; you can redistribute it and / or modify it |
8 | // under the terms of the GNU Lesser General Public version 2.1 as published | |
9 | // by the Free Software Foundation, with special exception defined in the file | |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
11 | // distribution for complete text of the license and disclaimer of any warranty. | |
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> | |
21 | #include <AIS_InteractiveContext.hxx> | |
22 | #include <ViewerTest.hxx> | |
23 | #include <AIS_Shape.hxx> | |
24 | #include <TopoDS_Shape.hxx> | |
25 | ||
26 | #include <gp_Pnt2d.hxx> | |
f6f03db9 | 27 | #include <gp_Ax1.hxx> |
7fd59977 | 28 | #include <GCE2d_MakeSegment.hxx> |
29 | #include <Geom2d_TrimmedCurve.hxx> | |
30 | #include <DrawTrSurf.hxx> | |
31 | ||
f6f03db9 | 32 | #include <Precision.hxx> |
33 | ||
7fd59977 | 34 | #include <PCollection_HAsciiString.hxx> |
35 | ||
c2ae831c | 36 | #include <cstdio> |
37 | #include <cmath> | |
38 | #include <iostream> | |
39 | #include <OSD_PerfMeter.hxx> | |
40 | #include <OSD_Timer.hxx> | |
41 | #include <BRepPrimAPI_MakeBox.hxx> | |
42 | #include <BRepPrimAPI_MakeSphere.hxx> | |
43 | #include <BRepAlgo_Cut.hxx> | |
ab2db9a5 | 44 | #include <NCollection_Map.hxx> |
29cb310a | 45 | #include <TCollection_HAsciiString.hxx> |
46 | ||
47 | #define QCOMPARE(val1, val2) \ | |
48 | di << "Checking " #val1 " == " #val2 << \ | |
49 | ((val1) == (val2) ? ": OK\n" : ": Error\n") | |
d2786814 | 50 | |
7fd59977 | 51 | static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
52 | { | |
53 | if ( argc != 4) { | |
54 | di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d" << "\n"; | |
55 | return 1; | |
56 | } | |
57 | ||
58 | gp_Pnt2d P1, P2; | |
59 | if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) { | |
60 | di << "ERROR OCC230: " << argv[2] << " is not Pnt2d" << "\n"; | |
61 | return 1; | |
62 | } | |
63 | if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) { | |
64 | di << "ERROR OCC230: " << argv[3] << " is not Pnt2d" << "\n"; | |
65 | return 1; | |
66 | } | |
67 | ||
68 | GCE2d_MakeSegment MakeSegment(P1,P2); | |
69 | Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value(); | |
70 | DrawTrSurf::Set(argv[1], TrimmedCurve); | |
71 | return 0; | |
72 | } | |
73 | ||
74 | static Standard_Integer OCC142 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) | |
75 | { | |
76 | for(Standard_Integer i= 0;i <= 20;i++){ | |
77 | Handle(PCollection_HAsciiString) pstr = new PCollection_HAsciiString("TEST"); | |
78 | pstr->Clear(); | |
79 | } | |
80 | di << "OCC142: OK" << "\n"; | |
81 | return 0; | |
82 | } | |
83 | ||
f6f03db9 | 84 | static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
85 | { | |
86 | gp_Pnt p(0, 0, 2); | |
87 | ||
88 | gp_Trsf t1, t2; | |
89 | t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267); | |
90 | t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880); | |
91 | ||
92 | gp_Trsf tComp = t2 * t1; | |
93 | ||
94 | gp_Pnt p1(10, 3, 4); | |
95 | gp_Pnt p2 = p1.Transformed(tComp); | |
96 | gp_Pnt p3 = p1.Transformed(t1); | |
97 | p3.Transform(t2); | |
98 | ||
99 | // points must be equal | |
100 | if ( ! p2.IsEqual(p3, Precision::Confusion()) ) | |
101 | di << "ERROR OCC23361: equivalent transformations does not produce equal points" << "\n"; | |
102 | else | |
103 | di << "OCC23361: OK" << "\n"; | |
104 | ||
105 | return 0; | |
106 | } | |
107 | ||
c2ae831c | 108 | static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/) |
109 | { | |
110 | OSD_PerfMeter aPM("TestMeter",0); | |
111 | OSD_Timer aTM; | |
112 | ||
113 | // run some operation in cycle for about 2 seconds to have good values of times to compare | |
114 | int count = 0; | |
115 | printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n"); | |
116 | for (; aTM.ElapsedTime() < 2.; count++) | |
117 | { | |
118 | aPM.Start(); | |
119 | aTM.Start(); | |
120 | ||
121 | // do some operation that will take considerable time compared with time or starting / stopping timers | |
122 | BRepPrimAPI_MakeBox aBox (10., 10., 10.); | |
123 | BRepPrimAPI_MakeSphere aSphere (10.); | |
124 | BRepAlgo_Cut (aBox.Shape(), aSphere.Shape()); | |
125 | ||
126 | aTM.Stop(); | |
127 | aPM.Stop(); | |
128 | } | |
129 | ||
130 | int aNbEnters = 0; | |
131 | Standard_Real aPerfMeter_CPUtime = 0., aTimer_ElapsedTime = aTM.ElapsedTime(); | |
132 | ||
133 | perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime); | |
134 | ||
135 | Standard_Real aTimeDiff = (fabs(aTimer_ElapsedTime - aPerfMeter_CPUtime) / aTimer_ElapsedTime); | |
136 | ||
137 | printf("\nMeasurement results (%d cycles):\n", count); | |
138 | printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer elapsed time: %lf\n", aPerfMeter_CPUtime, aTimer_ElapsedTime); | |
139 | printf("Time delta is: %.3lf %%\n", aTimeDiff * 100); | |
140 | ||
141 | if (aTimeDiff > 0.2) | |
142 | di << "OCC23237: Error: too much difference between CPU and elapsed times"; | |
143 | else if (aNbEnters != count) | |
144 | di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles"; | |
145 | else | |
146 | di << "OCC23237: OK"; | |
147 | ||
148 | return 0; | |
149 | } | |
150 | ||
1365140b RL |
151 | #ifdef HAVE_TBB |
152 | ||
153 | #include <Standard_Atomic.hxx> | |
154 | #include <tbb/blocked_range.h> | |
155 | #include <tbb/parallel_for.h> | |
156 | ||
157 | class IncrementerDecrementer | |
158 | { | |
159 | public: | |
160 | IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive) | |
161 | {} | |
162 | void operator() (const tbb::blocked_range<size_t>& r) const | |
163 | { | |
164 | if (myPositive) | |
165 | for (size_t i = r.begin(); i != r.end(); ++i) | |
166 | Standard_Atomic_Increment (myVal); | |
167 | else | |
168 | for (size_t i = r.begin(); i != r.end(); ++i) | |
169 | Standard_Atomic_Decrement (myVal); | |
170 | } | |
171 | private: | |
172 | Standard_Integer* myVal; | |
173 | Standard_Boolean myPositive; | |
174 | }; | |
175 | #endif | |
176 | ||
1365140b RL |
177 | #ifdef HAVE_TBB |
178 | static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) | |
179 | { | |
180 | int aSum = 0; | |
181 | ||
182 | //check returned value | |
183 | QCOMPARE (Standard_Atomic_Decrement (&aSum), -1); | |
184 | QCOMPARE (Standard_Atomic_Increment (&aSum), 0); | |
185 | QCOMPARE (Standard_Atomic_Increment (&aSum), 1); | |
186 | QCOMPARE (Standard_Atomic_Increment (&aSum), 2); | |
187 | // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0); | |
188 | // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1); | |
189 | ||
190 | //check atomicity | |
191 | aSum = 0; | |
192 | const int N = 1 << 24; //big enough to ensure concurrency | |
193 | ||
194 | //increment | |
195 | tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, true)); | |
196 | QCOMPARE (aSum, N); | |
197 | ||
198 | //decrement | |
199 | tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, false)); | |
200 | QCOMPARE (aSum, 0); | |
201 | ||
202 | return 0; | |
203 | } | |
204 | ||
205 | #else /* HAVE_TBB */ | |
206 | ||
207 | static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char **argv) | |
208 | { | |
209 | di << "Test skipped: command " << argv[0] << " requires TBB library\n"; | |
210 | return 0; | |
211 | } | |
212 | ||
213 | #endif /* HAVE_TBB */ | |
214 | ||
e6aad0ee RL |
215 | #include <TDocStd_Application.hxx> |
216 | #include <XCAFApp_Application.hxx> | |
217 | #include <TDocStd_Document.hxx> | |
218 | #include <XCAFDoc_ShapeTool.hxx> | |
219 | #include <XCAFDoc_DocumentTool.hxx> | |
220 | #include <TDF_Label.hxx> | |
221 | #include <TDataStd_Name.hxx> | |
222 | ||
773f53f1 | 223 | static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/) |
e6aad0ee RL |
224 | { |
225 | const Handle(TDocStd_Application)& anApp = XCAFApp_Application::GetApplication(); | |
226 | Handle(TDocStd_Document) aDoc; | |
227 | anApp->NewDocument ("XmlXCAF", aDoc); | |
228 | QCOMPARE (!aDoc.IsNull(), Standard_True); | |
229 | ||
230 | Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main()); | |
231 | ||
232 | //check default value | |
233 | Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming(); | |
234 | QCOMPARE (aValue, Standard_True); | |
235 | ||
236 | //true | |
237 | XCAFDoc_ShapeTool::SetAutoNaming (Standard_True); | |
238 | TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape(); | |
239 | TDF_Label aLabel = aShTool->AddShape (aShape); | |
240 | Handle(TDataStd_Name) anAttr; | |
241 | QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True); | |
242 | ||
243 | //false | |
244 | XCAFDoc_ShapeTool::SetAutoNaming (Standard_False); | |
245 | aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape(); | |
246 | aLabel = aShTool->AddShape (aShape); | |
247 | QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True); | |
248 | ||
249 | //restore | |
250 | XCAFDoc_ShapeTool::SetAutoNaming (aValue); | |
251 | ||
252 | return 0; | |
253 | } | |
254 | ||
5d1833ef | 255 | #include <ExprIntrp_GenExp.hxx> |
256 | Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
257 | { | |
258 | ||
259 | if (argc != 3) { | |
260 | di << "Usage : " << argv[0] << " string nb\n"; | |
261 | return 1; | |
262 | } | |
263 | ||
264 | TCollection_AsciiString aToken = argv[1]; | |
265 | Standard_Integer aNb = atoi(argv[2]); | |
266 | ||
267 | Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create(); | |
268 | for (Standard_Integer i=0; i < aNb; i++) | |
269 | { | |
270 | aGen->Process(aToken); | |
271 | Handle(Expr_GeneralExpression) aExpr = aGen->Expression(); | |
272 | } | |
273 | ||
274 | return 0; | |
275 | } | |
276 | ||
35e08fe8 | 277 | Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
e187cc0a | 278 | { |
279 | gp_Mat M0; | |
280 | di << "M0 = " | |
281 | << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}" | |
282 | << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}" | |
283 | << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"; | |
284 | return 0; | |
285 | } | |
286 | ||
bead40f2 | 287 | #include <TopoDS_Face.hxx> |
288 | #include <TopoDS_Face.hxx> | |
289 | #include <TopoDS.hxx> | |
290 | #include <BRepBuilderAPI_Transform.hxx> | |
291 | #include <BRepExtrema_DistShapeShape.hxx> | |
292 | #include <BRepTools.hxx> | |
293 | ||
f24125b9 | 294 | static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di) |
bead40f2 | 295 | { |
296 | BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN); | |
297 | if(!distShapeShape.IsDone()) { | |
298 | di <<"Distance ShapeShape is Not Done\n"; | |
299 | return Standard_False; | |
300 | } | |
301 | ||
302 | if(distShapeShape.Value() > 0.01) { | |
303 | di << "Wrong Dist = " <<distShapeShape.Value() << "\n"; | |
304 | return Standard_False; | |
305 | } else | |
306 | di << "Dist0 = " <<distShapeShape.Value() <<"\n"; | |
307 | ||
308 | ////////////////////////////////////////////////////////////////////////// | |
309 | /// First Flip Y | |
310 | const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970); | |
311 | const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970); | |
312 | ||
313 | gp_Vec2d mirrorVector1(axis1P1,axis1P2); | |
314 | ||
315 | gp_Trsf2d mirror1; | |
316 | mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1)); | |
317 | ||
318 | BRepBuilderAPI_Transform transformer1(mirror1); | |
319 | transformer1.Perform(originalWire); | |
320 | if(!transformer1.IsDone()) { | |
321 | di << "Not Done1 " << "\n"; | |
322 | return Standard_False; | |
323 | } | |
324 | const TopoDS_Shape& step1ModifiedShape = transformer1.ModifiedShape(originalWire); | |
325 | ||
326 | BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN); | |
327 | if(!distShapeShape1.IsDone()) | |
328 | return Standard_False; | |
329 | if(distShapeShape1.Value() > 0.01) { | |
330 | di << "Dist = " <<distShapeShape1.Value() <<"\n"; | |
331 | return Standard_False; | |
332 | } else | |
333 | di << "Dist1 = " <<distShapeShape1.Value() <<"\n"; | |
334 | ||
335 | ////////////////////////////////////////////////////////////////////////// | |
336 | /// Second flip Y | |
337 | transformer1.Perform(step1ModifiedShape); | |
338 | if(!transformer1.IsDone()) { | |
339 | di << "Not Done1 \n"; | |
340 | return Standard_False; | |
341 | } | |
342 | const TopoDS_Shape& step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape); | |
bead40f2 | 343 | |
344 | //This is identity matrix for values but for type is gp_Rotation ?! | |
345 | gp_Trsf2d mirror11 = mirror1; | |
346 | mirror11.PreMultiply(mirror1); | |
347 | ||
348 | BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN); | |
349 | if(!distShapeShape2.IsDone()) | |
350 | return Standard_False; | |
351 | ||
352 | //This last test case give error (the value is 1008.8822038689706) | |
353 | if(distShapeShape2.Value() > 0.01) { | |
354 | di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n"; | |
355 | Standard_Integer N = distShapeShape2.NbSolution(); | |
356 | di << "Nb = " <<N <<"\n"; | |
357 | for (Standard_Integer i=1;i <= N;i++) | |
358 | di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n"; | |
359 | return Standard_False; | |
360 | } | |
361 | di << "Distance2 = " <<distShapeShape2.Value() <<"\n"; | |
362 | ||
363 | return Standard_True; | |
364 | } | |
365 | static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a) | |
366 | { | |
367 | ||
368 | if (n != 3) { | |
369 | di <<"OCC23774: invalid number of input parameters\n"; | |
370 | return 1; | |
371 | } | |
372 | ||
373 | const char *ns1 = (a[1]), *ns2 = (a[2]); | |
374 | TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2)); | |
375 | if (S1.IsNull() || S2.IsNull()) { | |
376 | di <<"OCC23774: Null input shapes\n"; | |
377 | return 1; | |
378 | } | |
379 | const TopoDS_Face& aFace = TopoDS::Face(S1); | |
380 | if(!OCC23774Test(aFace, S2, di)) | |
381 | di << "Something is wrong\n"; | |
382 | ||
383 | return 0; | |
384 | } | |
385 | ||
1ef32e96 RL |
386 | #include <GeomConvert_ApproxSurface.hxx> |
387 | #include <Geom_BSplineSurface.hxx> | |
388 | #include <Draw.hxx> | |
389 | #include <OSD_Thread.hxx> | |
390 | static void GeomConvertTest (Draw_Interpretor& di, Standard_Integer theTargetNbUPoles, Standard_CString theFileName) | |
391 | { | |
392 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theFileName); | |
393 | GeomConvert_ApproxSurface aGAS (aSurf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1); | |
394 | if (!aGAS.IsDone()) { | |
395 | di << "ApproxSurface is not done!" << "\n"; | |
396 | return; | |
397 | } | |
398 | const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface(); | |
399 | if (aBSurf.IsNull()) { | |
400 | di << "BSplineSurface is not created!" << "\n"; | |
401 | return; | |
402 | } | |
403 | di << "Number of UPoles:" << aBSurf->NbUPoles() << "\n"; | |
404 | QCOMPARE (aBSurf->NbUPoles(), theTargetNbUPoles); | |
405 | } | |
406 | ||
407 | struct aData { | |
408 | Draw_Interpretor* di; | |
409 | Standard_Integer nbupoles; | |
410 | Standard_CString filename; | |
411 | }; | |
412 | ||
413 | Standard_EXPORT Standard_Address convert(Standard_Address data) | |
414 | { | |
415 | aData* info = (aData*) data; | |
416 | GeomConvertTest(*(info->di),info->nbupoles,info->filename); | |
417 | return NULL; | |
418 | } | |
419 | ||
420 | static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
421 | { | |
422 | if (argc != 3) { | |
423 | di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; | |
424 | return 1; | |
425 | } | |
426 | struct aData aStorage; | |
427 | aStorage.di = &di; | |
428 | aStorage.nbupoles = Draw::Atoi(argv[1]); | |
429 | aStorage.filename = argv[2]; | |
430 | ||
431 | OSD_Thread aThread1(convert); | |
432 | aThread1.Run(&aStorage); | |
433 | GeomConvertTest(di,aStorage.nbupoles,aStorage.filename); | |
85c44a05 | 434 | cout << "result of thread: " << aThread1.Wait() << endl; |
1ef32e96 RL |
435 | |
436 | return 0; | |
437 | } | |
d2786814 | 438 | |
1ef32e96 RL |
439 | #include <GeomInt_IntSS.hxx> |
440 | static void GeomIntSSTest (Draw_Interpretor& di, Standard_Integer theNbSol, Standard_CString theFileName1, Standard_CString theFileName2) | |
441 | { | |
442 | Handle(Geom_Surface) aSurf1 = DrawTrSurf::GetSurface(theFileName1); | |
443 | Handle(Geom_Surface) aSurf2 = DrawTrSurf::GetSurface(theFileName2); | |
444 | GeomInt_IntSS anInter; | |
445 | anInter.Perform(aSurf1, aSurf2, Precision::Confusion(), Standard_True); | |
446 | if (!anInter.IsDone()) { | |
447 | di << "An intersection is not done!" << "\n"; | |
448 | return; | |
449 | } | |
450 | ||
451 | di << "Number of Lines:" << anInter.NbLines() << "\n"; | |
452 | QCOMPARE (anInter.NbLines(), theNbSol); | |
453 | } | |
454 | ||
455 | struct aNewData { | |
456 | Draw_Interpretor* di; | |
457 | Standard_Integer nbsol; | |
458 | Standard_CString filename1; | |
459 | Standard_CString filename2; | |
460 | }; | |
461 | Standard_EXPORT Standard_Address convert_inter(Standard_Address data) | |
462 | { | |
463 | aNewData* info = (aNewData*) data; | |
464 | GeomIntSSTest(*(info->di),info->nbsol,info->filename1,info->filename2); | |
465 | return NULL; | |
466 | } | |
467 | ||
468 | static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
469 | { | |
470 | if (argc != 4) { | |
471 | di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; | |
472 | return 1; | |
473 | } | |
474 | struct aNewData aStorage; | |
475 | aStorage.di = &di; | |
476 | aStorage.nbsol = Draw::Atoi(argv[1]); | |
477 | aStorage.filename1 = argv[2]; | |
478 | aStorage.filename2 = argv[3]; | |
479 | ||
480 | OSD_Thread aThread1(convert_inter); | |
481 | aThread1.Run(&aStorage); | |
482 | GeomIntSSTest(di,aStorage.nbsol,aStorage.filename1,aStorage.filename2); | |
85c44a05 | 483 | cout << "result of thread: " << aThread1.Wait() << endl; |
1ef32e96 RL |
484 | |
485 | return 0; | |
486 | } | |
487 | ||
488 | #include <Geom_SurfaceOfRevolution.hxx> | |
06be28a4 RL |
489 | static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) |
490 | { | |
491 | if (argc < 2) { | |
492 | di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n"; | |
493 | return 1; | |
494 | } | |
495 | ||
496 | Standard_Integer ucontinuity = 1; | |
497 | Standard_Integer vcontinuity = 1; | |
498 | Standard_Boolean iscnu = false; | |
499 | Standard_Boolean iscnv = false; | |
500 | ||
501 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]); | |
502 | ||
503 | QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu); | |
504 | QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv); | |
505 | ||
506 | return 0; | |
507 | } | |
508 | ||
1939140c | 509 | #include <gp_Ax1.hxx> |
510 | #include <gp_Ax22d.hxx> | |
511 | #include <Geom_Plane.hxx> | |
512 | #include <Geom2d_Circle.hxx> | |
513 | #include <Geom2d_TrimmedCurve.hxx> | |
514 | #include <BRepBuilderAPI_MakeEdge.hxx> | |
515 | #include <BRepPrimAPI_MakeRevol.hxx> | |
516 | #include <Geom2d_OffsetCurve.hxx> | |
517 | ||
518 | static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
519 | { | |
520 | // Check the command arguments | |
521 | if ( argc != 1 ) | |
522 | { | |
523 | di << "Error: " << argv[0] << " - invalid number of arguments" << "\n"; | |
524 | di << "Usage: type help " << argv[0] << "\n"; | |
525 | return 1; // TCL_ERROR | |
526 | } | |
527 | ||
528 | gp_Ax1 RotoAx( gp::Origin(), gp::DZ() ); | |
529 | gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() ); | |
530 | Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() ); | |
531 | ||
532 | di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>" << "\n"; | |
533 | di << "-----------------------------------------------------------------------" << "\n"; | |
534 | ||
535 | Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0); | |
536 | Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0); | |
537 | TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane); | |
538 | ||
539 | DBRep::Set("e1", E1); | |
540 | ||
541 | BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx); | |
542 | TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() ); | |
543 | ||
544 | DBRep::Set("f1", F1); | |
545 | ||
546 | di << "Result: f1" << "\n"; | |
547 | ||
548 | di << "<<<< Preparing sample surface of revolution based on offset curve >>>>" << "\n"; | |
549 | di << "-----------------------------------------------------------------------" << "\n"; | |
550 | ||
551 | Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5); | |
552 | TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane); | |
553 | ||
554 | DBRep::Set("e2", E2); | |
555 | ||
556 | BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx); | |
557 | TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() ); | |
558 | ||
559 | DBRep::Set("f2", F2); | |
560 | ||
561 | di << "Result: f2" << "\n"; | |
562 | ||
563 | return 0; | |
564 | } | |
565 | ||
2e9fd4bc | 566 | #include <Geom_Curve.hxx> |
567 | #include <Geom_Surface.hxx> | |
568 | #include <Precision.hxx> | |
569 | #include <ShapeConstruct_ProjectCurveOnSurface.hxx> | |
570 | //======================================================================= | |
571 | //function : OCC24008 | |
572 | //purpose : | |
573 | //======================================================================= | |
574 | static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
575 | { | |
576 | if (argc != 3) { | |
577 | di << "Usage: " << argv[0] << " invalid number of arguments" << "\n"; | |
578 | return 1; | |
579 | } | |
580 | Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]); | |
581 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]); | |
582 | if (aCurve.IsNull()) { | |
583 | di << "Curve was not read" << "\n"; | |
584 | return 1; | |
585 | } | |
586 | if (aSurf.IsNull()) { | |
587 | di << "Surface was not read" << "\n"; | |
588 | return 1; | |
589 | } | |
590 | ShapeConstruct_ProjectCurveOnSurface aProj; | |
591 | aProj.Init (aSurf, Precision::Confusion()); | |
592 | try { | |
593 | Handle(Geom2d_Curve) aPCurve; | |
594 | aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve); | |
595 | if (aPCurve.IsNull()) { | |
596 | di << "PCurve was not created" << "\n"; | |
597 | return 1; | |
598 | } | |
599 | } catch (...) { | |
600 | di << "Exception was caught" << "\n"; | |
601 | } | |
602 | return 0; | |
603 | } | |
604 | ||
470ebb43 | 605 | #include <GeomAdaptor_Surface.hxx> |
606 | #include <Draw.hxx> | |
607 | //======================================================================= | |
608 | //function : OCC23945 | |
609 | //purpose : | |
610 | //======================================================================= | |
611 | ||
35e08fe8 | 612 | static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a) |
470ebb43 | 613 | { |
614 | if (n < 5) return 1; | |
615 | ||
616 | Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]); | |
617 | if (aS.IsNull()) return 1; | |
618 | ||
619 | GeomAdaptor_Surface GS(aS); | |
620 | ||
621 | Standard_Real U = Draw::Atof(a[2]); | |
622 | Standard_Real V = Draw::Atof(a[3]); | |
623 | ||
624 | Standard_Boolean DrawPoint = ( n%3 == 2); | |
625 | if ( DrawPoint) n--; | |
626 | ||
627 | gp_Pnt P; | |
628 | if (n >= 13) { | |
629 | gp_Vec DU,DV; | |
630 | if (n >= 22) { | |
631 | gp_Vec D2U,D2V,D2UV; | |
632 | GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV); | |
633 | Draw::Set(a[13],D2U.X()); | |
634 | Draw::Set(a[14],D2U.Y()); | |
635 | Draw::Set(a[15],D2U.Z()); | |
636 | Draw::Set(a[16],D2V.X()); | |
637 | Draw::Set(a[17],D2V.Y()); | |
638 | Draw::Set(a[18],D2V.Z()); | |
639 | Draw::Set(a[19],D2UV.X()); | |
640 | Draw::Set(a[20],D2UV.Y()); | |
641 | Draw::Set(a[21],D2UV.Z()); | |
642 | } | |
643 | else | |
644 | GS.D1(U,V,P,DU,DV); | |
645 | ||
646 | Draw::Set(a[7],DU.X()); | |
647 | Draw::Set(a[8],DU.Y()); | |
648 | Draw::Set(a[9],DU.Z()); | |
649 | Draw::Set(a[10],DV.X()); | |
650 | Draw::Set(a[11],DV.Y()); | |
651 | Draw::Set(a[12],DV.Z()); | |
652 | } | |
653 | else | |
654 | GS.D0(U,V,P); | |
655 | ||
656 | if ( n > 6) { | |
657 | Draw::Set(a[4],P.X()); | |
658 | Draw::Set(a[5],P.Y()); | |
659 | Draw::Set(a[6],P.Z()); | |
660 | } | |
661 | if ( DrawPoint) { | |
662 | DrawTrSurf::Set(a[n],P); | |
663 | } | |
664 | ||
665 | return 0; | |
666 | } | |
667 | ||
4bee43a9 P |
668 | #include <Voxel_BoolDS.hxx> |
669 | #include <Voxel_FastConverter.hxx> | |
670 | #include <Voxel_BooleanOperation.hxx> | |
671 | static Standard_Integer OCC24019 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
672 | { | |
673 | if ( argc != 2 ) { | |
674 | di << "Error: " << argv[0] << " - invalid number of arguments" << "\n"; | |
675 | return 1; | |
676 | } | |
677 | ||
678 | TCollection_AsciiString aFileName = argv[1]; | |
679 | TopoDS_Shape aShape; | |
680 | BRep_Builder aBuilder; | |
681 | ||
682 | if (!BRepTools::Read(aShape, aFileName.ToCString(), aBuilder)) { | |
683 | di << "Error: Could not read a shape!" << "\n"; | |
684 | return 1; | |
685 | } | |
686 | ||
687 | TopoDS_Solid aShape1 = BRepPrimAPI_MakeSphere(gp_Pnt(20,25,35), 7); | |
688 | ||
689 | Standard_Real deflection = 0.005; | |
690 | Standard_Integer nbThreads = 1; | |
691 | Standard_Integer nbx = 200, nby = 200, nbz = 200; | |
692 | Voxel_BoolDS theVoxels(0,0,0, 50, 50, 50, nbx, nby, nbz); | |
693 | Voxel_BoolDS theVoxels1(0,0,0, 50, 50, 50, nbx, nby, nbz); | |
694 | ||
695 | Standard_Integer progress = 0; | |
696 | Voxel_FastConverter fcp(aShape, theVoxels, deflection, nbx, nby, nbz, nbThreads); | |
697 | fcp.ConvertUsingSAT(progress, 1); | |
698 | fcp.FillInVolume(1); | |
699 | ||
700 | Voxel_FastConverter fcp1(aShape1, theVoxels1, deflection, nbx, nby, nbz, nbThreads); | |
701 | fcp1.ConvertUsingSAT(progress, 1); | |
702 | fcp1.FillInVolume(1); | |
703 | ||
704 | Voxel_BooleanOperation op; | |
705 | Standard_Boolean result = op.Cut(theVoxels1, theVoxels); | |
706 | if ( result != 1 ) { | |
707 | di << "Error: invalid boolean operation" << "\n"; | |
708 | } else { | |
709 | di << "OK: boolean operation is ok" << "\n"; | |
710 | } | |
711 | ||
712 | return 0; | |
713 | } | |
714 | ||
29cb310a | 715 | //======================================================================= |
716 | //function : OCC11758 | |
717 | //purpose : | |
718 | //======================================================================= | |
498ce76b | 719 | static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**) |
29cb310a | 720 | { |
721 | if (n != 1) return 1; | |
722 | ||
723 | const char* theStr = "0123456789"; | |
724 | Standard_Integer i, j; | |
725 | for ( i = 0; i < 5; ++i ) { | |
726 | // TCollection_AsciiString(const Standard_CString astring) | |
727 | TCollection_AsciiString a(theStr+i); | |
728 | // IsEqual (const Standard_CString other)const | |
729 | //assert( a == theStr+i ); | |
730 | QCOMPARE ( a , theStr+i ); | |
731 | ||
732 | //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen ) | |
733 | TCollection_AsciiString b(theStr+i, 3); | |
734 | //assert( b.Length() == 3 ); | |
735 | //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 ); | |
736 | //assert( strlen( b.ToCString() ) == 3 ); | |
737 | QCOMPARE ( b.Length() , 3 ); | |
738 | QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 ); | |
739 | QCOMPARE ( b.Length() , 3 ); | |
740 | ||
741 | //TCollection_AsciiString(const Standard_Integer aValue) | |
742 | TCollection_AsciiString c(i); | |
743 | //assert( c.IsIntegerValue() ); | |
744 | //assert( c.IntegerValue() == i ); | |
745 | QCOMPARE ( c.IsIntegerValue() , Standard_True ); | |
746 | QCOMPARE ( c.IntegerValue() , i ); | |
747 | ||
748 | //TCollection_AsciiString(const Standard_Real aValue) | |
749 | TCollection_AsciiString d( 0.1*i ); | |
750 | //assert( d.IsRealValue() ); | |
751 | //assert( TCollection_AsciiString(3.3) == "3.3"); | |
752 | QCOMPARE ( d.IsRealValue() , Standard_True ); | |
753 | QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" ); | |
754 | ||
755 | //TCollection_AsciiString(const TCollection_AsciiString& astring) | |
756 | TCollection_AsciiString e(d); | |
757 | //assert( e == d ); | |
758 | //assert( e.Length() == d.Length() ); | |
759 | //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 ); | |
760 | QCOMPARE ( e ,d ); | |
761 | QCOMPARE ( e.Length() , d.Length() ); | |
762 | QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 ); | |
763 | ||
764 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
765 | // const Standard_Character other ) | |
766 | TCollection_AsciiString f(e,'\a'); | |
767 | //assert( f.Length() == e.Length() + 1 ); | |
768 | //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 ); | |
769 | //assert( f.Value( f.Length() ) == '\a'); | |
770 | QCOMPARE ( f.Length() , e.Length() + 1 ); | |
771 | QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 ); | |
772 | QCOMPARE ( f.Value( f.Length() ) , '\a' ); | |
773 | ||
774 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
775 | // const Standard_CString other ) | |
776 | TCollection_AsciiString g(f, theStr); | |
777 | //assert( g.Length() == f.Length() + strlen( theStr )); | |
778 | //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 ); | |
779 | //assert( g.Search( theStr ) == f.Length() + 1 ); | |
780 | QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) ); | |
781 | QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 ); | |
782 | QCOMPARE ( g.Search( theStr ) , f.Length() + 1 ); | |
783 | ||
784 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
785 | // const TCollection_AsciiString& other ) | |
786 | TCollection_AsciiString h(d,a); | |
787 | //assert( h.Length() == d.Length() + a.Length() ); | |
788 | //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 ); | |
789 | //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 ); | |
790 | QCOMPARE ( h.Length() , d.Length() + a.Length() ); | |
791 | QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 ); | |
792 | QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 ); | |
793 | ||
794 | // AssignCat(const Standard_CString other) | |
795 | c.AssignCat( a.ToCString() ); | |
796 | //assert( c.Length() == 1 + a.Length() ); | |
797 | //assert( c.Search( a ) == 2 ); | |
798 | QCOMPARE ( c.Length() , 1 + a.Length() ); | |
799 | QCOMPARE ( c.Search( a ) , 2 ); | |
800 | ||
801 | // AssignCat(const TCollection_AsciiString& other) | |
802 | Standard_Integer dl = d.Length(); | |
803 | d.AssignCat( a ); | |
804 | //assert( d.Length() == dl + a.Length() ); | |
805 | //assert( d.Search( a ) == dl + 1 ); | |
806 | QCOMPARE ( d.Length() , dl + a.Length() ); | |
807 | QCOMPARE ( d.Search( a ) , dl + 1 ); | |
808 | ||
809 | // Capitalize() | |
810 | TCollection_AsciiString capitalize("aBC"); | |
811 | capitalize.Capitalize(); | |
812 | //assert( capitalize == "Abc" ); | |
813 | QCOMPARE ( capitalize , "Abc" ); | |
814 | ||
815 | // Copy(const Standard_CString fromwhere) | |
816 | d = theStr+i; | |
817 | //assert( d == theStr+i ); | |
818 | QCOMPARE ( d , theStr+i ); | |
819 | ||
820 | // Copy(const TCollection_AsciiString& fromwhere) | |
821 | d = h; | |
822 | // IsEqual (const TCollection_AsciiString& other)const | |
823 | //assert( d == h ); | |
824 | QCOMPARE ( d , h ); | |
825 | ||
826 | // Insert(const Standard_Integer where, const Standard_CString what) | |
827 | dl = d.Length(); | |
828 | d.Insert( 2, theStr ); | |
829 | //assert( d.Length() == dl + strlen( theStr )); | |
830 | //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 ); | |
831 | QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) ); | |
832 | QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 ); | |
833 | ||
834 | //Insert(const Standard_Integer where,const Standard_Character what) | |
835 | d = theStr; | |
836 | d.Insert( i+1, 'i' ); | |
837 | //assert( d.Length() == strlen( theStr ) + 1 ); | |
838 | //assert( d.Value( i+1 ) == 'i'); | |
839 | //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 ); | |
840 | QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 ); | |
841 | QCOMPARE ( d.Value( i+1 ) , 'i' ); | |
842 | QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 ); | |
843 | ||
844 | //Insert(const Standard_Integer where,const TCollection_AsciiString& what) | |
845 | d = theStr; | |
846 | d.Insert( i+1, TCollection_AsciiString( "i" )); | |
847 | //assert( d.Length() == strlen( theStr ) + 1 ); | |
848 | //assert( d.Value( i+1 ) == 'i'); | |
849 | //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 ); | |
850 | QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 ); | |
851 | QCOMPARE ( d.Value( i+1 ) , 'i' ); | |
852 | QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 ); | |
853 | ||
854 | // IsDifferent (const Standard_CString other)const | |
855 | //assert( d.IsDifferent( theStr )); | |
856 | //assert( d.IsDifferent( "theStr" )); | |
857 | //assert( d.IsDifferent( "" )); | |
858 | //assert( !d.IsDifferent( d.ToCString() )); | |
859 | QCOMPARE ( d.IsDifferent( theStr ) , Standard_True ); | |
860 | QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True ); | |
861 | QCOMPARE ( d.IsDifferent( "" ) , Standard_True ); | |
862 | QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True ); | |
863 | ||
864 | // IsDifferent (const TCollection_AsciiString& other)const | |
865 | //assert( d.IsDifferent( TCollection_AsciiString() )); | |
866 | //assert( d.IsDifferent( a )); | |
867 | //assert( d.IsDifferent( h )); | |
868 | //assert( !d.IsDifferent( d )); | |
869 | QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True ); | |
870 | QCOMPARE ( d.IsDifferent( a ) , Standard_True ); | |
871 | QCOMPARE ( d.IsDifferent( h ) , Standard_True ); | |
872 | QCOMPARE ( !d.IsDifferent( d ) , Standard_True ); | |
873 | ||
874 | // IsLess (const Standard_CString other)const | |
875 | //assert( TCollection_AsciiString ("0"). IsLess("1")); | |
876 | //assert( TCollection_AsciiString ("0"). IsLess("00")); | |
877 | //assert( TCollection_AsciiString (""). IsLess("0")); | |
878 | //assert( !TCollection_AsciiString("1"). IsLess("0")); | |
879 | //assert( !TCollection_AsciiString("00").IsLess("0")); | |
880 | //assert( !TCollection_AsciiString("0"). IsLess("")); | |
881 | //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1)); | |
882 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True ); | |
883 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True ); | |
884 | QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True ); | |
885 | QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True ); | |
886 | QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True ); | |
887 | QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True ); | |
888 | QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True ); | |
889 | ||
890 | // IsLess (const TCollection_AsciiString& other)const | |
891 | //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" ))); | |
892 | //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00"))); | |
893 | //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" ))); | |
894 | //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" ))); | |
895 | //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" ))); | |
896 | //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" ))); | |
897 | //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1))); | |
898 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True ); | |
899 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True ); | |
900 | QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
901 | QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
902 | QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
903 | QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True ); | |
904 | QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True ); | |
905 | ||
906 | // IsGreater (const Standard_CString other)const | |
907 | //assert( !TCollection_AsciiString("0"). IsGreater("1")); | |
908 | //assert( !TCollection_AsciiString("0"). IsGreater("00")); | |
909 | //assert( !TCollection_AsciiString(""). IsGreater("0")); | |
910 | //assert( TCollection_AsciiString ("1"). IsGreater("0")); | |
911 | //assert( TCollection_AsciiString ("00").IsGreater("0")); | |
912 | //assert( TCollection_AsciiString ("0"). IsGreater("")); | |
913 | //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i)); | |
914 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True ); | |
915 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True ); | |
916 | QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True ); | |
917 | QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True ); | |
918 | QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True ); | |
919 | QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True ); | |
920 | QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True ); | |
921 | ||
922 | // IsGreater (const TCollection_AsciiString& other)const | |
923 | //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" ))); | |
924 | //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00"))); | |
925 | //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" ))); | |
926 | //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" ))); | |
927 | //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" ))); | |
928 | //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" ))); | |
929 | //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i))); | |
930 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True ); | |
931 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True ); | |
932 | QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
933 | QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
934 | QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
935 | QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True ); | |
936 | QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True ); | |
937 | ||
938 | // void Read(Standard_IStream& astream) | |
939 | std::istringstream is( theStr ); | |
940 | e.Read( is ); | |
941 | //assert( e == theStr ); | |
942 | QCOMPARE ( e , theStr ); | |
943 | ||
944 | // Standard_Integer SearchFromEnd (const Standard_CString what)const | |
945 | //assert( e.SearchFromEnd( theStr + i ) == i + 1 ); | |
946 | QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 ); | |
947 | ||
948 | // SetValue(const Standard_Integer where, const Standard_CString what) | |
949 | e.SetValue( i+1, "what"); | |
950 | //assert( e.Search( "what" ) == i+1 ); | |
951 | //assert( e.Length() == strlen( theStr )); | |
952 | QCOMPARE ( e.Search( "what" ) , i+1 ); | |
953 | QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) ); | |
954 | ||
955 | // TCollection_AsciiString Split (const Standard_Integer where) | |
956 | e = theStr; | |
957 | d = e.Split( i+1 ); | |
958 | //assert( d.Length() + e.Length() == strlen( theStr )); | |
959 | QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) ); | |
960 | ||
961 | // TCollection_AsciiString SubString (const Standard_Integer FromIndex, | |
962 | // const Standard_Integer ToIndex) const | |
963 | e = theStr; | |
964 | d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 ); | |
965 | //assert( d.Length() == 3 ); | |
966 | //assert( d.Value(1) == theStr[ i ]); | |
967 | QCOMPARE ( d.Length() , 3 ); | |
968 | QCOMPARE ( d.Value(1) , theStr[ i ] ); | |
969 | ||
970 | // TCollection_AsciiString Token (const Standard_CString separators, | |
971 | // const Standard_Integer whichone) const | |
972 | e = " "; | |
973 | for ( j = 0; j < i; ++j ) { | |
974 | e += TCollection_AsciiString( theStr[j] ) + " "; | |
975 | //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 )); | |
976 | QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) ); | |
977 | } | |
978 | } | |
979 | for ( i = 0; i < 5; ++i ) | |
980 | { | |
981 | // TCollection_ExtendedString (const Standard_CString astring, | |
982 | // const Standard_Boolean isMultiByte) | |
983 | const TCollection_ExtendedString a( theStr+i ); | |
984 | //assert( TCollection_AsciiString( a ) == theStr+i ); | |
985 | QCOMPARE ( TCollection_AsciiString( a ) , theStr+i ); | |
986 | ||
987 | //TCollection_ExtendedString (const Standard_ExtString astring) | |
988 | const TCollection_ExtendedString b( a.ToExtString() ); | |
989 | //assert( a == b ); | |
990 | QCOMPARE ( a , b ); | |
991 | ||
992 | // TCollection_ExtendedString (const Standard_Integer length, | |
993 | // const Standard_ExtCharacter filler ) | |
994 | const TCollection_ExtendedString c( i, 1 ); | |
995 | //assert( c.Length() == i ); | |
996 | QCOMPARE ( c.Length() , i ); | |
997 | if ( c.Length() > 0 ) { | |
998 | //assert( c.Value( i ) == 1 ); | |
999 | QCOMPARE ( c.Value( i ) , 1 ); | |
1000 | } | |
1001 | ||
1002 | // TCollection_ExtendedString (const Standard_Integer aValue) | |
1003 | TCollection_ExtendedString d( i ); | |
1004 | const TCollection_AsciiString da( d ); | |
1005 | //assert( da.IsIntegerValue() ); | |
1006 | //assert( da.IntegerValue() == i ); | |
1007 | QCOMPARE ( da.IsIntegerValue() , Standard_True ); | |
1008 | QCOMPARE ( da.IntegerValue(), i ); | |
1009 | ||
1010 | // TCollection_ExtendedString (const Standard_Real aValue) | |
1011 | const TCollection_ExtendedString e( 0.1 * i ); | |
1012 | const TCollection_AsciiString ea( e ); | |
1013 | //assert( ea.IsRealValue() ); | |
1014 | //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 ); | |
1015 | QCOMPARE ( ea.IsRealValue() , Standard_True ); | |
1016 | QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True ); | |
1017 | ||
1018 | // TCollection_ExtendedString (const TCollection_ExtendedString& astring) | |
1019 | const TCollection_ExtendedString f(e); | |
1020 | //assert( f.Length() == e.Length()); | |
1021 | //assert( f == e ); | |
1022 | QCOMPARE ( f.Length() , e.Length() ); | |
1023 | QCOMPARE ( f , e ); | |
1024 | ||
1025 | // TCollection_ExtendedString (const TCollection_AsciiString& astring) | |
1026 | const TCollection_ExtendedString g( ea ); | |
1027 | //assert( g.Length() == ea.Length() ); | |
1028 | //assert( TCollection_AsciiString( g ) == ea ); | |
1029 | QCOMPARE ( g.Length() , ea.Length() ); | |
1030 | QCOMPARE ( TCollection_AsciiString( g ) , ea ); | |
1031 | ||
1032 | // AssignCat (const TCollection_ExtendedString& other) | |
1033 | const TCollection_ExtendedString sep(","); | |
1034 | d.AssignCat( sep ); | |
1035 | d.AssignCat( g ); | |
1036 | //assert( d.Length() == 2 + g.Length() ); | |
1037 | //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i )); | |
1038 | //assert( d.Token( sep.ToExtString(), 2 ) == g ); | |
1039 | QCOMPARE ( d.Length() , 2 + g.Length() ); | |
1040 | QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) ); | |
1041 | QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g ); | |
1042 | ||
1043 | // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const | |
1044 | const TCollection_ExtendedString cat = a.Cat( sep ); | |
1045 | //assert( cat.Length() == a.Length() + sep.Length() ); | |
1046 | //assert( cat.Search( a ) == 1 ); | |
1047 | //assert( cat.Search( sep ) == a.Length() + 1 ); | |
1048 | QCOMPARE ( cat.Length() , a.Length() + sep.Length() ); | |
1049 | QCOMPARE ( cat.Search( a ) , 1 ); | |
1050 | QCOMPARE ( cat.Search( sep ) , a.Length() + 1 ); | |
1051 | ||
1052 | // Copy (const TCollection_ExtendedString& fromwhere) | |
1053 | d = cat; | |
1054 | //assert( d.Length() == cat.Length() ); | |
1055 | //assert( d == cat ); | |
1056 | QCOMPARE ( d.Length() , cat.Length() ); | |
1057 | QCOMPARE ( d , cat ); | |
1058 | ||
1059 | // IsEqual (const Standard_ExtString other) const | |
1060 | //assert( d.IsEqual( d.ToExtString() )); | |
1061 | QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True ); | |
1062 | ||
1063 | // IsDifferent (const Standard_ExtString other ) const | |
1064 | //assert( d.IsDifferent( a.ToExtString() )); | |
1065 | QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True ); | |
1066 | ||
1067 | // IsDifferent (const TCollection_ExtendedString& other) const | |
1068 | //assert( d.IsDifferent( a )); | |
1069 | QCOMPARE ( d.IsDifferent( a ) , Standard_True ); | |
1070 | ||
1071 | // IsLess (const Standard_ExtString other) const | |
1072 | const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1); | |
1073 | //assert( l0. IsLess( l1.ToExtString() )); | |
1074 | //assert( l0. IsLess( l00.ToExtString() )); | |
1075 | //assert( l. IsLess( l0.ToExtString() )); | |
1076 | //assert( ! l1. IsLess( l0.ToExtString() )); | |
1077 | //assert( ! l00.IsLess( l0.ToExtString() )); | |
1078 | //assert( ! l0. IsLess( l.ToExtString() )); | |
1079 | //assert( ls.IsLess( ls1.ToExtString() )); | |
1080 | QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True ); | |
1081 | QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True ); | |
1082 | QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True ); | |
1083 | QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True ); | |
1084 | QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True ); | |
1085 | QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True ); | |
1086 | QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True ); | |
1087 | ||
1088 | // IsLess (const TCollection_ExtendedString& other) const | |
1089 | //assert( l0. IsLess( l1 )); | |
1090 | //assert( l0. IsLess( l00 )); | |
1091 | //assert( l. IsLess( l0 )); | |
1092 | //assert( ! l1. IsLess( l0 )); | |
1093 | //assert( ! l00.IsLess( l0 )); | |
1094 | //assert( ! l0. IsLess( l )); | |
1095 | //assert( ls.IsLess( ls1 )); | |
1096 | QCOMPARE ( l0. IsLess( l1 ) , Standard_True ); | |
1097 | QCOMPARE ( l0. IsLess( l00 ) , Standard_True ); | |
1098 | QCOMPARE ( l. IsLess( l0 ) , Standard_True ); | |
1099 | QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True ); | |
1100 | QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True ); | |
1101 | QCOMPARE ( ! l0. IsLess( l ) , Standard_True ); | |
1102 | QCOMPARE ( ls.IsLess( ls1 ) , Standard_True ); | |
1103 | ||
1104 | // IsGreater (const Standard_ExtString other) const | |
1105 | //assert( ! l0.IsGreater( l1.ToExtString() )); | |
1106 | //assert( ! l0.IsGreater( l00.ToExtString() )); | |
1107 | //assert( ! l. IsGreater( l0.ToExtString() )); | |
1108 | //assert( l1. IsGreater( l0.ToExtString() )); | |
1109 | //assert( l00.IsGreater( l0.ToExtString() )); | |
1110 | //assert( l0. IsGreater( l.ToExtString() )); | |
1111 | //assert( ls1.IsGreater( ls.ToExtString() )); | |
1112 | QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True ); | |
1113 | QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True ); | |
1114 | QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True ); | |
1115 | QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True ); | |
1116 | QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True ); | |
1117 | QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True ); | |
1118 | QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True ); | |
1119 | ||
1120 | // IsGreater (const TCollection_ExtendedString& other) const | |
1121 | //assert( ! l0.IsGreater( l1)); | |
1122 | //assert( ! l0.IsGreater( l00)); | |
1123 | //assert( ! l. IsGreater( l0)); | |
1124 | //assert( l1. IsGreater( l0)); | |
1125 | //assert( l00.IsGreater( l0)); | |
1126 | //assert( l0. IsGreater( l)); | |
1127 | //assert( ls1.IsGreater( ls)); | |
1128 | QCOMPARE ( ! l0.IsGreater( l1) , Standard_True ); | |
1129 | QCOMPARE ( ! l0.IsGreater( l00) , Standard_True ); | |
1130 | QCOMPARE ( ! l. IsGreater( l0) , Standard_True ); | |
1131 | QCOMPARE ( l1. IsGreater( l0) , Standard_True ); | |
1132 | QCOMPARE ( l00.IsGreater( l0) , Standard_True ); | |
1133 | QCOMPARE ( l0. IsGreater( l) , Standard_True ); | |
1134 | QCOMPARE ( ls1.IsGreater( ls) , Standard_True ); | |
1135 | ||
1136 | // ========================== | |
1137 | //TCollection_HAsciiString:: | |
1138 | // ========================== | |
1139 | ||
1140 | // IsDifferent(const Handle(TCollection_HAsciiString)& S) | |
1141 | Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i ); | |
1142 | Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 ); | |
1143 | //assert( ha1->IsDifferent( ha2 )); | |
1144 | //assert( !ha1->IsDifferent( ha1 )); | |
1145 | QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True ); | |
1146 | QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True ); | |
1147 | ||
1148 | // IsSameString (const Handle(TCollection_HAsciiString)& S) | |
1149 | //assert( !ha1->IsSameString( ha2 )); | |
1150 | //assert( ha1->IsSameString( ha1 )); | |
1151 | QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True ); | |
1152 | QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True ); | |
1153 | ||
1154 | // IsSameState (const Handle(TCollection_HAsciiString)& other) const | |
1155 | //assert( !ha1->IsSameState( ha2 )); | |
1156 | //assert( ha1->IsSameState( ha1 )); | |
1157 | QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True ); | |
1158 | QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True ); | |
1159 | ||
1160 | // IsSameString (const Handle(TCollection_HAsciiString)& S , | |
1161 | // const Standard_Boolean CaseSensitive) const | |
1162 | //assert( !ha1->IsSameString( ha2, true )); | |
1163 | //assert( ha1->IsSameString( ha1, true )); | |
1164 | //assert( !ha1->IsSameString( ha2, false )); | |
1165 | //assert( ha1->IsSameString( ha1, false )); | |
1166 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True ); | |
1167 | QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True ); | |
1168 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True ); | |
1169 | QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True ); | |
1170 | ||
1171 | ha1->SetValue( 1, "AbC0000000"); | |
1172 | ha2->SetValue( 1, "aBc0000000"); | |
1173 | //assert( !ha1->IsSameString( ha2, true )); | |
1174 | //assert( ha1->IsSameString( ha2, false )); | |
1175 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True ); | |
1176 | QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True ); | |
1177 | } | |
1178 | return 0; | |
1179 | } | |
1180 | ||
788cbaf4 | 1181 | #include <Geom_CylindricalSurface.hxx> |
1182 | #include <IntTools_FaceFace.hxx> | |
1183 | #include <IntTools_Curve.hxx> | |
1184 | #include <IntTools_PntOn2Faces.hxx> | |
1185 | ||
1186 | static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) | |
1187 | { | |
1188 | if(theNArg < 2) | |
1189 | { | |
1190 | theDI << "Wrong a number of arguments!\n"; | |
1191 | return 1; | |
1192 | } | |
1193 | ||
1194 | Handle_Geom_Plane plane(new Geom_Plane( | |
1195 | gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678), | |
1196 | gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000), | |
1197 | gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000)))); | |
1198 | Handle(Geom_CylindricalSurface) cylinder( | |
1199 | new Geom_CylindricalSurface( | |
1200 | gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465), | |
1201 | gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000), | |
1202 | gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)), | |
1203 | 19.712534607908712)); | |
1204 | ||
1205 | DrawTrSurf::Set("pln", plane); | |
1206 | theDI << "pln\n"; | |
1207 | DrawTrSurf::Set("cyl", cylinder); | |
1208 | theDI << "cyl\n"; | |
1209 | ||
1210 | BRep_Builder builder; | |
1211 | TopoDS_Face face1, face2; | |
1212 | builder.MakeFace(face1, plane, Precision::Confusion()); | |
1213 | builder.MakeFace(face2, cylinder, Precision::Confusion()); | |
1214 | IntTools_FaceFace anInters; | |
1215 | anInters.SetParameters(false, true, true, Precision::Confusion()); | |
1216 | anInters.Perform(face1, face2); | |
1217 | ||
1218 | if (!anInters.IsDone()) | |
1219 | { | |
1220 | theDI<<"No intersections found!"<<"\n"; | |
1221 | ||
1222 | return 1; | |
1223 | } | |
1224 | ||
1225 | //Handle(Geom_Curve) aResult; | |
1226 | //gp_Pnt aPoint; | |
1227 | ||
1228 | const IntTools_SequenceOfCurves& aCvsX=anInters.Lines(); | |
1229 | const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points(); | |
1230 | ||
1231 | char buf[1024]; | |
1232 | Standard_Integer aNbCurves, aNbPoints; | |
1233 | ||
1234 | aNbCurves=aCvsX.Length(); | |
1235 | aNbPoints=aPntsX.Length(); | |
1236 | ||
1237 | if (aNbCurves >= 2) | |
1238 | { | |
1239 | for (Standard_Integer i=1; i<=aNbCurves; ++i) | |
1240 | { | |
1241 | Sprintf(buf, "%s_%d",theArgv[1],i); | |
1242 | theDI << buf << " "; | |
1243 | ||
1244 | const IntTools_Curve& aIC = aCvsX(i); | |
1245 | const Handle(Geom_Curve)& aC3D= aIC.Curve(); | |
1246 | DrawTrSurf::Set(buf,aC3D); | |
1247 | } | |
1248 | } | |
1249 | else if (aNbCurves == 1) | |
1250 | { | |
1251 | const IntTools_Curve& aIC = aCvsX(1); | |
1252 | const Handle(Geom_Curve)& aC3D= aIC.Curve(); | |
1253 | Sprintf(buf, "%s",theArgv[1]); | |
1254 | theDI << buf << " "; | |
1255 | DrawTrSurf::Set(buf,aC3D); | |
1256 | } | |
1257 | ||
1258 | for (Standard_Integer i = 1; i<=aNbPoints; ++i) | |
1259 | { | |
1260 | const IntTools_PntOn2Faces& aPi=aPntsX(i); | |
1261 | const gp_Pnt& aP=aPi.P1().Pnt(); | |
1262 | ||
1263 | Sprintf(buf,"%s_p_%d",theArgv[1],i); | |
1264 | theDI << buf << " "; | |
1265 | DrawTrSurf::Set(buf, aP); | |
1266 | } | |
1267 | ||
1268 | return 0; | |
1269 | } | |
1270 | ||
89d8607f | 1271 | #include <Extrema_FuncExtPS.hxx> |
1272 | #include <math_FunctionSetRoot.hxx> | |
1273 | #include <math_Vector.hxx> | |
1274 | #include <BRepBuilderAPI_MakeVertex.hxx> | |
1275 | static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) | |
1276 | { | |
1277 | Standard_Integer anArgIter = 1; | |
1278 | if (theNArg < 5) | |
1279 | { | |
1280 | theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]"<<"\n"; | |
1281 | return 1; | |
1282 | } | |
1283 | ||
1284 | // get target shape | |
1285 | Standard_CString aFaceName = theArgv[anArgIter++]; | |
1286 | Standard_CString aVertName = theArgv[anArgIter++]; | |
1287 | const TopoDS_Shape aShapeF = DBRep::Get (aFaceName); | |
1288 | const TopoDS_Shape aShapeV = DBRep::Get (aVertName); | |
1289 | const Standard_Real aUFrom = Atof (theArgv[anArgIter++]); | |
1290 | const Standard_Real aVFrom = Atof (theArgv[anArgIter++]); | |
1291 | const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100; | |
1292 | if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE) | |
1293 | { | |
1294 | std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl; | |
1295 | return 1; | |
1296 | } | |
1297 | if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX) | |
1298 | { | |
1299 | std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl; | |
1300 | return 1; | |
1301 | } | |
1302 | const TopoDS_Face aFace = TopoDS::Face (aShapeF); | |
1303 | const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV); | |
1304 | GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace)); | |
1305 | ||
1306 | gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes; | |
1307 | ||
1308 | Extrema_FuncExtPS anExtFunc; | |
1309 | math_FunctionSetRoot aRoot (anExtFunc, aNbIts); | |
1310 | ||
1311 | math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2); | |
1312 | aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion(); | |
1313 | aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite(); | |
1314 | aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite(); | |
1315 | aFromUV(1) = aUFrom; aFromUV(2) = aVFrom; | |
1316 | ||
1317 | anExtFunc.Initialize (aSurf); | |
1318 | anExtFunc.SetPoint (aPnt); | |
1319 | aRoot.SetTolerance (aTolUV); | |
1320 | aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup); | |
1321 | if (!aRoot.IsDone()) | |
1322 | { | |
1323 | std::cerr << "No results!\n"; | |
1324 | return 1; | |
1325 | } | |
1326 | ||
1327 | theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n"; | |
1328 | ||
1329 | aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes); | |
1330 | DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes)); | |
1331 | return 0; | |
1332 | } | |
1333 | ||
ab2db9a5 | 1334 | //! Check boolean operations on NCollection_Map |
1335 | static Standard_Integer OCC24271 (Draw_Interpretor& di, | |
1336 | Standard_Integer /*theArgNb*/, | |
1337 | const char** /*theArgVec*/) | |
1338 | { | |
1339 | // input data | |
1340 | const Standard_Integer aLeftLower = 1; | |
1341 | const Standard_Integer aLeftUpper = 10; | |
1342 | const Standard_Integer aRightLower = 5; | |
1343 | const Standard_Integer aRightUpper = 15; | |
1344 | ||
1345 | // define arguments | |
1346 | NCollection_Map<Standard_Integer> aMapLeft; | |
1347 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1348 | { | |
1349 | aMapLeft.Add (aKeyIter); | |
1350 | } | |
1351 | ||
1352 | NCollection_Map<Standard_Integer> aMapRight; | |
1353 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter) | |
1354 | { | |
1355 | aMapRight.Add (aKeyIter); | |
1356 | } | |
1357 | ||
1358 | QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False); | |
1359 | QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False); | |
1360 | ||
1361 | // validate Union operation | |
1362 | NCollection_Map<Standard_Integer> aMapUnion; | |
1363 | aMapUnion.Union (aMapLeft, aMapRight); | |
1364 | QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1); | |
1365 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter) | |
1366 | { | |
1367 | QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True); | |
1368 | } | |
1369 | ||
1370 | // validate Intersection operation | |
1371 | NCollection_Map<Standard_Integer> aMapSect; | |
1372 | aMapSect.Intersection (aMapLeft, aMapRight); | |
1373 | QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1); | |
1374 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1375 | { | |
1376 | QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True); | |
1377 | } | |
1378 | QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True); | |
1379 | QCOMPARE (aMapRight.Contains (aMapSect), Standard_True); | |
1380 | ||
1381 | // validate Substruction operation | |
1382 | NCollection_Map<Standard_Integer> aMapSubsLR; | |
1383 | aMapSubsLR.Subtraction (aMapLeft, aMapRight); | |
1384 | QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower); | |
1385 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter) | |
1386 | { | |
1387 | QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True); | |
1388 | } | |
1389 | ||
1390 | NCollection_Map<Standard_Integer> aMapSubsRL; | |
1391 | aMapSubsRL.Subtraction (aMapRight, aMapLeft); | |
1392 | QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper); | |
1393 | for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter) | |
1394 | { | |
1395 | QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True); | |
1396 | } | |
1397 | ||
1398 | // validate Difference operation | |
1399 | NCollection_Map<Standard_Integer> aMapDiff; | |
1400 | aMapDiff.Difference (aMapLeft, aMapRight); | |
1401 | QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper); | |
1402 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter) | |
1403 | { | |
1404 | QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True); | |
1405 | } | |
1406 | for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter) | |
1407 | { | |
1408 | QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True); | |
1409 | } | |
1410 | ||
1411 | // validate Exchange operation | |
1412 | NCollection_Map<Standard_Integer> aMapSwap; | |
1413 | aMapSwap.Exchange (aMapSect); | |
1414 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1415 | { | |
1416 | QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True); | |
1417 | } | |
1418 | QCOMPARE (aMapSect.IsEmpty(), Standard_True); | |
1419 | aMapSwap.Add (34); | |
1420 | aMapSect.Add (43); | |
1421 | ||
1422 | NCollection_Map<Standard_Integer> aMapCopy (aMapSwap); | |
1423 | QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True); | |
1424 | aMapCopy.Remove (34); | |
1425 | aMapCopy.Add (43); | |
1426 | QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False); | |
1427 | ||
1428 | return 0; | |
1429 | } | |
1430 | ||
1cd84fee | 1431 | void QABugs::Commands_19(Draw_Interpretor& theCommands) { |
1365140b | 1432 | const char *group = "QABugs"; |
7fd59977 | 1433 | |
1434 | theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group); | |
1435 | theCommands.Add ("OCC142", "OCC142", __FILE__, OCC142, group); | |
f6f03db9 | 1436 | theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group); |
1365140b RL |
1437 | theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group); |
1438 | theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group); | |
e6aad0ee | 1439 | theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group); |
5d1833ef | 1440 | theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group); |
e187cc0a | 1441 | theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group); |
bead40f2 | 1442 | theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group); |
06be28a4 | 1443 | theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group); |
1ef32e96 RL |
1444 | theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group); |
1445 | theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group); | |
1939140c | 1446 | theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group); |
470ebb43 | 1447 | 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 | 1448 | theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group); |
4bee43a9 | 1449 | theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group); |
29cb310a | 1450 | theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group); |
788cbaf4 | 1451 | theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group); |
89d8607f | 1452 | theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group); |
ab2db9a5 | 1453 | theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group); |
7fd59977 | 1454 | return; |
1455 | } |