Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2002-05-21 |
2 | // Created by: QA Admin | |
973c2be1 | 3 | // Copyright (c) 2002-2014 OPEN CASCADE SAS |
b311480e | 4 | // |
973c2be1 | 5 | // This file is part of Open CASCADE Technology software library. |
b311480e | 6 | // |
d5f74e42 | 7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
11 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 12 | // |
973c2be1 | 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. | |
b311480e | 15 | |
1cd84fee | 16 | #include <QABugs.hxx> |
7fd59977 | 17 | |
18 | #include <Draw_Interpretor.hxx> | |
19 | #include <DBRep.hxx> | |
20 | #include <DrawTrSurf.hxx> | |
7fd59977 | 21 | #include <ViewerTest.hxx> |
4a350f94 | 22 | #include <V3d_View.hxx> |
7fd59977 | 23 | #include <TopoDS_Shape.hxx> |
f376ac72 | 24 | #include <AIS_InteractiveContext.hxx> |
c070aa39 | 25 | #include <AIS_LocalContext.hxx> |
f376ac72 | 26 | #include <AIS_TexturedShape.hxx> |
27 | #include <Image_PixMap.hxx> | |
28 | #include <Image_Color.hxx> | |
7fd59977 | 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 | ||
c2ae831c | 38 | #include <cstdio> |
39 | #include <cmath> | |
40 | #include <iostream> | |
c2ae831c | 41 | #include <OSD_Timer.hxx> |
c7b59798 | 42 | #include <OSD_Parallel.hxx> |
43 | #include <OSD_PerfMeter.hxx> | |
c2ae831c | 44 | #include <BRepPrimAPI_MakeBox.hxx> |
45 | #include <BRepPrimAPI_MakeSphere.hxx> | |
46 | #include <BRepAlgo_Cut.hxx> | |
ab2db9a5 | 47 | #include <NCollection_Map.hxx> |
dda67c1c | 48 | #include <NCollection_Handle.hxx> |
d09dda09 | 49 | #include <NCollection_IncAllocator.hxx> |
29cb310a | 50 | #include <TCollection_HAsciiString.hxx> |
2cd138b8 | 51 | #include <GeomFill_Trihedron.hxx> |
52 | #include <BRepOffsetAPI_MakePipe.hxx> | |
fff263bd | 53 | #include <TopExp_Explorer.hxx> |
29cb310a | 54 | |
badc9305 | 55 | #include <SelectMgr_Filter.hxx> |
56 | ||
05d7de53 | 57 | #include <Standard_Version.hxx> |
58 | ||
29cb310a | 59 | #define QCOMPARE(val1, val2) \ |
60 | di << "Checking " #val1 " == " #val2 << \ | |
61 | ((val1) == (val2) ? ": OK\n" : ": Error\n") | |
d2786814 | 62 | |
7fd59977 | 63 | static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
64 | { | |
65 | if ( argc != 4) { | |
586db386 | 66 | di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d\n"; |
7fd59977 | 67 | return 1; |
68 | } | |
69 | ||
70 | gp_Pnt2d P1, P2; | |
71 | if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) { | |
586db386 | 72 | di << "ERROR OCC230: " << argv[2] << " is not Pnt2d\n"; |
7fd59977 | 73 | return 1; |
74 | } | |
75 | if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) { | |
586db386 | 76 | di << "ERROR OCC230: " << argv[3] << " is not Pnt2d\n"; |
7fd59977 | 77 | return 1; |
78 | } | |
79 | ||
80 | GCE2d_MakeSegment MakeSegment(P1,P2); | |
81 | Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value(); | |
82 | DrawTrSurf::Set(argv[1], TrimmedCurve); | |
83 | return 0; | |
84 | } | |
85 | ||
f6f03db9 | 86 | static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
87 | { | |
88 | gp_Pnt p(0, 0, 2); | |
89 | ||
90 | gp_Trsf t1, t2; | |
91 | t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267); | |
92 | t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880); | |
93 | ||
94 | gp_Trsf tComp = t2 * t1; | |
95 | ||
96 | gp_Pnt p1(10, 3, 4); | |
97 | gp_Pnt p2 = p1.Transformed(tComp); | |
98 | gp_Pnt p3 = p1.Transformed(t1); | |
99 | p3.Transform(t2); | |
100 | ||
101 | // points must be equal | |
102 | if ( ! p2.IsEqual(p3, Precision::Confusion()) ) | |
586db386 | 103 | di << "ERROR OCC23361: equivalent transformations does not produce equal points\n"; |
f6f03db9 | 104 | else |
586db386 | 105 | di << "OCC23361: OK\n"; |
f6f03db9 | 106 | |
107 | return 0; | |
108 | } | |
109 | ||
c2ae831c | 110 | static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/) |
111 | { | |
112 | OSD_PerfMeter aPM("TestMeter",0); | |
113 | OSD_Timer aTM; | |
114 | ||
115 | // run some operation in cycle for about 2 seconds to have good values of times to compare | |
116 | int count = 0; | |
117 | printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n"); | |
118 | for (; aTM.ElapsedTime() < 2.; count++) | |
119 | { | |
120 | aPM.Start(); | |
121 | aTM.Start(); | |
122 | ||
b3a7aa39 | 123 | // do some operation that will take considerable time compared with time of starting / stopping timers |
c2ae831c | 124 | BRepPrimAPI_MakeBox aBox (10., 10., 10.); |
125 | BRepPrimAPI_MakeSphere aSphere (10.); | |
b3a7aa39 | 126 | BRepAlgo_Cut aCutter (aBox.Shape(), aSphere.Shape()); |
c2ae831c | 127 | |
128 | aTM.Stop(); | |
129 | aPM.Stop(); | |
130 | } | |
131 | ||
132 | int aNbEnters = 0; | |
3510db62 | 133 | Standard_Real aPerfMeter_CPUtime = 0., aTimer_CPUTime = 0., aS; |
134 | Standard_Integer aM, aH; | |
135 | aTM.Show(aS, aM, aH, aTimer_CPUTime); | |
c2ae831c | 136 | |
137 | perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime); | |
3510db62 | 138 | perf_init_meter("TestMeter"); |
c2ae831c | 139 | |
3510db62 | 140 | Standard_Real aTimeDiff = (fabs(aTimer_CPUTime - aPerfMeter_CPUtime) / aTimer_CPUTime); |
c2ae831c | 141 | |
142 | printf("\nMeasurement results (%d cycles):\n", count); | |
3510db62 | 143 | printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer CPU time: %lf\n", |
144 | aPerfMeter_CPUtime, aTimer_CPUTime); | |
c2ae831c | 145 | printf("Time delta is: %.3lf %%\n", aTimeDiff * 100); |
146 | ||
147 | if (aTimeDiff > 0.2) | |
148 | di << "OCC23237: Error: too much difference between CPU and elapsed times"; | |
149 | else if (aNbEnters != count) | |
150 | di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles"; | |
151 | else | |
152 | di << "OCC23237: OK"; | |
153 | ||
154 | return 0; | |
155 | } | |
156 | ||
1365140b RL |
157 | class IncrementerDecrementer |
158 | { | |
159 | public: | |
160 | IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive) | |
161 | {} | |
c7b59798 | 162 | void operator() (const size_t) const |
1365140b | 163 | { |
c7b59798 | 164 | if ( myPositive ) |
165 | Standard_Atomic_Increment(myVal); | |
166 | else | |
167 | Standard_Atomic_Decrement(myVal); | |
1365140b RL |
168 | } |
169 | private: | |
170 | Standard_Integer* myVal; | |
c7b59798 | 171 | Standard_Boolean myPositive; |
1365140b | 172 | }; |
1365140b | 173 | |
1365140b RL |
174 | static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
175 | { | |
176 | int aSum = 0; | |
177 | ||
178 | //check returned value | |
179 | QCOMPARE (Standard_Atomic_Decrement (&aSum), -1); | |
180 | QCOMPARE (Standard_Atomic_Increment (&aSum), 0); | |
181 | QCOMPARE (Standard_Atomic_Increment (&aSum), 1); | |
182 | QCOMPARE (Standard_Atomic_Increment (&aSum), 2); | |
183 | // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0); | |
184 | // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1); | |
185 | ||
186 | //check atomicity | |
187 | aSum = 0; | |
188 | const int N = 1 << 24; //big enough to ensure concurrency | |
189 | ||
190 | //increment | |
c7b59798 | 191 | OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, true)); |
1365140b RL |
192 | QCOMPARE (aSum, N); |
193 | ||
194 | //decrement | |
c7b59798 | 195 | OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, false)); |
1365140b RL |
196 | QCOMPARE (aSum, 0); |
197 | ||
198 | return 0; | |
199 | } | |
200 | ||
e6aad0ee RL |
201 | #include <TDocStd_Application.hxx> |
202 | #include <XCAFApp_Application.hxx> | |
203 | #include <TDocStd_Document.hxx> | |
204 | #include <XCAFDoc_ShapeTool.hxx> | |
205 | #include <XCAFDoc_DocumentTool.hxx> | |
206 | #include <TDF_Label.hxx> | |
207 | #include <TDataStd_Name.hxx> | |
208 | ||
773f53f1 | 209 | static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/) |
e6aad0ee | 210 | { |
5b111128 | 211 | Handle(TDocStd_Application) anApp = XCAFApp_Application::GetApplication(); |
e6aad0ee RL |
212 | Handle(TDocStd_Document) aDoc; |
213 | anApp->NewDocument ("XmlXCAF", aDoc); | |
214 | QCOMPARE (!aDoc.IsNull(), Standard_True); | |
215 | ||
216 | Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main()); | |
217 | ||
218 | //check default value | |
219 | Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming(); | |
220 | QCOMPARE (aValue, Standard_True); | |
221 | ||
222 | //true | |
223 | XCAFDoc_ShapeTool::SetAutoNaming (Standard_True); | |
224 | TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape(); | |
225 | TDF_Label aLabel = aShTool->AddShape (aShape); | |
226 | Handle(TDataStd_Name) anAttr; | |
227 | QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True); | |
228 | ||
229 | //false | |
230 | XCAFDoc_ShapeTool::SetAutoNaming (Standard_False); | |
231 | aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape(); | |
232 | aLabel = aShTool->AddShape (aShape); | |
233 | QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True); | |
234 | ||
235 | //restore | |
236 | XCAFDoc_ShapeTool::SetAutoNaming (aValue); | |
237 | ||
238 | return 0; | |
239 | } | |
240 | ||
5d1833ef | 241 | #include <ExprIntrp_GenExp.hxx> |
242 | Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
243 | { | |
244 | ||
245 | if (argc != 3) { | |
246 | di << "Usage : " << argv[0] << " string nb\n"; | |
247 | return 1; | |
248 | } | |
249 | ||
250 | TCollection_AsciiString aToken = argv[1]; | |
251 | Standard_Integer aNb = atoi(argv[2]); | |
252 | ||
253 | Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create(); | |
254 | for (Standard_Integer i=0; i < aNb; i++) | |
255 | { | |
256 | aGen->Process(aToken); | |
257 | Handle(Expr_GeneralExpression) aExpr = aGen->Expression(); | |
258 | } | |
259 | ||
260 | return 0; | |
261 | } | |
262 | ||
35e08fe8 | 263 | Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
e187cc0a | 264 | { |
265 | gp_Mat M0; | |
266 | di << "M0 = " | |
267 | << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}" | |
268 | << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}" | |
269 | << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"; | |
270 | return 0; | |
271 | } | |
272 | ||
bead40f2 | 273 | #include <TopoDS_Face.hxx> |
274 | #include <TopoDS_Face.hxx> | |
275 | #include <TopoDS.hxx> | |
276 | #include <BRepBuilderAPI_Transform.hxx> | |
277 | #include <BRepExtrema_DistShapeShape.hxx> | |
278 | #include <BRepTools.hxx> | |
279 | ||
f24125b9 | 280 | static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di) |
bead40f2 | 281 | { |
282 | BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN); | |
283 | if(!distShapeShape.IsDone()) { | |
284 | di <<"Distance ShapeShape is Not Done\n"; | |
285 | return Standard_False; | |
286 | } | |
287 | ||
288 | if(distShapeShape.Value() > 0.01) { | |
289 | di << "Wrong Dist = " <<distShapeShape.Value() << "\n"; | |
290 | return Standard_False; | |
291 | } else | |
292 | di << "Dist0 = " <<distShapeShape.Value() <<"\n"; | |
293 | ||
294 | ////////////////////////////////////////////////////////////////////////// | |
295 | /// First Flip Y | |
296 | const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970); | |
297 | const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970); | |
298 | ||
299 | gp_Vec2d mirrorVector1(axis1P1,axis1P2); | |
300 | ||
301 | gp_Trsf2d mirror1; | |
302 | mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1)); | |
303 | ||
304 | BRepBuilderAPI_Transform transformer1(mirror1); | |
305 | transformer1.Perform(originalWire); | |
306 | if(!transformer1.IsDone()) { | |
586db386 | 307 | di << "Not Done1 \n"; |
bead40f2 | 308 | return Standard_False; |
309 | } | |
346cf025 | 310 | TopoDS_Shape step1ModifiedShape = transformer1.ModifiedShape(originalWire); |
bead40f2 | 311 | |
312 | BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN); | |
313 | if(!distShapeShape1.IsDone()) | |
314 | return Standard_False; | |
315 | if(distShapeShape1.Value() > 0.01) { | |
316 | di << "Dist = " <<distShapeShape1.Value() <<"\n"; | |
317 | return Standard_False; | |
318 | } else | |
319 | di << "Dist1 = " <<distShapeShape1.Value() <<"\n"; | |
320 | ||
321 | ////////////////////////////////////////////////////////////////////////// | |
322 | /// Second flip Y | |
323 | transformer1.Perform(step1ModifiedShape); | |
324 | if(!transformer1.IsDone()) { | |
325 | di << "Not Done1 \n"; | |
326 | return Standard_False; | |
327 | } | |
346cf025 | 328 | TopoDS_Shape step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape); |
bead40f2 | 329 | |
330 | //This is identity matrix for values but for type is gp_Rotation ?! | |
331 | gp_Trsf2d mirror11 = mirror1; | |
332 | mirror11.PreMultiply(mirror1); | |
333 | ||
334 | BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN); | |
335 | if(!distShapeShape2.IsDone()) | |
336 | return Standard_False; | |
337 | ||
338 | //This last test case give error (the value is 1008.8822038689706) | |
339 | if(distShapeShape2.Value() > 0.01) { | |
340 | di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n"; | |
341 | Standard_Integer N = distShapeShape2.NbSolution(); | |
342 | di << "Nb = " <<N <<"\n"; | |
343 | for (Standard_Integer i=1;i <= N;i++) | |
344 | di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n"; | |
345 | return Standard_False; | |
346 | } | |
347 | di << "Distance2 = " <<distShapeShape2.Value() <<"\n"; | |
348 | ||
349 | return Standard_True; | |
350 | } | |
351 | static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a) | |
352 | { | |
353 | ||
354 | if (n != 3) { | |
355 | di <<"OCC23774: invalid number of input parameters\n"; | |
356 | return 1; | |
357 | } | |
358 | ||
359 | const char *ns1 = (a[1]), *ns2 = (a[2]); | |
360 | TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2)); | |
361 | if (S1.IsNull() || S2.IsNull()) { | |
362 | di <<"OCC23774: Null input shapes\n"; | |
363 | return 1; | |
364 | } | |
365 | const TopoDS_Face& aFace = TopoDS::Face(S1); | |
366 | if(!OCC23774Test(aFace, S2, di)) | |
367 | di << "Something is wrong\n"; | |
368 | ||
369 | return 0; | |
370 | } | |
371 | ||
1ef32e96 RL |
372 | #include <GeomConvert_ApproxSurface.hxx> |
373 | #include <Geom_BSplineSurface.hxx> | |
374 | #include <Draw.hxx> | |
375 | #include <OSD_Thread.hxx> | |
1ef32e96 | 376 | |
7a5f1202 | 377 | struct GeomConvertTest_Data |
378 | { | |
379 | Standard_Integer nbupoles; | |
380 | Handle(Geom_Surface) surf; | |
1ef32e96 RL |
381 | }; |
382 | ||
7a5f1202 | 383 | static Standard_Address GeomConvertTest (Standard_Address data) |
1ef32e96 | 384 | { |
7a5f1202 | 385 | GeomConvertTest_Data* info = (GeomConvertTest_Data*)data; |
386 | ||
387 | GeomConvert_ApproxSurface aGAS (info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1); | |
388 | if (!aGAS.IsDone()) { | |
389 | cout << "Error: ApproxSurface is not done!" << endl; | |
caaeed1b | 390 | return 0; |
7a5f1202 | 391 | } |
392 | const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface(); | |
393 | if (aBSurf.IsNull()) { | |
394 | cout << "Error: BSplineSurface is not created!" << endl; | |
caaeed1b | 395 | return 0; |
7a5f1202 | 396 | } |
397 | cout << "Number of UPoles:" << aBSurf->NbUPoles(); | |
398 | if (aBSurf->NbUPoles() == info->nbupoles) | |
399 | { | |
400 | cout << ": OK" << endl; | |
401 | return data; // any non-null pointer | |
402 | } | |
403 | else | |
404 | { | |
405 | cout << ": Error, must be " << info->nbupoles << endl; | |
406 | return 0; | |
407 | } | |
1ef32e96 RL |
408 | } |
409 | ||
410 | static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
411 | { | |
7a5f1202 | 412 | if (argc != 3) { |
413 | cout << "Error: invalid number of arguments" << endl; | |
414 | return 1; | |
415 | } | |
416 | ||
417 | struct GeomConvertTest_Data aStorage; | |
418 | aStorage.nbupoles = Draw::Atoi(argv[1]); | |
419 | aStorage.surf = DrawTrSurf::GetSurface(argv[2]); | |
420 | if (aStorage.surf.IsNull()) | |
421 | { | |
422 | cout << "Error: " << argv[2] << " is not a DRAW surface!" << endl; | |
423 | return 0; | |
424 | } | |
425 | ||
426 | // start conversion in several threads | |
427 | const int NBTHREADS = 100; | |
428 | OSD_Thread aThread[NBTHREADS]; | |
429 | for (int i=0; i < NBTHREADS; i++) | |
430 | { | |
431 | aThread[i].SetFunction (GeomConvertTest); | |
432 | if (!aThread[i].Run(&aStorage)) | |
433 | di << "Error: Cannot start thread << " << i << "\n"; | |
434 | } | |
435 | ||
436 | // check results | |
437 | for (int i=0; i < NBTHREADS; i++) | |
438 | { | |
439 | Standard_Address aResult = 0; | |
440 | if (!aThread[i].Wait(aResult)) | |
441 | di << "Error: Failed waiting for thread << " << i << "\n"; | |
442 | if (!aResult) | |
443 | di << "Error: wrong number of poles in thread " << i << "!\n"; | |
444 | } | |
445 | ||
446 | return 0; | |
1ef32e96 | 447 | } |
d2786814 | 448 | |
1ef32e96 | 449 | #include <GeomInt_IntSS.hxx> |
1ef32e96 | 450 | |
7a5f1202 | 451 | struct GeomIntSSTest_Data |
452 | { | |
453 | Standard_Integer nbsol; | |
454 | Handle(Geom_Surface) surf1, surf2; | |
1ef32e96 | 455 | }; |
7a5f1202 | 456 | |
457 | static Standard_Address GeomIntSSTest (Standard_Address data) | |
1ef32e96 | 458 | { |
7a5f1202 | 459 | GeomIntSSTest_Data* info = (GeomIntSSTest_Data*)data; |
460 | GeomInt_IntSS anInter; | |
461 | anInter.Perform (info->surf1, info->surf2, Precision::Confusion(), Standard_True); | |
462 | if (!anInter.IsDone()) { | |
463 | cout << "An intersection is not done!" << endl; | |
464 | return 0; | |
465 | } | |
466 | ||
467 | cout << "Number of Lines:" << anInter.NbLines(); | |
468 | if (anInter.NbLines() == info->nbsol) | |
469 | { | |
470 | cout << ": OK" << endl; | |
471 | return data; // any non-null pointer | |
472 | } | |
473 | else | |
474 | { | |
475 | cout << ": Error, must be " << info->nbsol << endl; | |
476 | return 0; | |
477 | } | |
1ef32e96 RL |
478 | } |
479 | ||
480 | static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
481 | { | |
7a5f1202 | 482 | if (argc != 4) { |
483 | cout << "Error: invalid number of arguments" << endl; | |
484 | return 1; | |
485 | } | |
486 | ||
487 | struct GeomIntSSTest_Data aStorage; | |
488 | aStorage.nbsol = Draw::Atoi(argv[1]); | |
489 | aStorage.surf1 = DrawTrSurf::GetSurface(argv[2]); | |
490 | aStorage.surf2 = DrawTrSurf::GetSurface(argv[3]); | |
491 | if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull()) | |
492 | { | |
493 | cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" << endl; | |
494 | return 0; | |
495 | } | |
496 | ||
497 | // start conversion in several threads | |
498 | const int NBTHREADS = 100; | |
499 | OSD_Thread aThread[NBTHREADS]; | |
500 | for (int i=0; i < NBTHREADS; i++) | |
501 | { | |
502 | aThread[i].SetFunction (GeomIntSSTest); | |
503 | if (!aThread[i].Run(&aStorage)) | |
504 | di << "Error: Cannot start thread << " << i << "\n"; | |
505 | } | |
506 | ||
507 | // check results | |
508 | for (int i=0; i < NBTHREADS; i++) | |
509 | { | |
510 | Standard_Address aResult = 0; | |
511 | if (!aThread[i].Wait(aResult)) | |
512 | di << "Error: Failed waiting for thread << " << i << "\n"; | |
513 | if (!aResult) | |
514 | di << "Error: wrong number of intersections in thread " << i << "!\n"; | |
515 | } | |
516 | ||
517 | return 0; | |
1ef32e96 RL |
518 | } |
519 | ||
520 | #include <Geom_SurfaceOfRevolution.hxx> | |
06be28a4 RL |
521 | static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) |
522 | { | |
523 | if (argc < 2) { | |
586db386 | 524 | di<<"Usage: " << argv[0] << " invalid number of arguments\n"; |
06be28a4 RL |
525 | return 1; |
526 | } | |
527 | ||
528 | Standard_Integer ucontinuity = 1; | |
529 | Standard_Integer vcontinuity = 1; | |
530 | Standard_Boolean iscnu = false; | |
531 | Standard_Boolean iscnv = false; | |
532 | ||
533 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]); | |
534 | ||
535 | QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu); | |
536 | QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv); | |
537 | ||
538 | return 0; | |
539 | } | |
540 | ||
1939140c | 541 | #include <gp_Ax1.hxx> |
542 | #include <gp_Ax22d.hxx> | |
543 | #include <Geom_Plane.hxx> | |
544 | #include <Geom2d_Circle.hxx> | |
545 | #include <Geom2d_TrimmedCurve.hxx> | |
546 | #include <BRepBuilderAPI_MakeEdge.hxx> | |
547 | #include <BRepPrimAPI_MakeRevol.hxx> | |
548 | #include <Geom2d_OffsetCurve.hxx> | |
549 | ||
550 | static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
551 | { | |
552 | // Check the command arguments | |
553 | if ( argc != 1 ) | |
554 | { | |
586db386 | 555 | di << "Error: " << argv[0] << " - invalid number of arguments\n"; |
1939140c | 556 | di << "Usage: type help " << argv[0] << "\n"; |
557 | return 1; // TCL_ERROR | |
558 | } | |
559 | ||
560 | gp_Ax1 RotoAx( gp::Origin(), gp::DZ() ); | |
561 | gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() ); | |
562 | Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() ); | |
563 | ||
586db386 | 564 | di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>\n"; |
565 | di << "-----------------------------------------------------------------------\n"; | |
1939140c | 566 | |
567 | Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0); | |
568 | Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0); | |
569 | TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane); | |
570 | ||
571 | DBRep::Set("e1", E1); | |
572 | ||
573 | BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx); | |
574 | TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() ); | |
575 | ||
576 | DBRep::Set("f1", F1); | |
577 | ||
586db386 | 578 | di << "Result: f1\n"; |
1939140c | 579 | |
586db386 | 580 | di << "<<<< Preparing sample surface of revolution based on offset curve >>>>\n"; |
581 | di << "-----------------------------------------------------------------------\n"; | |
1939140c | 582 | |
583 | Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5); | |
584 | TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane); | |
585 | ||
586 | DBRep::Set("e2", E2); | |
587 | ||
588 | BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx); | |
589 | TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() ); | |
590 | ||
591 | DBRep::Set("f2", F2); | |
592 | ||
586db386 | 593 | di << "Result: f2\n"; |
1939140c | 594 | |
595 | return 0; | |
596 | } | |
597 | ||
2e9fd4bc | 598 | #include <Geom_Curve.hxx> |
599 | #include <Geom_Surface.hxx> | |
600 | #include <Precision.hxx> | |
601 | #include <ShapeConstruct_ProjectCurveOnSurface.hxx> | |
602 | //======================================================================= | |
603 | //function : OCC24008 | |
604 | //purpose : | |
605 | //======================================================================= | |
606 | static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
607 | { | |
608 | if (argc != 3) { | |
586db386 | 609 | di << "Usage: " << argv[0] << " invalid number of arguments\n"; |
2e9fd4bc | 610 | return 1; |
611 | } | |
612 | Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]); | |
613 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]); | |
614 | if (aCurve.IsNull()) { | |
586db386 | 615 | di << "Curve was not read\n"; |
2e9fd4bc | 616 | return 1; |
617 | } | |
618 | if (aSurf.IsNull()) { | |
586db386 | 619 | di << "Surface was not read\n"; |
2e9fd4bc | 620 | return 1; |
621 | } | |
622 | ShapeConstruct_ProjectCurveOnSurface aProj; | |
623 | aProj.Init (aSurf, Precision::Confusion()); | |
624 | try { | |
625 | Handle(Geom2d_Curve) aPCurve; | |
626 | aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve); | |
627 | if (aPCurve.IsNull()) { | |
586db386 | 628 | di << "PCurve was not created\n"; |
2e9fd4bc | 629 | return 1; |
630 | } | |
631 | } catch (...) { | |
586db386 | 632 | di << "Exception was caught\n"; |
2e9fd4bc | 633 | } |
634 | return 0; | |
635 | } | |
636 | ||
470ebb43 | 637 | #include <GeomAdaptor_Surface.hxx> |
638 | #include <Draw.hxx> | |
639 | //======================================================================= | |
640 | //function : OCC23945 | |
641 | //purpose : | |
642 | //======================================================================= | |
643 | ||
35e08fe8 | 644 | static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a) |
470ebb43 | 645 | { |
646 | if (n < 5) return 1; | |
647 | ||
648 | Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]); | |
649 | if (aS.IsNull()) return 1; | |
650 | ||
651 | GeomAdaptor_Surface GS(aS); | |
652 | ||
653 | Standard_Real U = Draw::Atof(a[2]); | |
654 | Standard_Real V = Draw::Atof(a[3]); | |
655 | ||
656 | Standard_Boolean DrawPoint = ( n%3 == 2); | |
657 | if ( DrawPoint) n--; | |
658 | ||
659 | gp_Pnt P; | |
660 | if (n >= 13) { | |
661 | gp_Vec DU,DV; | |
662 | if (n >= 22) { | |
663 | gp_Vec D2U,D2V,D2UV; | |
664 | GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV); | |
665 | Draw::Set(a[13],D2U.X()); | |
666 | Draw::Set(a[14],D2U.Y()); | |
667 | Draw::Set(a[15],D2U.Z()); | |
668 | Draw::Set(a[16],D2V.X()); | |
669 | Draw::Set(a[17],D2V.Y()); | |
670 | Draw::Set(a[18],D2V.Z()); | |
671 | Draw::Set(a[19],D2UV.X()); | |
672 | Draw::Set(a[20],D2UV.Y()); | |
673 | Draw::Set(a[21],D2UV.Z()); | |
674 | } | |
675 | else | |
676 | GS.D1(U,V,P,DU,DV); | |
677 | ||
678 | Draw::Set(a[7],DU.X()); | |
679 | Draw::Set(a[8],DU.Y()); | |
680 | Draw::Set(a[9],DU.Z()); | |
681 | Draw::Set(a[10],DV.X()); | |
682 | Draw::Set(a[11],DV.Y()); | |
683 | Draw::Set(a[12],DV.Z()); | |
684 | } | |
685 | else | |
686 | GS.D0(U,V,P); | |
687 | ||
688 | if ( n > 6) { | |
689 | Draw::Set(a[4],P.X()); | |
690 | Draw::Set(a[5],P.Y()); | |
691 | Draw::Set(a[6],P.Z()); | |
692 | } | |
693 | if ( DrawPoint) { | |
694 | DrawTrSurf::Set(a[n],P); | |
695 | } | |
696 | ||
697 | return 0; | |
698 | } | |
699 | ||
29cb310a | 700 | //======================================================================= |
701 | //function : OCC11758 | |
702 | //purpose : | |
703 | //======================================================================= | |
498ce76b | 704 | static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**) |
29cb310a | 705 | { |
706 | if (n != 1) return 1; | |
707 | ||
708 | const char* theStr = "0123456789"; | |
709 | Standard_Integer i, j; | |
710 | for ( i = 0; i < 5; ++i ) { | |
711 | // TCollection_AsciiString(const Standard_CString astring) | |
712 | TCollection_AsciiString a(theStr+i); | |
713 | // IsEqual (const Standard_CString other)const | |
714 | //assert( a == theStr+i ); | |
715 | QCOMPARE ( a , theStr+i ); | |
716 | ||
717 | //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen ) | |
718 | TCollection_AsciiString b(theStr+i, 3); | |
719 | //assert( b.Length() == 3 ); | |
720 | //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 ); | |
721 | //assert( strlen( b.ToCString() ) == 3 ); | |
722 | QCOMPARE ( b.Length() , 3 ); | |
723 | QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 ); | |
724 | QCOMPARE ( b.Length() , 3 ); | |
725 | ||
726 | //TCollection_AsciiString(const Standard_Integer aValue) | |
727 | TCollection_AsciiString c(i); | |
728 | //assert( c.IsIntegerValue() ); | |
729 | //assert( c.IntegerValue() == i ); | |
730 | QCOMPARE ( c.IsIntegerValue() , Standard_True ); | |
731 | QCOMPARE ( c.IntegerValue() , i ); | |
732 | ||
733 | //TCollection_AsciiString(const Standard_Real aValue) | |
734 | TCollection_AsciiString d( 0.1*i ); | |
735 | //assert( d.IsRealValue() ); | |
736 | //assert( TCollection_AsciiString(3.3) == "3.3"); | |
737 | QCOMPARE ( d.IsRealValue() , Standard_True ); | |
738 | QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" ); | |
739 | ||
740 | //TCollection_AsciiString(const TCollection_AsciiString& astring) | |
741 | TCollection_AsciiString e(d); | |
742 | //assert( e == d ); | |
743 | //assert( e.Length() == d.Length() ); | |
744 | //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 ); | |
745 | QCOMPARE ( e ,d ); | |
746 | QCOMPARE ( e.Length() , d.Length() ); | |
747 | QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 ); | |
748 | ||
749 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
750 | // const Standard_Character other ) | |
751 | TCollection_AsciiString f(e,'\a'); | |
752 | //assert( f.Length() == e.Length() + 1 ); | |
753 | //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 ); | |
754 | //assert( f.Value( f.Length() ) == '\a'); | |
755 | QCOMPARE ( f.Length() , e.Length() + 1 ); | |
756 | QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 ); | |
757 | QCOMPARE ( f.Value( f.Length() ) , '\a' ); | |
758 | ||
759 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
760 | // const Standard_CString other ) | |
761 | TCollection_AsciiString g(f, theStr); | |
762 | //assert( g.Length() == f.Length() + strlen( theStr )); | |
763 | //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 ); | |
764 | //assert( g.Search( theStr ) == f.Length() + 1 ); | |
765 | QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) ); | |
766 | QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 ); | |
767 | QCOMPARE ( g.Search( theStr ) , f.Length() + 1 ); | |
768 | ||
769 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
770 | // const TCollection_AsciiString& other ) | |
771 | TCollection_AsciiString h(d,a); | |
772 | //assert( h.Length() == d.Length() + a.Length() ); | |
773 | //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 ); | |
774 | //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 ); | |
775 | QCOMPARE ( h.Length() , d.Length() + a.Length() ); | |
776 | QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 ); | |
777 | QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 ); | |
778 | ||
779 | // AssignCat(const Standard_CString other) | |
780 | c.AssignCat( a.ToCString() ); | |
781 | //assert( c.Length() == 1 + a.Length() ); | |
782 | //assert( c.Search( a ) == 2 ); | |
783 | QCOMPARE ( c.Length() , 1 + a.Length() ); | |
784 | QCOMPARE ( c.Search( a ) , 2 ); | |
785 | ||
786 | // AssignCat(const TCollection_AsciiString& other) | |
787 | Standard_Integer dl = d.Length(); | |
788 | d.AssignCat( a ); | |
789 | //assert( d.Length() == dl + a.Length() ); | |
790 | //assert( d.Search( a ) == dl + 1 ); | |
791 | QCOMPARE ( d.Length() , dl + a.Length() ); | |
792 | QCOMPARE ( d.Search( a ) , dl + 1 ); | |
793 | ||
794 | // Capitalize() | |
795 | TCollection_AsciiString capitalize("aBC"); | |
796 | capitalize.Capitalize(); | |
797 | //assert( capitalize == "Abc" ); | |
798 | QCOMPARE ( capitalize , "Abc" ); | |
799 | ||
800 | // Copy(const Standard_CString fromwhere) | |
801 | d = theStr+i; | |
802 | //assert( d == theStr+i ); | |
803 | QCOMPARE ( d , theStr+i ); | |
804 | ||
805 | // Copy(const TCollection_AsciiString& fromwhere) | |
806 | d = h; | |
807 | // IsEqual (const TCollection_AsciiString& other)const | |
808 | //assert( d == h ); | |
809 | QCOMPARE ( d , h ); | |
810 | ||
811 | // Insert(const Standard_Integer where, const Standard_CString what) | |
812 | dl = d.Length(); | |
813 | d.Insert( 2, theStr ); | |
814 | //assert( d.Length() == dl + strlen( theStr )); | |
815 | //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 ); | |
816 | QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) ); | |
817 | QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 ); | |
818 | ||
819 | //Insert(const Standard_Integer where,const Standard_Character what) | |
820 | d = theStr; | |
821 | d.Insert( i+1, 'i' ); | |
822 | //assert( d.Length() == strlen( theStr ) + 1 ); | |
823 | //assert( d.Value( i+1 ) == 'i'); | |
824 | //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 ); | |
825 | QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 ); | |
826 | QCOMPARE ( d.Value( i+1 ) , 'i' ); | |
827 | QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 ); | |
828 | ||
829 | //Insert(const Standard_Integer where,const TCollection_AsciiString& what) | |
830 | d = theStr; | |
831 | d.Insert( i+1, TCollection_AsciiString( "i" )); | |
832 | //assert( d.Length() == strlen( theStr ) + 1 ); | |
833 | //assert( d.Value( i+1 ) == 'i'); | |
834 | //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 ); | |
835 | QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 ); | |
836 | QCOMPARE ( d.Value( i+1 ) , 'i' ); | |
837 | QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 ); | |
838 | ||
839 | // IsDifferent (const Standard_CString other)const | |
840 | //assert( d.IsDifferent( theStr )); | |
841 | //assert( d.IsDifferent( "theStr" )); | |
842 | //assert( d.IsDifferent( "" )); | |
843 | //assert( !d.IsDifferent( d.ToCString() )); | |
844 | QCOMPARE ( d.IsDifferent( theStr ) , Standard_True ); | |
845 | QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True ); | |
846 | QCOMPARE ( d.IsDifferent( "" ) , Standard_True ); | |
847 | QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True ); | |
848 | ||
849 | // IsDifferent (const TCollection_AsciiString& other)const | |
850 | //assert( d.IsDifferent( TCollection_AsciiString() )); | |
851 | //assert( d.IsDifferent( a )); | |
852 | //assert( d.IsDifferent( h )); | |
853 | //assert( !d.IsDifferent( d )); | |
854 | QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True ); | |
855 | QCOMPARE ( d.IsDifferent( a ) , Standard_True ); | |
856 | QCOMPARE ( d.IsDifferent( h ) , Standard_True ); | |
857 | QCOMPARE ( !d.IsDifferent( d ) , Standard_True ); | |
858 | ||
859 | // IsLess (const Standard_CString other)const | |
860 | //assert( TCollection_AsciiString ("0"). IsLess("1")); | |
861 | //assert( TCollection_AsciiString ("0"). IsLess("00")); | |
862 | //assert( TCollection_AsciiString (""). IsLess("0")); | |
863 | //assert( !TCollection_AsciiString("1"). IsLess("0")); | |
864 | //assert( !TCollection_AsciiString("00").IsLess("0")); | |
865 | //assert( !TCollection_AsciiString("0"). IsLess("")); | |
866 | //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1)); | |
867 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True ); | |
868 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True ); | |
869 | QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True ); | |
870 | QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True ); | |
871 | QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True ); | |
872 | QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True ); | |
873 | QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True ); | |
874 | ||
875 | // IsLess (const TCollection_AsciiString& other)const | |
876 | //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" ))); | |
877 | //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00"))); | |
878 | //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" ))); | |
879 | //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" ))); | |
880 | //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" ))); | |
881 | //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" ))); | |
882 | //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1))); | |
883 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True ); | |
884 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True ); | |
885 | QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
886 | QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
887 | QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
888 | QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True ); | |
889 | QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True ); | |
890 | ||
891 | // IsGreater (const Standard_CString other)const | |
892 | //assert( !TCollection_AsciiString("0"). IsGreater("1")); | |
893 | //assert( !TCollection_AsciiString("0"). IsGreater("00")); | |
894 | //assert( !TCollection_AsciiString(""). IsGreater("0")); | |
895 | //assert( TCollection_AsciiString ("1"). IsGreater("0")); | |
896 | //assert( TCollection_AsciiString ("00").IsGreater("0")); | |
897 | //assert( TCollection_AsciiString ("0"). IsGreater("")); | |
898 | //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i)); | |
899 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True ); | |
900 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True ); | |
901 | QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True ); | |
902 | QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True ); | |
903 | QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True ); | |
904 | QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True ); | |
905 | QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True ); | |
906 | ||
907 | // IsGreater (const TCollection_AsciiString& other)const | |
908 | //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" ))); | |
909 | //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00"))); | |
910 | //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" ))); | |
911 | //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" ))); | |
912 | //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" ))); | |
913 | //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" ))); | |
914 | //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i))); | |
915 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True ); | |
916 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True ); | |
917 | QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
918 | QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
919 | QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
920 | QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True ); | |
921 | QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True ); | |
922 | ||
923 | // void Read(Standard_IStream& astream) | |
924 | std::istringstream is( theStr ); | |
925 | e.Read( is ); | |
926 | //assert( e == theStr ); | |
927 | QCOMPARE ( e , theStr ); | |
928 | ||
929 | // Standard_Integer SearchFromEnd (const Standard_CString what)const | |
930 | //assert( e.SearchFromEnd( theStr + i ) == i + 1 ); | |
931 | QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 ); | |
932 | ||
933 | // SetValue(const Standard_Integer where, const Standard_CString what) | |
934 | e.SetValue( i+1, "what"); | |
935 | //assert( e.Search( "what" ) == i+1 ); | |
936 | //assert( e.Length() == strlen( theStr )); | |
937 | QCOMPARE ( e.Search( "what" ) , i+1 ); | |
938 | QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) ); | |
939 | ||
940 | // TCollection_AsciiString Split (const Standard_Integer where) | |
941 | e = theStr; | |
942 | d = e.Split( i+1 ); | |
943 | //assert( d.Length() + e.Length() == strlen( theStr )); | |
944 | QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) ); | |
945 | ||
946 | // TCollection_AsciiString SubString (const Standard_Integer FromIndex, | |
947 | // const Standard_Integer ToIndex) const | |
948 | e = theStr; | |
949 | d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 ); | |
950 | //assert( d.Length() == 3 ); | |
951 | //assert( d.Value(1) == theStr[ i ]); | |
952 | QCOMPARE ( d.Length() , 3 ); | |
953 | QCOMPARE ( d.Value(1) , theStr[ i ] ); | |
954 | ||
955 | // TCollection_AsciiString Token (const Standard_CString separators, | |
956 | // const Standard_Integer whichone) const | |
957 | e = " "; | |
958 | for ( j = 0; j < i; ++j ) { | |
959 | e += TCollection_AsciiString( theStr[j] ) + " "; | |
960 | //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 )); | |
961 | QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) ); | |
962 | } | |
963 | } | |
964 | for ( i = 0; i < 5; ++i ) | |
965 | { | |
966 | // TCollection_ExtendedString (const Standard_CString astring, | |
967 | // const Standard_Boolean isMultiByte) | |
968 | const TCollection_ExtendedString a( theStr+i ); | |
969 | //assert( TCollection_AsciiString( a ) == theStr+i ); | |
970 | QCOMPARE ( TCollection_AsciiString( a ) , theStr+i ); | |
971 | ||
972 | //TCollection_ExtendedString (const Standard_ExtString astring) | |
973 | const TCollection_ExtendedString b( a.ToExtString() ); | |
974 | //assert( a == b ); | |
975 | QCOMPARE ( a , b ); | |
976 | ||
977 | // TCollection_ExtendedString (const Standard_Integer length, | |
978 | // const Standard_ExtCharacter filler ) | |
979 | const TCollection_ExtendedString c( i, 1 ); | |
980 | //assert( c.Length() == i ); | |
981 | QCOMPARE ( c.Length() , i ); | |
982 | if ( c.Length() > 0 ) { | |
983 | //assert( c.Value( i ) == 1 ); | |
984 | QCOMPARE ( c.Value( i ) , 1 ); | |
985 | } | |
986 | ||
987 | // TCollection_ExtendedString (const Standard_Integer aValue) | |
988 | TCollection_ExtendedString d( i ); | |
989 | const TCollection_AsciiString da( d ); | |
990 | //assert( da.IsIntegerValue() ); | |
991 | //assert( da.IntegerValue() == i ); | |
992 | QCOMPARE ( da.IsIntegerValue() , Standard_True ); | |
993 | QCOMPARE ( da.IntegerValue(), i ); | |
994 | ||
995 | // TCollection_ExtendedString (const Standard_Real aValue) | |
996 | const TCollection_ExtendedString e( 0.1 * i ); | |
997 | const TCollection_AsciiString ea( e ); | |
998 | //assert( ea.IsRealValue() ); | |
999 | //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 ); | |
1000 | QCOMPARE ( ea.IsRealValue() , Standard_True ); | |
1001 | QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True ); | |
1002 | ||
1003 | // TCollection_ExtendedString (const TCollection_ExtendedString& astring) | |
1004 | const TCollection_ExtendedString f(e); | |
1005 | //assert( f.Length() == e.Length()); | |
1006 | //assert( f == e ); | |
1007 | QCOMPARE ( f.Length() , e.Length() ); | |
1008 | QCOMPARE ( f , e ); | |
1009 | ||
1010 | // TCollection_ExtendedString (const TCollection_AsciiString& astring) | |
1011 | const TCollection_ExtendedString g( ea ); | |
1012 | //assert( g.Length() == ea.Length() ); | |
1013 | //assert( TCollection_AsciiString( g ) == ea ); | |
1014 | QCOMPARE ( g.Length() , ea.Length() ); | |
1015 | QCOMPARE ( TCollection_AsciiString( g ) , ea ); | |
1016 | ||
1017 | // AssignCat (const TCollection_ExtendedString& other) | |
1018 | const TCollection_ExtendedString sep(","); | |
1019 | d.AssignCat( sep ); | |
1020 | d.AssignCat( g ); | |
1021 | //assert( d.Length() == 2 + g.Length() ); | |
1022 | //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i )); | |
1023 | //assert( d.Token( sep.ToExtString(), 2 ) == g ); | |
1024 | QCOMPARE ( d.Length() , 2 + g.Length() ); | |
1025 | QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) ); | |
1026 | QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g ); | |
1027 | ||
1028 | // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const | |
1029 | const TCollection_ExtendedString cat = a.Cat( sep ); | |
1030 | //assert( cat.Length() == a.Length() + sep.Length() ); | |
1031 | //assert( cat.Search( a ) == 1 ); | |
1032 | //assert( cat.Search( sep ) == a.Length() + 1 ); | |
1033 | QCOMPARE ( cat.Length() , a.Length() + sep.Length() ); | |
1034 | QCOMPARE ( cat.Search( a ) , 1 ); | |
1035 | QCOMPARE ( cat.Search( sep ) , a.Length() + 1 ); | |
1036 | ||
1037 | // Copy (const TCollection_ExtendedString& fromwhere) | |
1038 | d = cat; | |
1039 | //assert( d.Length() == cat.Length() ); | |
1040 | //assert( d == cat ); | |
1041 | QCOMPARE ( d.Length() , cat.Length() ); | |
1042 | QCOMPARE ( d , cat ); | |
1043 | ||
1044 | // IsEqual (const Standard_ExtString other) const | |
1045 | //assert( d.IsEqual( d.ToExtString() )); | |
1046 | QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True ); | |
1047 | ||
1048 | // IsDifferent (const Standard_ExtString other ) const | |
1049 | //assert( d.IsDifferent( a.ToExtString() )); | |
1050 | QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True ); | |
1051 | ||
1052 | // IsDifferent (const TCollection_ExtendedString& other) const | |
1053 | //assert( d.IsDifferent( a )); | |
1054 | QCOMPARE ( d.IsDifferent( a ) , Standard_True ); | |
1055 | ||
1056 | // IsLess (const Standard_ExtString other) const | |
1057 | const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1); | |
1058 | //assert( l0. IsLess( l1.ToExtString() )); | |
1059 | //assert( l0. IsLess( l00.ToExtString() )); | |
1060 | //assert( l. IsLess( l0.ToExtString() )); | |
1061 | //assert( ! l1. IsLess( l0.ToExtString() )); | |
1062 | //assert( ! l00.IsLess( l0.ToExtString() )); | |
1063 | //assert( ! l0. IsLess( l.ToExtString() )); | |
1064 | //assert( ls.IsLess( ls1.ToExtString() )); | |
1065 | QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True ); | |
1066 | QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True ); | |
1067 | QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True ); | |
1068 | QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True ); | |
1069 | QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True ); | |
1070 | QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True ); | |
1071 | QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True ); | |
1072 | ||
1073 | // IsLess (const TCollection_ExtendedString& other) const | |
1074 | //assert( l0. IsLess( l1 )); | |
1075 | //assert( l0. IsLess( l00 )); | |
1076 | //assert( l. IsLess( l0 )); | |
1077 | //assert( ! l1. IsLess( l0 )); | |
1078 | //assert( ! l00.IsLess( l0 )); | |
1079 | //assert( ! l0. IsLess( l )); | |
1080 | //assert( ls.IsLess( ls1 )); | |
1081 | QCOMPARE ( l0. IsLess( l1 ) , Standard_True ); | |
1082 | QCOMPARE ( l0. IsLess( l00 ) , Standard_True ); | |
1083 | QCOMPARE ( l. IsLess( l0 ) , Standard_True ); | |
1084 | QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True ); | |
1085 | QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True ); | |
1086 | QCOMPARE ( ! l0. IsLess( l ) , Standard_True ); | |
1087 | QCOMPARE ( ls.IsLess( ls1 ) , Standard_True ); | |
1088 | ||
1089 | // IsGreater (const Standard_ExtString other) const | |
1090 | //assert( ! l0.IsGreater( l1.ToExtString() )); | |
1091 | //assert( ! l0.IsGreater( l00.ToExtString() )); | |
1092 | //assert( ! l. IsGreater( l0.ToExtString() )); | |
1093 | //assert( l1. IsGreater( l0.ToExtString() )); | |
1094 | //assert( l00.IsGreater( l0.ToExtString() )); | |
1095 | //assert( l0. IsGreater( l.ToExtString() )); | |
1096 | //assert( ls1.IsGreater( ls.ToExtString() )); | |
1097 | QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True ); | |
1098 | QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True ); | |
1099 | QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True ); | |
1100 | QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True ); | |
1101 | QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True ); | |
1102 | QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True ); | |
1103 | QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True ); | |
1104 | ||
1105 | // IsGreater (const TCollection_ExtendedString& other) const | |
1106 | //assert( ! l0.IsGreater( l1)); | |
1107 | //assert( ! l0.IsGreater( l00)); | |
1108 | //assert( ! l. IsGreater( l0)); | |
1109 | //assert( l1. IsGreater( l0)); | |
1110 | //assert( l00.IsGreater( l0)); | |
1111 | //assert( l0. IsGreater( l)); | |
1112 | //assert( ls1.IsGreater( ls)); | |
1113 | QCOMPARE ( ! l0.IsGreater( l1) , Standard_True ); | |
1114 | QCOMPARE ( ! l0.IsGreater( l00) , Standard_True ); | |
1115 | QCOMPARE ( ! l. IsGreater( l0) , Standard_True ); | |
1116 | QCOMPARE ( l1. IsGreater( l0) , Standard_True ); | |
1117 | QCOMPARE ( l00.IsGreater( l0) , Standard_True ); | |
1118 | QCOMPARE ( l0. IsGreater( l) , Standard_True ); | |
1119 | QCOMPARE ( ls1.IsGreater( ls) , Standard_True ); | |
1120 | ||
1121 | // ========================== | |
1122 | //TCollection_HAsciiString:: | |
1123 | // ========================== | |
1124 | ||
1125 | // IsDifferent(const Handle(TCollection_HAsciiString)& S) | |
1126 | Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i ); | |
1127 | Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 ); | |
1128 | //assert( ha1->IsDifferent( ha2 )); | |
1129 | //assert( !ha1->IsDifferent( ha1 )); | |
1130 | QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True ); | |
1131 | QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True ); | |
1132 | ||
1133 | // IsSameString (const Handle(TCollection_HAsciiString)& S) | |
1134 | //assert( !ha1->IsSameString( ha2 )); | |
1135 | //assert( ha1->IsSameString( ha1 )); | |
1136 | QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True ); | |
1137 | QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True ); | |
1138 | ||
1139 | // IsSameState (const Handle(TCollection_HAsciiString)& other) const | |
1140 | //assert( !ha1->IsSameState( ha2 )); | |
1141 | //assert( ha1->IsSameState( ha1 )); | |
1142 | QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True ); | |
1143 | QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True ); | |
1144 | ||
1145 | // IsSameString (const Handle(TCollection_HAsciiString)& S , | |
1146 | // const Standard_Boolean CaseSensitive) const | |
1147 | //assert( !ha1->IsSameString( ha2, true )); | |
1148 | //assert( ha1->IsSameString( ha1, true )); | |
1149 | //assert( !ha1->IsSameString( ha2, false )); | |
1150 | //assert( ha1->IsSameString( ha1, false )); | |
1151 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True ); | |
1152 | QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True ); | |
1153 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True ); | |
1154 | QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True ); | |
1155 | ||
1156 | ha1->SetValue( 1, "AbC0000000"); | |
1157 | ha2->SetValue( 1, "aBc0000000"); | |
1158 | //assert( !ha1->IsSameString( ha2, true )); | |
1159 | //assert( ha1->IsSameString( ha2, false )); | |
1160 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True ); | |
1161 | QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True ); | |
1162 | } | |
1163 | return 0; | |
1164 | } | |
1165 | ||
788cbaf4 | 1166 | #include <Geom_CylindricalSurface.hxx> |
1167 | #include <IntTools_FaceFace.hxx> | |
1168 | #include <IntTools_Curve.hxx> | |
1169 | #include <IntTools_PntOn2Faces.hxx> | |
1170 | ||
1171 | static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) | |
1172 | { | |
1173 | if(theNArg < 2) | |
1174 | { | |
1175 | theDI << "Wrong a number of arguments!\n"; | |
1176 | return 1; | |
1177 | } | |
1178 | ||
857ffd5e | 1179 | Handle(Geom_Plane) plane(new Geom_Plane( |
788cbaf4 | 1180 | gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678), |
1181 | gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000), | |
1182 | gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000)))); | |
1183 | Handle(Geom_CylindricalSurface) cylinder( | |
1184 | new Geom_CylindricalSurface( | |
1185 | gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465), | |
1186 | gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000), | |
1187 | gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)), | |
1188 | 19.712534607908712)); | |
1189 | ||
1190 | DrawTrSurf::Set("pln", plane); | |
1191 | theDI << "pln\n"; | |
1192 | DrawTrSurf::Set("cyl", cylinder); | |
1193 | theDI << "cyl\n"; | |
1194 | ||
1195 | BRep_Builder builder; | |
1196 | TopoDS_Face face1, face2; | |
1197 | builder.MakeFace(face1, plane, Precision::Confusion()); | |
1198 | builder.MakeFace(face2, cylinder, Precision::Confusion()); | |
1199 | IntTools_FaceFace anInters; | |
1200 | anInters.SetParameters(false, true, true, Precision::Confusion()); | |
1201 | anInters.Perform(face1, face2); | |
1202 | ||
1203 | if (!anInters.IsDone()) | |
1204 | { | |
586db386 | 1205 | theDI<<"No intersections found!\n"; |
788cbaf4 | 1206 | |
1207 | return 1; | |
1208 | } | |
1209 | ||
1210 | //Handle(Geom_Curve) aResult; | |
1211 | //gp_Pnt aPoint; | |
1212 | ||
1213 | const IntTools_SequenceOfCurves& aCvsX=anInters.Lines(); | |
1214 | const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points(); | |
1215 | ||
1216 | char buf[1024]; | |
1217 | Standard_Integer aNbCurves, aNbPoints; | |
1218 | ||
1219 | aNbCurves=aCvsX.Length(); | |
1220 | aNbPoints=aPntsX.Length(); | |
1221 | ||
1222 | if (aNbCurves >= 2) | |
1223 | { | |
1224 | for (Standard_Integer i=1; i<=aNbCurves; ++i) | |
1225 | { | |
1226 | Sprintf(buf, "%s_%d",theArgv[1],i); | |
1227 | theDI << buf << " "; | |
1228 | ||
1229 | const IntTools_Curve& aIC = aCvsX(i); | |
1230 | const Handle(Geom_Curve)& aC3D= aIC.Curve(); | |
1231 | DrawTrSurf::Set(buf,aC3D); | |
1232 | } | |
1233 | } | |
1234 | else if (aNbCurves == 1) | |
1235 | { | |
1236 | const IntTools_Curve& aIC = aCvsX(1); | |
1237 | const Handle(Geom_Curve)& aC3D= aIC.Curve(); | |
1238 | Sprintf(buf, "%s",theArgv[1]); | |
1239 | theDI << buf << " "; | |
1240 | DrawTrSurf::Set(buf,aC3D); | |
1241 | } | |
1242 | ||
1243 | for (Standard_Integer i = 1; i<=aNbPoints; ++i) | |
1244 | { | |
1245 | const IntTools_PntOn2Faces& aPi=aPntsX(i); | |
1246 | const gp_Pnt& aP=aPi.P1().Pnt(); | |
1247 | ||
1248 | Sprintf(buf,"%s_p_%d",theArgv[1],i); | |
1249 | theDI << buf << " "; | |
1250 | DrawTrSurf::Set(buf, aP); | |
1251 | } | |
1252 | ||
1253 | return 0; | |
1254 | } | |
1255 | ||
1b7602c8 | 1256 | #include <BRepAlgo_NormalProjection.hxx> |
1257 | static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1258 | { | |
1259 | if (argc != 3) { | |
1260 | di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)"; | |
1261 | return 1; | |
1262 | } | |
1263 | ||
1264 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
1265 | if(myAISContext.IsNull()) { | |
1266 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1267 | return 1; | |
1268 | } | |
1269 | ||
1270 | TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1])); | |
1271 | TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2])); | |
1272 | ||
1273 | BRepAlgo_NormalProjection anormpro(m_Face1); | |
1274 | anormpro.Add(m_Edge); | |
1275 | anormpro.SetDefaultParams(); | |
1276 | ||
1277 | //anormpro.Compute3d(); | |
1278 | //anormpro.SetLimit(); | |
1279 | ||
1280 | anormpro.Build(); | |
1281 | ||
1282 | if (anormpro.IsDone()) | |
1283 | { | |
1284 | TopoDS_Shape rshape = anormpro.Projection(); | |
1285 | Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape); | |
1286 | myAISContext->SetColor(myShape, Quantity_Color(Quantity_NOC_YELLOW)); | |
1287 | myAISContext->Display(myShape, Standard_True); | |
1288 | } | |
1289 | ||
1290 | return 0; | |
1291 | } | |
1292 | ||
69fd2d1b | 1293 | #include <BRepFeat_SplitShape.hxx> |
1294 | #include <ShapeAnalysis_ShapeContents.hxx> | |
1295 | #include <BRepAlgo.hxx> | |
1296 | static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1297 | { | |
1298 | if (argc != 3) { | |
1299 | di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)"; | |
1300 | return 1; | |
1301 | } | |
1302 | ||
1303 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
1304 | if(myAISContext.IsNull()) { | |
1305 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1306 | return 1; | |
1307 | } | |
1308 | ||
1309 | TopoDS_Shape result; | |
1310 | TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1])); | |
1311 | TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2])); | |
1312 | ||
1313 | BRepFeat_SplitShape asplit(face); | |
1314 | asplit.Add(wire, face); | |
1315 | asplit.Build(); | |
1316 | result = asplit.Shape(); | |
1317 | ShapeAnalysis_ShapeContents ana; | |
1318 | ana.Perform(result); | |
1319 | ana.NbFaces(); | |
1320 | ||
1321 | if (!(BRepAlgo::IsValid(result))) { | |
586db386 | 1322 | di << "Result was checked and it is INVALID\n"; |
69fd2d1b | 1323 | } else { |
586db386 | 1324 | di << "Result was checked and it is VALID\n"; |
69fd2d1b | 1325 | } |
1326 | ||
1327 | Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result); | |
1328 | myAISContext->Display(myShape, Standard_True); | |
1329 | ||
1330 | return 0; | |
1331 | } | |
1332 | ||
c764e804 | 1333 | #include <Geom_Circle.hxx> |
1334 | #include <GeomAdaptor_Curve.hxx> | |
1335 | #include <Extrema_ExtPC.hxx> | |
1336 | #include <gp_Cylinder.hxx> | |
1337 | #include <ElSLib.hxx> | |
1338 | static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1339 | { | |
1340 | if (argc != 1) { | |
586db386 | 1341 | di << "Usage: " << argv[0] << " invalid number of arguments\n"; |
c764e804 | 1342 | return 1; |
1343 | } | |
1344 | ||
1345 | gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 ); | |
1346 | gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() ); | |
1347 | Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 ); | |
1348 | GeomAdaptor_Curve aC3D( aCircle ); | |
1349 | ||
1350 | Extrema_ExtPC aExtPC( aP3D, aC3D ); | |
1351 | //Standard_Real aParam = (aExtPC.Point(1)).Parameter(); | |
1352 | gp_Pnt aProj = (aExtPC.Point(1)).Value(); | |
1353 | di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n"; | |
1354 | ||
1355 | // Result of deviation | |
1356 | gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() ); | |
1357 | gp_Cylinder aCylinder( aCylAxis, 1890. ); | |
1358 | ||
1359 | Standard_Real aU = 0., aV = 0.; | |
1360 | ElSLib::Parameters( aCylinder, aProj, aU, aV ); | |
1361 | di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n"; | |
1362 | ||
1363 | return 0; | |
1364 | } | |
1365 | ||
89d8607f | 1366 | #include <Extrema_FuncExtPS.hxx> |
1367 | #include <math_FunctionSetRoot.hxx> | |
1368 | #include <math_Vector.hxx> | |
1369 | #include <BRepBuilderAPI_MakeVertex.hxx> | |
1370 | static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) | |
1371 | { | |
1372 | Standard_Integer anArgIter = 1; | |
1373 | if (theNArg < 5) | |
1374 | { | |
586db386 | 1375 | theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]\n"; |
89d8607f | 1376 | return 1; |
1377 | } | |
1378 | ||
1379 | // get target shape | |
1380 | Standard_CString aFaceName = theArgv[anArgIter++]; | |
1381 | Standard_CString aVertName = theArgv[anArgIter++]; | |
1382 | const TopoDS_Shape aShapeF = DBRep::Get (aFaceName); | |
1383 | const TopoDS_Shape aShapeV = DBRep::Get (aVertName); | |
1384 | const Standard_Real aUFrom = Atof (theArgv[anArgIter++]); | |
1385 | const Standard_Real aVFrom = Atof (theArgv[anArgIter++]); | |
1386 | const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100; | |
1387 | if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE) | |
1388 | { | |
1389 | std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl; | |
1390 | return 1; | |
1391 | } | |
1392 | if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX) | |
1393 | { | |
1394 | std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl; | |
1395 | return 1; | |
1396 | } | |
1397 | const TopoDS_Face aFace = TopoDS::Face (aShapeF); | |
1398 | const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV); | |
1399 | GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace)); | |
1400 | ||
1401 | gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes; | |
1402 | ||
1403 | Extrema_FuncExtPS anExtFunc; | |
1404 | math_FunctionSetRoot aRoot (anExtFunc, aNbIts); | |
1405 | ||
1406 | math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2); | |
1407 | aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion(); | |
1408 | aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite(); | |
1409 | aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite(); | |
1410 | aFromUV(1) = aUFrom; aFromUV(2) = aVFrom; | |
1411 | ||
1412 | anExtFunc.Initialize (aSurf); | |
1413 | anExtFunc.SetPoint (aPnt); | |
1414 | aRoot.SetTolerance (aTolUV); | |
1415 | aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup); | |
1416 | if (!aRoot.IsDone()) | |
1417 | { | |
1418 | std::cerr << "No results!\n"; | |
1419 | return 1; | |
1420 | } | |
1421 | ||
1422 | theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n"; | |
1423 | ||
1424 | aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes); | |
1425 | DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes)); | |
1426 | return 0; | |
1427 | } | |
1428 | ||
ab2db9a5 | 1429 | //! Check boolean operations on NCollection_Map |
1430 | static Standard_Integer OCC24271 (Draw_Interpretor& di, | |
1431 | Standard_Integer /*theArgNb*/, | |
1432 | const char** /*theArgVec*/) | |
1433 | { | |
1434 | // input data | |
1435 | const Standard_Integer aLeftLower = 1; | |
1436 | const Standard_Integer aLeftUpper = 10; | |
1437 | const Standard_Integer aRightLower = 5; | |
1438 | const Standard_Integer aRightUpper = 15; | |
1439 | ||
1440 | // define arguments | |
1441 | NCollection_Map<Standard_Integer> aMapLeft; | |
1442 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1443 | { | |
1444 | aMapLeft.Add (aKeyIter); | |
1445 | } | |
1446 | ||
1447 | NCollection_Map<Standard_Integer> aMapRight; | |
1448 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter) | |
1449 | { | |
1450 | aMapRight.Add (aKeyIter); | |
1451 | } | |
1452 | ||
1453 | QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False); | |
1454 | QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False); | |
1455 | ||
1456 | // validate Union operation | |
1457 | NCollection_Map<Standard_Integer> aMapUnion; | |
1458 | aMapUnion.Union (aMapLeft, aMapRight); | |
1459 | QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1); | |
1460 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter) | |
1461 | { | |
1462 | QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True); | |
1463 | } | |
1464 | ||
1465 | // validate Intersection operation | |
1466 | NCollection_Map<Standard_Integer> aMapSect; | |
1467 | aMapSect.Intersection (aMapLeft, aMapRight); | |
1468 | QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1); | |
1469 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1470 | { | |
1471 | QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True); | |
1472 | } | |
1473 | QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True); | |
1474 | QCOMPARE (aMapRight.Contains (aMapSect), Standard_True); | |
1475 | ||
1476 | // validate Substruction operation | |
1477 | NCollection_Map<Standard_Integer> aMapSubsLR; | |
1478 | aMapSubsLR.Subtraction (aMapLeft, aMapRight); | |
1479 | QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower); | |
1480 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter) | |
1481 | { | |
1482 | QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True); | |
1483 | } | |
1484 | ||
1485 | NCollection_Map<Standard_Integer> aMapSubsRL; | |
1486 | aMapSubsRL.Subtraction (aMapRight, aMapLeft); | |
1487 | QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper); | |
1488 | for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter) | |
1489 | { | |
1490 | QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True); | |
1491 | } | |
1492 | ||
1493 | // validate Difference operation | |
1494 | NCollection_Map<Standard_Integer> aMapDiff; | |
1495 | aMapDiff.Difference (aMapLeft, aMapRight); | |
1496 | QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper); | |
1497 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter) | |
1498 | { | |
1499 | QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True); | |
1500 | } | |
1501 | for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter) | |
1502 | { | |
1503 | QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True); | |
1504 | } | |
1505 | ||
1506 | // validate Exchange operation | |
1507 | NCollection_Map<Standard_Integer> aMapSwap; | |
1508 | aMapSwap.Exchange (aMapSect); | |
1509 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1510 | { | |
1511 | QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True); | |
1512 | } | |
1513 | QCOMPARE (aMapSect.IsEmpty(), Standard_True); | |
1514 | aMapSwap.Add (34); | |
1515 | aMapSect.Add (43); | |
1516 | ||
1517 | NCollection_Map<Standard_Integer> aMapCopy (aMapSwap); | |
1518 | QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True); | |
1519 | aMapCopy.Remove (34); | |
1520 | aMapCopy.Add (43); | |
1521 | QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False); | |
1522 | ||
1523 | return 0; | |
1524 | } | |
1525 | ||
e6c9f595 | 1526 | #define QVERIFY(val1) \ |
1527 | di << "Checking " #val1 " == Standard_True" << \ | |
1528 | ((val1) == Standard_True ? ": OK\n" : ": Error\n") | |
1529 | ||
1530 | #include <GeomInt_IntSS.hxx> | |
1531 | #include <Geom_ConicalSurface.hxx> | |
1532 | #include <Standard_ErrorHandler.hxx> | |
1533 | //======================================================================= | |
1534 | //function : OCC23972 | |
1535 | //purpose : | |
1536 | //======================================================================= | |
1537 | static void DoGeomIntSSTest (const Handle(Geom_Surface)& theSurf1, | |
1538 | const Handle(Geom_Surface)& theSurf2, | |
1539 | const Standard_Integer theNbSol, | |
1540 | Draw_Interpretor& di) | |
1541 | { | |
1542 | try { | |
1543 | OCC_CATCH_SIGNALS | |
1544 | GeomInt_IntSS anInter; | |
1545 | anInter.Perform (theSurf1, theSurf2, Precision::Confusion(), Standard_True); | |
1546 | QVERIFY (anInter.IsDone()); | |
1547 | QCOMPARE (anInter.NbLines(), theNbSol); | |
1548 | } catch (...) { | |
1549 | QVERIFY (Standard_False); | |
1550 | } | |
1551 | } | |
1552 | ||
1553 | namespace { | |
1554 | static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc, | |
1555 | const gp_Dir& theDir, | |
1556 | const gp_Dir& theXDir, | |
1557 | const Standard_Real theRad, | |
1558 | const Standard_Real theSin, | |
1559 | const Standard_Real theCos) | |
1560 | { | |
1561 | const Standard_Real anA = atan (theSin / theCos); | |
1562 | gp_Ax3 anAxis (theLoc, theDir, theXDir); | |
1563 | Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad); | |
1564 | return aSurf; | |
1565 | } | |
1566 | } | |
1567 | ||
1568 | static Standard_Integer OCC23972 (Draw_Interpretor& di,Standard_Integer n, const char**) | |
1569 | { | |
1570 | if (n != 1) return 1; | |
1571 | ||
1572 | //process specific cones, cannot read them from files because due to rounding the original error | |
1573 | //in math_FunctionRoots gets hidden | |
1574 | Handle(Geom_Surface) aS1 = CreateCone ( | |
1575 | gp_Pnt (123.694345356663, 789.9, 68.15), | |
1576 | gp_Dir (-1, 3.48029791472957e-016, -8.41302743359754e-017), | |
1577 | gp_Dir (-3.48029791472957e-016, -1, -3.17572289932207e-016), | |
1578 | 3.28206830417112, | |
1579 | 0.780868809443031, | |
1580 | 0.624695047554424); | |
1581 | Handle(Geom_Surface) aS2 = CreateCone ( | |
1582 | gp_Pnt (123.694345356663, 784.9, 68.15), | |
1583 | gp_Dir (-1, -2.5209507537117e-016, -1.49772808948866e-016), | |
1584 | gp_Dir (1.49772808948866e-016, 3.17572289932207e-016, -1), | |
1585 | 3.28206830417112, | |
1586 | 0.780868809443031, | |
1587 | 0.624695047554424); | |
1588 | ||
1589 | DoGeomIntSSTest (aS1, aS2, 2, di); | |
1590 | ||
1591 | return 0; | |
1592 | } | |
1593 | ||
e3096dec | 1594 | #include <ShapeFix_EdgeProjAux.hxx> |
1595 | static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) | |
1596 | { | |
1597 | if (argc < 5) { | |
586db386 | 1598 | di<<"Usage: " << argv[0] << " invalid number of arguments\n"; |
e3096dec | 1599 | return 1; |
1600 | } | |
1601 | ||
1602 | TopoDS_Shape aSh = DBRep::Get(argv[1]); | |
1603 | if (aSh.IsNull()) { | |
1604 | di << argv[0] << " Error: Null input edge\n"; | |
1605 | return 1; | |
1606 | } | |
1607 | const TopoDS_Edge& anEdge = TopoDS::Edge (aSh); | |
1608 | ||
1609 | Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]); | |
1610 | if (aC.IsNull()) { | |
1611 | di << argv[0] << " Error: Null input curve\n"; | |
1612 | return 1; | |
1613 | } | |
1614 | ||
1615 | Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]); | |
1616 | if (aS.IsNull()) { | |
1617 | di << argv[0] << " Error: Null input surface\n"; | |
1618 | return 1; | |
1619 | } | |
1620 | ||
1621 | Standard_Real prec = Draw::Atof(argv[4]); | |
1622 | ||
1623 | //prepare data | |
1624 | TopoDS_Face aFace; | |
1625 | BRep_Builder aB; | |
1626 | aB.MakeFace (aFace, aS, Precision::Confusion()); | |
1627 | aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion()); | |
1628 | aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter()); | |
1629 | ||
1630 | //call algorithm | |
1631 | ShapeFix_EdgeProjAux aProj (aFace, anEdge); | |
1632 | aProj.Compute (prec); | |
1633 | ||
1634 | Standard_Boolean isfirstdone = aProj.IsFirstDone(); | |
1635 | Standard_Boolean islastdone = aProj.IsLastDone(); | |
1636 | ||
1637 | Standard_Real first = 0.; | |
1638 | Standard_Real last = 0.; | |
1639 | Standard_Integer isfirstdoneInteger = 0; | |
1640 | Standard_Integer islastdoneInteger = 0; | |
1641 | ||
1642 | ||
1643 | if (isfirstdone) { | |
1644 | first = aProj.FirstParam(); | |
1645 | isfirstdoneInteger = 1; | |
1646 | } | |
1647 | ||
1648 | if (islastdone) { | |
1649 | last= aProj.LastParam(); | |
1650 | islastdoneInteger = 1; | |
1651 | } | |
1652 | ||
1653 | di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n"; | |
1654 | ||
1655 | return 0; | |
1656 | } | |
1657 | ||
05d7de53 | 1658 | template<typename T, typename HT> |
1659 | static void DoIsNull(Draw_Interpretor& di) | |
1660 | { | |
1661 | HT aHandle; | |
1662 | // QVERIFY (aHandle.IsNull()); | |
1663 | QCOMPARE (aHandle.IsNull(), Standard_True); | |
c04c30b3 | 1664 | const T* p = aHandle.get(); |
05d7de53 | 1665 | #if OCC_VERSION_HEX > 0x060700 |
1666 | //QVERIFY (!p); | |
1667 | //QVERIFY (p == 0); | |
1668 | QCOMPARE (!p, Standard_True); | |
1669 | QCOMPARE (p == 0, Standard_True); | |
1670 | #endif | |
1671 | ||
1672 | aHandle = new T; | |
1673 | //QVERIFY (!aHandle.IsNull()); | |
1674 | QCOMPARE (!aHandle.IsNull(), Standard_True); | |
c04c30b3 | 1675 | p = aHandle.get(); |
05d7de53 | 1676 | //QVERIFY (p); |
1677 | //QVERIFY (p != 0); | |
1678 | QCOMPARE (p != NULL, Standard_True); | |
1679 | QCOMPARE (p != 0, Standard_True); | |
1680 | } | |
1681 | ||
1682 | //======================================================================= | |
1683 | //function : OCC24533 | |
1684 | //purpose : | |
1685 | //======================================================================= | |
1686 | static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**) | |
1687 | { | |
1688 | if (n != 1) return 1; | |
1689 | ||
857ffd5e | 1690 | DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di); |
05d7de53 | 1691 | |
1692 | return 0; | |
1693 | } | |
1694 | ||
dda67c1c | 1695 | // Dummy class to test interface for compilation issues |
1696 | class QABugs_HandleClass : public Standard_Transient | |
1697 | { | |
1698 | public: | |
1699 | Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec) | |
1700 | { | |
1701 | std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n"; | |
1702 | return 0; | |
1703 | } | |
92efcf78 | 1704 | DEFINE_STANDARD_RTTI_INLINE(QABugs_HandleClass,Standard_Transient) // Type definition |
dda67c1c | 1705 | }; |
1706 | DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient) | |
ec357c5c | 1707 | |
dda67c1c | 1708 | |
1709 | // Dummy class to test interface for compilation issues | |
1710 | struct QABugs_NHandleClass | |
1711 | { | |
1712 | Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec) | |
1713 | { | |
586db386 | 1714 | std::cerr << "QABugs_NHandleClass[" << this << "] " << theArgVec[0] << "\n"; |
dda67c1c | 1715 | return 0; |
1716 | } | |
1717 | }; | |
1718 | ||
574d7236 | 1719 | #include <XCAFDoc_ColorTool.hxx> |
1720 | #include <STEPControl_StepModelType.hxx> | |
1721 | #include <STEPCAFControl_Writer.hxx> | |
1722 | static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1723 | { | |
7a7e8cf1 | 1724 | if (argc != 2) { |
586db386 | 1725 | di << "Usage: " << argv[0] << " invalid number of arguments\n"; |
574d7236 | 1726 | return 1; |
1727 | } | |
1728 | Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");; | |
1729 | TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape(); | |
1730 | TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape(); | |
1731 | XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1); | |
1732 | TDataStd_Name::Set(lab1, "Box1"); | |
1733 | ||
1734 | Quantity_Color yellow(1,1,0, Quantity_TOC_RGB); | |
1735 | XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen); | |
1736 | XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0); | |
1737 | ||
1738 | STEPControl_StepModelType mode = STEPControl_AsIs; | |
1739 | STEPCAFControl_Writer writer; | |
1740 | if ( ! writer.Transfer (aDoc, mode ) ) | |
1741 | { | |
1742 | di << "The document cannot be translated or gives no result" << "\n"; | |
1743 | return 1; | |
1744 | } | |
1745 | ||
7a7e8cf1 | 1746 | writer.Write(argv[1]); |
574d7236 | 1747 | return 0; |
1748 | } | |
1749 | ||
1750 | ||
0c674248 | 1751 | //======================================================================= |
1752 | //function : OCC23950 | |
1753 | //purpose : | |
1754 | //======================================================================= | |
1755 | static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1756 | { | |
1fa7cb8c | 1757 | if (argc != 2) { |
1758 | di << "Usage : " << argv[0] << " step_file\n"; | |
0c674248 | 1759 | return 1; |
1760 | } | |
1761 | ||
1762 | Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy"); | |
1763 | TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0)); | |
1764 | gp_Trsf t0; | |
1765 | TopLoc_Location location0 (t0); | |
1766 | ||
1767 | TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape (); | |
1768 | XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6); | |
1769 | TDataStd_Name::Set(lab1, "Point1"); | |
1770 | ||
1771 | TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape (); | |
1772 | TDataStd_Name::Set(labelA0, "ASSEMBLY"); | |
1773 | ||
1774 | TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0); | |
1775 | ||
1776 | Quantity_Color yellow(1,1,0, Quantity_TOC_RGB); | |
1777 | XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen); | |
1778 | XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0); | |
1779 | ||
1780 | STEPControl_StepModelType mode = STEPControl_AsIs; | |
1781 | STEPCAFControl_Writer writer; | |
1782 | if (! writer.Transfer (aDoc, mode)) | |
1783 | { | |
586db386 | 1784 | di << "The document cannot be translated or gives no result\n"; |
0c674248 | 1785 | return 1; |
1786 | } | |
1787 | ||
1fa7cb8c | 1788 | writer.Write (argv[1]); |
0c674248 | 1789 | return 0; |
1790 | } | |
1791 | ||
f376ac72 | 1792 | //======================================================================= |
1793 | //function : OCC24622 | |
1794 | //purpose : The command tests sourcing Image_PixMap to AIS_TexturedShape | |
1795 | //======================================================================= | |
1796 | static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNb, const char** theArgVec) | |
1797 | { | |
1798 | if (theArgNb != 2) | |
1799 | { | |
1800 | std::cout << "Usage : " << theArgVec[0] << " texture={1D|2D}"; | |
1801 | return 1; | |
1802 | } | |
1803 | ||
1804 | const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext(); | |
1805 | if (anAISContext.IsNull()) | |
1806 | { | |
1807 | std::cout << "Please initialize view with \"vinit\".\n"; | |
1808 | return 1; | |
1809 | } | |
1810 | ||
1811 | Handle(Image_PixMap) anImage = new Image_PixMap(); | |
1812 | ||
b56dd33f | 1813 | static const Image_ColorRGB aBitmap[8] = |
1814 | { | |
1815 | {{255, 0, 0}}, {{0, 148, 255}}, {{ 0, 148, 255}}, {{255, 94, 0}}, | |
1816 | {{255, 121, 0}}, {{76, 255, 0}}, {{76, 255, 0}}, {{255, 202, 0}} | |
f376ac72 | 1817 | }; |
1818 | ||
1819 | TCollection_AsciiString aTextureTypeArg (theArgVec[1]); | |
1820 | aTextureTypeArg.UpperCase(); | |
1821 | if (aTextureTypeArg == "1D") | |
1822 | { | |
1823 | anImage->InitWrapper (Image_PixMap::ImgRGB, (Standard_Byte*)aBitmap, 8, 1); | |
1824 | } | |
1825 | else if (aTextureTypeArg == "2D") | |
1826 | { | |
1827 | anImage->InitTrash (Image_PixMap::ImgRGB, 8, 8); | |
f376ac72 | 1828 | for (Standard_Integer aRow = 0; aRow < 8; ++aRow) |
1829 | { | |
1830 | for (Standard_Integer aCol = 0; aCol < 8; ++aCol) | |
1831 | { | |
ca0c0b11 | 1832 | anImage->ChangeValue<Image_ColorRGB> (aRow, aCol) = aBitmap[aRow]; |
f376ac72 | 1833 | } |
1834 | } | |
1835 | } | |
1836 | else | |
1837 | { | |
1838 | std::cout << "Please specify type of texture to test {1D|2D}.\n"; | |
1839 | return 1; | |
1840 | } | |
1841 | ||
1842 | TopoDS_Shape aBlankShape = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape(); | |
1843 | ||
1844 | Handle(AIS_TexturedShape) aTexturedShape = new AIS_TexturedShape (aBlankShape); | |
1845 | aTexturedShape->SetTexturePixMap (anImage); | |
1846 | anAISContext->Display (aTexturedShape, 3, 0); | |
1847 | ||
1848 | return 0; | |
1849 | } | |
1850 | ||
2cd138b8 | 1851 | //======================================================================= |
1852 | //function : OCC24667 | |
1853 | //purpose : | |
1854 | //======================================================================= | |
1855 | static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
1856 | { | |
1857 | if (n == 1) | |
1858 | { | |
586db386 | 1859 | di << "OCC24667 result Wire_spine Profile [Mode [Approx]]\n"; |
1860 | di << "Mode = 0 - CorrectedFrenet,\n"; | |
1861 | di << " = 1 - Frenet,\n"; | |
1862 | di << " = 2 - DiscreteTrihedron\n"; | |
1863 | di << "Approx - force C1-approximation if result is C0\n"; | |
2cd138b8 | 1864 | return 0; |
1865 | } | |
1866 | ||
1867 | if (n > 1 && n < 4) return 1; | |
1868 | ||
1869 | TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE); | |
1870 | if ( Spine.IsNull()) return 1; | |
1871 | ||
1872 | TopoDS_Shape Profile = DBRep::Get(a[3]); | |
1873 | if ( Profile.IsNull()) return 1; | |
1874 | ||
1875 | GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet; | |
1876 | if (n >= 5) | |
1877 | { | |
1878 | Standard_Integer iMode = atoi(a[4]); | |
1879 | if (iMode == 1) | |
1880 | Mode = GeomFill_IsFrenet; | |
1881 | else if (iMode == 2) | |
1882 | Mode = GeomFill_IsDiscreteTrihedron; | |
1883 | } | |
1884 | ||
1885 | Standard_Boolean ForceApproxC1 = Standard_False; | |
1886 | if (n >= 6) | |
1887 | ForceApproxC1 = Standard_True; | |
1888 | ||
1889 | BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine), | |
1890 | Profile, | |
1891 | Mode, | |
1892 | ForceApproxC1); | |
1893 | ||
1894 | TopoDS_Shape S = aPipe.Shape(); | |
1895 | TopoDS_Shape aSF = aPipe.FirstShape(); | |
1896 | TopoDS_Shape aSL = aPipe.LastShape(); | |
1897 | ||
1898 | DBRep::Set(a[1],S); | |
1899 | ||
1900 | TCollection_AsciiString aStrF(a[1], "_f"); | |
1901 | TCollection_AsciiString aStrL(a[1], "_l"); | |
1902 | ||
1903 | DBRep::Set(aStrF.ToCString(), aSF); | |
1904 | DBRep::Set(aStrL.ToCString(), aSL); | |
1905 | ||
1906 | return 0; | |
1907 | } | |
1908 | ||
70167e69 RL |
1909 | #include <BRepPrimAPI_MakeCylinder.hxx> |
1910 | #include <BRepBuilderAPI_Copy.hxx> | |
1911 | #include <BRepTools_NurbsConvertModification.hxx> | |
1912 | static TopoDS_Shape CreateTestShape (int& theShapeNb) | |
1913 | { | |
1914 | TopoDS_Compound aComp; | |
1915 | BRep_Builder aBuilder; | |
1916 | aBuilder.MakeCompound (aComp); | |
1917 | //NURBS modifier is used to increase footprint of each shape | |
35c0599a | 1918 | Handle(BRepTools_NurbsConvertModification) aNurbsModif = new BRepTools_NurbsConvertModification; |
70167e69 RL |
1919 | TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid(); |
1920 | BRepTools_Modifier aModifier (aRefShape, aNurbsModif); | |
1921 | if (aModifier.IsDone()) { | |
1922 | aRefShape = aModifier.ModifiedShape (aRefShape); | |
1923 | } | |
1924 | int aSiblingNb = 0; | |
1925 | for (; theShapeNb > 0; --theShapeNb) { | |
1926 | TopoDS_Shape aShape; | |
1927 | if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists | |
1928 | aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape(); | |
1929 | } else { | |
1930 | aShape = CreateTestShape (theShapeNb); | |
1931 | } | |
1932 | aBuilder.Add (aComp, aShape); | |
1933 | } | |
1934 | return aComp; | |
1935 | } | |
1936 | ||
1937 | #include <AppStd_Application.hxx> | |
1938 | #include <TDataStd_Integer.hxx> | |
1939 | #include <TNaming_Builder.hxx> | |
1940 | static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1941 | { | |
7a7e8cf1 | 1942 | if (argc != 2) { |
586db386 | 1943 | di << "Usage: " << argv[0] << " invalid number of arguments\n"; |
70167e69 RL |
1944 | return 1; |
1945 | } | |
7a7e8cf1 | 1946 | TCollection_ExtendedString aFileName (argv[1]); |
70167e69 RL |
1947 | PCDM_StoreStatus aSStatus = PCDM_SS_Failure; |
1948 | ||
1949 | Handle(TDocStd_Application) anApp = new AppStd_Application; | |
1950 | { | |
1951 | Handle(TDocStd_Document) aDoc; | |
1952 | anApp->NewDocument ("XmlOcaf", aDoc); | |
1953 | TDF_Label aLab = aDoc->Main(); | |
1954 | TDataStd_Integer::Set (aLab, 0); | |
1955 | int n = 10000; //must be big enough | |
1956 | TopoDS_Shape aShape = CreateTestShape (n); | |
1957 | TNaming_Builder aBuilder (aLab); | |
1958 | aBuilder.Generated (aShape); | |
1959 | ||
1960 | aSStatus = anApp->SaveAs (aDoc, aFileName); | |
1961 | anApp->Close (aDoc); | |
1962 | } | |
1963 | QCOMPARE (aSStatus, PCDM_SS_OK); | |
1964 | return 0; | |
1965 | } | |
1966 | ||
d01cc61d | 1967 | #include <AppStdL_Application.hxx> |
1968 | #include <TDocStd_Application.hxx> | |
1969 | #include <TDataStd_Integer.hxx> | |
1970 | #include <TDF_AttributeIterator.hxx> | |
1971 | //======================================================================= | |
1972 | //function : OCC24755 | |
1973 | //purpose : | |
1974 | //======================================================================= | |
1975 | static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
1976 | { | |
1977 | if (n != 1) | |
1978 | { | |
1979 | std::cout << "Usage : " << a[0] << "\n"; | |
1980 | return 1; | |
1981 | } | |
1982 | ||
1983 | Handle(TDocStd_Application) anApp = new AppStdL_Application; | |
1984 | Handle(TDocStd_Document) aDoc; | |
fff263bd | 1985 | anApp->NewDocument ("BinOcaf", aDoc); |
d01cc61d | 1986 | TDF_Label aLab = aDoc->Main(); |
1987 | TDataStd_Integer::Set (aLab, 0); | |
1988 | TDataStd_Name::Set (aLab, "test"); | |
1989 | ||
1990 | TDF_AttributeIterator i (aLab); | |
1991 | Handle(TDF_Attribute) anAttr = i.Value(); | |
1992 | QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True); | |
1993 | i.Next(); | |
1994 | anAttr = i.Value(); | |
1995 | QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True); | |
1996 | ||
1997 | return 0; | |
1998 | } | |
1999 | ||
a73267f2 | 2000 | struct MyStubObject |
2001 | { | |
2002 | MyStubObject() : ptr(0L) {} | |
2003 | MyStubObject(void* thePtr) : ptr(thePtr) {} | |
2004 | char overhead[40]; | |
2005 | void* ptr; | |
2006 | }; | |
2007 | ||
2008 | //======================================================================= | |
2009 | //function : OCC24834 | |
2010 | //purpose : | |
2011 | //======================================================================= | |
2012 | static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
2013 | { | |
2014 | if (n != 1) | |
2015 | { | |
2016 | std::cout << "Usage : " << a[0] << "\n"; | |
2017 | return 1; | |
2018 | } | |
5a89733f | 2019 | |
2020 | int i = sizeof (char*); | |
2021 | if (i > 4) { | |
2d7b28ac | 2022 | std::cout << "64-bit architecture is not supported.\n"; |
2023 | return 0; | |
2024 | } | |
a73267f2 | 2025 | |
2026 | NCollection_List<MyStubObject> aList; | |
2027 | const Standard_Integer aSmallBlockSize = 40; | |
2028 | const Standard_Integer aLargeBlockSize = 1500000; | |
2029 | ||
2030 | // quick populate memory with large blocks | |
2031 | try | |
2032 | { | |
2033 | for (;;) | |
2034 | { | |
2035 | aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize))); | |
2036 | } | |
2037 | } | |
2038 | catch (Standard_Failure) | |
2039 | { | |
2040 | di << "caught out of memory for large blocks: OK\n"; | |
2041 | } | |
2042 | catch (...) | |
2043 | { | |
2044 | di << "skept out of memory for large blocks: Error\n"; | |
2045 | } | |
2046 | ||
2047 | // allocate small blocks | |
2048 | try | |
2049 | { | |
2050 | for (;;) | |
2051 | { | |
2052 | aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize))); | |
2053 | } | |
2054 | } | |
2055 | catch (Standard_Failure) | |
2056 | { | |
2057 | di << "caught out of memory for small blocks: OK\n"; | |
2058 | } | |
2059 | catch (...) | |
2060 | { | |
2061 | di << "skept out of memory for small blocks: Error\n"; | |
2062 | } | |
2063 | ||
2064 | // release all allocated blocks | |
2065 | for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next()) | |
2066 | { | |
2067 | Standard::Free(it.Value().ptr); | |
2068 | } | |
2069 | return 0; | |
2070 | } | |
2071 | ||
8696d65d | 2072 | |
2073 | #include <Geom2dAPI_InterCurveCurve.hxx> | |
2074 | #include <IntRes2d_IntersectionPoint.hxx> | |
2075 | //======================================================================= | |
2076 | //function : OCC24889 | |
2077 | //purpose : | |
2078 | //======================================================================= | |
2079 | static Standard_Integer OCC24889 (Draw_Interpretor& theDI, | |
2080 | Standard_Integer /*theNArg*/, | |
2081 | const char** /*theArgs*/) | |
2082 | { | |
2083 | // Curves | |
2084 | Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle( | |
2085 | gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 ); | |
2086 | ||
2087 | Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle( | |
2088 | gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 ); | |
2089 | ||
2090 | Handle( Geom2d_TrimmedCurve ) aTrim[2] = { | |
2091 | new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ), | |
2092 | new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 ) | |
2093 | }; | |
2094 | ||
2095 | DrawTrSurf::Set("c_1", aTrim[0]); | |
2096 | DrawTrSurf::Set("c_2", aTrim[1]); | |
2097 | ||
2098 | // Intersection | |
2099 | const Standard_Real aTol = Precision::Confusion(); | |
2100 | Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol ); | |
2101 | ||
2102 | const IntRes2d_IntersectionPoint& aIntPnt = | |
2103 | aIntTool.Intersector().Point( 1 ); | |
2104 | ||
2105 | gp_Pnt2d aIntRes = aIntTool.Point( 1 ); | |
2106 | Standard_Real aPar[2] = { | |
2107 | aIntPnt.ParamOnFirst(), | |
2108 | aIntPnt.ParamOnSecond() | |
2109 | }; | |
2110 | ||
2111 | //theDI.precision( 5 ); | |
2112 | theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n"; | |
2113 | for (int i = 0; i < 2; ++i) | |
2114 | { | |
2115 | theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() << | |
2116 | "; LastParam = " << aTrim[i]->LastParameter() << | |
2117 | "; IntParameter = " << aPar[i] << "\n"; | |
2118 | } | |
2119 | ||
2120 | return 0; | |
2121 | } | |
2122 | ||
5493d334 | 2123 | #include <math_GlobOptMin.hxx> |
2124 | #include <math_MultipleVarFunctionWithHessian.hxx> | |
2125 | //======================================================================= | |
2126 | //function : OCC25004 | |
2127 | //purpose : Check extremaCC on Branin function. | |
2128 | //======================================================================= | |
2129 | // Function is: | |
2130 | // f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s | |
2131 | // Standard borders are: | |
2132 | // -5 <= u <= 10 | |
2133 | // 0 <= v <= 15 | |
2134 | class BraninFunction : public math_MultipleVarFunctionWithHessian | |
2135 | { | |
2136 | public: | |
2137 | BraninFunction() | |
2138 | { | |
2139 | a = 1.0; | |
2140 | b = 5.1 / (4.0 * M_PI * M_PI); | |
2141 | c = 5.0 / M_PI; | |
2142 | r = 6.0; | |
2143 | s = 10.0; | |
2144 | t = 1.0 / (8.0 * M_PI); | |
2145 | } | |
2146 | virtual Standard_Integer NbVariables() const | |
2147 | { | |
2148 | return 2; | |
2149 | } | |
2150 | virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F) | |
2151 | { | |
2152 | Standard_Real u = X(1); | |
2153 | Standard_Real v = X(2); | |
2154 | ||
2155 | Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function. | |
2156 | Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion. | |
2157 | F = a * aSqPt * aSqPt + aLnPt + s; | |
2158 | return Standard_True; | |
2159 | } | |
2160 | virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G) | |
2161 | { | |
2162 | Standard_Real u = X(1); | |
2163 | Standard_Real v = X(2); | |
2164 | ||
2165 | Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function. | |
2166 | G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u); | |
2167 | G(2) = 2 * a * aSqPt; | |
2168 | ||
2169 | return Standard_True; | |
2170 | } | |
2171 | virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G) | |
2172 | { | |
2173 | Value(X,F); | |
2174 | Gradient(X,G); | |
2175 | ||
2176 | return Standard_True; | |
2177 | } | |
2178 | virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H) | |
2179 | { | |
2180 | Value(X,F); | |
2181 | Gradient(X,G); | |
2182 | ||
2183 | Standard_Real u = X(1); | |
2184 | Standard_Real v = X(2); | |
2185 | ||
2186 | Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function. | |
2187 | Standard_Real aTmpPt = c - 2 * b *u; // Tmp part. | |
2188 | H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u); | |
2189 | H(1,2) = 2 * a * aTmpPt; | |
2190 | H(2,1) = H(1,2); | |
2191 | H(2,2) = 2 * a; | |
2192 | ||
2193 | return Standard_True; | |
2194 | } | |
2195 | ||
2196 | private: | |
2197 | // Standard parameters. | |
2198 | Standard_Real a, b, c, r, s, t; | |
2199 | }; | |
2200 | ||
2201 | static Standard_Integer OCC25004 (Draw_Interpretor& theDI, | |
2202 | Standard_Integer /*theNArg*/, | |
2203 | const char** /*theArgs*/) | |
2204 | { | |
4b65fc77 | 2205 | BraninFunction aFunc; |
5493d334 | 2206 | |
2207 | math_Vector aLower(1,2), aUpper(1,2); | |
2208 | aLower(1) = -5; | |
2209 | aLower(2) = 0; | |
2210 | aUpper(1) = 10; | |
2211 | aUpper(2) = 15; | |
2212 | ||
2213 | Standard_Integer aGridOrder = 16; | |
2214 | math_Vector aFuncValues(1, aGridOrder * aGridOrder); | |
2215 | ||
2216 | Standard_Real aLipConst = 0; | |
2217 | math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2); | |
2218 | ||
2219 | // Get Lipshitz constant estimation on regular grid. | |
2220 | Standard_Integer i, j, idx = 1; | |
2221 | for(i = 1; i <= aGridOrder; i++) | |
2222 | { | |
2223 | for(j = 1; j <= aGridOrder; j++) | |
2224 | { | |
2225 | aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0); | |
2226 | aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0); | |
2227 | ||
4b65fc77 | 2228 | aFunc.Value(aCurrPnt1, aFuncValues(idx)); |
5493d334 | 2229 | idx++; |
2230 | } | |
2231 | } | |
2232 | ||
2233 | Standard_Integer k, l; | |
2234 | Standard_Integer idx1, idx2; | |
2235 | for(i = 1; i <= aGridOrder; i++) | |
2236 | for(j = 1; j <= aGridOrder; j++) | |
2237 | for(k = 1; k <= aGridOrder; k++) | |
2238 | for(l = 1; l <= aGridOrder; l++) | |
2239 | { | |
2240 | if (i == k && j == l) | |
2241 | continue; | |
2242 | ||
2243 | aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0); | |
2244 | aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0); | |
2245 | idx1 = (i - 1) * aGridOrder + j; | |
2246 | ||
2247 | aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0); | |
2248 | aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0); | |
2249 | idx2 = (k - 1) * aGridOrder + l; | |
2250 | ||
2251 | aCurrPnt1.Add(-aCurrPnt2); | |
2252 | Standard_Real dist = aCurrPnt1.Norm(); | |
2253 | ||
2254 | Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist; | |
2255 | if (C > aLipConst) | |
2256 | aLipConst = C; | |
2257 | } | |
2258 | ||
4b65fc77 | 2259 | math_GlobOptMin aFinder(&aFunc, aLower, aUpper, aLipConst); |
5493d334 | 2260 | aFinder.Perform(); |
2261 | //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475) | |
2262 | ||
2263 | Standard_Real anExtValue = aFinder.GetF(); | |
2264 | theDI << "F = " << anExtValue << "\n"; | |
2265 | ||
2266 | Standard_Integer aNbExt = aFinder.NbExtrema(); | |
2267 | theDI << "NbExtrema = " << aNbExt << "\n"; | |
2268 | ||
2269 | return 0; | |
2270 | } | |
8696d65d | 2271 | |
b6c0b841 RL |
2272 | #include <OSD_Environment.hxx> |
2273 | #include <Plugin.hxx> | |
2274 | #include <Plugin_Macro.hxx> | |
2275 | #include <Resource_Manager.hxx> | |
2276 | ||
2277 | #define THE_QATEST_DOC_FORMAT "My Proprietary Format" | |
2278 | ||
2279 | #define QA_CHECK(theDesc, theExpr, theValue) \ | |
2280 | {\ | |
2281 | const bool isTrue = !!(theExpr); \ | |
2282 | std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \ | |
2283 | } | |
2284 | ||
2285 | class Test_TDocStd_Application : public TDocStd_Application | |
2286 | { | |
2287 | public: | |
2288 | ||
2289 | static void initGlobalPluginMap (const TCollection_AsciiString& thePlugin, | |
2290 | const TCollection_AsciiString& theSaver, | |
2291 | const TCollection_AsciiString& theLoader) | |
2292 | { | |
2293 | const Handle(Resource_Manager)& aManager = Plugin::AdditionalPluginMap(); | |
2294 | aManager->SetResource ((theSaver + ".Location").ToCString(), thePlugin.ToCString()); | |
2295 | aManager->SetResource ((theLoader + ".Location").ToCString(), thePlugin.ToCString()); | |
2296 | } | |
2297 | ||
2298 | Test_TDocStd_Application (const TCollection_AsciiString& thePlugin, | |
2299 | const TCollection_AsciiString& theSaver, | |
2300 | const TCollection_AsciiString& theLoader) | |
2301 | { | |
2302 | initGlobalPluginMap (thePlugin, theSaver, theLoader); | |
2303 | ||
2304 | // explicitly initialize resource manager | |
2305 | myResources = new Resource_Manager (""); | |
2306 | myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT); | |
2307 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document"); | |
2308 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml"); | |
2309 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".StoragePlugin", theSaver.ToCString()); | |
2310 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".RetrievalPlugin", theLoader.ToCString()); | |
2311 | } | |
2312 | ||
2313 | virtual Standard_CString ResourcesName() { return ""; } | |
2314 | virtual void Formats (TColStd_SequenceOfExtendedString& theFormats) { theFormats.Clear(); } | |
2315 | }; | |
2316 | ||
2317 | //======================================================================= | |
2318 | //function : OCC24925 | |
2319 | //purpose : | |
2320 | //======================================================================= | |
2321 | static Standard_Integer OCC24925 (Draw_Interpretor& theDI, | |
2322 | Standard_Integer theArgNb, | |
2323 | const char** theArgVec) | |
2324 | { | |
2325 | if (theArgNb != 2 | |
2326 | && theArgNb != 5) | |
2327 | { | |
2328 | std::cout << "Error: wrong syntax! See usage:\n"; | |
2329 | theDI.PrintHelp (theArgVec[0]); | |
2330 | return 1; | |
2331 | } | |
2332 | ||
2333 | Standard_Integer anArgIter = 1; | |
2334 | TCollection_ExtendedString aFileName = theArgVec[anArgIter++]; | |
2335 | TCollection_AsciiString aPlugin = "TKXml"; | |
2336 | TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx | |
2337 | TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx | |
2338 | if (anArgIter < theArgNb) | |
2339 | { | |
2340 | aPlugin = theArgVec[anArgIter++]; | |
2341 | aSaver = theArgVec[anArgIter++]; | |
2342 | aLoader = theArgVec[anArgIter++]; | |
2343 | } | |
2344 | ||
2345 | PCDM_StoreStatus aSStatus = PCDM_SS_Failure; | |
2346 | PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError; | |
2347 | ||
2348 | Handle(TDocStd_Application) anApp = new Test_TDocStd_Application (aPlugin, aSaver, aLoader); | |
2349 | { | |
2350 | Handle(TDocStd_Document) aDoc; | |
2351 | anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc); | |
2352 | TDF_Label aLab = aDoc->Main(); | |
2353 | TDataStd_Integer::Set (aLab, 0); | |
2354 | TDataStd_Name::Set (aLab, "QABugs_19.cxx"); | |
2355 | ||
2356 | aSStatus = anApp->SaveAs (aDoc, aFileName); | |
2357 | anApp->Close (aDoc); | |
2358 | } | |
2359 | QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true); | |
2360 | ||
2361 | { | |
2362 | Handle(TDocStd_Document) aDoc; | |
2363 | aRStatus = anApp->Open (aFileName, aDoc); | |
2364 | anApp->Close (aDoc); | |
2365 | } | |
2366 | QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true); | |
2367 | return 0; | |
2368 | } | |
2369 | ||
a967f104 | 2370 | //======================================================================= |
2371 | //function : OCC25043 | |
2372 | //purpose : | |
2373 | //======================================================================= | |
2374 | #include <BRepAlgoAPI_Check.hxx> | |
2375 | static Standard_Integer OCC25043 (Draw_Interpretor& theDI, | |
2376 | Standard_Integer theArgNb, | |
2377 | const char** theArgVec) | |
2378 | { | |
2379 | if (theArgNb != 2) { | |
2380 | theDI << "Usage: " << theArgVec[0] << " shape\n"; | |
2381 | return 1; | |
2382 | } | |
2383 | ||
2384 | TopoDS_Shape aShape = DBRep::Get(theArgVec[1]); | |
2385 | if (aShape.IsNull()) | |
2386 | { | |
2387 | theDI << theArgVec[1] << " shape is NULL\n"; | |
2388 | return 1; | |
2389 | } | |
2390 | ||
2391 | BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True); | |
2392 | ||
2393 | if (!anAlgoApiCheck.IsValid()) | |
2394 | { | |
2395 | BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result()); | |
2396 | for (; anCheckIter.More(); anCheckIter.Next()) | |
2397 | { | |
2398 | const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value(); | |
2399 | const BOPCol_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1(); | |
2400 | BOPCol_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes); | |
2401 | for (; aFaultyIter.More(); aFaultyIter.Next()) | |
2402 | { | |
2403 | const TopoDS_Shape& aFaultyShape = aFaultyIter.Value(); | |
2404 | ||
2405 | Standard_Boolean anIsFaultyShapeFound = Standard_False; | |
2406 | TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType()); | |
2407 | for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next()) | |
2408 | { | |
2409 | if (anExp.Current().IsEqual(aFaultyShape)) | |
2410 | anIsFaultyShapeFound = Standard_True; | |
2411 | } | |
2412 | ||
2413 | if (!anIsFaultyShapeFound) | |
2414 | { | |
2415 | theDI << "Error. Faulty Shape is NOT found in source shape.\n"; | |
2416 | return 0; | |
2417 | } | |
2418 | else | |
2419 | { | |
3510db62 | 2420 | theDI << "Info. Faulty shape is found in source shape\n"; |
a967f104 | 2421 | } |
2422 | } | |
2423 | } | |
2424 | } | |
2425 | else | |
2426 | { | |
3510db62 | 2427 | theDI << "Problems are not detected. Test is not performed."; |
a967f104 | 2428 | } |
2429 | ||
2430 | return 0; | |
2431 | } | |
2432 | ||
4a350f94 | 2433 | //======================================================================= |
2434 | //function : OCC24606 | |
2435 | //purpose : | |
2436 | //======================================================================= | |
2437 | static Standard_Integer OCC24606 (Draw_Interpretor& theDI, | |
2438 | Standard_Integer theArgNb, | |
2439 | const char** theArgVec) | |
2440 | { | |
2441 | if (theArgNb > 1) | |
2442 | { | |
2443 | std::cerr << "Error: incorrect number of arguments.\n"; | |
2444 | theDI << "Usage : " << theArgVec[0] << "\n"; | |
2445 | return 1; | |
2446 | } | |
2447 | ||
2448 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
2449 | if (aView.IsNull()) | |
2450 | { | |
2451 | std::cerr << "Errro: no active view, please call 'vinit'.\n"; | |
2452 | return 1; | |
2453 | } | |
2454 | ||
2455 | aView->DepthFitAll(); | |
2456 | aView->FitAll(); | |
2457 | ||
2458 | return 0; | |
2459 | } | |
2460 | ||
e4b5c45a | 2461 | //======================================================================= |
2462 | //function : OCC23010 | |
2463 | //purpose : | |
2464 | //======================================================================= | |
2465 | #include <STEPCAFControl_Reader.hxx> | |
2466 | ||
2467 | class mOcafApplication : public TDocStd_Application | |
2468 | { | |
2469 | void Formats(TColStd_SequenceOfExtendedString& Formats) | |
2470 | { | |
2471 | Formats.Append(TCollection_ExtendedString("mOcafApplication")); | |
2472 | } | |
2473 | Standard_CString ResourcesName() | |
2474 | { | |
2475 | return Standard_CString("Resources"); | |
2476 | } | |
2477 | }; | |
2478 | ||
2479 | static Standard_Integer OCC23010 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
2480 | { | |
2481 | if (argc != 2) { | |
586db386 | 2482 | di << "Usage: " << argv[0] << " invalid number of arguments\n"; |
e4b5c45a | 2483 | return 1; |
2484 | } | |
2485 | std::string fileName=argv[1]; | |
2486 | mOcafApplication *mCasApp = new mOcafApplication(); | |
2487 | Handle(TDocStd_Document) doc; | |
fff263bd | 2488 | mCasApp->NewDocument("BinXCAF", doc); |
e4b5c45a | 2489 | STEPCAFControl_Reader stepReader; |
2490 | IFSelect_ReturnStatus status = stepReader.ReadFile (fileName.c_str()); | |
2491 | if (status != IFSelect_RetDone) | |
2492 | return false; | |
2493 | stepReader.SetColorMode(Standard_True); | |
2494 | stepReader.SetLayerMode(Standard_True); | |
2495 | stepReader.SetNameMode(Standard_True); | |
2496 | stepReader.Transfer(doc); // ERROR HERE!!! | |
2497 | delete mCasApp; | |
2498 | return 0; | |
2499 | } | |
2500 | ||
ab860031 | 2501 | //======================================================================= |
2502 | //function : OCC25202 | |
2503 | //purpose : | |
2504 | //======================================================================= | |
2505 | #include <ShapeBuild_ReShape.hxx> | |
2506 | static Standard_Integer OCC25202 ( Draw_Interpretor& theDI, | |
2507 | Standard_Integer theArgN, | |
2508 | const char** theArgVal) | |
2509 | { | |
2510 | // 0 1 2 3 4 5 6 | |
2511 | //reshape res shape numF1 face1 numF2 face2 | |
2512 | if(theArgN < 7) | |
2513 | { | |
2514 | theDI << "Use: reshape res shape numF1 face1 numF2 face2\n"; | |
2515 | return 1; | |
2516 | } | |
2517 | ||
2518 | TopoDS_Shape aShape = DBRep::Get(theArgVal[2]); | |
2519 | const Standard_Integer aNumOfRE1 = Draw::Atoi(theArgVal[3]), | |
2520 | aNumOfRE2 = Draw::Atoi(theArgVal[5]); | |
2521 | TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])), | |
2522 | aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6])); | |
2523 | ||
2524 | if(aShape.IsNull()) | |
2525 | { | |
2526 | theDI << theArgVal[2] << " is null shape\n"; | |
2527 | return 1; | |
2528 | } | |
2529 | ||
2530 | if(aShapeForRepl1.IsNull()) | |
2531 | { | |
2532 | theDI << theArgVal[4] << " is not a replaced type\n"; | |
2533 | return 1; | |
2534 | } | |
2535 | ||
2536 | if(aShapeForRepl2.IsNull()) | |
2537 | { | |
2538 | theDI << theArgVal[6] << " is not a replaced type\n"; | |
2539 | return 1; | |
2540 | } | |
2541 | ||
2542 | ||
2543 | TopoDS_Shape aReplacedShape; | |
2544 | ShapeBuild_ReShape aReshape; | |
2545 | ||
2546 | //////////////////// explode (begin) | |
2547 | TopTools_MapOfShape M; | |
2548 | M.Add(aShape); | |
2549 | Standard_Integer aNbShapes = 0; | |
2550 | for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next()) | |
2551 | { | |
2552 | const TopoDS_Shape& Sx = ex.Current(); | |
2553 | Standard_Boolean added = M.Add(Sx); | |
2554 | if (added) | |
2555 | { | |
2556 | aNbShapes++; | |
2557 | if(aNbShapes == aNumOfRE1) | |
2558 | { | |
2559 | aReplacedShape = Sx; | |
2560 | ||
2561 | aReshape.Replace(aReplacedShape, aShapeForRepl1); | |
2562 | } | |
2563 | ||
2564 | if(aNbShapes == aNumOfRE2) | |
2565 | { | |
2566 | aReplacedShape = Sx; | |
2567 | ||
2568 | aReshape.Replace(aReplacedShape, aShapeForRepl2); | |
2569 | } | |
2570 | } | |
2571 | } | |
2572 | //////////////////// explode (end) | |
2573 | ||
2574 | if(aReplacedShape.IsNull()) | |
2575 | { | |
2576 | theDI << "There is not any shape for replacing.\n"; | |
2577 | } | |
2578 | ||
2579 | DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2)); | |
2580 | ||
2581 | return 0; | |
2582 | } | |
2583 | ||
c6037065 | 2584 | #include <ShapeFix_Wireframe.hxx> |
2585 | //======================================================================= | |
2586 | //function : OCC7570 | |
2587 | //purpose : | |
2588 | //======================================================================= | |
2589 | static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
2590 | { | |
2591 | if (n != 2) { | |
586db386 | 2592 | di<<"Usage: "<<a[0]<<" invalid number of arguments\n"; |
c6037065 | 2593 | return 1; |
2594 | } | |
2595 | TopoDS_Shape in_shape (DBRep::Get (a[1])); | |
2596 | ShapeFix_Wireframe fix_tool (in_shape); | |
2597 | fix_tool.ModeDropSmallEdges () = Standard_True; | |
2598 | fix_tool.SetPrecision (1.e+6); | |
2599 | fix_tool.SetLimitAngle (0.01); | |
2600 | fix_tool.FixSmallEdges (); | |
2601 | TopoDS_Shape new_shape = fix_tool.Shape (); | |
2602 | return 0; | |
2603 | } | |
2604 | ||
54a16ee4 | 2605 | #include <AIS_TypeFilter.hxx> |
5e452c37 | 2606 | //======================================================================= |
2607 | //function : OCC25340 | |
2608 | //purpose : | |
2609 | //======================================================================= | |
54a16ee4 | 2610 | static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/, |
2611 | Standard_Integer /*theArgNb*/, | |
2612 | const char** /*theArgVec*/) | |
2613 | { | |
2614 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
2615 | if (aCtx.IsNull()) | |
2616 | { | |
2617 | std::cerr << "Error: No opened viewer!\n"; | |
2618 | return 1; | |
2619 | } | |
2620 | Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape); | |
2621 | aCtx->AddFilter (aFilter); | |
2622 | return 0; | |
2623 | } | |
2624 | ||
c7b59798 | 2625 | //======================================================================= |
2626 | //function : OCC24826 | |
2627 | //purpose : | |
2628 | //======================================================================= | |
2629 | class ParallelTest_Saxpy | |
2630 | { | |
2631 | public: | |
2632 | typedef NCollection_Array1<Standard_Real> Vector; | |
2633 | ||
2634 | //! Constructor | |
2635 | ParallelTest_Saxpy(const Vector& theX, Vector& theY, Standard_Real theScalar) | |
2636 | : myX(theX), | |
2637 | myY(theY), | |
2638 | myScalar(theScalar) | |
2639 | { | |
2640 | } | |
2641 | ||
2642 | //! Dummy calculation | |
2643 | void operator() (const Standard_Integer theIndex) const | |
2644 | { | |
2645 | myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex); | |
2646 | } | |
2647 | ||
2648 | private: | |
2649 | ParallelTest_Saxpy( const ParallelTest_Saxpy& ); | |
2650 | ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& ); | |
2651 | ||
2652 | private: | |
2653 | const Vector& myX; | |
2654 | Vector& myY; | |
2655 | const Standard_Real myScalar; | |
2656 | }; | |
2657 | ||
2658 | //--------------------------------------------------------------------- | |
2659 | static Standard_Integer OCC24826(Draw_Interpretor& theDI, | |
2660 | Standard_Integer trheArgc, | |
2661 | const char** theArgv) | |
2662 | { | |
2663 | if ( trheArgc != 2 ) | |
2664 | { | |
2665 | theDI << "Usage: " | |
2666 | << theArgv[0] | |
2667 | << " vec_length\n"; | |
2668 | return 1; | |
2669 | } | |
2670 | ||
2671 | // Generate data; | |
2672 | Standard_Integer aLength = Draw::Atoi(theArgv[1]); | |
2673 | ||
2674 | NCollection_Array1<Standard_Real> aX (0, aLength - 1); | |
2675 | NCollection_Array1<Standard_Real> anY(0, aLength - 1); | |
2676 | ||
2677 | for ( Standard_Integer i = 0; i < aLength; ++i ) | |
2678 | { | |
2679 | aX(i) = anY(i) = (Standard_Real) i; | |
2680 | } | |
2681 | ||
2682 | OSD_Timer aTimer; | |
2683 | ||
2684 | aTimer.Start(); | |
2685 | ||
2686 | //! Serial proccesing | |
2687 | for ( Standard_Integer i = 0; i < aLength; ++i ) | |
2688 | { | |
2689 | anY(i) = 1e-6 * aX(i) + anY(i); | |
2690 | } | |
2691 | ||
2692 | aTimer.Stop(); | |
2693 | cout << "Processing time (sequential mode):\n"; | |
2694 | aTimer.Show(); | |
2695 | ||
2696 | const ParallelTest_Saxpy aFunctor(aX, anY, 1e-6); | |
2697 | ||
2698 | aTimer.Reset(); | |
2699 | aTimer.Start(); | |
2700 | ||
2701 | // Parallel processing | |
2702 | OSD_Parallel::For(0, aLength, aFunctor); | |
2703 | ||
2704 | aTimer.Stop(); | |
2705 | cout << "Processing time (parallel mode):\n"; | |
2706 | aTimer.Show(); | |
2707 | ||
2708 | return 0; | |
2709 | } | |
2710 | ||
b6c0b841 | 2711 | /*****************************************************************************/ |
8696d65d | 2712 | |
058f130e | 2713 | #include <GeomAPI_IntSS.hxx> |
2714 | //======================================================================= | |
2715 | //function : OCC25100 | |
2716 | //purpose : | |
2717 | //======================================================================= | |
2718 | static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
2719 | { | |
2720 | if (argc < 2) | |
2721 | { | |
2722 | di << "the method requires a shape name\n"; | |
2723 | return 1; | |
2724 | } | |
2725 | ||
2726 | TopoDS_Shape S = DBRep::Get(argv[1]); | |
2727 | if ( S.IsNull() ) | |
2728 | { | |
586db386 | 2729 | di << "Shape is empty\n"; |
058f130e | 2730 | return 1; |
2731 | } | |
2732 | ||
2733 | TopExp_Explorer aFaceExp(S, TopAbs_FACE); | |
2734 | const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current())); | |
2735 | ||
2736 | GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion()); | |
2737 | ||
2738 | if (!anIntersector.IsDone()) | |
2739 | { | |
2740 | di << "Error. Intersection is not done\n"; | |
2741 | return 1; | |
2742 | } | |
2743 | ||
2744 | di << "Test complete\n"; | |
2745 | ||
2746 | return 0; | |
2747 | } | |
2748 | ||
5e452c37 | 2749 | //======================================================================= |
2750 | //function : OCC25348 | |
2751 | //purpose : | |
2752 | //======================================================================= | |
2753 | static Standard_Integer OCC25348 (Draw_Interpretor& theDI, | |
2754 | Standard_Integer /*theArgNb*/, | |
2755 | const char** /*theArgVec*/) | |
2756 | { | |
2757 | Handle(NCollection_IncAllocator) anAlloc1; | |
2758 | NCollection_List<int> aList1(anAlloc1); | |
2759 | for (int i=0; i < 10; i++) | |
2760 | { | |
2761 | Handle(NCollection_IncAllocator) anAlloc2; | |
2762 | NCollection_List<int> aList2(anAlloc2); | |
2763 | aList2.Append(i); | |
2764 | aList1.Assign(aList2); | |
2765 | } | |
2766 | theDI << "Test complete\n"; | |
2767 | return 0; | |
2768 | } | |
2769 | ||
6fb3418e | 2770 | #include <IntCurvesFace_ShapeIntersector.hxx> |
2771 | #include <BRepBndLib.hxx> | |
2772 | //======================================================================= | |
2773 | //function : OCC25413 | |
2774 | //purpose : | |
2775 | //======================================================================= | |
2776 | static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a) | |
2777 | { | |
2778 | if (narg != 2) { | |
586db386 | 2779 | di << "Usage: " << a[0] << " invalid number of arguments\n"; |
6fb3418e | 2780 | return 1; |
2781 | } | |
2782 | TopoDS_Shape aShape = DBRep::Get (a[1]); | |
2783 | ||
2784 | IntCurvesFace_ShapeIntersector Inter; | |
2785 | Inter.Load(aShape, Precision::Confusion()); | |
2786 | ||
2787 | Bnd_Box aBndBox; | |
2788 | BRepBndLib::Add(aShape, aBndBox); | |
2789 | ||
2790 | gp_Dir aDir(0., 1., 0.); | |
2791 | const int N = 250; | |
2792 | Standard_Real xMin = aBndBox.CornerMin().X(); | |
2793 | Standard_Real zMin = aBndBox.CornerMin().Z(); | |
2794 | Standard_Real xMax = aBndBox.CornerMax().X(); | |
2795 | Standard_Real zMax = aBndBox.CornerMax().Z(); | |
2796 | Standard_Real xStep = (xMax - xMin) / N; | |
2797 | Standard_Real zStep = (zMax - zMin) / N; | |
2798 | ||
2799 | for (Standard_Real x = xMin; x <= xMax; x += xStep) | |
2800 | for (Standard_Real z = zMin; z <= zMax; z += zStep) | |
2801 | { | |
2802 | gp_Pnt aPoint(x, 0.0, z); | |
2803 | gp_Lin aLine(aPoint, aDir); | |
2804 | Inter.PerformNearest(aLine, -100., 100.); | |
2805 | } | |
2806 | return 0; | |
2807 | } | |
058f130e | 2808 | |
c088aa93 | 2809 | |
2810 | #include <BOPAlgo_PaveFiller.hxx> | |
2811 | // | |
2812 | #include <BRepAlgoAPI_BooleanOperation.hxx> | |
2813 | #include <BRepAlgoAPI_Common.hxx> | |
2814 | #include <BRepAlgoAPI_Fuse.hxx> | |
2815 | #include <BRepAlgoAPI_Cut.hxx> | |
2816 | #include <BRepAlgoAPI_Section.hxx> | |
2817 | // | |
2818 | #include <BOPTools.hxx> | |
2819 | // | |
2820 | #include <BOPCol_MapOfShape.hxx> | |
2821 | #include <BOPCol_ListOfShape.hxx> | |
2822 | //======================================================================= | |
2823 | //function : OCC25446 | |
2824 | //purpose : | |
2825 | //======================================================================= | |
2826 | static Standard_Integer OCC25446 (Draw_Interpretor& theDI, | |
2827 | Standard_Integer argc, | |
2828 | const char ** argv) | |
2829 | { | |
2830 | if (argc != 5) { | |
2831 | theDI << "Usage: OCC25446 res b1 b2 op\n"; | |
2832 | return 1; | |
2833 | } | |
2834 | // | |
2835 | TopoDS_Shape aS1 = DBRep::Get(argv[2]); | |
2836 | if (aS1.IsNull()) { | |
2837 | theDI << argv[2] << " shape is NULL\n"; | |
2838 | return 1; | |
2839 | } | |
2840 | // | |
2841 | TopoDS_Shape aS2 = DBRep::Get(argv[3]); | |
2842 | if (aS2.IsNull()) { | |
2843 | theDI << argv[3] << " shape is NULL\n"; | |
2844 | return 1; | |
2845 | } | |
2846 | // | |
2847 | Standard_Integer iOp; | |
2848 | BOPAlgo_Operation aOp; | |
2849 | // | |
2850 | iOp = Draw::Atoi(argv[4]); | |
2851 | if (iOp < 0 || iOp > 4) { | |
2852 | theDI << "Invalid operation type\n"; | |
2853 | return 1; | |
2854 | } | |
2855 | aOp = (BOPAlgo_Operation)iOp; | |
2856 | // | |
2857 | Standard_Integer iErr; | |
2858 | BOPCol_ListOfShape aLS; | |
2859 | BOPAlgo_PaveFiller aPF; | |
2860 | // | |
2861 | aLS.Append(aS1); | |
2862 | aLS.Append(aS2); | |
2863 | aPF.SetArguments(aLS); | |
2864 | // | |
2865 | aPF.Perform(); | |
2866 | iErr = aPF.ErrorStatus(); | |
2867 | if (iErr) { | |
2868 | theDI << "Intersection failed with error status: " << iErr << "\n"; | |
2869 | return 1; | |
2870 | } | |
2871 | // | |
2872 | BRepAlgoAPI_BooleanOperation* pBuilder = NULL; | |
2873 | // | |
2874 | switch (aOp) { | |
2875 | case BOPAlgo_COMMON: | |
2876 | pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF); | |
2877 | break; | |
2878 | case BOPAlgo_FUSE: | |
2879 | pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF); | |
2880 | break; | |
2881 | case BOPAlgo_CUT: | |
2882 | pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF); | |
2883 | break; | |
2884 | case BOPAlgo_CUT21: | |
2885 | pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False); | |
2886 | break; | |
2887 | case BOPAlgo_SECTION: | |
2888 | pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF); | |
2889 | break; | |
2890 | default: | |
2891 | break; | |
2892 | } | |
2893 | // | |
2894 | iErr = pBuilder->ErrorStatus(); | |
2895 | if (!pBuilder->IsDone()) { | |
2896 | theDI << "BOP failed with error status: " << iErr << "\n"; | |
2897 | return 1; | |
2898 | } | |
2899 | // | |
2900 | const TopoDS_Shape& aRes = pBuilder->Shape(); | |
2901 | DBRep::Set(argv[1], aRes); | |
2902 | // | |
2903 | BOPCol_MapOfShape aMapArgs, aMapShape; | |
2904 | BOPCol_MapIteratorOfMapOfShape aIt; | |
2905 | Standard_Boolean bIsDeletedHist, bIsDeletedMap; | |
2906 | TopAbs_ShapeEnum aType; | |
2907 | // | |
2908 | BOPTools::MapShapes(aS1, aMapArgs); | |
2909 | BOPTools::MapShapes(aS2, aMapArgs); | |
2910 | BOPTools::MapShapes(aRes, aMapShape); | |
2911 | // | |
2912 | aIt.Initialize(aMapArgs); | |
2913 | for (; aIt.More(); aIt.Next()) { | |
2914 | const TopoDS_Shape& aS = aIt.Value(); | |
2915 | aType = aS.ShapeType(); | |
2916 | if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE || | |
2917 | aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) { | |
2918 | continue; | |
2919 | } | |
2920 | // | |
2921 | bIsDeletedHist = pBuilder->IsDeleted(aS); | |
2922 | bIsDeletedMap = !aMapShape.Contains(aS) && | |
2923 | (pBuilder->Modified(aS).Extent() == 0); | |
2924 | // | |
2925 | if (bIsDeletedHist != bIsDeletedMap) { | |
2926 | theDI << "Error. Wrong value of IsDeleted flag.\n"; | |
2927 | return 1; | |
2928 | } | |
2929 | } | |
2930 | // | |
2931 | theDI << "Test complete\n"; | |
2932 | return 0; | |
2933 | } | |
2934 | ||
ee6bb37b | 2935 | //==================================================== |
2936 | // Auxiliary functor class for the command OCC25545; | |
2937 | // it gets access to a vertex with the given index and | |
2938 | // checks that X coordinate of the point is equal to index; | |
2939 | // if it is not so then a data race is reported. | |
2940 | //==================================================== | |
2941 | struct OCC25545_Functor | |
2942 | { | |
2943 | OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec) | |
2944 | : myShapeVec(&theShapeVec), | |
2945 | myIsRaceDetected(0) | |
2946 | {} | |
2947 | ||
2948 | void operator()(size_t i) const | |
2949 | { | |
2950 | if (!myIsRaceDetected) { | |
2951 | const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i)); | |
2952 | gp_Pnt aP = BRep_Tool::Pnt (aV); | |
2953 | if (aP.X () != static_cast<double> (i)) { | |
2954 | Standard_Atomic_Increment(&myIsRaceDetected); | |
2955 | } | |
2956 | } | |
2957 | } | |
2958 | ||
2959 | const std::vector<TopoDS_Shape>* myShapeVec; | |
2960 | mutable volatile int myIsRaceDetected; | |
2961 | }; | |
2962 | ||
2963 | //======================================================================= | |
2964 | //function : OCC25545 | |
2965 | //purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation() | |
2966 | //======================================================================= | |
2967 | #ifdef HAVE_TBB | |
2968 | static Standard_Integer OCC25545 (Draw_Interpretor& di, | |
2969 | Standard_Integer, | |
2970 | const char **) | |
2971 | { | |
2972 | // Place vertices in a vector, giving the i-th vertex the | |
2973 | // transformation that translates it on the vector (i,0,0) from the origin. | |
2974 | size_t n = 1000; | |
2975 | std::vector<TopoDS_Shape> aShapeVec (n); | |
2976 | std::vector<TopLoc_Location> aLocVec (n); | |
2977 | TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ()); | |
2978 | aShapeVec[0] = aShape; | |
2979 | for (size_t i = 1; i < n; ++i) { | |
2980 | gp_Trsf aT; | |
2981 | aT.SetTranslation (gp_Vec (1, 0, 0)); | |
2982 | aLocVec[i] = aLocVec[i - 1] * aT; | |
2983 | aShapeVec[i] = aShape.Moved (aLocVec[i]); | |
2984 | } | |
2985 | ||
2986 | // Evaluator function will access vertices geometry | |
2987 | // concurrently | |
2988 | OCC25545_Functor aFunc(aShapeVec); | |
2989 | ||
2990 | //concurrently process | |
2991 | tbb::parallel_for (size_t (0), n, aFunc, tbb::simple_partitioner ()); | |
2992 | QVERIFY (!aFunc.myIsRaceDetected); | |
2993 | return 0; | |
2994 | } | |
2995 | #else | |
2996 | static Standard_Integer OCC25545 (Draw_Interpretor&, | |
2997 | Standard_Integer, | |
2998 | const char **argv) | |
2999 | { | |
3000 | cout << "Test skipped: command " << argv[0] << " requires TBB library" << endl; | |
3001 | return 0; | |
3002 | } | |
3003 | #endif | |
3004 | ||
d315303d | 3005 | //======================================================================= |
3006 | //function : OCC25547 | |
3007 | //purpose : | |
3008 | //======================================================================= | |
3009 | #include <BRepMesh_GeomTool.hxx> | |
3010 | #include <BRepAdaptor_Curve.hxx> | |
3011 | #include <Geom_TrimmedCurve.hxx> | |
3012 | #include <BRepBuilderAPI_MakeFace.hxx> | |
3013 | #include <BRepAdaptor_HSurface.hxx> | |
3014 | #include <BRepAdaptor_Surface.hxx> | |
3015 | static Standard_Integer OCC25547( | |
3016 | Draw_Interpretor& theDI, | |
3017 | Standard_Integer /*argc*/, | |
3018 | const char ** /*argv*/) | |
3019 | { | |
3020 | // The general aim of this test is to prevent linkage errors due to missed | |
3021 | // Standard_EXPORT attribute for static methods. | |
3022 | ||
3023 | // However, start checking the main functionality at first. | |
3024 | const Standard_Real aFirstP = 0., aLastP = M_PI; | |
3025 | Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10); | |
3026 | Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP); | |
3027 | TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf); | |
3028 | BRepAdaptor_Curve aAdaptor(aEdge); | |
3029 | BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5); | |
3030 | ||
3031 | if (aGeomTool.NbPoints() == 0) | |
3032 | { | |
3033 | theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n"; | |
3034 | return 1; | |
3035 | } | |
3036 | ||
3037 | // Test static methods. | |
3038 | TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ())); | |
3039 | BRepAdaptor_Surface aSurf(aFace); | |
3040 | Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf); | |
3041 | ||
3042 | gp_Pnt aPnt; | |
3043 | gp_Dir aNormal; | |
3044 | if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal)) | |
3045 | { | |
3046 | theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n"; | |
3047 | return 1; | |
3048 | } | |
3049 | ||
3050 | gp_XY aRefPnts[4] = { | |
3051 | gp_XY(-10., -10.), gp_XY(10., 10.), | |
3052 | gp_XY(-10., 10.), gp_XY(10., -10.) | |
3053 | }; | |
3054 | ||
3055 | gp_Pnt2d aIntPnt; | |
3056 | Standard_Real aParams[2]; | |
3057 | BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin( | |
3058 | aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3], | |
3059 | aIntPnt.ChangeCoord(), aParams); | |
3060 | ||
3061 | Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d()); | |
3062 | if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion()) | |
3063 | { | |
3064 | theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n"; | |
3065 | return 1; | |
3066 | } | |
3067 | ||
3068 | aIntFlag = BRepMesh_GeomTool::IntSegSeg( | |
3069 | aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3], | |
3070 | Standard_False, Standard_False, aIntPnt); | |
3071 | ||
3072 | aDiff = aIntPnt.Distance(gp::Origin2d()); | |
3073 | if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion()) | |
3074 | { | |
3075 | theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n"; | |
3076 | return 1; | |
3077 | } | |
3078 | ||
3079 | ||
3080 | theDI << "Test complete\n"; | |
3081 | return 0; | |
3082 | } | |
3083 | ||
ec81011f | 3084 | static Standard_Integer OCC26139 (Draw_Interpretor& theDI, |
3085 | Standard_Integer argc, | |
3086 | const char ** argv) | |
3087 | { | |
3088 | ||
3089 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
3090 | if (aCtx.IsNull()) | |
3091 | { | |
3092 | theDI << "Use 'vinit' command before " << argv[0] << "\n"; | |
3093 | return 1; | |
3094 | } | |
3095 | ||
3096 | Standard_Integer aBoxGridSize = 100; | |
3097 | Standard_Integer aCompGridSize = 3; | |
3098 | Standard_Real aBoxSize = 5.0; | |
3099 | ||
3100 | if (argc > 1) | |
3101 | { | |
3102 | for (Standard_Integer anArgIdx = 1; anArgIdx < argc; ++anArgIdx) | |
3103 | { | |
3104 | TCollection_AsciiString anArg (argv[anArgIdx]); | |
3105 | anArg.LowerCase(); | |
3106 | if (anArg == "-boxgrid") | |
3107 | { | |
3108 | aBoxGridSize = Draw::Atoi (argv[++anArgIdx]); | |
3109 | } | |
3110 | else if (anArg == "-compgrid") | |
3111 | { | |
3112 | aCompGridSize = Draw::Atoi (argv[++anArgIdx]); | |
3113 | } | |
3114 | else if (anArg == "-boxsize") | |
3115 | { | |
3116 | aBoxSize = Draw::Atof (argv[++anArgIdx]); | |
3117 | } | |
3118 | } | |
3119 | } | |
3120 | ||
3121 | NCollection_List<Handle(AIS_Shape)> aCompounds; | |
3122 | for (Standard_Integer aCompGridX = 0; aCompGridX < aCompGridSize; ++aCompGridX) | |
3123 | { | |
3124 | for (Standard_Integer aCompGridY = 0; aCompGridY < aCompGridSize; ++aCompGridY) | |
3125 | { | |
3126 | BRep_Builder aBuilder; | |
3127 | TopoDS_Compound aComp; | |
3128 | aBuilder.MakeCompound (aComp); | |
3129 | for (Standard_Integer aBoxGridX = 0; aBoxGridX < aBoxGridSize; ++aBoxGridX) | |
3130 | { | |
3131 | for (Standard_Integer aBoxGridY = 0; aBoxGridY < aBoxGridSize; ++aBoxGridY) | |
3132 | { | |
3133 | BRepPrimAPI_MakeBox aBox (gp_Pnt (aBoxGridX * aBoxSize, aBoxGridY * aBoxSize, 0.0), | |
3134 | aBoxSize, aBoxSize, aBoxSize); | |
3135 | aBuilder.Add (aComp, aBox.Shape()); | |
3136 | } | |
3137 | } | |
3138 | gp_Trsf aTrsf; | |
3139 | aTrsf.SetTranslation (gp_Vec (aBoxGridSize * aBoxSize * aCompGridX, | |
3140 | aBoxGridSize * aBoxSize * aCompGridY, | |
3141 | 0.0)); | |
3142 | TopLoc_Location aLoc (aTrsf); | |
3143 | aComp.Located (aLoc); | |
3144 | aCompounds.Append (new AIS_Shape (aComp)); | |
3145 | } | |
3146 | } | |
3147 | ||
3148 | OSD_Timer aTimer; | |
3149 | for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next()) | |
3150 | { | |
3151 | aTimer.Start(); | |
3152 | aCtx->Display (aCompIter.Value(), Standard_False); | |
3153 | aTimer.Stop(); | |
3154 | theDI << "Display time: " << aTimer.ElapsedTime() << "\n"; | |
3155 | aTimer.Reset(); | |
3156 | } | |
3157 | ||
3158 | aTimer.Reset(); | |
3159 | aTimer.Start(); | |
3160 | for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next()) | |
3161 | { | |
3162 | aCtx->Remove (aCompIter.Value(), Standard_False); | |
3163 | } | |
3164 | aTimer.Stop(); | |
3165 | theDI << "Remove time: " << aTimer.ElapsedTime() << "\n"; | |
3166 | ||
3167 | return 0; | |
3168 | } | |
3169 | ||
2bfe59b6 | 3170 | #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx> |
3171 | #include <TColStd_DataMapOfIntegerInteger.hxx> | |
3172 | #include <OSD.hxx> | |
3173 | #include <ShapeFix_Wire.hxx> | |
3174 | #include <ShapeExtend_Status.hxx> | |
57c28b61 | 3175 | #ifdef _WIN32 |
2bfe59b6 | 3176 | #define EXCEPTION ... |
3177 | #else | |
3178 | #define EXCEPTION Standard_Failure | |
3179 | #endif | |
3180 | ||
3181 | static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)& theFix, | |
3182 | const Standard_Boolean theIs3d) | |
3183 | { | |
3184 | for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++) | |
3185 | { | |
3186 | Standard_Boolean isFound; | |
3187 | if (theIs3d) | |
3188 | isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i ); | |
3189 | else | |
3190 | isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i ); | |
3191 | if (isFound) return ShapeExtend_Status(i); | |
3192 | } | |
3193 | return ShapeExtend_OK; | |
3194 | } | |
3195 | ||
3196 | //=================== | |
3197 | //function : OCC24881 | |
3198 | //purpose : | |
3199 | //=================== | |
3200 | static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a) | |
3201 | { | |
3202 | if (narg < 2) { | |
586db386 | 3203 | di<<"Usage: "<<a[0]<<" invalid number of arguments\n"; |
2bfe59b6 | 3204 | return 1; |
3205 | } | |
3206 | // cout <<"FileName1: " << argv[1] <<endl; | |
3207 | ||
3208 | TopoDS_Shape aShape = DBRep::Get (a[1]); | |
3209 | ||
3210 | OSD::SetSignal(); | |
3211 | Handle(ShapeFix_Wire) aWireFix = new ShapeFix_Wire; | |
3212 | ||
3213 | // map FixStatus - NbSuchStatuses | |
3214 | TColStd_DataMapOfIntegerInteger aStatusNbDMap; | |
3215 | Standard_Integer nbFixed=0, nbOk=0; | |
3216 | ||
3217 | //Begin: STEP 7 | |
3218 | ShapeExtend_Status aStatus=ShapeExtend_OK; | |
3219 | try { | |
3220 | TopExp_Explorer aFaceExplorer(aShape, TopAbs_FACE); | |
3221 | for (; aFaceExplorer.More(); aFaceExplorer.Next()) | |
3222 | { | |
3223 | TopoDS_Shape aFace = aFaceExplorer.Current(); | |
3224 | // loop on wires | |
3225 | TopoDS_Iterator aWireItr(aFace); | |
3226 | for (; aWireItr.More(); aWireItr.Next() ) | |
3227 | { | |
3228 | Standard_Boolean wasOk = Standard_False; | |
3229 | TopoDS_Wire aSrcWire = TopoDS::Wire(aWireItr.Value()); | |
3230 | ||
3231 | aWireFix->Load (aSrcWire); | |
3232 | aWireFix->SetFace (TopoDS::Face(aFace)); | |
3233 | aWireFix->FixReorder(); //correct order is a prerequisite | |
3234 | // fix 3d | |
3235 | if (!aWireFix->FixGaps3d()) | |
3236 | { | |
3237 | // not fixed, why? | |
3238 | aStatus = getStatusGap(aWireFix, Standard_True); | |
3239 | if (aStatus == ShapeExtend_OK) | |
3240 | wasOk = Standard_True; | |
3241 | else | |
3242 | { | |
3243 | // keep 3d fail status | |
3244 | if (aStatusNbDMap.IsBound (aStatus)) | |
3245 | aStatusNbDMap(aStatus)++; | |
3246 | else | |
3247 | aStatusNbDMap.Bind(aStatus,1); | |
3248 | continue; | |
3249 | } | |
3250 | } | |
3251 | ||
3252 | // fix 2d | |
3253 | if (aWireFix->FixGaps2d()) | |
3254 | nbFixed++; | |
3255 | else | |
3256 | { | |
3257 | aStatus = getStatusGap(aWireFix, Standard_False); | |
3258 | if (aStatus == ShapeExtend_OK) | |
3259 | { | |
3260 | if (wasOk) | |
3261 | { | |
3262 | nbOk++; | |
3263 | continue; | |
3264 | } | |
3265 | else | |
3266 | nbFixed++; | |
3267 | } | |
3268 | else | |
3269 | { | |
3270 | // keep 2d fail status | |
3271 | Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL; | |
3272 | if (aStatusNbDMap.IsBound (aStatus2d)) | |
3273 | aStatusNbDMap(aStatus2d)++; | |
3274 | else | |
3275 | aStatusNbDMap.Bind(aStatus2d,1); | |
3276 | continue; | |
3277 | } | |
3278 | } | |
3279 | } | |
3280 | } | |
3281 | //End: STEP 7 | |
3282 | } catch (EXCEPTION) { | |
3283 | di << "Exception is raised = " <<aStatus << "\n"; | |
3284 | return 1; | |
3285 | ||
3286 | } | |
3287 | // report what is done | |
3288 | ||
3289 | if (nbFixed) | |
3290 | { | |
3291 | di <<"Fix_FillGaps_Fixed: nbFixed = "<<nbFixed <<"\n"; | |
3292 | ||
3293 | } | |
3294 | if (nbOk) | |
3295 | { | |
586db386 | 3296 | di << "Fix_FillGaps_NothingToDo\n"; |
2bfe59b6 | 3297 | |
3298 | } | |
3299 | TColStd_DataMapIteratorOfDataMapOfIntegerInteger aStatusItr(aStatusNbDMap); | |
3300 | for (; aStatusItr.More(); aStatusItr.Next()) | |
3301 | { | |
3302 | switch ((ShapeExtend_Status) aStatusItr.Key()) | |
3303 | { | |
3304 | // treat 3d status | |
3305 | case ShapeExtend_FAIL1: | |
3306 | di <<"Fix_FillGaps_3dNoCurveFail, nb failed = "; | |
3307 | break; | |
3308 | case ShapeExtend_FAIL2: | |
3309 | di <<"Fix_FillGaps_3dSomeGapsFail, nb failed = "; | |
3310 | break; | |
3311 | default: | |
3312 | // treat 2d status | |
3313 | switch ((ShapeExtend_Status) (aStatusItr.Key() - ShapeExtend_FAIL)) | |
3314 | { | |
3315 | case ShapeExtend_FAIL1: | |
3316 | di <<"Fix_FillGaps_2dNoPCurveFail, nb failed = "; | |
3317 | break; | |
3318 | case ShapeExtend_FAIL2: | |
3319 | di <<"Fix_FillGaps_2dSomeGapsFail, nb failed = "; | |
3320 | break; | |
3321 | default: | |
3322 | break; | |
3323 | } | |
3324 | } | |
3325 | di <<aStatusItr.Value()<< "\n"; | |
3326 | } | |
3327 | di << ("__________________________________") <<"\n"; | |
3328 | ||
3329 | return 0; | |
3330 | } | |
3331 | ||
c070aa39 | 3332 | //======================================================================= |
3333 | //function : OCC26172 | |
3334 | //purpose : | |
3335 | //======================================================================= | |
3336 | static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
3337 | { | |
3338 | if (theArgNb != 1) | |
3339 | { | |
3340 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
3341 | theDI.PrintHelp (theArgVec[0]); | |
3342 | return 1; | |
3343 | } | |
3344 | ||
3345 | Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext(); | |
3346 | if(anAISContext.IsNull()) | |
3347 | { | |
3348 | std::cerr << "Error: no active view. Please call vinit.\n"; | |
3349 | return 1; | |
3350 | } | |
3351 | ||
3352 | gp_Pnt aStart (100, 100, 100); | |
3353 | gp_Pnt anEnd (300, 400, 600); | |
3354 | BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd); | |
3355 | TopoDS_Edge anEdge = anEdgeBuilder.Edge(); | |
3356 | Handle(AIS_Shape) aTestAISShape = new AIS_Shape (anEdge); | |
3357 | anAISContext->Display (aTestAISShape); | |
3358 | ||
3359 | // 2. activate it in selection modes | |
3360 | TColStd_SequenceOfInteger aModes; | |
3361 | aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX)); | |
3362 | aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_EDGE)); | |
3363 | ||
3364 | anAISContext->OpenLocalContext(); | |
3365 | anAISContext->Deactivate (aTestAISShape); | |
3366 | anAISContext->Load (aTestAISShape, -1, true); | |
3367 | for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt) | |
3368 | { | |
3369 | anAISContext->Activate (aTestAISShape, aModes (anIt)); | |
3370 | } | |
3371 | ||
3372 | // select entities in vertex selection mode | |
3373 | Handle(SelectMgr_Selection) aSelection = aTestAISShape->Selection (aModes (1)); | |
3374 | for (aSelection->Init(); aSelection->More(); aSelection->Next()) | |
3375 | { | |
3376 | Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive(); | |
3377 | if (anEntity.IsNull()) | |
3378 | { | |
3379 | continue; | |
3380 | } | |
3381 | ||
3382 | Handle(SelectMgr_EntityOwner) anOwner = | |
3383 | Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId()); | |
3384 | ||
3385 | if (anOwner.IsNull()) | |
3386 | { | |
3387 | continue; | |
3388 | } | |
3389 | ||
3390 | anAISContext->LocalContext()->AddOrRemoveSelected (anOwner); | |
3391 | } | |
3392 | ||
3393 | // select entities in edge selection mode | |
3394 | aSelection = aTestAISShape->Selection (aModes (2)); | |
3395 | for (aSelection->Init(); aSelection->More(); aSelection->Next()) | |
3396 | { | |
3397 | Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive(); | |
3398 | if (anEntity.IsNull()) | |
3399 | { | |
3400 | continue; | |
3401 | } | |
3402 | ||
3403 | Handle(SelectMgr_EntityOwner) anOwner = | |
3404 | Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId()); | |
3405 | ||
3406 | if (anOwner.IsNull()) | |
3407 | { | |
3408 | continue; | |
3409 | } | |
3410 | ||
3411 | anAISContext->LocalContext()->AddOrRemoveSelected (anOwner); | |
3412 | } | |
3413 | ||
3414 | // deactivate vertex mode and check clearing of outdated selection | |
3415 | anAISContext->Deactivate (aTestAISShape, aModes (1)); | |
3416 | anAISContext->LocalContext()->ClearOutdatedSelection (aTestAISShape, true); | |
3417 | ||
3418 | return 0; | |
3419 | } | |
3420 | ||
e11850fd | 3421 | //======================================================================= |
3422 | //function : OCC26284 | |
3423 | //purpose : | |
3424 | //======================================================================= | |
3425 | static Standard_Integer OCC26284 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
3426 | { | |
3427 | if (theArgNb != 1) | |
3428 | { | |
3429 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
3430 | theDI.PrintHelp (theArgVec[0]); | |
3431 | return 1; | |
3432 | } | |
3433 | ||
3434 | Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext(); | |
3435 | if (anAISContext.IsNull()) | |
3436 | { | |
3437 | std::cerr << "Error: no active view. Please call vinit.\n"; | |
3438 | return 1; | |
3439 | } | |
3440 | ||
3441 | BRepPrimAPI_MakeSphere aSphereBuilder (gp_Pnt (0.0, 0.0, 0.0), 1.0); | |
3442 | Handle(AIS_Shape) aSphere = new AIS_Shape (aSphereBuilder.Shape()); | |
3443 | anAISContext->Display (aSphere); | |
3444 | for (Standard_Integer aChildIdx = 0; aChildIdx < 5; ++aChildIdx) | |
3445 | { | |
3446 | BRepPrimAPI_MakeSphere aBuilder (gp_Pnt (1.0 + aChildIdx, 1.0 + aChildIdx, 1.0 + aChildIdx), 1.0); | |
3447 | Handle(AIS_Shape) aChild = new AIS_Shape (aBuilder.Shape()); | |
3448 | aSphere->AddChild (aChild); | |
3449 | anAISContext->Display (aChild); | |
3450 | } | |
3451 | ||
3452 | anAISContext->RecomputeSelectionOnly (aSphere); | |
3453 | ||
3454 | return 0; | |
3455 | } | |
3456 | ||
9bf3177f | 3457 | #include <IntTools_Context.hxx> |
3458 | #include <GeomAPI_ProjectPointOnSurf.hxx> | |
3459 | ||
3460 | //======================================================================= | |
3461 | //function : xprojponf | |
3462 | //purpose : | |
3463 | //======================================================================= | |
3464 | Standard_Integer xprojponf (Draw_Interpretor& di, | |
3465 | Standard_Integer n, | |
3466 | const char** a) | |
3467 | { | |
3468 | if (n!=3) { | |
3469 | di<<" use xprojponf p f \n"; | |
3470 | return 0; | |
3471 | } | |
3472 | // | |
3473 | gp_Pnt aP, aPS; | |
3474 | TopoDS_Shape aS; | |
3475 | TopoDS_Face aF; | |
3476 | Handle(IntTools_Context) aCtx; | |
3477 | // | |
3478 | DrawTrSurf::GetPoint(a[1], aP); | |
3479 | aS=DBRep::Get(a[2]); | |
3480 | // | |
3481 | if (aS.IsNull()) { | |
3482 | di<<" null shape is not allowed\n"; | |
3483 | return 0; | |
3484 | } | |
3485 | // | |
3486 | if (aS.ShapeType()!=TopAbs_FACE) { | |
3487 | di << a[2] << " not a face\n"; | |
3488 | return 0; | |
3489 | } | |
3490 | // | |
3491 | aCtx=new IntTools_Context; | |
3492 | // | |
3493 | aF=TopoDS::Face(aS); | |
3494 | GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF); | |
3495 | // | |
3496 | aPPS.Perform(aP); | |
3497 | if (!aPPS.IsDone()) { | |
3498 | di<<" projection failed\n"; | |
3499 | return 0; | |
3500 | } | |
3501 | // | |
3502 | aPS=aPPS.NearestPoint(); | |
3503 | di<< " point px " << aPS.X() << " " << aPS.Y() << " " << aPS.Z() << "\n"; | |
3504 | // | |
3505 | return 0; | |
3506 | } | |
3507 | ||
ec26bf88 | 3508 | //======================================================================= |
3509 | //function : OCC25547 | |
3510 | //purpose : | |
3511 | //======================================================================= | |
3512 | #include <BRepMesh_CircleTool.hxx> | |
ec357c5c | 3513 | #include <SelectMgr_EntityOwner.hxx> |
ec26bf88 | 3514 | |
3515 | static Standard_Boolean inspect_point(const gp_XY& thePoint, | |
3516 | const gp_XY& theCenter, | |
3517 | const Standard_Real theRadius) | |
3518 | { | |
3519 | static Standard_Real aPrecision = Precision::PConfusion(); | |
3520 | static Standard_Real aSqPrecision = aPrecision * aPrecision; | |
3521 | const gp_XY aDistVec = thePoint - theCenter; | |
3522 | if (aDistVec.SquareModulus() - (theRadius * theRadius) < aSqPrecision) | |
3523 | return Standard_True; | |
3524 | else | |
3525 | return Standard_False; | |
3526 | } | |
3527 | ||
3528 | static Standard_Integer OCC24923( | |
3529 | Draw_Interpretor& theDI, | |
3530 | Standard_Integer argc, | |
3531 | const char ** argv) | |
3532 | { | |
3533 | srand(static_cast<unsigned int>(time(NULL))); | |
3534 | ||
3535 | const Standard_Real aMaxDeviation = (argc > 1) ? Draw::Atof(argv[1]) : 0.01; | |
3536 | const Standard_Integer aPointsNb = 10000000; | |
3537 | const Standard_Real aMinAngle = 5 * M_PI / 180.; | |
3538 | static Standard_Real aSqPrecision = Precision::PConfusion() * Precision::PConfusion(); | |
3539 | ||
3540 | Standard_Integer aFailedNb = 0; | |
3541 | for (Standard_Integer i = 0; i < aPointsNb; ++i) | |
3542 | { | |
3543 | gp_XY p[3]; | |
3544 | for (Standard_Integer j = 0; j < 3; ++j) | |
3545 | p[j].SetCoord(((Standard_Real)rand())/RAND_MAX, ((Standard_Real)rand())/RAND_MAX); | |
3546 | ||
3547 | // Check that points do not compose degenerated triangle. | |
3548 | gp_XY aVec1 = p[1] - p[0]; | |
3549 | gp_XY aVec2 = p[2] - p[0]; | |
3550 | if (aVec1.SquareModulus() > aSqPrecision && | |
3551 | aVec2.SquareModulus() > aSqPrecision && | |
3552 | (aVec1 ^ aVec2) > aMinAngle) | |
3553 | { | |
3554 | gp_XY aCenter; | |
3555 | Standard_Real aRadius; | |
3556 | if (BRepMesh_CircleTool::MakeCircle(p[0], p[1], p[2], aCenter, aRadius)) | |
3557 | { | |
3558 | if (!inspect_point(p[0], aCenter, aRadius) || | |
3559 | !inspect_point(p[1], aCenter, aRadius) || | |
3560 | !inspect_point(p[2], aCenter, aRadius)) | |
3561 | { | |
3562 | /* theDI << "Missed: " << | |
3563 | "p1=(" << p1.X() << ", " << p1.Y() << "), " << | |
3564 | "p2=(" << p2.X() << ", " << p2.Y() << "), " << | |
3565 | "p3=(" << p3.X() << ", " << p3.Y() << "), " << | |
3566 | "c=(" << aCenter.X() << ", " << aCenter.Y() << "), " << | |
3567 | "r=" << aRadius << "\n";*/ | |
3568 | ||
3569 | ++aFailedNb; | |
3570 | } | |
3571 | ||
3572 | continue; | |
3573 | } | |
3574 | } | |
3575 | ||
3576 | // Ensure that aPointsNb suitable for tests are generated | |
3577 | --i; | |
3578 | } | |
3579 | ||
3580 | const Standard_Real aDeviation = | |
3581 | 1. - (Standard_Real)(aPointsNb - aFailedNb) / (Standard_Real)aPointsNb; | |
3582 | ||
3583 | theDI << "Number of failed cases: " << aFailedNb << " (Total " << aPointsNb << ")\n"; | |
3584 | if (aDeviation > aMaxDeviation) | |
3585 | { | |
3586 | theDI << "Failed. Number of incorrect results is too huge: " << | |
586db386 | 3587 | aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n"; |
ec26bf88 | 3588 | return 1; |
3589 | } | |
3590 | ||
3591 | theDI << "Deviation of incorrect results is: " << | |
586db386 | 3592 | aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n"; |
ec26bf88 | 3593 | theDI << "Test completed\n"; |
3594 | return 0; | |
3595 | } | |
3596 | ||
3ceb4c3c | 3597 | #include <TColGeom_Array1OfBSplineCurve.hxx> |
3598 | #include <TColStd_Array1OfReal.hxx> | |
3599 | #include <TColGeom_HArray1OfBSplineCurve.hxx> | |
3600 | #include <GeomConvert.hxx> | |
3601 | ||
3602 | //======================================================================= | |
3603 | //function : OCC26446 | |
3604 | //purpose : | |
3605 | //======================================================================= | |
3606 | Standard_Integer OCC26446 (Draw_Interpretor& di, | |
3607 | Standard_Integer n, | |
3608 | const char** a) | |
3609 | { | |
3610 | if (n != 4) { | |
586db386 | 3611 | di << "Usage: OCC26446 r c1 c2\n"; |
3ceb4c3c | 3612 | return 1; |
3613 | } | |
3614 | ||
3615 | Handle(Geom_BSplineCurve) aCurve1 = | |
3616 | Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[2])); | |
3617 | Handle(Geom_BSplineCurve) aCurve2 = | |
3618 | Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[3])); | |
3619 | ||
3620 | if (aCurve1.IsNull()) { | |
586db386 | 3621 | di << a[2] << " is not a BSpline curve\n"; |
3ceb4c3c | 3622 | return 1; |
3623 | } | |
3624 | ||
3625 | if (aCurve2.IsNull()) { | |
586db386 | 3626 | di << a[3] << " is not a BSpline curve\n"; |
3ceb4c3c | 3627 | return 1; |
3628 | } | |
3629 | ||
3630 | TColGeom_Array1OfBSplineCurve aCurves (0, 1); | |
3631 | TColStd_Array1OfReal aTolerances (0, 0); | |
3632 | Standard_Real aTolConf = 1.e-3; | |
3633 | Standard_Real aTolClosure = Precision::Confusion(); | |
3634 | Handle(TColGeom_HArray1OfBSplineCurve) aConcatCurves; | |
3635 | Handle(TColStd_HArray1OfInteger) anIndices; | |
3636 | ||
3637 | aCurves.SetValue(0, aCurve1); | |
3638 | aCurves.SetValue(1, aCurve2); | |
3639 | aTolerances.SetValue(0, aTolConf); | |
3640 | ||
3641 | GeomConvert::ConcatC1(aCurves, | |
3642 | aTolerances, | |
3643 | anIndices, | |
3644 | aConcatCurves, | |
3645 | Standard_False, | |
3646 | aTolClosure); | |
3647 | ||
3648 | Handle(Geom_BSplineCurve) aResult = | |
3649 | aConcatCurves->Value(aConcatCurves->Lower()); | |
3650 | ||
3651 | DrawTrSurf::Set(a[1], aResult); | |
3652 | return 0; | |
3653 | } | |
3654 | ||
fac9298e | 3655 | static Standard_Integer OCC26448 (Draw_Interpretor& theDI, Standard_Integer, const char **) |
3656 | { | |
3657 | TColStd_SequenceOfReal aSeq1, aSeq2; | |
3658 | aSeq1.Append(11.); | |
3659 | aSeq1.Prepend (aSeq2); | |
3660 | theDI << "TCollection: 11 -> " << aSeq1.First() << "\n"; | |
3661 | ||
3662 | NCollection_Sequence<Standard_Real> nSeq1, nSeq2; | |
3663 | nSeq1.Append(11.); | |
3664 | nSeq1.Prepend (nSeq2); | |
3665 | theDI << "NCollection: 11 -> " << nSeq1.First() << "\n"; | |
3666 | ||
3667 | theDI << "OK"; | |
3668 | return 0; | |
3669 | } | |
3670 | ||
71316196 | 3671 | //======================================================================= |
3672 | //function : OCC26407 | |
3673 | //purpose : | |
3674 | //======================================================================= | |
3675 | #include <BRepBuilderAPI_MakeWire.hxx> | |
3676 | #include <BRepBuilderAPI_MakeEdge.hxx> | |
3677 | #include <BRepMesh_IncrementalMesh.hxx> | |
3678 | #include <TCollection_AsciiString.hxx> | |
3679 | static Standard_Integer OCC26407 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
3680 | { | |
3681 | if (theArgNb != 2) | |
3682 | { | |
3683 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
3684 | theDI.PrintHelp (theArgVec[0]); | |
3685 | return 1; | |
3686 | } | |
3687 | ||
3688 | // Construct vertices. | |
3689 | std::vector<TopoDS_Vertex> wire_vertices; | |
3690 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.90000000000009094947, 40.6758179230516248026106, 88.5))); | |
3691 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(807.824182076948432040808, 260.599999999999965893949, 88.5))); | |
3692 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(644.174182076948454778176, 424.249999999999943156581, 88.5000000000000142108547))); | |
3693 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(629.978025792618950617907, 424.25, 88.5))); | |
3694 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(793.628025792618700506864, 260.599999999999852207111, 88.5))); | |
3695 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.900000000000204636308, 54.8719742073813492311274, 88.5))); | |
3696 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(218.521974207381418864315, 424.250000000000056843419, 88.5))); | |
3697 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(204.325817923051886282337, 424.249999999999943156581, 88.5))); | |
3698 | ||
3699 | // Construct wire. | |
3700 | BRepBuilderAPI_MakeWire wire_builder; | |
3701 | for (size_t i = 0; i < wire_vertices.size(); i++) | |
3702 | { | |
3703 | const TopoDS_Vertex &v = wire_vertices[i]; | |
3704 | const TopoDS_Vertex &w = wire_vertices[(i+1) % wire_vertices.size()]; | |
3705 | ||
3706 | wire_builder.Add(BRepBuilderAPI_MakeEdge(v, w)); | |
3707 | } | |
3708 | ||
3709 | // Create face and triangulate it. | |
3710 | // Construct face. | |
3711 | gp_Pnt v0 = BRep_Tool::Pnt(wire_vertices[0]); | |
3712 | gp_Pnt v1 = BRep_Tool::Pnt(wire_vertices[1]); | |
3713 | gp_Pnt v2 = BRep_Tool::Pnt(wire_vertices[wire_vertices.size() - 1]); | |
3714 | ||
3715 | gp_Vec face_normal = gp_Vec(v0, v1).Crossed(gp_Vec(v0, v2)); | |
3716 | ||
3717 | TopoDS_Face face = BRepBuilderAPI_MakeFace(gp_Pln(v0, face_normal), wire_builder); | |
3718 | BRepMesh_IncrementalMesh m(face, 1e-7); | |
3719 | ||
3720 | if (m.GetStatusFlags() != 0) | |
3721 | { | |
3722 | theDI << "Failed. Status for face constructed from vertices: " << m.GetStatusFlags() << "\n"; | |
3723 | return 1; | |
3724 | } | |
3725 | DBRep::Set(theArgVec[1], face); | |
3726 | char buf[256]; | |
3727 | sprintf(buf, "isos %s 0", theArgVec[1]); | |
3728 | theDI.Eval(buf); | |
3729 | ||
3730 | sprintf(buf, "triangles %s", theArgVec[1]); | |
3731 | theDI.Eval(buf); | |
3732 | ||
3733 | theDI.Eval("smallview; fit"); | |
3734 | ||
3735 | theDI << "Test completed\n"; | |
3736 | return 0; | |
3737 | } | |
3738 | ||
db6c6404 | 3739 | //======================================================================= |
3740 | //function : OCC26485 | |
3741 | //purpose : | |
3742 | //======================================================================= | |
3743 | #include <Poly.hxx> | |
3744 | static Standard_Integer OCC26485 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
3745 | { | |
3746 | if (theArgNb != 2) | |
3747 | { | |
3748 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
3749 | theDI.PrintHelp (theArgVec[0]); | |
3750 | return 1; | |
3751 | } | |
3752 | ||
3753 | TopoDS_Shape aShape = DBRep::Get(theArgVec[1]); | |
3754 | if (aShape.IsNull()) | |
3755 | { | |
3756 | theDI << "Failed. Null shape\n"; | |
3757 | return 1; | |
3758 | } | |
3759 | ||
3760 | Standard_Boolean isFailed = Standard_False; | |
3761 | TopExp_Explorer aExplorer(aShape, TopAbs_FACE); | |
3762 | for (; aExplorer.More(); aExplorer.Next()) | |
3763 | { | |
3764 | const TopoDS_Face& aFace = TopoDS::Face( aExplorer.Current() ); | |
3765 | TopLoc_Location L = TopLoc_Location(); | |
3766 | const Handle(Poly_Triangulation)& aT = BRep_Tool::Triangulation( aFace , L ); | |
3767 | ||
3768 | if(aT.IsNull()) | |
3769 | continue; | |
3770 | ||
3771 | Poly::ComputeNormals(aT); | |
3772 | const TColgp_Array1OfPnt& aVertices = aT->Nodes(); | |
3773 | const TShort_Array1OfShortReal& aNormals = aT->Normals(); | |
3774 | ||
3775 | // Number of nodes in the triangulation | |
3776 | int aVertexNb = aT->Nodes().Length(); | |
3777 | if (aVertexNb*3 != aNormals.Length()) | |
3778 | { | |
3779 | theDI << "Failed. Different number of normals vs. vertices\n"; | |
3780 | return 1; | |
3781 | } | |
3782 | ||
3783 | // Get each vertex index, checking common vertexes between shapes | |
3784 | for( int i=0; i < aVertexNb; i++ ) | |
3785 | { | |
3786 | gp_Pnt aPoint = aVertices.Value( i+1 ); | |
3787 | gp_Vec aNormal = gp_Vec( | |
3788 | aNormals.Value( i*3 + 1 ), | |
3789 | aNormals.Value( i*3 + 2 ), | |
3790 | aNormals.Value( i*3 + 3 ) ); | |
3791 | ||
3792 | if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1) | |
3793 | { | |
3794 | char buf[256]; | |
3795 | sprintf(buf, "fail_%d", i+1); | |
3796 | theDI << "Failed. Point " << buf << ": " | |
3797 | << aPoint.X() << " " | |
3798 | << aPoint.Y() << " " | |
3799 | << aPoint.Z() << "\n"; | |
3800 | ||
3801 | DrawTrSurf::Set (buf, aPoint); | |
3802 | } | |
3803 | } | |
3804 | } | |
3805 | ||
3806 | theDI << (isFailed ? "Test failed" : "Test completed") << "\n"; | |
3807 | return 0; | |
3808 | } | |
3809 | ||
5a8dc41a | 3810 | //======================================================================= |
3811 | //function : OCC26553 | |
3812 | //purpose : | |
3813 | //======================================================================= | |
3814 | #include <BRepBuilderAPI_MakeWire.hxx> | |
3815 | ||
3816 | static Standard_Integer OCC26553 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv) | |
3817 | { | |
3818 | if (theArgc < 2) | |
3819 | { | |
3820 | theDI << "Error: path to file with shell is missing\n"; | |
3821 | return 1; | |
3822 | } | |
3823 | ||
3824 | BRep_Builder aBuilder; | |
3825 | TopoDS_Shape aShell; | |
3826 | BRepTools::Read(aShell, theArgv[1], aBuilder); | |
3827 | ||
3828 | if (aShell.IsNull()) | |
3829 | { | |
3830 | theDI << "Error: shell not loaded\n"; | |
3831 | return 1; | |
3832 | } | |
3833 | ||
3834 | TopoDS_Edge aPipeEdge = BRepBuilderAPI_MakeEdge (gp_Pnt (0, 0, 0), gp_Pnt (0, 0, 10)); | |
3835 | TopoDS_Wire aPipeWire = BRepBuilderAPI_MakeWire(aPipeEdge).Wire(); | |
3836 | ||
3837 | BRepOffsetAPI_MakePipe aPipeBuilder(aPipeWire, aShell); | |
3838 | if (!aPipeBuilder.IsDone()) | |
3839 | { | |
3840 | theDI << "Error: failed to create pipe\n"; | |
3841 | return 1; | |
3842 | } | |
3843 | ||
3844 | for (TopExp_Explorer aShapeExplorer(aShell, TopAbs_EDGE); aShapeExplorer.More(); aShapeExplorer.Next ()) { | |
3845 | const TopoDS_Shape& aGeneratedShape = aPipeBuilder.Generated(aPipeEdge, aShapeExplorer.Current()); | |
3846 | if (aGeneratedShape.IsNull()) | |
3847 | { | |
3848 | theDI << "Error: null shape\n"; | |
3849 | return 1; | |
3850 | } | |
3851 | } | |
3852 | ||
3853 | theDI << "History returned successfully\n"; | |
3854 | return 0; | |
3855 | } | |
3856 | ||
3bf9a45f | 3857 | //======================================================================= |
3858 | //function : OCC26195 | |
3859 | //purpose : | |
3860 | //======================================================================= | |
3861 | #include <SelectMgr_SelectingVolumeManager.hxx> | |
3862 | #include <BRepBuilderAPI_MakePolygon.hxx> | |
3863 | #include <Geom_CartesianPoint.hxx> | |
3864 | #include <AIS_Line.hxx> | |
3865 | #include <Aspect_Window.hxx> | |
3866 | static Standard_Integer OCC26195 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
3867 | { | |
3868 | if (theArgNb < 3) | |
3869 | { | |
3870 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
3871 | theDI.PrintHelp (theArgVec[0]); | |
3872 | return 1; | |
3873 | } | |
3874 | ||
3875 | if (ViewerTest::GetAISContext().IsNull()) | |
3876 | { | |
3877 | std::cerr << "Error: No opened context!\n"; | |
3878 | return 1; | |
3879 | } | |
3880 | ||
3881 | gp_Pnt2d aPxPnt1, aPxPnt2; | |
3882 | aPxPnt1.SetX (Draw::Atof (theArgVec[1])); | |
3883 | aPxPnt1.SetY (Draw::Atof (theArgVec[2])); | |
3884 | if (theArgNb > 4) | |
3885 | { | |
3886 | aPxPnt2.SetX (Draw::Atof (theArgVec[3])); | |
3887 | aPxPnt2.SetY (Draw::Atof (theArgVec[4])); | |
3888 | } | |
3889 | Standard_Boolean toPrint = Standard_False; | |
3890 | if (theArgNb % 2 == 0) | |
3891 | { | |
3892 | toPrint = Draw::Atoi (theArgVec[theArgNb - 1]); | |
3893 | } | |
3894 | ||
3895 | SelectMgr_SelectingVolumeManager* aMgr = new SelectMgr_SelectingVolumeManager(); | |
3896 | aMgr->SetActiveSelectionType (theArgNb > 4 ? | |
3897 | SelectMgr_SelectingVolumeManager::Box : SelectMgr_SelectingVolumeManager::Point); | |
3898 | aMgr->SetCamera (ViewerTest::CurrentView()->Camera()); | |
3899 | aMgr->SetPixelTolerance (ViewerTest::GetAISContext()->PixelTolerance()); | |
3900 | Standard_Integer aWidth, aHeight; | |
3901 | ViewerTest::CurrentView()->View()->Window()->Size (aWidth, aHeight); | |
3902 | aMgr->SetWindowSize (aWidth, aHeight); | |
3903 | if (theArgNb > 4) | |
3904 | { | |
3905 | aMgr->BuildSelectingVolume (aPxPnt1, aPxPnt2); | |
3906 | } | |
3907 | else | |
3908 | { | |
3909 | aMgr->BuildSelectingVolume (aPxPnt1); | |
3910 | } | |
3911 | const gp_Pnt* aVerts = aMgr->GetVertices(); | |
3912 | gp_Pnt aNearPnt = aMgr->GetNearPnt(); | |
3913 | gp_Pnt aFarPnt = aMgr->GetFarPnt(); | |
3914 | BRepBuilderAPI_MakePolygon aWireBldrs[4]; | |
3915 | ||
3916 | aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z())); | |
3917 | aWireBldrs[0].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z())); | |
3918 | aWireBldrs[0].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z())); | |
3919 | aWireBldrs[0].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z())); | |
3920 | aWireBldrs[0].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z())); | |
3921 | ||
3922 | aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z())); | |
3923 | aWireBldrs[1].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z())); | |
3924 | aWireBldrs[1].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z())); | |
3925 | aWireBldrs[1].Add (gp_Pnt (aVerts[6].X(), aVerts[6].Y(), aVerts[6].Z())); | |
3926 | aWireBldrs[1].Add (gp_Pnt (aVerts[4].X(), aVerts[4].Y(), aVerts[4].Z())); | |
3927 | ||
3928 | aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z())); | |
3929 | aWireBldrs[2].Add (gp_Pnt (aVerts[5].X(), aVerts[5].Y(), aVerts[5].Z())); | |
3930 | aWireBldrs[2].Add (gp_Pnt (aVerts[7].X(), aVerts[7].Y(), aVerts[7].Z())); | |
3931 | aWireBldrs[2].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z())); | |
3932 | aWireBldrs[2].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z())); | |
3933 | ||
3934 | aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z())); | |
3935 | aWireBldrs[3].Add (gp_Pnt (aVerts[1].X(), aVerts[1].Y(), aVerts[1].Z())); | |
3936 | aWireBldrs[3].Add (gp_Pnt (aVerts[3].X(), aVerts[3].Y(), aVerts[3].Z())); | |
3937 | aWireBldrs[3].Add (gp_Pnt (aVerts[2].X(), aVerts[2].Y(), aVerts[2].Z())); | |
3938 | aWireBldrs[3].Add (gp_Pnt (aVerts[0].X(), aVerts[0].Y(), aVerts[0].Z())); | |
3939 | ||
3940 | TopoDS_Compound aComp; | |
3941 | BRep_Builder aCompBuilder; | |
3942 | aCompBuilder.MakeCompound (aComp); | |
3943 | for (Standard_Integer aWireIdx = 0; aWireIdx < 4; ++aWireIdx) | |
3944 | { | |
3945 | aCompBuilder.Add (aComp, aWireBldrs[aWireIdx].Shape()); | |
3946 | } | |
3947 | DBRep::Set ("c", aComp); | |
3948 | ||
3949 | Handle(AIS_InteractiveObject) aCmp = new AIS_Shape (aComp); | |
3950 | aCmp->SetColor (Quantity_NOC_GREEN); | |
3951 | ViewerTest::Display ("c", aCmp, Standard_True, Standard_True); | |
3952 | ||
3953 | Handle(Geom_CartesianPoint) aPnt1 = new Geom_CartesianPoint (aNearPnt); | |
3954 | Handle(Geom_CartesianPoint) aPnt2 = new Geom_CartesianPoint (aFarPnt); | |
3955 | ||
3956 | Handle(AIS_Line) aLine = new AIS_Line (aPnt1, aPnt2); | |
3957 | ViewerTest::Display ("l", aLine, Standard_True, Standard_True); | |
3958 | ||
3959 | if (toPrint) | |
3960 | { | |
3961 | theDI << "Near: " << aNearPnt.X() << " " << aNearPnt.Y() << " " << aNearPnt.Z() << "\n"; | |
3962 | theDI << "Far: " << aFarPnt.X() << " " << aFarPnt.Y() << " " << aFarPnt.Z() << "\n"; | |
3963 | } | |
3964 | ||
3965 | return 0; | |
3966 | } | |
3967 | ||
8a1170ad | 3968 | //======================================================================= |
3969 | //function : OCC26462 | |
3970 | //purpose : | |
3971 | //======================================================================= | |
3972 | static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/) | |
3973 | { | |
3974 | if (ViewerTest::GetAISContext().IsNull()) | |
3975 | { | |
3976 | std::cerr << "Error: No opened context!\n"; | |
3977 | return 1; | |
3978 | } | |
3979 | ||
3980 | BRepPrimAPI_MakeBox aBuilder1 (gp_Pnt (10.0, 10.0, 0.0), 10.0, 10.0, 10.0); | |
3981 | BRepPrimAPI_MakeBox aBuilder2 (10.0, 10.0, 10.0); | |
3982 | Handle(AIS_InteractiveObject) aBox1 = new AIS_Shape (aBuilder1.Shape()); | |
3983 | Handle(AIS_InteractiveObject) aBox2 = new AIS_Shape (aBuilder2.Shape()); | |
3984 | ||
3985 | const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
3986 | aCtx->OpenLocalContext(); | |
3987 | aCtx->Display (aBox1, 0, 2); | |
3988 | aCtx->Display (aBox2, 0, 2); | |
3989 | ViewerTest::CurrentView()->FitAll(); | |
3990 | aCtx->SetWidth (aBox1, 3); | |
3991 | aCtx->SetWidth (aBox2, 3); | |
3992 | ||
3993 | aCtx->MoveTo (305, 322, ViewerTest::CurrentView()); | |
3994 | aCtx->ShiftSelect(); | |
3995 | aCtx->MoveTo (103, 322, ViewerTest::CurrentView()); | |
3996 | aCtx->ShiftSelect(); | |
3997 | if (aCtx->NbSelected() != 0) | |
3998 | { | |
3999 | theDI << "ERROR: no boxes must be selected!\n"; | |
4000 | return 1; | |
4001 | } | |
4002 | ||
4003 | aCtx->SetSelectionSensitivity (aBox1, 2, 5); | |
4004 | ||
4005 | aCtx->MoveTo (305, 322, ViewerTest::CurrentView()); | |
4006 | aCtx->ShiftSelect(); | |
4007 | if (aCtx->NbSelected() != 1) | |
4008 | { | |
4009 | theDI << "ERROR: b1 was not selected\n"; | |
4010 | return 1; | |
4011 | } | |
4012 | aCtx->MoveTo (103, 322, ViewerTest::CurrentView()); | |
4013 | aCtx->ShiftSelect(); | |
4014 | if (aCtx->NbSelected() != 1) | |
4015 | { | |
4016 | theDI << "ERROR: b2 is selected after b1's tolerance increased\n"; | |
4017 | return 1; | |
4018 | } | |
4019 | ||
4020 | return 0; | |
4021 | } | |
4022 | ||
43940380 | 4023 | |
4024 | #include <BRepBuilderAPI_GTransform.hxx> | |
4025 | static Standard_Integer OCC26313(Draw_Interpretor& di,Standard_Integer n,const char** a) | |
4026 | { | |
4027 | if (n <= 1) return 1; | |
4028 | ||
4029 | gp_Trsf T; | |
4030 | gp_GTrsf GT(T); | |
4031 | ||
4032 | gp_Mat rot( 1.0, 0.0, 0.0, | |
4033 | 0.0, 2.0, 0.0, | |
4034 | 0.0, 0.0, 3.0); | |
4035 | ||
4036 | GT.SetVectorialPart(rot); | |
4037 | BRepBuilderAPI_GTransform gtrf(GT); | |
4038 | ||
4039 | TopoDS_Shape aSrcShape = DBRep::Get(a[2]); | |
4040 | if (aSrcShape.IsNull()) { | |
586db386 | 4041 | di << a[2] << " is not a valid shape\n"; |
43940380 | 4042 | return 1; |
4043 | } | |
4044 | ||
4045 | ||
4046 | gtrf.Perform(aSrcShape); | |
4047 | if (gtrf.IsDone()) | |
4048 | { | |
4049 | try | |
4050 | { | |
4051 | DBRep::Set(a[1], gtrf.ModifiedShape(aSrcShape)); | |
4052 | } | |
4053 | catch(Standard_Failure) | |
4054 | { | |
4055 | di << "Error: Exception is thrown\n"; | |
4056 | } | |
4057 | } | |
4058 | else | |
4059 | { | |
4060 | di << "Error: Result is not done\n"; | |
4061 | return 1; | |
4062 | } | |
4063 | ||
4064 | return 0; | |
4065 | } | |
4066 | ||
81b47143 | 4067 | //======================================================================= |
4068 | //function : OCC26525 | |
4069 | //purpose : check number of intersection points | |
4070 | //======================================================================= | |
4071 | #include <BRepAdaptor_Curve.hxx> | |
4072 | #include <BRepAdaptor_Surface.hxx> | |
4073 | #include <BRepAdaptor_HCurve.hxx> | |
4074 | #include <BRepAdaptor_HSurface.hxx> | |
4075 | #include <IntCurveSurface_HInter.hxx> | |
4076 | Standard_Integer OCC26525 (Draw_Interpretor& di, | |
4077 | Standard_Integer n, | |
4078 | const char** a) | |
4079 | { | |
4080 | TopoDS_Shape aS1, aS2; | |
4081 | TopoDS_Edge aE; | |
4082 | TopoDS_Face aF; | |
4083 | ||
4084 | if (n<4) | |
4085 | { | |
4086 | di << " use OCC26525 r edge face \n"; | |
4087 | return 1; | |
4088 | } | |
4089 | ||
4090 | aS1 = DBRep::Get(a[2]); | |
4091 | aS2 = DBRep::Get(a[3]); | |
4092 | ||
4093 | if (aS1.IsNull() || aS2.IsNull()) | |
4094 | { | |
4095 | di << " Null shapes are not allowed \n"; | |
4096 | return 0; | |
4097 | } | |
4098 | if (aS1.ShapeType()!=TopAbs_EDGE) | |
4099 | { | |
4100 | di << " Shape" << a[2] << " should be of type EDGE\n"; | |
4101 | return 0; | |
4102 | } | |
4103 | if (aS2.ShapeType()!=TopAbs_FACE) | |
4104 | { | |
4105 | di << " Shape" << a[3] << " should be of type FACE\n"; | |
4106 | return 0; | |
4107 | } | |
4108 | ||
4109 | aE=TopoDS::Edge(aS1); | |
4110 | aF=TopoDS::Face(aS2); | |
4111 | ||
4112 | char buf[128]; | |
4113 | Standard_Boolean bIsDone; | |
4114 | Standard_Integer i, aNbPoints; | |
4115 | Standard_Real aU, aV, aT; | |
4116 | gp_Pnt aP; | |
4117 | BRepAdaptor_Curve aBAC; | |
4118 | BRepAdaptor_Surface aBAS; | |
4119 | IntCurveSurface_TransitionOnCurve aTC; | |
4120 | IntCurveSurface_HInter aHInter; | |
4121 | ||
4122 | aBAC.Initialize(aE); | |
4123 | aBAS.Initialize(aF); | |
4124 | ||
4125 | Handle(BRepAdaptor_HCurve) aHBAC=new BRepAdaptor_HCurve(aBAC); | |
4126 | Handle(BRepAdaptor_HSurface) aHBAS = new BRepAdaptor_HSurface(aBAS); | |
4127 | ||
4128 | aHInter.Perform(aHBAC, aHBAS); | |
4129 | bIsDone=aHInter.IsDone(); | |
4130 | if (!bIsDone) | |
4131 | { | |
4132 | di << " intersection is not done\n"; | |
4133 | return 0; | |
4134 | } | |
4135 | ||
4136 | aNbPoints=aHInter.NbPoints(); | |
4137 | sprintf (buf, " Number of intersection points found: %d", aNbPoints); | |
4138 | di << buf << "\n"; | |
4139 | for (i=1; i<=aNbPoints; ++i) | |
4140 | { | |
4141 | const IntCurveSurface_IntersectionPoint& aIP=aHInter.Point(i); | |
4142 | aIP.Values(aP, aU, aV, aT, aTC); | |
4143 | // | |
4144 | sprintf (buf, "point %s_%d %lg %lg %lg ", a[1], i, aP.X(), aP.Y(), aP.Z()); | |
4145 | di << buf << "\n"; | |
4146 | } | |
4147 | ||
4148 | return 0; | |
4149 | } | |
4150 | ||
10a4116e | 4151 | //======================================================================= |
4152 | //function : OCC24537 | |
4153 | //purpose : Puts inverted numbers (in the sense of little/big endian inversion) | |
4154 | // from predefined arrays. | |
4155 | //======================================================================= | |
4156 | #include <FSD_BinaryFile.hxx> | |
4157 | ||
4158 | template<int size> | |
4159 | inline const unsigned char* SizeRef (); | |
4160 | ||
4161 | template<> | |
4162 | inline const unsigned char* SizeRef <8> () | |
4163 | { | |
4164 | static const unsigned char aSizeRef[] = { | |
4165 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, | |
4166 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02, | |
4167 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, | |
4168 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04, | |
4169 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05, | |
4170 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06, | |
4171 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07, | |
4172 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08, | |
4173 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09, | |
4174 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; | |
4175 | return aSizeRef; | |
4176 | } | |
4177 | ||
4178 | template<> | |
4179 | inline const unsigned char* SizeRef <4> () | |
4180 | { | |
4181 | static const unsigned char aSizeRef[] = { | |
4182 | 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02, | |
4183 | 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04, | |
4184 | 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06, | |
4185 | 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08, | |
4186 | 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00}; | |
4187 | return aSizeRef; | |
4188 | } | |
4189 | ||
4190 | static Standard_Integer OCC24537( | |
4191 | Draw_Interpretor& theDI, | |
4192 | Standard_Integer argc, | |
4193 | const char ** argv) | |
4194 | { | |
4195 | std::ofstream aF; | |
4196 | if (argc > 1) | |
4197 | { | |
4198 | aF.open(argv[1]); | |
4199 | if (!aF.is_open()) | |
4200 | { | |
4201 | cout << "cannot create file " << argv[1] << endl; | |
4202 | return 1; | |
4203 | } | |
4204 | } | |
4205 | Standard_Boolean isErr = Standard_False; | |
4206 | // 1. InverseInt | |
4207 | const unsigned char anIntRef[] = { | |
4208 | 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02, | |
4209 | 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04, | |
4210 | 0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06, | |
4211 | 0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08, | |
4212 | 0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00}; | |
4213 | Standard_Integer anIntArr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; | |
4214 | if (aF.is_open()) | |
4215 | { | |
4216 | for(int i = 0; i < 10; ++i) | |
4217 | { | |
4218 | Standard_Integer anInv = FSD_BinaryFile::InverseInt(anIntArr[i]); | |
4219 | aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv)); | |
4220 | } | |
4221 | } | |
4222 | else | |
4223 | { | |
4224 | Standard_Integer anInv[10]; | |
4225 | for(int i = 0; i < 10; ++i) | |
4226 | anInv[i] = FSD_BinaryFile::InverseInt(anIntArr[i]); | |
4227 | if (memcmp(anInv, anIntRef, sizeof(anIntRef)) != 0) | |
4228 | { | |
4229 | theDI << "Error: incorrect conversion of an integer value\n"; | |
4230 | isErr = Standard_True; | |
4231 | } | |
4232 | } | |
4233 | ||
4234 | // 1a. Random InverseInt | |
4235 | const unsigned char aRndIntRef[] = { | |
4236 | 0xFF,0xC2,0xF7,0x00,0xFF,0xFF,0xFB,0x2E, | |
4237 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, | |
4238 | 0x00,0x00,0x04,0xD2,0x00,0x00,0x04,0xD3, | |
4239 | 0xFF,0xFF,0xFD,0x1E,0xFF,0xFF,0xFF,0xFB, | |
4240 | 0x00,0x00,0x03,0x8D,0x00,0x3D,0x09,0x00}; | |
4241 | Standard_Integer aRndIntArr[] = {-4000000, -1234, 0, 1, 1234, 1235, -738, -5, 909, 4000000}; | |
4242 | if (aF.is_open()) | |
4243 | { | |
4244 | for(int i = 0; i < 10; ++i) | |
4245 | { | |
4246 | Standard_Integer anInv = FSD_BinaryFile::InverseInt(aRndIntArr[i]); | |
4247 | aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv)); | |
4248 | } | |
4249 | } | |
4250 | else | |
4251 | { | |
4252 | Standard_Integer anInv[10]; | |
4253 | for(int i = 0; i < 10; ++i) | |
4254 | anInv[i] = FSD_BinaryFile::InverseInt(aRndIntArr[i]); | |
4255 | if (memcmp(anInv, aRndIntRef, sizeof(aRndIntRef)) != 0) | |
4256 | { | |
4257 | theDI << "Error: incorrect conversion of a dispersed integer value\n"; | |
4258 | isErr = Standard_True; | |
4259 | } | |
4260 | } | |
4261 | ||
4262 | // 2. InverseReal | |
4263 | const unsigned char aRealRef[] = { | |
4264 | 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, | |
4265 | 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
4266 | 0x40,0x08,0x00,0x00,0x00,0x00,0x00,0x00, | |
4267 | 0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00, | |
4268 | 0x40,0x14,0x00,0x00,0x00,0x00,0x00,0x00, | |
4269 | 0x40,0x18,0x00,0x00,0x00,0x00,0x00,0x00, | |
4270 | 0x40,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, | |
4271 | 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00, | |
4272 | 0x40,0x22,0x00,0x00,0x00,0x00,0x00,0x00, | |
4273 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; | |
4274 | const Standard_Real aRealArr[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0}; | |
4275 | if (aF.is_open()) | |
4276 | { | |
4277 | for(int i = 0; i < 10; ++i) | |
4278 | { | |
4279 | Standard_Real anInv = FSD_BinaryFile::InverseReal(aRealArr[i]); | |
4280 | aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv)); | |
4281 | } | |
4282 | } | |
4283 | else | |
4284 | { | |
4285 | Standard_Real anInv[10]; | |
4286 | for(int i = 0; i < 10; ++i) | |
4287 | anInv[i] = FSD_BinaryFile::InverseReal(aRealArr[i]); | |
4288 | if (memcmp(anInv, aRealRef, sizeof(aRealRef)) != 0) | |
4289 | { | |
4290 | theDI << "Error: incorrect conversion of a real value\n"; | |
4291 | isErr = Standard_True; | |
4292 | } | |
4293 | } | |
4294 | ||
4295 | // 2a. Random InverseReal | |
4296 | const unsigned char aRndRealRef[] = { | |
4297 | 0xFE,0x37,0xE4,0x3C,0x88,0x00,0x75,0x9C, | |
4298 | 0xBE,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95, | |
4299 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
4300 | 0x3E,0x11,0x2E,0x0B,0xE8,0x26,0xD6,0x95, | |
4301 | 0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, | |
4302 | 0x40,0x09,0x21,0xDA,0x45,0x5B,0x53,0xE4, | |
4303 | 0x54,0xB2,0x49,0xAD,0x25,0x94,0xC3,0x7D, | |
4304 | 0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00, | |
4305 | 0xC0,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD, | |
4306 | 0x40,0x23,0xCC,0xCC,0xCC,0xCC,0xCC,0xCD}; | |
4307 | const Standard_Real aRndRealArr[] = {-1e300, -1.e-9, 0., 1.e-9, 1., 3.1415296, 1.e100, 8.0, -9.9, 9.9}; | |
4308 | if (aF.is_open()) | |
4309 | { | |
4310 | for(int i = 0; i < 10; ++i) | |
4311 | { | |
4312 | Standard_Real anInv = FSD_BinaryFile::InverseReal(aRndRealArr[i]); | |
4313 | aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv)); | |
4314 | } | |
4315 | } | |
4316 | else | |
4317 | { | |
4318 | Standard_Real anInv[10]; | |
4319 | for(int i = 0; i < 10; ++i) | |
4320 | anInv[i] = FSD_BinaryFile::InverseReal(aRndRealArr[i]); | |
4321 | if (memcmp(anInv, aRndRealRef, sizeof(aRndRealRef)) != 0) | |
4322 | { | |
4323 | theDI << "Error: incorrect conversion of a dispersed real value\n"; | |
4324 | isErr = Standard_True; | |
4325 | } | |
4326 | } | |
4327 | ||
4328 | // 3. InverseShortReal | |
4329 | const unsigned char aShortRealRef[] = { | |
4330 | 0x3F,0x80,0x00,0x00,0x40,0x00,0x00,0x00, | |
4331 | 0x40,0x40,0x00,0x00,0x40,0x80,0x00,0x00, | |
4332 | 0x40,0xA0,0x00,0x00,0x40,0xC0,0x00,0x00, | |
4333 | 0x40,0xE0,0x00,0x00,0x41,0x00,0x00,0x00, | |
4334 | 0x41,0x10,0x00,0x00,0x00,0x00,0x00,0x00}; | |
4335 | const Standard_ShortReal aShortRealArr[] = { | |
4336 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 0.0f}; | |
4337 | if (aF.is_open()) | |
4338 | { | |
4339 | for(int i = 0; i < 10; ++i) | |
4340 | { | |
4341 | Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]); | |
4342 | aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv)); | |
4343 | } | |
4344 | } | |
4345 | else | |
4346 | { | |
4347 | Standard_ShortReal anInv[10]; | |
4348 | for(int i = 0; i < 10; ++i) | |
4349 | anInv[i] = FSD_BinaryFile::InverseShortReal(aShortRealArr[i]); | |
4350 | if (memcmp(anInv, aShortRealRef, sizeof(aShortRealRef)) != 0) | |
4351 | { | |
4352 | theDI << "Error: incorrect conversion of a short real value\n"; | |
4353 | isErr = Standard_True; | |
4354 | } | |
4355 | } | |
4356 | ||
4357 | // 3a. Random InverseShortReal | |
4358 | const unsigned char aRndShortRealRef[] = { | |
4359 | 0xB0,0x89,0x70,0x5F,0x00,0x00,0x00,0x00, | |
4360 | 0x30,0x89,0x70,0x5F,0x3F,0x80,0x00,0x00, | |
4361 | 0x40,0x49,0x0E,0x56,0xC0,0xD6,0x66,0x66, | |
4362 | 0x40,0xD6,0x66,0x66,0x42,0xC5,0xCC,0xCD, | |
4363 | 0xC2,0xC7,0xCC,0xCD,0x42,0xC7,0xCC,0xCD}; | |
4364 | const Standard_ShortReal aRndShortRealArr[] = { | |
4365 | -1.e-9f, 0.f, 1.e-9f, 1.f, 3.1415f, -6.7f, 6.7f, 98.9f, -99.9f, 99.9f}; | |
4366 | if (aF.is_open()) | |
4367 | { | |
4368 | for(int i = 0; i < 10; ++i) | |
4369 | { | |
4370 | Standard_ShortReal anInv = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]); | |
4371 | aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv)); | |
4372 | } | |
4373 | } | |
4374 | else | |
4375 | { | |
4376 | Standard_ShortReal anInv[10]; | |
4377 | for(int i = 0; i < 10; ++i) | |
4378 | anInv[i] = FSD_BinaryFile::InverseShortReal(aRndShortRealArr[i]); | |
4379 | if (memcmp(anInv, aRndShortRealRef, sizeof(aRndShortRealRef)) != 0) | |
4380 | { | |
4381 | theDI << "Error: incorrect conversion of a dispersed short real value\n"; | |
4382 | isErr = Standard_True; | |
4383 | } | |
4384 | } | |
4385 | ||
4386 | // 4. InverseSize | |
4387 | const Standard_Size aSizeArr[] = {1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul, 8ul, 9ul, 0ul}; | |
4388 | if (aF.is_open()) | |
4389 | { | |
4390 | for(int i = 0; i < 10; ++i) | |
4391 | { | |
4392 | Standard_Size anInv = FSD_BinaryFile::InverseSize(aSizeArr[i]); | |
4393 | aF.write(reinterpret_cast<char*>(&anInv), sizeof(anInv)); | |
4394 | } | |
4395 | } | |
4396 | else | |
4397 | { | |
4398 | Standard_Size anInv[10]; | |
4399 | const unsigned char* aSizeRef = SizeRef<sizeof(Standard_Size)>(); | |
4400 | for(int i = 0; i < 10; ++i) | |
4401 | anInv[i] = FSD_BinaryFile::InverseSize(aSizeArr[i]); | |
4402 | if (memcmp(anInv, aSizeRef, sizeof(Standard_Size)*10) != 0) | |
4403 | { | |
4404 | theDI << "Error: incorrect conversion of a size value\n"; | |
4405 | isErr = Standard_True; | |
4406 | } | |
4407 | } | |
4408 | ||
4409 | if (!aF.is_open() && !isErr) | |
4410 | theDI << "Conversion was done OK"; | |
4411 | if (aF.is_open()) | |
4412 | { | |
4413 | cout << "the file " << argv[1] << " has been created" << endl; | |
4414 | aF.close(); | |
4415 | } | |
4416 | return 0; | |
4417 | } | |
4418 | ||
8cc2a23a | 4419 | |
4420 | #include <TopExp.hxx> | |
4421 | #include <BRepOffsetAPI_DraftAngle.hxx> | |
4422 | #include <vector> | |
4423 | static TopoDS_Shape taper(const TopoDS_Shape &shape, const TopoDS_Face &face_a, const TopoDS_Face &face_b, Standard_Real angle) | |
4424 | { | |
4425 | // Use maximum face-to-taper z-offset. | |
4426 | const gp_Pln neutral_plane(gp_Ax3(gp_Pnt(0.0, 0.0, 140.0), gp_Dir(0.0, 0.0, 1.0))); | |
4427 | ||
4428 | // Draft angle needs to be in radians, and flipped to adhere to our own (arbitrary) draft | |
4429 | // angle definition. | |
4430 | const Standard_Real draft_angle = -(angle / 180.0) * M_PI; | |
4431 | ||
4432 | // Add face to draft. The first argument indicates that all material added/removed during | |
4433 | // drafting is located below the neutral plane | |
4434 | BRepOffsetAPI_DraftAngle drafter(shape); | |
4435 | drafter.Add(face_a, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane); | |
4436 | drafter.Add(face_b, gp_Dir(0.0, 0.0, -1.0), draft_angle, neutral_plane); | |
4437 | drafter.Build(); | |
4438 | ||
4439 | return drafter.Shape(); | |
4440 | } | |
4441 | ||
4442 | static void dumpShapeVertices(const TopoDS_Shape &shape, std::vector<Standard_Real>& coords) | |
4443 | { | |
4444 | TopTools_IndexedMapOfShape shape_vertices; | |
4445 | TopExp::MapShapes(shape, TopAbs_VERTEX, shape_vertices); | |
4446 | ||
4447 | for (Standard_Integer i = 1; i <= shape_vertices.Extent(); i++) | |
4448 | { | |
4449 | gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(shape_vertices(i))); | |
4450 | coords.push_back(p.X()); | |
4451 | coords.push_back(p.Y()); | |
4452 | coords.push_back(p.Z()); | |
4453 | } | |
4454 | } | |
4455 | ||
4456 | static void GetCoords(const Standard_CString& path_to_file, std::vector<Standard_Real>& coords) | |
4457 | { | |
4458 | TopoDS_Shape shape; | |
4459 | BRep_Builder builder; | |
4460 | BRepTools::Read(shape, path_to_file, builder); | |
4461 | TopTools_IndexedMapOfShape shape_faces; | |
4462 | TopExp::MapShapes(shape, TopAbs_FACE, shape_faces); | |
4463 | TopoDS_Face face_a = TopoDS::Face(shape_faces(1)); | |
4464 | TopoDS_Face face_b = TopoDS::Face(shape_faces(5)); | |
4465 | dumpShapeVertices(taper(shape, face_a, face_b, 5.0), coords); | |
4466 | } | |
4467 | ||
4468 | static Standard_Integer OCC26396 (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv) | |
4469 | { | |
4470 | if (theArgc < 2) | |
4471 | { | |
4472 | theDI << "Error: path to file is missing\n"; | |
4473 | return 1; | |
4474 | } | |
4475 | ||
4476 | const int maxInd = 50; | |
4477 | ||
4478 | std::vector<Standard_Real> ref_coords; | |
4479 | ref_coords.reserve(100); | |
4480 | Standard_Boolean Stat = Standard_True; | |
4481 | ||
4482 | GetCoords(theArgv[1], ref_coords); | |
4483 | ||
4484 | std::vector<Standard_Real> coords; | |
4485 | coords.reserve(100); | |
4486 | for (int i = 1; i < maxInd; i++) | |
4487 | { | |
4488 | GetCoords(theArgv[1], coords); | |
4489 | if (coords.size() != ref_coords.size()) | |
4490 | { | |
4491 | Stat = Standard_False; | |
4492 | break; | |
4493 | } | |
4494 | for (size_t j = 0; j < coords.size(); j++) | |
4495 | if (Abs(ref_coords[j] - coords[j]) > RealEpsilon()) | |
4496 | { | |
4497 | Stat = Standard_False; | |
4498 | break; | |
4499 | } | |
4500 | coords.clear(); | |
4501 | } | |
4502 | if (!Stat) | |
4503 | theDI << "Error: unstable results"; | |
4504 | else | |
4505 | theDI << "test OK"; | |
4506 | ||
4507 | return 0; | |
4508 | } | |
4509 | ||
d0fcf95a | 4510 | //======================================================================= |
4511 | //function : OCC26750 | |
4512 | //purpose : | |
4513 | //======================================================================= | |
4514 | static Standard_Integer OCC26750( Draw_Interpretor& theDI, | |
4515 | Standard_Integer /*theNArg*/, | |
4516 | const char ** /*theArgVal*/) | |
4517 | { | |
4518 | const gp_Vec2d aVec1(1.0, 0.0); | |
4519 | const gp_Vec2d aVec2(0.0, -1.0); | |
4520 | ||
4521 | if(aVec1.IsNormal(aVec2, Precision::Angular())) | |
4522 | { | |
4523 | theDI << "gp_Vec2d OK. Vectors are normal.\n"; | |
4524 | } | |
4525 | else | |
4526 | { | |
4527 | theDI << "Error in gp_Vec2d. Vectors should be normal.\n"; | |
4528 | } | |
4529 | ||
4530 | const gp_Dir2d aD1(1.0, 0.0); | |
4531 | const gp_Dir2d aD2(0.0, -1.0); | |
4532 | ||
4533 | if(aD1.IsNormal(aD2, Precision::Angular())) | |
4534 | { | |
4535 | theDI << "gp_Dir2d OK. Vectors are normal.\n"; | |
4536 | } | |
4537 | else | |
4538 | { | |
4539 | theDI << "Error in gp_Dir2d. Vectors should be normal.\n"; | |
4540 | } | |
4541 | ||
4542 | return 0; | |
4543 | } | |
4544 | ||
0b4abfb9 | 4545 | //======================================================================= |
4546 | //function : OCC26746 | |
4547 | //purpose : Checks if coefficients of the torus are computed properly. | |
4548 | //======================================================================= | |
4549 | #include <Geom_ToroidalSurface.hxx> | |
92efcf78 | 4550 | #include <Geom_BSplineCurve.hxx> |
0b4abfb9 | 4551 | static Standard_Integer OCC26746( |
4552 | Draw_Interpretor& theDI, | |
4553 | Standard_Integer theNArg, | |
4554 | const char ** theArgVal) | |
4555 | { | |
4556 | if(theNArg < 2) | |
4557 | { | |
4558 | theDI << "Use: OCC26746 torus [toler NbCheckedPoints]\n"; | |
4559 | return 1; | |
4560 | } | |
4561 | ||
4562 | const Handle(Geom_ToroidalSurface) aGtor = | |
4563 | Handle(Geom_ToroidalSurface)::DownCast(DrawTrSurf::GetSurface(theArgVal[1])); | |
4564 | ||
4565 | const Standard_Real aToler = (theNArg >= 3)? Draw::Atof(theArgVal[2]) : 1.0e-7; | |
4566 | const Standard_Integer aNbPntsMax = (theNArg >= 4)? Draw::Atoi(theArgVal[3]) : 5; | |
4567 | ||
4568 | const Standard_Integer aLowIndex = 5; | |
4569 | const Standard_Real aStep = 2.0*M_PI/aNbPntsMax; | |
4570 | ||
4571 | TColStd_Array1OfReal anArrCoeffs(aLowIndex, aLowIndex+34); | |
4572 | aGtor->Torus().Coefficients(anArrCoeffs); | |
4573 | ||
4574 | Standard_Real aUpar = 0.0, aVpar = 0.0; | |
4575 | for(Standard_Integer aUind = 0; aUind <= aNbPntsMax; aUind++) | |
4576 | { | |
4577 | for(Standard_Integer aVind = 0; aVind <= aNbPntsMax; aVind++) | |
4578 | { | |
4579 | const gp_Pnt aPt(aGtor->Value(aUpar, aVpar)); | |
4580 | const Standard_Real aX1 = aPt.X(); | |
4581 | const Standard_Real aX2 = aX1*aX1; | |
4582 | const Standard_Real aX3 = aX2*aX1; | |
4583 | const Standard_Real aX4 = aX2*aX2; | |
4584 | const Standard_Real aY1 = aPt.Y(); | |
4585 | const Standard_Real aY2 = aY1*aY1; | |
4586 | const Standard_Real aY3 = aY2*aY1; | |
4587 | const Standard_Real aY4 = aY2*aY2; | |
4588 | const Standard_Real aZ1 = aPt.Z(); | |
4589 | const Standard_Real aZ2 = aZ1*aZ1; | |
4590 | const Standard_Real aZ3 = aZ2*aZ1; | |
4591 | const Standard_Real aZ4 = aZ2*aZ2; | |
4592 | ||
4593 | Standard_Integer i = aLowIndex; | |
4594 | ||
4595 | Standard_Real aDelta = anArrCoeffs(i++) * aX4; //1 | |
4596 | aDelta+= anArrCoeffs(i++) * aY4; //2 | |
4597 | aDelta+= anArrCoeffs(i++) * aZ4; //3 | |
4598 | aDelta+= anArrCoeffs(i++) * aX3 * aY1; //4 | |
4599 | aDelta+= anArrCoeffs(i++) * aX3 * aZ1; //5 | |
4600 | aDelta+= anArrCoeffs(i++) * aY3 * aX1; //6 | |
4601 | aDelta+= anArrCoeffs(i++) * aY3 * aZ1; //7 | |
4602 | aDelta+= anArrCoeffs(i++) * aZ3 * aX1; //8 | |
4603 | aDelta+= anArrCoeffs(i++) * aZ3 * aY1; //9 | |
4604 | aDelta+= anArrCoeffs(i++) * aX2 * aY2; //10 | |
4605 | aDelta+= anArrCoeffs(i++) * aX2 * aZ2; //11 | |
4606 | aDelta+= anArrCoeffs(i++) * aY2 * aZ2; //12 | |
4607 | aDelta+= anArrCoeffs(i++) * aX2 * aY1 * aZ1; //13 | |
4608 | aDelta+= anArrCoeffs(i++) * aX1 * aY2 * aZ1; //14 | |
4609 | aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ2; //15 | |
4610 | aDelta+= anArrCoeffs(i++) * aX3; //16 | |
4611 | aDelta+= anArrCoeffs(i++) * aY3; //17 | |
4612 | aDelta+= anArrCoeffs(i++) * aZ3; //18 | |
4613 | aDelta+= anArrCoeffs(i++) * aX2 * aY1; //19 | |
4614 | aDelta+= anArrCoeffs(i++) * aX2 * aZ1; //20 | |
4615 | aDelta+= anArrCoeffs(i++) * aY2 * aX1; //21 | |
4616 | aDelta+= anArrCoeffs(i++) * aY2 * aZ1; //22 | |
4617 | aDelta+= anArrCoeffs(i++) * aZ2 * aX1; //23 | |
4618 | aDelta+= anArrCoeffs(i++) * aZ2 * aY1; //24 | |
4619 | aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ1; //25 | |
4620 | aDelta+= anArrCoeffs(i++) * aX2; //26 | |
4621 | aDelta+= anArrCoeffs(i++) * aY2; //27 | |
4622 | aDelta+= anArrCoeffs(i++) * aZ2; //28 | |
4623 | aDelta+= anArrCoeffs(i++) * aX1 * aY1; //29 | |
4624 | aDelta+= anArrCoeffs(i++) * aX1 * aZ1; //30 | |
4625 | aDelta+= anArrCoeffs(i++) * aY1 * aZ1; //31 | |
4626 | aDelta+= anArrCoeffs(i++) * aX1; //32 | |
4627 | aDelta+= anArrCoeffs(i++) * aY1; //33 | |
4628 | aDelta+= anArrCoeffs(i++) * aZ1; //34 | |
4629 | aDelta+= anArrCoeffs(i++); //35 | |
4630 | ||
4631 | if(Abs(aDelta) > aToler) | |
4632 | { | |
4633 | theDI << "(" << aUpar << ", " << aVpar << "): Error in torus coefficients computation (Delta = " << aDelta << ").\n"; | |
4634 | } | |
4635 | else | |
4636 | { | |
4637 | theDI << "(" << aUpar << ", " << aVpar << "): OK (Delta = " << aDelta << ").\n"; | |
4638 | } | |
4639 | ||
4640 | aVpar = (aVind == aNbPntsMax)? 2.0*M_PI : aVpar + aStep; | |
4641 | } | |
4642 | ||
4643 | aVpar = 0.0; | |
4644 | aUpar = (aUind == aNbPntsMax)? 2.0*M_PI : aUpar + aStep; | |
4645 | } | |
4646 | ||
4647 | return 0; | |
4648 | } | |
4649 | ||
a3f6f591 | 4650 | DEFINE_STANDARD_HANDLE(QABugs_VertexFilter, SelectMgr_Filter) |
badc9305 | 4651 | class QABugs_VertexFilter: public SelectMgr_Filter |
4652 | { | |
4653 | public: | |
4654 | Standard_EXPORT QABugs_VertexFilter() : SelectMgr_Filter() {} | |
4655 | ||
4656 | Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)&) const | |
4657 | { | |
4658 | return Standard_False; | |
4659 | } | |
4660 | }; | |
4661 | ||
4662 | //======================================================================= | |
4663 | //function : BUC26658 | |
4664 | //purpose : Checks selection in the context after using a selection filter | |
4665 | //======================================================================= | |
4666 | static Standard_Integer BUC26658 (Draw_Interpretor& theDI, | |
4667 | Standard_Integer /*theNArg*/, | |
4668 | const char ** theArgVal) | |
4669 | { | |
4670 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
4671 | if(aContext.IsNull()) { | |
4672 | theDI << "use 'vinit' command before " << theArgVal[0] << "\n"; | |
4673 | return 1; | |
4674 | } | |
4675 | ||
4676 | TopoDS_Shape aBoxShape = BRepPrimAPI_MakeBox(20,20,20).Shape(); | |
4677 | Handle(AIS_Shape) anAISIO = new AIS_Shape(aBoxShape); | |
4678 | ||
4679 | // visualization of the box in the local mode with possibility to | |
4680 | // select box vertices | |
4681 | aContext->OpenLocalContext(); | |
4682 | ||
4683 | int aDispMode = 0;// wireframe | |
4684 | anAISIO->SetDisplayMode(aDispMode); | |
4685 | aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed); | |
4686 | theDI.Eval(" vfit"); | |
4687 | ||
4688 | aContext->Load(anAISIO, -1, true); /// load allowing decomposition | |
4689 | aContext->Deactivate(anAISIO); | |
4690 | aContext->Activate(anAISIO, AIS_Shape::SelectionMode(TopAbs_VERTEX), false); | |
4691 | aContext->UpdateCurrentViewer(); | |
4692 | ||
4693 | // select a point on the box | |
4694 | Handle(V3d_View) myV3dView = ViewerTest::CurrentView(); | |
4695 | double Xv,Yv; | |
4696 | myV3dView->Project(20,20,0,Xv,Yv); | |
4697 | Standard_Integer Xp,Yp; | |
4698 | myV3dView->Convert(Xv,Yv,Xp,Yp); | |
4699 | ||
4700 | aContext->MoveTo(Xp,Yp, myV3dView); | |
4701 | aContext->Select(); | |
4702 | bool aHasSelected = false; | |
4703 | for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) { | |
4704 | Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive(); | |
4705 | if (!anIO.IsNull()) { | |
4706 | const TopoDS_Shape aShape = aContext->SelectedShape(); | |
4707 | if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) | |
4708 | aHasSelected = true; | |
4709 | } | |
4710 | } | |
4711 | if (aHasSelected) | |
4712 | cout << "has selected vertex : OK" << endl; | |
4713 | else { | |
4714 | theDI << "has selected vertex : bugged - Faulty\n"; | |
4715 | return 1; | |
4716 | } | |
4717 | // filter to deny any selection in the viewer | |
4718 | Handle(QABugs_VertexFilter) aFilter = new QABugs_VertexFilter(); | |
4719 | aContext->AddFilter(aFilter); | |
4720 | ||
4721 | // update previous selection by hand | |
4722 | aContext->LocalContext()->ClearOutdatedSelection(anAISIO, true); | |
4723 | ||
4724 | // check that there are no selected vertices | |
4725 | aContext->Select(); | |
4726 | aHasSelected = false; | |
4727 | for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) { | |
4728 | Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive(); | |
4729 | if (!anIO.IsNull()) { | |
4730 | const TopoDS_Shape aShape = aContext->SelectedShape(); | |
4731 | if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) | |
4732 | aHasSelected = true; | |
4733 | } | |
4734 | } | |
4735 | if (!aHasSelected) cout << "has no selected vertex after filter : OK" << endl; | |
4736 | else { | |
4737 | theDI << "has no selected vertex after filter : bugged - Faulty\n"; | |
4738 | return 1; | |
4739 | } | |
4740 | ||
4741 | return 0; | |
4742 | } | |
4743 | ||
325e442b | 4744 | //======================================================================= |
4745 | //function : OCC26945_open | |
4746 | //purpose : Opens local context and activates given standard selection mode | |
4747 | //======================================================================= | |
4748 | static Standard_Integer OCC26945_open (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv) | |
4749 | { | |
4750 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); | |
4751 | if (aCtx.IsNull()) | |
4752 | { | |
4753 | std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n"; | |
4754 | return 1; | |
4755 | } | |
4756 | ||
4757 | if (theArgc < 2) | |
4758 | { | |
4759 | std::cout << "Not enough arguments. See usage:\n"; | |
4760 | theDI.PrintHelp (theArgv[0]); | |
4761 | return 1; | |
4762 | } | |
4763 | ||
4764 | const TopAbs_ShapeEnum aSelType = AIS_Shape::SelectionType (Draw::Atoi (theArgv[1])); | |
4765 | Standard_Integer aLocalCtxIdx = aCtx->OpenLocalContext(); | |
4766 | aCtx->ActivateStandardMode (aSelType); | |
4767 | theDI << aLocalCtxIdx; | |
4768 | ||
4769 | return 0; | |
4770 | } | |
4771 | ||
4772 | //======================================================================= | |
4773 | //function : OCC26945_close | |
4774 | //purpose : Closes local context with the id given | |
4775 | //======================================================================= | |
4776 | static Standard_Integer OCC26945_close (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv) | |
4777 | { | |
4778 | const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); | |
4779 | if (aCtx.IsNull()) | |
4780 | { | |
4781 | std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n"; | |
4782 | return 1; | |
4783 | } | |
4784 | ||
4785 | if (theArgc < 2) | |
4786 | { | |
4787 | std::cout << "Not enough arguments. See usage:\n"; | |
4788 | theDI.PrintHelp (theArgv[0]); | |
4789 | return 1; | |
4790 | } | |
4791 | ||
4792 | const Standard_Integer aCtxToClose = Draw::Atoi (theArgv[1]); | |
4793 | aCtx->CloseLocalContext (aCtxToClose); | |
4794 | ||
4795 | return 0; | |
4796 | } | |
4797 | ||
1cd84fee | 4798 | void QABugs::Commands_19(Draw_Interpretor& theCommands) { |
1365140b | 4799 | const char *group = "QABugs"; |
7fd59977 | 4800 | |
dda67c1c | 4801 | Handle(QABugs_HandleClass) aClassPtr = new QABugs_HandleClass(); |
4802 | theCommands.Add ("OCC24202_1", "Test Handle-based procedure", | |
4803 | __FILE__, aClassPtr, &QABugs_HandleClass::HandleProc, group); | |
4804 | NCollection_Handle<QABugs_NHandleClass> aNClassPtr = new QABugs_NHandleClass(); | |
4805 | theCommands.Add ("OCC24202_2", "Test NCollection_Handle-based procedure", | |
4806 | __FILE__, aNClassPtr, &QABugs_NHandleClass::NHandleProc, group); | |
4807 | ||
7fd59977 | 4808 | theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group); |
f6f03db9 | 4809 | theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group); |
1365140b RL |
4810 | theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group); |
4811 | theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group); | |
e6aad0ee | 4812 | theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group); |
5d1833ef | 4813 | theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group); |
e187cc0a | 4814 | theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group); |
bead40f2 | 4815 | theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group); |
06be28a4 | 4816 | theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group); |
1ef32e96 RL |
4817 | theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group); |
4818 | theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group); | |
1939140c | 4819 | theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group); |
05d7de53 | 4820 | 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 | 4821 | theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group); |
29cb310a | 4822 | theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group); |
788cbaf4 | 4823 | theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group); |
89d8607f | 4824 | theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group); |
ab2db9a5 | 4825 | theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group); |
e6c9f595 | 4826 | theCommands.Add ("OCC23972", "OCC23972", __FILE__, OCC23972, group); |
e3096dec | 4827 | theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group); |
05d7de53 | 4828 | theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group); |
1b7602c8 | 4829 | theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group); |
69fd2d1b | 4830 | theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group); |
2cd138b8 | 4831 | theCommands.Add ("OCC24622", "OCC24622 texture={1D|2D}\n Tests sourcing of 1D/2D pixmaps for AIS_TexturedShape", __FILE__, OCC24622, group); |
4832 | theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group); | |
d01cc61d | 4833 | theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group); |
a73267f2 | 4834 | theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group); |
8696d65d | 4835 | theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group); |
7a7e8cf1 | 4836 | theCommands.Add ("OCC23951", "OCC23951 path to saved step file", __FILE__, OCC23951, group); |
4837 | theCommands.Add ("OCC24931", "OCC24931 path to saved xml file", __FILE__, OCC24931, group); | |
c764e804 | 4838 | theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group); |
1fa7cb8c | 4839 | theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group); |
5493d334 | 4840 | theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group); |
b6c0b841 RL |
4841 | theCommands.Add ("OCC24925", |
4842 | "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]" | |
4843 | "\nOCAF persistence without setting environment variables", | |
4844 | __FILE__, OCC24925, group); | |
e4b5c45a | 4845 | theCommands.Add ("OCC23010", "OCC23010 STEP_file", __FILE__, OCC23010, group); |
a967f104 | 4846 | theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group); |
c7b59798 | 4847 | theCommands.Add ("OCC24826,", "This test performs simple saxpy test.\n Usage: OCC24826 length", __FILE__, OCC24826, group); |
4a350f94 | 4848 | theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group); |
ab860031 | 4849 | theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group); |
c6037065 | 4850 | theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group); |
058f130e | 4851 | theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group); |
54a16ee4 | 4852 | theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group); |
5e452c37 | 4853 | theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group); |
6fb3418e | 4854 | theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group); |
c088aa93 | 4855 | theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group); |
ee6bb37b | 4856 | theCommands.Add ("OCC25545", |
4857 | "no args; tests data race when concurrently accessing \n" | |
4858 | "\t\tTopLoc_Location::Transformation()", | |
4859 | __FILE__, OCC25545, group); | |
d315303d | 4860 | theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group); |
2bfe59b6 | 4861 | theCommands.Add ("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group); |
c070aa39 | 4862 | theCommands.Add ("OCC26172", "OCC26172", __FILE__, OCC26172, group); |
9bf3177f | 4863 | theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group); |
ec26bf88 | 4864 | theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group); |
ec81011f | 4865 | theCommands.Add ("OCC26139", "OCC26139 [-boxsize value] [-boxgrid value] [-compgrid value]", __FILE__, OCC26139, group); |
e11850fd | 4866 | theCommands.Add ("OCC26284", "OCC26284", __FILE__, OCC26284, group); |
3ceb4c3c | 4867 | theCommands.Add ("OCC26446", "OCC26446 r c1 c2", __FILE__, OCC26446, group); |
fac9298e | 4868 | theCommands.Add ("OCC26448", "OCC26448: check method Prepend() of sequence", __FILE__, OCC26448, group); |
71316196 | 4869 | theCommands.Add ("OCC26407", "OCC26407 result_name", __FILE__, OCC26407, group); |
db6c6404 | 4870 | theCommands.Add ("OCC26485", "OCC26485 shape", __FILE__, OCC26485, group); |
5a8dc41a | 4871 | theCommands.Add ("OCC26553", "OCC26553 file_path", __FILE__, OCC26553, group); |
3bf9a45f | 4872 | theCommands.Add ("OCC26195", |
4873 | "OCC26195: x1_pix y1_pix [x2_pix y2_pix] [toPrintPixelCoord 0|1]" | |
4874 | "\n\t\t: Draws rectangular selecting frustum defined by point selection in pixel coordinates" | |
4875 | "\n\t\t: [x1_pix, y1_pix] or rectangular selection in pixel coordinates [x1_pix, y1_pix," | |
4876 | "\n\t\t: x2_pix, y2_pix]." | |
4877 | "\n\t\t: [toPrintPixelCoord 0|1] - prints 3d projection of pixel coordinate or center of" | |
4878 | "\n\t\t: selecting rectangle onto near and far view frustum planes", | |
4879 | __FILE__, OCC26195, group); | |
8a1170ad | 4880 | theCommands.Add ("OCC26462", |
4881 | "OCC26462: Checks the ability to manage sensitivity of a particular selection mode in local context", | |
4882 | __FILE__, OCC26462, group); | |
43940380 | 4883 | |
4884 | theCommands.Add ("OCC26313", "OCC26313 result shape", __FILE__, OCC26313, group); | |
8cc2a23a | 4885 | theCommands.Add ("OCC26396", "OCC26396 shape_file_path", __FILE__, OCC26396, group); |
81b47143 | 4886 | theCommands.Add ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group); |
43940380 | 4887 | |
10a4116e | 4888 | theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group); |
d0fcf95a | 4889 | theCommands.Add ("OCC26750", "OCC26750", __FILE__, OCC26750, group); |
4890 | ||
0b4abfb9 | 4891 | theCommands.Add ("OCC26746", "OCC26746 torus [toler NbCheckedPoints] ", __FILE__, OCC26746, group); |
4892 | ||
badc9305 | 4893 | theCommands.Add ("BUC26658", "BUC26658 unexpected selection in the context using a selection filter", __FILE__, BUC26658, group); |
325e442b | 4894 | theCommands.Add ("OCC26945_open", |
4895 | "OCC26945 selectionModeToActivate" | |
4896 | "\n\t\t: Opens a new local context with selectionModeToActivate activated." | |
4897 | "\n\t\t: Prints the ID of newely opened local context in case of success.", | |
4898 | __FILE__, OCC26945_open, group); | |
4899 | theCommands.Add ("OCC26945_close", | |
4900 | "OCC26945 localCtxToClose" | |
4901 | "\n\t\t: Closes local context with the ID localCtxToClose", | |
4902 | __FILE__, OCC26945_close, group); | |
badc9305 | 4903 | |
7fd59977 | 4904 | return; |
4905 | } |