Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2002-05-21 |
2 | // Created by: QA Admin | |
973c2be1 | 3 | // Copyright (c) 2002-2014 OPEN CASCADE SAS |
b311480e | 4 | // |
973c2be1 | 5 | // This file is part of Open CASCADE Technology software library. |
b311480e | 6 | // |
d5f74e42 | 7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
11 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 12 | // |
973c2be1 | 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. | |
b311480e | 15 | |
1cd84fee | 16 | #include <QABugs.hxx> |
7fd59977 | 17 | |
f376ac72 | 18 | #include <AIS_InteractiveContext.hxx> |
c070aa39 | 19 | #include <AIS_LocalContext.hxx> |
a6dee93d | 20 | #include <AIS_Shape.hxx> |
431d0f18 | 21 | #include <BRepAlgoAPI_Cut.hxx> |
6d0e6be5 | 22 | #include <BRepOffsetAPI_MakePipe.hxx> |
c2ae831c | 23 | #include <BRepPrimAPI_MakeBox.hxx> |
24 | #include <BRepPrimAPI_MakeSphere.hxx> | |
6d0e6be5 | 25 | #include <DBRep.hxx> |
26 | #include <Draw_Interpretor.hxx> | |
27 | #include <DrawTrSurf.hxx> | |
28 | #include <GCE2d_MakeSegment.hxx> | |
29 | #include <Geom2d_TrimmedCurve.hxx> | |
30 | #include <GeomFill_Trihedron.hxx> | |
31 | #include <Graphic3d_ArrayOfTriangles.hxx> | |
32 | #include <gp_Ax1.hxx> | |
33 | #include <gp_Pnt2d.hxx> | |
34 | #include <gp_Quaternion.hxx> | |
35 | #include <Image_Color.hxx> | |
36 | #include <Image_PixMap.hxx> | |
dda67c1c | 37 | #include <NCollection_Handle.hxx> |
d09dda09 | 38 | #include <NCollection_IncAllocator.hxx> |
6d0e6be5 | 39 | #include <NCollection_Map.hxx> |
40 | #include <OSD_Parallel.hxx> | |
41 | #include <OSD_PerfMeter.hxx> | |
42 | #include <OSD_Timer.hxx> | |
43 | #include <Precision.hxx> | |
44 | #include <Prs3d_ShadingAspect.hxx> | |
45 | #include <Prs3d_Text.hxx> | |
badc9305 | 46 | #include <SelectMgr_Filter.hxx> |
05d7de53 | 47 | #include <Standard_Version.hxx> |
6d0e6be5 | 48 | #include <StdSelect_BRepOwner.hxx> |
49 | #include <TCollection_HAsciiString.hxx> | |
50 | #include <TopExp_Explorer.hxx> | |
51 | #include <TopoDS_Shape.hxx> | |
52 | #include <V3d_View.hxx> | |
53 | #include <ViewerTest.hxx> | |
6fe96f84 | 54 | #include <XmlDrivers_DocumentRetrievalDriver.hxx> |
55 | #include <XmlDrivers_DocumentStorageDriver.hxx> | |
0f3d1d7c | 56 | #include <TDataStd_Real.hxx> |
00af0ebb | 57 | #include <Standard_Atomic.hxx> |
05d7de53 | 58 | |
6d0e6be5 | 59 | #include <cstdio> |
60 | #include <cmath> | |
61 | #include <iostream> | |
62 | ||
29cb310a | 63 | #define QCOMPARE(val1, val2) \ |
64 | di << "Checking " #val1 " == " #val2 << \ | |
65 | ((val1) == (val2) ? ": OK\n" : ": Error\n") | |
d2786814 | 66 | |
7fd59977 | 67 | static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
68 | { | |
69 | if ( argc != 4) { | |
586db386 | 70 | di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d\n"; |
7fd59977 | 71 | return 1; |
72 | } | |
73 | ||
74 | gp_Pnt2d P1, P2; | |
75 | if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) { | |
586db386 | 76 | di << "ERROR OCC230: " << argv[2] << " is not Pnt2d\n"; |
7fd59977 | 77 | return 1; |
78 | } | |
79 | if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) { | |
586db386 | 80 | di << "ERROR OCC230: " << argv[3] << " is not Pnt2d\n"; |
7fd59977 | 81 | return 1; |
82 | } | |
83 | ||
84 | GCE2d_MakeSegment MakeSegment(P1,P2); | |
85 | Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value(); | |
86 | DrawTrSurf::Set(argv[1], TrimmedCurve); | |
87 | return 0; | |
88 | } | |
89 | ||
f6f03db9 | 90 | static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
91 | { | |
92 | gp_Pnt p(0, 0, 2); | |
93 | ||
94 | gp_Trsf t1, t2; | |
95 | t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267); | |
96 | t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880); | |
97 | ||
98 | gp_Trsf tComp = t2 * t1; | |
99 | ||
100 | gp_Pnt p1(10, 3, 4); | |
101 | gp_Pnt p2 = p1.Transformed(tComp); | |
102 | gp_Pnt p3 = p1.Transformed(t1); | |
103 | p3.Transform(t2); | |
104 | ||
105 | // points must be equal | |
106 | if ( ! p2.IsEqual(p3, Precision::Confusion()) ) | |
586db386 | 107 | di << "ERROR OCC23361: equivalent transformations does not produce equal points\n"; |
f6f03db9 | 108 | else |
586db386 | 109 | di << "OCC23361: OK\n"; |
f6f03db9 | 110 | |
111 | return 0; | |
112 | } | |
113 | ||
c2ae831c | 114 | static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/) |
115 | { | |
116 | OSD_PerfMeter aPM("TestMeter",0); | |
117 | OSD_Timer aTM; | |
118 | ||
119 | // run some operation in cycle for about 2 seconds to have good values of times to compare | |
120 | int count = 0; | |
121 | printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n"); | |
122 | for (; aTM.ElapsedTime() < 2.; count++) | |
123 | { | |
124 | aPM.Start(); | |
125 | aTM.Start(); | |
126 | ||
b3a7aa39 | 127 | // do some operation that will take considerable time compared with time of starting / stopping timers |
c2ae831c | 128 | BRepPrimAPI_MakeBox aBox (10., 10., 10.); |
129 | BRepPrimAPI_MakeSphere aSphere (10.); | |
431d0f18 | 130 | BRepAlgoAPI_Cut aCutter (aBox.Shape(), aSphere.Shape()); |
c2ae831c | 131 | |
132 | aTM.Stop(); | |
133 | aPM.Stop(); | |
134 | } | |
135 | ||
136 | int aNbEnters = 0; | |
3510db62 | 137 | Standard_Real aPerfMeter_CPUtime = 0., aTimer_CPUTime = 0., aS; |
138 | Standard_Integer aM, aH; | |
139 | aTM.Show(aS, aM, aH, aTimer_CPUTime); | |
c2ae831c | 140 | |
141 | perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime); | |
3510db62 | 142 | perf_init_meter("TestMeter"); |
c2ae831c | 143 | |
3510db62 | 144 | Standard_Real aTimeDiff = (fabs(aTimer_CPUTime - aPerfMeter_CPUtime) / aTimer_CPUTime); |
c2ae831c | 145 | |
146 | printf("\nMeasurement results (%d cycles):\n", count); | |
3510db62 | 147 | printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer CPU time: %lf\n", |
148 | aPerfMeter_CPUtime, aTimer_CPUTime); | |
c2ae831c | 149 | printf("Time delta is: %.3lf %%\n", aTimeDiff * 100); |
150 | ||
151 | if (aTimeDiff > 0.2) | |
152 | di << "OCC23237: Error: too much difference between CPU and elapsed times"; | |
153 | else if (aNbEnters != count) | |
154 | di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles"; | |
155 | else | |
156 | di << "OCC23237: OK"; | |
157 | ||
158 | return 0; | |
159 | } | |
160 | ||
1365140b RL |
161 | class IncrementerDecrementer |
162 | { | |
163 | public: | |
164 | IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive) | |
165 | {} | |
c7b59798 | 166 | void operator() (const size_t) const |
1365140b | 167 | { |
c7b59798 | 168 | if ( myPositive ) |
169 | Standard_Atomic_Increment(myVal); | |
170 | else | |
171 | Standard_Atomic_Decrement(myVal); | |
1365140b RL |
172 | } |
173 | private: | |
174 | Standard_Integer* myVal; | |
c7b59798 | 175 | Standard_Boolean myPositive; |
1365140b | 176 | }; |
1365140b | 177 | |
1365140b RL |
178 | static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
179 | { | |
180 | int aSum = 0; | |
181 | ||
182 | //check returned value | |
183 | QCOMPARE (Standard_Atomic_Decrement (&aSum), -1); | |
184 | QCOMPARE (Standard_Atomic_Increment (&aSum), 0); | |
185 | QCOMPARE (Standard_Atomic_Increment (&aSum), 1); | |
186 | QCOMPARE (Standard_Atomic_Increment (&aSum), 2); | |
187 | // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0); | |
188 | // QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1); | |
189 | ||
190 | //check atomicity | |
191 | aSum = 0; | |
192 | const int N = 1 << 24; //big enough to ensure concurrency | |
193 | ||
194 | //increment | |
c7b59798 | 195 | OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, true)); |
1365140b RL |
196 | QCOMPARE (aSum, N); |
197 | ||
198 | //decrement | |
c7b59798 | 199 | OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, false)); |
1365140b RL |
200 | QCOMPARE (aSum, 0); |
201 | ||
202 | return 0; | |
203 | } | |
204 | ||
e6aad0ee | 205 | #include <TDocStd_Application.hxx> |
e6aad0ee RL |
206 | #include <TDocStd_Document.hxx> |
207 | #include <XCAFDoc_ShapeTool.hxx> | |
208 | #include <XCAFDoc_DocumentTool.hxx> | |
209 | #include <TDF_Label.hxx> | |
210 | #include <TDataStd_Name.hxx> | |
6fe96f84 | 211 | #include <DDocStd.hxx> |
e6aad0ee | 212 | |
773f53f1 | 213 | static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/) |
e6aad0ee | 214 | { |
6fe96f84 | 215 | Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); |
e6aad0ee RL |
216 | Handle(TDocStd_Document) aDoc; |
217 | anApp->NewDocument ("XmlXCAF", aDoc); | |
218 | QCOMPARE (!aDoc.IsNull(), Standard_True); | |
219 | ||
220 | Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main()); | |
221 | ||
222 | //check default value | |
223 | Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming(); | |
224 | QCOMPARE (aValue, Standard_True); | |
225 | ||
226 | //true | |
227 | XCAFDoc_ShapeTool::SetAutoNaming (Standard_True); | |
228 | TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape(); | |
229 | TDF_Label aLabel = aShTool->AddShape (aShape); | |
230 | Handle(TDataStd_Name) anAttr; | |
231 | QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True); | |
232 | ||
233 | //false | |
234 | XCAFDoc_ShapeTool::SetAutoNaming (Standard_False); | |
235 | aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape(); | |
236 | aLabel = aShTool->AddShape (aShape); | |
237 | QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True); | |
238 | ||
239 | //restore | |
240 | XCAFDoc_ShapeTool::SetAutoNaming (aValue); | |
241 | ||
242 | return 0; | |
243 | } | |
244 | ||
5d1833ef | 245 | #include <ExprIntrp_GenExp.hxx> |
246 | Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
247 | { | |
248 | ||
249 | if (argc != 3) { | |
250 | di << "Usage : " << argv[0] << " string nb\n"; | |
251 | return 1; | |
252 | } | |
253 | ||
254 | TCollection_AsciiString aToken = argv[1]; | |
255 | Standard_Integer aNb = atoi(argv[2]); | |
256 | ||
257 | Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create(); | |
258 | for (Standard_Integer i=0; i < aNb; i++) | |
259 | { | |
260 | aGen->Process(aToken); | |
261 | Handle(Expr_GeneralExpression) aExpr = aGen->Expression(); | |
262 | } | |
263 | ||
264 | return 0; | |
265 | } | |
266 | ||
35e08fe8 | 267 | Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
e187cc0a | 268 | { |
269 | gp_Mat M0; | |
270 | di << "M0 = " | |
271 | << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}" | |
272 | << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}" | |
273 | << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"; | |
274 | return 0; | |
275 | } | |
276 | ||
bead40f2 | 277 | #include <TopoDS_Face.hxx> |
278 | #include <TopoDS_Face.hxx> | |
279 | #include <TopoDS.hxx> | |
280 | #include <BRepBuilderAPI_Transform.hxx> | |
281 | #include <BRepExtrema_DistShapeShape.hxx> | |
282 | #include <BRepTools.hxx> | |
283 | ||
f24125b9 | 284 | static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di) |
bead40f2 | 285 | { |
286 | BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN); | |
287 | if(!distShapeShape.IsDone()) { | |
288 | di <<"Distance ShapeShape is Not Done\n"; | |
289 | return Standard_False; | |
290 | } | |
291 | ||
292 | if(distShapeShape.Value() > 0.01) { | |
293 | di << "Wrong Dist = " <<distShapeShape.Value() << "\n"; | |
294 | return Standard_False; | |
295 | } else | |
296 | di << "Dist0 = " <<distShapeShape.Value() <<"\n"; | |
297 | ||
298 | ////////////////////////////////////////////////////////////////////////// | |
299 | /// First Flip Y | |
300 | const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970); | |
301 | const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970); | |
302 | ||
303 | gp_Vec2d mirrorVector1(axis1P1,axis1P2); | |
304 | ||
305 | gp_Trsf2d mirror1; | |
306 | mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1)); | |
307 | ||
308 | BRepBuilderAPI_Transform transformer1(mirror1); | |
309 | transformer1.Perform(originalWire); | |
310 | if(!transformer1.IsDone()) { | |
586db386 | 311 | di << "Not Done1 \n"; |
bead40f2 | 312 | return Standard_False; |
313 | } | |
346cf025 | 314 | TopoDS_Shape step1ModifiedShape = transformer1.ModifiedShape(originalWire); |
bead40f2 | 315 | |
316 | BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN); | |
317 | if(!distShapeShape1.IsDone()) | |
318 | return Standard_False; | |
319 | if(distShapeShape1.Value() > 0.01) { | |
320 | di << "Dist = " <<distShapeShape1.Value() <<"\n"; | |
321 | return Standard_False; | |
322 | } else | |
323 | di << "Dist1 = " <<distShapeShape1.Value() <<"\n"; | |
324 | ||
325 | ////////////////////////////////////////////////////////////////////////// | |
326 | /// Second flip Y | |
327 | transformer1.Perform(step1ModifiedShape); | |
328 | if(!transformer1.IsDone()) { | |
329 | di << "Not Done1 \n"; | |
330 | return Standard_False; | |
331 | } | |
346cf025 | 332 | TopoDS_Shape step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape); |
bead40f2 | 333 | |
334 | //This is identity matrix for values but for type is gp_Rotation ?! | |
335 | gp_Trsf2d mirror11 = mirror1; | |
336 | mirror11.PreMultiply(mirror1); | |
337 | ||
338 | BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN); | |
339 | if(!distShapeShape2.IsDone()) | |
340 | return Standard_False; | |
341 | ||
342 | //This last test case give error (the value is 1008.8822038689706) | |
343 | if(distShapeShape2.Value() > 0.01) { | |
344 | di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n"; | |
345 | Standard_Integer N = distShapeShape2.NbSolution(); | |
346 | di << "Nb = " <<N <<"\n"; | |
347 | for (Standard_Integer i=1;i <= N;i++) | |
348 | di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n"; | |
349 | return Standard_False; | |
350 | } | |
351 | di << "Distance2 = " <<distShapeShape2.Value() <<"\n"; | |
352 | ||
353 | return Standard_True; | |
354 | } | |
355 | static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a) | |
356 | { | |
357 | ||
358 | if (n != 3) { | |
359 | di <<"OCC23774: invalid number of input parameters\n"; | |
360 | return 1; | |
361 | } | |
362 | ||
363 | const char *ns1 = (a[1]), *ns2 = (a[2]); | |
364 | TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2)); | |
365 | if (S1.IsNull() || S2.IsNull()) { | |
366 | di <<"OCC23774: Null input shapes\n"; | |
367 | return 1; | |
368 | } | |
369 | const TopoDS_Face& aFace = TopoDS::Face(S1); | |
370 | if(!OCC23774Test(aFace, S2, di)) | |
371 | di << "Something is wrong\n"; | |
372 | ||
373 | return 0; | |
374 | } | |
375 | ||
1ef32e96 RL |
376 | #include <GeomConvert_ApproxSurface.hxx> |
377 | #include <Geom_BSplineSurface.hxx> | |
378 | #include <Draw.hxx> | |
379 | #include <OSD_Thread.hxx> | |
1ef32e96 | 380 | |
7a5f1202 | 381 | struct GeomConvertTest_Data |
382 | { | |
383 | Standard_Integer nbupoles; | |
384 | Handle(Geom_Surface) surf; | |
1ef32e96 RL |
385 | }; |
386 | ||
7a5f1202 | 387 | static Standard_Address GeomConvertTest (Standard_Address data) |
1ef32e96 | 388 | { |
7a5f1202 | 389 | GeomConvertTest_Data* info = (GeomConvertTest_Data*)data; |
390 | ||
391 | GeomConvert_ApproxSurface aGAS (info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1); | |
392 | if (!aGAS.IsDone()) { | |
393 | cout << "Error: ApproxSurface is not done!" << endl; | |
caaeed1b | 394 | return 0; |
7a5f1202 | 395 | } |
396 | const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface(); | |
397 | if (aBSurf.IsNull()) { | |
398 | cout << "Error: BSplineSurface is not created!" << endl; | |
caaeed1b | 399 | return 0; |
7a5f1202 | 400 | } |
401 | cout << "Number of UPoles:" << aBSurf->NbUPoles(); | |
402 | if (aBSurf->NbUPoles() == info->nbupoles) | |
403 | { | |
404 | cout << ": OK" << endl; | |
405 | return data; // any non-null pointer | |
406 | } | |
407 | else | |
408 | { | |
409 | cout << ": Error, must be " << info->nbupoles << endl; | |
410 | return 0; | |
411 | } | |
1ef32e96 RL |
412 | } |
413 | ||
414 | static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
415 | { | |
7a5f1202 | 416 | if (argc != 3) { |
417 | cout << "Error: invalid number of arguments" << endl; | |
418 | return 1; | |
419 | } | |
420 | ||
421 | struct GeomConvertTest_Data aStorage; | |
422 | aStorage.nbupoles = Draw::Atoi(argv[1]); | |
423 | aStorage.surf = DrawTrSurf::GetSurface(argv[2]); | |
424 | if (aStorage.surf.IsNull()) | |
425 | { | |
426 | cout << "Error: " << argv[2] << " is not a DRAW surface!" << endl; | |
427 | return 0; | |
428 | } | |
429 | ||
430 | // start conversion in several threads | |
431 | const int NBTHREADS = 100; | |
432 | OSD_Thread aThread[NBTHREADS]; | |
433 | for (int i=0; i < NBTHREADS; i++) | |
434 | { | |
435 | aThread[i].SetFunction (GeomConvertTest); | |
436 | if (!aThread[i].Run(&aStorage)) | |
437 | di << "Error: Cannot start thread << " << i << "\n"; | |
438 | } | |
439 | ||
440 | // check results | |
441 | for (int i=0; i < NBTHREADS; i++) | |
442 | { | |
443 | Standard_Address aResult = 0; | |
444 | if (!aThread[i].Wait(aResult)) | |
445 | di << "Error: Failed waiting for thread << " << i << "\n"; | |
446 | if (!aResult) | |
447 | di << "Error: wrong number of poles in thread " << i << "!\n"; | |
448 | } | |
449 | ||
450 | return 0; | |
1ef32e96 | 451 | } |
d2786814 | 452 | |
1ef32e96 | 453 | #include <GeomInt_IntSS.hxx> |
1ef32e96 | 454 | |
7a5f1202 | 455 | struct GeomIntSSTest_Data |
456 | { | |
457 | Standard_Integer nbsol; | |
458 | Handle(Geom_Surface) surf1, surf2; | |
1ef32e96 | 459 | }; |
7a5f1202 | 460 | |
461 | static Standard_Address GeomIntSSTest (Standard_Address data) | |
1ef32e96 | 462 | { |
7a5f1202 | 463 | GeomIntSSTest_Data* info = (GeomIntSSTest_Data*)data; |
464 | GeomInt_IntSS anInter; | |
465 | anInter.Perform (info->surf1, info->surf2, Precision::Confusion(), Standard_True); | |
466 | if (!anInter.IsDone()) { | |
467 | cout << "An intersection is not done!" << endl; | |
468 | return 0; | |
469 | } | |
470 | ||
471 | cout << "Number of Lines:" << anInter.NbLines(); | |
472 | if (anInter.NbLines() == info->nbsol) | |
473 | { | |
474 | cout << ": OK" << endl; | |
475 | return data; // any non-null pointer | |
476 | } | |
477 | else | |
478 | { | |
479 | cout << ": Error, must be " << info->nbsol << endl; | |
480 | return 0; | |
481 | } | |
1ef32e96 RL |
482 | } |
483 | ||
484 | static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
485 | { | |
7a5f1202 | 486 | if (argc != 4) { |
487 | cout << "Error: invalid number of arguments" << endl; | |
488 | return 1; | |
489 | } | |
490 | ||
491 | struct GeomIntSSTest_Data aStorage; | |
492 | aStorage.nbsol = Draw::Atoi(argv[1]); | |
493 | aStorage.surf1 = DrawTrSurf::GetSurface(argv[2]); | |
494 | aStorage.surf2 = DrawTrSurf::GetSurface(argv[3]); | |
495 | if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull()) | |
496 | { | |
497 | cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" << endl; | |
498 | return 0; | |
499 | } | |
500 | ||
501 | // start conversion in several threads | |
502 | const int NBTHREADS = 100; | |
503 | OSD_Thread aThread[NBTHREADS]; | |
504 | for (int i=0; i < NBTHREADS; i++) | |
505 | { | |
506 | aThread[i].SetFunction (GeomIntSSTest); | |
507 | if (!aThread[i].Run(&aStorage)) | |
508 | di << "Error: Cannot start thread << " << i << "\n"; | |
509 | } | |
510 | ||
511 | // check results | |
512 | for (int i=0; i < NBTHREADS; i++) | |
513 | { | |
514 | Standard_Address aResult = 0; | |
515 | if (!aThread[i].Wait(aResult)) | |
516 | di << "Error: Failed waiting for thread << " << i << "\n"; | |
517 | if (!aResult) | |
518 | di << "Error: wrong number of intersections in thread " << i << "!\n"; | |
519 | } | |
520 | ||
521 | return 0; | |
1ef32e96 RL |
522 | } |
523 | ||
524 | #include <Geom_SurfaceOfRevolution.hxx> | |
06be28a4 RL |
525 | static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) |
526 | { | |
527 | if (argc < 2) { | |
586db386 | 528 | di<<"Usage: " << argv[0] << " invalid number of arguments\n"; |
06be28a4 RL |
529 | return 1; |
530 | } | |
531 | ||
532 | Standard_Integer ucontinuity = 1; | |
533 | Standard_Integer vcontinuity = 1; | |
534 | Standard_Boolean iscnu = false; | |
535 | Standard_Boolean iscnv = false; | |
536 | ||
537 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]); | |
538 | ||
539 | QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu); | |
540 | QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv); | |
541 | ||
542 | return 0; | |
543 | } | |
544 | ||
1939140c | 545 | #include <gp_Ax1.hxx> |
546 | #include <gp_Ax22d.hxx> | |
547 | #include <Geom_Plane.hxx> | |
548 | #include <Geom2d_Circle.hxx> | |
549 | #include <Geom2d_TrimmedCurve.hxx> | |
550 | #include <BRepBuilderAPI_MakeEdge.hxx> | |
551 | #include <BRepPrimAPI_MakeRevol.hxx> | |
552 | #include <Geom2d_OffsetCurve.hxx> | |
553 | ||
554 | static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
555 | { | |
556 | // Check the command arguments | |
557 | if ( argc != 1 ) | |
558 | { | |
586db386 | 559 | di << "Error: " << argv[0] << " - invalid number of arguments\n"; |
1939140c | 560 | di << "Usage: type help " << argv[0] << "\n"; |
561 | return 1; // TCL_ERROR | |
562 | } | |
563 | ||
564 | gp_Ax1 RotoAx( gp::Origin(), gp::DZ() ); | |
565 | gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() ); | |
566 | Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() ); | |
567 | ||
586db386 | 568 | di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>\n"; |
569 | di << "-----------------------------------------------------------------------\n"; | |
1939140c | 570 | |
571 | Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0); | |
572 | Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0); | |
573 | TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane); | |
574 | ||
575 | DBRep::Set("e1", E1); | |
576 | ||
577 | BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx); | |
578 | TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() ); | |
579 | ||
580 | DBRep::Set("f1", F1); | |
581 | ||
586db386 | 582 | di << "Result: f1\n"; |
1939140c | 583 | |
586db386 | 584 | di << "<<<< Preparing sample surface of revolution based on offset curve >>>>\n"; |
585 | di << "-----------------------------------------------------------------------\n"; | |
1939140c | 586 | |
587 | Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5); | |
588 | TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane); | |
589 | ||
590 | DBRep::Set("e2", E2); | |
591 | ||
592 | BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx); | |
593 | TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() ); | |
594 | ||
595 | DBRep::Set("f2", F2); | |
596 | ||
586db386 | 597 | di << "Result: f2\n"; |
1939140c | 598 | |
599 | return 0; | |
600 | } | |
601 | ||
2e9fd4bc | 602 | #include <Geom_Curve.hxx> |
603 | #include <Geom_Surface.hxx> | |
604 | #include <Precision.hxx> | |
605 | #include <ShapeConstruct_ProjectCurveOnSurface.hxx> | |
606 | //======================================================================= | |
607 | //function : OCC24008 | |
608 | //purpose : | |
609 | //======================================================================= | |
610 | static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
611 | { | |
612 | if (argc != 3) { | |
586db386 | 613 | di << "Usage: " << argv[0] << " invalid number of arguments\n"; |
2e9fd4bc | 614 | return 1; |
615 | } | |
616 | Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]); | |
617 | Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]); | |
618 | if (aCurve.IsNull()) { | |
586db386 | 619 | di << "Curve was not read\n"; |
2e9fd4bc | 620 | return 1; |
621 | } | |
622 | if (aSurf.IsNull()) { | |
586db386 | 623 | di << "Surface was not read\n"; |
2e9fd4bc | 624 | return 1; |
625 | } | |
626 | ShapeConstruct_ProjectCurveOnSurface aProj; | |
627 | aProj.Init (aSurf, Precision::Confusion()); | |
628 | try { | |
629 | Handle(Geom2d_Curve) aPCurve; | |
630 | aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve); | |
631 | if (aPCurve.IsNull()) { | |
586db386 | 632 | di << "PCurve was not created\n"; |
2e9fd4bc | 633 | return 1; |
634 | } | |
635 | } catch (...) { | |
586db386 | 636 | di << "Exception was caught\n"; |
2e9fd4bc | 637 | } |
638 | return 0; | |
639 | } | |
640 | ||
470ebb43 | 641 | #include <GeomAdaptor_Surface.hxx> |
642 | #include <Draw.hxx> | |
643 | //======================================================================= | |
644 | //function : OCC23945 | |
645 | //purpose : | |
646 | //======================================================================= | |
647 | ||
35e08fe8 | 648 | static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a) |
470ebb43 | 649 | { |
650 | if (n < 5) return 1; | |
651 | ||
652 | Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]); | |
653 | if (aS.IsNull()) return 1; | |
654 | ||
655 | GeomAdaptor_Surface GS(aS); | |
656 | ||
657 | Standard_Real U = Draw::Atof(a[2]); | |
658 | Standard_Real V = Draw::Atof(a[3]); | |
659 | ||
660 | Standard_Boolean DrawPoint = ( n%3 == 2); | |
661 | if ( DrawPoint) n--; | |
662 | ||
663 | gp_Pnt P; | |
664 | if (n >= 13) { | |
665 | gp_Vec DU,DV; | |
666 | if (n >= 22) { | |
667 | gp_Vec D2U,D2V,D2UV; | |
668 | GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV); | |
669 | Draw::Set(a[13],D2U.X()); | |
670 | Draw::Set(a[14],D2U.Y()); | |
671 | Draw::Set(a[15],D2U.Z()); | |
672 | Draw::Set(a[16],D2V.X()); | |
673 | Draw::Set(a[17],D2V.Y()); | |
674 | Draw::Set(a[18],D2V.Z()); | |
675 | Draw::Set(a[19],D2UV.X()); | |
676 | Draw::Set(a[20],D2UV.Y()); | |
677 | Draw::Set(a[21],D2UV.Z()); | |
678 | } | |
679 | else | |
680 | GS.D1(U,V,P,DU,DV); | |
681 | ||
682 | Draw::Set(a[7],DU.X()); | |
683 | Draw::Set(a[8],DU.Y()); | |
684 | Draw::Set(a[9],DU.Z()); | |
685 | Draw::Set(a[10],DV.X()); | |
686 | Draw::Set(a[11],DV.Y()); | |
687 | Draw::Set(a[12],DV.Z()); | |
688 | } | |
689 | else | |
690 | GS.D0(U,V,P); | |
691 | ||
692 | if ( n > 6) { | |
693 | Draw::Set(a[4],P.X()); | |
694 | Draw::Set(a[5],P.Y()); | |
695 | Draw::Set(a[6],P.Z()); | |
696 | } | |
697 | if ( DrawPoint) { | |
698 | DrawTrSurf::Set(a[n],P); | |
699 | } | |
700 | ||
701 | return 0; | |
702 | } | |
703 | ||
29cb310a | 704 | //======================================================================= |
705 | //function : OCC11758 | |
706 | //purpose : | |
707 | //======================================================================= | |
498ce76b | 708 | static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**) |
29cb310a | 709 | { |
710 | if (n != 1) return 1; | |
711 | ||
712 | const char* theStr = "0123456789"; | |
713 | Standard_Integer i, j; | |
714 | for ( i = 0; i < 5; ++i ) { | |
715 | // TCollection_AsciiString(const Standard_CString astring) | |
716 | TCollection_AsciiString a(theStr+i); | |
717 | // IsEqual (const Standard_CString other)const | |
718 | //assert( a == theStr+i ); | |
719 | QCOMPARE ( a , theStr+i ); | |
720 | ||
721 | //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen ) | |
722 | TCollection_AsciiString b(theStr+i, 3); | |
723 | //assert( b.Length() == 3 ); | |
724 | //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 ); | |
725 | //assert( strlen( b.ToCString() ) == 3 ); | |
726 | QCOMPARE ( b.Length() , 3 ); | |
727 | QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 ); | |
728 | QCOMPARE ( b.Length() , 3 ); | |
729 | ||
730 | //TCollection_AsciiString(const Standard_Integer aValue) | |
731 | TCollection_AsciiString c(i); | |
732 | //assert( c.IsIntegerValue() ); | |
733 | //assert( c.IntegerValue() == i ); | |
734 | QCOMPARE ( c.IsIntegerValue() , Standard_True ); | |
735 | QCOMPARE ( c.IntegerValue() , i ); | |
736 | ||
737 | //TCollection_AsciiString(const Standard_Real aValue) | |
738 | TCollection_AsciiString d( 0.1*i ); | |
739 | //assert( d.IsRealValue() ); | |
740 | //assert( TCollection_AsciiString(3.3) == "3.3"); | |
741 | QCOMPARE ( d.IsRealValue() , Standard_True ); | |
742 | QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" ); | |
743 | ||
744 | //TCollection_AsciiString(const TCollection_AsciiString& astring) | |
745 | TCollection_AsciiString e(d); | |
746 | //assert( e == d ); | |
747 | //assert( e.Length() == d.Length() ); | |
748 | //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 ); | |
749 | QCOMPARE ( e ,d ); | |
750 | QCOMPARE ( e.Length() , d.Length() ); | |
751 | QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 ); | |
752 | ||
753 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
754 | // const Standard_Character other ) | |
755 | TCollection_AsciiString f(e,'\a'); | |
756 | //assert( f.Length() == e.Length() + 1 ); | |
757 | //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 ); | |
758 | //assert( f.Value( f.Length() ) == '\a'); | |
759 | QCOMPARE ( f.Length() , e.Length() + 1 ); | |
760 | QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 ); | |
761 | QCOMPARE ( f.Value( f.Length() ) , '\a' ); | |
762 | ||
763 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
764 | // const Standard_CString other ) | |
765 | TCollection_AsciiString g(f, theStr); | |
766 | //assert( g.Length() == f.Length() + strlen( theStr )); | |
767 | //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 ); | |
768 | //assert( g.Search( theStr ) == f.Length() + 1 ); | |
769 | QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) ); | |
770 | QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 ); | |
771 | QCOMPARE ( g.Search( theStr ) , f.Length() + 1 ); | |
772 | ||
773 | // TCollection_AsciiString(const TCollection_AsciiString& astring , | |
774 | // const TCollection_AsciiString& other ) | |
775 | TCollection_AsciiString h(d,a); | |
776 | //assert( h.Length() == d.Length() + a.Length() ); | |
777 | //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 ); | |
778 | //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 ); | |
779 | QCOMPARE ( h.Length() , d.Length() + a.Length() ); | |
780 | QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 ); | |
781 | QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 ); | |
782 | ||
783 | // AssignCat(const Standard_CString other) | |
784 | c.AssignCat( a.ToCString() ); | |
785 | //assert( c.Length() == 1 + a.Length() ); | |
786 | //assert( c.Search( a ) == 2 ); | |
787 | QCOMPARE ( c.Length() , 1 + a.Length() ); | |
788 | QCOMPARE ( c.Search( a ) , 2 ); | |
789 | ||
790 | // AssignCat(const TCollection_AsciiString& other) | |
791 | Standard_Integer dl = d.Length(); | |
792 | d.AssignCat( a ); | |
793 | //assert( d.Length() == dl + a.Length() ); | |
794 | //assert( d.Search( a ) == dl + 1 ); | |
795 | QCOMPARE ( d.Length() , dl + a.Length() ); | |
796 | QCOMPARE ( d.Search( a ) , dl + 1 ); | |
797 | ||
798 | // Capitalize() | |
799 | TCollection_AsciiString capitalize("aBC"); | |
800 | capitalize.Capitalize(); | |
801 | //assert( capitalize == "Abc" ); | |
802 | QCOMPARE ( capitalize , "Abc" ); | |
803 | ||
804 | // Copy(const Standard_CString fromwhere) | |
805 | d = theStr+i; | |
806 | //assert( d == theStr+i ); | |
807 | QCOMPARE ( d , theStr+i ); | |
808 | ||
809 | // Copy(const TCollection_AsciiString& fromwhere) | |
810 | d = h; | |
811 | // IsEqual (const TCollection_AsciiString& other)const | |
812 | //assert( d == h ); | |
813 | QCOMPARE ( d , h ); | |
814 | ||
815 | // Insert(const Standard_Integer where, const Standard_CString what) | |
816 | dl = d.Length(); | |
817 | d.Insert( 2, theStr ); | |
818 | //assert( d.Length() == dl + strlen( theStr )); | |
819 | //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 ); | |
820 | QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) ); | |
821 | QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 ); | |
822 | ||
823 | //Insert(const Standard_Integer where,const Standard_Character what) | |
824 | d = theStr; | |
825 | d.Insert( i+1, 'i' ); | |
826 | //assert( d.Length() == strlen( theStr ) + 1 ); | |
827 | //assert( d.Value( i+1 ) == 'i'); | |
828 | //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 ); | |
829 | QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 ); | |
830 | QCOMPARE ( d.Value( i+1 ) , 'i' ); | |
831 | QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 ); | |
832 | ||
833 | //Insert(const Standard_Integer where,const TCollection_AsciiString& what) | |
834 | d = theStr; | |
835 | d.Insert( i+1, TCollection_AsciiString( "i" )); | |
836 | //assert( d.Length() == strlen( theStr ) + 1 ); | |
837 | //assert( d.Value( i+1 ) == 'i'); | |
838 | //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 ); | |
839 | QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 ); | |
840 | QCOMPARE ( d.Value( i+1 ) , 'i' ); | |
841 | QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 ); | |
842 | ||
843 | // IsDifferent (const Standard_CString other)const | |
844 | //assert( d.IsDifferent( theStr )); | |
845 | //assert( d.IsDifferent( "theStr" )); | |
846 | //assert( d.IsDifferent( "" )); | |
847 | //assert( !d.IsDifferent( d.ToCString() )); | |
848 | QCOMPARE ( d.IsDifferent( theStr ) , Standard_True ); | |
849 | QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True ); | |
850 | QCOMPARE ( d.IsDifferent( "" ) , Standard_True ); | |
851 | QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True ); | |
852 | ||
853 | // IsDifferent (const TCollection_AsciiString& other)const | |
854 | //assert( d.IsDifferent( TCollection_AsciiString() )); | |
855 | //assert( d.IsDifferent( a )); | |
856 | //assert( d.IsDifferent( h )); | |
857 | //assert( !d.IsDifferent( d )); | |
858 | QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True ); | |
859 | QCOMPARE ( d.IsDifferent( a ) , Standard_True ); | |
860 | QCOMPARE ( d.IsDifferent( h ) , Standard_True ); | |
861 | QCOMPARE ( !d.IsDifferent( d ) , Standard_True ); | |
862 | ||
863 | // IsLess (const Standard_CString other)const | |
864 | //assert( TCollection_AsciiString ("0"). IsLess("1")); | |
865 | //assert( TCollection_AsciiString ("0"). IsLess("00")); | |
866 | //assert( TCollection_AsciiString (""). IsLess("0")); | |
867 | //assert( !TCollection_AsciiString("1"). IsLess("0")); | |
868 | //assert( !TCollection_AsciiString("00").IsLess("0")); | |
869 | //assert( !TCollection_AsciiString("0"). IsLess("")); | |
870 | //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1)); | |
871 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True ); | |
872 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True ); | |
873 | QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True ); | |
874 | QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True ); | |
875 | QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True ); | |
876 | QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True ); | |
877 | QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True ); | |
878 | ||
879 | // IsLess (const TCollection_AsciiString& other)const | |
880 | //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" ))); | |
881 | //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00"))); | |
882 | //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" ))); | |
883 | //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" ))); | |
884 | //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" ))); | |
885 | //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" ))); | |
886 | //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1))); | |
887 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True ); | |
888 | QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True ); | |
889 | QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
890 | QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
891 | QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True ); | |
892 | QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True ); | |
893 | QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True ); | |
894 | ||
895 | // IsGreater (const Standard_CString other)const | |
896 | //assert( !TCollection_AsciiString("0"). IsGreater("1")); | |
897 | //assert( !TCollection_AsciiString("0"). IsGreater("00")); | |
898 | //assert( !TCollection_AsciiString(""). IsGreater("0")); | |
899 | //assert( TCollection_AsciiString ("1"). IsGreater("0")); | |
900 | //assert( TCollection_AsciiString ("00").IsGreater("0")); | |
901 | //assert( TCollection_AsciiString ("0"). IsGreater("")); | |
902 | //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i)); | |
903 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True ); | |
904 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True ); | |
905 | QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True ); | |
906 | QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True ); | |
907 | QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True ); | |
908 | QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True ); | |
909 | QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True ); | |
910 | ||
911 | // IsGreater (const TCollection_AsciiString& other)const | |
912 | //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" ))); | |
913 | //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00"))); | |
914 | //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" ))); | |
915 | //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" ))); | |
916 | //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" ))); | |
917 | //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" ))); | |
918 | //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i))); | |
919 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True ); | |
920 | QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True ); | |
921 | QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
922 | QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
923 | QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True ); | |
924 | QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True ); | |
925 | QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True ); | |
926 | ||
927 | // void Read(Standard_IStream& astream) | |
928 | std::istringstream is( theStr ); | |
929 | e.Read( is ); | |
930 | //assert( e == theStr ); | |
931 | QCOMPARE ( e , theStr ); | |
932 | ||
933 | // Standard_Integer SearchFromEnd (const Standard_CString what)const | |
934 | //assert( e.SearchFromEnd( theStr + i ) == i + 1 ); | |
935 | QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 ); | |
936 | ||
937 | // SetValue(const Standard_Integer where, const Standard_CString what) | |
938 | e.SetValue( i+1, "what"); | |
939 | //assert( e.Search( "what" ) == i+1 ); | |
940 | //assert( e.Length() == strlen( theStr )); | |
941 | QCOMPARE ( e.Search( "what" ) , i+1 ); | |
942 | QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) ); | |
943 | ||
944 | // TCollection_AsciiString Split (const Standard_Integer where) | |
945 | e = theStr; | |
946 | d = e.Split( i+1 ); | |
947 | //assert( d.Length() + e.Length() == strlen( theStr )); | |
948 | QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) ); | |
949 | ||
950 | // TCollection_AsciiString SubString (const Standard_Integer FromIndex, | |
951 | // const Standard_Integer ToIndex) const | |
952 | e = theStr; | |
953 | d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 ); | |
954 | //assert( d.Length() == 3 ); | |
955 | //assert( d.Value(1) == theStr[ i ]); | |
956 | QCOMPARE ( d.Length() , 3 ); | |
957 | QCOMPARE ( d.Value(1) , theStr[ i ] ); | |
958 | ||
959 | // TCollection_AsciiString Token (const Standard_CString separators, | |
960 | // const Standard_Integer whichone) const | |
961 | e = " "; | |
962 | for ( j = 0; j < i; ++j ) { | |
963 | e += TCollection_AsciiString( theStr[j] ) + " "; | |
964 | //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 )); | |
965 | QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) ); | |
966 | } | |
967 | } | |
968 | for ( i = 0; i < 5; ++i ) | |
969 | { | |
970 | // TCollection_ExtendedString (const Standard_CString astring, | |
971 | // const Standard_Boolean isMultiByte) | |
972 | const TCollection_ExtendedString a( theStr+i ); | |
973 | //assert( TCollection_AsciiString( a ) == theStr+i ); | |
974 | QCOMPARE ( TCollection_AsciiString( a ) , theStr+i ); | |
975 | ||
976 | //TCollection_ExtendedString (const Standard_ExtString astring) | |
977 | const TCollection_ExtendedString b( a.ToExtString() ); | |
978 | //assert( a == b ); | |
979 | QCOMPARE ( a , b ); | |
980 | ||
981 | // TCollection_ExtendedString (const Standard_Integer length, | |
982 | // const Standard_ExtCharacter filler ) | |
983 | const TCollection_ExtendedString c( i, 1 ); | |
984 | //assert( c.Length() == i ); | |
985 | QCOMPARE ( c.Length() , i ); | |
986 | if ( c.Length() > 0 ) { | |
987 | //assert( c.Value( i ) == 1 ); | |
988 | QCOMPARE ( c.Value( i ) , 1 ); | |
989 | } | |
990 | ||
991 | // TCollection_ExtendedString (const Standard_Integer aValue) | |
992 | TCollection_ExtendedString d( i ); | |
993 | const TCollection_AsciiString da( d ); | |
994 | //assert( da.IsIntegerValue() ); | |
995 | //assert( da.IntegerValue() == i ); | |
996 | QCOMPARE ( da.IsIntegerValue() , Standard_True ); | |
997 | QCOMPARE ( da.IntegerValue(), i ); | |
998 | ||
999 | // TCollection_ExtendedString (const Standard_Real aValue) | |
1000 | const TCollection_ExtendedString e( 0.1 * i ); | |
1001 | const TCollection_AsciiString ea( e ); | |
1002 | //assert( ea.IsRealValue() ); | |
1003 | //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 ); | |
1004 | QCOMPARE ( ea.IsRealValue() , Standard_True ); | |
1005 | QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True ); | |
1006 | ||
1007 | // TCollection_ExtendedString (const TCollection_ExtendedString& astring) | |
1008 | const TCollection_ExtendedString f(e); | |
1009 | //assert( f.Length() == e.Length()); | |
1010 | //assert( f == e ); | |
1011 | QCOMPARE ( f.Length() , e.Length() ); | |
1012 | QCOMPARE ( f , e ); | |
1013 | ||
1014 | // TCollection_ExtendedString (const TCollection_AsciiString& astring) | |
1015 | const TCollection_ExtendedString g( ea ); | |
1016 | //assert( g.Length() == ea.Length() ); | |
1017 | //assert( TCollection_AsciiString( g ) == ea ); | |
1018 | QCOMPARE ( g.Length() , ea.Length() ); | |
1019 | QCOMPARE ( TCollection_AsciiString( g ) , ea ); | |
1020 | ||
1021 | // AssignCat (const TCollection_ExtendedString& other) | |
1022 | const TCollection_ExtendedString sep(","); | |
1023 | d.AssignCat( sep ); | |
1024 | d.AssignCat( g ); | |
1025 | //assert( d.Length() == 2 + g.Length() ); | |
1026 | //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i )); | |
1027 | //assert( d.Token( sep.ToExtString(), 2 ) == g ); | |
1028 | QCOMPARE ( d.Length() , 2 + g.Length() ); | |
1029 | QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) ); | |
1030 | QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g ); | |
1031 | ||
1032 | // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const | |
1033 | const TCollection_ExtendedString cat = a.Cat( sep ); | |
1034 | //assert( cat.Length() == a.Length() + sep.Length() ); | |
1035 | //assert( cat.Search( a ) == 1 ); | |
1036 | //assert( cat.Search( sep ) == a.Length() + 1 ); | |
1037 | QCOMPARE ( cat.Length() , a.Length() + sep.Length() ); | |
1038 | QCOMPARE ( cat.Search( a ) , 1 ); | |
1039 | QCOMPARE ( cat.Search( sep ) , a.Length() + 1 ); | |
1040 | ||
1041 | // Copy (const TCollection_ExtendedString& fromwhere) | |
1042 | d = cat; | |
1043 | //assert( d.Length() == cat.Length() ); | |
1044 | //assert( d == cat ); | |
1045 | QCOMPARE ( d.Length() , cat.Length() ); | |
1046 | QCOMPARE ( d , cat ); | |
1047 | ||
1048 | // IsEqual (const Standard_ExtString other) const | |
1049 | //assert( d.IsEqual( d.ToExtString() )); | |
1050 | QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True ); | |
1051 | ||
1052 | // IsDifferent (const Standard_ExtString other ) const | |
1053 | //assert( d.IsDifferent( a.ToExtString() )); | |
1054 | QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True ); | |
1055 | ||
1056 | // IsDifferent (const TCollection_ExtendedString& other) const | |
1057 | //assert( d.IsDifferent( a )); | |
1058 | QCOMPARE ( d.IsDifferent( a ) , Standard_True ); | |
1059 | ||
1060 | // IsLess (const Standard_ExtString other) const | |
1061 | const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1); | |
1062 | //assert( l0. IsLess( l1.ToExtString() )); | |
1063 | //assert( l0. IsLess( l00.ToExtString() )); | |
1064 | //assert( l. IsLess( l0.ToExtString() )); | |
1065 | //assert( ! l1. IsLess( l0.ToExtString() )); | |
1066 | //assert( ! l00.IsLess( l0.ToExtString() )); | |
1067 | //assert( ! l0. IsLess( l.ToExtString() )); | |
1068 | //assert( ls.IsLess( ls1.ToExtString() )); | |
1069 | QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True ); | |
1070 | QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True ); | |
1071 | QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True ); | |
1072 | QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True ); | |
1073 | QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True ); | |
1074 | QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True ); | |
1075 | QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True ); | |
1076 | ||
1077 | // IsLess (const TCollection_ExtendedString& other) const | |
1078 | //assert( l0. IsLess( l1 )); | |
1079 | //assert( l0. IsLess( l00 )); | |
1080 | //assert( l. IsLess( l0 )); | |
1081 | //assert( ! l1. IsLess( l0 )); | |
1082 | //assert( ! l00.IsLess( l0 )); | |
1083 | //assert( ! l0. IsLess( l )); | |
1084 | //assert( ls.IsLess( ls1 )); | |
1085 | QCOMPARE ( l0. IsLess( l1 ) , Standard_True ); | |
1086 | QCOMPARE ( l0. IsLess( l00 ) , Standard_True ); | |
1087 | QCOMPARE ( l. IsLess( l0 ) , Standard_True ); | |
1088 | QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True ); | |
1089 | QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True ); | |
1090 | QCOMPARE ( ! l0. IsLess( l ) , Standard_True ); | |
1091 | QCOMPARE ( ls.IsLess( ls1 ) , Standard_True ); | |
1092 | ||
1093 | // IsGreater (const Standard_ExtString other) const | |
1094 | //assert( ! l0.IsGreater( l1.ToExtString() )); | |
1095 | //assert( ! l0.IsGreater( l00.ToExtString() )); | |
1096 | //assert( ! l. IsGreater( l0.ToExtString() )); | |
1097 | //assert( l1. IsGreater( l0.ToExtString() )); | |
1098 | //assert( l00.IsGreater( l0.ToExtString() )); | |
1099 | //assert( l0. IsGreater( l.ToExtString() )); | |
1100 | //assert( ls1.IsGreater( ls.ToExtString() )); | |
1101 | QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True ); | |
1102 | QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True ); | |
1103 | QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True ); | |
1104 | QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True ); | |
1105 | QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True ); | |
1106 | QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True ); | |
1107 | QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True ); | |
1108 | ||
1109 | // IsGreater (const TCollection_ExtendedString& other) const | |
1110 | //assert( ! l0.IsGreater( l1)); | |
1111 | //assert( ! l0.IsGreater( l00)); | |
1112 | //assert( ! l. IsGreater( l0)); | |
1113 | //assert( l1. IsGreater( l0)); | |
1114 | //assert( l00.IsGreater( l0)); | |
1115 | //assert( l0. IsGreater( l)); | |
1116 | //assert( ls1.IsGreater( ls)); | |
1117 | QCOMPARE ( ! l0.IsGreater( l1) , Standard_True ); | |
1118 | QCOMPARE ( ! l0.IsGreater( l00) , Standard_True ); | |
1119 | QCOMPARE ( ! l. IsGreater( l0) , Standard_True ); | |
1120 | QCOMPARE ( l1. IsGreater( l0) , Standard_True ); | |
1121 | QCOMPARE ( l00.IsGreater( l0) , Standard_True ); | |
1122 | QCOMPARE ( l0. IsGreater( l) , Standard_True ); | |
1123 | QCOMPARE ( ls1.IsGreater( ls) , Standard_True ); | |
1124 | ||
1125 | // ========================== | |
1126 | //TCollection_HAsciiString:: | |
1127 | // ========================== | |
1128 | ||
1129 | // IsDifferent(const Handle(TCollection_HAsciiString)& S) | |
1130 | Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i ); | |
1131 | Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 ); | |
1132 | //assert( ha1->IsDifferent( ha2 )); | |
1133 | //assert( !ha1->IsDifferent( ha1 )); | |
1134 | QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True ); | |
1135 | QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True ); | |
1136 | ||
1137 | // IsSameString (const Handle(TCollection_HAsciiString)& S) | |
1138 | //assert( !ha1->IsSameString( ha2 )); | |
1139 | //assert( ha1->IsSameString( ha1 )); | |
1140 | QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True ); | |
1141 | QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True ); | |
1142 | ||
1143 | // IsSameState (const Handle(TCollection_HAsciiString)& other) const | |
1144 | //assert( !ha1->IsSameState( ha2 )); | |
1145 | //assert( ha1->IsSameState( ha1 )); | |
1146 | QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True ); | |
1147 | QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True ); | |
1148 | ||
1149 | // IsSameString (const Handle(TCollection_HAsciiString)& S , | |
1150 | // const Standard_Boolean CaseSensitive) const | |
1151 | //assert( !ha1->IsSameString( ha2, true )); | |
1152 | //assert( ha1->IsSameString( ha1, true )); | |
1153 | //assert( !ha1->IsSameString( ha2, false )); | |
1154 | //assert( ha1->IsSameString( ha1, false )); | |
1155 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True ); | |
1156 | QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True ); | |
1157 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True ); | |
1158 | QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True ); | |
1159 | ||
1160 | ha1->SetValue( 1, "AbC0000000"); | |
1161 | ha2->SetValue( 1, "aBc0000000"); | |
1162 | //assert( !ha1->IsSameString( ha2, true )); | |
1163 | //assert( ha1->IsSameString( ha2, false )); | |
1164 | QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True ); | |
1165 | QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True ); | |
1166 | } | |
1167 | return 0; | |
1168 | } | |
1169 | ||
788cbaf4 | 1170 | #include <Geom_CylindricalSurface.hxx> |
1171 | #include <IntTools_FaceFace.hxx> | |
1172 | #include <IntTools_Curve.hxx> | |
1173 | #include <IntTools_PntOn2Faces.hxx> | |
1174 | ||
1175 | static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) | |
1176 | { | |
1177 | if(theNArg < 2) | |
1178 | { | |
1179 | theDI << "Wrong a number of arguments!\n"; | |
1180 | return 1; | |
1181 | } | |
1182 | ||
857ffd5e | 1183 | Handle(Geom_Plane) plane(new Geom_Plane( |
788cbaf4 | 1184 | gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678), |
1185 | gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000), | |
1186 | gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000)))); | |
1187 | Handle(Geom_CylindricalSurface) cylinder( | |
1188 | new Geom_CylindricalSurface( | |
1189 | gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465), | |
1190 | gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000), | |
1191 | gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)), | |
1192 | 19.712534607908712)); | |
1193 | ||
1194 | DrawTrSurf::Set("pln", plane); | |
1195 | theDI << "pln\n"; | |
1196 | DrawTrSurf::Set("cyl", cylinder); | |
1197 | theDI << "cyl\n"; | |
1198 | ||
1199 | BRep_Builder builder; | |
1200 | TopoDS_Face face1, face2; | |
1201 | builder.MakeFace(face1, plane, Precision::Confusion()); | |
1202 | builder.MakeFace(face2, cylinder, Precision::Confusion()); | |
1203 | IntTools_FaceFace anInters; | |
1204 | anInters.SetParameters(false, true, true, Precision::Confusion()); | |
1205 | anInters.Perform(face1, face2); | |
1206 | ||
1207 | if (!anInters.IsDone()) | |
1208 | { | |
586db386 | 1209 | theDI<<"No intersections found!\n"; |
788cbaf4 | 1210 | |
1211 | return 1; | |
1212 | } | |
1213 | ||
1214 | //Handle(Geom_Curve) aResult; | |
1215 | //gp_Pnt aPoint; | |
1216 | ||
1217 | const IntTools_SequenceOfCurves& aCvsX=anInters.Lines(); | |
1218 | const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points(); | |
1219 | ||
1220 | char buf[1024]; | |
1221 | Standard_Integer aNbCurves, aNbPoints; | |
1222 | ||
1223 | aNbCurves=aCvsX.Length(); | |
1224 | aNbPoints=aPntsX.Length(); | |
1225 | ||
1226 | if (aNbCurves >= 2) | |
1227 | { | |
1228 | for (Standard_Integer i=1; i<=aNbCurves; ++i) | |
1229 | { | |
1230 | Sprintf(buf, "%s_%d",theArgv[1],i); | |
1231 | theDI << buf << " "; | |
1232 | ||
1233 | const IntTools_Curve& aIC = aCvsX(i); | |
1234 | const Handle(Geom_Curve)& aC3D= aIC.Curve(); | |
1235 | DrawTrSurf::Set(buf,aC3D); | |
1236 | } | |
1237 | } | |
1238 | else if (aNbCurves == 1) | |
1239 | { | |
1240 | const IntTools_Curve& aIC = aCvsX(1); | |
1241 | const Handle(Geom_Curve)& aC3D= aIC.Curve(); | |
1242 | Sprintf(buf, "%s",theArgv[1]); | |
1243 | theDI << buf << " "; | |
1244 | DrawTrSurf::Set(buf,aC3D); | |
1245 | } | |
1246 | ||
1247 | for (Standard_Integer i = 1; i<=aNbPoints; ++i) | |
1248 | { | |
1249 | const IntTools_PntOn2Faces& aPi=aPntsX(i); | |
1250 | const gp_Pnt& aP=aPi.P1().Pnt(); | |
1251 | ||
1252 | Sprintf(buf,"%s_p_%d",theArgv[1],i); | |
1253 | theDI << buf << " "; | |
1254 | DrawTrSurf::Set(buf, aP); | |
1255 | } | |
1256 | ||
1257 | return 0; | |
1258 | } | |
1259 | ||
1b7602c8 | 1260 | #include <BRepAlgo_NormalProjection.hxx> |
1261 | static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1262 | { | |
1263 | if (argc != 3) { | |
1264 | di << "Usage : " << argv[0] << " should be 2 arguments (face and edge)"; | |
1265 | return 1; | |
1266 | } | |
1267 | ||
1268 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
1269 | if(myAISContext.IsNull()) { | |
1270 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1271 | return 1; | |
1272 | } | |
1273 | ||
1274 | TopoDS_Face m_Face1 = TopoDS::Face(DBRep::Get(argv[1])); | |
1275 | TopoDS_Edge m_Edge = TopoDS::Edge(DBRep::Get(argv[2])); | |
1276 | ||
1277 | BRepAlgo_NormalProjection anormpro(m_Face1); | |
1278 | anormpro.Add(m_Edge); | |
1279 | anormpro.SetDefaultParams(); | |
1280 | ||
1281 | //anormpro.Compute3d(); | |
1282 | //anormpro.SetLimit(); | |
1283 | ||
1284 | anormpro.Build(); | |
1285 | ||
1286 | if (anormpro.IsDone()) | |
1287 | { | |
1288 | TopoDS_Shape rshape = anormpro.Projection(); | |
1289 | Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape); | |
0577ae8c | 1290 | myAISContext->SetColor (myShape, Quantity_Color(Quantity_NOC_YELLOW), Standard_False); |
1291 | myAISContext->Display (myShape, Standard_True); | |
1b7602c8 | 1292 | } |
1293 | ||
1294 | return 0; | |
1295 | } | |
1296 | ||
69fd2d1b | 1297 | #include <BRepFeat_SplitShape.hxx> |
1298 | #include <ShapeAnalysis_ShapeContents.hxx> | |
1299 | #include <BRepAlgo.hxx> | |
1300 | static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1301 | { | |
1302 | if (argc != 3) { | |
1303 | di << "Usage : " << argv[0] << " should be 2 arguments (face and wire)"; | |
1304 | return 1; | |
1305 | } | |
1306 | ||
1307 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
1308 | if(myAISContext.IsNull()) { | |
1309 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1310 | return 1; | |
1311 | } | |
1312 | ||
1313 | TopoDS_Shape result; | |
1314 | TopoDS_Face face = TopoDS::Face(DBRep::Get(argv[1])); | |
1315 | TopoDS_Wire wire = TopoDS::Wire(DBRep::Get(argv[2])); | |
1316 | ||
1317 | BRepFeat_SplitShape asplit(face); | |
1318 | asplit.Add(wire, face); | |
1319 | asplit.Build(); | |
1320 | result = asplit.Shape(); | |
1321 | ShapeAnalysis_ShapeContents ana; | |
1322 | ana.Perform(result); | |
1323 | ana.NbFaces(); | |
1324 | ||
1325 | if (!(BRepAlgo::IsValid(result))) { | |
586db386 | 1326 | di << "Result was checked and it is INVALID\n"; |
69fd2d1b | 1327 | } else { |
586db386 | 1328 | di << "Result was checked and it is VALID\n"; |
69fd2d1b | 1329 | } |
1330 | ||
1331 | Handle(AIS_InteractiveObject) myShape = new AIS_Shape (result); | |
1332 | myAISContext->Display(myShape, Standard_True); | |
1333 | ||
1334 | return 0; | |
1335 | } | |
1336 | ||
c764e804 | 1337 | #include <Geom_Circle.hxx> |
1338 | #include <GeomAdaptor_Curve.hxx> | |
1339 | #include <Extrema_ExtPC.hxx> | |
1340 | #include <gp_Cylinder.hxx> | |
1341 | #include <ElSLib.hxx> | |
1342 | static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1343 | { | |
1344 | if (argc != 1) { | |
586db386 | 1345 | di << "Usage: " << argv[0] << " invalid number of arguments\n"; |
c764e804 | 1346 | return 1; |
1347 | } | |
1348 | ||
1349 | gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 ); | |
1350 | gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() ); | |
1351 | Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 ); | |
1352 | GeomAdaptor_Curve aC3D( aCircle ); | |
1353 | ||
1354 | Extrema_ExtPC aExtPC( aP3D, aC3D ); | |
1355 | //Standard_Real aParam = (aExtPC.Point(1)).Parameter(); | |
1356 | gp_Pnt aProj = (aExtPC.Point(1)).Value(); | |
1357 | di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n"; | |
1358 | ||
1359 | // Result of deviation | |
1360 | gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() ); | |
1361 | gp_Cylinder aCylinder( aCylAxis, 1890. ); | |
1362 | ||
1363 | Standard_Real aU = 0., aV = 0.; | |
1364 | ElSLib::Parameters( aCylinder, aProj, aU, aV ); | |
1365 | di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n"; | |
1366 | ||
1367 | return 0; | |
1368 | } | |
1369 | ||
e5260e1d | 1370 | #include <Extrema_FuncPSNorm.hxx> |
89d8607f | 1371 | #include <math_FunctionSetRoot.hxx> |
1372 | #include <math_Vector.hxx> | |
1373 | #include <BRepBuilderAPI_MakeVertex.hxx> | |
1374 | static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv) | |
1375 | { | |
1376 | Standard_Integer anArgIter = 1; | |
1377 | if (theNArg < 5) | |
1378 | { | |
586db386 | 1379 | theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]\n"; |
89d8607f | 1380 | return 1; |
1381 | } | |
1382 | ||
1383 | // get target shape | |
1384 | Standard_CString aFaceName = theArgv[anArgIter++]; | |
1385 | Standard_CString aVertName = theArgv[anArgIter++]; | |
1386 | const TopoDS_Shape aShapeF = DBRep::Get (aFaceName); | |
1387 | const TopoDS_Shape aShapeV = DBRep::Get (aVertName); | |
1388 | const Standard_Real aUFrom = Atof (theArgv[anArgIter++]); | |
1389 | const Standard_Real aVFrom = Atof (theArgv[anArgIter++]); | |
1390 | const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100; | |
1391 | if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE) | |
1392 | { | |
1393 | std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl; | |
1394 | return 1; | |
1395 | } | |
1396 | if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX) | |
1397 | { | |
1398 | std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl; | |
1399 | return 1; | |
1400 | } | |
1401 | const TopoDS_Face aFace = TopoDS::Face (aShapeF); | |
1402 | const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV); | |
1403 | GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace)); | |
1404 | ||
1405 | gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes; | |
1406 | ||
e5260e1d | 1407 | Extrema_FuncPSNorm anExtFunc; |
89d8607f | 1408 | math_FunctionSetRoot aRoot (anExtFunc, aNbIts); |
1409 | ||
1410 | math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2); | |
1411 | aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion(); | |
1412 | aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite(); | |
1413 | aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite(); | |
1414 | aFromUV(1) = aUFrom; aFromUV(2) = aVFrom; | |
1415 | ||
1416 | anExtFunc.Initialize (aSurf); | |
1417 | anExtFunc.SetPoint (aPnt); | |
1418 | aRoot.SetTolerance (aTolUV); | |
1419 | aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup); | |
1420 | if (!aRoot.IsDone()) | |
1421 | { | |
1422 | std::cerr << "No results!\n"; | |
1423 | return 1; | |
1424 | } | |
1425 | ||
1426 | theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n"; | |
1427 | ||
1428 | aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes); | |
1429 | DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes)); | |
1430 | return 0; | |
1431 | } | |
1432 | ||
ab2db9a5 | 1433 | //! Check boolean operations on NCollection_Map |
1434 | static Standard_Integer OCC24271 (Draw_Interpretor& di, | |
1435 | Standard_Integer /*theArgNb*/, | |
1436 | const char** /*theArgVec*/) | |
1437 | { | |
1438 | // input data | |
1439 | const Standard_Integer aLeftLower = 1; | |
1440 | const Standard_Integer aLeftUpper = 10; | |
1441 | const Standard_Integer aRightLower = 5; | |
1442 | const Standard_Integer aRightUpper = 15; | |
1443 | ||
1444 | // define arguments | |
1445 | NCollection_Map<Standard_Integer> aMapLeft; | |
1446 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1447 | { | |
1448 | aMapLeft.Add (aKeyIter); | |
1449 | } | |
1450 | ||
1451 | NCollection_Map<Standard_Integer> aMapRight; | |
1452 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter) | |
1453 | { | |
1454 | aMapRight.Add (aKeyIter); | |
1455 | } | |
1456 | ||
1457 | QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False); | |
1458 | QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False); | |
1459 | ||
1460 | // validate Union operation | |
1461 | NCollection_Map<Standard_Integer> aMapUnion; | |
1462 | aMapUnion.Union (aMapLeft, aMapRight); | |
1463 | QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1); | |
1464 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter) | |
1465 | { | |
1466 | QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True); | |
1467 | } | |
1468 | ||
1469 | // validate Intersection operation | |
1470 | NCollection_Map<Standard_Integer> aMapSect; | |
1471 | aMapSect.Intersection (aMapLeft, aMapRight); | |
1472 | QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1); | |
1473 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1474 | { | |
1475 | QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True); | |
1476 | } | |
1477 | QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True); | |
1478 | QCOMPARE (aMapRight.Contains (aMapSect), Standard_True); | |
1479 | ||
1480 | // validate Substruction operation | |
1481 | NCollection_Map<Standard_Integer> aMapSubsLR; | |
1482 | aMapSubsLR.Subtraction (aMapLeft, aMapRight); | |
1483 | QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower); | |
1484 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter) | |
1485 | { | |
1486 | QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True); | |
1487 | } | |
1488 | ||
1489 | NCollection_Map<Standard_Integer> aMapSubsRL; | |
1490 | aMapSubsRL.Subtraction (aMapRight, aMapLeft); | |
1491 | QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper); | |
1492 | for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter) | |
1493 | { | |
1494 | QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True); | |
1495 | } | |
1496 | ||
1497 | // validate Difference operation | |
1498 | NCollection_Map<Standard_Integer> aMapDiff; | |
1499 | aMapDiff.Difference (aMapLeft, aMapRight); | |
1500 | QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper); | |
1501 | for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter) | |
1502 | { | |
1503 | QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True); | |
1504 | } | |
1505 | for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter) | |
1506 | { | |
1507 | QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True); | |
1508 | } | |
1509 | ||
1510 | // validate Exchange operation | |
1511 | NCollection_Map<Standard_Integer> aMapSwap; | |
1512 | aMapSwap.Exchange (aMapSect); | |
1513 | for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter) | |
1514 | { | |
1515 | QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True); | |
1516 | } | |
1517 | QCOMPARE (aMapSect.IsEmpty(), Standard_True); | |
1518 | aMapSwap.Add (34); | |
1519 | aMapSect.Add (43); | |
1520 | ||
1521 | NCollection_Map<Standard_Integer> aMapCopy (aMapSwap); | |
1522 | QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True); | |
1523 | aMapCopy.Remove (34); | |
1524 | aMapCopy.Add (43); | |
1525 | QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False); | |
1526 | ||
1527 | return 0; | |
1528 | } | |
1529 | ||
e6c9f595 | 1530 | #define QVERIFY(val1) \ |
1531 | di << "Checking " #val1 " == Standard_True" << \ | |
1532 | ((val1) == Standard_True ? ": OK\n" : ": Error\n") | |
1533 | ||
1534 | #include <GeomInt_IntSS.hxx> | |
1535 | #include <Geom_ConicalSurface.hxx> | |
1536 | #include <Standard_ErrorHandler.hxx> | |
1537 | //======================================================================= | |
1538 | //function : OCC23972 | |
1539 | //purpose : | |
1540 | //======================================================================= | |
1541 | static void DoGeomIntSSTest (const Handle(Geom_Surface)& theSurf1, | |
1542 | const Handle(Geom_Surface)& theSurf2, | |
1543 | const Standard_Integer theNbSol, | |
1544 | Draw_Interpretor& di) | |
1545 | { | |
1546 | try { | |
1547 | OCC_CATCH_SIGNALS | |
1548 | GeomInt_IntSS anInter; | |
1549 | anInter.Perform (theSurf1, theSurf2, Precision::Confusion(), Standard_True); | |
1550 | QVERIFY (anInter.IsDone()); | |
1551 | QCOMPARE (anInter.NbLines(), theNbSol); | |
1552 | } catch (...) { | |
1553 | QVERIFY (Standard_False); | |
1554 | } | |
1555 | } | |
1556 | ||
1557 | namespace { | |
1558 | static Handle(Geom_ConicalSurface) CreateCone (const gp_Pnt& theLoc, | |
1559 | const gp_Dir& theDir, | |
1560 | const gp_Dir& theXDir, | |
1561 | const Standard_Real theRad, | |
1562 | const Standard_Real theSin, | |
1563 | const Standard_Real theCos) | |
1564 | { | |
1565 | const Standard_Real anA = atan (theSin / theCos); | |
1566 | gp_Ax3 anAxis (theLoc, theDir, theXDir); | |
1567 | Handle(Geom_ConicalSurface) aSurf = new Geom_ConicalSurface (anAxis, anA, theRad); | |
1568 | return aSurf; | |
1569 | } | |
1570 | } | |
1571 | ||
1572 | static Standard_Integer OCC23972 (Draw_Interpretor& di,Standard_Integer n, const char**) | |
1573 | { | |
1574 | if (n != 1) return 1; | |
1575 | ||
1576 | //process specific cones, cannot read them from files because due to rounding the original error | |
1577 | //in math_FunctionRoots gets hidden | |
1578 | Handle(Geom_Surface) aS1 = CreateCone ( | |
1579 | gp_Pnt (123.694345356663, 789.9, 68.15), | |
1580 | gp_Dir (-1, 3.48029791472957e-016, -8.41302743359754e-017), | |
1581 | gp_Dir (-3.48029791472957e-016, -1, -3.17572289932207e-016), | |
1582 | 3.28206830417112, | |
1583 | 0.780868809443031, | |
1584 | 0.624695047554424); | |
1585 | Handle(Geom_Surface) aS2 = CreateCone ( | |
1586 | gp_Pnt (123.694345356663, 784.9, 68.15), | |
1587 | gp_Dir (-1, -2.5209507537117e-016, -1.49772808948866e-016), | |
1588 | gp_Dir (1.49772808948866e-016, 3.17572289932207e-016, -1), | |
1589 | 3.28206830417112, | |
1590 | 0.780868809443031, | |
1591 | 0.624695047554424); | |
1592 | ||
1593 | DoGeomIntSSTest (aS1, aS2, 2, di); | |
1594 | ||
1595 | return 0; | |
1596 | } | |
1597 | ||
e3096dec | 1598 | #include <ShapeFix_EdgeProjAux.hxx> |
1599 | static Standard_Integer OCC24370 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv) | |
1600 | { | |
1601 | if (argc < 5) { | |
586db386 | 1602 | di<<"Usage: " << argv[0] << " invalid number of arguments\n"; |
e3096dec | 1603 | return 1; |
1604 | } | |
1605 | ||
1606 | TopoDS_Shape aSh = DBRep::Get(argv[1]); | |
1607 | if (aSh.IsNull()) { | |
1608 | di << argv[0] << " Error: Null input edge\n"; | |
1609 | return 1; | |
1610 | } | |
1611 | const TopoDS_Edge& anEdge = TopoDS::Edge (aSh); | |
1612 | ||
1613 | Handle(Geom2d_Curve) aC = DrawTrSurf::GetCurve2d(argv[2]); | |
1614 | if (aC.IsNull()) { | |
1615 | di << argv[0] << " Error: Null input curve\n"; | |
1616 | return 1; | |
1617 | } | |
1618 | ||
1619 | Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(argv[3]); | |
1620 | if (aS.IsNull()) { | |
1621 | di << argv[0] << " Error: Null input surface\n"; | |
1622 | return 1; | |
1623 | } | |
1624 | ||
1625 | Standard_Real prec = Draw::Atof(argv[4]); | |
1626 | ||
1627 | //prepare data | |
1628 | TopoDS_Face aFace; | |
1629 | BRep_Builder aB; | |
1630 | aB.MakeFace (aFace, aS, Precision::Confusion()); | |
1631 | aB.UpdateEdge (anEdge, aC, aFace, Precision::Confusion()); | |
1632 | aB.Range (anEdge, aFace, aC->FirstParameter(), aC->LastParameter()); | |
1633 | ||
1634 | //call algorithm | |
1635 | ShapeFix_EdgeProjAux aProj (aFace, anEdge); | |
1636 | aProj.Compute (prec); | |
1637 | ||
1638 | Standard_Boolean isfirstdone = aProj.IsFirstDone(); | |
1639 | Standard_Boolean islastdone = aProj.IsLastDone(); | |
1640 | ||
1641 | Standard_Real first = 0.; | |
1642 | Standard_Real last = 0.; | |
1643 | Standard_Integer isfirstdoneInteger = 0; | |
1644 | Standard_Integer islastdoneInteger = 0; | |
1645 | ||
1646 | ||
1647 | if (isfirstdone) { | |
1648 | first = aProj.FirstParam(); | |
1649 | isfirstdoneInteger = 1; | |
1650 | } | |
1651 | ||
1652 | if (islastdone) { | |
1653 | last= aProj.LastParam(); | |
1654 | islastdoneInteger = 1; | |
1655 | } | |
1656 | ||
1657 | di << isfirstdoneInteger << " "<< islastdoneInteger << " "<< first << " "<< last << " \n"; | |
1658 | ||
1659 | return 0; | |
1660 | } | |
1661 | ||
05d7de53 | 1662 | template<typename T, typename HT> |
1663 | static void DoIsNull(Draw_Interpretor& di) | |
1664 | { | |
1665 | HT aHandle; | |
1666 | // QVERIFY (aHandle.IsNull()); | |
1667 | QCOMPARE (aHandle.IsNull(), Standard_True); | |
c04c30b3 | 1668 | const T* p = aHandle.get(); |
05d7de53 | 1669 | #if OCC_VERSION_HEX > 0x060700 |
1670 | //QVERIFY (!p); | |
1671 | //QVERIFY (p == 0); | |
1672 | QCOMPARE (!p, Standard_True); | |
1673 | QCOMPARE (p == 0, Standard_True); | |
1674 | #endif | |
1675 | ||
1676 | aHandle = new T; | |
1677 | //QVERIFY (!aHandle.IsNull()); | |
1678 | QCOMPARE (!aHandle.IsNull(), Standard_True); | |
c04c30b3 | 1679 | p = aHandle.get(); |
05d7de53 | 1680 | //QVERIFY (p); |
1681 | //QVERIFY (p != 0); | |
1682 | QCOMPARE (p != NULL, Standard_True); | |
1683 | QCOMPARE (p != 0, Standard_True); | |
1684 | } | |
1685 | ||
1686 | //======================================================================= | |
1687 | //function : OCC24533 | |
1688 | //purpose : | |
1689 | //======================================================================= | |
1690 | static Standard_Integer OCC24533 (Draw_Interpretor& di, Standard_Integer n, const char**) | |
1691 | { | |
1692 | if (n != 1) return 1; | |
1693 | ||
857ffd5e | 1694 | DoIsNull<Standard_Transient, Handle(Standard_Transient)>(di); |
05d7de53 | 1695 | |
1696 | return 0; | |
1697 | } | |
1698 | ||
dda67c1c | 1699 | // Dummy class to test interface for compilation issues |
1700 | class QABugs_HandleClass : public Standard_Transient | |
1701 | { | |
1702 | public: | |
1703 | Standard_Integer HandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec) | |
1704 | { | |
1705 | std::cerr << "QABugs_HandleClass[" << this << "] " << theArgVec[0] << "\n"; | |
1706 | return 0; | |
1707 | } | |
92efcf78 | 1708 | DEFINE_STANDARD_RTTI_INLINE(QABugs_HandleClass,Standard_Transient) // Type definition |
dda67c1c | 1709 | }; |
1710 | DEFINE_STANDARD_HANDLE (QABugs_HandleClass, Standard_Transient) | |
ec357c5c | 1711 | |
dda67c1c | 1712 | |
1713 | // Dummy class to test interface for compilation issues | |
1714 | struct QABugs_NHandleClass | |
1715 | { | |
1716 | Standard_Integer NHandleProc (Draw_Interpretor& , Standard_Integer , const char** theArgVec) | |
1717 | { | |
586db386 | 1718 | std::cerr << "QABugs_NHandleClass[" << this << "] " << theArgVec[0] << "\n"; |
dda67c1c | 1719 | return 0; |
1720 | } | |
1721 | }; | |
1722 | ||
574d7236 | 1723 | #include <XCAFDoc_ColorTool.hxx> |
1724 | #include <STEPControl_StepModelType.hxx> | |
1725 | #include <STEPCAFControl_Writer.hxx> | |
1726 | static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1727 | { | |
7a7e8cf1 | 1728 | if (argc != 2) { |
586db386 | 1729 | di << "Usage: " << argv[0] << " invalid number of arguments\n"; |
574d7236 | 1730 | return 1; |
1731 | } | |
1732 | Handle(TDocStd_Document) aDoc = new TDocStd_Document("dummy");; | |
1733 | TopoDS_Shape s1 = BRepPrimAPI_MakeBox(1,1,1).Shape(); | |
1734 | TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape(); | |
1735 | XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1); | |
1736 | TDataStd_Name::Set(lab1, "Box1"); | |
1737 | ||
1738 | Quantity_Color yellow(1,1,0, Quantity_TOC_RGB); | |
1739 | XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen); | |
1740 | XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0); | |
1741 | ||
1742 | STEPControl_StepModelType mode = STEPControl_AsIs; | |
1743 | STEPCAFControl_Writer writer; | |
1744 | if ( ! writer.Transfer (aDoc, mode ) ) | |
1745 | { | |
1746 | di << "The document cannot be translated or gives no result" << "\n"; | |
1747 | return 1; | |
1748 | } | |
1749 | ||
7a7e8cf1 | 1750 | writer.Write(argv[1]); |
574d7236 | 1751 | return 0; |
1752 | } | |
1753 | ||
1754 | ||
f376ac72 | 1755 | //======================================================================= |
0c674248 | 1756 | //function : OCC23950 |
1757 | //purpose : | |
1758 | //======================================================================= | |
1759 | static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1760 | { | |
1fa7cb8c | 1761 | if (argc != 2) { |
1762 | di << "Usage : " << argv[0] << " step_file\n"; | |
0c674248 | 1763 | return 1; |
1764 | } | |
1765 | ||
1766 | Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy"); | |
1767 | TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0)); | |
1768 | gp_Trsf t0; | |
1769 | TopLoc_Location location0 (t0); | |
1770 | ||
1771 | TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape (); | |
1772 | XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6); | |
1773 | TDataStd_Name::Set(lab1, "Point1"); | |
1774 | ||
1775 | TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape (); | |
1776 | TDataStd_Name::Set(labelA0, "ASSEMBLY"); | |
1777 | ||
1778 | TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0); | |
acc909a8 | 1779 | XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->UpdateAssemblies(); |
0c674248 | 1780 | |
1781 | Quantity_Color yellow(1,1,0, Quantity_TOC_RGB); | |
1782 | XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen); | |
1783 | XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0); | |
1784 | ||
1785 | STEPControl_StepModelType mode = STEPControl_AsIs; | |
1786 | STEPCAFControl_Writer writer; | |
1787 | if (! writer.Transfer (aDoc, mode)) | |
1788 | { | |
586db386 | 1789 | di << "The document cannot be translated or gives no result\n"; |
0c674248 | 1790 | return 1; |
1791 | } | |
1792 | ||
1fa7cb8c | 1793 | writer.Write (argv[1]); |
0c674248 | 1794 | return 0; |
1795 | } | |
1796 | ||
1797 | //======================================================================= | |
2cd138b8 | 1798 | //function : OCC24667 |
1799 | //purpose : | |
1800 | //======================================================================= | |
1801 | static Standard_Integer OCC24667 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
1802 | { | |
1803 | if (n == 1) | |
1804 | { | |
586db386 | 1805 | di << "OCC24667 result Wire_spine Profile [Mode [Approx]]\n"; |
1806 | di << "Mode = 0 - CorrectedFrenet,\n"; | |
1807 | di << " = 1 - Frenet,\n"; | |
1808 | di << " = 2 - DiscreteTrihedron\n"; | |
1809 | di << "Approx - force C1-approximation if result is C0\n"; | |
2cd138b8 | 1810 | return 0; |
1811 | } | |
1812 | ||
1813 | if (n > 1 && n < 4) return 1; | |
1814 | ||
1815 | TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE); | |
1816 | if ( Spine.IsNull()) return 1; | |
1817 | ||
1818 | TopoDS_Shape Profile = DBRep::Get(a[3]); | |
1819 | if ( Profile.IsNull()) return 1; | |
1820 | ||
1821 | GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet; | |
1822 | if (n >= 5) | |
1823 | { | |
1824 | Standard_Integer iMode = atoi(a[4]); | |
1825 | if (iMode == 1) | |
1826 | Mode = GeomFill_IsFrenet; | |
1827 | else if (iMode == 2) | |
1828 | Mode = GeomFill_IsDiscreteTrihedron; | |
1829 | } | |
1830 | ||
1831 | Standard_Boolean ForceApproxC1 = Standard_False; | |
1832 | if (n >= 6) | |
1833 | ForceApproxC1 = Standard_True; | |
1834 | ||
1835 | BRepOffsetAPI_MakePipe aPipe(TopoDS::Wire(Spine), | |
1836 | Profile, | |
1837 | Mode, | |
1838 | ForceApproxC1); | |
1839 | ||
1840 | TopoDS_Shape S = aPipe.Shape(); | |
1841 | TopoDS_Shape aSF = aPipe.FirstShape(); | |
1842 | TopoDS_Shape aSL = aPipe.LastShape(); | |
1843 | ||
1844 | DBRep::Set(a[1],S); | |
1845 | ||
1846 | TCollection_AsciiString aStrF(a[1], "_f"); | |
1847 | TCollection_AsciiString aStrL(a[1], "_l"); | |
1848 | ||
1849 | DBRep::Set(aStrF.ToCString(), aSF); | |
1850 | DBRep::Set(aStrL.ToCString(), aSL); | |
1851 | ||
1852 | return 0; | |
1853 | } | |
1854 | ||
70167e69 RL |
1855 | #include <BRepPrimAPI_MakeCylinder.hxx> |
1856 | #include <BRepBuilderAPI_Copy.hxx> | |
1857 | #include <BRepTools_NurbsConvertModification.hxx> | |
1858 | static TopoDS_Shape CreateTestShape (int& theShapeNb) | |
1859 | { | |
1860 | TopoDS_Compound aComp; | |
1861 | BRep_Builder aBuilder; | |
1862 | aBuilder.MakeCompound (aComp); | |
1863 | //NURBS modifier is used to increase footprint of each shape | |
35c0599a | 1864 | Handle(BRepTools_NurbsConvertModification) aNurbsModif = new BRepTools_NurbsConvertModification; |
70167e69 RL |
1865 | TopoDS_Shape aRefShape = BRepPrimAPI_MakeCylinder (50., 100.).Solid(); |
1866 | BRepTools_Modifier aModifier (aRefShape, aNurbsModif); | |
1867 | if (aModifier.IsDone()) { | |
1868 | aRefShape = aModifier.ModifiedShape (aRefShape); | |
1869 | } | |
1870 | int aSiblingNb = 0; | |
1871 | for (; theShapeNb > 0; --theShapeNb) { | |
1872 | TopoDS_Shape aShape; | |
1873 | if (++aSiblingNb <= 100) { //number of siblings is limited to avoid long lists | |
1874 | aShape = BRepBuilderAPI_Copy (aRefShape, Standard_True /*CopyGeom*/).Shape(); | |
1875 | } else { | |
1876 | aShape = CreateTestShape (theShapeNb); | |
1877 | } | |
1878 | aBuilder.Add (aComp, aShape); | |
1879 | } | |
1880 | return aComp; | |
1881 | } | |
1882 | ||
70167e69 RL |
1883 | #include <TDataStd_Integer.hxx> |
1884 | #include <TNaming_Builder.hxx> | |
1885 | static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) | |
1886 | { | |
7a7e8cf1 | 1887 | if (argc != 2) { |
586db386 | 1888 | di << "Usage: " << argv[0] << " invalid number of arguments\n"; |
70167e69 RL |
1889 | return 1; |
1890 | } | |
7a7e8cf1 | 1891 | TCollection_ExtendedString aFileName (argv[1]); |
70167e69 RL |
1892 | PCDM_StoreStatus aSStatus = PCDM_SS_Failure; |
1893 | ||
6fe96f84 | 1894 | Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); |
70167e69 RL |
1895 | { |
1896 | Handle(TDocStd_Document) aDoc; | |
1897 | anApp->NewDocument ("XmlOcaf", aDoc); | |
1898 | TDF_Label aLab = aDoc->Main(); | |
1899 | TDataStd_Integer::Set (aLab, 0); | |
1900 | int n = 10000; //must be big enough | |
1901 | TopoDS_Shape aShape = CreateTestShape (n); | |
1902 | TNaming_Builder aBuilder (aLab); | |
1903 | aBuilder.Generated (aShape); | |
1904 | ||
1905 | aSStatus = anApp->SaveAs (aDoc, aFileName); | |
1906 | anApp->Close (aDoc); | |
1907 | } | |
1908 | QCOMPARE (aSStatus, PCDM_SS_OK); | |
1909 | return 0; | |
1910 | } | |
1911 | ||
d01cc61d | 1912 | #include <TDF_AttributeIterator.hxx> |
1913 | //======================================================================= | |
1914 | //function : OCC24755 | |
1915 | //purpose : | |
1916 | //======================================================================= | |
1917 | static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
1918 | { | |
1919 | if (n != 1) | |
1920 | { | |
1921 | std::cout << "Usage : " << a[0] << "\n"; | |
1922 | return 1; | |
1923 | } | |
1924 | ||
6fe96f84 | 1925 | Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); |
d01cc61d | 1926 | Handle(TDocStd_Document) aDoc; |
fff263bd | 1927 | anApp->NewDocument ("BinOcaf", aDoc); |
d01cc61d | 1928 | TDF_Label aLab = aDoc->Main(); |
0f3d1d7c | 1929 | // Prepend an int value. |
d01cc61d | 1930 | TDataStd_Integer::Set (aLab, 0); |
0f3d1d7c | 1931 | // Prepend a name. |
d01cc61d | 1932 | TDataStd_Name::Set (aLab, "test"); |
0f3d1d7c | 1933 | // Append a double value. |
1934 | aLab.AddAttribute(new TDataStd_Real(), true/*append*/); | |
d01cc61d | 1935 | |
1936 | TDF_AttributeIterator i (aLab); | |
1937 | Handle(TDF_Attribute) anAttr = i.Value(); | |
bd6f0d2f | 1938 | QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True); |
0f3d1d7c | 1939 | i.Next(); |
1940 | anAttr = i.Value(); | |
bd6f0d2f | 1941 | QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True); |
d01cc61d | 1942 | i.Next(); |
1943 | anAttr = i.Value(); | |
0f3d1d7c | 1944 | QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Real)), Standard_True); |
d01cc61d | 1945 | |
1946 | return 0; | |
1947 | } | |
1948 | ||
a73267f2 | 1949 | struct MyStubObject |
1950 | { | |
1951 | MyStubObject() : ptr(0L) {} | |
1952 | MyStubObject(void* thePtr) : ptr(thePtr) {} | |
1953 | char overhead[40]; | |
1954 | void* ptr; | |
1955 | }; | |
1956 | ||
1957 | //======================================================================= | |
1958 | //function : OCC24834 | |
1959 | //purpose : | |
1960 | //======================================================================= | |
1961 | static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
1962 | { | |
1963 | if (n != 1) | |
1964 | { | |
1965 | std::cout << "Usage : " << a[0] << "\n"; | |
1966 | return 1; | |
1967 | } | |
5a89733f | 1968 | |
1969 | int i = sizeof (char*); | |
1970 | if (i > 4) { | |
2d7b28ac | 1971 | std::cout << "64-bit architecture is not supported.\n"; |
1972 | return 0; | |
1973 | } | |
a73267f2 | 1974 | |
1975 | NCollection_List<MyStubObject> aList; | |
1976 | const Standard_Integer aSmallBlockSize = 40; | |
1977 | const Standard_Integer aLargeBlockSize = 1500000; | |
1978 | ||
1979 | // quick populate memory with large blocks | |
1980 | try | |
1981 | { | |
1982 | for (;;) | |
1983 | { | |
1984 | aList.Append(MyStubObject(Standard::Allocate(aLargeBlockSize))); | |
1985 | } | |
1986 | } | |
1987 | catch (Standard_Failure) | |
1988 | { | |
1989 | di << "caught out of memory for large blocks: OK\n"; | |
1990 | } | |
1991 | catch (...) | |
1992 | { | |
1993 | di << "skept out of memory for large blocks: Error\n"; | |
1994 | } | |
1995 | ||
1996 | // allocate small blocks | |
1997 | try | |
1998 | { | |
1999 | for (;;) | |
2000 | { | |
2001 | aList.Append(MyStubObject(Standard::Allocate(aSmallBlockSize))); | |
2002 | } | |
2003 | } | |
2004 | catch (Standard_Failure) | |
2005 | { | |
2006 | di << "caught out of memory for small blocks: OK\n"; | |
2007 | } | |
2008 | catch (...) | |
2009 | { | |
2010 | di << "skept out of memory for small blocks: Error\n"; | |
2011 | } | |
2012 | ||
2013 | // release all allocated blocks | |
2014 | for (NCollection_List<MyStubObject>::Iterator it(aList); it.More(); it.Next()) | |
2015 | { | |
2016 | Standard::Free(it.Value().ptr); | |
2017 | } | |
2018 | return 0; | |
2019 | } | |
2020 | ||
8696d65d | 2021 | |
2022 | #include <Geom2dAPI_InterCurveCurve.hxx> | |
2023 | #include <IntRes2d_IntersectionPoint.hxx> | |
2024 | //======================================================================= | |
2025 | //function : OCC24889 | |
2026 | //purpose : | |
2027 | //======================================================================= | |
2028 | static Standard_Integer OCC24889 (Draw_Interpretor& theDI, | |
2029 | Standard_Integer /*theNArg*/, | |
2030 | const char** /*theArgs*/) | |
2031 | { | |
2032 | // Curves | |
2033 | Handle( Geom2d_Circle ) aCircle1 = new Geom2d_Circle( | |
2034 | gp_Ax22d( gp_Pnt2d( 25, -25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 ); | |
2035 | ||
2036 | Handle( Geom2d_Circle ) aCircle2 = new Geom2d_Circle( | |
2037 | gp_Ax22d( gp_Pnt2d( 25, 25 ), gp_Dir2d( 1, 0 ), gp_Dir2d( -0, 1 ) ), 155 ); | |
2038 | ||
2039 | Handle( Geom2d_TrimmedCurve ) aTrim[2] = { | |
2040 | new Geom2d_TrimmedCurve( aCircle1, 1.57079632679490, 2.97959469729228 ), | |
2041 | new Geom2d_TrimmedCurve( aCircle2, 3.30359060633978, 4.71238898038469 ) | |
2042 | }; | |
2043 | ||
2044 | DrawTrSurf::Set("c_1", aTrim[0]); | |
2045 | DrawTrSurf::Set("c_2", aTrim[1]); | |
2046 | ||
2047 | // Intersection | |
2048 | const Standard_Real aTol = Precision::Confusion(); | |
2049 | Geom2dAPI_InterCurveCurve aIntTool( aTrim[0], aTrim[1], aTol ); | |
2050 | ||
2051 | const IntRes2d_IntersectionPoint& aIntPnt = | |
2052 | aIntTool.Intersector().Point( 1 ); | |
2053 | ||
2054 | gp_Pnt2d aIntRes = aIntTool.Point( 1 ); | |
2055 | Standard_Real aPar[2] = { | |
2056 | aIntPnt.ParamOnFirst(), | |
2057 | aIntPnt.ParamOnSecond() | |
2058 | }; | |
2059 | ||
2060 | //theDI.precision( 5 ); | |
2061 | theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n"; | |
2062 | for (int i = 0; i < 2; ++i) | |
2063 | { | |
2064 | theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter() << | |
2065 | "; LastParam = " << aTrim[i]->LastParameter() << | |
2066 | "; IntParameter = " << aPar[i] << "\n"; | |
2067 | } | |
2068 | ||
2069 | return 0; | |
2070 | } | |
2071 | ||
5493d334 | 2072 | #include <math_GlobOptMin.hxx> |
2073 | #include <math_MultipleVarFunctionWithHessian.hxx> | |
2074 | //======================================================================= | |
2075 | //function : OCC25004 | |
2076 | //purpose : Check extremaCC on Branin function. | |
2077 | //======================================================================= | |
2078 | // Function is: | |
2079 | // f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s | |
2080 | // Standard borders are: | |
2081 | // -5 <= u <= 10 | |
2082 | // 0 <= v <= 15 | |
2083 | class BraninFunction : public math_MultipleVarFunctionWithHessian | |
2084 | { | |
2085 | public: | |
2086 | BraninFunction() | |
2087 | { | |
2088 | a = 1.0; | |
2089 | b = 5.1 / (4.0 * M_PI * M_PI); | |
2090 | c = 5.0 / M_PI; | |
2091 | r = 6.0; | |
2092 | s = 10.0; | |
2093 | t = 1.0 / (8.0 * M_PI); | |
2094 | } | |
2095 | virtual Standard_Integer NbVariables() const | |
2096 | { | |
2097 | return 2; | |
2098 | } | |
2099 | virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F) | |
2100 | { | |
2101 | Standard_Real u = X(1); | |
2102 | Standard_Real v = X(2); | |
2103 | ||
2104 | Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function. | |
2105 | Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion. | |
2106 | F = a * aSqPt * aSqPt + aLnPt + s; | |
2107 | return Standard_True; | |
2108 | } | |
2109 | virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G) | |
2110 | { | |
2111 | Standard_Real u = X(1); | |
2112 | Standard_Real v = X(2); | |
2113 | ||
2114 | Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function. | |
2115 | G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u); | |
2116 | G(2) = 2 * a * aSqPt; | |
2117 | ||
2118 | return Standard_True; | |
2119 | } | |
2120 | virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G) | |
2121 | { | |
2122 | Value(X,F); | |
2123 | Gradient(X,G); | |
2124 | ||
2125 | return Standard_True; | |
2126 | } | |
2127 | virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H) | |
2128 | { | |
2129 | Value(X,F); | |
2130 | Gradient(X,G); | |
2131 | ||
2132 | Standard_Real u = X(1); | |
2133 | Standard_Real v = X(2); | |
2134 | ||
2135 | Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function. | |
2136 | Standard_Real aTmpPt = c - 2 * b *u; // Tmp part. | |
2137 | H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u); | |
2138 | H(1,2) = 2 * a * aTmpPt; | |
2139 | H(2,1) = H(1,2); | |
2140 | H(2,2) = 2 * a; | |
2141 | ||
2142 | return Standard_True; | |
2143 | } | |
2144 | ||
2145 | private: | |
2146 | // Standard parameters. | |
2147 | Standard_Real a, b, c, r, s, t; | |
2148 | }; | |
2149 | ||
2150 | static Standard_Integer OCC25004 (Draw_Interpretor& theDI, | |
2151 | Standard_Integer /*theNArg*/, | |
2152 | const char** /*theArgs*/) | |
2153 | { | |
4b65fc77 | 2154 | BraninFunction aFunc; |
5493d334 | 2155 | |
2156 | math_Vector aLower(1,2), aUpper(1,2); | |
2157 | aLower(1) = -5; | |
2158 | aLower(2) = 0; | |
2159 | aUpper(1) = 10; | |
2160 | aUpper(2) = 15; | |
2161 | ||
2162 | Standard_Integer aGridOrder = 16; | |
2163 | math_Vector aFuncValues(1, aGridOrder * aGridOrder); | |
2164 | ||
2165 | Standard_Real aLipConst = 0; | |
2166 | math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2); | |
2167 | ||
2168 | // Get Lipshitz constant estimation on regular grid. | |
2169 | Standard_Integer i, j, idx = 1; | |
2170 | for(i = 1; i <= aGridOrder; i++) | |
2171 | { | |
2172 | for(j = 1; j <= aGridOrder; j++) | |
2173 | { | |
2174 | aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0); | |
2175 | aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0); | |
2176 | ||
4b65fc77 | 2177 | aFunc.Value(aCurrPnt1, aFuncValues(idx)); |
5493d334 | 2178 | idx++; |
2179 | } | |
2180 | } | |
2181 | ||
2182 | Standard_Integer k, l; | |
2183 | Standard_Integer idx1, idx2; | |
2184 | for(i = 1; i <= aGridOrder; i++) | |
2185 | for(j = 1; j <= aGridOrder; j++) | |
2186 | for(k = 1; k <= aGridOrder; k++) | |
2187 | for(l = 1; l <= aGridOrder; l++) | |
2188 | { | |
2189 | if (i == k && j == l) | |
2190 | continue; | |
2191 | ||
2192 | aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0); | |
2193 | aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0); | |
2194 | idx1 = (i - 1) * aGridOrder + j; | |
2195 | ||
2196 | aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0); | |
2197 | aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0); | |
2198 | idx2 = (k - 1) * aGridOrder + l; | |
2199 | ||
2200 | aCurrPnt1.Add(-aCurrPnt2); | |
2201 | Standard_Real dist = aCurrPnt1.Norm(); | |
2202 | ||
2203 | Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist; | |
2204 | if (C > aLipConst) | |
2205 | aLipConst = C; | |
2206 | } | |
2207 | ||
4b65fc77 | 2208 | math_GlobOptMin aFinder(&aFunc, aLower, aUpper, aLipConst); |
5493d334 | 2209 | aFinder.Perform(); |
2210 | //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475) | |
2211 | ||
2212 | Standard_Real anExtValue = aFinder.GetF(); | |
2213 | theDI << "F = " << anExtValue << "\n"; | |
2214 | ||
2215 | Standard_Integer aNbExt = aFinder.NbExtrema(); | |
2216 | theDI << "NbExtrema = " << aNbExt << "\n"; | |
2217 | ||
2218 | return 0; | |
2219 | } | |
8696d65d | 2220 | |
b6c0b841 RL |
2221 | #include <OSD_Environment.hxx> |
2222 | #include <Plugin.hxx> | |
2223 | #include <Plugin_Macro.hxx> | |
2224 | #include <Resource_Manager.hxx> | |
2225 | ||
2226 | #define THE_QATEST_DOC_FORMAT "My Proprietary Format" | |
2227 | ||
2228 | #define QA_CHECK(theDesc, theExpr, theValue) \ | |
2229 | {\ | |
2230 | const bool isTrue = !!(theExpr); \ | |
2231 | std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \ | |
2232 | } | |
2233 | ||
2234 | class Test_TDocStd_Application : public TDocStd_Application | |
2235 | { | |
2236 | public: | |
2237 | ||
6fe96f84 | 2238 | Test_TDocStd_Application () |
b6c0b841 | 2239 | { |
b6c0b841 RL |
2240 | // explicitly initialize resource manager |
2241 | myResources = new Resource_Manager (""); | |
2242 | myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT); | |
2243 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description", "Test XML Document"); | |
2244 | myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension", "xml"); | |
b6c0b841 RL |
2245 | } |
2246 | ||
6fe96f84 | 2247 | virtual Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString&) Standard_OVERRIDE |
2248 | { | |
2249 | return new XmlDrivers_DocumentRetrievalDriver (); | |
2250 | } | |
2251 | virtual Handle(PCDM_StorageDriver) WriterFromFormat (const TCollection_ExtendedString&) Standard_OVERRIDE | |
2252 | { | |
2253 | return new XmlDrivers_DocumentStorageDriver ("Test"); | |
2254 | } | |
2255 | virtual Standard_CString ResourcesName() Standard_OVERRIDE { return ""; } | |
b6c0b841 RL |
2256 | }; |
2257 | ||
2258 | //======================================================================= | |
2259 | //function : OCC24925 | |
2260 | //purpose : | |
2261 | //======================================================================= | |
2262 | static Standard_Integer OCC24925 (Draw_Interpretor& theDI, | |
2263 | Standard_Integer theArgNb, | |
2264 | const char** theArgVec) | |
2265 | { | |
2266 | if (theArgNb != 2 | |
2267 | && theArgNb != 5) | |
2268 | { | |
2269 | std::cout << "Error: wrong syntax! See usage:\n"; | |
2270 | theDI.PrintHelp (theArgVec[0]); | |
2271 | return 1; | |
2272 | } | |
2273 | ||
2274 | Standard_Integer anArgIter = 1; | |
2275 | TCollection_ExtendedString aFileName = theArgVec[anArgIter++]; | |
2276 | TCollection_AsciiString aPlugin = "TKXml"; | |
2277 | TCollection_AsciiString aSaver = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver in XmlDrivers.cxx | |
2278 | TCollection_AsciiString aLoader = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx | |
2279 | if (anArgIter < theArgNb) | |
2280 | { | |
2281 | aPlugin = theArgVec[anArgIter++]; | |
2282 | aSaver = theArgVec[anArgIter++]; | |
2283 | aLoader = theArgVec[anArgIter++]; | |
2284 | } | |
2285 | ||
2286 | PCDM_StoreStatus aSStatus = PCDM_SS_Failure; | |
2287 | PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError; | |
2288 | ||
6fe96f84 | 2289 | Handle(TDocStd_Application) anApp = new Test_TDocStd_Application (); |
b6c0b841 RL |
2290 | { |
2291 | Handle(TDocStd_Document) aDoc; | |
2292 | anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc); | |
2293 | TDF_Label aLab = aDoc->Main(); | |
2294 | TDataStd_Integer::Set (aLab, 0); | |
2295 | TDataStd_Name::Set (aLab, "QABugs_19.cxx"); | |
2296 | ||
2297 | aSStatus = anApp->SaveAs (aDoc, aFileName); | |
2298 | anApp->Close (aDoc); | |
2299 | } | |
2300 | QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true); | |
2301 | ||
2302 | { | |
2303 | Handle(TDocStd_Document) aDoc; | |
2304 | aRStatus = anApp->Open (aFileName, aDoc); | |
2305 | anApp->Close (aDoc); | |
2306 | } | |
2307 | QA_CHECK ("Open() ", aRStatus == PCDM_RS_OK, true); | |
2308 | return 0; | |
2309 | } | |
2310 | ||
e4b5c45a | 2311 | //======================================================================= |
a967f104 | 2312 | //function : OCC25043 |
2313 | //purpose : | |
2314 | //======================================================================= | |
2315 | #include <BRepAlgoAPI_Check.hxx> | |
2316 | static Standard_Integer OCC25043 (Draw_Interpretor& theDI, | |
2317 | Standard_Integer theArgNb, | |
2318 | const char** theArgVec) | |
2319 | { | |
2320 | if (theArgNb != 2) { | |
2321 | theDI << "Usage: " << theArgVec[0] << " shape\n"; | |
2322 | return 1; | |
2323 | } | |
2324 | ||
2325 | TopoDS_Shape aShape = DBRep::Get(theArgVec[1]); | |
2326 | if (aShape.IsNull()) | |
2327 | { | |
2328 | theDI << theArgVec[1] << " shape is NULL\n"; | |
2329 | return 1; | |
2330 | } | |
2331 | ||
2332 | BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True); | |
2333 | ||
2334 | if (!anAlgoApiCheck.IsValid()) | |
2335 | { | |
2336 | BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result()); | |
2337 | for (; anCheckIter.More(); anCheckIter.Next()) | |
2338 | { | |
2339 | const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value(); | |
1155d05a | 2340 | const TopTools_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1(); |
2341 | TopTools_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes); | |
a967f104 | 2342 | for (; aFaultyIter.More(); aFaultyIter.Next()) |
2343 | { | |
2344 | const TopoDS_Shape& aFaultyShape = aFaultyIter.Value(); | |
2345 | ||
2346 | Standard_Boolean anIsFaultyShapeFound = Standard_False; | |
2347 | TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType()); | |
2348 | for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next()) | |
2349 | { | |
2350 | if (anExp.Current().IsEqual(aFaultyShape)) | |
2351 | anIsFaultyShapeFound = Standard_True; | |
2352 | } | |
2353 | ||
2354 | if (!anIsFaultyShapeFound) | |
2355 | { | |
2356 | theDI << "Error. Faulty Shape is NOT found in source shape.\n"; | |
2357 | return 0; | |
2358 | } | |
2359 | else | |
2360 | { | |
3510db62 | 2361 | theDI << "Info. Faulty shape is found in source shape\n"; |
a967f104 | 2362 | } |
2363 | } | |
2364 | } | |
2365 | } | |
2366 | else | |
2367 | { | |
3510db62 | 2368 | theDI << "Problems are not detected. Test is not performed."; |
a967f104 | 2369 | } |
2370 | ||
2371 | return 0; | |
2372 | } | |
2373 | ||
2374 | //======================================================================= | |
4a350f94 | 2375 | //function : OCC24606 |
2376 | //purpose : | |
2377 | //======================================================================= | |
2378 | static Standard_Integer OCC24606 (Draw_Interpretor& theDI, | |
2379 | Standard_Integer theArgNb, | |
2380 | const char** theArgVec) | |
2381 | { | |
2382 | if (theArgNb > 1) | |
2383 | { | |
2384 | std::cerr << "Error: incorrect number of arguments.\n"; | |
2385 | theDI << "Usage : " << theArgVec[0] << "\n"; | |
2386 | return 1; | |
2387 | } | |
2388 | ||
2389 | Handle(V3d_View) aView = ViewerTest::CurrentView(); | |
2390 | if (aView.IsNull()) | |
2391 | { | |
2392 | std::cerr << "Errro: no active view, please call 'vinit'.\n"; | |
2393 | return 1; | |
2394 | } | |
2395 | ||
2396 | aView->DepthFitAll(); | |
2397 | aView->FitAll(); | |
2398 | ||
2399 | return 0; | |
2400 | } | |
2401 | ||
2402 | //======================================================================= | |
ab860031 | 2403 | //function : OCC25202 |
2404 | //purpose : | |
2405 | //======================================================================= | |
2406 | #include <ShapeBuild_ReShape.hxx> | |
2407 | static Standard_Integer OCC25202 ( Draw_Interpretor& theDI, | |
2408 | Standard_Integer theArgN, | |
2409 | const char** theArgVal) | |
2410 | { | |
2411 | // 0 1 2 3 4 5 6 | |
2412 | //reshape res shape numF1 face1 numF2 face2 | |
2413 | if(theArgN < 7) | |
2414 | { | |
2415 | theDI << "Use: reshape res shape numF1 face1 numF2 face2\n"; | |
2416 | return 1; | |
2417 | } | |
2418 | ||
2419 | TopoDS_Shape aShape = DBRep::Get(theArgVal[2]); | |
2420 | const Standard_Integer aNumOfRE1 = Draw::Atoi(theArgVal[3]), | |
2421 | aNumOfRE2 = Draw::Atoi(theArgVal[5]); | |
2422 | TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])), | |
2423 | aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6])); | |
2424 | ||
2425 | if(aShape.IsNull()) | |
2426 | { | |
2427 | theDI << theArgVal[2] << " is null shape\n"; | |
2428 | return 1; | |
2429 | } | |
2430 | ||
2431 | if(aShapeForRepl1.IsNull()) | |
2432 | { | |
2433 | theDI << theArgVal[4] << " is not a replaced type\n"; | |
2434 | return 1; | |
2435 | } | |
2436 | ||
2437 | if(aShapeForRepl2.IsNull()) | |
2438 | { | |
2439 | theDI << theArgVal[6] << " is not a replaced type\n"; | |
2440 | return 1; | |
2441 | } | |
2442 | ||
2443 | ||
2444 | TopoDS_Shape aReplacedShape; | |
2445 | ShapeBuild_ReShape aReshape; | |
2446 | ||
2447 | //////////////////// explode (begin) | |
2448 | TopTools_MapOfShape M; | |
2449 | M.Add(aShape); | |
2450 | Standard_Integer aNbShapes = 0; | |
2451 | for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next()) | |
2452 | { | |
2453 | const TopoDS_Shape& Sx = ex.Current(); | |
2454 | Standard_Boolean added = M.Add(Sx); | |
2455 | if (added) | |
2456 | { | |
2457 | aNbShapes++; | |
2458 | if(aNbShapes == aNumOfRE1) | |
2459 | { | |
2460 | aReplacedShape = Sx; | |
2461 | ||
2462 | aReshape.Replace(aReplacedShape, aShapeForRepl1); | |
2463 | } | |
2464 | ||
2465 | if(aNbShapes == aNumOfRE2) | |
2466 | { | |
2467 | aReplacedShape = Sx; | |
2468 | ||
2469 | aReshape.Replace(aReplacedShape, aShapeForRepl2); | |
2470 | } | |
2471 | } | |
2472 | } | |
2473 | //////////////////// explode (end) | |
2474 | ||
2475 | if(aReplacedShape.IsNull()) | |
2476 | { | |
2477 | theDI << "There is not any shape for replacing.\n"; | |
2478 | } | |
2479 | ||
2480 | DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2)); | |
2481 | ||
2482 | return 0; | |
2483 | } | |
2484 | ||
c6037065 | 2485 | #include <ShapeFix_Wireframe.hxx> |
2486 | //======================================================================= | |
2487 | //function : OCC7570 | |
2488 | //purpose : | |
2489 | //======================================================================= | |
2490 | static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
2491 | { | |
2492 | if (n != 2) { | |
586db386 | 2493 | di<<"Usage: "<<a[0]<<" invalid number of arguments\n"; |
c6037065 | 2494 | return 1; |
2495 | } | |
2496 | TopoDS_Shape in_shape (DBRep::Get (a[1])); | |
2497 | ShapeFix_Wireframe fix_tool (in_shape); | |
2498 | fix_tool.ModeDropSmallEdges () = Standard_True; | |
2499 | fix_tool.SetPrecision (1.e+6); | |
2500 | fix_tool.SetLimitAngle (0.01); | |
2501 | fix_tool.FixSmallEdges (); | |
2502 | TopoDS_Shape new_shape = fix_tool.Shape (); | |
2503 | return 0; | |
2504 | } | |
2505 | ||
54a16ee4 | 2506 | #include <AIS_TypeFilter.hxx> |
5e452c37 | 2507 | //======================================================================= |
2508 | //function : OCC25340 | |
2509 | //purpose : | |
2510 | //======================================================================= | |
54a16ee4 | 2511 | static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/, |
2512 | Standard_Integer /*theArgNb*/, | |
2513 | const char** /*theArgVec*/) | |
2514 | { | |
2515 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
2516 | if (aCtx.IsNull()) | |
2517 | { | |
2518 | std::cerr << "Error: No opened viewer!\n"; | |
2519 | return 1; | |
2520 | } | |
2521 | Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape); | |
2522 | aCtx->AddFilter (aFilter); | |
2523 | return 0; | |
2524 | } | |
2525 | ||
c7b59798 | 2526 | //======================================================================= |
2527 | //function : OCC24826 | |
2528 | //purpose : | |
2529 | //======================================================================= | |
2530 | class ParallelTest_Saxpy | |
2531 | { | |
2532 | public: | |
2533 | typedef NCollection_Array1<Standard_Real> Vector; | |
2534 | ||
2535 | //! Constructor | |
2536 | ParallelTest_Saxpy(const Vector& theX, Vector& theY, Standard_Real theScalar) | |
2537 | : myX(theX), | |
2538 | myY(theY), | |
2539 | myScalar(theScalar) | |
2540 | { | |
2541 | } | |
2542 | ||
2543 | //! Dummy calculation | |
2544 | void operator() (const Standard_Integer theIndex) const | |
2545 | { | |
2546 | myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex); | |
2547 | } | |
2548 | ||
2549 | private: | |
2550 | ParallelTest_Saxpy( const ParallelTest_Saxpy& ); | |
2551 | ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& ); | |
2552 | ||
2553 | private: | |
2554 | const Vector& myX; | |
2555 | Vector& myY; | |
2556 | const Standard_Real myScalar; | |
2557 | }; | |
2558 | ||
2559 | //--------------------------------------------------------------------- | |
2560 | static Standard_Integer OCC24826(Draw_Interpretor& theDI, | |
2561 | Standard_Integer trheArgc, | |
2562 | const char** theArgv) | |
2563 | { | |
2564 | if ( trheArgc != 2 ) | |
2565 | { | |
2566 | theDI << "Usage: " | |
2567 | << theArgv[0] | |
2568 | << " vec_length\n"; | |
2569 | return 1; | |
2570 | } | |
2571 | ||
2572 | // Generate data; | |
2573 | Standard_Integer aLength = Draw::Atoi(theArgv[1]); | |
2574 | ||
2575 | NCollection_Array1<Standard_Real> aX (0, aLength - 1); | |
2576 | NCollection_Array1<Standard_Real> anY(0, aLength - 1); | |
2577 | ||
2578 | for ( Standard_Integer i = 0; i < aLength; ++i ) | |
2579 | { | |
2580 | aX(i) = anY(i) = (Standard_Real) i; | |
2581 | } | |
2582 | ||
2583 | OSD_Timer aTimer; | |
2584 | ||
2585 | aTimer.Start(); | |
2586 | ||
2587 | //! Serial proccesing | |
2588 | for ( Standard_Integer i = 0; i < aLength; ++i ) | |
2589 | { | |
2590 | anY(i) = 1e-6 * aX(i) + anY(i); | |
2591 | } | |
2592 | ||
2593 | aTimer.Stop(); | |
2594 | cout << "Processing time (sequential mode):\n"; | |
2595 | aTimer.Show(); | |
2596 | ||
2597 | const ParallelTest_Saxpy aFunctor(aX, anY, 1e-6); | |
2598 | ||
2599 | aTimer.Reset(); | |
2600 | aTimer.Start(); | |
2601 | ||
2602 | // Parallel processing | |
2603 | OSD_Parallel::For(0, aLength, aFunctor); | |
2604 | ||
2605 | aTimer.Stop(); | |
2606 | cout << "Processing time (parallel mode):\n"; | |
2607 | aTimer.Show(); | |
2608 | ||
2609 | return 0; | |
2610 | } | |
2611 | ||
b6c0b841 | 2612 | /*****************************************************************************/ |
8696d65d | 2613 | |
058f130e | 2614 | #include <GeomAPI_IntSS.hxx> |
2615 | //======================================================================= | |
2616 | //function : OCC25100 | |
2617 | //purpose : | |
2618 | //======================================================================= | |
2619 | static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
2620 | { | |
2621 | if (argc < 2) | |
2622 | { | |
2623 | di << "the method requires a shape name\n"; | |
2624 | return 1; | |
2625 | } | |
2626 | ||
2627 | TopoDS_Shape S = DBRep::Get(argv[1]); | |
2628 | if ( S.IsNull() ) | |
2629 | { | |
586db386 | 2630 | di << "Shape is empty\n"; |
058f130e | 2631 | return 1; |
2632 | } | |
2633 | ||
2634 | TopExp_Explorer aFaceExp(S, TopAbs_FACE); | |
2635 | const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current())); | |
2636 | ||
2637 | GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion()); | |
2638 | ||
2639 | if (!anIntersector.IsDone()) | |
2640 | { | |
2641 | di << "Error. Intersection is not done\n"; | |
2642 | return 1; | |
2643 | } | |
2644 | ||
2645 | di << "Test complete\n"; | |
2646 | ||
2647 | return 0; | |
2648 | } | |
2649 | ||
5e452c37 | 2650 | //======================================================================= |
2651 | //function : OCC25348 | |
2652 | //purpose : | |
2653 | //======================================================================= | |
2654 | static Standard_Integer OCC25348 (Draw_Interpretor& theDI, | |
2655 | Standard_Integer /*theArgNb*/, | |
2656 | const char** /*theArgVec*/) | |
2657 | { | |
2658 | Handle(NCollection_IncAllocator) anAlloc1; | |
2659 | NCollection_List<int> aList1(anAlloc1); | |
2660 | for (int i=0; i < 10; i++) | |
2661 | { | |
2662 | Handle(NCollection_IncAllocator) anAlloc2; | |
2663 | NCollection_List<int> aList2(anAlloc2); | |
2664 | aList2.Append(i); | |
2665 | aList1.Assign(aList2); | |
2666 | } | |
2667 | theDI << "Test complete\n"; | |
2668 | return 0; | |
2669 | } | |
2670 | ||
6fb3418e | 2671 | #include <IntCurvesFace_ShapeIntersector.hxx> |
2672 | #include <BRepBndLib.hxx> | |
2673 | //======================================================================= | |
2674 | //function : OCC25413 | |
2675 | //purpose : | |
2676 | //======================================================================= | |
2677 | static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a) | |
2678 | { | |
2679 | if (narg != 2) { | |
586db386 | 2680 | di << "Usage: " << a[0] << " invalid number of arguments\n"; |
6fb3418e | 2681 | return 1; |
2682 | } | |
2683 | TopoDS_Shape aShape = DBRep::Get (a[1]); | |
2684 | ||
2685 | IntCurvesFace_ShapeIntersector Inter; | |
2686 | Inter.Load(aShape, Precision::Confusion()); | |
2687 | ||
2688 | Bnd_Box aBndBox; | |
2689 | BRepBndLib::Add(aShape, aBndBox); | |
2690 | ||
2691 | gp_Dir aDir(0., 1., 0.); | |
2692 | const int N = 250; | |
2693 | Standard_Real xMin = aBndBox.CornerMin().X(); | |
2694 | Standard_Real zMin = aBndBox.CornerMin().Z(); | |
2695 | Standard_Real xMax = aBndBox.CornerMax().X(); | |
2696 | Standard_Real zMax = aBndBox.CornerMax().Z(); | |
2697 | Standard_Real xStep = (xMax - xMin) / N; | |
2698 | Standard_Real zStep = (zMax - zMin) / N; | |
2699 | ||
2700 | for (Standard_Real x = xMin; x <= xMax; x += xStep) | |
2701 | for (Standard_Real z = zMin; z <= zMax; z += zStep) | |
2702 | { | |
2703 | gp_Pnt aPoint(x, 0.0, z); | |
2704 | gp_Lin aLine(aPoint, aDir); | |
2705 | Inter.PerformNearest(aLine, -100., 100.); | |
2706 | } | |
2707 | return 0; | |
2708 | } | |
058f130e | 2709 | |
c088aa93 | 2710 | |
2711 | #include <BOPAlgo_PaveFiller.hxx> | |
2712 | // | |
2713 | #include <BRepAlgoAPI_BooleanOperation.hxx> | |
2714 | #include <BRepAlgoAPI_Common.hxx> | |
2715 | #include <BRepAlgoAPI_Fuse.hxx> | |
2716 | #include <BRepAlgoAPI_Cut.hxx> | |
2717 | #include <BRepAlgoAPI_Section.hxx> | |
2718 | // | |
1155d05a | 2719 | #include <TopExp.hxx> |
2720 | #include <TopTools_MapOfShape.hxx> | |
c088aa93 | 2721 | //======================================================================= |
2722 | //function : OCC25446 | |
2723 | //purpose : | |
2724 | //======================================================================= | |
2725 | static Standard_Integer OCC25446 (Draw_Interpretor& theDI, | |
2726 | Standard_Integer argc, | |
2727 | const char ** argv) | |
2728 | { | |
2729 | if (argc != 5) { | |
2730 | theDI << "Usage: OCC25446 res b1 b2 op\n"; | |
2731 | return 1; | |
2732 | } | |
2733 | // | |
2734 | TopoDS_Shape aS1 = DBRep::Get(argv[2]); | |
2735 | if (aS1.IsNull()) { | |
2736 | theDI << argv[2] << " shape is NULL\n"; | |
2737 | return 1; | |
2738 | } | |
2739 | // | |
2740 | TopoDS_Shape aS2 = DBRep::Get(argv[3]); | |
2741 | if (aS2.IsNull()) { | |
2742 | theDI << argv[3] << " shape is NULL\n"; | |
2743 | return 1; | |
2744 | } | |
2745 | // | |
2746 | Standard_Integer iOp; | |
2747 | BOPAlgo_Operation aOp; | |
2748 | // | |
2749 | iOp = Draw::Atoi(argv[4]); | |
2750 | if (iOp < 0 || iOp > 4) { | |
2751 | theDI << "Invalid operation type\n"; | |
2752 | return 1; | |
2753 | } | |
2754 | aOp = (BOPAlgo_Operation)iOp; | |
2755 | // | |
2756 | Standard_Integer iErr; | |
1155d05a | 2757 | TopTools_ListOfShape aLS; |
c088aa93 | 2758 | BOPAlgo_PaveFiller aPF; |
2759 | // | |
2760 | aLS.Append(aS1); | |
2761 | aLS.Append(aS2); | |
2762 | aPF.SetArguments(aLS); | |
2763 | // | |
2764 | aPF.Perform(); | |
33ba8565 | 2765 | iErr = aPF.HasErrors(); |
c088aa93 | 2766 | if (iErr) { |
2767 | theDI << "Intersection failed with error status: " << iErr << "\n"; | |
2768 | return 1; | |
2769 | } | |
2770 | // | |
2771 | BRepAlgoAPI_BooleanOperation* pBuilder = NULL; | |
2772 | // | |
2773 | switch (aOp) { | |
2774 | case BOPAlgo_COMMON: | |
2775 | pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF); | |
2776 | break; | |
2777 | case BOPAlgo_FUSE: | |
2778 | pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF); | |
2779 | break; | |
2780 | case BOPAlgo_CUT: | |
2781 | pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF); | |
2782 | break; | |
2783 | case BOPAlgo_CUT21: | |
2784 | pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False); | |
2785 | break; | |
2786 | case BOPAlgo_SECTION: | |
2787 | pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF); | |
2788 | break; | |
2789 | default: | |
2790 | break; | |
2791 | } | |
2792 | // | |
33ba8565 | 2793 | iErr = pBuilder->HasErrors(); |
c088aa93 | 2794 | if (!pBuilder->IsDone()) { |
2795 | theDI << "BOP failed with error status: " << iErr << "\n"; | |
2796 | return 1; | |
2797 | } | |
2798 | // | |
2799 | const TopoDS_Shape& aRes = pBuilder->Shape(); | |
2800 | DBRep::Set(argv[1], aRes); | |
2801 | // | |
1155d05a | 2802 | TopTools_MapOfShape aMapArgs, aMapShape; |
2803 | TopTools_MapIteratorOfMapOfShape aIt; | |
c088aa93 | 2804 | Standard_Boolean bIsDeletedHist, bIsDeletedMap; |
2805 | TopAbs_ShapeEnum aType; | |
2806 | // | |
1155d05a | 2807 | TopExp::MapShapes(aS1, aMapArgs); |
2808 | TopExp::MapShapes(aS2, aMapArgs); | |
2809 | TopExp::MapShapes(aRes, aMapShape); | |
c088aa93 | 2810 | // |
2811 | aIt.Initialize(aMapArgs); | |
2812 | for (; aIt.More(); aIt.Next()) { | |
2813 | const TopoDS_Shape& aS = aIt.Value(); | |
2814 | aType = aS.ShapeType(); | |
2815 | if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE || | |
2816 | aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) { | |
2817 | continue; | |
2818 | } | |
2819 | // | |
2820 | bIsDeletedHist = pBuilder->IsDeleted(aS); | |
2821 | bIsDeletedMap = !aMapShape.Contains(aS) && | |
2822 | (pBuilder->Modified(aS).Extent() == 0); | |
2823 | // | |
2824 | if (bIsDeletedHist != bIsDeletedMap) { | |
2825 | theDI << "Error. Wrong value of IsDeleted flag.\n"; | |
2826 | return 1; | |
2827 | } | |
2828 | } | |
2829 | // | |
2830 | theDI << "Test complete\n"; | |
2831 | return 0; | |
2832 | } | |
2833 | ||
ee6bb37b | 2834 | //==================================================== |
2835 | // Auxiliary functor class for the command OCC25545; | |
2836 | // it gets access to a vertex with the given index and | |
2837 | // checks that X coordinate of the point is equal to index; | |
2838 | // if it is not so then a data race is reported. | |
2839 | //==================================================== | |
2840 | struct OCC25545_Functor | |
2841 | { | |
2842 | OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec) | |
2843 | : myShapeVec(&theShapeVec), | |
2844 | myIsRaceDetected(0) | |
2845 | {} | |
2846 | ||
2847 | void operator()(size_t i) const | |
2848 | { | |
2849 | if (!myIsRaceDetected) { | |
2850 | const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i)); | |
2851 | gp_Pnt aP = BRep_Tool::Pnt (aV); | |
2852 | if (aP.X () != static_cast<double> (i)) { | |
2853 | Standard_Atomic_Increment(&myIsRaceDetected); | |
2854 | } | |
2855 | } | |
2856 | } | |
2857 | ||
2858 | const std::vector<TopoDS_Shape>* myShapeVec; | |
2859 | mutable volatile int myIsRaceDetected; | |
2860 | }; | |
2861 | ||
2862 | //======================================================================= | |
2863 | //function : OCC25545 | |
2864 | //purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation() | |
2865 | //======================================================================= | |
00af0ebb | 2866 | |
ee6bb37b | 2867 | static Standard_Integer OCC25545 (Draw_Interpretor& di, |
2868 | Standard_Integer, | |
2869 | const char **) | |
2870 | { | |
2871 | // Place vertices in a vector, giving the i-th vertex the | |
2872 | // transformation that translates it on the vector (i,0,0) from the origin. | |
00af0ebb | 2873 | Standard_Integer n = 1000; |
ee6bb37b | 2874 | std::vector<TopoDS_Shape> aShapeVec (n); |
2875 | std::vector<TopLoc_Location> aLocVec (n); | |
2876 | TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ()); | |
2877 | aShapeVec[0] = aShape; | |
00af0ebb | 2878 | for (Standard_Integer i = 1; i < n; ++i) { |
ee6bb37b | 2879 | gp_Trsf aT; |
2880 | aT.SetTranslation (gp_Vec (1, 0, 0)); | |
2881 | aLocVec[i] = aLocVec[i - 1] * aT; | |
2882 | aShapeVec[i] = aShape.Moved (aLocVec[i]); | |
2883 | } | |
2884 | ||
2885 | // Evaluator function will access vertices geometry | |
2886 | // concurrently | |
2887 | OCC25545_Functor aFunc(aShapeVec); | |
2888 | ||
00af0ebb | 2889 | // concurrently process |
2890 | OSD_Parallel::For (0, n, aFunc); | |
2891 | ||
ee6bb37b | 2892 | QVERIFY (!aFunc.myIsRaceDetected); |
2893 | return 0; | |
2894 | } | |
ee6bb37b | 2895 | |
d315303d | 2896 | //======================================================================= |
2897 | //function : OCC25547 | |
2898 | //purpose : | |
2899 | //======================================================================= | |
2900 | #include <BRepMesh_GeomTool.hxx> | |
2901 | #include <BRepAdaptor_Curve.hxx> | |
2902 | #include <Geom_TrimmedCurve.hxx> | |
2903 | #include <BRepBuilderAPI_MakeFace.hxx> | |
2904 | #include <BRepAdaptor_HSurface.hxx> | |
2905 | #include <BRepAdaptor_Surface.hxx> | |
2906 | static Standard_Integer OCC25547( | |
2907 | Draw_Interpretor& theDI, | |
2908 | Standard_Integer /*argc*/, | |
2909 | const char ** /*argv*/) | |
2910 | { | |
2911 | // The general aim of this test is to prevent linkage errors due to missed | |
2912 | // Standard_EXPORT attribute for static methods. | |
2913 | ||
2914 | // However, start checking the main functionality at first. | |
2915 | const Standard_Real aFirstP = 0., aLastP = M_PI; | |
2916 | Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10); | |
2917 | Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP); | |
2918 | TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf); | |
2919 | BRepAdaptor_Curve aAdaptor(aEdge); | |
2920 | BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5); | |
2921 | ||
2922 | if (aGeomTool.NbPoints() == 0) | |
2923 | { | |
2924 | theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n"; | |
2925 | return 1; | |
2926 | } | |
2927 | ||
2928 | // Test static methods. | |
2929 | TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ())); | |
2930 | BRepAdaptor_Surface aSurf(aFace); | |
2931 | Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf); | |
2932 | ||
2933 | gp_Pnt aPnt; | |
2934 | gp_Dir aNormal; | |
2935 | if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal)) | |
2936 | { | |
2937 | theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n"; | |
2938 | return 1; | |
2939 | } | |
2940 | ||
2941 | gp_XY aRefPnts[4] = { | |
2942 | gp_XY(-10., -10.), gp_XY(10., 10.), | |
2943 | gp_XY(-10., 10.), gp_XY(10., -10.) | |
2944 | }; | |
2945 | ||
2946 | gp_Pnt2d aIntPnt; | |
2947 | Standard_Real aParams[2]; | |
2948 | BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin( | |
2949 | aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3], | |
2950 | aIntPnt.ChangeCoord(), aParams); | |
2951 | ||
2952 | Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d()); | |
2953 | if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion()) | |
2954 | { | |
2955 | theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n"; | |
2956 | return 1; | |
2957 | } | |
2958 | ||
2959 | aIntFlag = BRepMesh_GeomTool::IntSegSeg( | |
2960 | aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3], | |
2961 | Standard_False, Standard_False, aIntPnt); | |
2962 | ||
2963 | aDiff = aIntPnt.Distance(gp::Origin2d()); | |
2964 | if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion()) | |
2965 | { | |
2966 | theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n"; | |
2967 | return 1; | |
2968 | } | |
2969 | ||
2970 | ||
2971 | theDI << "Test complete\n"; | |
2972 | return 0; | |
2973 | } | |
2974 | ||
ec81011f | 2975 | static Standard_Integer OCC26139 (Draw_Interpretor& theDI, |
2976 | Standard_Integer argc, | |
2977 | const char ** argv) | |
2978 | { | |
2979 | ||
2980 | Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); | |
2981 | if (aCtx.IsNull()) | |
2982 | { | |
2983 | theDI << "Use 'vinit' command before " << argv[0] << "\n"; | |
2984 | return 1; | |
2985 | } | |
2986 | ||
2987 | Standard_Integer aBoxGridSize = 100; | |
2988 | Standard_Integer aCompGridSize = 3; | |
2989 | Standard_Real aBoxSize = 5.0; | |
2990 | ||
2991 | if (argc > 1) | |
2992 | { | |
2993 | for (Standard_Integer anArgIdx = 1; anArgIdx < argc; ++anArgIdx) | |
2994 | { | |
2995 | TCollection_AsciiString anArg (argv[anArgIdx]); | |
2996 | anArg.LowerCase(); | |
2997 | if (anArg == "-boxgrid") | |
2998 | { | |
2999 | aBoxGridSize = Draw::Atoi (argv[++anArgIdx]); | |
3000 | } | |
3001 | else if (anArg == "-compgrid") | |
3002 | { | |
3003 | aCompGridSize = Draw::Atoi (argv[++anArgIdx]); | |
3004 | } | |
3005 | else if (anArg == "-boxsize") | |
3006 | { | |
3007 | aBoxSize = Draw::Atof (argv[++anArgIdx]); | |
3008 | } | |
3009 | } | |
3010 | } | |
3011 | ||
3012 | NCollection_List<Handle(AIS_Shape)> aCompounds; | |
3013 | for (Standard_Integer aCompGridX = 0; aCompGridX < aCompGridSize; ++aCompGridX) | |
3014 | { | |
3015 | for (Standard_Integer aCompGridY = 0; aCompGridY < aCompGridSize; ++aCompGridY) | |
3016 | { | |
3017 | BRep_Builder aBuilder; | |
3018 | TopoDS_Compound aComp; | |
3019 | aBuilder.MakeCompound (aComp); | |
3020 | for (Standard_Integer aBoxGridX = 0; aBoxGridX < aBoxGridSize; ++aBoxGridX) | |
3021 | { | |
3022 | for (Standard_Integer aBoxGridY = 0; aBoxGridY < aBoxGridSize; ++aBoxGridY) | |
3023 | { | |
3024 | BRepPrimAPI_MakeBox aBox (gp_Pnt (aBoxGridX * aBoxSize, aBoxGridY * aBoxSize, 0.0), | |
3025 | aBoxSize, aBoxSize, aBoxSize); | |
3026 | aBuilder.Add (aComp, aBox.Shape()); | |
3027 | } | |
3028 | } | |
3029 | gp_Trsf aTrsf; | |
3030 | aTrsf.SetTranslation (gp_Vec (aBoxGridSize * aBoxSize * aCompGridX, | |
3031 | aBoxGridSize * aBoxSize * aCompGridY, | |
3032 | 0.0)); | |
3033 | TopLoc_Location aLoc (aTrsf); | |
3034 | aComp.Located (aLoc); | |
3035 | aCompounds.Append (new AIS_Shape (aComp)); | |
3036 | } | |
3037 | } | |
3038 | ||
3039 | OSD_Timer aTimer; | |
3040 | for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next()) | |
3041 | { | |
3042 | aTimer.Start(); | |
3043 | aCtx->Display (aCompIter.Value(), Standard_False); | |
3044 | aTimer.Stop(); | |
3045 | theDI << "Display time: " << aTimer.ElapsedTime() << "\n"; | |
3046 | aTimer.Reset(); | |
3047 | } | |
3048 | ||
3049 | aTimer.Reset(); | |
3050 | aTimer.Start(); | |
3051 | for (NCollection_List<Handle(AIS_Shape)>::Iterator aCompIter (aCompounds); aCompIter.More(); aCompIter.Next()) | |
3052 | { | |
3053 | aCtx->Remove (aCompIter.Value(), Standard_False); | |
3054 | } | |
3055 | aTimer.Stop(); | |
3056 | theDI << "Remove time: " << aTimer.ElapsedTime() << "\n"; | |
3057 | ||
3058 | return 0; | |
3059 | } | |
3060 | ||
2bfe59b6 | 3061 | #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx> |
3062 | #include <TColStd_DataMapOfIntegerInteger.hxx> | |
3063 | #include <OSD.hxx> | |
3064 | #include <ShapeFix_Wire.hxx> | |
3065 | #include <ShapeExtend_Status.hxx> | |
57c28b61 | 3066 | #ifdef _WIN32 |
2bfe59b6 | 3067 | #define EXCEPTION ... |
3068 | #else | |
3069 | #define EXCEPTION Standard_Failure | |
3070 | #endif | |
3071 | ||
3072 | static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)& theFix, | |
3073 | const Standard_Boolean theIs3d) | |
3074 | { | |
3075 | for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++) | |
3076 | { | |
3077 | Standard_Boolean isFound; | |
3078 | if (theIs3d) | |
3079 | isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i ); | |
3080 | else | |
3081 | isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i ); | |
3082 | if (isFound) return ShapeExtend_Status(i); | |
3083 | } | |
3084 | return ShapeExtend_OK; | |
3085 | } | |
3086 | ||
3087 | //=================== | |
3088 | //function : OCC24881 | |
3089 | //purpose : | |
3090 | //=================== | |
3091 | static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a) | |
3092 | { | |
3093 | if (narg < 2) { | |
586db386 | 3094 | di<<"Usage: "<<a[0]<<" invalid number of arguments\n"; |
2bfe59b6 | 3095 | return 1; |
3096 | } | |
3097 | // cout <<"FileName1: " << argv[1] <<endl; | |
3098 | ||
3099 | TopoDS_Shape aShape = DBRep::Get (a[1]); | |
3100 | ||
3101 | OSD::SetSignal(); | |
3102 | Handle(ShapeFix_Wire) aWireFix = new ShapeFix_Wire; | |
3103 | ||
3104 | // map FixStatus - NbSuchStatuses | |
3105 | TColStd_DataMapOfIntegerInteger aStatusNbDMap; | |
3106 | Standard_Integer nbFixed=0, nbOk=0; | |
3107 | ||
3108 | //Begin: STEP 7 | |
3109 | ShapeExtend_Status aStatus=ShapeExtend_OK; | |
3110 | try { | |
3111 | TopExp_Explorer aFaceExplorer(aShape, TopAbs_FACE); | |
3112 | for (; aFaceExplorer.More(); aFaceExplorer.Next()) | |
3113 | { | |
3114 | TopoDS_Shape aFace = aFaceExplorer.Current(); | |
3115 | // loop on wires | |
3116 | TopoDS_Iterator aWireItr(aFace); | |
3117 | for (; aWireItr.More(); aWireItr.Next() ) | |
3118 | { | |
3119 | Standard_Boolean wasOk = Standard_False; | |
3120 | TopoDS_Wire aSrcWire = TopoDS::Wire(aWireItr.Value()); | |
3121 | ||
3122 | aWireFix->Load (aSrcWire); | |
3123 | aWireFix->SetFace (TopoDS::Face(aFace)); | |
3124 | aWireFix->FixReorder(); //correct order is a prerequisite | |
3125 | // fix 3d | |
3126 | if (!aWireFix->FixGaps3d()) | |
3127 | { | |
3128 | // not fixed, why? | |
3129 | aStatus = getStatusGap(aWireFix, Standard_True); | |
3130 | if (aStatus == ShapeExtend_OK) | |
3131 | wasOk = Standard_True; | |
3132 | else | |
3133 | { | |
3134 | // keep 3d fail status | |
3135 | if (aStatusNbDMap.IsBound (aStatus)) | |
3136 | aStatusNbDMap(aStatus)++; | |
3137 | else | |
3138 | aStatusNbDMap.Bind(aStatus,1); | |
3139 | continue; | |
3140 | } | |
3141 | } | |
3142 | ||
3143 | // fix 2d | |
3144 | if (aWireFix->FixGaps2d()) | |
3145 | nbFixed++; | |
3146 | else | |
3147 | { | |
3148 | aStatus = getStatusGap(aWireFix, Standard_False); | |
3149 | if (aStatus == ShapeExtend_OK) | |
3150 | { | |
3151 | if (wasOk) | |
3152 | { | |
3153 | nbOk++; | |
3154 | continue; | |
3155 | } | |
3156 | else | |
3157 | nbFixed++; | |
3158 | } | |
3159 | else | |
3160 | { | |
3161 | // keep 2d fail status | |
3162 | Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL; | |
3163 | if (aStatusNbDMap.IsBound (aStatus2d)) | |
3164 | aStatusNbDMap(aStatus2d)++; | |
3165 | else | |
3166 | aStatusNbDMap.Bind(aStatus2d,1); | |
3167 | continue; | |
3168 | } | |
3169 | } | |
3170 | } | |
3171 | } | |
3172 | //End: STEP 7 | |
3173 | } catch (EXCEPTION) { | |
3174 | di << "Exception is raised = " <<aStatus << "\n"; | |
3175 | return 1; | |
3176 | ||
3177 | } | |
3178 | // report what is done | |
3179 | ||
3180 | if (nbFixed) | |
3181 | { | |
3182 | di <<"Fix_FillGaps_Fixed: nbFixed = "<<nbFixed <<"\n"; | |
3183 | ||
3184 | } | |
3185 | if (nbOk) | |
3186 | { | |
586db386 | 3187 | di << "Fix_FillGaps_NothingToDo\n"; |
2bfe59b6 | 3188 | |
3189 | } | |
3190 | TColStd_DataMapIteratorOfDataMapOfIntegerInteger aStatusItr(aStatusNbDMap); | |
3191 | for (; aStatusItr.More(); aStatusItr.Next()) | |
3192 | { | |
3193 | switch ((ShapeExtend_Status) aStatusItr.Key()) | |
3194 | { | |
3195 | // treat 3d status | |
3196 | case ShapeExtend_FAIL1: | |
3197 | di <<"Fix_FillGaps_3dNoCurveFail, nb failed = "; | |
3198 | break; | |
3199 | case ShapeExtend_FAIL2: | |
3200 | di <<"Fix_FillGaps_3dSomeGapsFail, nb failed = "; | |
3201 | break; | |
3202 | default: | |
3203 | // treat 2d status | |
3204 | switch ((ShapeExtend_Status) (aStatusItr.Key() - ShapeExtend_FAIL)) | |
3205 | { | |
3206 | case ShapeExtend_FAIL1: | |
3207 | di <<"Fix_FillGaps_2dNoPCurveFail, nb failed = "; | |
3208 | break; | |
3209 | case ShapeExtend_FAIL2: | |
3210 | di <<"Fix_FillGaps_2dSomeGapsFail, nb failed = "; | |
3211 | break; | |
3212 | default: | |
3213 | break; | |
3214 | } | |
3215 | } | |
3216 | di <<aStatusItr.Value()<< "\n"; | |
3217 | } | |
3218 | di << ("__________________________________") <<"\n"; | |
3219 | ||
3220 | return 0; | |
3221 | } | |
3222 | ||
c070aa39 | 3223 | //======================================================================= |
3224 | //function : OCC26172 | |
3225 | //purpose : | |
3226 | //======================================================================= | |
3227 | static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
3228 | { | |
3229 | if (theArgNb != 1) | |
3230 | { | |
3231 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
3232 | theDI.PrintHelp (theArgVec[0]); | |
3233 | return 1; | |
3234 | } | |
3235 | ||
3236 | Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext(); | |
3237 | if(anAISContext.IsNull()) | |
3238 | { | |
3239 | std::cerr << "Error: no active view. Please call vinit.\n"; | |
3240 | return 1; | |
3241 | } | |
3242 | ||
3243 | gp_Pnt aStart (100, 100, 100); | |
3244 | gp_Pnt anEnd (300, 400, 600); | |
3245 | BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd); | |
3246 | TopoDS_Edge anEdge = anEdgeBuilder.Edge(); | |
3247 | Handle(AIS_Shape) aTestAISShape = new AIS_Shape (anEdge); | |
0577ae8c | 3248 | anAISContext->Display (aTestAISShape, Standard_True); |
c070aa39 | 3249 | |
3250 | // 2. activate it in selection modes | |
3251 | TColStd_SequenceOfInteger aModes; | |
3252 | aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX)); | |
3253 | aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_EDGE)); | |
3254 | ||
404c8936 | 3255 | Standard_DISABLE_DEPRECATION_WARNINGS |
c070aa39 | 3256 | anAISContext->OpenLocalContext(); |
404c8936 | 3257 | Standard_ENABLE_DEPRECATION_WARNINGS |
c070aa39 | 3258 | anAISContext->Deactivate (aTestAISShape); |
3259 | anAISContext->Load (aTestAISShape, -1, true); | |
3260 | for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt) | |
3261 | { | |
3262 | anAISContext->Activate (aTestAISShape, aModes (anIt)); | |
3263 | } | |
3264 | ||
3265 | // select entities in vertex selection mode | |
3266 | Handle(SelectMgr_Selection) aSelection = aTestAISShape->Selection (aModes (1)); | |
404c8936 | 3267 | Standard_DISABLE_DEPRECATION_WARNINGS |
c070aa39 | 3268 | for (aSelection->Init(); aSelection->More(); aSelection->Next()) |
3269 | { | |
3270 | Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive(); | |
3271 | if (anEntity.IsNull()) | |
3272 | { | |
3273 | continue; | |
3274 | } | |
3275 | ||
3276 | Handle(SelectMgr_EntityOwner) anOwner = | |
3277 | Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId()); | |
3278 | ||
3279 | if (anOwner.IsNull()) | |
3280 | { | |
3281 | continue; | |
3282 | } | |
3283 | ||
3284 | anAISContext->LocalContext()->AddOrRemoveSelected (anOwner); | |
3285 | } | |
404c8936 | 3286 | Standard_ENABLE_DEPRECATION_WARNINGS |
c070aa39 | 3287 | |
3288 | // select entities in edge selection mode | |
3289 | aSelection = aTestAISShape->Selection (aModes (2)); | |
404c8936 | 3290 | Standard_DISABLE_DEPRECATION_WARNINGS |
c070aa39 | 3291 | for (aSelection->Init(); aSelection->More(); aSelection->Next()) |
3292 | { | |
3293 | Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive(); | |
3294 | if (anEntity.IsNull()) | |
3295 | { | |
3296 | continue; | |
3297 | } | |
3298 | ||
3299 | Handle(SelectMgr_EntityOwner) anOwner = | |
3300 | Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId()); | |
3301 | ||
3302 | if (anOwner.IsNull()) | |
3303 | { | |
3304 | continue; | |
3305 | } | |
3306 | ||
3307 | anAISContext->LocalContext()->AddOrRemoveSelected (anOwner); | |
3308 | } | |
404c8936 | 3309 | Standard_ENABLE_DEPRECATION_WARNINGS |
c070aa39 | 3310 | |
3311 | // deactivate vertex mode and check clearing of outdated selection | |
3312 | anAISContext->Deactivate (aTestAISShape, aModes (1)); | |
404c8936 | 3313 | Standard_DISABLE_DEPRECATION_WARNINGS |
c070aa39 | 3314 | anAISContext->LocalContext()->ClearOutdatedSelection (aTestAISShape, true); |
404c8936 | 3315 | Standard_ENABLE_DEPRECATION_WARNINGS |
c070aa39 | 3316 | |
3317 | return 0; | |
3318 | } | |
3319 | ||
e11850fd | 3320 | //======================================================================= |
3321 | //function : OCC26284 | |
3322 | //purpose : | |
3323 | //======================================================================= | |
3324 | static Standard_Integer OCC26284 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
3325 | { | |
3326 | if (theArgNb != 1) | |
3327 | { | |
3328 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
3329 | theDI.PrintHelp (theArgVec[0]); | |
3330 | return 1; | |
3331 | } | |
3332 | ||
3333 | Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext(); | |
3334 | if (anAISContext.IsNull()) | |
3335 | { | |
3336 | std::cerr << "Error: no active view. Please call vinit.\n"; | |
3337 | return 1; | |
3338 | } | |
3339 | ||
3340 | BRepPrimAPI_MakeSphere aSphereBuilder (gp_Pnt (0.0, 0.0, 0.0), 1.0); | |
3341 | Handle(AIS_Shape) aSphere = new AIS_Shape (aSphereBuilder.Shape()); | |
0577ae8c | 3342 | anAISContext->Display (aSphere, Standard_False); |
e11850fd | 3343 | for (Standard_Integer aChildIdx = 0; aChildIdx < 5; ++aChildIdx) |
3344 | { | |
3345 | BRepPrimAPI_MakeSphere aBuilder (gp_Pnt (1.0 + aChildIdx, 1.0 + aChildIdx, 1.0 + aChildIdx), 1.0); | |
3346 | Handle(AIS_Shape) aChild = new AIS_Shape (aBuilder.Shape()); | |
3347 | aSphere->AddChild (aChild); | |
0577ae8c | 3348 | anAISContext->Display (aChild, Standard_False); |
e11850fd | 3349 | } |
3350 | ||
3351 | anAISContext->RecomputeSelectionOnly (aSphere); | |
0577ae8c | 3352 | anAISContext->UpdateCurrentViewer(); |
e11850fd | 3353 | |
3354 | return 0; | |
3355 | } | |
3356 | ||
9bf3177f | 3357 | #include <IntTools_Context.hxx> |
3358 | #include <GeomAPI_ProjectPointOnSurf.hxx> | |
3359 | ||
3360 | //======================================================================= | |
3361 | //function : xprojponf | |
3362 | //purpose : | |
3363 | //======================================================================= | |
3364 | Standard_Integer xprojponf (Draw_Interpretor& di, | |
3365 | Standard_Integer n, | |
3366 | const char** a) | |
3367 | { | |
3368 | if (n!=3) { | |
3369 | di<<" use xprojponf p f \n"; | |
3370 | return 0; | |
3371 | } | |
3372 | // | |
3373 | gp_Pnt aP, aPS; | |
3374 | TopoDS_Shape aS; | |
3375 | TopoDS_Face aF; | |
3376 | Handle(IntTools_Context) aCtx; | |
3377 | // | |
3378 | DrawTrSurf::GetPoint(a[1], aP); | |
3379 | aS=DBRep::Get(a[2]); | |
3380 | // | |
3381 | if (aS.IsNull()) { | |
3382 | di<<" null shape is not allowed\n"; | |
3383 | return 0; | |
3384 | } | |
3385 | // | |
3386 | if (aS.ShapeType()!=TopAbs_FACE) { | |
3387 | di << a[2] << " not a face\n"; | |
3388 | return 0; | |
3389 | } | |
3390 | // | |
3391 | aCtx=new IntTools_Context; | |
3392 | // | |
3393 | aF=TopoDS::Face(aS); | |
3394 | GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF); | |
3395 | // | |
3396 | aPPS.Perform(aP); | |
3397 | if (!aPPS.IsDone()) { | |
3398 | di<<" projection failed\n"; | |
3399 | return 0; | |
3400 | } | |
3401 | // | |
3402 | aPS=aPPS.NearestPoint(); | |
3403 | di<< " point px " << aPS.X() << " " << aPS.Y() << " " << aPS.Z() << "\n"; | |
3404 | // | |
3405 | return 0; | |
3406 | } | |
3407 | ||
ec26bf88 | 3408 | //======================================================================= |
3409 | //function : OCC25547 | |
3410 | //purpose : | |
3411 | //======================================================================= | |
3412 | #include <BRepMesh_CircleTool.hxx> | |
ec357c5c | 3413 | #include <SelectMgr_EntityOwner.hxx> |
ec26bf88 | 3414 | |
3415 | static Standard_Boolean inspect_point(const gp_XY& thePoint, | |
3416 | const gp_XY& theCenter, | |
3417 | const Standard_Real theRadius) | |
3418 | { | |
3419 | static Standard_Real aPrecision = Precision::PConfusion(); | |
3420 | static Standard_Real aSqPrecision = aPrecision * aPrecision; | |
3421 | const gp_XY aDistVec = thePoint - theCenter; | |
3422 | if (aDistVec.SquareModulus() - (theRadius * theRadius) < aSqPrecision) | |
3423 | return Standard_True; | |
3424 | else | |
3425 | return Standard_False; | |
3426 | } | |
3427 | ||
3428 | static Standard_Integer OCC24923( | |
3429 | Draw_Interpretor& theDI, | |
3430 | Standard_Integer argc, | |
3431 | const char ** argv) | |
3432 | { | |
3433 | srand(static_cast<unsigned int>(time(NULL))); | |
3434 | ||
3435 | const Standard_Real aMaxDeviation = (argc > 1) ? Draw::Atof(argv[1]) : 0.01; | |
3436 | const Standard_Integer aPointsNb = 10000000; | |
3437 | const Standard_Real aMinAngle = 5 * M_PI / 180.; | |
3438 | static Standard_Real aSqPrecision = Precision::PConfusion() * Precision::PConfusion(); | |
3439 | ||
3440 | Standard_Integer aFailedNb = 0; | |
3441 | for (Standard_Integer i = 0; i < aPointsNb; ++i) | |
3442 | { | |
3443 | gp_XY p[3]; | |
3444 | for (Standard_Integer j = 0; j < 3; ++j) | |
3445 | p[j].SetCoord(((Standard_Real)rand())/RAND_MAX, ((Standard_Real)rand())/RAND_MAX); | |
3446 | ||
3447 | // Check that points do not compose degenerated triangle. | |
3448 | gp_XY aVec1 = p[1] - p[0]; | |
3449 | gp_XY aVec2 = p[2] - p[0]; | |
3450 | if (aVec1.SquareModulus() > aSqPrecision && | |
3451 | aVec2.SquareModulus() > aSqPrecision && | |
3452 | (aVec1 ^ aVec2) > aMinAngle) | |
3453 | { | |
3454 | gp_XY aCenter; | |
3455 | Standard_Real aRadius; | |
3456 | if (BRepMesh_CircleTool::MakeCircle(p[0], p[1], p[2], aCenter, aRadius)) | |
3457 | { | |
3458 | if (!inspect_point(p[0], aCenter, aRadius) || | |
3459 | !inspect_point(p[1], aCenter, aRadius) || | |
3460 | !inspect_point(p[2], aCenter, aRadius)) | |
3461 | { | |
3462 | /* theDI << "Missed: " << | |
3463 | "p1=(" << p1.X() << ", " << p1.Y() << "), " << | |
3464 | "p2=(" << p2.X() << ", " << p2.Y() << "), " << | |
3465 | "p3=(" << p3.X() << ", " << p3.Y() << "), " << | |
3466 | "c=(" << aCenter.X() << ", " << aCenter.Y() << "), " << | |
3467 | "r=" << aRadius << "\n";*/ | |
3468 | ||
3469 | ++aFailedNb; | |
3470 | } | |
3471 | ||
3472 | continue; | |
3473 | } | |
3474 | } | |
3475 | ||
3476 | // Ensure that aPointsNb suitable for tests are generated | |
3477 | --i; | |
3478 | } | |
3479 | ||
3480 | const Standard_Real aDeviation = | |
3481 | 1. - (Standard_Real)(aPointsNb - aFailedNb) / (Standard_Real)aPointsNb; | |
3482 | ||
0e443e13 | 3483 | theDI << "Number of incorrect cases: " << aFailedNb << " (Total " << aPointsNb << ")\n"; |
ec26bf88 | 3484 | if (aDeviation > aMaxDeviation) |
3485 | { | |
3486 | theDI << "Failed. Number of incorrect results is too huge: " << | |
586db386 | 3487 | aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n"; |
ec26bf88 | 3488 | return 1; |
3489 | } | |
3490 | ||
3491 | theDI << "Deviation of incorrect results is: " << | |
586db386 | 3492 | aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)\n"; |
ec26bf88 | 3493 | theDI << "Test completed\n"; |
3494 | return 0; | |
3495 | } | |
3496 | ||
4f5ad416 | 3497 | //======================================================================= |
3498 | //function : OCC25574 | |
3499 | //purpose : check implementation of Euler angles in gp_Quaternion | |
3500 | //======================================================================= | |
3501 | ||
3502 | static Standard_Integer OCC25574 (Draw_Interpretor& theDI, Standard_Integer /*argc*/, const char** /*argv*/) | |
3503 | { | |
3504 | Standard_Boolean isTestOk = Standard_True; | |
3505 | ||
3506 | // Check consistency of Get and Set operations for Euler angles | |
3507 | gp_Quaternion aQuat; | |
3508 | aQuat.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637); | |
3509 | Standard_Real alpha,beta,gamma; | |
3510 | gp_Mat aRinv = aQuat.GetMatrix().Inverted(); | |
3511 | gp_Mat aI; | |
3512 | aI.SetIdentity(); | |
3513 | const char* names[] = { "Extrinsic_XYZ", "Extrinsic_XZY", "Extrinsic_YZX", "Extrinsic_YXZ", "Extrinsic_ZXY", "Extrinsic_ZYX", | |
3514 | "Intrinsic_XYZ", "Intrinsic_XZY", "Intrinsic_YZX", "Intrinsic_YXZ", "Intrinsic_ZXY", "Intrinsic_ZYX", | |
3515 | "Extrinsic_XYX", "Extrinsic_XZX", "Extrinsic_YZY", "Extrinsic_YXY", "Extrinsic_ZYZ", "Extrinsic_ZXZ", | |
3516 | "Intrinsic_XYX", "Intrinsic_XZX", "Intrinsic_YZY", "Intrinsic_YXY", "Intrinsic_ZXZ", "Intrinsic_ZYZ" }; | |
3517 | for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++) | |
3518 | { | |
3519 | aQuat.GetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma); | |
3520 | ||
3521 | gp_Quaternion aQuat2; | |
3522 | aQuat2.SetEulerAngles (gp_EulerSequence(i), alpha, beta, gamma); | |
3523 | ||
3524 | gp_Mat aR = aQuat2.GetMatrix(); | |
3525 | gp_Mat aDiff = aR * aRinv - aI; | |
3526 | if (aDiff.Determinant() > 1e-5) | |
3527 | { | |
3528 | theDI << "Error: Euler angles conversion incorrect for sequence " << names[i - gp_Extrinsic_XYZ] << "\n"; | |
3529 | isTestOk = Standard_False; | |
3530 | } | |
3531 | } | |
3532 | ||
3533 | // Check conversion between intrinsic and extrinsic rotations | |
3534 | // Any extrinsic rotation is equivalent to an intrinsic rotation | |
3535 | // by the same angles but with inverted order of elemental rotations, and vice versa | |
3536 | // For instance: | |
3537 | // Extrinsic_XZY = Incrinsic_XZY | |
3538 | // R = X(A)Z(B)Y(G) --> R = Y(G)Z(B)X(A) | |
3539 | alpha = 0.1517461713131; | |
3540 | beta = 1.5162198410141; | |
3541 | gamma = 1.9313156236541; | |
3542 | Standard_Real alpha2, beta2, gamma2; | |
3543 | gp_EulerSequence pairs[][2] = { {gp_Extrinsic_XYZ, gp_Intrinsic_ZYX}, | |
3544 | {gp_Extrinsic_XZY, gp_Intrinsic_YZX}, | |
3545 | {gp_Extrinsic_YZX, gp_Intrinsic_XZY}, | |
3546 | {gp_Extrinsic_YXZ, gp_Intrinsic_ZXY}, | |
3547 | {gp_Extrinsic_ZXY, gp_Intrinsic_YXZ}, | |
3548 | {gp_Extrinsic_ZYX, gp_Intrinsic_XYZ} }; | |
3549 | for (int i = 0; i < 6; i++) | |
3550 | { | |
3551 | aQuat.SetEulerAngles(pairs[i][0], alpha, beta, gamma); | |
3552 | aQuat.GetEulerAngles(pairs[i][1], gamma2, beta2, alpha2); | |
3553 | ||
3554 | if (Abs(alpha - alpha2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - gamma2) > 1e-5) | |
3555 | { | |
3556 | theDI << "Error: intrinsic and extrinsic conversion incorrect for sequence " << names[i] << "\n"; | |
3557 | isTestOk = Standard_False; | |
3558 | } | |
3559 | } | |
3560 | ||
3561 | // Check correspondence of enumeration and actual rotation it defines, | |
3562 | // by rotation by one axis and checking that it does not change a point on that axis | |
3563 | for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++) | |
3564 | { | |
3565 | // Iterate over rotations R(A)R(B)R(G) for each Euler angle Alpha, Beta, Gamma | |
3566 | // There are three ordered axes corresponding to three rotations. | |
3567 | // Each rotation applyed with current angle around current axis. | |
3568 | for (int j=0; j < 3; j++) | |
3569 | { | |
3570 | // note that current axis index is obtained by parsing of enumeration name! | |
3571 | int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X'; | |
3572 | Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1); | |
3573 | ||
3574 | // Set 90 degrees to current Euler angle | |
3575 | double anAngles[3] = {0., 0., 0.}; | |
3576 | anAngles[j] = 0.5 * M_PI; | |
3577 | ||
3578 | gp_Quaternion q2; | |
3579 | q2.SetEulerAngles (gp_EulerSequence(i), anAngles[0], anAngles[1], anAngles[2]); | |
3580 | ||
3581 | // Set point on axis corresponding to current rotation | |
3582 | // We will apply rotation around this axis | |
3583 | gp_XYZ v (0., 0., 0.); | |
3584 | v.SetCoord (anAxis + 1, 1.); | |
3585 | ||
3586 | // Apply rotation to point | |
3587 | gp_Trsf aT; | |
3588 | aT.SetRotation (q2); | |
3589 | gp_XYZ v2 = v; | |
3590 | aT.Transforms (v2); | |
3591 | ||
3592 | // Check that point is still on origin position | |
3593 | if ((v - v2).SquareModulus() > Precision::SquareConfusion()) | |
3594 | { | |
3595 | // avoid reporting small coordinates | |
3596 | for (int k=1; k <= 3; k++) | |
3597 | if (Abs (v2.Coord(k)) < Precision::Confusion()) | |
3598 | v2.SetCoord (k, 0.); | |
3599 | ||
3600 | isTestOk = Standard_False; | |
3601 | theDI << "Error: Euler sequence " << names[i - gp_Extrinsic_XYZ] << " is incorrect:\n"; | |
3602 | theDI << "rotating by angle 90 deg around " << (anAxis == 0 ? "X" : anAxis == 1 ? "Y" : "Z") << | |
3603 | " converts vector (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") to (" | |
3604 | << v2.X() << ", " << v2.Y() << ", " << v2.Z() << ")\n"; | |
3605 | } | |
3606 | } | |
3607 | } | |
3608 | ||
3609 | // Check correspondence of enumeration and actual rotation it defines, | |
3610 | // by comparing cumulative rotation matrix with sequence of rotations by axes | |
3611 | const Standard_Real anAngle[3] = { 0.1, 0.2, 0.3 }; | |
3612 | for (int i = gp_Extrinsic_XYZ; i <= gp_Intrinsic_ZYZ; i++) | |
3613 | { | |
3614 | // Sequence of rotations | |
3615 | gp_Mat aR[3]; | |
3616 | for (int j=0; j < 3; j++) | |
3617 | { | |
3618 | // note that current axis index is obtained by parsing of enumeration name! | |
3619 | int anAxis = names[i - gp_Extrinsic_XYZ][10 + j] - 'X'; | |
3620 | Standard_ASSERT_RETURN (anAxis >=0 && anAxis <= 2, "Incorrect parsing of enumeration name", 1); | |
3621 | ||
3622 | // Set point on axis corresponding to current rotation | |
3623 | // We will apply rotation around this axis | |
3624 | gp_XYZ v (0., 0., 0.); | |
3625 | v.SetCoord (anAxis + 1, 1.); | |
3626 | aR[j].SetRotation (v, anAngle[j]); | |
3627 | } | |
3628 | ||
3629 | // construct cumulative transformation (differently for extrinsic and intrinsic rotations); | |
3630 | // note that we parse first symbol of the enum name to identify its type | |
3631 | gp_Mat aRot; | |
3632 | if (names[i - gp_Extrinsic_XYZ][0] == 'E') // extrinsic | |
3633 | { | |
3634 | aRot = aR[2] * aR[1] * aR[0]; | |
3635 | } | |
3636 | else // intrinsic | |
3637 | { | |
3638 | aRot = aR[0] * aR[1] * aR[2]; | |
3639 | } | |
3640 | ||
3641 | // set the same angles in quaternion | |
4f5ad416 | 3642 | aQuat.SetEulerAngles (gp_EulerSequence(i), anAngle[0], anAngle[1], anAngle[2]); |
3643 | ||
3644 | gp_Mat aRQ = aQuat.GetMatrix(); | |
3645 | gp_Mat aDiff = aRQ * aRot.Inverted() - aI; | |
3646 | if (aDiff.Determinant() > 1e-5) | |
3647 | { | |
3648 | theDI << "Error: Euler angles conversion does not correspond to sequential rotations for " << names[i - gp_Extrinsic_XYZ] << "\n"; | |
3649 | isTestOk = Standard_False; | |
3650 | } | |
3651 | } | |
3652 | ||
3653 | // similar checkfor YawPitchRoll sequence as defined in description of #25574 | |
3654 | { | |
3655 | // Start with world coordinate system | |
3656 | gp_Ax2 world; | |
3657 | ||
3658 | // Perform three rotations using the yaw-pitch-roll convention. | |
3659 | // This means: rotate around the original z axis with angle alpha, | |
3660 | // then rotate around the new y axis with angle beta, | |
3661 | // then rotate around the new x axis with angle gamma. | |
3662 | alpha = 0.0 / 180.0 * M_PI; | |
3663 | beta = -35.0 / 180.0 * M_PI; | |
3664 | gamma = 90.0 / 180.0 * M_PI; | |
3665 | ||
3666 | const gp_Quaternion rotationZ(world.Direction(), alpha); | |
3667 | const gp_Vec rotY = rotationZ.Multiply(world.YDirection()); | |
3668 | const gp_Vec rotX = rotationZ.Multiply(world.XDirection()); | |
3669 | ||
3670 | const gp_Quaternion rotationY(rotY, beta); | |
3671 | const gp_Vec rotZ = rotationY.Multiply(world.Direction()); | |
3672 | const gp_Vec rotRotX = rotationY.Multiply(rotX); | |
3673 | ||
3674 | const gp_Quaternion rotationX(rotRotX, gamma); | |
3675 | const gp_Vec rotRotZ = rotationX.Multiply(rotZ); | |
3676 | ||
3677 | gp_Ax2 result(gp_Pnt(0.0, 0.0, 0.0), rotRotZ, rotRotX); | |
3678 | ||
3679 | // Now compute the Euler angles | |
3680 | gp_Trsf transformation; | |
3681 | transformation.SetDisplacement(gp_Ax2(), result); | |
3682 | ||
3683 | Standard_Real computedAlpha; | |
3684 | Standard_Real computedBeta; | |
3685 | Standard_Real computedGamma; | |
3686 | ||
3687 | transformation.GetRotation().GetEulerAngles(gp_YawPitchRoll, computedAlpha, computedBeta, computedGamma); | |
3688 | ||
3689 | // We expect now to get the same angles as we have used for our rotations | |
3690 | if (Abs(alpha - computedAlpha) > 1e-5 || Abs(beta - computedBeta) > 1e-5 || Abs(gamma - computedGamma) > 1e-5) | |
3691 | { | |
3692 | theDI << "Error: unexpected values of Euler angles for YawPitchRoll sequence:\n"; | |
3693 | theDI << "alpha: " << alpha / M_PI * 180.0 << " and computed alpha: " | |
3694 | << computedAlpha / M_PI * 180.0 << "\n"; | |
3695 | theDI << "beta: " << beta / M_PI * 180.0 << " and computed beta: " | |
3696 | << computedBeta / M_PI * 180.0 << "\n"; | |
3697 | theDI << "gamma: " << gamma / M_PI * 180.0 << " and computed gamma: " | |
3698 | << computedGamma / M_PI * 180.0 << "\n"; | |
3699 | isTestOk = Standard_False; | |
3700 | } | |
3701 | } | |
3702 | ||
3703 | // test from #25946 | |
3704 | { | |
3705 | gp_Quaternion q; | |
3706 | q.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637); | |
3707 | ||
3708 | q.GetEulerAngles(gp_Intrinsic_ZYX, alpha,beta, gamma); | |
4f5ad416 | 3709 | q.GetEulerAngles(gp_Extrinsic_XYZ, alpha2,beta2,gamma2); |
3710 | ||
3711 | // gp_Intrinsic_ZYX and gp_Extrinsic_XYZ should produce the same values of angles but in opposite order | |
3712 | if (Abs(alpha - gamma2) > 1e-5 || Abs(beta - beta2) > 1e-5 || Abs(gamma - alpha2) > 1e-5) | |
3713 | { | |
3714 | theDI << "Error: Euler angles computed for gp_Intrinsic_ZYX and gp_Extrinsic_XYZ do not match:\n"; | |
3715 | theDI << "alpha: " << alpha / M_PI * 180.0 << " and " << alpha2 / M_PI * 180.0 << "\n"; | |
3716 | theDI << "beta: " << beta / M_PI * 180.0 << " and " << beta2 / M_PI * 180.0 << "\n"; | |
3717 | theDI << "gamma: " << gamma / M_PI * 180.0 << " and " << gamma2 / M_PI * 180.0 << "\n"; | |
3718 | isTestOk = Standard_False; | |
3719 | } | |
3720 | } | |
3721 | ||
3722 | theDI << (isTestOk ? "Test completed" : "Test failed") << "\n"; | |
3723 | return 0; | |
3724 | } | |
3725 | ||
3ceb4c3c | 3726 | #include <TColGeom_Array1OfBSplineCurve.hxx> |
3727 | #include <TColStd_Array1OfReal.hxx> | |
3728 | #include <TColGeom_HArray1OfBSplineCurve.hxx> | |
3729 | #include <GeomConvert.hxx> | |
3730 | ||
3731 | //======================================================================= | |
3732 | //function : OCC26446 | |
3733 | //purpose : | |
3734 | //======================================================================= | |
3735 | Standard_Integer OCC26446 (Draw_Interpretor& di, | |
3736 | Standard_Integer n, | |
3737 | const char** a) | |
3738 | { | |
3739 | if (n != 4) { | |
586db386 | 3740 | di << "Usage: OCC26446 r c1 c2\n"; |
3ceb4c3c | 3741 | return 1; |
3742 | } | |
3743 | ||
3744 | Handle(Geom_BSplineCurve) aCurve1 = | |
3745 | Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[2])); | |
3746 | Handle(Geom_BSplineCurve) aCurve2 = | |
3747 | Handle(Geom_BSplineCurve)::DownCast(DrawTrSurf::GetCurve(a[3])); | |
3748 | ||
3749 | if (aCurve1.IsNull()) { | |
586db386 | 3750 | di << a[2] << " is not a BSpline curve\n"; |
3ceb4c3c | 3751 | return 1; |
3752 | } | |
3753 | ||
3754 | if (aCurve2.IsNull()) { | |
586db386 | 3755 | di << a[3] << " is not a BSpline curve\n"; |
3ceb4c3c | 3756 | return 1; |
3757 | } | |
3758 | ||
3759 | TColGeom_Array1OfBSplineCurve aCurves (0, 1); | |
3760 | TColStd_Array1OfReal aTolerances (0, 0); | |
3761 | Standard_Real aTolConf = 1.e-3; | |
3762 | Standard_Real aTolClosure = Precision::Confusion(); | |
3763 | Handle(TColGeom_HArray1OfBSplineCurve) aConcatCurves; | |
3764 | Handle(TColStd_HArray1OfInteger) anIndices; | |
3765 | ||
3766 | aCurves.SetValue(0, aCurve1); | |
3767 | aCurves.SetValue(1, aCurve2); | |
3768 | aTolerances.SetValue(0, aTolConf); | |
3769 | ||
3770 | GeomConvert::ConcatC1(aCurves, | |
3771 | aTolerances, | |
3772 | anIndices, | |
3773 | aConcatCurves, | |
3774 | Standard_False, | |
3775 | aTolClosure); | |
3776 | ||
3777 | Handle(Geom_BSplineCurve) aResult = | |
3778 | aConcatCurves->Value(aConcatCurves->Lower()); | |
3779 | ||
3780 | DrawTrSurf::Set(a[1], aResult); | |
3781 | return 0; | |
3782 | } | |
3783 | ||
fac9298e | 3784 | static Standard_Integer OCC26448 (Draw_Interpretor& theDI, Standard_Integer, const char **) |
3785 | { | |
3786 | TColStd_SequenceOfReal aSeq1, aSeq2; | |
3787 | aSeq1.Append(11.); | |
3788 | aSeq1.Prepend (aSeq2); | |
3789 | theDI << "TCollection: 11 -> " << aSeq1.First() << "\n"; | |
3790 | ||
3791 | NCollection_Sequence<Standard_Real> nSeq1, nSeq2; | |
3792 | nSeq1.Append(11.); | |
3793 | nSeq1.Prepend (nSeq2); | |
3794 | theDI << "NCollection: 11 -> " << nSeq1.First() << "\n"; | |
3795 | ||
3796 | theDI << "OK"; | |
3797 | return 0; | |
3798 | } | |
3799 | ||
71316196 | 3800 | //======================================================================= |
3801 | //function : OCC26407 | |
3802 | //purpose : | |
3803 | //======================================================================= | |
3804 | #include <BRepBuilderAPI_MakeWire.hxx> | |
3805 | #include <BRepBuilderAPI_MakeEdge.hxx> | |
3806 | #include <BRepMesh_IncrementalMesh.hxx> | |
3807 | #include <TCollection_AsciiString.hxx> | |
3808 | static Standard_Integer OCC26407 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) | |
3809 | { | |
3810 | if (theArgNb != 2) | |
3811 | { | |
3812 | std::cerr << "Error: wrong number of arguments! See usage:\n"; | |
3813 | theDI.PrintHelp (theArgVec[0]); | |
3814 | return 1; | |
3815 | } | |
3816 | ||
3817 | // Construct vertices. | |
3818 | std::vector<TopoDS_Vertex> wire_vertices; | |
3819 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.90000000000009094947, 40.6758179230516248026106, 88.5))); | |
3820 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(807.824182076948432040808, 260.599999999999965893949, 88.5))); | |
3821 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(644.174182076948454778176, 424.249999999999943156581, 88.5000000000000142108547))); | |
3822 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(629.978025792618950617907, 424.25, 88.5))); | |
3823 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(793.628025792618700506864, 260.599999999999852207111, 88.5))); | |
3824 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(587.900000000000204636308, 54.8719742073813492311274, 88.5))); | |
3825 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(218.521974207381418864315, 424.250000000000056843419, 88.5))); | |
3826 | wire_vertices.push_back(BRepBuilderAPI_MakeVertex(gp_Pnt(204.325817923051886282337, 424.249999999999943156581, 88.5))); | |
3827 | ||
3828 | // Construct wire. | |
3829 | BRepBuilderAPI_MakeWire wire_builder; | |
3830 | for (size_t i = 0; i < wire_vertices.size(); i++) | |
3831 | { | |
3832 | const TopoDS_Vertex &v = wire_vertices[i]; | |
3833 | const TopoDS_Vertex &w = wire_vertices[(i+1) % wire_vertices.size()]; | |
3834 | ||
3835 | wire_builder.Add(BRepBuilderAPI_MakeEdge(v, w)); | |
3836 | } | |
3837 | ||
3838 | // Create face and triangulate it. | |
3839 | // Construct face. | |
3840 | gp_Pnt v0 = BRep_Tool::Pnt(wire_vertices[0]); | |