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