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