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