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