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