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