0024008: ShapeAnalysis_Surface causes exception in Geom_OffsetSurface
[occt.git] / src / QABugs / QABugs_19.cxx
... / ...
CommitLineData
1// Created on: 2002-05-21
2// Created by: QA Admin
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
20#include <QABugs.hxx>
21
22#include <Draw_Interpretor.hxx>
23#include <DBRep.hxx>
24#include <DrawTrSurf.hxx>
25#include <AIS_InteractiveContext.hxx>
26#include <ViewerTest.hxx>
27#include <AIS_Shape.hxx>
28#include <TopoDS_Shape.hxx>
29
30#include <gp_Pnt2d.hxx>
31#include <gp_Ax1.hxx>
32#include <GCE2d_MakeSegment.hxx>
33#include <Geom2d_TrimmedCurve.hxx>
34#include <DrawTrSurf.hxx>
35
36#include <Precision.hxx>
37
38#include <PCollection_HAsciiString.hxx>
39
40#include <cstdio>
41#include <cmath>
42#include <iostream>
43#include <OSD_PerfMeter.hxx>
44#include <OSD_Timer.hxx>
45#include <BRepPrimAPI_MakeBox.hxx>
46#include <BRepPrimAPI_MakeSphere.hxx>
47#include <BRepAlgo_Cut.hxx>
48#include <NCollection_Map.hxx>
49#include <TCollection_HAsciiString.hxx>
50
51#define QCOMPARE(val1, val2) \
52 di << "Checking " #val1 " == " #val2 << \
53 ((val1) == (val2) ? ": OK\n" : ": Error\n")
54
55static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
56{
57 if ( argc != 4) {
58 di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d" << "\n";
59 return 1;
60 }
61
62 gp_Pnt2d P1, P2;
63 if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
64 di << "ERROR OCC230: " << argv[2] << " is not Pnt2d" << "\n";
65 return 1;
66 }
67 if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
68 di << "ERROR OCC230: " << argv[3] << " is not Pnt2d" << "\n";
69 return 1;
70 }
71
72 GCE2d_MakeSegment MakeSegment(P1,P2);
73 Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
74 DrawTrSurf::Set(argv[1], TrimmedCurve);
75 return 0;
76}
77
78static Standard_Integer OCC142 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
79{
80 for(Standard_Integer i= 0;i <= 20;i++){
81 Handle(PCollection_HAsciiString) pstr = new PCollection_HAsciiString("TEST");
82 pstr->Clear();
83 }
84 di << "OCC142: OK" << "\n";
85 return 0;
86}
87
88static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
89{
90 gp_Pnt p(0, 0, 2);
91
92 gp_Trsf t1, t2;
93 t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267);
94 t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880);
95
96 gp_Trsf tComp = t2 * t1;
97
98 gp_Pnt p1(10, 3, 4);
99 gp_Pnt p2 = p1.Transformed(tComp);
100 gp_Pnt p3 = p1.Transformed(t1);
101 p3.Transform(t2);
102
103 // points must be equal
104 if ( ! p2.IsEqual(p3, Precision::Confusion()) )
105 di << "ERROR OCC23361: equivalent transformations does not produce equal points" << "\n";
106 else
107 di << "OCC23361: OK" << "\n";
108
109 return 0;
110}
111
112static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
113{
114 OSD_PerfMeter aPM("TestMeter",0);
115 OSD_Timer aTM;
116
117 // run some operation in cycle for about 2 seconds to have good values of times to compare
118 int count = 0;
119 printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n");
120 for (; aTM.ElapsedTime() < 2.; count++)
121 {
122 aPM.Start();
123 aTM.Start();
124
125 // do some operation that will take considerable time compared with time or starting / stopping timers
126 BRepPrimAPI_MakeBox aBox (10., 10., 10.);
127 BRepPrimAPI_MakeSphere aSphere (10.);
128 BRepAlgo_Cut (aBox.Shape(), aSphere.Shape());
129
130 aTM.Stop();
131 aPM.Stop();
132 }
133
134 int aNbEnters = 0;
135 Standard_Real aPerfMeter_CPUtime = 0., aTimer_ElapsedTime = aTM.ElapsedTime();
136
137 perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
138
139 Standard_Real aTimeDiff = (fabs(aTimer_ElapsedTime - aPerfMeter_CPUtime) / aTimer_ElapsedTime);
140
141 printf("\nMeasurement results (%d cycles):\n", count);
142 printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer elapsed time: %lf\n", aPerfMeter_CPUtime, aTimer_ElapsedTime);
143 printf("Time delta is: %.3lf %%\n", aTimeDiff * 100);
144
145 if (aTimeDiff > 0.2)
146 di << "OCC23237: Error: too much difference between CPU and elapsed times";
147 else if (aNbEnters != count)
148 di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles";
149 else
150 di << "OCC23237: OK";
151
152 return 0;
153}
154
155#ifdef HAVE_TBB
156
157#include <Standard_Atomic.hxx>
158#include <tbb/blocked_range.h>
159#include <tbb/parallel_for.h>
160
161class IncrementerDecrementer
162{
163public:
164 IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
165 {}
166 void operator() (const tbb::blocked_range<size_t>& r) const
167 {
168 if (myPositive)
169 for (size_t i = r.begin(); i != r.end(); ++i)
170 Standard_Atomic_Increment (myVal);
171 else
172 for (size_t i = r.begin(); i != r.end(); ++i)
173 Standard_Atomic_Decrement (myVal);
174 }
175private:
176 Standard_Integer* myVal;
177 Standard_Boolean myPositive;
178};
179#endif
180
181#ifdef HAVE_TBB
182static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
183{
184 int aSum = 0;
185
186 //check returned value
187 QCOMPARE (Standard_Atomic_Decrement (&aSum), -1);
188 QCOMPARE (Standard_Atomic_Increment (&aSum), 0);
189 QCOMPARE (Standard_Atomic_Increment (&aSum), 1);
190 QCOMPARE (Standard_Atomic_Increment (&aSum), 2);
191// QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 0);
192// QCOMPARE (Standard_Atomic_DecrementTest (&aSum), 1);
193
194 //check atomicity
195 aSum = 0;
196 const int N = 1 << 24; //big enough to ensure concurrency
197
198 //increment
199 tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, true));
200 QCOMPARE (aSum, N);
201
202 //decrement
203 tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, false));
204 QCOMPARE (aSum, 0);
205
206 return 0;
207}
208
209#else /* HAVE_TBB */
210
211static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char **argv)
212{
213 di << "Test skipped: command " << argv[0] << " requires TBB library\n";
214 return 0;
215}
216
217#endif /* HAVE_TBB */
218
219#include <TDocStd_Application.hxx>
220#include <XCAFApp_Application.hxx>
221#include <TDocStd_Document.hxx>
222#include <XCAFDoc_ShapeTool.hxx>
223#include <XCAFDoc_DocumentTool.hxx>
224#include <TDF_Label.hxx>
225#include <TDataStd_Name.hxx>
226
227static Standard_Integer OCC23595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
228{
229 const Handle(TDocStd_Application)& anApp = XCAFApp_Application::GetApplication();
230 Handle(TDocStd_Document) aDoc;
231 anApp->NewDocument ("XmlXCAF", aDoc);
232 QCOMPARE (!aDoc.IsNull(), Standard_True);
233
234 Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
235
236 //check default value
237 Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
238 QCOMPARE (aValue, Standard_True);
239
240 //true
241 XCAFDoc_ShapeTool::SetAutoNaming (Standard_True);
242 TopoDS_Shape aShape = BRepPrimAPI_MakeBox (100., 200., 300.).Shape();
243 TDF_Label aLabel = aShTool->AddShape (aShape);
244 Handle(TDataStd_Name) anAttr;
245 QCOMPARE (aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
246
247 //false
248 XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
249 aShape = BRepPrimAPI_MakeBox (300., 200., 100.).Shape();
250 aLabel = aShTool->AddShape (aShape);
251 QCOMPARE (!aLabel.FindAttribute (TDataStd_Name::GetID(), anAttr), Standard_True);
252
253 //restore
254 XCAFDoc_ShapeTool::SetAutoNaming (aValue);
255
256 return 0;
257}
258
259#include <ExprIntrp_GenExp.hxx>
260Standard_Integer OCC22611 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
261{
262
263 if (argc != 3) {
264 di << "Usage : " << argv[0] << " string nb\n";
265 return 1;
266 }
267
268 TCollection_AsciiString aToken = argv[1];
269 Standard_Integer aNb = atoi(argv[2]);
270
271 Handle(ExprIntrp_GenExp) aGen = ExprIntrp_GenExp::Create();
272 for (Standard_Integer i=0; i < aNb; i++)
273 {
274 aGen->Process(aToken);
275 Handle(Expr_GeneralExpression) aExpr = aGen->Expression();
276 }
277
278 return 0;
279}
280
281Standard_Integer OCC22595 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
282{
283 gp_Mat M0;
284 di << "M0 = "
285 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}"
286 << " {" << M0(2,1) << "} {" << M0(2,2) << "} {" << M0(2,3) <<"}"
287 << " {" << M0(1,1) << "} {" << M0(1,2) << "} {" << M0(1,3) <<"}";
288 return 0;
289}
290
291#include <TopoDS_Face.hxx>
292#include <TopoDS_Face.hxx>
293#include <TopoDS.hxx>
294#include <BRepBuilderAPI_Transform.hxx>
295#include <BRepExtrema_DistShapeShape.hxx>
296#include <BRepTools.hxx>
297
298static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const TopoDS_Shape& originalWire, Draw_Interpretor& di)
299{
300 BRepExtrema_DistShapeShape distShapeShape(grossPlateFace,originalWire,Extrema_ExtFlag_MIN);
301 if(!distShapeShape.IsDone()) {
302 di <<"Distance ShapeShape is Not Done\n";
303 return Standard_False;
304 }
305
306 if(distShapeShape.Value() > 0.01) {
307 di << "Wrong Dist = " <<distShapeShape.Value() << "\n";
308 return Standard_False;
309 } else
310 di << "Dist0 = " <<distShapeShape.Value() <<"\n";
311
312 //////////////////////////////////////////////////////////////////////////
313 /// First Flip Y
314 const gp_Pnt2d axis1P1(1474.8199035519228,1249.9995745636970);
315 const gp_Pnt2d axis1P2(1474.8199035519228,1250.9995745636970);
316
317 gp_Vec2d mirrorVector1(axis1P1,axis1P2);
318
319 gp_Trsf2d mirror1;
320 mirror1.SetMirror(gp_Ax2d(axis1P1,mirrorVector1));
321
322 BRepBuilderAPI_Transform transformer1(mirror1);
323 transformer1.Perform(originalWire);
324 if(!transformer1.IsDone()) {
325 di << "Not Done1 " << "\n";
326 return Standard_False;
327 }
328 const TopoDS_Shape& step1ModifiedShape = transformer1.ModifiedShape(originalWire);
329
330 BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN);
331 if(!distShapeShape1.IsDone())
332 return Standard_False;
333 if(distShapeShape1.Value() > 0.01) {
334 di << "Dist = " <<distShapeShape1.Value() <<"\n";
335 return Standard_False;
336 } else
337 di << "Dist1 = " <<distShapeShape1.Value() <<"\n";
338
339 //////////////////////////////////////////////////////////////////////////
340 /// Second flip Y
341 transformer1.Perform(step1ModifiedShape);
342 if(!transformer1.IsDone()) {
343 di << "Not Done1 \n";
344 return Standard_False;
345 }
346 const TopoDS_Shape& step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
347
348 //This is identity matrix for values but for type is gp_Rotation ?!
349 gp_Trsf2d mirror11 = mirror1;
350 mirror11.PreMultiply(mirror1);
351
352 BRepExtrema_DistShapeShape distShapeShape2(grossPlateFace,step2ModifiedShape);//,Extrema_ExtFlag_MIN);
353 if(!distShapeShape2.IsDone())
354 return Standard_False;
355
356 //This last test case give error (the value is 1008.8822038689706)
357 if(distShapeShape2.Value() > 0.01) {
358 di << "Wrong Dist2 = " <<distShapeShape2.Value() <<"\n";
359 Standard_Integer N = distShapeShape2.NbSolution();
360 di << "Nb = " <<N <<"\n";
361 for (Standard_Integer i=1;i <= N;i++)
362 di <<"Sol(" <<i<<") = " <<distShapeShape2.PointOnShape1(i).Distance(distShapeShape2.PointOnShape2(i)) <<"\n";
363 return Standard_False;
364 }
365 di << "Distance2 = " <<distShapeShape2.Value() <<"\n";
366
367 return Standard_True;
368}
369static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const char** a)
370{
371
372 if (n != 3) {
373 di <<"OCC23774: invalid number of input parameters\n";
374 return 1;
375 }
376
377 const char *ns1 = (a[1]), *ns2 = (a[2]);
378 TopoDS_Shape S1(DBRep::Get(ns1)), S2(DBRep::Get(ns2));
379 if (S1.IsNull() || S2.IsNull()) {
380 di <<"OCC23774: Null input shapes\n";
381 return 1;
382 }
383 const TopoDS_Face& aFace = TopoDS::Face(S1);
384 if(!OCC23774Test(aFace, S2, di))
385 di << "Something is wrong\n";
386
387 return 0;
388}
389
390#include <GeomConvert_ApproxSurface.hxx>
391#include <Geom_BSplineSurface.hxx>
392#include <Draw.hxx>
393#include <OSD_Thread.hxx>
394static void GeomConvertTest (Draw_Interpretor& di, Standard_Integer theTargetNbUPoles, Standard_CString theFileName)
395{
396 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theFileName);
397 GeomConvert_ApproxSurface aGAS (aSurf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
398 if (!aGAS.IsDone()) {
399 di << "ApproxSurface is not done!" << "\n";
400 return;
401 }
402 const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
403 if (aBSurf.IsNull()) {
404 di << "BSplineSurface is not created!" << "\n";
405 return;
406 }
407 di << "Number of UPoles:" << aBSurf->NbUPoles() << "\n";
408 QCOMPARE (aBSurf->NbUPoles(), theTargetNbUPoles);
409}
410
411struct aData {
412 Draw_Interpretor* di;
413 Standard_Integer nbupoles;
414 Standard_CString filename;
415};
416
417Standard_EXPORT Standard_Address convert(Standard_Address data)
418{
419 aData* info = (aData*) data;
420 GeomConvertTest(*(info->di),info->nbupoles,info->filename);
421 return NULL;
422}
423
424static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
425{
426 if (argc != 3) {
427 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
428 return 1;
429 }
430 struct aData aStorage;
431 aStorage.di = &di;
432 aStorage.nbupoles = Draw::Atoi(argv[1]);
433 aStorage.filename = argv[2];
434
435 OSD_Thread aThread1(convert);
436 aThread1.Run(&aStorage);
437 GeomConvertTest(di,aStorage.nbupoles,aStorage.filename);
438 cout << "result of thread: " << aThread1.Wait() << endl;
439
440 return 0;
441}
442
443#include <GeomInt_IntSS.hxx>
444static void GeomIntSSTest (Draw_Interpretor& di, Standard_Integer theNbSol, Standard_CString theFileName1, Standard_CString theFileName2)
445{
446 Handle(Geom_Surface) aSurf1 = DrawTrSurf::GetSurface(theFileName1);
447 Handle(Geom_Surface) aSurf2 = DrawTrSurf::GetSurface(theFileName2);
448 GeomInt_IntSS anInter;
449 anInter.Perform(aSurf1, aSurf2, Precision::Confusion(), Standard_True);
450 if (!anInter.IsDone()) {
451 di << "An intersection is not done!" << "\n";
452 return;
453 }
454
455 di << "Number of Lines:" << anInter.NbLines() << "\n";
456 QCOMPARE (anInter.NbLines(), theNbSol);
457}
458
459struct aNewData {
460 Draw_Interpretor* di;
461 Standard_Integer nbsol;
462 Standard_CString filename1;
463 Standard_CString filename2;
464};
465Standard_EXPORT Standard_Address convert_inter(Standard_Address data)
466{
467 aNewData* info = (aNewData*) data;
468 GeomIntSSTest(*(info->di),info->nbsol,info->filename1,info->filename2);
469 return NULL;
470}
471
472static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
473{
474 if (argc != 4) {
475 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
476 return 1;
477 }
478 struct aNewData aStorage;
479 aStorage.di = &di;
480 aStorage.nbsol = Draw::Atoi(argv[1]);
481 aStorage.filename1 = argv[2];
482 aStorage.filename2 = argv[3];
483
484 OSD_Thread aThread1(convert_inter);
485 aThread1.Run(&aStorage);
486 GeomIntSSTest(di,aStorage.nbsol,aStorage.filename1,aStorage.filename2);
487 cout << "result of thread: " << aThread1.Wait() << endl;
488
489 return 0;
490}
491
492#include <Geom_SurfaceOfRevolution.hxx>
493static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
494{
495 if (argc < 2) {
496 di<<"Usage: " << argv[0] << " invalid number of arguments"<<"\n";
497 return 1;
498 }
499
500 Standard_Integer ucontinuity = 1;
501 Standard_Integer vcontinuity = 1;
502 Standard_Boolean iscnu = false;
503 Standard_Boolean iscnv = false;
504
505 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[1]);
506
507 QCOMPARE (aSurf->IsCNu (ucontinuity), iscnu);
508 QCOMPARE (aSurf->IsCNv (vcontinuity), iscnv);
509
510 return 0;
511}
512
513#include <gp_Ax1.hxx>
514#include <gp_Ax22d.hxx>
515#include <Geom_Plane.hxx>
516#include <Geom2d_Circle.hxx>
517#include <Geom2d_TrimmedCurve.hxx>
518#include <BRepBuilderAPI_MakeEdge.hxx>
519#include <BRepPrimAPI_MakeRevol.hxx>
520#include <Geom2d_OffsetCurve.hxx>
521
522static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
523{
524 // Check the command arguments
525 if ( argc != 1 )
526 {
527 di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
528 di << "Usage: type help " << argv[0] << "\n";
529 return 1; // TCL_ERROR
530 }
531
532 gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
533 gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
534 Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
535
536 di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>" << "\n";
537 di << "-----------------------------------------------------------------------" << "\n";
538
539 Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
540 Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
541 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
542
543 DBRep::Set("e1", E1);
544
545 BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
546 TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
547
548 DBRep::Set("f1", F1);
549
550 di << "Result: f1" << "\n";
551
552 di << "<<<< Preparing sample surface of revolution based on offset curve >>>>" << "\n";
553 di << "-----------------------------------------------------------------------" << "\n";
554
555 Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
556 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
557
558 DBRep::Set("e2", E2);
559
560 BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
561 TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
562
563 DBRep::Set("f2", F2);
564
565 di << "Result: f2" << "\n";
566
567 return 0;
568}
569
570#include <Geom_Curve.hxx>
571#include <Geom_Surface.hxx>
572#include <Precision.hxx>
573#include <ShapeConstruct_ProjectCurveOnSurface.hxx>
574//=======================================================================
575//function : OCC24008
576//purpose :
577//=======================================================================
578static Standard_Integer OCC24008 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
579{
580 if (argc != 3) {
581 di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
582 return 1;
583 }
584 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[1]);
585 Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(argv[2]);
586 if (aCurve.IsNull()) {
587 di << "Curve was not read" << "\n";
588 return 1;
589 }
590 if (aSurf.IsNull()) {
591 di << "Surface was not read" << "\n";
592 return 1;
593 }
594 ShapeConstruct_ProjectCurveOnSurface aProj;
595 aProj.Init (aSurf, Precision::Confusion());
596 try {
597 Handle(Geom2d_Curve) aPCurve;
598 aProj.Perform (aCurve, aCurve->FirstParameter(), aCurve->LastParameter(), aPCurve);
599 if (aPCurve.IsNull()) {
600 di << "PCurve was not created" << "\n";
601 return 1;
602 }
603 } catch (...) {
604 di << "Exception was caught" << "\n";
605 }
606 return 0;
607}
608
609#include <GeomAdaptor_Surface.hxx>
610#include <Draw.hxx>
611//=======================================================================
612//function : OCC23945
613//purpose :
614//=======================================================================
615
616static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
617{
618 if (n < 5) return 1;
619
620 Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
621 if (aS.IsNull()) return 1;
622
623 GeomAdaptor_Surface GS(aS);
624
625 Standard_Real U = Draw::Atof(a[2]);
626 Standard_Real V = Draw::Atof(a[3]);
627
628 Standard_Boolean DrawPoint = ( n%3 == 2);
629 if ( DrawPoint) n--;
630
631 gp_Pnt P;
632 if (n >= 13) {
633 gp_Vec DU,DV;
634 if (n >= 22) {
635 gp_Vec D2U,D2V,D2UV;
636 GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
637 Draw::Set(a[13],D2U.X());
638 Draw::Set(a[14],D2U.Y());
639 Draw::Set(a[15],D2U.Z());
640 Draw::Set(a[16],D2V.X());
641 Draw::Set(a[17],D2V.Y());
642 Draw::Set(a[18],D2V.Z());
643 Draw::Set(a[19],D2UV.X());
644 Draw::Set(a[20],D2UV.Y());
645 Draw::Set(a[21],D2UV.Z());
646 }
647 else
648 GS.D1(U,V,P,DU,DV);
649
650 Draw::Set(a[7],DU.X());
651 Draw::Set(a[8],DU.Y());
652 Draw::Set(a[9],DU.Z());
653 Draw::Set(a[10],DV.X());
654 Draw::Set(a[11],DV.Y());
655 Draw::Set(a[12],DV.Z());
656 }
657 else
658 GS.D0(U,V,P);
659
660 if ( n > 6) {
661 Draw::Set(a[4],P.X());
662 Draw::Set(a[5],P.Y());
663 Draw::Set(a[6],P.Z());
664 }
665 if ( DrawPoint) {
666 DrawTrSurf::Set(a[n],P);
667 }
668
669 return 0;
670}
671
672#include <Voxel_BoolDS.hxx>
673#include <Voxel_FastConverter.hxx>
674#include <Voxel_BooleanOperation.hxx>
675static Standard_Integer OCC24019 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
676{
677 if ( argc != 2 ) {
678 di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
679 return 1;
680 }
681
682 TCollection_AsciiString aFileName = argv[1];
683 TopoDS_Shape aShape;
684 BRep_Builder aBuilder;
685
686 if (!BRepTools::Read(aShape, aFileName.ToCString(), aBuilder)) {
687 di << "Error: Could not read a shape!" << "\n";
688 return 1;
689 }
690
691 TopoDS_Solid aShape1 = BRepPrimAPI_MakeSphere(gp_Pnt(20,25,35), 7);
692
693 Standard_Real deflection = 0.005;
694 Standard_Integer nbThreads = 1;
695 Standard_Integer nbx = 200, nby = 200, nbz = 200;
696 Voxel_BoolDS theVoxels(0,0,0, 50, 50, 50, nbx, nby, nbz);
697 Voxel_BoolDS theVoxels1(0,0,0, 50, 50, 50, nbx, nby, nbz);
698
699 Standard_Integer progress = 0;
700 Voxel_FastConverter fcp(aShape, theVoxels, deflection, nbx, nby, nbz, nbThreads);
701 fcp.ConvertUsingSAT(progress, 1);
702 fcp.FillInVolume(1);
703
704 Voxel_FastConverter fcp1(aShape1, theVoxels1, deflection, nbx, nby, nbz, nbThreads);
705 fcp1.ConvertUsingSAT(progress, 1);
706 fcp1.FillInVolume(1);
707
708 Voxel_BooleanOperation op;
709 Standard_Boolean result = op.Cut(theVoxels1, theVoxels);
710 if ( result != 1 ) {
711 di << "Error: invalid boolean operation" << "\n";
712 } else {
713 di << "OK: boolean operation is ok" << "\n";
714 }
715
716 return 0;
717}
718
719//=======================================================================
720//function : OCC11758
721//purpose :
722//=======================================================================
723static Standard_Integer OCC11758 (Draw_Interpretor& di, Standard_Integer n, const char**)
724{
725 if (n != 1) return 1;
726
727 const char* theStr = "0123456789";
728 Standard_Integer i, j;
729 for ( i = 0; i < 5; ++i ) {
730 // TCollection_AsciiString(const Standard_CString astring)
731 TCollection_AsciiString a(theStr+i);
732 // IsEqual (const Standard_CString other)const
733 //assert( a == theStr+i );
734 QCOMPARE ( a , theStr+i );
735
736 //TCollection_AsciiString(const Standard_CString astring,const Standard_Integer aLen )
737 TCollection_AsciiString b(theStr+i, 3);
738 //assert( b.Length() == 3 );
739 //assert( strncmp( b.ToCString(), theStr+i, 3 ) == 0 );
740 //assert( strlen( b.ToCString() ) == 3 );
741 QCOMPARE ( b.Length() , 3 );
742 QCOMPARE ( strncmp( b.ToCString() , theStr+i, 3 ) , 0 );
743 QCOMPARE ( b.Length() , 3 );
744
745 //TCollection_AsciiString(const Standard_Integer aValue)
746 TCollection_AsciiString c(i);
747 //assert( c.IsIntegerValue() );
748 //assert( c.IntegerValue() == i );
749 QCOMPARE ( c.IsIntegerValue() , Standard_True );
750 QCOMPARE ( c.IntegerValue() , i );
751
752 //TCollection_AsciiString(const Standard_Real aValue)
753 TCollection_AsciiString d( 0.1*i );
754 //assert( d.IsRealValue() );
755 //assert( TCollection_AsciiString(3.3) == "3.3");
756 QCOMPARE ( d.IsRealValue() , Standard_True );
757 QCOMPARE ( TCollection_AsciiString(3.3) , "3.3" );
758
759 //TCollection_AsciiString(const TCollection_AsciiString& astring)
760 TCollection_AsciiString e(d);
761 //assert( e == d );
762 //assert( e.Length() == d.Length() );
763 //assert( strcmp( e.ToCString(), d.ToCString() ) == 0 );
764 QCOMPARE ( e ,d );
765 QCOMPARE ( e.Length() , d.Length() );
766 QCOMPARE ( strcmp( e.ToCString(), d.ToCString() ) , 0 );
767
768 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
769 // const Standard_Character other )
770 TCollection_AsciiString f(e,'\a');
771 //assert( f.Length() == e.Length() + 1 );
772 //assert( strncmp( f.ToCString(), e.ToCString(), e.Length() ) == 0 );
773 //assert( f.Value( f.Length() ) == '\a');
774 QCOMPARE ( f.Length() , e.Length() + 1 );
775 QCOMPARE ( strncmp( f.ToCString(), e.ToCString(), e.Length() ) , 0 );
776 QCOMPARE ( f.Value( f.Length() ) , '\a' );
777
778 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
779 // const Standard_CString other )
780 TCollection_AsciiString g(f, theStr);
781 //assert( g.Length() == f.Length() + strlen( theStr ));
782 //assert( strncmp( g.ToCString(), f.ToCString(), f.Length() ) == 0 );
783 //assert( g.Search( theStr ) == f.Length() + 1 );
784 QCOMPARE ( g.Length() , f.Length() + (Standard_Integer)strlen( theStr ) );
785 QCOMPARE ( strncmp( g.ToCString(), f.ToCString(), f.Length() ) , 0 );
786 QCOMPARE ( g.Search( theStr ) , f.Length() + 1 );
787
788 // TCollection_AsciiString(const TCollection_AsciiString& astring ,
789 // const TCollection_AsciiString& other )
790 TCollection_AsciiString h(d,a);
791 //assert( h.Length() == d.Length() + a.Length() );
792 //assert( strncmp( h.ToCString(), d.ToCString(), d.Length() ) == 0 );
793 //assert( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) == 0 );
794 QCOMPARE ( h.Length() , d.Length() + a.Length() );
795 QCOMPARE ( strncmp( h.ToCString(), d.ToCString(), d.Length() ) , 0 );
796 QCOMPARE ( strncmp( h.ToCString() + d.Length(), a.ToCString(), a.Length() ) , 0 );
797
798 // AssignCat(const Standard_CString other)
799 c.AssignCat( a.ToCString() );
800 //assert( c.Length() == 1 + a.Length() );
801 //assert( c.Search( a ) == 2 );
802 QCOMPARE ( c.Length() , 1 + a.Length() );
803 QCOMPARE ( c.Search( a ) , 2 );
804
805 // AssignCat(const TCollection_AsciiString& other)
806 Standard_Integer dl = d.Length();
807 d.AssignCat( a );
808 //assert( d.Length() == dl + a.Length() );
809 //assert( d.Search( a ) == dl + 1 );
810 QCOMPARE ( d.Length() , dl + a.Length() );
811 QCOMPARE ( d.Search( a ) , dl + 1 );
812
813 // Capitalize()
814 TCollection_AsciiString capitalize("aBC");
815 capitalize.Capitalize();
816 //assert( capitalize == "Abc" );
817 QCOMPARE ( capitalize , "Abc" );
818
819 // Copy(const Standard_CString fromwhere)
820 d = theStr+i;
821 //assert( d == theStr+i );
822 QCOMPARE ( d , theStr+i );
823
824 // Copy(const TCollection_AsciiString& fromwhere)
825 d = h;
826 // IsEqual (const TCollection_AsciiString& other)const
827 //assert( d == h );
828 QCOMPARE ( d , h );
829
830 // Insert(const Standard_Integer where, const Standard_CString what)
831 dl = d.Length();
832 d.Insert( 2, theStr );
833 //assert( d.Length() == dl + strlen( theStr ));
834 //assert( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) == 0 );
835 QCOMPARE ( d.Length() , dl + (Standard_Integer)strlen( theStr ) );
836 QCOMPARE ( strncmp( d.ToCString() + 1, theStr, strlen( theStr )) , 0 );
837
838 //Insert(const Standard_Integer where,const Standard_Character what)
839 d = theStr;
840 d.Insert( i+1, 'i' );
841 //assert( d.Length() == strlen( theStr ) + 1 );
842 //assert( d.Value( i+1 ) == 'i');
843 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
844 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
845 QCOMPARE ( d.Value( i+1 ) , 'i' );
846 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
847
848 //Insert(const Standard_Integer where,const TCollection_AsciiString& what)
849 d = theStr;
850 d.Insert( i+1, TCollection_AsciiString( "i" ));
851 //assert( d.Length() == strlen( theStr ) + 1 );
852 //assert( d.Value( i+1 ) == 'i');
853 //assert( strcmp( d.ToCString() + i + 1, theStr+i ) == 0 );
854 QCOMPARE ( d.Length() , (Standard_Integer)strlen( theStr ) + 1 );
855 QCOMPARE ( d.Value( i+1 ) , 'i' );
856 QCOMPARE ( strcmp( d.ToCString() + i + 1, theStr+i ) , 0 );
857
858 // IsDifferent (const Standard_CString other)const
859 //assert( d.IsDifferent( theStr ));
860 //assert( d.IsDifferent( "theStr" ));
861 //assert( d.IsDifferent( "" ));
862 //assert( !d.IsDifferent( d.ToCString() ));
863 QCOMPARE ( d.IsDifferent( theStr ) , Standard_True );
864 QCOMPARE ( d.IsDifferent( "theStr" ) , Standard_True );
865 QCOMPARE ( d.IsDifferent( "" ) , Standard_True );
866 QCOMPARE ( !d.IsDifferent( d.ToCString() ) , Standard_True );
867
868 // IsDifferent (const TCollection_AsciiString& other)const
869 //assert( d.IsDifferent( TCollection_AsciiString() ));
870 //assert( d.IsDifferent( a ));
871 //assert( d.IsDifferent( h ));
872 //assert( !d.IsDifferent( d ));
873 QCOMPARE ( d.IsDifferent( TCollection_AsciiString() ) , Standard_True );
874 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
875 QCOMPARE ( d.IsDifferent( h ) , Standard_True );
876 QCOMPARE ( !d.IsDifferent( d ) , Standard_True );
877
878 // IsLess (const Standard_CString other)const
879 //assert( TCollection_AsciiString ("0"). IsLess("1"));
880 //assert( TCollection_AsciiString ("0"). IsLess("00"));
881 //assert( TCollection_AsciiString (""). IsLess("0"));
882 //assert( !TCollection_AsciiString("1"). IsLess("0"));
883 //assert( !TCollection_AsciiString("00").IsLess("0"));
884 //assert( !TCollection_AsciiString("0"). IsLess(""));
885 //assert( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1));
886 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("1") , Standard_True );
887 QCOMPARE ( TCollection_AsciiString ("0"). IsLess("00") , Standard_True );
888 QCOMPARE ( TCollection_AsciiString (""). IsLess("0") , Standard_True );
889 QCOMPARE ( !TCollection_AsciiString("1"). IsLess("0"), Standard_True );
890 QCOMPARE ( !TCollection_AsciiString("00").IsLess("0") , Standard_True );
891 QCOMPARE ( !TCollection_AsciiString("0"). IsLess("") , Standard_True );
892 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(theStr+i+1) , Standard_True );
893
894 // IsLess (const TCollection_AsciiString& other)const
895 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )));
896 //assert( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")));
897 //assert( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )));
898 //assert( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )));
899 //assert( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )));
900 //assert( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )));
901 //assert( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)));
902 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("1" )) , Standard_True );
903 QCOMPARE ( TCollection_AsciiString ("0"). IsLess(TCollection_AsciiString("00")) , Standard_True );
904 QCOMPARE ( TCollection_AsciiString (""). IsLess(TCollection_AsciiString("0" )) , Standard_True );
905 QCOMPARE ( !TCollection_AsciiString("1"). IsLess(TCollection_AsciiString("0" )) , Standard_True );
906 QCOMPARE ( !TCollection_AsciiString("00").IsLess(TCollection_AsciiString("0" )) , Standard_True );
907 QCOMPARE ( !TCollection_AsciiString("0"). IsLess(TCollection_AsciiString("" )) , Standard_True );
908 QCOMPARE ( TCollection_AsciiString (theStr+i).IsLess(TCollection_AsciiString(theStr+i+1)) , Standard_True );
909
910 // IsGreater (const Standard_CString other)const
911 //assert( !TCollection_AsciiString("0"). IsGreater("1"));
912 //assert( !TCollection_AsciiString("0"). IsGreater("00"));
913 //assert( !TCollection_AsciiString(""). IsGreater("0"));
914 //assert( TCollection_AsciiString ("1"). IsGreater("0"));
915 //assert( TCollection_AsciiString ("00").IsGreater("0"));
916 //assert( TCollection_AsciiString ("0"). IsGreater(""));
917 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i));
918 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("1") , Standard_True );
919 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater("00") , Standard_True );
920 QCOMPARE ( !TCollection_AsciiString(""). IsGreater("0") , Standard_True );
921 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater("0") , Standard_True );
922 QCOMPARE ( TCollection_AsciiString ("00").IsGreater("0") , Standard_True );
923 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater("") , Standard_True );
924 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(theStr+i) , Standard_True );
925
926 // IsGreater (const TCollection_AsciiString& other)const
927 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )));
928 //assert( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")));
929 //assert( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )));
930 //assert( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )));
931 //assert( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )));
932 //assert( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )));
933 //assert( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)));
934 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("1" )) , Standard_True );
935 QCOMPARE ( !TCollection_AsciiString("0"). IsGreater(TCollection_AsciiString("00")) , Standard_True );
936 QCOMPARE ( !TCollection_AsciiString(""). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
937 QCOMPARE ( TCollection_AsciiString ("1"). IsGreater(TCollection_AsciiString("0" )) , Standard_True );
938 QCOMPARE ( TCollection_AsciiString ("00").IsGreater(TCollection_AsciiString("0" )) , Standard_True );
939 QCOMPARE ( TCollection_AsciiString ("0"). IsGreater(TCollection_AsciiString("" )) , Standard_True );
940 QCOMPARE ( TCollection_AsciiString (theStr+i+1).IsGreater(TCollection_AsciiString(theStr+i)) , Standard_True );
941
942 // void Read(Standard_IStream& astream)
943 std::istringstream is( theStr );
944 e.Read( is );
945 //assert( e == theStr );
946 QCOMPARE ( e , theStr );
947
948 // Standard_Integer SearchFromEnd (const Standard_CString what)const
949 //assert( e.SearchFromEnd( theStr + i ) == i + 1 );
950 QCOMPARE ( e.SearchFromEnd( theStr + i ) , i + 1 );
951
952 // SetValue(const Standard_Integer where, const Standard_CString what)
953 e.SetValue( i+1, "what");
954 //assert( e.Search( "what" ) == i+1 );
955 //assert( e.Length() == strlen( theStr ));
956 QCOMPARE ( e.Search( "what" ) , i+1 );
957 QCOMPARE ( e.Length() , (Standard_Integer)strlen( theStr ) );
958
959 // TCollection_AsciiString Split (const Standard_Integer where)
960 e = theStr;
961 d = e.Split( i+1 );
962 //assert( d.Length() + e.Length() == strlen( theStr ));
963 QCOMPARE ( d.Length() + e.Length() , (Standard_Integer)strlen( theStr ) );
964
965 // TCollection_AsciiString SubString (const Standard_Integer FromIndex,
966 // const Standard_Integer ToIndex) const
967 e = theStr;
968 d = e.SubString( (unsigned int)i+1, (unsigned int)i+3 );
969 //assert( d.Length() == 3 );
970 //assert( d.Value(1) == theStr[ i ]);
971 QCOMPARE ( d.Length() , 3 );
972 QCOMPARE ( d.Value(1) , theStr[ i ] );
973
974 // TCollection_AsciiString Token (const Standard_CString separators,
975 // const Standard_Integer whichone) const
976 e = " ";
977 for ( j = 0; j < i; ++j ) {
978 e += TCollection_AsciiString( theStr[j] ) + " ";
979 //assert( e.Token(" ", j+1 ) == TCollection_AsciiString( theStr+j, 1 ));
980 QCOMPARE ( e.Token(" ", j+1 ) , TCollection_AsciiString( theStr+j, 1 ) );
981 }
982 }
983 for ( i = 0; i < 5; ++i )
984 {
985 // TCollection_ExtendedString (const Standard_CString astring,
986 // const Standard_Boolean isMultiByte)
987 const TCollection_ExtendedString a( theStr+i );
988 //assert( TCollection_AsciiString( a ) == theStr+i );
989 QCOMPARE ( TCollection_AsciiString( a ) , theStr+i );
990
991 //TCollection_ExtendedString (const Standard_ExtString astring)
992 const TCollection_ExtendedString b( a.ToExtString() );
993 //assert( a == b );
994 QCOMPARE ( a , b );
995
996 // TCollection_ExtendedString (const Standard_Integer length,
997 // const Standard_ExtCharacter filler )
998 const TCollection_ExtendedString c( i, 1 );
999 //assert( c.Length() == i );
1000 QCOMPARE ( c.Length() , i );
1001 if ( c.Length() > 0 ) {
1002 //assert( c.Value( i ) == 1 );
1003 QCOMPARE ( c.Value( i ) , 1 );
1004 }
1005
1006 // TCollection_ExtendedString (const Standard_Integer aValue)
1007 TCollection_ExtendedString d( i );
1008 const TCollection_AsciiString da( d );
1009 //assert( da.IsIntegerValue() );
1010 //assert( da.IntegerValue() == i );
1011 QCOMPARE ( da.IsIntegerValue() , Standard_True );
1012 QCOMPARE ( da.IntegerValue(), i );
1013
1014 // TCollection_ExtendedString (const Standard_Real aValue)
1015 const TCollection_ExtendedString e( 0.1 * i );
1016 const TCollection_AsciiString ea( e );
1017 //assert( ea.IsRealValue() );
1018 //assert( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 );
1019 QCOMPARE ( ea.IsRealValue() , Standard_True );
1020 QCOMPARE ( Abs( ea.RealValue() - 0.1 * i ) < 1e-10 , Standard_True );
1021
1022 // TCollection_ExtendedString (const TCollection_ExtendedString& astring)
1023 const TCollection_ExtendedString f(e);
1024 //assert( f.Length() == e.Length());
1025 //assert( f == e );
1026 QCOMPARE ( f.Length() , e.Length() );
1027 QCOMPARE ( f , e );
1028
1029 // TCollection_ExtendedString (const TCollection_AsciiString& astring)
1030 const TCollection_ExtendedString g( ea );
1031 //assert( g.Length() == ea.Length() );
1032 //assert( TCollection_AsciiString( g ) == ea );
1033 QCOMPARE ( g.Length() , ea.Length() );
1034 QCOMPARE ( TCollection_AsciiString( g ) , ea );
1035
1036 // AssignCat (const TCollection_ExtendedString& other)
1037 const TCollection_ExtendedString sep(",");
1038 d.AssignCat( sep );
1039 d.AssignCat( g );
1040 //assert( d.Length() == 2 + g.Length() );
1041 //assert( d.Token( sep.ToExtString(), 1 ) == TCollection_ExtendedString( i ));
1042 //assert( d.Token( sep.ToExtString(), 2 ) == g );
1043 QCOMPARE ( d.Length() , 2 + g.Length() );
1044 QCOMPARE ( d.Token( sep.ToExtString(), 1 ) , TCollection_ExtendedString( i ) );
1045 QCOMPARE ( d.Token( sep.ToExtString(), 2 ) , g );
1046
1047 // TCollection_ExtendedString Cat (const TCollection_ExtendedString& other) const
1048 const TCollection_ExtendedString cat = a.Cat( sep );
1049 //assert( cat.Length() == a.Length() + sep.Length() );
1050 //assert( cat.Search( a ) == 1 );
1051 //assert( cat.Search( sep ) == a.Length() + 1 );
1052 QCOMPARE ( cat.Length() , a.Length() + sep.Length() );
1053 QCOMPARE ( cat.Search( a ) , 1 );
1054 QCOMPARE ( cat.Search( sep ) , a.Length() + 1 );
1055
1056 // Copy (const TCollection_ExtendedString& fromwhere)
1057 d = cat;
1058 //assert( d.Length() == cat.Length() );
1059 //assert( d == cat );
1060 QCOMPARE ( d.Length() , cat.Length() );
1061 QCOMPARE ( d , cat );
1062
1063 // IsEqual (const Standard_ExtString other) const
1064 //assert( d.IsEqual( d.ToExtString() ));
1065 QCOMPARE ( d.IsEqual( d.ToExtString() ) , Standard_True );
1066
1067 // IsDifferent (const Standard_ExtString other ) const
1068 //assert( d.IsDifferent( a.ToExtString() ));
1069 QCOMPARE ( d.IsDifferent( a.ToExtString() ) , Standard_True );
1070
1071 // IsDifferent (const TCollection_ExtendedString& other) const
1072 //assert( d.IsDifferent( a ));
1073 QCOMPARE ( d.IsDifferent( a ) , Standard_True );
1074
1075 // IsLess (const Standard_ExtString other) const
1076 const TCollection_ExtendedString l0("0"), l1("1"), l00("00"), l, ls(theStr+i), ls1(theStr+i+1);
1077 //assert( l0. IsLess( l1.ToExtString() ));
1078 //assert( l0. IsLess( l00.ToExtString() ));
1079 //assert( l. IsLess( l0.ToExtString() ));
1080 //assert( ! l1. IsLess( l0.ToExtString() ));
1081 //assert( ! l00.IsLess( l0.ToExtString() ));
1082 //assert( ! l0. IsLess( l.ToExtString() ));
1083 //assert( ls.IsLess( ls1.ToExtString() ));
1084 QCOMPARE ( l0. IsLess( l1.ToExtString() ) , Standard_True );
1085 QCOMPARE ( l0. IsLess( l00.ToExtString() ) , Standard_True );
1086 QCOMPARE ( l. IsLess( l0.ToExtString() ) , Standard_True );
1087 QCOMPARE ( ! l1. IsLess( l0.ToExtString() ) , Standard_True );
1088 QCOMPARE ( ! l00.IsLess( l0.ToExtString() ) , Standard_True );
1089 QCOMPARE ( ! l0. IsLess( l.ToExtString() ) , Standard_True );
1090 QCOMPARE ( ls.IsLess( ls1.ToExtString() ) , Standard_True );
1091
1092 // IsLess (const TCollection_ExtendedString& other) const
1093 //assert( l0. IsLess( l1 ));
1094 //assert( l0. IsLess( l00 ));
1095 //assert( l. IsLess( l0 ));
1096 //assert( ! l1. IsLess( l0 ));
1097 //assert( ! l00.IsLess( l0 ));
1098 //assert( ! l0. IsLess( l ));
1099 //assert( ls.IsLess( ls1 ));
1100 QCOMPARE ( l0. IsLess( l1 ) , Standard_True );
1101 QCOMPARE ( l0. IsLess( l00 ) , Standard_True );
1102 QCOMPARE ( l. IsLess( l0 ) , Standard_True );
1103 QCOMPARE ( ! l1. IsLess( l0 ) , Standard_True );
1104 QCOMPARE ( ! l00.IsLess( l0 ) , Standard_True );
1105 QCOMPARE ( ! l0. IsLess( l ) , Standard_True );
1106 QCOMPARE ( ls.IsLess( ls1 ) , Standard_True );
1107
1108 // IsGreater (const Standard_ExtString other) const
1109 //assert( ! l0.IsGreater( l1.ToExtString() ));
1110 //assert( ! l0.IsGreater( l00.ToExtString() ));
1111 //assert( ! l. IsGreater( l0.ToExtString() ));
1112 //assert( l1. IsGreater( l0.ToExtString() ));
1113 //assert( l00.IsGreater( l0.ToExtString() ));
1114 //assert( l0. IsGreater( l.ToExtString() ));
1115 //assert( ls1.IsGreater( ls.ToExtString() ));
1116 QCOMPARE ( ! l0.IsGreater( l1.ToExtString() ) , Standard_True );
1117 QCOMPARE ( ! l0.IsGreater( l00.ToExtString() ) , Standard_True );
1118 QCOMPARE ( ! l. IsGreater( l0.ToExtString() ) , Standard_True );
1119 QCOMPARE ( l1. IsGreater( l0.ToExtString() ) , Standard_True );
1120 QCOMPARE ( l00.IsGreater( l0.ToExtString() ) , Standard_True );
1121 QCOMPARE ( l0. IsGreater( l.ToExtString() ) , Standard_True );
1122 QCOMPARE ( ls1.IsGreater( ls.ToExtString() ) ,Standard_True );
1123
1124 // IsGreater (const TCollection_ExtendedString& other) const
1125 //assert( ! l0.IsGreater( l1));
1126 //assert( ! l0.IsGreater( l00));
1127 //assert( ! l. IsGreater( l0));
1128 //assert( l1. IsGreater( l0));
1129 //assert( l00.IsGreater( l0));
1130 //assert( l0. IsGreater( l));
1131 //assert( ls1.IsGreater( ls));
1132 QCOMPARE ( ! l0.IsGreater( l1) , Standard_True );
1133 QCOMPARE ( ! l0.IsGreater( l00) , Standard_True );
1134 QCOMPARE ( ! l. IsGreater( l0) , Standard_True );
1135 QCOMPARE ( l1. IsGreater( l0) , Standard_True );
1136 QCOMPARE ( l00.IsGreater( l0) , Standard_True );
1137 QCOMPARE ( l0. IsGreater( l) , Standard_True );
1138 QCOMPARE ( ls1.IsGreater( ls) , Standard_True );
1139
1140 // ==========================
1141 //TCollection_HAsciiString::
1142 // ==========================
1143
1144 // IsDifferent(const Handle(TCollection_HAsciiString)& S)
1145 Handle(TCollection_HAsciiString) ha1 = new TCollection_HAsciiString( theStr+i );
1146 Handle(TCollection_HAsciiString) ha2 = new TCollection_HAsciiString( theStr+i+1 );
1147 //assert( ha1->IsDifferent( ha2 ));
1148 //assert( !ha1->IsDifferent( ha1 ));
1149 QCOMPARE ( ha1->IsDifferent( ha2 ) , Standard_True );
1150 QCOMPARE ( !ha1->IsDifferent( ha1 ) , Standard_True );
1151
1152 // IsSameString (const Handle(TCollection_HAsciiString)& S)
1153 //assert( !ha1->IsSameString( ha2 ));
1154 //assert( ha1->IsSameString( ha1 ));
1155 QCOMPARE ( !ha1->IsSameString( ha2 ) , Standard_True );
1156 QCOMPARE ( ha1->IsSameString( ha1 ) , Standard_True );
1157
1158 // IsSameState (const Handle(TCollection_HAsciiString)& other) const
1159 //assert( !ha1->IsSameState( ha2 ));
1160 //assert( ha1->IsSameState( ha1 ));
1161 QCOMPARE ( !ha1->IsSameState( ha2 ) , Standard_True );
1162 QCOMPARE ( ha1->IsSameState( ha1 ) , Standard_True );
1163
1164 // IsSameString (const Handle(TCollection_HAsciiString)& S ,
1165 // const Standard_Boolean CaseSensitive) const
1166 //assert( !ha1->IsSameString( ha2, true ));
1167 //assert( ha1->IsSameString( ha1, true ));
1168 //assert( !ha1->IsSameString( ha2, false ));
1169 //assert( ha1->IsSameString( ha1, false ));
1170 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1171 QCOMPARE ( ha1->IsSameString( ha1, Standard_True ) , Standard_True );
1172 QCOMPARE ( !ha1->IsSameString( ha2, Standard_False ) , Standard_True );
1173 QCOMPARE ( ha1->IsSameString( ha1, Standard_False ) , Standard_True );
1174
1175 ha1->SetValue( 1, "AbC0000000");
1176 ha2->SetValue( 1, "aBc0000000");
1177 //assert( !ha1->IsSameString( ha2, true ));
1178 //assert( ha1->IsSameString( ha2, false ));
1179 QCOMPARE ( !ha1->IsSameString( ha2, Standard_True ) , Standard_True );
1180 QCOMPARE ( ha1->IsSameString( ha2, Standard_False ), Standard_True );
1181 }
1182 return 0;
1183}
1184
1185#include <Geom_CylindricalSurface.hxx>
1186#include <IntTools_FaceFace.hxx>
1187#include <IntTools_Curve.hxx>
1188#include <IntTools_PntOn2Faces.hxx>
1189
1190static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1191{
1192 if(theNArg < 2)
1193 {
1194 theDI << "Wrong a number of arguments!\n";
1195 return 1;
1196 }
1197
1198 Handle_Geom_Plane plane(new Geom_Plane(
1199 gp_Ax3( gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
1200 gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
1201 gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000))));
1202 Handle(Geom_CylindricalSurface) cylinder(
1203 new Geom_CylindricalSurface(
1204 gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
1205 gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
1206 gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
1207 19.712534607908712));
1208
1209 DrawTrSurf::Set("pln", plane);
1210 theDI << "pln\n";
1211 DrawTrSurf::Set("cyl", cylinder);
1212 theDI << "cyl\n";
1213
1214 BRep_Builder builder;
1215 TopoDS_Face face1, face2;
1216 builder.MakeFace(face1, plane, Precision::Confusion());
1217 builder.MakeFace(face2, cylinder, Precision::Confusion());
1218 IntTools_FaceFace anInters;
1219 anInters.SetParameters(false, true, true, Precision::Confusion());
1220 anInters.Perform(face1, face2);
1221
1222 if (!anInters.IsDone())
1223 {
1224 theDI<<"No intersections found!"<<"\n";
1225
1226 return 1;
1227 }
1228
1229 //Handle(Geom_Curve) aResult;
1230 //gp_Pnt aPoint;
1231
1232 const IntTools_SequenceOfCurves& aCvsX=anInters.Lines();
1233 const IntTools_SequenceOfPntOn2Faces& aPntsX=anInters.Points();
1234
1235 char buf[1024];
1236 Standard_Integer aNbCurves, aNbPoints;
1237
1238 aNbCurves=aCvsX.Length();
1239 aNbPoints=aPntsX.Length();
1240
1241 if (aNbCurves >= 2)
1242 {
1243 for (Standard_Integer i=1; i<=aNbCurves; ++i)
1244 {
1245 Sprintf(buf, "%s_%d",theArgv[1],i);
1246 theDI << buf << " ";
1247
1248 const IntTools_Curve& aIC = aCvsX(i);
1249 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1250 DrawTrSurf::Set(buf,aC3D);
1251 }
1252 }
1253 else if (aNbCurves == 1)
1254 {
1255 const IntTools_Curve& aIC = aCvsX(1);
1256 const Handle(Geom_Curve)& aC3D= aIC.Curve();
1257 Sprintf(buf, "%s",theArgv[1]);
1258 theDI << buf << " ";
1259 DrawTrSurf::Set(buf,aC3D);
1260 }
1261
1262 for (Standard_Integer i = 1; i<=aNbPoints; ++i)
1263 {
1264 const IntTools_PntOn2Faces& aPi=aPntsX(i);
1265 const gp_Pnt& aP=aPi.P1().Pnt();
1266
1267 Sprintf(buf,"%s_p_%d",theArgv[1],i);
1268 theDI << buf << " ";
1269 DrawTrSurf::Set(buf, aP);
1270 }
1271
1272 return 0;
1273}
1274
1275#include <Extrema_FuncExtPS.hxx>
1276#include <math_FunctionSetRoot.hxx>
1277#include <math_Vector.hxx>
1278#include <BRepBuilderAPI_MakeVertex.hxx>
1279static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
1280{
1281 Standard_Integer anArgIter = 1;
1282 if (theNArg < 5)
1283 {
1284 theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]"<<"\n";
1285 return 1;
1286 }
1287
1288 // get target shape
1289 Standard_CString aFaceName = theArgv[anArgIter++];
1290 Standard_CString aVertName = theArgv[anArgIter++];
1291 const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
1292 const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
1293 const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
1294 const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
1295 const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
1296 if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
1297 {
1298 std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
1299 return 1;
1300 }
1301 if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
1302 {
1303 std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
1304 return 1;
1305 }
1306 const TopoDS_Face aFace = TopoDS::Face (aShapeF);
1307 const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
1308 GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
1309
1310 gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
1311
1312 Extrema_FuncExtPS anExtFunc;
1313 math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
1314
1315 math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2);
1316 aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion();
1317 aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite();
1318 aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite();
1319 aFromUV(1) = aUFrom; aFromUV(2) = aVFrom;
1320
1321 anExtFunc.Initialize (aSurf);
1322 anExtFunc.SetPoint (aPnt);
1323 aRoot.SetTolerance (aTolUV);
1324 aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
1325 if (!aRoot.IsDone())
1326 {
1327 std::cerr << "No results!\n";
1328 return 1;
1329 }
1330
1331 theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
1332
1333 aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
1334 DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
1335 return 0;
1336}
1337
1338//! Check boolean operations on NCollection_Map
1339static Standard_Integer OCC24271 (Draw_Interpretor& di,
1340 Standard_Integer /*theArgNb*/,
1341 const char** /*theArgVec*/)
1342{
1343 // input data
1344 const Standard_Integer aLeftLower = 1;
1345 const Standard_Integer aLeftUpper = 10;
1346 const Standard_Integer aRightLower = 5;
1347 const Standard_Integer aRightUpper = 15;
1348
1349 // define arguments
1350 NCollection_Map<Standard_Integer> aMapLeft;
1351 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1352 {
1353 aMapLeft.Add (aKeyIter);
1354 }
1355
1356 NCollection_Map<Standard_Integer> aMapRight;
1357 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aRightUpper; ++aKeyIter)
1358 {
1359 aMapRight.Add (aKeyIter);
1360 }
1361
1362 QCOMPARE (aMapLeft .Contains (aMapRight), Standard_False);
1363 QCOMPARE (aMapRight.Contains (aMapLeft), Standard_False);
1364
1365 // validate Union operation
1366 NCollection_Map<Standard_Integer> aMapUnion;
1367 aMapUnion.Union (aMapLeft, aMapRight);
1368 QCOMPARE (aMapUnion.Extent(), aRightUpper - aLeftLower + 1);
1369 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter <= aRightUpper; ++aKeyIter)
1370 {
1371 QCOMPARE (aMapUnion.Contains (aKeyIter), Standard_True);
1372 }
1373
1374 // validate Intersection operation
1375 NCollection_Map<Standard_Integer> aMapSect;
1376 aMapSect.Intersection (aMapLeft, aMapRight);
1377 QCOMPARE (aMapSect.Extent(), aLeftUpper - aRightLower + 1);
1378 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1379 {
1380 QCOMPARE (aMapSect.Contains (aKeyIter), Standard_True);
1381 }
1382 QCOMPARE (aMapLeft .Contains (aMapSect), Standard_True);
1383 QCOMPARE (aMapRight.Contains (aMapSect), Standard_True);
1384
1385 // validate Substruction operation
1386 NCollection_Map<Standard_Integer> aMapSubsLR;
1387 aMapSubsLR.Subtraction (aMapLeft, aMapRight);
1388 QCOMPARE (aMapSubsLR.Extent(), aRightLower - aLeftLower);
1389 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1390 {
1391 QCOMPARE (aMapSubsLR.Contains (aKeyIter), Standard_True);
1392 }
1393
1394 NCollection_Map<Standard_Integer> aMapSubsRL;
1395 aMapSubsRL.Subtraction (aMapRight, aMapLeft);
1396 QCOMPARE (aMapSubsRL.Extent(), aRightUpper - aLeftUpper);
1397 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1398 {
1399 QCOMPARE (aMapSubsRL.Contains (aKeyIter), Standard_True);
1400 }
1401
1402 // validate Difference operation
1403 NCollection_Map<Standard_Integer> aMapDiff;
1404 aMapDiff.Difference (aMapLeft, aMapRight);
1405 QCOMPARE (aMapDiff.Extent(), aRightLower - aLeftLower + aRightUpper - aLeftUpper);
1406 for (Standard_Integer aKeyIter = aLeftLower; aKeyIter < aRightLower; ++aKeyIter)
1407 {
1408 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1409 }
1410 for (Standard_Integer aKeyIter = aLeftUpper + 1; aKeyIter < aRightUpper; ++aKeyIter)
1411 {
1412 QCOMPARE (aMapDiff.Contains (aKeyIter), Standard_True);
1413 }
1414
1415 // validate Exchange operation
1416 NCollection_Map<Standard_Integer> aMapSwap;
1417 aMapSwap.Exchange (aMapSect);
1418 for (Standard_Integer aKeyIter = aRightLower; aKeyIter <= aLeftUpper; ++aKeyIter)
1419 {
1420 QCOMPARE (aMapSwap.Contains (aKeyIter), Standard_True);
1421 }
1422 QCOMPARE (aMapSect.IsEmpty(), Standard_True);
1423 aMapSwap.Add (34);
1424 aMapSect.Add (43);
1425
1426 NCollection_Map<Standard_Integer> aMapCopy (aMapSwap);
1427 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_True);
1428 aMapCopy.Remove (34);
1429 aMapCopy.Add (43);
1430 QCOMPARE (aMapCopy.IsEqual (aMapSwap), Standard_False);
1431
1432 return 0;
1433}
1434
1435void QABugs::Commands_19(Draw_Interpretor& theCommands) {
1436 const char *group = "QABugs";
1437
1438 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
1439 theCommands.Add ("OCC142", "OCC142", __FILE__, OCC142, group);
1440 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
1441 theCommands.Add ("OCC23237", "OCC23237", __FILE__, OCC23237, group);
1442 theCommands.Add ("OCC22980", "OCC22980", __FILE__, OCC22980, group);
1443 theCommands.Add ("OCC23595", "OCC23595", __FILE__, OCC23595, group);
1444 theCommands.Add ("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
1445 theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
1446 theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
1447 theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
1448 theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
1449 theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
1450 theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
1451 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);
1452 theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group);
1453 theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group);
1454 theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
1455 theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
1456 theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
1457 theCommands.Add ("OCC24271", "Boolean operations on NCollection_Map", __FILE__, OCC24271, group);
1458 return;
1459}